@devries-cameron20 / t3code Mirror · read-only / commits / 6c84239d6d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 09:15 UTC

fix(client-runtime): hide pending context handoff on threads with no sent message (#20033)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

maria committed Oct 15, 2026 at 23:35 UTC 6c84239d6de6f48b78ee704a1216d508a62bba5d
2 files changed +17 -1
packages/client-runtime/src/handoff.test.ts
+13
@@ -75,6 +75,7 @@ describe("handoff endpoints shared by web and mobile", () => {
75
76 const projection = {
77 runs: [{ ...run("source", 1, from, "source"), startedAt: "2026-10-11T00:00:00Z" }],
78 + visibleTurnItems: [{ item: { type: "user_message" } }],
79 } as unknown as OrchestrationV2ThreadProjection;
80
81 describe("pending context handoff", () => {
@@ -89,6 +90,18 @@ describe("pending context handoff", () => {
90 expect(resolvePendingHandoff(projection, { instanceId: from, model: "source" }, [])).toBeNull();
91 expect(resolvePendingHandoff(projection, { instanceId: from, model: "other" }, [])).toBeNull();
92 });
93 + it("stays hidden while the thread's timeline is empty", () => {
94 + const empty = { ...projection, visibleTurnItems: [] };
95 + expect(resolvePendingHandoff(empty, { instanceId: to, model: "first" }, [])).toBeNull();
96 + // Paging can leave a window of only tool rows after the prompt.
97 + const toolRowsOnly = {
98 + ...projection,
99 + visibleTurnItems: [{ item: { type: "command_execution" } }],
100 + } as unknown as OrchestrationV2ThreadProjection;
101 + expect(
102 + resolvePendingHandoff(toolRowsOnly, { instanceId: to, model: "first" }, [])?.to.model,
103 + ).toBe("first");
104 + });
105 it("only previews a same-provider model change when it needs a fresh native thread", () => {
106 const providers = [
107 { instanceId: from, requiresNewThreadForModelChange: true },
packages/client-runtime/src/handoff.ts
+4 -1
@@ -25,7 +25,10 @@ export function resolvePendingHandoff(
25 selection: ModelSelection | null | undefined,
26 providers: ReadonlyArray<ServerProvider>,
27 ): HandoffEndpoints | null {
28 - const from = projection?.runs.findLast(
28 + // A thread with an empty timeline has nothing to hand off. Any loaded row
29 + // counts: paging can leave a window of only tool rows.
30 + if (!projection?.visibleTurnItems.length) return null;
31 + const from = projection.runs.findLast(
32 (run) => run.startedAt !== null && run.status !== "rolled_back",
33 )?.modelSelection;
34 if (from === undefined || selection == null) return null;