fix(react): use stable keys for dynamic lists - #6840
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview Patterns introduced: generated Design system: Tests updated for upload-error message mapping and duplicate-error id uniqueness; CustomPatternsEditor test asserts focus preservation when rows are appended/removed. Reviewed by Cursor Bugbot for commit 63337d3. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR replaces positional React keys with stable identities across dynamic lists in the Sim UI, documentation site, and shared component packages.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified. The changed list keys are derived from stable IDs, source positions, or deterministic domain signatures, and the updated component contracts and consumers remain aligned.
|
| Filename | Overview |
|---|---|
| packages/emcn/src/components/tag-input/tag-input.tsx | Makes stable identity part of the TagItem contract and uses it when rendering editable tags. |
| packages/emcn/src/components/chip-modal/chip-modal.tsx | Requires IDs for secondary footer actions and replaces positional fragment keys. |
| apps/sim/components/pii/custom-patterns-editor.tsx | Tracks row identities through local add and remove operations while preserving controlled pattern values. |
| apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx | Derives option-group keys from block and option identity instead of render position. |
| apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx | Assigns content-derived identities to inline and special-tag render groups during streaming. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/hooks/use-chat-file-upload.ts | Gives each upload error a generated identity so duplicate messages reconcile independently. |
Reviews (1): Last reviewed commit: "fix(react): use stable keys for dynamic ..." | Re-trigger Greptile
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 63337d3. Configure here.
| index, | ||
| pattern, | ||
| } | ||
| }) |
There was a problem hiding this comment.
Pattern fallback keys change while editing
Medium Severity
When patternIds is shorter than patterns (parent append, or ids not updated), row identity falls back to name, regex, and replacement. Editing those fields changes the React key, so the row remounts and the input loses focus and in-progress text.
Reviewed by Cursor Bugbot for commit 63337d3. Configure here.


Summary
Dynamic lists now keep each row's identity through duplicate values, deletion, filtering, and redaction-stage changes. This prevents focus, entered text, or submitted data from moving to the wrong row after React reconciles a changed list.
This is stack PR 2 of 3. It depends on #6839 and is followed by #6841.
Type of Change
Testing
npx react-doctor@latest --verbose: 3,488 findings;no-array-index-as-keyis 0@sim/app,@sim/emcn,@sim/workflow-renderer, anddocsChecklist
Screenshots/Videos
Not captured. The behavior is covered by focused tests that add, remove, and rerender controlled rows.
Post-Deploy Monitoring & Validation