Fix merge records page accumulating duplicate morph items#17705
Fix merge records page accumulating duplicate morph items#17705mabdullahabaid merged 4 commits intotwentyhq:mainfrom
Conversation
Greptile OverviewGreptile SummaryFixed a bug where repeatedly opening the Merge Records page accumulated duplicate morph items instead of replacing them. The hook now correctly replaces existing morph items for a given page ID, preventing duplicate record IDs and extra duplicate tabs in the UI. Added comprehensive regression tests to ensure the replacement behavior works correctly. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant MergeUI as Merge Records UI
participant Hook as useOpenMergeRecordsPageInCommandMenu
participant UpdateHook as useCommandMenuUpdateNavigationMorphItemsByPage
participant State as commandMenuNavigationMorphItemsByPageState
participant Nav as navigateCommandMenu
User->>MergeUI: Click "Merge Records"
MergeUI->>Hook: openMergeRecordsPageInCommandMenu()
Hook->>Hook: Generate new pageId (UUID)
Hook->>UpdateHook: updateCommandMenuNavigationMorphItemsByPage({pageId, objectMetadataId, objectRecordIds})
Note over UpdateHook: OLD: Appended to existing items<br/>NEW: Replaces existing items
UpdateHook->>State: Get current morph items Map
UpdateHook->>UpdateHook: Map objectRecordIds to MorphItems
UpdateHook->>State: Set new Map with pageId → newMorphItems
Hook->>Hook: Fetch records from API
Hook->>Hook: Upsert records in store
Hook->>Nav: Navigate to MergeRecords page
Nav->>User: Display Merge Records page with correct items
|
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:64466 This environment will automatically shut down when the PR is closed or after 5 hours. |
|
Thanks a lot @rdelassus! @mabdullahabaid could you please review/test/merge if it looks good? Thank you |
LogDetails |
|
Hey @mabdullahabaid! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
1 similar comment
|
Hey @mabdullahabaid! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
Why
When opening Merge records repeatedly, morph items for the same command-menu page were appended instead of replaced. This could produce duplicated IDs (e.g.
[A,B,B,A]) in the merge flow and extra duplicate tabs in the UI.What
useCommandMenuUpdateNavigationMorphItemsByPageto replace page morph items instead of appending existing ones.Notes
I could not run the full workspace tests locally in this environment because of existing test/build setup issues unrelated to this change (missing
packages/twenty-front/tsconfig.spec.jsonandtemporal-polyfillresolution in dependent tasks).