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]>
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.
- 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]>
Follow-up to the #5757 port: start and steer turns now append the
'[Attached ... is saved at: path]' line, so the adapter fixtures assert it.
Co-Authored-By: Claude Fable 5 <[email protected]>
- a6c9b41f90 (agents open pasted images): ClaudeAdapterV2 now grants the
attachments dir alongside cwd via additionalDirectories and appends
'[Attached ... is saved at: path]' lines to the turn text so tools can
dereference pasted images (pixels alone are not tool-readable).
- 5bb8c03664 (settle leaves monitors running): thread.settle now joins
archive/delete in the provider-session detach set, so PR monitors, dev
servers and subagent fleets stop when the user parks the thread. The
settle guard already rejects active runs, and serialized dispatch closes
the re-engage race the v1 fix handled with onlyIfSettled.
- e70cdb478d (Claude resume handshakes) and 2c7267ad43 (reaper vs live
background subagents) are already covered structurally in v2: results
are turn-scoped with explicit zero-turn handshake drops, and idle
release is pinned while background work is pending.
Co-Authored-By: Claude Fable 5 <[email protected]>
Main released ProjectionThreadsPinOrderKey (038),
ProjectionProjectsDefaultThreadEnvMode (039) and
ProjectionProjectFaviconPath (040), so the branch-private v2 stack shifts
up by three. Registry ids were already 41-49; this renames the files and
identifiers to match and updates the ledger expectations and through-id
boundaries in the migration tests (released boundary 37 -> 40).
Co-Authored-By: Claude Fable 5 <[email protected]>
Native subagent observability (#5219), wired per its spec's v2 merge plan:
- getWorkflowScript RPC re-homed onto the v2 WS surface (contracts, rpc
group, ws handler, auth scope, client atom).
- AgentsPanel fed by the spec's mapper swap: projectedSubagentsToRuntime
maps orchestration-v2 subagent entities into the panel model;
deriveAgentPanelModel's v2Projection leg is now live and the v1 fold
never runs. Agents surface wired into ChatView + RightPanelTabs.
Other ports and reconciliations:
- Shell reconnect-loop fix (#5561) ported into the v2 shell sync
(same-session resubscribes resume from the in-memory cursor), with the
cursor-resume regression test adapted to v2 fixtures.
- Mobile end-follow latch (#5566) ported onto the v2 ThreadFeed.
- Claude ede_diagnostic interrupt classification (#5557) ported into
ClaudeAdapterV2 (aborted_tools/aborted_streaming => interrupted; CLI
telemetry never becomes the failure banner). #5559 needs no v2 port
(unknown system subtypes are already ignored).
- Plan sidebar removed from the v2 ChatView/ChatComposer per main's
plans-fold-into-chat rework (#5558); rightPanelStore stays at main's
surface set.
- SettingsPanels rebuilt as main's refactored version plus the branch's
composer-context setting; sidebar snooze respects the time format
(#4438 follow-through).
- v1-only leftovers deleted: zombie v1 adapters/ingestion/tests the v2
rewrite removes, the v1-bound transfer-budget CI harness (#5350, needs
a v2 rebuild), and main's v1 client pagination machinery (#5493 client
side; the 037 keyset migration is kept — server-side v2 windowing is a
follow-up).
Co-Authored-By: Claude Fable 5 <[email protected]>
Main owns migration numbering: 037_ProjectionTurnsKeysetIndex landed on
main (#5493), so the v2 migrations shift from 037-045 to 038-046.
Co-Authored-By: Claude Fable 5 <[email protected]>
rerere replayed stale resolutions during the rebase and committed nested
conflict markers in several files. Restore the branch-intended v2 shapes
and re-graft main's compatible additions (pending-card opacity comments,
theme-editor keybinding test, mobile scroll re-arm effects from #5566).
Co-Authored-By: Claude Fable 5 <[email protected]>
- Port thread pinning (#5312) into the orchestration-v2 command pipeline:
thread.pin/unpin commands, thread.pinned/unpinned events, pinnedAt on the
v2 thread state and projected shells, promotion semantics (pin clears
settle/snooze, settle clears pin) matching the v1 decider, and client
pin/unpin operations in the v2 dispatch style.
- Port the regenerated-title context anchoring (#5365) into
ThreadTitleRegenerationService: pin the first user message ahead of the
retained tail when the digest is truncated.
- Re-apply the right-panel controls positioning from #5260 to the v2
ChatView title bar controls.
- Repair merge artifacts: committed conflict markers in BranchToolbar,
duplicate capability keys, duplicate CommandPalette import, v1 turn
naming in DiffPanel's focus-refresh effect, onSend signature merge.
Co-Authored-By: Claude Fable 5 <[email protected]>
Main owns migration numbering: 036_ProjectionThreadsPinned landed on main,
so the v2 migrations shift from 036-044 to 037-045. Release path runs all
of main's migrations first, then the v2 stack.
Co-Authored-By: Claude Fable 5 <[email protected]>
The codex resume test was the only replay scenario without a
runtimePolicyOverride, so its checkpoint scope cwd fell back to
process.cwd() and baseline capture ran real git over the entire
checkout. Locally the capture short-circuits on checkpoint refs left
behind by earlier runs; on a fresh CI checkout it is a cold multi-second
capture that outlives the scenario wait budget, failing await_thread_idle
while the run is still mid-checkpoint. Point the fixture's turn/start
frames at the <workspace> placeholder and checkpoint a throwaway git
workspace like every other replay test.
Scenario waits are also wall-clock-bounded now: the iteration budget
counts event-loop turns, which burn at full speed while git/fixture IO
is in flight, so exhaustion additionally requires a 60s real-time
deadline to pass.
Co-Authored-By: Claude Fable 5 <[email protected]>
Hoist inline Schema compiles to module scope, drop unused
imports/vars, stabilize react-markdown component identities via a
module-scope factory, remove useless spreads, and use data-derived
keys for release-note bullets. No behavior changes.
Co-Authored-By: Claude Fable 5 <[email protected]>