Skip to content

refactor(unread): one workspace-attention module owns every unread transition - #28538

Merged
Jinwoo-H merged 6 commits into
mainfrom
jinwoo/workspace-attention-module
Oct 14, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
jinwoo/workspace-attention-module

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1496 $\color{#cf222e}{\Huge{\mathbf{−}}}$​380 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1116
Prod 54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​890 $\color{#cf222e}{\Huge{\mathbf{−}}}$​679 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211

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 isUnread flag (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:

  • markTerminalBell and markAgentAttentionUnread: something needs attention.
  • readTerminalPaneOnInput: keydown or pointerdown.
  • readViewedAgentAttention: auto-acknowledge on view.
  • setWorkspaceUnreadByUser: Mark as read / Mark as unread.
  • The activation read.
  • Five removal functions for close, sleep, hibernate, retire, rekey and purge.

Readers ask isWorkspaceUnread(row), which today returns the row flag. The experimentalTerminalAttention check now lives in the module for both bells and completions, instead of being copied into each dispatcher. The old store actions (markWorktreeUnread, clearWorktreeUnread and 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:

  • A pane is read when it is on screen.
  • Closing a tab clears its unread state.
  • The workspace dot is worked out from per-pane records.
  • Reading or closing a pane removes its notifications.

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:

    • the flag per host row;
    • exact persistence payloads;
    • lastActivityAt / sortEpoch;
    • all three marker maps;
    • the Dock count;
    • the floating-terminal dot.

    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.ts files are byte-identical in the later commits.

  • Full src/renderer suite: 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote and SSH: persistence still goes through the same persistPassiveWorktreeMetaForOwner / updateFolderWorkspace / updateWorktreeMeta calls with the same payloads. Mixed-version clients and servers see no difference.
  • Folder workspaces: covered by the characterization suite, including host-scoped activation and the Dock rule.
  • Cross-platform: renderer-only; no platform-specific code.
  • Performance:
    • Per-keystroke clears keep their no-op fast path and reference stability.
    • One extra store subscription per sidebar card, for a stable action reference that never re-renders.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbafcd26-8002-4a5e-82d2-d5a7f7284fe3
📥 Commits

Reviewing files that changed from the base of the PR and between b14ca3b and ad1062d.

📒 Files selected for processing: 9
  • config/focus-setting-read-baseline.txt
  • config/renderer-layout-writer-baseline.txt
  • src/renderer/src/components/native-chat/structured-attention-dispatch.ts
  • src/renderer/src/components/terminal-pane/pty-connection-types.ts
  • src/renderer/src/components/terminal-pane/use-notification-dispatch.test.ts
  • src/renderer/src/components/terminal-pane/use-notification-dispatch.ts
  • src/renderer/src/store/slices/worktrees/teardown/worktree-purge-state.ts
  • src/renderer/src/store/terminals/terminal-state.ts
  • src/renderer/src/store/terminals/terminal-tab-close.ts
💤 Files with no reviewable changes: 1
  • src/renderer/src/store/terminals/terminal-state.ts
🚧 Files skipped from review as they are similar to previous changes: 2
  • config/renderer-layout-writer-baseline.txt
  • config/focus-setting-read-baseline.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The renderer store adds a workspace-attention slice for terminal bells, agent attention, input reads, viewed-agent acknowledgement, and user-controlled workspace unread state. Terminal and agent event paths, sidebar unread controls, and store lifecycle cleanup now use these actions and shared attention-transition helpers. New characterization tests cover unread markers, workspace and folder persistence, badge counts, and no-op updates. The terminal-tab appearance actions are separated from the removed terminal-tab attention module.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ad106

Workspace unread behavior remains consistent when terminal attention is disabled, with no actionable user-facing regression identified; the change appears ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 41.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 61 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: centralizing unread transitions in one workspace-attention module.
Description check Passed The description is complete and focused. It includes the required explanation, change summary, rationale, issue context, visual proof, testing details, review notes, compatibility considerations, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 41.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 61 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H Jinwoo-H closed this Oct 14, 2026
@Jinwoo-H Jinwoo-H reopened this Oct 14, 2026
…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.
@Jinwoo-H
Jinwoo-H merged commit 93baa82 into main Oct 14, 2026
44 checks 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