Skip to content

perf(store): decouple coarse subscriptions with fine-grained selectors - #3803

Open
Raing5Days wants to merge 1 commit into
GCWing:mainfrom
Raing5Days:perf/store-selector-opt
Open

Raing5Days wants to merge 1 commit into
GCWing:mainfrom
Raing5Days:perf/store-selector-opt

Conversation

@Raing5Days

Copy link
Copy Markdown
Contributor

Summary of Changes

  • Targeted selector subscriptions: Replaced coarse global \ lowChatStore.subscribe(notify)\ invocations across core consumers with fine-grained \subscribeSelector\ hooks:
    • \useSessionTerminalDirectory: Now only triggers notifications when the evaluated \�ctiveSessionTerminalDirectory(workspaceId)\ result changes, instead of on every token streaming chunk in any session.
    • \useActiveSessionState: Only wakes up when the active session entity reference or the specific scoped session changes in the store, and filters global state machine broadcasts to only the active session.
    • \useSessionTabLabels: Selects on \state.sessions\ Map identity rather than waking on unrelated flow store mutations.
    • \ContentCanvas\ and \AuxPane: Directly select \s => s.activeSessionId\ to eliminate re-rendering when background sessions update or stream.

Verification

  • Unit tests:
    • \useSessionTerminalDirectory.test.ts: 5/5 passed.
    • \useSessionTabLabels.test.tsx: 2/2 passed.
    • \ContentCanvas.test.tsx: 5/5 passed.
    • \VirtualMessageList.resize.test.tsx\ (12/12 passed) and full \src/app/hooks/\ (87/87 passed).
    • \FlowChatStore.test.ts: All tests passed.

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