The rebase reconstruction of this file left each service module imported
twice — once as a namespace and once for its tag. At a service boundary
the namespace shape is the convention, so the duplicate named imports go
and their uses read through the module.
Co-Authored-By: Claude Fable 5 <[email protected]>
Worktree cleanup treats listAllThreadRefs as the complete set, but it
mapped only the live shells. A worktree held solely by an archived
thread was therefore classified orphaned and offered for removal — the
same data-loss shape this RPC exists to prevent, through a different gap.
Also drops the two toSorted calls in the subagent derivations: this
module is mobile-reachable and Hermes ships no ES2023 change-by-copy
array methods, so an Android import could crash. The regression deletes
toSorted from the prototype while exercising both derivations.
Co-Authored-By: Claude Fable 5 <[email protected]>
The base rebased onto main again, renumbering migrations (subagent
observability moves 045 to 046) and reworking three paths this series
extends: Claude's background-task lookup, ACP's terminal-status helper,
and turn-item routing for inherited background items. Each merge keeps
both intents — the base's newer mechanism with this branch's activation,
identity-proof, and completedAt semantics.
ProviderTurnStartService.test.ts was added on both sides as different
files; rebuilt as the base's suite plus this branch's rehydration tests.
Test mocks and fixtures gain the members the observability types now
require.
Co-Authored-By: Claude Fable 5 <[email protected]>
registerSubagentThreads emits a running subagent whose currentActivationId
stays null until the child turn opens an activation. The settled-noise gate
skipped every state without one, so a terminal state carried on the spawning
frame itself was dropped and the agent stuck at running. The gate now only
drops states for identities that are already settled; an active identity
without an activation is a just-registered agent whose state still counts.
Co-Authored-By: Claude Fable 5 <[email protected]>
Aliasing a module's layer erases the service namespace at the call site;
the boundary convention keeps the module name visible.
Co-Authored-By: Claude Fable 5 <[email protected]>
Pre-seeded reactivatable identities were treated as current-run
ownership, so an interrupted prior run's trailing traffic — delayed
non-terminal rows, activation updates, subagent items — was admitted and
misattributed: stale child threads got adopted, ingestion could be held
open indefinitely, and finalization could terminalize a prior run's
activation with this run's outcome.
Identity routing now requires proof that this run drives the agent. The
seed carries each identity's activation count at turn start; a genuine
re-activation always advances past that baseline, while trailing
traffic re-emits at it. Rows carrying this run's id, rows advancing the
baseline, and activations with a higher ordinal all prove it; until one
arrives, identity-only events are refused, and the lifecycle tracker
keys on the proven set rather than the seeded one.
Also folds in two review fixes: Claude cache-read tokens now count into
inputTokens (they are input the model consumed, and excluding them broke
reconciliation with the four-component total), and a running workflow
coordinator stays counted in the Agents panel while all its members are
settled — between phases the coordinator is the only live row, and
dropping it read "0 active" for a visibly running workflow.
Co-Authored-By: Claude Fable 5 <[email protected]>
The rebase both-added this file: the base's lineage-window tests and the
detach-control tests landed as competing versions. Keep both suites, and
teach the panel mocks about the base's row-ordering export.
Co-Authored-By: Claude Fable 5 <[email protected]>
The decision state survived navigation on the same mounted screen: after
the timer fired for one thread, the next route's first render still saw
decided=true before the effect could reset it, flashing the unavailable
screen the delay exists to prevent. The state is now keyed by route and
reset during render, so a stale decision can never apply to a new route.
Co-Authored-By: Claude Fable 5 <[email protected]>
Thread selection resolves after the connection reports available, and a
hidden subagent thread's redirect-to-parent depends on that selection
landing. Deciding unavailable the instant the connection is ready
flashed the error screen over what was actually a redirect. The
unavailable state now waits out a short per-route decision window; the
redirect or content wins the race whenever the data arrives.
Co-Authored-By: Claude Fable 5 <[email protected]>
Worktree bookkeeping now reads every thread in the environment, so
deleting a parent no longer flags a worktree as orphaned while hidden
subagent threads still hold it. Mobile thread routes redirect internal
subagent threads to their parent instead of rendering the hidden
transcript, matching the web route guard.
Co-Authored-By: Claude Fable 5 <[email protected]>
Removing the "Open subagent thread" affordance left the mobile work log
subscribing to item support it no longer reads, and the web sidebar
importing a predicate it no longer calls. Both tripped the lint rule the
CI Check job enforces.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A subagent's child thread is an implementation detail of the agent that
owns it, not a conversation the user started. Listing them alongside real
threads makes the sidebar grow with every delegation.
Filtered at the source — the shell snapshot the server serves — so every
client sees the same set rather than each re-deriving it. The web client
filters again for locally-held state, and the thread route redirects to
the parent if a subagent thread is reached directly.
Mobile is part of the sweep, not left behind. It still offered "Open
subagent thread" and had no redirect to fall back on, so it would have
navigated to a thread the client no longer receives. Its relationships
banner also needed the same subagent-edge filter web has: those edges are
derived from the projection rather than from thread shells, so they
survive the shell filtering and would have rendered as "Unavailable" —
and, sorting first, could have taken over the banner headline.
Trade-off worth stating plainly: a subagent's transcript becomes
unreachable. The Agents panel added in the previous PR shows what an
agent did and what it returned, but not its full conversation. That is
the intended shape here, and the "Open subagent thread" affordances are
removed on both clients rather than left as dead ends.
Live testing showed every workflow agent wearing a "retry 2" badge on
its first attempt: the SDK reports attempt 1-based once an agent starts,
and the adapter added 1 on top assuming 0-based. Clamp absent or 0 up
to 1 instead of incrementing.
Found by a computer-use pass against a real workflow run; the replay
fixture's hand-authored attempt: 0 normalizes to the same 1 as before.
Co-Authored-By: Claude Fable 5 <[email protected]>
The Workflow tool result is the run's only carrier of its disk handles
(script path, transcript dir, run id) and remote session URL. Attach them
to the coordinator's workflow struct so script view, transcripts, and
resume-command affordances have something to read.
The workflow input on updateClaudeSubagentNode becomes a merged partial:
phases arrive on progress snapshots, the name on task_started, and
handles on the tool result, so no writer may clobber the others.
Workflow tool_uses now skip toolCalls like Agent ones do — the
coordinator subagent row is the run's timeline representation, and
registering the tool call too would double-render it. The launch ACK
consequently routes through the subagent branch, which must not
terminalize the coordinator (only task_notification does).
sessionUrl is scheme-restricted to http(s) at the adapter; the replay
fixture carries a hostile javascript: URL to pin the filter.
Co-Authored-By: Claude Fable 5 <[email protected]>
The rehydration seed stored Math.max(1, activationCount) in a map that
tracks the last issued ordinal, so a leftover with no recorded
activations started its first turn at ordinal 2 and skipped
childRootNodeId. Skip seeding those entries so the first turn takes
ordinal 1.
Co-Authored-By: Claude Fable 5 <[email protected]>
A fresh adapter is the post-restart state: the process-local registry is
empty, so a returning native child thread can only be recognised through
the identities the projection hands back in existingSubagents.
Drives a transcript with no spawn frame, seeds one idle subagent, and
asserts the returning thread reuses that identity, continues the
activation count and ordinal rather than restarting them, and keeps the
usage recorded before the restart. Paired with a negative control that
replays the same transcript unseeded.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A subagent row keeps the run id it was spawned under. Routing admits a
row by run or by parent thread, and the parent thread is excluded by
construction, so a later run re-activating that subagent could only see
its updates while the spawning run's ingestion fiber happened to still be
alive. The Claude adapter already re-attributed on reopen for exactly
this reason; this brings the same treatment to routing and to Codex.
Reuse arrives on item/completed, not item/started: resumeAgent and
sendInput only ever complete, and registerSubagentThreads ignores them
because they are not spawnAgent. Hooking the rebind there is what makes
it fire — subagent_continue now asserts the subagent is attributed to the
run that drove it, where before it stayed pinned to the spawning run.
Routing gains a third test: subagent identity, seeded from the projection
at turn start. The child thread is adopted only while the agent is live,
because a settled row is also re-emitted by trailing traffic — a token
usage frame or a collab state sweep — and adopting on those would hand a
later run an interrupted agent's thread, readmitting the stale events
that post-interrupt recovery exists to exclude.
A subagent's row and its timeline item are emitted together, so both
route by identity; matching only the row advanced the agent while its
item stayed frozen on the spawning run.
The reactivation predicate is separate from canRouteRelatedSubagent
rather than a widening of it, for the same reason: an interrupted agent
must not have its child thread pre-owned, but its identity is still
resumable, because the user stopped it rather than losing it.
Rehydration seeds turn ordinals alongside the registry — restarting them
at 1 would re-derive childRootNodeId for a different native turn — and
parks non-terminal leftovers at idle, since a new session can never
terminalize an activation it did not drive and would otherwise keep the
session pinned open.
Not proven: rehydration itself. The fixture that would exercise it is
recorded but does not replay to completion, for reasons unrelated to
these changes, and is left unregistered with the open question written
up in fixtures/index.ts.
- Treat pending/waiting workflow agents as active in the session-registry
write guard and wake-buffer pre-open, so concurrent active transitions
are not dropped and wake task_started cannot force a false resume.
- Preserve the first-recorded activation completion time on duplicate
terminal frames (Claude in-place update and ACP rebuilt emits).
- Let a blocked/waiting first snapshot of a new attempt reopen a settled
workflow agent entry instead of silently dropping its status and usage.
- Settle still-active workflow members when their coordinator
terminalizes, and expect the Implementer completed in claude_workflow.
Co-Authored-By: Claude Fable 5 <[email protected]>
The adapter's workflow projection was covered in isolation and the panel
derivation was covered against synthetic agents, but nothing drove real
workflow frames through the orchestrator to the projection the client
receives.
Adds a claude_workflow replay fixture: a local_workflow task with two
phases and two members, asserted on the resulting projection. Pins what
the panel groups by — that members claim declared phases, that their
membership points at the coordinator that actually reached the
projection, and that the coordinator's usage still covers its members
so subtracting theirs cannot go negative.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Fills in the data model added by the previous PR. Every adapter now
reports what its subagents are actually doing: role provenance, token
usage, recent activity, and per-activation records.
Usage needs two merge strategies because providers report it
differently. Codex sends cumulative snapshots per thread, so those merge
by maximum — duplicate and late out-of-order frames then leave the total
unchanged instead of inflating it. Claude reports per activation, so
lifetime usage accumulates only the delta since the previous snapshot.
A subagent identity is reusable, so completing an activation leaves it
at "idle" rather than "completed"; the timeline row for that activation
is still recorded as completed via the status mapping.
A Codex subAgentActivity frame carries no model of its own, so agents
registered from one were recorded with none at all — the common case for
Codex-native subagents, which then showed a role and a token count but
no model. They are recorded against the turn's model selection, which is
what they actually run on.
Three activation-lifecycle fixes in the Claude adapter, found in review:
- A resume that raced past settle was pre-opened by the wake buffer,
which erased the terminal status the reopen check reads. The resume
then reused the finished activation instead of starting a new one, so
its ordinal stopped matching reality and its usage was measured
against the previous activation's totals — clamping the delta to zero
and silently dropping the resumed run's tokens. The pre-open now
records that it happened, and the reopen check honours it.
- A replayed "waiting" frame could resurrect a settled subagent; only
pending/running were guarded before.
- A duplicate terminal frame re-stamped completedAt, drifting the
recorded completion time. Codex already preserved it; Claude now
matches.
Reuse across runs is deliberately not addressed here — a subagent row
still carries the run it was spawned under. That is the next PR.
Every observability field the migration backfilled carries a decoding
default equal to the value it wrote, so pre-upgrade rows already read
back correctly without it. The projection schema version bump also
fails startup verification, which deletes and replays those rows from
the event log before anything reads them.
Pin both halves: a contracts test decodes a stored payload missing all
eight fields through the schema the projection actually uses, and the
migration test asserts an existing row survives byte-identical.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Introduces the schema, storage, and migration for richer subagent
tracking. Nothing produces the new data yet — adapters populate neutral
defaults so every subagent row remains valid — which keeps this change
reviewable as a pure data-model step.
Contracts gain a reusable subagent identity: per-activation records
(SubagentActivationId, OrchestrationV2SubagentActivation), cumulative
usage, a role, recent activity, and workflow grouping. A subagent may
now also rest at "idle" between activations.
Because a subagent status is not a turn item status, the two are bridged
by an explicit mapping rather than a copy. The Record type makes that
total: adding a subagent status without giving it a timeline meaning is
a compile error. Without it, a producer can emit a turn item whose own
schema cannot decode it, which is unrecoverable — the projection rebuild
then fails on every subsequent startup and the server cannot boot.
Migration 043 backfills existing rows so old events stay readable. Its
riskiest path is a partially-migrated row, where already-present JSON is
round-tripped through COALESCE; a test pins that structured values keep
their JSON subtype rather than being rewritten as quoted strings.
Also narrows event-envelope attribution in ProviderEventIngestor: a
payload carrying an explicit null run or node id now keeps that null
instead of inheriting the ambient run. Activations legitimately have no
run id, and the envelope is persistence metadata only — routing reads
payload fields — but this does change stored metadata for existing
event types that already pass explicit nulls.
The trigger's icon falls through to the Button default (size-4) while the
right cluster hard-coded size-3.5, so the two ends of the titlebar read a
pixel apart on every edge. All five layout-control icons now use size-4,
matching the trigger and the pull requests page's refresh icon.
Co-Authored-By: Claude Fable 5 <[email protected]>
The right controls carry mr-px (main's border compensation for anchoring
inside the panel frame), which left the sidebar trigger one pixel closer
to its edge and the sheet-mode tab bar one pixel tighter than the closed
state. Mirror the pixel on the trigger and the sheet layout-controls slot
so all three read the same inset.
Co-Authored-By: Claude Fable 5 <[email protected]>
Restores main's one-inset rule (#5226) that a rebase resolution had
overridden with a conditional right-2 offset, which made the controls jump
sideways whenever the right panel opened. Also restores the live-agent
count badge on the right-panel toggle (#5745) that the round-6 replay
dropped, and applies the same fixed-position rule to the pull requests
page: the toggle now stays mounted at one absolute inset in both states,
with a footprint spacer in the list header so the refresh button never
slides underneath it.
Co-Authored-By: Claude Fable 5 <[email protected]>
- ChatView: #5880 auto-settle-on-merge setting flows into effectiveSettled,
#5644 browser favicon project registration effect, activeProjectRef memo,
desktopByTabId on both RightPanelTabs mounts
- server: provide ServerSecretStore to the McpSessionRegistry's
ServerEnvironment layer (#6325 reads publish opt-in per descriptor)
- mobile: 3-way merged main's deltas into the v2 thread screens
(NewTaskDraftScreen keeps the branch title seed + main's environmentId,
threadListV2 keeps both new test suites, queries imports deduped)
Co-Authored-By: Claude Fable 5 <[email protected]>
The round-5 ChatView reconciliation kept the round-3-era PullRequestDetailPanel
call, so the panel mounted without chromeVariant="collapse" — the #6039
scroll-condensing chrome never engaged and the description scrolled under a
full-height chrome. Restore main's call exactly: collapse chrome,
composerDraftTarget for same-thread hand-offs, the isThreadOwnPullRequest
context check, and tab statuses keyed by the active surface id via
updatePullRequestTabStatus instead of a key rebuilt from the status payload.
Co-Authored-By: Claude Fable 5 <[email protected]>