Skip to content

feat(worktree): order row badges by salience and surface alarms when collapsed#8763

Merged
gregpriday merged 3 commits into
developfrom
feature/issue-8379-order-worktree-row-badges
May 20, 2026
Merged

feat(worktree): order row badges by salience and surface alarms when collapsed#8763
gregpriday merged 3 commits into
developfrom
feature/issue-8379-order-worktree-row-badges

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

Two things were broken in the worktree dashboard: collapsed rows hid actionable alarms entirely, and expanded rows stacked badges in a fixed positional order regardless of how critical each signal was.

  • Collapsed rows now hoist the highest-priority alarm into the title row as a CollapsedAlarmPill chip (CI failure > auth-failed > behind upstream), so a failing PR is visible without expanding the row
  • Expanded rows reorder PR and upstream-sync badges by salience tier on threshold-crossings only, so spatial order doesn't churn on every poll tick
  • Both surfaces derive their priority from the same computeAlarmTier helper in src/lib/worktreeAlarmTier.ts, keeping the two in agreement

Resolves #8379

Changes

  • src/lib/worktreeAlarmTier.ts — pure helper that reduces CI state, gated auth-failed, and behind-count to a single tier (3 = CI failed, 2 = auth-failed, 1 = behind, 0 = none); detached HEAD excluded as gitStateIndicator already labels it in the title row
  • src/components/Worktree/WorktreeCard/CollapsedAlarmPill.tsx — new chip using bg-status-error/10 text-status-error for CI tier and bg-status-warning/10 text-status-warning for warning tiers; shrink-0, pointer-events-none, transition-colors only
  • WorktreeHeader — collapsed alarm rendered inside the title flex-1 container after gitStateIndicator, gated on isCollapsed; CI state only considered when a live PR is linked; auth-failed only passed through when the provider is GitHub
  • NonMainSecondaryRowupstreamFirst boolean flips PR vs UpstreamSyncBadge order by salience; reorder gated on actual tier change, not poll ticks

Testing

  • src/lib/__tests__/worktreeAlarmTier.test.ts — full priority matrix and cascade cases
  • src/components/Worktree/WorktreeCard/__tests__/CollapsedAlarmPill.test.tsx — chip styling per tier
  • Extended NonMainSecondaryRow.test.tsx — badge ordering by tier with presence guards
  • Extended WorktreeHeader.test.tsx — collapsed pill rendering, closed-PR stale CI suppression, non-GitHub auth-failed suppression, detached double-label prevention
  • 125 targeted tests pass; typecheck, lint, and format clean

… salience

- Add computeAlarmTier helper that reduces worktree alarm fields to a single
  salience tier (CI failed > auth-failed > behind > detached > none); only
  'failure' CI maps above tier 0 so transient pending states don't churn
  spatial ordering on every push.
- Add CollapsedAlarmPill chip that renders the highest-priority alarm inside
  the title row when the card is collapsed, so CI failures, auth failures, and
  behind-upstream counts stay visible without expanding the row.
- Reorder NonMainSecondaryRow so the upstream-sync badge leads when its tier
  outranks the PR badge's CI tier; PR keeps its lead by default and on CI
  failure. Reorder is gated on threshold crossings (tiers), not poll ticks.
- Drop detached HEAD from computeAlarmTier; gitStateIndicator already labels
  it in the title row, so including it in the pill produced a double-label on
  collapsed cards.
- Gate the CI-failed alarm on the linked PR being live (not closed/declined)
  so a stale ciStatus on a closed PR does not surface a phantom alarm in the
  collapsed row while the expanded row shows no PR badge.
- Switch the auth-failed alarm input to the already-gated hasAuthFailedSignIn
  boolean so the collapsed pill, expanded ordering, and UpstreamSyncBadge
  treatment all agree on the GitHub-only provider gate.
- Use computeAlarmTier in NonMainSecondaryRow for prTier and upstreamTier so
  the expanded badge ordering tracks the helper, not a duplicated inline
  cascade.
- Add presence guards to the ordering tests so an absent badge can no longer
  satisfy an indexOf-based less-than assertion.
The prLinked() helper inline union didn't accept the closed/declined values
mutated in the new stale-CI tests; widen the parameter to NormalizedPRState
from the forge type so mutations to closed/declined typecheck cleanly.
@gregpriday gregpriday force-pushed the feature/issue-8379-order-worktree-row-badges branch from 7c1d6ac to 28620d9 Compare May 20, 2026 23:26
@gregpriday gregpriday merged commit c5c7f66 into develop May 20, 2026
2 checks passed
@gregpriday gregpriday deleted the feature/issue-8379-order-worktree-row-badges branch May 21, 2026 08:34
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.

Order worktree row badges by salience and surface alarms when collapsed

1 participant