Skip to content

Fix merge records page accumulating duplicate morph items#17705

Merged
mabdullahabaid merged 4 commits intotwentyhq:mainfrom
rdelassus:codex/fix-merge-records-duplicate-tabs
Feb 11, 2026
Merged

Fix merge records page accumulating duplicate morph items#17705
mabdullahabaid merged 4 commits intotwentyhq:mainfrom
rdelassus:codex/fix-merge-records-duplicate-tabs

Conversation

@rdelassus
Copy link
Copy Markdown
Contributor

@rdelassus rdelassus commented Feb 4, 2026

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

  • Update useCommandMenuUpdateNavigationMorphItemsByPage to replace page morph items instead of appending existing ones.
  • Add regression tests covering:
    • replacing existing morph items for the same page
    • keeping only the latest payload when called twice for the same page

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.json and temporal-polyfill resolution in dependent tasks).

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 4, 2026

Greptile Overview

Greptile Summary

Fixed 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

  • This PR is safe to merge with minimal risk
  • The fix is straightforward and well-tested, changing append behavior to replacement behavior. The logic change is minimal, removing the spread operator that was accumulating items. Comprehensive regression tests verify both replacement scenarios.
  • No files require special attention

Important Files Changed

Filename Overview
packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuUpdateNavigationMorphItemsByPage.tsx Replaced appending logic with replacement logic to fix duplicate IDs bug; removed unused import
packages/twenty-front/src/modules/command-menu/hooks/tests/useCommandMenuUpdateNavigationMorphItemsByPage.test.tsx Added comprehensive regression tests for replacement behavior

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 4, 2026

🚀 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.

@FelixMalfait
Copy link
Copy Markdown
Member

Thanks a lot @rdelassus!

@mabdullahabaid could you please review/test/merge if it looks good? Thank you

Copy link
Copy Markdown
Member

@mabdullahabaid mabdullahabaid left a comment

Choose a reason for hiding this comment

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

Tested. LGTM. Thank you @rdelassus

@mabdullahabaid mabdullahabaid added this pull request to the merge queue Feb 11, 2026
Merged via the queue into twentyhq:main with commit 859241d Feb 11, 2026
63 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫

node failed.

Log

Details
�[31mError: �[39m SyntaxError: Unexpected token 'C', "Contributo"... is not valid JSON
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:4259:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:6882:27)�[39m
�[90m    at readAllBytes (node:internal/deps/undici/undici:5807:13)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)�[39m
danger-results://tmp/danger-results-e3a2b473.json

Generated by 🚫 dangerJS against 19cefb7

@twenty-eng-sync
Copy link
Copy Markdown

Hey @mabdullahabaid! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

1 similar comment
@twenty-eng-sync
Copy link
Copy Markdown

Hey @mabdullahabaid! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants