Skip to content

Fix teammate pending status label#5

Merged
TraderSamwise merged 3 commits into
masterfrom
fix/teammate-pending-status-label
May 21, 2026
Merged

Fix teammate pending status label#5
TraderSamwise merged 3 commits into
masterfrom
fix/teammate-pending-status-label

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Use the shared derived status label for teammate detail summaries
  • Add coverage so pending teammate actions stay visible when semantic state is stale

Verification

  • yarn verify

Summary by CodeRabbit

  • Bug Fixes

    • Teammate pending labels now show reliably even when semantic state is stale.
    • Offline/retired teammates no longer appear in statusline; teammate "active" flag reported correctly.
    • API now rejects invalid/empty parent IDs for teammate creation.
  • Improvements

    • Pending-action handling is token-guarded to avoid races; retry logic for service requests tightened.
    • Various robustness fixes around session capture, restore error messaging, and graveyard persistence.
  • Tests

    • Added coverage for rendering, pending-action races, API validation, persistence, and edge cases.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e4871cd7-9a8e-4d79-b825-457cfcda5095

📥 Commits

Reviewing files that changed from the base of the PR and between 5d32b4d and edeee4f.

📒 Files selected for processing (1)
  • src/multiplexer/dashboard-ops.ts

📝 Walkthrough

Walkthrough

This PR coordinates fixes across dashboard pending-action tokening and mutation flows, restore-warning deduplication, persistence/graveyard handling, session capture and creation hardening, control retry tightening, debug notification matching, metadata parent validation, TUI status derivation, and tmux/statusline filtering, with accompanying tests.

Changes

Dashboard pending-actions and ops

Layer / File(s) Summary
Pending action tokening and settle semantics
src/dashboard/pending-actions.ts, src/dashboard/pending-actions.test.ts, src/multiplexer/dashboard-ops.ts
Adds token-checked clearing, extends settleCreatePending with expectedToken, propagates token-based clearing through runDashboardSessionMutation/runDashboardServiceMutation, and removes stale settle effects; tests validate stale callbacks cannot clear newer pending actions.
Restore warning dedupe and error formatting
src/multiplexer/dashboard-ops.ts, src/multiplexer/dashboard-ops.test.ts
restoreWarningLines now returns unique teammate-failure lines when present and otherwise composes fallback warnings; tests updated to expect only structured teammate error lines when available.
UI state load reset
src/dashboard/ui-state-store.ts
loadSharedState resets orderState to empty maps before loading persisted UI state.

Persistence and graveyarding

Layer / File(s) Summary
Statusline active flag
src/multiplexer/persistence-methods.ts, src/multiplexer/persistence-methods.test.ts
buildStatuslineSnapshot uses session.active for active teammate flag; tests adjusted to expect active: true.
Worktree graveyard split and append helper
src/multiplexer/persistence-methods.ts, src/multiplexer/persistence-methods.test.ts
Splits attached agents into worktreeAgents vs cross-worktree teammates, appends cross-worktree agents into flat graveyard via appendFlatGraveyardAgents, and updates graveyard writing and tests to match new persisted shapes.

Multiplexer session/control flows

Layer / File(s) Summary
Teammate initialPrompt handling
src/multiplexer/session-actions.ts, src/multiplexer/session-actions.test.ts
Pre-trims initialPrompt, rejects early when host input support is unavailable, and uses the pre-trimmed value when writing agent input; test added for early-reject behavior.
Session capture sampling and exact preamble match
src/multiplexer/session-capture.ts, src/multiplexer/session-launch.test.ts
Reads large session-capture files by sampling head/tail via file descriptors, uses an escaped-session-id regex with a boundary to avoid prefix false-matches, and adds a test ensuring codex-10 doesn't match codex-1.
Control retry policy and model token cleanup
src/multiplexer/dashboard-control.ts, src/multiplexer/dashboard-control.test.ts, src/multiplexer/dashboard-model.ts
Tightens POST retry logic to only retry on retryable HTTP statuses within the deadline; model mutation error paths now clear pending state using token-checked helpers and reapply when token-based clearing succeeds; tests added/updated for non-retryable behavior.

TUI rendering and statusline

Layer / File(s) Summary
Teammate status derivation and rendering test
src/tui/screens/dashboard-renderers.ts, src/tui/screens/dashboard-renderers.test.ts
summarizeTeammate now derives status text from derivedStatusLabel(session) exclusively; new test verifies pending action labels render correctly when semantic state is stale.
Exclude retired/offline teammates
src/statusline-model.ts, src/tmux/statusline.test.ts
resolveCurrentTeammates filters out offline/exited sessions from focused lists; statusline test adds a retired teammate and asserts it is not rendered.

Debug state

Layer / File(s) Summary
Include notifications in target matches
src/debug-state.ts, src/debug-state.test.ts
filterNotifications now appends notification TargetMatch entries to shared matches/seen; buildDebugStateReport passes those collections so notifications contribute to target resolution; test added verifying resolution from notifications.

Metadata server

Layer / File(s) Summary
Validate parentSessionId on teammate create
src/metadata-server.ts, src/metadata-server.test.ts
Trims and validates parentSessionId, returns HTTP 400 for empty/whitespace-only values, normalizes the body field, and pre-validates parent eligibility via resolveDirectTeammates when desktop state is available; test added for nested-team rejection.

tmux control

Layer / File(s) Summary
Filter direct teammates by tmuxWindowId
scripts/tmux-control.sh
resolve_local_target_from_statusline for action=="team" now filters direct teammates to those with a non-empty tmuxWindowId, fails early when none are live, and selects the first live tmuxWindowId as the target.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as MutationCaller
  participant MutationRunner as runDashboard*Mutation
  participant Pending as DashboardPendingActions
  Caller->>MutationRunner: setPendingDashboard*Action(...) -> token
  MutationRunner->>Pending: settleCreatePending(... expectedToken=token)
  Pending-->>MutationRunner: clear only if token matches
  MutationRunner->>Pending: clear*ActionIfToken(token) on finalize/error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through tokens, graveyards, and trace,
Trimmed prompts, fixed matches, and tidied the place.
Tests now assert what the dashboard should show,
Statuslines prune retired friends in a row.
Quiet carrots grown where the codebases grow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Fix teammate pending status label" clearly summarizes the main change in the changeset: the update to how teammate status labels are derived and displayed, with emphasis on ensuring pending actions remain visible.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/teammate-pending-status-label

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/multiplexer/dashboard-ops.ts`:
- Around line 254-256: The token used to clear pending dashboard actions is
captured before calling opts.onBeforeRequest, so if onBeforeRequest re-calls
host.setPendingDashboardSessionAction (e.g., in spawn/fork flows) the token
becomes stale and clearSessionActionIfToken (used later) can fail and leave the
row stuck; fix by deferring capturing the token until after opts.onBeforeRequest
completes (or re-read the current pending token) and then call
clearSessionActionIfToken with that fresh token; apply the same
single-pending-set pattern to forkDashboardAgentWithFeedback and update the code
paths around host.setPendingDashboardSessionAction, token, onBeforeRequest, and
clearSessionActionIfToken so the token used for clearing always matches the
latest pending action.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c9b17a0a-0513-4e29-93c1-16c97b6672e2

📥 Commits

Reviewing files that changed from the base of the PR and between fa36d86 and 5d32b4d.

📒 Files selected for processing (21)
  • scripts/tmux-control.sh
  • src/dashboard/pending-actions.test.ts
  • src/dashboard/pending-actions.ts
  • src/dashboard/ui-state-store.ts
  • src/debug-state.test.ts
  • src/debug-state.ts
  • src/metadata-server.test.ts
  • src/metadata-server.ts
  • src/multiplexer/dashboard-control.test.ts
  • src/multiplexer/dashboard-control.ts
  • src/multiplexer/dashboard-model.ts
  • src/multiplexer/dashboard-ops.test.ts
  • src/multiplexer/dashboard-ops.ts
  • src/multiplexer/persistence-methods.test.ts
  • src/multiplexer/persistence-methods.ts
  • src/multiplexer/session-actions.test.ts
  • src/multiplexer/session-actions.ts
  • src/multiplexer/session-capture.ts
  • src/multiplexer/session-launch.test.ts
  • src/statusline-model.ts
  • src/tmux/statusline.test.ts

Comment thread src/multiplexer/dashboard-ops.ts
@TraderSamwise
TraderSamwise merged commit 1ed4320 into master May 21, 2026
1 check 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