Skip to content

refactor: move selectedRowIndices to @Observable GridSelectionState on coordinator#914

Merged
datlechin merged 1 commit into
mainfrom
fix/selection-state-isolation
Apr 27, 2026
Merged

refactor: move selectedRowIndices to @Observable GridSelectionState on coordinator#914
datlechin merged 1 commit into
mainfrom
fix/selection-state-isolation

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

selectedRowIndices was a @State var on MainContentView (the top-level view). Every row click invalidated MainContentView.body, cascading re-renders through sidebar (186 samples in profiler) and inspector.

Now lives in GridSelectionState (@Observable class) on MainContentCoordinator. Only views that actually read .indices re-render (DataGrid, status bar, inspector). MainContentView.body passes the reference without reading .indices — zero invalidation.

  • @State var selectedRowIndices removed from MainContentView
  • GridSelectionState added to MainContentCoordinator
  • All coordinator methods (handleSort, addNewRow, undoInsertRow, etc.) read/write selectionState.indices directly instead of accepting inout Set<Int>
  • MainContentCommandActions uses GridSelectionState directly instead of Binding<Set<Int>>
  • Inspector update debounced 50ms via scheduleInspectorUpdate()
  • 15 files changed, net -81 lines

Test plan

  • Click rows rapidly with inspector open — verify no jank
  • Arrow key navigation — verify smooth
  • Double-click to edit — verify no delay
  • Sort column — verify selection adjusts correctly
  • Add new row — verify selection moves to new row
  • Undo insert — verify selection adjusts
  • Tab switch — verify selection persisted and restored
  • Multi-select with Shift+Click — verify works
  • Inspector shows correct row data after selection
  • Status bar shows correct "X of Y rows selected"

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38769a3ccc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Libs Outdated
@@ -0,0 +1 @@
/Users/ngoquocdat/Projects/TablePro/Libs No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0 Badge Revert absolute symlink for Libs

This change replaces the repository’s Libs directory with a symlink to /Users/ngoquocdat/Projects/TablePro/Libs, which is a machine-local absolute path. On CI and every other developer machine that path will not exist, so required bundled libraries under Libs/ are no longer present in the checkout and builds become non-reproducible or fail outright. Libs needs to remain project-relative content (or a proper submodule), not a user-specific symlink.

Useful? React with 👍 / 👎.

@datlechin datlechin force-pushed the fix/selection-state-isolation branch from 38769a3 to 55e34fa Compare April 27, 2026 13:36
@datlechin datlechin force-pushed the fix/selection-state-isolation branch from 55e34fa to 9dd96d1 Compare April 27, 2026 13:41
@datlechin datlechin merged commit edd9497 into main Apr 27, 2026
1 check passed
@datlechin datlechin deleted the fix/selection-state-isolation branch April 27, 2026 13:42
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.

1 participant