Skip to content

feat: commands record what they waited on, and the invite card says what it's doing - #1023

Merged
badcuban merged 1 commit into
mainfrom
perf/invite-answer
Nov 20, 2026
Merged

badcuban merged 1 commit into
mainfrom
perf/invite-answer

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

An answer to an agent's invite once waited about 3.9s on the server before its command started (the command itself took 0.36s). Nothing on disk could say why. The trace had rotated out, the command queue's wait time lives only in an in-memory metric, and the freeze monitor logs only freezes of 5s or more.

Server. Every orchestration command runs in one line, one at a time. Each command now records, when its turn comes:

  • how long it waited
  • how many commands ran ahead of it
  • how much of the wait went to their work
  • how busy the main loop was

These go on its trace span as orchestration.queue_*. A wait of 1s or more also writes orchestration command waited in line to the log, which keeps weeks of history, at most once per 5s with a count. The next slow click then shows whether it was stuck in line or the server was frozen.

Times use the monotonic clock. "Work ahead" counts only work done after the command joined the line, including failure handling. The warning is written after the command's turn ends, so a slow or broken log write can't hold it up.

Web. After the user answers an invite, the card replaces its buttons with a line saying what's happening, until the thread update removes the card. The line keeps the buttons' height, so the card doesn't shift:

  • "Adding X to the thread…"
  • "Asking X for a review…"
  • "Telling Y not now…"

The answer is recorded from the click on, so a card left and reopened while the answer is still on its way shows the same line instead of the choices. If the answer fails, the buttons come back with a toast.

Tests. New engine test: a command queued behind a slow write logs the warning, with one command ahead and over 1s of its work. The existing invite browser test is updated, because its expectation changed on purpose: the card used to grey out the buttons and now replaces them with the line. 884 orchestration tests and 26 room tests pass, along with fmt, lint and typecheck.

Review. Reviewed by GPT-6.2-Astra. Fixed: the log write held the command, reopening the card mid-answer brought the buttons back, "work ahead" was miscounted, and the clock could change mid-wait. Kept on purpose: the skipped-warning count includes the current warning.

Not in this PR: any change to how commands are lined up. That waits until these records show what the wait was.

…hat it's doing

An invite answer once waited ~3.9s before its command started, and nothing
on disk said why: the trace had rotated out, and neither the queue wait
nor short freezes are saved.

Server: every orchestration command runs in one line. Each command now
records, when its turn comes, how long it waited, how many commands ran
ahead of it, how much of the wait went to their work, and how busy the
main loop was (trace span attributes `orchestration.queue_*`). A wait of
1s or more also writes "orchestration command waited in line" to the log,
which outlives the traces, at most once per 5s with a count. Times use the
monotonic clock, work ahead counts only what ran after the command joined
(failure handling included), and the warning is written after the
command's turn so it can never hold it up.

Web: after the user answers an agent's invite, the card replaces its
buttons with what is happening ("Asking X for a review…") until the
thread update removes it. The answer is shared from the click on, so a
card left and reopened while the answer is on its way shows the same line
instead of the choices.
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 20, 2026 6:48pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 44129bd Nov 20, 2026
23 checks passed
@badcuban
badcuban deleted the perf/invite-answer branch November 20, 2026 19:00

This branch was previously deployed

1 inactive deployment
Preview — de14009c Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant