Skip to content

feat(firstmate): walk everything that needs you as one ranked queue - #4

Merged
thiagown1 merged 3 commits into
mainfrom
feat/firstmate-decision-queue
Sep 24, 2026
Merged

thiagown1 merged 3 commits into
mainfrom
feat/firstmate-decision-queue

Conversation

@thiagown1

@thiagown1 thiagown1 commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #5 (CI fix) and #3 (status bugs). Merge #5, then #3; this PR then shows only its own commit.

What Changed

The FirstMate chat's Decisions panel is now a queue of everything in the project that needs the user, shown one item at a time:

  • Sources: pending decision cards (turn review / Jev, supervisor questions, provider requests), a pending approval or question with no card yet, a delegated thread whose run failed or was interrupted, and a delegated PR with failing, action-required or conflicting checks.
  • Enough context to decide in place: topic goal, the last round summary, the question (for a turn review, the tail of the agent's last message), judge verdict and confidence, PR links with head SHA, "Open thread", the card's options, and a reply box.
  • Reply from the panel: the text is queued on the thread with after-current-turn (starts now on an idle thread, never interrupts a running one). The card it answered is closed (turn review → "I'll answer in the thread", supervisor question → cancelled). Provider requests have no reply box; they are answered through their options.
  • The item being read never changes or jumps. It is pinned when shown; new or more urgent items only reorder "Up next" behind it. If it is resolved elsewhere it stays on screen with "Already handled elsewhere · Next". Answering, Later (to the back of the queue) or Dismiss moves to the highest-priority item.
  • The turn-review card now stores the judge's verdict (source.verdict: outcome, confidence, in-scope) so the queue can rank by it. It is optional, so older cards still decode.

Priority formula (firstMateQueuePriority)

Item Priority
Provider request (agent paused mid-turn) 100
Turn review, blocked 90 + 10 × confidence
Turn review, needs_user 80 + 10 × confidence
Supervisor question 70 blocking / 40 otherwise
Failed or interrupted run 65
PR checks failing 60
PR action required 55
PR conflicting 50
Turn review, done / continue (judge leaned towards acting alone) 30

Ties go to the newer item. A turn review stored without a verdict ranks as needs_user at 0 confidence when blocking, otherwise 30. Also in docs/internals/firstmate-domain.md.

Why

The user wants to read and decide everything in sequence without opening thread after thread. Before, the panel only listed cards, so a failed run or red checks never reached it (on the real data below it said "Nothing to decide" while six items needed attention), and a list that reorders while you read it makes you lose your place.

Clearing an answered item uses the same mechanism as #3: starting the thread's next turn cancels its turn-review card, and a running thread's items leave the queue.

UI Changes

Worktree dev server seeded with a VACUUM INTO copy of the real FirstMate database, 1440×950.

Before After
Before: Nothing to decide After: one item with context and a reply box, the rest ranked behind it

After Later: the failed run moved to the back and the next item (checks failed on pingdotgg#2202) took its place:

After Later

Not exercised in the browser: Send. On the copied database it would start a real provider turn in a real worktree. The reply wiring was checked by typecheck and the queue/cursor tests; no Jev card was pending in the copied data, so the verdict line was only covered by tests.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (no animation)

Tests

  • FirstMateDecisionQueue.logic.test.ts (new): priority order and the no-verdict fallback; queue building from every source with context; turn review and PR items leave while the thread runs; no duplicate for a provider request that has a card, and no reply on it; newer first on ties; the item being read stays pinned while a more urgent one arrives; a resolved-elsewhere item stays until "Next"; Later/handled ordering.
  • FirstMateTurnReviewReactor.test.ts: the opened card now carries the verdict.
  • vp test run on the FirstMate web components, the turn-review and delivery reactors, and packages/contracts: 37 files, 550 tests, all passing.
  • tsc --noEmit: apps/web, apps/server, packages/contracts, packages/shared clean.
  • CI: stacked on fix(ci): drop the msgpackr-extract dependency upstream removed #5, which fixes the three jobs that were already red on main.

Done by Claude Opus 5.5 (Claude Code, via T3 Code).

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 13.5 KiB — 15.1 KiB ✅
Codex Thread snapshot wire — 7.1 KiB — 7.3 KiB ✅
Codex Live turn WebSocket wire — 6.4 KiB — 7.8 KiB ✅
Codex Live turn WebSocket decoded — 56.2 KiB — 66.4 KiB ✅
Codex Live turn messages — 9 — 21 ✅
Claude Total thread wire — 13.5 KiB — 15.1 KiB ✅
Claude Thread snapshot wire — 7.1 KiB — 7.3 KiB ✅
Claude Live turn WebSocket wire — 6.4 KiB — 7.8 KiB ✅
Claude Live turn WebSocket decoded — 57.0 KiB — 66.4 KiB ✅
Claude Live turn messages — 9 — 21 ✅

Baseline: unavailable · PR result: 8860ba2 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

thiagown1 and others added 3 commits September 24, 2026 18:35
main's Check and Test jobs have been red since the upstream sync:

- The sync merge put back `msgpackr-extract` in apps/server, which upstream
  removed in d547e3b. knip reports it unused, and the CLI bundle closure
  test flags its native loader's `detect-libc` as bundled away.
- With knip passing, its export pass ran for the first time and found twelve
  fork-only exports used only in their own file. They are no longer exported;
  the two Effect service constructors keep `@public` like the other reactors.
- `vp check` then ran and rejected the raw `GitPullRequestIcon` in the
  FirstMate topics panel; it now uses the shared `PullRequestGlyph`.
- The 902 migration test listed every migration after 52, so adding 905
  broke it. It now checks only what it is about.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A turn-review card was only cancelled when the next turn ended, so a topic
kept saying "Waiting for you" through the whole run that answered it. The
panel also derived "Waiting for you" (all PRs merged) or "Blocked" (a PR with
action-required or failing checks) while the thread was visibly working.

- Starting a turn now cancels that thread's pending turn-review cards in the
  same event batch.
- The topics panel ignores turn-review cards and PR-derived status while the
  thread runs; each PR line keeps its own status. A completed topic whose
  thread runs again reads as working.
- Every icon button in a topic row has a tooltip and an aria-label.
- Threads the FirstMate panel already lists (supervisor chat and delegated
  topic threads) no longer repeat as active cards in the sessions list; the
  panel marks the one on screen instead. Pins, shelves and search still
  reach them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Decisions panel listed pending cards only, so a failed run, a red or
action-required PR, or a request without a card still meant opening threads
one by one. It now builds one queue per project from all of them and shows one
item at a time with the topic goal, the last round summary, the question or
agent tail, PR and thread links, the options, and a reply box.

- Priority: a paused agent, then turn reviews by the judge's outcome and
  confidence, supervisor questions, failed runs, PR checks, and reviews where
  the judge leaned towards acting alone; newer first on ties. The turn review
  card now stores the judge's verdict so the ranking can use it.
- The item on screen is pinned: new or more urgent items only reorder the
  list behind it. Answering, "Later" or "Next" moves to the top of the queue.
- A reply is queued on the thread after the current turn and closes the card
  it answered.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thiagown1
thiagown1 force-pushed the feat/firstmate-decision-queue branch from 56e79ae to 8860ba2 Compare September 24, 2026 21:42
@thiagown1
thiagown1 merged commit b02213d into main Sep 24, 2026
25 of 26 checks passed
@thiagown1
thiagown1 deleted the feat/firstmate-decision-queue branch September 24, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant