@devries-cameron20 / t3code-1 / commits / ff4197c480
Fork 0

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

perf(client-runtime): skip history scans when no runs are queued (#25519)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Nov 20, 2026 at 06:28 UTC ff4197c480525e228d4c0058b0d7b5f88bb5627e
2 files changed +21
packages/client-runtime/src/state/threadWorkflows.test.ts
+19
@@ -4,6 +4,7 @@ import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
4 import {
5 canForkProjectedAssistantItem,
6 deriveThreadQueueWorkflowState,
7 + getUserQueuedThreadRuns,
8 resolveLatestMergeBackRun,
9 threadSupportsProviderHandoff,
10 } from "./threadWorkflows.ts";
@@ -30,6 +31,24 @@ const capabilities = (input?: {
31 }) as never;
32
33 describe("thread workflows", () => {
34 + it("skips message history classification when no runs are queued", () => {
35 + let metadataReads = 0;
36 + const message = {
37 + id: "message",
38 + get delegatedCompletion() {
39 + metadataReads++;
40 + return undefined;
41 + },
42 + };
43 + const projection = {
44 + runs: [{ id: "active", status: "running", userMessageId: "message", ordinal: 1 }],
45 + messages: [message],
46 + } as never;
47 +
48 + expect(getUserQueuedThreadRuns(projection)).toEqual([]);
49 + expect(metadataReads).toBe(0);
50 + });
51 +
52 it("allows a completed thread to switch providers after its session detaches", () => {
53 const projection = {
54 thread: {
packages/client-runtime/src/state/threadWorkflows.ts
+2
@@ -125,6 +125,8 @@ export function threadSupportsProviderHandoff(projection: Projection | null | un
125 export function getUserQueuedThreadRuns(
126 projection: Pick<Projection, "runs" | "messages">,
127 ): ReadonlyArray<Run> {
128 + if (!projection.runs.some((run) => run.status === "queued")) return [];
129 +
130 const automaticCompletionMessageIds = new Set(
131 projection.messages
132 .filter(