Commit Graph
2445 Commits
Author SHA1 Message Date
T3 Code Test c99767e518 fix(orchestration-v2): protect pending Claude resumes 2026-08-14 20:52:14 +05:30
T3 Code Test d45c3e7f9a fix(orchestration-v2): guard Claude activation generations 2026-08-14 20:44:26 +05:30
T3 Code Test e4a4c60121 fix(orchestration-v2): settle subagent lifecycle races 2026-08-14 20:34:57 +05:30
T3 Code Test a1e1ab5f04 refactor(orchestration-v2): drop unused targeted task stop 2026-08-14 19:58:01 +05:30
T3 Code Test 200bcc9d8c test(orchestration-v2): make observability regressions explicit 2026-08-14 15:04:13 +05:30
T3 Code Test da996a85f9 fix(web): avoid double-counting workflow failures 2026-08-14 15:04:13 +05:30
T3 Code Test ee333b1929 fix(orchestration-v2): preserve settled subagent state 2026-08-14 15:04:13 +05:30
T3 Code Test b0839e45b9 feat(web): show v2 subagents through the Agents CTA 2026-08-14 15:04:13 +05:30
Shivam SharmaandClaude Fable 5 fc171656c7 style(orchestration-v2): keep service boundaries namespace-imported in the turn-start test
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]>
2026-08-14 15:04:13 +05:30
Shivam SharmaandClaude Fable 5 1aea7ba0d3 fix(threads): include archived threads in the unfiltered thread refs
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]>
2026-08-14 15:04:13 +05:30
Shivam SharmaandClaude Fable 5 1391f94470 fix: reconcile the observability series with the rebased v2 base
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 4b3f8be173 fix(orchestration-v2): apply Codex collab states that arrive before an activation
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 b95171112d style(orchestration-v2): import service modules as namespaces in the turn-start test
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 ba5b043d1f fix(orchestration-v2): require reactivation proof before identity routing
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 aeecfd01a9 test(web): reunite lineage windowing and detach-control coverage
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 4dc6d32100 fix(mobile): reset the unavailable decision synchronously on route change
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 f6e005ba0f fix(mobile): wait out thread hydration before declaring a thread unavailable
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 3a74176b65 fix(threads): keep subagent worktrees visible to cleanup
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 15:04:12 +05:30
T3 Code TestandClaude Fable 5 b8c54e76a3 fix: keep hidden subagent threads out of orphan checks and mobile routes
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]>
2026-08-14 15:04:12 +05:30
Shivam Sharma 36609fd932 test(web): update thread workflow mock 2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude 0e22482251 fix(web): preserve detachable thread controls
Co-Authored-By: Claude <[email protected]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Opus 5 67022de4a2 refactor(web,mobile): drop code left dead by hiding subagent threads
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]>
2026-08-14 15:04:12 +05:30
Shivam Sharma 7ac23a7523 feat(web): hide subagent threads from user-facing thread lists
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.
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 87cb5bc0ad fix(orchestration-v2): model task stop failures directly
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 6894fe9f6f fix(orchestration-v2): target live subagent sessions
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 9099ca6007 fix(orchestration-v2): stop stamping first-attempt workflow agents as retries
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]>
2026-08-14 15:04:12 +05:30
Shivam Sharma c62f0ccded feat(orchestration-v2): support stopping a workflow task 2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 75a41ed26e feat(orchestration-v2): capture workflow run handles from the launch ACK
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]>
2026-08-14 15:04:12 +05:30
Shivam SharmaandClaude Fable 5 3a2622f7ff fix(orchestration-v2): ignore settled subagent noise
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 15:04:12 +05:30
T3 Code TestandClaude Fable 5 fbb573b62e fix(orchestration-v2): leave zero-activation leftovers unseeded in turn ordinals
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]>
2026-08-14 15:04:12 +05:30
Shivam Sharma 289c000a57 test(orchestration-v2): register idle reuse replay expectations 2026-08-14 15:04:12 +05:30
Shivam Sharma 53d5009440 test(orchestration-v2): replay subagent reuse after idle 2026-08-14 15:04:12 +05:30
Shivam Sharma 22e15a8423 refactor(orchestration-v2): catch projection errors by tag 2026-08-14 15:04:11 +05:30
Shivam SharmaandClaude dedb92f627 fix(orchestration-v2): harden reused subagent recovery
Co-Authored-By: Claude <[email protected]>
2026-08-14 15:04:11 +05:30
Shivam SharmaandClaude Opus 5 6ece559186 test(orchestration-v2): cover subagent registry rehydration after a restart
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]>
2026-08-14 15:04:11 +05:30
Shivam Sharma 61c76c41ba feat(orchestration-v2): attribute reused subagents to the run driving them
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.
2026-08-14 15:04:11 +05:30
Shivam SharmaandClaude Fable 5 b819de73af fix(orchestration-v2): preserve subagent progress state
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-14 15:04:11 +05:30
T3 Code TestandClaude Fable 5 cdfbb9ac64 fix(orchestration-v2): address subagent observability review findings
- 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]>
2026-08-14 15:04:11 +05:30
Shivam SharmaandClaude Opus 5 39bc22bb2e test(orchestration-v2): replay a Claude workflow end to end
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]>
2026-08-14 15:04:11 +05:30
Shivam Sharma ae3a724dc9 feat(orchestration-v2): populate subagent observability from providers
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.
2026-08-14 15:04:11 +05:30
Shivam Sharma 2feacbf1fc test(mobile): include subagent activations in cached projection 2026-08-14 15:04:11 +05:30
Shivam SharmaandClaude Opus 5 5d008944dd refactor(orchestration-v2): drop the redundant subagent observability backfill
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]>
2026-08-14 15:04:11 +05:30
Shivam Sharma cb09929e16 feat(orchestration-v2): add subagent observability data model
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.
2026-08-14 15:04:11 +05:30
Julius MarmingeandClaude Fable 5 77168d081a fix(web): size the titlebar layout-control icons like the sidebar trigger
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]>
2026-08-14 11:24:06 +02:00
Julius MarmingeandClaude Fable 5 f6601420ad fix(web): align titlebar clusters to one shared pixel inset
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]>
2026-08-14 11:24:06 +02:00
Julius MarmingeandClaude Fable 5 a29fd51629 fix(web): keep the titlebar layout controls fixed across right-panel toggles
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]>
2026-08-14 11:24:06 +02:00
Julius MarmingeandClaude Fable 5 d6e8dd8161 fix: reconcile main's round-6 features after the rebase
- 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]>
2026-08-14 11:23:51 +02:00
Julius Marminge 8dcbdcac52 feat(contracts): track thread title regeneration
- Add optional title regeneration request and start time to thread shells
- Cover cache serialization on mobile and client runtime
2026-08-14 11:23:51 +02:00
Julius Marminge 402fde73dd feat(orchestration): bound thread history and resume payloads
- Add paginated thread history with bounded snapshots and replay limits
- Trim oversized wire payloads and support progressive mobile history loading
2026-08-14 11:23:51 +02:00
Julius MarmingeandClaude Fable 5 c03c9926ad fix(web): restore main's collapse chrome and tab-status keying on the PR panel
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]>
2026-08-14 11:23:51 +02:00