feat(web,mobile): Continue on… a linked environment #16758
Closedjuliusmarmingewants to merge 4 commits into
t3code/peer/handoff fromrefs/pull/16758/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/web/src/hooks/useThreadActionMenu.ts line 153OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -147,3 +148,6 @@147148 };148149 const isRegeneratingTitle = thread.titleRegeneration != null;149150 const snoozePresets = resolveSnoozePresets(now, timestampFormat);151+ const handoffTargets =152+ thread.handoff == null || thread.handoff.state === "failed"153+ ? await readThreadHandoffTargets(threadRef.environmentId, threadRef.threadId)
- apps/mobile/src/features/threads/ThreadHandoffCard.tsx line 73OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +53,21 @@53+ <Text54+ className={cn(55+ "text-sm font-t3-bold",56+ notice.tone === "error" ? "text-danger-foreground" : "text-foreground",57+ )}58+ >59+ {notice.title}60+ </Text>61+ {notice.detail !== null ? (62+ <Text className="text-sm text-foreground-secondary">{notice.detail}</Text>63+ ) : null}64+ {handoff.state === "pending" ? (65+ <View className="flex-row">66+ <RequestActionButton67+ label={cancelling ? "Cancelling…" : "Keep it here"}68+ tone="secondary"69+ disabled={cancelling}70+ onPress={() => void keepHere()}71+ />72+ </View>73+ ) : handoff.state === "departed" && presentationById.has(handoff.environmentId) ? (apps/mobile/src/features/threads/ThreadHandoffSheet.tsx lines 56 to 59Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +31,21 @@31+ const options = useEnvironmentQuery(32+ threadHandoffEnvironment.options({33+ environmentId: target.environmentId,34+ input: { threadId: target.threadId },35+ }),36+ );37+ const start = useAtomCommand(threadHandoffEnvironment.start, {38+ label: "move thread",39+ reportFailure: false,40+ });41+ const [starting, setStarting] = useState<EnvironmentId | null>(null);42+ const [error, setError] = useState<string | null>(null);43+44+ const choose = async (environmentId: EnvironmentId) => {45+ void Haptics.selectionAsync();46+ setStarting(environmentId);47+ setError(null);48+ const result = await start({49+ environmentId: target.environmentId,50+ input: { threadId: target.threadId, environmentId },51+ });apps/web/src/components/chat/ThreadHandoffBanner.tsx lines 30 to 96Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +80,21 @@80+ to: "/$environmentId/$threadId",81+ params: buildThreadRouteParams(82+ scopeThreadRef(handoff.environmentId, handoff.threadId),83+ ),84+ })85+ }86+ >87+ Open on {handoff.label}88+ <ArrowUpRightIcon />89+ </Button>90+ ) : undefined;91+ return {92+ id: `thread-handoff:${shell.id}:${handoff.handoffId}:${handoff.state}`,93+ variant: notice.tone,94+ icon: notice.tone === "error" ? <TriangleAlertIcon /> : <MonitorUpIcon />,95+ title: notice.title,96+ ...(notice.detail === null ? {} : { description: notice.detail }),97+ ...(actions === undefined ? {} : { actions }),98+ };99+ }, [canOpenThere, cancel, cancelling, handoff, navigate, shell]);100+}
- apps/web/src/components/ChatView.tsx line 7771OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -7757,8 +7762,10 @@77577762 const backgroundWorkItems = [goalBannerItem, backgroundWorkBannerItem].filter(77587763 (item) => item !== null,77597764 );7765+ const handoffItems = threadHandoffBannerItem === null ? [] : [threadHandoffBannerItem];77607766 // The user asked for this one, so it leads the notice tier instead of trailing it.77617767 const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner];77627768 const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];77637769 if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {77647770 return [7771+ ...handoffItems,apps/web/src/components/ChatView.tsx lines 3488 to 3489Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -11538,4 +11547,5 @@1153811547 sendDisabledReason={1153911548 !canOperateThread1154011549 ? "This connection cannot change threads."11541- : isEnvironmentChanging11550+ : (threadHandoffSendBlockReason(activeThreadShell) ??11551+ (isEnvironmentChanging
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx lines 881 to 884OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -869,3 +877,8 @@869877 mergeBackTargetThreadId !== null && mergeBackRun !== null870878 ? () => void handleMergeBack()871879 : undefined,880+ onContinueOn:881+ selectedThread !== null &&882+ selectedThread !== undefined &&883+ routeEnvironmentRuntime?.serverConfig?.environment.capabilities.peerLinks === true &&884+ (selectedThread.handoff === null || selectedThread.handoff.state === "failed")
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx line 778OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -771,3 +771,8 @@771771 mergeBackTargetThreadId !== null && mergeBackRun !== null772772 ? () => void handleMergeBack()773773 : undefined,774+ onContinueOn:775+ selectedThread !== null &&776+ selectedThread !== undefined &&777+ routeEnvironmentRuntime?.serverConfig?.environment.capabilities.peerLinks === true &&778+ (selectedThread.handoff === null || selectedThread.handoff.state === "failed")
- apps/web/src/components/chat/ThreadHandoffBanner.tsx line 44OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +24,21 @@24+ const handoff = shell?.handoff;25+ if (handoff?.state === "departing") return `Moving to ${handoff.label}`;26+ if (handoff?.state === "departed") return `Continues on ${handoff.label}`;27+ return null;28+}29+30+/**31+ * The banner for a thread's move to a linked environment: waiting (with32+ * Cancel), under way, moved (with a link to it there when this client is33+ * connected to that environment), or failed.34+ */35+export function useThreadHandoffBannerItem(36+ shell: Pick<EnvironmentThreadShell, "environmentId" | "id" | "handoff"> | null | undefined,37+): ComposerBannerStackItem | null {38+ const navigate = useNavigate();39+ const cancel = useAtomCommand(threadHandoffEnvironment.cancel, { label: "cancel thread move" });40+ const [cancelling, setCancelling] = useState(false);41+ const handoff = shell?.handoff ?? null;42+ const environmentIds = useEnvironmentIds();43+ const canOpenThere =44+ handoff?.state === "departed" && environmentIds.includes(handoff.environmentId);
- apps/web/src/components/CommandPalette.tsx line 1944OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1926,3 +1929,16 @@19261929 }19271930 }192819311932+ if (1933+ activeThread !== null &&1934+ activeThreadServerConfig?.environment.capabilities.peerLinks === true &&1935+ (activeThread.handoff == null || activeThread.handoff.state === "failed")1936+ ) {1937+ const thread = activeThread;1938+ actionItems.push({1939+ kind: "action",1940+ value: "action:continue-on",1941+ searchTerms: ["continue on", "move", "hand off", "handoff", "environment", "machine"],1942+ title: "Continue on…",1943+ description: "Move this thread and its work to a linked environment",1944+ disabled: !threadRuntimeCanArchive(thread.runtime),apps/mobile/src/features/threads/ThreadGitControls.tsx line 397OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -392,3 +394,4 @@392394 },393395 ]394396 : []),397+ ...(props.onContinueOn
- @@ -0,0 +37,21 @@37+): ComposerBannerStackItem | null {38+ const navigate = useNavigate();39+ const cancel = useAtomCommand(threadHandoffEnvironment.cancel, { label: "cancel thread move" });40+ const [cancelling, setCancelling] = useState(false);41+ const handoff = shell?.handoff ?? null;42+ const connectedEnvironmentIds = useConnectedEnvironmentIds();43+ const canOpenThere =44+ handoff?.state === "departed" && connectedEnvironmentIds.includes(handoff.environmentId);45+ const notice = threadHandoffNotice(handoff);46+ if (shell == null || handoff === null || notice === null) return null;47+ const actions =48+ handoff.state === "pending" ? (49+ <Button50+ size="xs"51+ variant="ghost"52+ disabled={cancelling}53+ onClick={() => {54+ setCancelling(true);55+ void cancel({ environmentId: shell.environmentId, input: { threadId: shell.id } }).then(56+ (result) => {57+ setCancelling(false);
juliusmarminge assignedjuliusmarminge
juliusmarminge closed this
juliusmarminge reopened this
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
tanstack-source added labelsfeature
juliusmarminge closed this
Sign in to join this conversation.





Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
5558f85· Source CI: failureScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.