feat(web): surface orchestration agents in the timeline #4664
Closedshivamhwp(GitHub profile, opens in a new tab)wants to merge 250+ commits into
t3code/codex-turn-mapping fromsubagent-obs/05-thread-visibilityopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/state/entities.ts line 223OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -204,4 +217,7 @@204217 export function readEnvironmentThreadRefs(205218 environmentId: EnvironmentId,206219 ): ReadonlyArray<ScopedThreadRef> {207- return appAtomRegistry.get(environmentThreadShells.environmentThreadRefsAtom(environmentId));220+ return appAtomRegistry221+ .get(environmentThreadShells.threadShellsAtom)222+ .filter((thread) => thread.environmentId === environmentId && isUserFacingThread(thread))223+ .map((thread) => scopeThreadRef(thread.environmentId, thread.id));
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 192OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -156,3 +179,14 @@156179 // loading placeholder while messages fetch, and the composer's connection157180 // pill reports connecting/reconnecting/syncing status.158181 if (selectedThread !== null && selectedThreadKey === routeThreadKey) {182+ // Internal subagent threads are hidden from user-facing lists; a deep183+ // link or stale selection still lands here, so send it to the parent184+ // thread instead of exposing the hidden transcript.185+ if (selectedThread.lineage.relationshipToParent === "subagent") {186+ return (187+ <SubagentThreadRedirect188+ environmentId={selectedThread.environmentId}189+ parentThreadId={selectedThread.lineage.parentThreadId}190+ />191+ );192+ }
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 185OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -156,3 +179,7 @@156179 // loading placeholder while messages fetch, and the composer's connection157180 // pill reports connecting/reconnecting/syncing status.158181 if (selectedThread !== null && selectedThreadKey === routeThreadKey) {182+ // Internal subagent threads are hidden from user-facing lists; a deep183+ // link or stale selection still lands here, so send it to the parent184+ // thread instead of exposing the hidden transcript.185+ if (selectedThread.lineage.relationshipToParent === "subagent") {apps/web/src/state/entities.ts line 229OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -204,4 +217,13 @@204217 export function readEnvironmentThreadRefs(205218 environmentId: EnvironmentId,206219 ): ReadonlyArray<ScopedThreadRef> {207- return appAtomRegistry.get(environmentThreadShells.environmentThreadRefsAtom(environmentId));220+ return appAtomRegistry221+ .get(environmentThreadShells.threadShellsAtom)222+ .filter((thread) => thread.environmentId === environmentId && isUserFacingThread(thread))223+ .map((thread) => scopeThreadRef(thread.environmentId, thread.id));224+}225+226+/** Every thread in the environment, including internal subagent threads.227+ Worktree bookkeeping must see all threads that can hold a worktree228+ reference, or deleting a parent reads its subagents' worktree as orphaned. */229+export function readEnvironmentAllThreadRefs(
- apps/web/src/hooks/useThreadActions.ts line 291OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -278,5 +285,7 @@278285 : undefined;279286 const survivingThreads =280287 deletedIds && deletedIds.size > 0281- ? threads.filter((entry) => entry.id === threadRef.threadId || !deletedIds.has(entry.id))282- : threads;288+ ? allThreads.filter(289+ (entry) => entry.id === threadRef.threadId || !deletedIds.has(entry.id),290+ )291+ : allThreads;
shivamhwp(GitHub profile, opens in a new tab) changed the title
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 193OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -156,3 +180,14 @@156180 // loading placeholder while messages fetch, and the composer's connection157181 // pill reports connecting/reconnecting/syncing status.158182 if (selectedThread !== null && selectedThreadKey === routeThreadKey) {183+ // Internal subagent threads are hidden from user-facing lists; a deep184+ // link or stale selection still lands here, so send it to the parent185+ // thread instead of exposing the hidden transcript.186+ if (isInternalSubagentThread(selectedThread)) {187+ return (188+ <SubagentThreadRedirect189+ environmentId={selectedThread.environmentId}190+ parentThreadId={selectedThread.lineage.parentThreadId}191+ />192+ );193+ }
shivamhwp(GitHub profile, opens in a new tab) changed the title
- apps/server/scripts/record-codex-app-server-replay-fixture.ts line 484OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -447,0 +464,21 @@464+ turnDefaults: {465+ approvalPolicy: "never",466+ sandboxPolicy: workspaceWriteSandbox(),467+ },468+ steps: [469+ {470+ type: "interruptedTurn",471+ label: "spawn-subagent-then-interrupt",472+ prompt: SUBAGENT_REUSE_AFTER_INTERRUPT_PROMPT,473+ interruptAfterCommandExecutionStarted: true,474+ },475+ {476+ type: "turn",477+ label: "reuse-interrupted-subagent",478+ prompt: SUBAGENT_REUSE_AFTER_INTERRUPT_RESUME_PROMPT,479+ },480+ ],481+ },482+ ],483+ },484+ {apps/server/scripts/record-codex-app-server-replay-fixture.ts line 454OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -445,3 +451,4 @@445451 },446452 ],447453 },454+ {
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 160OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -128,0 +140,21 @@140+ navigation.dispatch(StackActions.replace("Home"));141+ return;142+ }143+ navigation.dispatch(144+ StackActions.replace("Thread", {145+ environmentId,146+ threadId: parentThreadId,147+ }),148+ );149+ }, [environmentId, navigation, parentThreadId]);150+ return <OpeningThreadLoadingScreen />;151+}152+153+// Thread selection resolves on its own tick after the connection reports154+// available, and a hidden subagent thread's redirect depends on that155+// selection landing. Deciding "unavailable" the instant the connection is156+// ready flashes the error screen over what is actually a redirect (or a157+// late-arriving shell); the decision must wait out this window first.158+const UNAVAILABLE_DECISION_DELAY_MS = 1_500;159+160+function useThreadUnavailableDecision(routeThreadKey: string | null, connectionReady: boolean) {
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 168OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -128,0 +148,21 @@148+ );149+ }, [environmentId, navigation, parentThreadId]);150+ return <OpeningThreadLoadingScreen />;151+}152+153+// Thread selection resolves on its own tick after the connection reports154+// available, and a hidden subagent thread's redirect depends on that155+// selection landing. Deciding "unavailable" the instant the connection is156+// ready flashes the error screen over what is actually a redirect (or a157+// late-arriving shell); the decision must wait out this window first.158+const UNAVAILABLE_DECISION_DELAY_MS = 1_500;159+160+function useThreadUnavailableDecision(routeThreadKey: string | null, connectionReady: boolean) {161+ const [decided, setDecided] = useState(false);162+ useEffect(() => {163+ setDecided(false);164+ if (!connectionReady) return;165+ const timer = setTimeout(() => setDecided(true), UNAVAILABLE_DECISION_DELAY_MS);166+ return () => clearTimeout(timer);167+ }, [routeThreadKey, connectionReady]);168+ return decided;
- packages/client-runtime/src/state/orchestrationV2Subagents.ts line 123OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +103,21 @@103+ if (workflowId === undefined) continue;104+ memberTotalsByWorkflow.set(105+ workflowId,106+ (memberTotalsByWorkflow.get(workflowId) ?? 0) + (agent.usage?.totalTokens ?? 0),107+ );108+ }109+ const workflowIdsWithReportedUsage = new Set(110+ workflows.flatMap((workflow) => (workflow.usage === null ? [] : [workflow.id])),111+ );112+ const reportedUsage = input.subagents.flatMap((agent) => {113+ if (agent.usage === null) return [];114+ const workflowId = agent.workflowMembership?.workflowSubagentId;115+ return workflowId !== undefined && workflowIdsWithReportedUsage.has(workflowId)116+ ? []117+ : [agent.usage.totalTokens];118+ });119+ // Count the workers, plus any coordinator that has no members yet. A120+ // coordinator with members is represented by them and would double-count;121+ // one without is the only row on the thread, and omitting it reported122+ // "0 active" while a workflow was visibly running.123+ const counted = input.subagents.filter(apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts lines 1517 to 1519OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1411,0 +1499,21 @@1499+ nonNegativeInteger(recordField(value, "totalToolUseCount"));1500+ const durationMs =1501+ nonNegativeInteger(recordField(value, "duration_ms")) ??1502+ nonNegativeInteger(recordField(value, "totalDurationMs"));1503+ if (1504+ inputTokens === undefined &&1505+ cacheCreationTokens === undefined &&1506+ cachedInputTokens === undefined &&1507+ outputTokens === undefined &&1508+ nonNegativeInteger(recordField(value, "total_tokens")) === undefined &&1509+ nonNegativeInteger(recordField(value, "totalTokens")) === undefined &&1510+ toolUses === undefined &&1511+ durationMs === undefined1512+ ) {1513+ return undefined;1514+ }1515+ return {1516+ totalTokens,1517+ ...(inputTokens === undefined && cacheCreationTokens === undefined1518+ ? {}1519+ : { inputTokens: (inputTokens ?? 0) + (cacheCreationTokens ?? 0) }),apps/server/src/orchestration-v2/RunExecutionService.ts line 454OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -359,5 +447,8 @@359447 }360448 return [true, addProviderThread(event.node.providerThreadId)];361449 }362- case "subagent.updated":363- return [ownsRun(event.subagent.runId) || ownsChildThread(event.subagent.threadId), state];450+ case "subagent.updated": {451+ const belongs =452+ ownsRun(event.subagent.runId) ||453+ ownsChildThread(event.subagent.threadId) ||454+ ownsSubagent(event.subagent.id);
- apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts lines 32 to 35OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +15,21 @@15+} from "@t3tools/contracts";16+import * as DateTime from "effect/DateTime";17+import * as Effect from "effect/Effect";18+import * as Layer from "effect/Layer";19+import * as Ref from "effect/Ref";20+21+import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts";22+import { EventSinkV2 } from "./EventSink.ts";23+import { layer as idAllocatorLayer } from "./IdAllocator.ts";24+import type { ProviderAdapterV2SessionRuntime } from "./ProviderAdapter.ts";25+import {26+ ProjectionStoreReadError,27+ ProjectionStoreThreadNotFoundError,28+ ProjectionStoreV2,29+ type ProjectionStoreV2Error,30+} from "./ProjectionStore.ts";31+import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";32+import {33+ layer as providerTurnStartLayer,34+ ProviderTurnStartServiceV2,35+} from "./ProviderTurnStartService.ts";
- apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 2484OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2241,18 +2476,9 @@22412476 const subagents = yield* Ref.get(subagentThreads);22422477 for (const [nativeThreadId, state] of Object.entries(input.item.agentsStates)) {22432478 const subagent = subagents.get(nativeThreadId);2244- if (subagent === undefined) {2479+ if (subagent === undefined || subagent.task.currentActivationId === null) {22452480 continue;22462481 }2247- const nativeStatus = String(state.status);2248- const status: OrchestrationV2Subagent["status"] =2249- nativeStatus === "completed"2250- ? "completed"2251- : nativeStatus === "failed" || nativeStatus === "errored"2252- ? "failed"2253- : nativeStatus === "cancelled" || nativeStatus === "closed"2254- ? "cancelled"2255- : "running";22562482 yield* emitSubagentTaskUpdate({22572483 subagent,2258- status,2484+ status: codexCollabAgentStatus(state.status),
- packages/client-runtime/src/state/orchestrationV2Subagents.ts line 90OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +70,21 @@70+ const workflowId = agent.workflowMembership?.workflowSubagentId;71+ if (workflowId === undefined) {72+ direct.push(agent);73+ continue;74+ }75+ const members = membersByWorkflow.get(workflowId) ?? [];76+ members.push(agent);77+ membersByWorkflow.set(workflowId, members);78+ }79+80+ const groups: OrchestrationV2SubagentGroup[] = workflows.map((workflow) => {81+ const members = membersByWorkflow.get(workflow.id) ?? [];82+ membersByWorkflow.delete(workflow.id);83+ const phases = (workflow.workflow?.phases ?? []).map((phase) => {84+ const agents = members85+ .filter((agent) => agent.workflowMembership?.phaseIndex === phase.index)86+ .toSorted(87+ (left, right) =>88+ (left.workflowMembership?.agentIndex ?? 0) -89+ (right.workflowMembership?.agentIndex ?? 0),90+ );
- apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts lines 38 to 38OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -14,8 +18,21 @@1418 import * as Layer from "effect/Layer";19+import * as Ref from "effect/Ref";20+import { expect, vi } from "vite-plus/test";15211622 import * as ContextHandoffService from "./ContextHandoffService.ts";23+import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts";1724 import * as EventSink from "./EventSink.ts";25+import { EventSinkV2 } from "./EventSink.ts";1826 import * as IdAllocator from "./IdAllocator.ts";27+import type { ProviderAdapterV2SessionRuntime } from "./ProviderAdapter.ts";1928 import * as ProjectionStore from "./ProjectionStore.ts";29+import {30+ ProjectionStoreReadError,31+ ProjectionStoreThreadNotFoundError,32+ ProjectionStoreV2,33+ type ProjectionStoreV2Error,34+} from "./ProjectionStore.ts";2035 import * as ProviderSessionManager from "./ProviderSessionManager.ts";36+import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";2137 import * as ProviderTurnStart from "./ProviderTurnStartService.ts";38+import * as ProviderTurnStartService from "./ProviderTurnStartService.ts";
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 3283OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2880,2 +3172,2 @@28803172 // re-open must not clobber its result.28813173 yield* Ref.update(sessionSubagentsByTaskId, (current) => {apps/web/src/components/chat/MessagesTimeline.tsx line 1569OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1484,0 +1549,21 @@1549+ ...workflowGroup.phases.flatMap((phase) => phase.members),1550+ ...workflowGroup.unphasedMembers,1551+ ];1552+ const fallbackMemberCount =1553+ spawn.workflowId === null1554+ ? memberIds.size1555+ : [...memberIds].filter((id) => id !== spawn.workflowId).length;1556+ const agentCount = Math.max(agents.length, fallbackMemberCount);1557+ const useItemStatus = agents.length === 0;1558+ const running = useItemStatus1559+ ? props.item.status === "running" || props.item.status === "pending"1560+ ? 11561+ : 01562+ : agents.filter((agent) => agent.status === "running" || agent.status === "pending").length;1563+ const waiting = useItemStatus1564+ ? props.item.status === "waiting"1565+ ? 11566+ : 01567+ : agents.filter((agent) => agent.status === "waiting").length;1568+ const idle = useItemStatus ? 0 : agents.filter((agent) => agent.status === "idle").length;1569+ const failed = useItemStatusapps/web/src/components/chat/MessagesTimeline.tsx line 1547OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1484,0 +1527,21 @@1527+ if (spawn === undefined) {1528+ return (1529+ <V2LifecycleRow1530+ item={props.item}1531+ createdAt={props.createdAt}1532+ timestampFormat={shared.timestampFormat}1533+ providerStatuses={shared.providerStatuses}1534+ runs={shared.runs}1535+ onOpenThread={shared.onOpenThread}1536+ />1537+ );1538+ }1539+1540+ const memberIds = new Set(spawn.agentIds);1541+ const workflowGroup =1542+ spawn.workflowId === null1543+ ? undefined1544+ : agentPanelModel.workflows.find((group) => group.workflow.id === spawn.workflowId);1545+ const agents =1546+ workflowGroup === undefined1547+ ? agentPanelModel.directAgents.filter((agent) => memberIds.has(agent.id))
- apps/web/src/components/chat/MessagesTimeline.tsx line 1595OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1484,0 +1575,21 @@1575+ spawn.workflowId === null1576+ ? memberIds.size1577+ : [...memberIds].filter((id) => id !== spawn.workflowId).length;1578+ const agentCount = Math.max(agentStates.length, fallbackMemberCount);1579+ const useItemStatus = agentStates.length === 0;1580+ let running = 0;1581+ let waiting = 0;1582+ let idle = 0;1583+ let failed = 0;1584+ let stopped = 0;1585+ const statuses = useItemStatus ? [props.item.status] : agentStates.map((agent) => agent.status);1586+ for (const status of statuses) {1587+ if (status === "running" || status === "pending") running += 1;1588+ else if (status === "waiting") waiting += 1;1589+ else if (status === "idle") idle += 1;1590+ else if (status === "failed") failed += 1;1591+ else if (status === "cancelled" || status === "interrupted") stopped += 1;1592+ }1593+ const coordinatorStatus = workflowGroup?.workflow.status;1594+ if (coordinatorStatus === "failed") failed += 1;1595+ if (coordinatorStatus === "cancelled" || coordinatorStatus === "interrupted") stopped += 1;
- apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts line 1646OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1630,3 +1642,5 @@16301642 driver: CURSOR_PROVIDER,16311643 subagent: task,16321644 });1645+ yield* emitProviderEvent({1646+ type: "subagent_activation.updated",apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts lines 2254 to 2258OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2036,0 +2238,21 @@2238+ Entry extends ClaudeSubagentRegistryEntry,2239+>(input: {2240+ readonly registry: Ref.Ref<Map<string, Entry>>;2241+ readonly taskId: string;2242+ readonly observed: Entry | undefined;2243+ readonly candidate: Entry;2244+ readonly activeStart: boolean;2245+ readonly isReopen: boolean;2246+}) {2247+ return yield* Ref.modify(input.registry, (current) => {2248+ const registered = current.get(input.taskId);2249+ const registeredSettled =2250+ registered !== undefined &&2251+ (registered.task.status === "completed" ||2252+ registered.task.status === "failed" ||2253+ registered.task.status === "cancelled");2254+ if (2255+ registeredSettled &&2256+ input.activeStart &&2257+ !(input.isReopen && registered === input.observed)2258+ ) {
- apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 3519OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3258,0 +3499,21 @@3499+ yield* client.handleServerNotification("thread/tokenUsage/updated", (payload) =>3500+ Effect.gen(function* () {3501+ const subagent = (yield* Ref.get(subagentThreads)).get(payload.threadId);3502+ if (subagent === undefined || payload.tokenUsage.total.totalTokens <= 0) {3503+ return;3504+ }3505+ if (subagent.task.currentActivationId !== null) {3506+ const total = payload.tokenUsage.total;3507+ const usage = {3508+ totalTokens: total.totalTokens,3509+ inputTokens: total.inputTokens,3510+ cachedInputTokens: total.cachedInputTokens,3511+ outputTokens: total.outputTokens,3512+ reasoningOutputTokens: total.reasoningOutputTokens,3513+ } satisfies OrchestrationV2SubagentUsage;3514+ yield* emitSubagentTaskUpdate({3515+ subagent,3516+ status: subagent.task.status,3517+ usage,3518+ });3519+ }
- apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts lines 2400 to 2400OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2198,3 +2386,15 @@21982386 }21992387 });220023882389+ /**2390+ * Adopt an already-registered subagent into the root turn that is2391+ * re-activating it. The task row keeps the run it was spawned under2392+ * otherwise, and every later row would be attributed to a closed run:2393+ * routing drops it, and the current run stops counting the subagent as2394+ * open work and can finalize while it is still going.2395+ */2396+ const rebindSubagentToContext = (2397+ subagent: CodexSubagentThreadContext,2398+ context: ActiveCodexTurnContext,2399+ ) => {2400+ if (subagent.parentContext.projectionRunId === context.projectionRunId) return;
- apps/server/src/orchestration-v2/Orchestrator.ts line 6110OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -5960,0 +6090,21 @@6090+ ...(subagent.runId === null ? {} : { runId: subagent.runId }),6091+ nodeId: subagent.id,6092+ driver: subagent.driver,6093+ occurredAt: now,6094+ payload: {6095+ ...subagent,6096+ recentActivity: appendSubagentActivity(subagent.recentActivity, "Stop requested", now),6097+ updatedAt: now,6098+ },6099+ });6100+ yield* Ref.update(effects, (existing) => [6101+ ...existing,6102+ {6103+ id: `effect:${command.commandId}:subagent.stop:${subagent.id}`,6104+ commandId: command.commandId,6105+ threadId: command.threadId,6106+ request: {6107+ type: "subagent.stop",6108+ providerSessionId,6109+ nativeTaskId,6110+ },
shivamhwp(GitHub profile, opens in a new tab) changed the title
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 2224OutdatedResolvedby shivamhwp(GitHub profile, opens in a new tab)@@ -2036,0 +2204,21 @@2204+2205+export const commitClaudeSubagentRegistryEntry = Effect.fnUntraced(function* <2206+ Entry extends ClaudeSubagentRegistryEntry,2207+>(input: {2208+ readonly registry: Ref.Ref<Map<string, Entry>>;2209+ readonly taskId: string;2210+ readonly observed: Entry | undefined;2211+ readonly candidate: Entry;2212+ readonly activeStart: boolean;2213+ readonly isReopen: boolean;2214+}) {2215+ return yield* Ref.modify(input.registry, (current) => {2216+ const registered = current.get(input.taskId);2217+ const registeredSettled =2218+ registered !== undefined &&2219+ (registered.task.status === "completed" ||2220+ registered.task.status === "failed" ||2221+ registered.task.status === "cancelled");2222+ if (2223+ (!input.activeStart && registered !== input.observed) ||2224+ (registeredSettled && input.activeStart && !(input.isReopen && registered === input.observed))
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 2230OutdatedResolvedby shivamhwp(GitHub profile, opens in a new tab)@@ -2036,0 +2210,21 @@2210+ readonly taskId: string;2211+ readonly observed: Entry | undefined;2212+ readonly candidate: Entry;2213+ readonly activeStart: boolean;2214+ readonly isReopen: boolean;2215+}) {2216+ return yield* Ref.modify(input.registry, (current) => {2217+ const registered = current.get(input.taskId);2218+ const registeredSettled =2219+ registered !== undefined &&2220+ (registered.task.status === "completed" ||2221+ registered.task.status === "failed" ||2222+ registered.task.status === "cancelled");2223+ const sameObservedActivation =2224+ registered !== undefined &&2225+ input.observed !== undefined &&2226+ registered.activation.id === input.observed.activation.id;2227+ if (2228+ (!input.activeStart &&2229+ registered !== input.observed &&2230+ (registeredSettled || !sameObservedActivation)) ||
- apps/web/src/components/chat/MessagesTimeline.tsx lines 1696 to 1696OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1531,0 +1676,21 @@1676+ ? `${working} working`1677+ : "working"1678+ : failed > 01679+ ? `${failed} failed`1680+ : coordinatorFailed1681+ ? "failed"1682+ : idle > 01683+ ? `${idle} idle`1684+ : stopped > 01685+ ? `${stopped} stopped`1686+ : coordinatorStopped1687+ ? "stopped"1688+ : "✓ completed";1689+1690+ return (1691+ <button1692+ type="button"1693+ onClick={onOpenAgents}1694+ data-v2-item-type="subagent"1695+ data-agent-spawn-cta="true"1696+ className="-mx-1 flex w-full items-center gap-2 rounded-md border border-border/60 bg-card/50 px-2.5 py-1.5 text-left text-[13px] transition hover:bg-accent/50"
- apps/web/src/components/chat/MessagesTimeline.logic.ts lines 286 to 286OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -174,0 +266,21 @@266+ for (const member of [267+ ...group.phases.flatMap((phase) => phase.members),268+ ...group.unphasedMembers,269+ ]) {270+ workflowIdByAgentId.set(member.id, group.workflow.id);271+ }272+ }273+274+ const timelineEntries: TimelineEntry[] = [];275+ const anchorItemIdByGroup = new Map<string, string>();276+ const ctaByItemId = new Map<string, AgentSpawnCtaGroup>();277+ for (const entry of input.timelineEntries) {278+ if (entry.kind !== "event" || entry.projectedItem.item.type !== "subagent") {279+ timelineEntries.push(entry);280+ continue;281+ }282+283+ const item = entry.projectedItem.item;284+ const workflowId = workflowIdByAgentId.get(item.subagentId) ?? null;285+ const groupKey =286+ workflowId === null ? `direct:${item.runId ?? item.subagentId}` : `workflow:${workflowId}`;apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts lines 3004 to 3004OutdatedResolvedby shivamhwp(GitHub profile, opens in a new tab)@@ -2757,6 +2990,15 @@2757- if (2758- existingSubagent !== undefined &&2759- existingSubagent.task.status !== "running" &&2760- input.status === "running" &&2761- !isReopen2762- ) {2990+ (existingSubagent.task.status === "completed" ||2991+ existingSubagent.task.status === "failed" ||2992+ existingSubagent.task.status === "cancelled");2993+ // The wake buffer may already have pre-opened a settled entry, hiding2994+ // the terminal status this check relies on. Treat that as settled too,2995+ // or the resume silently reuses the finished activation: its ordinal2996+ // stops matching reality and its usage is measured against the2997+ // previous activation's totals, which clamps the delta to zero.2998+ const resumePending = existingSubagent?.resumePending === true;2999+ const wasSettled = previousSettled || resumePending;3000+ // "waiting" reopens a settled entry just as readily as an active3001+ // start, so a replayed blocked-worker snapshot must be refused too.3002+ const activeStart =3003+ input.status === "pending" || input.status === "running" || input.status === "waiting";3004+ const isReopen = input.reopen === true && wasSettled && activeStart;
- apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts line 1526OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1504,4 +1522,5 @@15041522 },15051523 status,15061524 result: resultText.length === 0 ? (existing?.task.result ?? null) : resultText,1507- completedAt: input.completed ? now : null,1525+ currentActivationId: completed ? null : activationId,1526+ completedAt: completed ? now : null,
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 4359OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3926,0 +4339,21 @@4339+ tokens === undefined4340+ ? undefined4341+ : ({4342+ totalTokens: tokens,4343+ ...(toolUses === undefined ? {} : { toolUses }),4344+ } satisfies OrchestrationV2SubagentUsage);4345+ const workerTaskId = `${message.task_id}:workflow:${index}`;4346+ const existingWorker =4347+ context.subagentsByTaskId.get(workerTaskId) ??4348+ (yield* Ref.get(sessionSubagentsByTaskId)).get(workerTaskId);4349+ const activeWorker =4350+ status === "pending" || status === "running" || status === "waiting";4351+ const reopen =4352+ activeWorker &&4353+ existingWorker !== undefined &&4354+ attempt > (existingWorker.task.workflowMembership?.attempt ?? 0);4355+ yield* updateClaudeSubagentNode({4356+ context,4357+ taskId: workerTaskId,4358+ title: label.trim(),4359+ parentNodeId: workflowParent.task.id,
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID:
606ccf48-8344-45dd-ab00-72d4e58d33f9You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning
Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.