Files
orca/src/shared
Jinwoo Hong b8950a4f66 feat(orchestration): answer workers' permission prompts from the coordinator (re-land with fixes) (#41259)
* revert: worker permission approvals (#40756)

This reverts commit 818055fcbb.

The feature misbehaves in real use: an Allow on a worker's approval card
was recorded as closed without an answer, and closed approval cards render
at the bottom of the coordinator chat, below newer messages.

Removed: the Claude PermissionRequest hook hold and its 130 s timeout,
the approval card in the coordinator chat, `orchestration deny`, the
approval payload on stop escalations, and the held-delivery lines on send
receipts. Escalation text goes back to its pre-#40756 wording.

Kept from later commits:
- #40983 (lost-worker alerts): its `lost` reason, cause/leftover/settled
  fields, turnStartedAt and the rejected-report check stay; only the
  approval branches around them are removed.
- #41158 (owner moves) and the test cleanups (#41151, #41175, #41177)
  only touched approval code that is now deleted.

* feat(orchestration): answer workers' permission prompts from the coordinator (re-land of #40756)

* fix(orchestration): credit an approval from Claude's own decision record and place each worker card at its time

- An Allow that Claude took is answered by the person even when the command then fails or is still running; a failed command's PostToolUseFailure counts as ran.
- Expired means the agent's own timeout only; a close Orca can't name is not an expiry, and reasonDelivered is true only with a reason.
- Escalations wait for the dialog to paint and read Claude's warning even when a long command hides the top of its box.
- Worker cards and receipts render after the message they followed in time, not after the whole conversation; the toast says what happened.

* fix(native-chat): place timed rows without a memo the compiler skips

* perf(orchestration): feed chat approvals from their own stream, pin open cards, close cards whose worker ended

Native chats no longer subscribe to the crew stream for worker approvals. A
narrow orchestration.workerApprovalsSubscribe stream per chat party wakes only
on that party's own mail and on Run/Dispatch changes, never on agent status,
and reads the crew only when the approval list itself changes. The pane no
longer redraws for approvals: the transcript receipts and the pinned stack
each hold the feed themselves.

Open worker prompts are pinned above the composer (above the chat's own
prompt), oldest first, in a bounded scrolling stack; the transcript keeps only
receipts, at the time the worker asked. The countdown ticks only for open
cards in a visible pane.

An approval whose Dispatch is no longer running reads as closed ("No longer
open · worker ended"); a hook that hangs up after its worker is gone closes as
worker-ended rather than "answer it in the terminal"; and a click that finds
the prompt or Dispatch already gone turns the card into its receipt at once.

Also carries over: a stop owes a closing line only to an approval whose
escalation went out.

* fix(native-chat): no toast when a worker approval answer lands; the card's receipt says it

* fix(native-chat): a worker approval card answers on click, as the chat's own prompt does

The card turns into 'Allowed by you' at once and Claude's confirmation runs behind it; only an answer
Claude did not take changes it to the real outcome, and a failure reopens the card.

* fix(orchestration): keep main's stop-report index for the open-approval sweep after the re-land

* fix(orchestration): final-review fixes for chat worker approvals

- A click that gets approval_not_open no longer hides the card: the host's list decides, so a
  prompt the host still holds stays answerable. Only dispatch_inactive closes it locally.
- The approvals stream watches only the orchestration database's own changes (Runs, Dispatches,
  mail), not terminal identity notices, so agent status and title changes cost it nothing in main.
- Receipts are the chat's history: no 30-minute window, bounded by 100 rows with still-open
  prompts kept first.
- The pinned stack is capped against the pane and gives way first, so the chat's own prompt keeps
  its room; a prompt that closes while shown stays pinned as its receipt for 4 s, and one only the
  worker's terminal can answer stays pinned.
- A close no one named, after the worker's Dispatch ended, reads as worker-ended, and an
  unanswered close of an ended worker sends the coordinator no second notice.
- The transcript's receipts keep one array until a receipt changes.

* refactor(native-chat): a worker approval card waits on the host after a click instead of answering ahead of it

Both buttons turn off and the clicked one shows a spinner until the answer returns; the host's list
then turns the card into its receipt. Drops the client-side close and its reconciliation.

* fix(native-chat): let the compiler memoize the worker approval answer handler
2026-11-11 21:04:44 -05:00
..
…