Repository navigation
refactor(unread): one workspace-attention module owns every unread transition - #28538
Conversation
Pins, against the real store, what every unread trigger does today: the workspace flag per host row, the three tab/pane marker maps, persistence calls and payloads, lastActivityAt and sortEpoch bumps, the Dock count and the floating launcher dot. Events are replayed through one driver file so a later rewiring of who writes the state changes only the driver, never these expectations.
…ansition Every write to the workspace unread flag and the tab/pane/completion markers now goes through src/renderer/src/store/slices/workspace-attention: store operations named by the triggering event (bell, agent attention, pane input, viewed-agent auto-ack, manual mark read/unread) and pure transitions folded into other slices' set() calls (activation, tab activation, close, sleep, hibernate, retire, rekey, reconcile, mirror removal, purge, acknowledge). Behaviour, storage, readers, persistence and wire format are unchanged; the characterization suites pass without edits to their expectations.
- Ratchets: moved terminal-tab-attention baseline entries to terminal-tab-appearance; split the characterization setup/observables into an exempt fixture so the driver holds only events. - Removed the test-only writer seam; mocked-store tests assert the event they fire. - The slice owns the experimental pane gate for completions too; groupAttentionEnabled is gone from the attention request and write. - Collapsed marker removals to removeTabsAttention / removePanesAttention / removeCompletionAttention / removeTabMarkers / movePaneAttention; tab activation uses omitRecordKeys. - Mark read/unread is passed in like other store actions; readers of the workspace dot go through isWorkspaceUnread.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…functions module-internal Reverts the reconcile/mirror/activation/focus/group call sites and the isWorkspaceUnread selector to main, removes removeTabMarkers, removeCompletionAttention and the activation read helpers, and drives tests through public attention actions.
ELI5
Orca decides "this needs your attention" (the sidebar unread dot, the Dock count, and tab highlights) in about fifteen scattered places. This PR moves all of them into one module, with no behaviour change, so the follow-up that fixes the unread bugs can change the rules in one place.
What Changed
Nothing changes for users. Same dots, same Dock count, same tab highlights, same saved data and same data sent to other clients.
Before: unread state was written from scattered call sites: the workspace
isUnreadflag (bells, agent completions, keydown, pointerdown, activation, Mark as read/unread) and three marker maps (unreadTerminalTabs,unreadTerminalPanes,unreadAgentCompletionPanes, cleared on close, sleep, hibernate, retire, reconcile, purge and tab activation).After:
src/renderer/src/store/slices/workspace-attention/is the only writer. Its operations are named after the event that triggers them:markTerminalBellandmarkAgentAttentionUnread: something needs attention.readTerminalPaneOnInput: keydown or pointerdown.readViewedAgentAttention: auto-acknowledge on view.setWorkspaceUnreadByUser: Mark as read / Mark as unread.Readers ask
isWorkspaceUnread(row), which today returns the row flag. TheexperimentalTerminalAttentioncheck now lives in the module for both bells and completions, instead of being copied into each dispatcher. The old store actions (markWorktreeUnread,clearWorktreeUnreadand the tab/pane mark/clear actions) are removed, with no forwarding layer.The only non-value difference: hibernating a pane that had no marker now keeps the same marker map objects instead of allocating new ones.
Why
The unread cluster (STA-9043, STA-9273, STA-9361 and others) comes from these writes being scattered and drifting apart: a tab close clears tab markers but not the workspace flag; typing clears the workspace flag but not other tabs' markers. The follow-up PR changes those rules:
Doing that on scattered code would repeat the patch-on-patch pattern of #24877 and #21274. Splitting the move from the rule change keeps each PR reviewable.
I considered making this PR already store per-pane records and derive the workspace flag from them. Staying exactly behaviour-neutral would then have needed temporary state copying today's quirks ("seen" stamps, "held" flags), which the follow-up would delete again. Consolidating first avoids that throwaway state.
Linked Issue
Prepares the fix for STA-9043 and STA-9273 (follow-up PR). No issue is closed by this PR.
Visual Proof
N/A. This is an inert refactor with no visible or behavioural change.
Testing
New characterization suite (
workspace-attention/workspace-unread-characterization*.test.ts, 30 tests), run against the real store. Each step records:lastActivityAt/sortEpoch;Cases cover bells, completions with the experimental setting on and off, activation, typing, closing the only unread tab, sleep/hibernate/retire, Mark read/unread on one of two same-id host rows, inbound refetch, restart, the folder-workspace Dock rule, structured chat close, and the floating-terminal bell.
Proof that nothing changed: the suite landed as the first commit and passes on unchanged main. Its
.test.tsfiles are byte-identical in the later commits.Full
src/renderersuite: 41,522 tests pass, run with--maxWorkers=2.Other checks:
pnpm tc:web,check:code-quality:changed, and both ratchet scripts pass.Reviews: an independent review found no behaviour change.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
persistPassiveWorktreeMetaForOwner/updateFolderWorkspace/updateWorktreeMetacalls with the same payloads. Mixed-version clients and servers see no difference.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)