From 0df124c7ece4b975ac9d7bb29c06772912a8c5ad Mon Sep 17 00:00:00 2001 From: angrojo Date: Fri, 20 Nov 2026 22:15:31 +0100 Subject: [PATCH] fix(client-runtime): prevent self-handoff arrow on recovered context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using 'Edit from here' with ACP agents or the dev replay agent, context recovery writes a handoff item targeting the same model or provider thread. Previously, the timeline rendered a misleading self-handoff row such as 'Context handoff · Multi turn → Multi turn'. Now resolveHandoffEndpoints identifies recovered context and same-model endpoints, omitting the self-directed source and arrow while presenting the row under the localized 'Recovered context' label across web and mobile. Model: Gemini 3.8 Flash (High) Harness: Antigravity ACP --- .../features/threads/thread-handoff-row.tsx | 34 ++++++++------ .../src/components/chat/V2LifecycleRow.tsx | 47 +++++++++++-------- packages/client-runtime/src/handoff.test.ts | 37 +++++++++++++++ packages/client-runtime/src/handoff.ts | 39 +++++++++++++-- 4 files changed, 119 insertions(+), 38 deletions(-) diff --git a/apps/mobile/src/features/threads/thread-handoff-row.tsx b/apps/mobile/src/features/threads/thread-handoff-row.tsx index 7158a9968bcc6..a6ac68ed7535e 100644 --- a/apps/mobile/src/features/threads/thread-handoff-row.tsx +++ b/apps/mobile/src/features/threads/thread-handoff-row.tsx @@ -94,13 +94,14 @@ export function ThreadHandoffRow(props: { const endpoints = useAtomValue(endpointsAtom); if (item.type !== "handoff" || endpoints === null) return null; const color = item.status === "failed" ? "#e11d48" : props.iconColor; + const label = endpoints.isRecoveredContext ? gt("Recovered context") : gt("Context handoff"); return ( ); @@ -116,6 +117,7 @@ export function ThreadHandoffDivider(props: { }) { const config = useAtomValue(serverEnvironment.configValueAtom(props.environmentId)); const { endpoints } = props; + const showFromEndpoints = !endpoints.isRecoveredContext && endpoints.from.length > 0; const endpointProps = { providers: (config?.providers ?? []).map((provider) => { const rawConfig = config?.settings.providerInstances[provider.instanceId]?.config; @@ -141,20 +143,22 @@ export function ThreadHandoffDivider(props: { failed={props.failed} > - {endpoints.from.map((endpoint, index) => ( - - - {index < endpoints.from.length - 1 ? ( - - , - - ) : null} - - ))} - {endpoints.from.length > 0 ? ( + {showFromEndpoints + ? endpoints.from.map((endpoint, index) => ( + + + {index < endpoints.from.length - 1 ? ( + + , + + ) : null} + + )) + : null} + {showFromEndpoints ? ( ) : null} diff --git a/apps/web/src/components/chat/V2LifecycleRow.tsx b/apps/web/src/components/chat/V2LifecycleRow.tsx index 940e741b9c486..1b2621a2f5c8a 100644 --- a/apps/web/src/components/chat/V2LifecycleRow.tsx +++ b/apps/web/src/components/chat/V2LifecycleRow.tsx @@ -669,36 +669,45 @@ export function HandoffRow(props: { readonly failed?: boolean; }) { const gt = useGT(); - const { from: fromEndpoints, to } = props.endpoints; + const { from: fromEndpoints, to, isRecoveredContext } = props.endpoints; const settings = useAtomValue(serverEnvironment.settingsValueAtom(props.environmentId)); const derived = deriveProviderInstanceEntries(props.providers); const entries = settings ? applyProviderInstanceSettings(derived, settings, null) : derived; + const showFromEndpoints = !isRecoveredContext && fromEndpoints.length > 0; return ( - {fromEndpoints.map((endpoint, index) => ( - - - {index < fromEndpoints.length - 1 ? ( - - ))} - {fromEndpoints.length > 0 ? ( + )) + : null} + {showFromEndpoints ? (