Skip to content

fix(dock): clear stale workspace unread counts - #24877

Merged
nwparker merged 4 commits into
stablyai:mainfrom
AmoabaKelvin:fix/dock-badge-matches-sidebar-unread
Oct 6, 2026
Merged

nwparker merged 4 commits into
stablyai:mainfrom
AmoabaKelvin:fix/dock-badge-matches-sidebar-unread

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​373 $\color{#cf222e}{\Huge{\mathbf{−}}}$​61 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​312
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65

ELI5

The number on Orca's Dock icon should mean "this many workspaces have something new". It could say 1 while no workspace in the sidebar had an unread dot, so there was nothing to click to make it go away. The Dock now clears those stale counts when the workspace is visited, without clearing the tab highlight.

What Changed

Before: a terminal bell in workspace W lit W's sidebar dot and set the Dock to 1. Clicking W, or typing in another tab of W, cleared the dot but left the Dock at 1 until you clicked or typed in the exact tab that rang. A marked agent chat tab made its workspace count twice.

After: the Dock counts:

  • git worktrees whose unread flag is set, skipping archived ones, ones on a host the sidebar isn't showing, and ones hidden by the other-device filter. The same workspace id on two hosts still counts once, preserving the existing deduplication.
  • folder workspaces whose unread flag is set, that own a live marked terminal or chat tab, and that pass the sidebar's host, hide-other-devices and project-group checks. This preserves existing folder bell notifications without adding counts for flag-only folders.
  • the floating terminal, only while its launcher shows the unread dot (feature on, panel closed).

A bell in a background tab still highlights that tab in its workspace's tab strip. It no longer holds the Dock on its own.

Mechanism: Git worktrees contribute through their unread workspace flag. Folder workspaces require both that flag and a marked tab owned by the live workspace. Orphan markers contribute nothing, multiple marked tabs in a folder count once, and clearing the workspace flag clears its Dock contribution. Host and folder membership use the sidebar's existing functions. The App subscribes to a cached integer; folder title changes do not invalidate that count.

Why

A count the sidebar can't explain is the bug. Alternatives considered:

  • Keep the workspace flag lit while any tab is still marked. The flag is shared and has other writers (phone and web clients, the host, a restart) that know nothing about the desktop's tab markers, so the two drift apart again.
  • Only drop markers that match no tab (the suggestion in the issue). That leaves the common case, a live marked tab in a workspace you already visited.

The scope stays narrow: clear stale Dock counts without changing how tab highlights are stored or cleared. Existing folder notifications stay available.

Linked Issue

Fixes #23363

Visual Proof

N/A: the Dock icon is drawn by macOS outside the app window, and I have no before/after capture of it.

Testing

  • New store-level tests drive the real actions for each route (bell then visit, bell in a sibling tab, marked chat tab, folder workspace, archive in place, same id on two hosts, and a sidebar scoped to the local host with an unread SSH folder workspace or a two-host workspace). They fail on main with the Dock at 1 or 2 where the sidebar shows 0 or 1.

  • Hook tests cover the floating terminal with the panel closed, open, and the feature off, plus worktree and folder title frames that do not re-render the App root.

  • A migration test compares the workspace count against the old count across 256 flag/owner/marker combinations, each with 32 host, group (including collapsed), and device-policy combinations. The new count never exceeds the old count.

  • Latest combined head: 140 tests across 14 suites passed, along with the official renderer and main-process typechecks, changed-code quality gate and standalone React Doctor. A shared main-branch integration repair restores the journal test's required provider-handle import; its five tests passed too. The shared Windows startup-prompt expectation repair adds a test for one physical escaped command line; 40 startup tests passed. Released-snapshot compatibility also retains its exact parser dependency as dev-only; 10 release-checkout helper tests passed.

  • 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 follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: the count is computed everywhere; only macOS applies it (unchanged).
  • SSH/remote: same persisted flag for local and SSH workspaces. No IPC, RPC or stored-data change.
  • Performance: the App selects a cached integer. Worktree attention ignores tab markers; unread folders compare only the presence of a live owned marker. Title frames do not trigger count rescans or App renders. Runtime-state invalidation remains gated by the existing hide-other-devices setting.
  • Existing visibility limitations remain in [Bug]: Dock counts unread workspaces that show no unread dot (hidden while working, kept after the finished terminal closes) #24193: working/permission cues can suppress a dot, collapsed groups can hide rows, and worktree view filters such as repo or sleeping-workspace filters are not applied by this count. This PR does not add workspace counts in those states relative to the previous implementation; it removes stale and orphan contributions.

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)

@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 2, 2026 20:22

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the single commit 012c0f6 reviewed end to end (7 files, +278/−104).

  • The Dock count now reads workspace flags only — src/renderer/src/lib/unread-badge-count.ts: drops the tab-marker scan entirely and counts unread, non-archived worktrees (deduped by getWorktreeHostIdentity, so a repo::path id on two hosts counts as two rows) plus unread folder workspaces.
  • Floating terminal counted via its launcher dot — src/renderer/src/hooks/useUnreadDockBadge.ts: new floatingTerminalOpen arg adds 1 while floatingTerminalEnabled && selectFloatingWorkspaceHasUnread(s) and the panel is closed, matching FloatingTerminalToggleButton.showAttentionDot and the status-bar dot (both !open && hasUnread).
  • Cache projection narrowed — createUnreadBadgeCountSelector now keys on the worktree projection (id/hostId/isUnread/isArchived) plus folderWorkspaces array identity, instead of tabsByWorktree/unreadTerminalTabs.
  • Tests — store-level tests drive real actions (bell then visit, sibling tab, unified chat tab, folder workspace, archive in place, same id on two hosts); the hook test covers the floating terminal with the panel open/closed and the feature off.

The load-bearing premise checks out: the sidebar dot is driven purely by Worktree.isUnread (WorktreeCardStatusSlot.tsx:231), folder rows render through folderWorkspaceToWorktree → WorktreeCard so FolderWorkspace.isUnread is the same signal, and every producer (bell, structured completion, manual toggle, activation) writes that flag. Folder workspaces are deliberately not archive-filtered by the sidebar (getRenderableFolderWorkspaces), so counting archived folder flags is parity rather than an oversight. Tests are meaningful — each selector case produces a different Dock number on main than after the change.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 2, 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: 92f7dcb3-38e7-4bcd-bcfa-a1a1110f4fd4
📥 Commits

Reviewing files that changed from the base of the PR and between a47e0f5 and 0bcd08b.

📒 Files selected for processing (8)
  • src/renderer/src/App.tsx
  • src/renderer/src/hooks/useUnreadDockBadge.test.ts
  • src/renderer/src/hooks/useUnreadDockBadge.ts
  • src/renderer/src/lib/unread-badge-count-migration.test.ts
  • src/renderer/src/lib/unread-badge-count-selector.test.ts
  • src/renderer/src/lib/unread-badge-count-selector.ts
  • src/renderer/src/lib/unread-badge-count.test.ts
  • src/renderer/src/lib/unread-badge-count.ts

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


📝 Walkthrough

Walkthrough

Unread badge counting now reflects visible unread worktrees and qualifying folder workspaces, with host and device visibility filters. The selector recalculates when count-relevant state changes. The Dock hook also counts an unread floating terminal when its launcher is enabled and the panel is closed.

Priority: ➖ Normal

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 0bcd0

No actionable badge-count issue remains established; the change is mergeable after normal checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to f4ac3

The change adjusts which unread activity contributes to the Dock badge. The reviewed flow sends only a numeric count and does not grant access to workspaces, hosts, or their contents. No material security risk was found in this change.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Activity represented in renderer unread state can influence the application's aggregate Dock label. In the inspected path, this influence does not select a remote operation, expose workspace contents, or change host privileges.

Trust Boundaries and Controls

  • observed — The existing renderer-to-main Dock operation accepts a numeric count. Main rejects nonfinite values, truncates and clamps the count to nonnegative values, and renders an empty, numeric, or 99+ label on macOS. Host visibility helpers constrain display membership, not authorization.
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning For [#23363], the new count excludes orphan tab markers and requires a live owned marker for unread folder workspaces. It also filters archived worktrees and host/device visibility. However, the count… Make the Dock count match the unread indicators the sidebar actually displays for worktrees, including cue-suppressed and filtered rows, or otherwise prevent those hidden worktrees from contributing. Add regression tests for these cases.
Out of Scope Changes check ⚠️ Warning The Dock selector, hook, App wiring, and related tests support [#23363]. The PR description also reports a journal-test provider-handle import repair, a Windows startup-prompt test repair, and a relea… Remove the journal-test, Windows startup-prompt, and released-snapshot compatibility repairs from this PR or move them to a separate change.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: clearing stale workspace unread counts from the Dock badge.
Description check ✅ Passed The description covers the required sections, explains the user-facing change and approach, links issue #23363, gives a reason for the visual-proof exception, and summarizes testing. The general lint,…
Full details: Linked Issues check

Explanation

For [#23363], the new count excludes orphan tab markers and requires a live owned marker for unread folder workspaces. It also filters archived worktrees and host/device visibility. However, the count can still include unread worktrees whose sidebar dot is suppressed by working or permission cues or worktree view filters. The PR description confirms these cases remain, so the Dock can still show a count with no findable indicator.

Full details: Out of Scope Changes check

Explanation

The Dock selector, hook, App wiring, and related tests support [#23363]. The PR description also reports a journal-test provider-handle import repair, a Windows startup-prompt test repair, and a released-snapshot parser dependency change. These do not affect Dock unread counting and have no demonstrated connection to [#23363].

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@nwparker
nwparker force-pushed the fix/dock-badge-matches-sidebar-unread branch from 012c0f6 to 7adb205 Compare October 5, 2026 05:46

@nwparker nwparker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dock badge derives the same visible workspace unread dots, including folder/remote identity and archived/floating policy. Narrow stable selectors keep unrelated terminal activity from rerendering shell. 18 tests and web typecheck pass.

Required PR Checks verify passed on this exact commit: 7adb205385fdd1fc767fd9cbb5352a04cac4f616.

@nwparker nwparker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The orphan tab-marker fix is sound, but this head introduces another unfindable Dock count through its expanded workspace counting.

At head 7adb205385fdd1fc767fd9cbb5352a04cac4f616, take one unread SSH folder workspace, no unread tab markers, and select only the local host in the sidebar. The baseline count is 0; this PR changes it to 1, while the existing sidebar host filter renders 0 folder rows. I reproduced those outputs using the exact baseline/head count functions and the head's existing filterFolderWorkspacesForVisibleHosts function. The new unconditional folder loop is unread-badge-count.ts:33; the sidebar excludes that host at host-filtering.ts:49. Similarly, two unread same-id worktrees on local and SSH hosts now count 2 instead of 1, even when only one host is visible.

CodeRabbit's visibility warning therefore includes a newly introduced case, beyond the existing working-agent cue issue tracked in #24193. Before merging, make newly counted folder/host rows follow the existing sidebar visibility policy, or keep this change narrowly scoped to removing stale tab-marker contributions. Add a regression for the local-only sidebar/unread SSH folder case and preserve the existing render-isolation tests so the fix does not wake the App root for unrelated terminal updates.

The bot's separate 80% docstring warning does not warrant boilerplate: this repository requires concise non-obvious comments, and the changed mechanisms explain their rationale. CI and the scoped tests passed this exact head, but they do not cover the filtered-folder regression above.

@AmoabaKelvin
AmoabaKelvin force-pushed the fix/dock-badge-matches-sidebar-unread branch from 7adb205 to f4ac358 Compare October 5, 2026 23:45
@AmoabaKelvin
AmoabaKelvin requested a review from nwparker October 5, 2026 23:50

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The new commit makes both row types follow the sidebar's host filter, but the sibling "hide workspaces from other devices" filter is applied only to folder workspaces. An unread worktree hidden by that toggle still lights the Dock — the same unfindable-count class this PR fixes.

Reviewed changes — the delta since the prior pullfrog review (7adb205 → f4ac358): the count now derives from the sidebar's visibility pipeline.

  • Worktree and folder counts follow the sidebar host filter — getUnreadBadgeCount now takes a sources object and drops archived worktrees plus any row whose execution host is not in the visible set; folder rows additionally run through the same host/group/device steps the sidebar uses before building rows (filterFolderWorkspacesForVisibleHosts → filterFolderWorkspacesFromOtherDevices → getRenderableFolderWorkspaces with filterProjectGroupsForVisibleHosts).
  • Cache key reads the new inputs — createUnreadBadgeCountSelector replaced the tab-map projection with sameCountInputs: folder/group/repo/scope identities, focused execution host, and runtime env+status gated on the other-device toggle.
  • Tests — new cases cover an SSH folder hidden until its host is shown, a repo/project-group host change recounting, and one id on two hosts counted once per shown host.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker nwparker changed the title fix(dock): count only the unread the app shows fix(dock): clear stale workspace unread counts Oct 6, 2026
@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Addressed the reproduced host-filter/folder-count concern on 4c1785d4533f25dae66d0079dd20f0490b8c04b3, preserving Kelvin's concurrent f4ac358 host/device/group membership fix.

  • Git worktree IDs keep the existing deduplication across hosts. Showing a second same-ID host no longer introduces an extra Dock count.
  • Folder notifications require an unread workspace flag plus an unread marker owned by a live terminal or chat tab. Existing folder bells remain available; flag-only folders and orphan markers cannot add a count. Visiting the workspace clears its contribution, and sibling markers count the folder once.
  • The workspace count is bounded by the old implementation. The regression proof covers 256 flag/owner/marker combinations with 32 host/group/device-policy combinations, including collapsed and missing groups. Existing working/permission cue and other view-filter gaps remain tracked in [Bug]: Dock counts unread workspaces that show no unread dot (hidden while working, kept after the finished terminal closes) #24193; the title and description now state this narrower scope.

Validation: 88 tests across 11 suites, official renderer typecheck, changed-code quality, and standalone React Doctor passed. Worktree and folder title-frame tests prove no App render or count-rescan churn. The shared duplicate journal import CI repair was reused and its focused tests passed. Fresh CI is required for this exact head before approval or merge.

@nwparker
nwparker force-pushed the fix/dock-badge-matches-sidebar-unread branch from 4c1785d to 8dc23ee Compare October 6, 2026 00:24

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (f4ac358 → 5cec080; the branch was rewritten, so this range-diff covers the whole series). The prior inline concern — worktree rows ignoring the other-device filter — is addressed.

  • Folder rows now require a live owned marked tab — getUnreadBadgeCount counts an unread folder only when hasUnreadFolderTab finds a marked terminal tab or agent-session unified tab under folder:<id>, so flag-only folders and orphan markers no longer contribute; rows are deduped by folder id.
  • Worktree rows honor the other-device filter — the worktree loop now drops rows hidden by "Hide workspaces from other devices" via isWorkspaceFromOtherDevice, matching the folder branch and computeVisibleWorktrees.
  • Deduplication reverts to id-only — same-id rows on two hosts count once again (main's behavior) instead of once per shown host.
  • Selector cache tracks the new inputs — sameBadgeWorktree compares creator provenance and runtime owner; sameFolderAttention re-derives folder contributions when the tab maps change.
  • Migration + hook coverage — new unread-badge-count-migration.test.ts asserts the new count never exceeds the old across 8,192 flag/owner/marker × host/group/device combinations; the hook test adds folder title frames and floating-terminal open/closed/off.
  • Shared test repairs — restored the journal test's codexProviderHandle import and updated the Windows startup-prompt test for the encoded physical launch line.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the delta since the prior pullfrog review (5cec080 → 4c724e1):

  • Retained the released journal parser as a test-only dependency — @streamparser/[email protected] added to devDependencies with the matching pnpm-lock.yaml importer/package/snapshot entries, and a comment in tests/e2e/cross-version-wire/release-checkout.ts records why: extracted release sources still import it, so the cross-version harness needs it resolvable from the repo root.

The dependency is not imported anywhere under src/, so it stays test-only, and the lockfile importer entry matches package.json. No production code changed. (The release-checkout helper suite itself needs release tags and writable git refs, which this shallow review checkout lacks, so those cases cannot run here — the failure is environmental, not from this commit.)

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

AmoabaKelvin and others added 4 commits October 5, 2026 18:45
Tab markers outlive the workspace unread flag, so the badge could
sit at 1 with no sidebar dot to find or clear.

Fixes stablyai#23363
Counting folder workspaces and per-host rows by flag put rows on the
Dock that a host-scoped sidebar does not show.
@nwparker
nwparker force-pushed the fix/dock-badge-matches-sidebar-unread branch from 4c724e1 to 0bcd08b Compare October 6, 2026 01:47
@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai resume

@coderabbitai review

Please review the current head 0bcd08b43058bc769b3594f094efd88cb3ca52c9. The rebase retains all four Dock changes unchanged and uses main's stronger Windows test; 207 focused tests and official web/node types pass.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai full review

Please review the current rebased head 0bcd08b43058bc769b3594f094efd88cb3ca52c9. The incremental command reported an already-reviewed prior commit.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@nwparker nwparker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Low merge risk after the final repairs. Workspace unread counts require a live owned unread marker and respect host/device policy. The repair preserves legitimate folder alerts and baseline worktree deduplication. 207 focused integration tests, both typechecks, and quality gates pass. The full PR Checks workflow and all runnable CI on this exact head have passed, and review findings are addressed. Pullfrog was manually disabled repository-wide and its integration-review run cancelled; the stale pending bot check is documented. The feature code is unchanged from its completed bot-reviewed state, and this integration was reviewed manually.

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.

[Bug]: macOS Dock badge sticks at 1 with no findable unread

2 participants