Skip to content

chore(web): use stable keys for mapped lists#593

Open
grzdev wants to merge 1 commit intoaccomplish-ai:mainfrom
grzdev:chore/web-stable-react-keys
Open

chore(web): use stable keys for mapped lists#593
grzdev wants to merge 1 commit intoaccomplish-ai:mainfrom
grzdev:chore/web-stable-react-keys

Conversation

@grzdev
Copy link

@grzdev grzdev commented Feb 21, 2026

Description

Replaces "key={index}" usage with stable, content-based keys in "Home.tsx" and "DebugPanel.tsx".

Using array indices as keys can cause React reconciliation issues when items are reordered or dynamically updated. This change uses stable identifiers derived from content instead.

No functional behavior changes.

Type of Change

  • feat: New feature or functionality
  • fix: Bug fix
  • docs: Documentation only changes
  • chore: Maintenance, dependencies, or tooling
  • refactor: Code refactoring (no feature change)
  • test: Adding or updating tests
  • perf: Performance improvement
  • ci: CI/CD changes

Checklist

  • PR title follows conventional commit format (e.g., feat: add dark mode support)
  • Changes have been tested locally
  • Any new dependencies are justified

Related Issues

No related Issues.

Summary by CodeRabbit

  • Refactor
    • Improved rendering stability in the debug panel's highlight segments and log list.
    • Enhanced reliability of use case example list rendering on the home page.

@orcaman
Copy link
Contributor

orcaman commented Feb 21, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Warning

Rate limit exceeded

@grzdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 12 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

React list rendering keys are being updated from simple numeric indices to composite identifiers in two components. DebugPanel uses timestamp-type-index combinations for log rows and part-index composites for highlights, while Home.tsx applies the use case example's key property to its rendered list.

Changes

Cohort / File(s) Summary
Debug Panel Key Stabilization
apps/web/src/client/components/execution/DebugPanel.tsx
Highlight segment keys changed from simple index to composite ${i}-${part} format; log row keys updated from numeric index to ${log.timestamp}-${log.type}-${index} composite key.
Use Case Examples List Keying
apps/web/src/client/pages/Home.tsx
Added key property to use case objects within useCaseExamples and replaced list rendering key from array index to example.key.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Old indices danced and swayed,
Keys were tangled, chains unmade,
Now composite identifiers reign,
React renders without strain,
Stability and peace remain! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(web): use stable keys for mapped lists' directly and concisely summarizes the main change: replacing array index keys with stable, content-based keys in React list rendering across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/src/client/components/execution/DebugPanel.tsx (1)

266-268: Composite key improves stability but retains index dependency.

The key ${log.timestamp}-${log.type}-${index} is an improvement over a bare index. However, since index is derived from filteredDebugLogs, when the search query changes, the same log entry may receive a different key (e.g., if it shifts from position 5 to position 2 in filtered results).

If DebugLogEntry had a unique id field, using log.id alone would provide fully stable keys across filter changes. For now, this implementation is acceptable since the timestamp-type prefix provides partial stability within consistent filter states.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/client/components/execution/DebugPanel.tsx` around lines 266 -
268, The current key for items in the filteredDebugLogs map uses the index
(`key={`${log.timestamp}-${log.type}-${index}`}`), which can change when
filters/searches reorder results; update the mapping to use a stable unique
identifier instead—add an `id` field to the DebugLogEntry type and populate it
when logs are created/loaded, then use `log.id` as the React key in the map
(fallback: if you cannot add ids right now, remove the index and use the stable
composite `\`${log.timestamp}-${log.type}\`` to reduce churn); update references
in the component where filteredDebugLogs is iterated to use the new `log.id`
key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/src/client/components/execution/DebugPanel.tsx`:
- Around line 266-268: The current key for items in the filteredDebugLogs map
uses the index (`key={`${log.timestamp}-${log.type}-${index}`}`), which can
change when filters/searches reorder results; update the mapping to use a stable
unique identifier instead—add an `id` field to the DebugLogEntry type and
populate it when logs are created/loaded, then use `log.id` as the React key in
the map (fallback: if you cannot add ids right now, remove the index and use the
stable composite `\`${log.timestamp}-${log.type}\`` to reduce churn); update
references in the component where filteredDebugLogs is iterated to use the new
`log.id` key.

@grzdev grzdev force-pushed the chore/web-stable-react-keys branch from 8f55620 to 096680b Compare February 21, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants