Skip to content

fix(sidebar): distinguish sleeping workspaces in the new card style - #21540

Merged
nwparker merged 2 commits into
stablyai:mainfrom
mmarabel:mmarabel/bug-new-worktree-card-style-makes-completed-but
Sep 19, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
mmarabel:mmarabel/bug-new-worktree-card-style-makes-completed-but

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

In the new sidebar card style, a workspace that had finished its work and a workspace that had gone to sleep looked exactly the same. This PR gives sleeping workspaces a moon icon and dims the row, so you can tell at a glance which ones are still awake.

What Changed

Before: with the experimental new worktree card style on, every quiet workspace — active, finished, or asleep — rendered the same branch/PR glyph in the status lane. A completed-but-awake card and a sleeping card were pixel-identical, so the only way to tell them apart was to open them.

After: a sleeping workspace shows a moon in the status lane (with a Sleeping label for screen readers) and its row is dimmed. Awake workspaces keep the branch or PR glyph exactly as before, and the legacy card style is untouched.

Two mechanisms:

  1. Sleep is keyed on runtime liveness, not status. useIsSleepingWorktree treats a workspace as asleep when it has no live PTY, no browser tabs, and no fresh agent activity. Status alone is wrong here: a slept workspace keeps its retained done rows, so it still reports done — which is exactly why the two states collapsed together. The hook calls isInactiveWorkspace — the same predicate the hide-sleeping filter decides with, including its SSH-gap protection — so the moon and that filter cannot drift apart. The filter's live-agent set is cached per store generation, so adding the hook does not make every card rescan the agent-status map.

  2. The dim redefines theme tokens, it does not paint over the card. On the sleeping row, --foreground, --muted-foreground, --muted and --border are re-derived as an oklab mix of --worktree-sidebar-foreground into --worktree-sidebar. Because those are the same two anchors every other sidebar token is built from, the dim scales with whatever theme, tint, or custom background the user has set, and descendants inherit it through the tokens they already use.

Why

The status lane in the new card style is the only place a workspace's state is visible, and it was reporting the same thing for two states a user acts on differently. Colour alone would not fix it — the legacy green/grey dots are unreadable for colourblind users, and moving to shape plus dim is what the new style was for.

Alternatives considered for the dim, and why they were rejected:

  • opacity on the row. Opacity dims toward whatever is painted behind the card. On a near-black custom background it collapsed to almost nothing, and on a lighter sidebar the same alpha is a much smaller perceptual step, so the cue faded exactly where it was needed.
  • A bg-sidebar/NN veil. Same failure, more sharply: when the card already sits on the sidebar colour, painting the sidebar colour over it is a no-op.
  • backdrop-grayscale / saturate. Readable, but it strips hue, so a custom-themed sidebar lost its colour on sleeping rows.

The oklab token mix is a fixed perceptual step rather than a backdrop-dependent one, so it holds on black, on a tinted sidebar, and on light themes, and it keeps themed hues. Measured in a blue-tinted sidebar: awake title 8.91:1 contrast, sleeping title 2.93:1 — clearly de-emphasised, still readable.

The amber unread badge is outside that token family, so an unread sleeping workspace stays noticeable without a z-index workaround.

Linked Issue

Fixes #19624

Related to #20807 — that issue asks for sleep to be legible rather than invisible, and lists "no dimmed asleep state" as its first problem. This PR delivers that affordance at the workspace level in the sidebar. It does not close #20807, which also covers the pane-level slept notice and making the Agent sleep setting discoverable outside Settings → Experimental.

Visual Proof

Before (left): in the new card style, an awake workspace and a sleeping one render identically — same branch glyph, same brightness.

After (right): the sleeping workspace shows a moon and a dimmed row. Shown across three sidebar appearances — a tinted dark theme, a near-black custom background, and the default dark theme — to show the dim holds its strength on each rather than washing out.

Sleeping versus awake worktree cards, before and after

Testing

Manually tested on macOS in a real Orca window against several sidebar appearances: default dark, a near-black custom background, a light theme, and a green custom terminal-matched theme. Verified that a sleeping workspace reads as dimmed with a moon in every one, that awake workspaces are unchanged, that the legacy card style still shows its green/grey dots, and that controls on a dimmed card still respond.

Automated:

  • use-worktree-sleep-state.test.tsx — the liveness verdict, including a retained-done workspace with no runtime resolving as sleeping, and the SSH-gap case.
  • WorktreeCardStatusSlot.test.tsx — sleeping beats both the branch and PR lanes, an awake done workspace with a branch identity still renders the branch glyph, and Sleeping · Unread is announced.
  • WorktreeCard.affiliate-list-mode.test.tsx — the dim wrapper is present only for sleeping workspaces in the new style, absent when awake and in legacy, and carries no opacity or filter class.
  • worktree-card-active-style.test.ts — pins the CSS rule to oklab and the two theme anchors, so a future edit cannot silently reintroduce a backdrop-dependent dim.

pnpm typecheck, the changed-code quality gate, and the sidebar suites (307 files, 2596 tests) pass locally.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude Opus 4.5.

Review

Cross-platform: renderer-only, CSS and React; no platform branches, paths, or shortcuts involved.

SSH and remote: the sleep verdict reuses the existing liveness helpers, which already treat loss of contact with an SSH host as unverifiable rather than dead, so a reachability gap cannot make a live remote workspace render as asleep.

Agents, integrations, git providers: provider-neutral. The branch and PR lanes are unchanged, and the sleeping state takes precedence over both without inspecting the provider.

Performance: the hook reads the same store slices the card already subscribes to, through the existing selector cache, with no new subscriptions or timers. The dim is static CSS with no filter or backdrop work, so it does not add a compositing layer.

UI quality: styling uses theme tokens only, with no raw colours, so it follows any theme or custom tint. Legacy card style untouched; the experimental style is behind its existing setting.

Security: no new IPC, no process spawning, no user input handling, no network access.

Backwards compatibility: no wire, settings, or persisted-state changes.

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

The change is scoped to the experimental new card style. Mobile is unaffected — the sidebar card surface is desktop renderer code.

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)

The experimental card style mapped every quiet status to the same
branch/PR glyph, so a workspace that finished its work and a workspace
that went to sleep looked identical.

Sleeping workspaces now show a Moon in the status lane and dim the row.
Sleep is keyed on runtime liveness (no live PTY, no browser tabs, no
fresh agent activity), not on status, because a slept workspace keeps
its retained done rows and still reports 'done'. The same liveness
verdict already drives the hide-sleeping filter, including its SSH-gap
protection.

The dim redefines the theme's own tokens on the sleeping row with an
oklab mix of the sidebar foreground into the sidebar surface. Opacity
or a painted veil dims toward whatever is behind the card, which
collapses to nothing on a custom background and shrinks as the surface
lightens; a token mix is a fixed perceptual step on any theme and keeps
themed hues instead of greying them.

Legacy card style is untouched.
@mmarabel
mmarabel marked this pull request as ready for review September 18, 2026 22:12
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: b6e135e3-9f78-41df-a81a-460286d03001

📥 Commits

Reviewing files that changed from the base of the PR and between ae83b05 and e8911a7.

📒 Files selected for processing (3)
  • src/renderer/src/components/sidebar/use-worktree-sleep-state.test.tsx
  • src/renderer/src/components/sidebar/use-worktree-sleep-state.ts
  • src/renderer/src/i18n/locales/en.json

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


📝 Walkthrough

Walkthrough

The change updates useIsSleepingWorktree to use the shared inactivity predicate and cached live-agent state. New-style cards show sleeping worktrees with a moon icon and sleeping labels. Sleeping cards receive token-based Oklab dimming instead of opacity or filter dimming. Tests cover sleep-state detection, status rendering, card styling, legacy behavior, unread cards, and awake-card scenarios.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning For #19624, the PR adds runtime sleep detection, a Moon icon with the Sleeping label, and a theme-token dim for the new card style. Tests cover sleeping status, dimming, unread cards, legacy-style b… Implement the remaining coding requirements from #20807, or remove #20807 as a linked issue if this PR is intended to cover only the #19624 workspace-card distinction. The missing work includes a pane-level slept state with cause and recove…
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 16 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changed source files support the linked objectives. The sleep-state hook supports consistent filtering and card rendering. The status-slot, card-surface, CSS token rule, localization entry, and te…
Title check ✅ Passed The title clearly and concisely describes the main change: distinguishing sleeping workspaces in the new sidebar card style.
Description check ✅ Passed The description is complete and aligned with the template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, compatibility considerations, and checklist stat…
Full details: Linked Issues check

Explanation

For #19624, the PR adds runtime sleep detection, a Moon icon with the Sleeping label, and a theme-token dim for the new card style. Tests cover sleeping status, dimming, unread cards, legacy-style behavior, and the shared sleep predicate. For #20807, the PR addresses only the workspace-card distinction that overlaps the issue. It does not implement the required pane-level sleep notice, setting or wake affordance, documented foreground-input idle semantics, or the automatic-wake live-process check. The changed paths contain sidebar card, CSS, localization, and test updates only.

Resolution

Implement the remaining coding requirements from #20807, or remove #20807 as a linked issue if this PR is intended to cover only the #19624 workspace-card distinction. The missing work includes a pane-level slept state with cause and recovery controls, reliable documented idle-clock handling for foreground input, and protection against resuming a session that already has a live process.

Full details: Docstring Coverage

Explanation

Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 16 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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.

@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

One required CI gate fails: the new translate() key is missing from en.json. Add it with pnpm run sync:localization-catalog and commit the regenerated catalog.

Reviewed changes

  • Sleep verdict hook — new useIsSleepingWorktree treats a workspace as asleep when it has no live PTY, no browser tabs, and no fresh agent activity.
  • Sleeping status glyph — WorktreeCardStatusSlot shows a moon plus an sr-only Sleeping label ahead of the PR and branch lanes in the new card style.
  • Row dim — WorktreeCardSurface wraps parent content in data-worktree-sleeping-dim and main.css re-derives --foreground/--muted-foreground/--muted/--border as oklab mixes of the theme's own sidebar anchors.
  • Tests — new hook suite, expanded status-slot coverage, affiliate-list-mode dim assertions, a CSS pin test, and sleep mocks added to eight existing WorktreeCard.* suites.

The 31 tests across the three primary suites pass. The localization catalog verifier does not — details inline.

ℹ️ Nitpicks

  • worktree-card-surface.tsx:72 says "Same token as the disconnected dim", but the disconnected dim two lines below is opacity-60, not a token mix — the wording implies the two share a token.
  • WorktreeCardSurface and WorktreeCardStatusSlot both call useIsSleepingWorktree, so each card runs the hook twice (~8 store subscriptions). The surface already computes isSleeping; passing it down as a prop would drop the duplicate and guarantee the dim and the glyph read the same value.
  • The removed test uses context-aware branch or folder path accessible copy was the only cover for the branchIdentityLabel prop; consider keeping an assertion for it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…ping label

Review found two problems with the first pass.

The sleep hook re-derived liveness instead of reusing isInactiveWorkspace,
and the two definitions already disagreed: a fresh interrupted agent kept
the row awake here while the filter's isFreshNonDoneAgentStatus treated the
same workspace as sleeping. The hook now calls the filter's own predicate,
with the live-agent set cached per store generation so every card does not
rescan the status map, so the moon and the filter cannot drift apart.

The new 'Sleeping' translate() key was never added to en.json, which fails
the localization catalog and extraction CI jobs.

@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

Incremental re-review of e8911a7, which resolves both findings from the prior review. Only three files changed since ae83b05: the hook, its test, and en.json.

  • Shared sleep predicate — useIsSleepingWorktree now delegates to isInactiveWorkspace / getWorktreeIdsWithLiveAgent from worktree-activity-state.ts, the same predicate the hide-sleeping filter uses, so the moon and the filter cannot diverge. The fresh-interrupted-agent drift is gone with it.
  • Per-generation live-agent cache — the whole-store live-agent scan is cached at module scope, keyed on agentStatusByPaneKey, tabsByWorktree, and the epoch-sampled now, so it runs once per store generation instead of once per card.
  • Localization key — auto.components.sidebar.WorktreeCardStatusSlot.sleeping added to en.json; verify:localization-catalog and verify:localization-extraction both pass locally.
  • Parity tests — a stale-agent-row case and a parameterized assertion that the hook matches isInactiveWorkspace across four runtime shapes.

The cache is sound: getWorktreeIdsWithLiveAgent is pure in its three cached keys, so a cache hit returns exactly what a recompute would, and any mutation that can change membership replaces the agentStatusByPaneKey or tabsByWorktree identity and forces a rebuild. The hook reads the real state.agentStatusEpoch, never the kanban sentinel 0, so it cannot evict the shared epoch-clock sample. The hook suite (8 tests), the status-slot suite, and the affiliate-list-mode suite pass locally.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Reviewed independently. Focused tests (36/36), changed-code quality, typecheck, and diff checks pass. No correctness or compatibility issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants