Skip to content
This repository was archived by the owner on Sep 2, 2026. It is now read-only.

[Spec #28] Sidebar stage groups - #66

Merged
64ix merged 12 commits into
mainfrom
spec/28-sidebar-stage-groups
Aug 25, 2026
Merged

64ix merged 12 commits into
mainfrom
spec/28-sidebar-stage-groups

Conversation

@64ix

@64ix 64ix commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​960 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​955
Prod 38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​686 $\color{#cf222e}{\Huge{\mathbf{−}}}$​81 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​605

Closes #28, closes #45, closes #53.

Summary

Adds a fourth sidebar group-by mode, By stage, so the generalist workspace list can be sorted by delivery stage without losing the general overview. Stage lanes follow the fixed board column order with a Sans stage lane on top, lineage children stay nested under their root inside its lane, and a small stage badge rides on staged rows in every grouping mode — including none — so the sidebar stays oriented outside the board. Dropping a workspace onto a stage lane declares that stage through the same authority guard the board uses, with blocked drops explained rather than silently dropped. Awaiting-input keeps its existing agent-state gutter indicator, and rows never reorder themselves — elevation stays board-only by design.

The three existing modes (status, repo, PR status) are untouched.

Spec & Tickets

Acceptance criteria

Criterion Verdict Evidence
The new mode appears beside the existing three; nothing existing disappears ✅ GROUP_BY_OPTIONS gains a workflow-stage entry (sidebar-workspace-option-items.ts); SidebarGroupByToggle.test.tsx asserts all four render in order. The other three modes' branches are untouched — build-rows.test.ts and build-rows.folder-workspace-lanes.test.ts still pass unchanged for them.
Groups are ordered by the fixed stage set, "Sans stage" first ✅ WORKFLOW_STAGE_LANE_ORDER = [sans, ...WORKFLOW_STAGE_IDS], the same fixed set the board columns iterate. build-rows.workflow-stage.test.ts: "groups by declared stage with 'Sans stage' first", "orders lanes by the fixed stage pipeline regardless of encounter order". Empty lanes stay hidden, matching the existing status-lane behavior.
Children render nested under their root inside its group ✅ Children have no stage of their own, so lane membership resolves through getWorkflowStageLaneRoot (walks parent links, treats a cyclic member as rootless). build-rows.workflow-stage.test.ts: unstaged child lands in its staged parent's lane with no "Sans stage" header; a child whose own declared stage differs still follows the root; a three-level chain buckets entirely into the root's lane; cyclic lineage stays stable and does not hang.
The stage badge is visible in every grouping mode including none ✅ The badge renders from WorktreeRow.effectiveStage, populated in row-builders.ts for every mode's item emission (including the pinned section and the flat none path) — deliberately not coupled to the hasWorktreeCardDetails gate. WorktreeCard.stage-badge.test.tsx plus build-rows.workflow-stage.test.ts: "renders the effective stage badge on rows in every grouping mode".
Group membership uses the effective stage (declared or derived) ✅ getEffectiveWorkflowStageForWorktree wraps deriveEffectiveWorkflowStage (spec #22/#38) and falls back to the declared stage. build-rows.workflow-stage.test.ts: membership derives from cached PR facts over the declared stage, an open PR promotes an undeclared worktree to review, a closed PR sends it to triage, an open linked issue promotes idea → spec. workflow-stage-grouping.test.ts covers the lane-key/label round trip.
Dropping a worktree onto a stage group declares that stage ✅ useWorkflowStageRowDrag resolves the lane's stage from the drop target's key and writes workflowStage via updateWorktreeMeta. Both the group header and every row inside the lane are drop targets (mirroring status-lane behavior); item rows read row.sectionKey, the lane they visually sit in, not their own effective stage. use-workflow-stage-row-drag.test.tsx.
Blocked drops show the guard's explanation and change nothing ✅ decideSidebarWorkflowStageDrop wraps the board's decideFeatureBoardCardDrop, so the authority gate and its explanation strings are shared, not forked. A refusal aborts the whole gesture (all-or-nothing across a multi-select drag) and toasts the guard's own explanation; a write that resolves { ok: false } toasts the error — the same two-toast pattern the board uses. sidebar-workflow-stage-drop.test.ts, use-workflow-stage-row-drag.test.tsx.
The amber awaiting indicator appears on waiting rows ✅ (as the existing gutter) Verified rather than rebuilt: StatusIndicator's 'permission' state — sourced from selectWorktreeAgentActivitySummary(...).hasPermission — already renders unconditionally on every sidebar row via showStatus, in every grouping mode. See the Problem → Resolution note on the colour.
Rows never reorder themselves (elevation stays board-only) ✅ Sidebar grouping reads no agent-activity state at all, so there is no path by which awaiting-input can reorder rows. build-rows.no-awaiting-elevation.test.ts asserts row order is unchanged with an awaiting worktree present, and guards against applyAwaitingInputElevation ever being imported into sidebar grouping.
Drop gating is tested at the drop-handler seam ✅ sidebar-workflow-stage-drop.test.ts tests the pure decision seam (accepted drop declares the stage; refused drop carries the guard's explanation and produces no write; human→shipped allowed; lineage child skipped). use-workflow-stage-row-drag.test.tsx covers the hook seam (persists on allow, toasts and writes nothing on refusal, toasts on a failed write).

Changes

Group-by mode plumbing — 'workflow-stage' added to the canonical WorktreeGroupBy union and each of its four duplicates (renderer store, shared persisted-UI type, main-process normalizeGroupBy, the client-ui.set zod enum) so the mode survives a restart and a cross-client sync instead of being normalized away. The exhaustive getFolderWorkspaceLaneKey switch gains a workflow-stage case: folder workspaces run the manual regime and never derive a stage, so they join the "Sans stage" lane.

Stage lanes — new workflow-stage-grouping.ts owns the lane vocabulary (key prefix, sans key, key↔stage round trip, labels reused from getFeatureBoardStageLabel, and the fixed lane order). Bucketing and single-worktree lookup both go through one resolver, getWorkflowStageLaneKeyForWorktree, so lane membership, group-reveal targeting, and collapse state cannot disagree about which lane a row lives in. Lineage-root resolution respects the existing cyclic-lineage guard.

Stage badge — WorktreeRow.effectiveStage threads through item-row.tsx into WorktreeCard, rendered as a small outline Badge matching the sibling chips already in worktree-card-header.tsx. Populated for all modes, so it is present in the flat list too.

Stage drops — useWorkflowStageRowDrag wires the group header and the lane's rows as drop targets, resolves each dragged worktree's current effective stage and derivation facts, and calls the shared decision core with callerKind: 'human'. The board's FeatureBoardCardDropRequest.targetStage was widened to WorkflowStage | null so the "Sans stage" lane can clear a stage through the same core — the guard and the de-ship consumed-merge bookkeeping already handled null. The local/remote authority asymmetry is preserved: local IPC writes are ungated, remote worktree.set still gates as callerKind: 'agent', because that wire method is shared with the CLI, MCP, and mobile and cannot distinguish a human drag.

Awaiting-input — no new UI; a confirming test plus a guard against importing the board's elevation into sidebar grouping.

Problem → Resolution

  • A lineage child's lane — children have no stage of their own, so bucketing each worktree by its own effective stage split an unstaged child into "Sans stage" away from its staged parent, breaking nesting. → Lane membership resolves through the root ancestor, in one shared resolver used by both bucketing and single-worktree lookup.
  • "Sans stage" is not a WorkflowStage — the board's drop core typed targetStage as a concrete stage. → Widened it to WorkflowStage | null rather than forking the decision core, so "who may write which stage" cannot drift between the two surfaces.
  • Dropping onto (or dragging) a lineage child — a per-child stage declaration would contradict "children have no stage of their own". → A silent no-op, no toast and no write; a multi-select drag still applies to the eligible root-level ids.
  • Item-row drop targets inside a lane — a child row's own effective stage is absent, which would have wrongly targeted the sans lane. → Item rows target row.sectionKey, the lane they are actually rendered in.
  • "Amber" awaiting indicator — the spec says amber, but the existing gutter glyph is deliberately orange (--agent-question, whose own comment explains it must stay separable from working-yellow), and no --amber/--warning token exists. The spec also says to reuse the existing agent-state gutter. → Reused the existing glyph and read "amber" as colloquial for it, rather than inventing a colour token. Flagging for confirmation; swapping the hue later is a one-line change.
  • Mobile shares PersistedUIState.groupBy — mobile's own narrower union has no workflow-stage, and groupModeFromDesktop returns null for an unknown mode, which applyDesktopViewSettings already resolves to ?? current.groupMode. → Left mobile's union narrow: it keeps its own grouping instead of breaking, and widening it would force a mobile stage-grouping design that is out of this spec's scope. No wire change — groupBy is an existing field carrying a new value.

QA plan

  • Open the sidebar group-by menu — Stage appears alongside None / Status / PR / Project, and picking each of the other three still groups exactly as before.
  • Select Stage with a mix of staged and unstaged workspaces — lanes read Sans stage, then Idea → Exploring → Spec → Implementing → Review → Shipped → Triage, with empty lanes absent.
  • Quit and relaunch — the sidebar comes back in Stage mode (not reset to Project).
  • Create a child workspace under a staged root, leave the child's own stage unset — both rows sit in the root's lane, child indented under the parent, and no Sans stage lane appears for the child alone.
  • Declare a different stage on that child — it stays in the root's lane (the root governs).
  • Switch to None, then Status, then Project — the stage badge stays visible on staged rows in every mode.
  • Open a PR on an undeclared workspace — it moves into the Review lane and its badge reads Review without touching the declared stage.
  • Drag a workspace onto another stage lane's header — it moves there and the badge updates; drop it onto a row inside a lane and it behaves the same.
  • Drag a workspace onto Sans stage — its stage clears and the badge disappears.
  • Drag a workspace off a shipped lane that a merged PR is driving — it stays where you dropped it instead of snapping back to Shipped.
  • Trigger a refused drop (a remote workspace declaring shipped over RPC) — a toast names the reason and the row does not move.
  • Drag a lineage child onto a different lane — nothing happens, no toast, no stage written.
  • Let an agent ask for permission — the amber/orange question glyph appears in the row's status gutter in every grouping mode, and no row changes position.
  • Repeat the lane checks on an SSH-hosted workspace and on a folder workspace (folder workspaces stay in Sans stage until a stage is declared on them).

Reviewer notes

  • Badge derivation cost — the effective-stage map that feeds the row badge is computed for every worktree on every buildRows call, in all grouping modes, because the badge is required in all of them (including none). Each entry is a deriveEffectiveWorkflowStage call doing PR/issue cache lookups. That work is necessary rather than wasted, but it is new per-row work on the sidebar's hot path — worth watching if list responsiveness regresses on very large workspace sets, where memoizing the map across calls would be the fix.
  • Multi-select refusal branch — the all-or-nothing refusal path in the drop hook is unreachable today (the authority guard only refuses agent callers, and sidebar drops are always human). It is kept, and commented as such, so widening the guard surfaces the behavior instead of silently applying partial drops.

64ix added 12 commits August 25, 2026 08:24
Widen the WorktreeGroupBy union across the store, persistence, and
paired-client schemas; bucket worktrees by effective workflow stage in
buildOrderedGroups with the fixed stage order and a leading 'Sans stage'
lane; thread pr/issue caches through the row model so stage membership
and the per-row badge derive from the same effective stage.

Issue: #45
…45)

Add build-rows.workflow-stage tests (membership, fixed ordering, sans
first, effective-stage derivation, lineage nesting, pinned handling,
badge in every mode), lane-key unit tests, card stage-badge rendering
tests, cache-input gating tests, the group-by toggle option, and
persistence/store cases for the new union member.

Issue: #45
Children have no stage of their own: buildOrderedGroups' workflow-stage
branch and getGroupKeyForWorktree bucketed every worktree by its own
effective stage, splitting an unstaged child from its staged parent into
'Sans stage'. Both now resolve lane membership via a shared
getWorkflowStageLaneKeyForWorktree/getWorkflowStageLaneRoot in
workflow-stage-grouping.ts, walking to the root ancestor and respecting
cyclicLineageIds so a cyclic chain cannot loop forever. The per-row stage
badge is untouched (still the row's own effective stage).

Extends build-rows.workflow-stage.test.ts: unstaged child in parent lane,
differing own-declared-stage child still in root lane, multi-level chain,
and cyclic lineage stability.
- New use-workflow-stage-row-drag hook + sidebar-workflow-stage-drop pure
  decision core, reusing decideFeatureBoardCardDrop/decideStageWrite as
  callerKind 'human', same as the board.
- Widen FeatureBoardCardDropRequest.targetStage to WorkflowStage | null so
  the sidebar's 'Sans stage' lane can reuse the same core to clear a stage.
- Wire stage-lane header + item-row drop targets through SectionHeader,
  virtual-row-dispatch, and VirtualizedWorktreeViewport.
- Lineage children are a silent no-op on drop (no stage of their own).
- Refusals and post-write failures toast via the same two-toast pattern as
  the board; no inline banner.
- Confirming test that sidebar row order never elevates for awaiting-input
  worktrees (board-only behavior) and that sidebar grouping never imports
  applyAwaitingInputElevation.
@64ix
64ix marked this pull request as ready for review August 25, 2026 10:37
@64ix
64ix merged commit 61ac02c into main Aug 25, 2026
95 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar stage drops & awaiting indicator Sidebar 'By stage' group-by mode & stage badge [Spec] Sidebar stage groups

1 participant