@devries-cameron20 / t3code-1 / commits / 5f8294246c
Fork 0

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

fix(client): reveal earlier agent turns in one load (#24417)

Julius Marminge committed Nov 11, 2026 at 15:29 UTC 5f8294246c5f16efc211673c65b12633eb0eb9bd
2 files changed +72 -3
packages/client-runtime/src/state/threads-sync.test.ts
+60
@@ -1051,6 +1051,66 @@ describe("EnvironmentThreads", () => {
1051 expect((yield* SubscriptionRef.get(harness.threadState)).history.loading).toBe(false);
1052 }),
1053 );
1054 + const boundary = (fields: object, id = "boundary", ordinal = 2) => ({
1055 + ...command(id, "completed", 0, ordinal),
1056 + ...fields,
1057 + });
1058 + const message = (
1059 + inputIntent: "turn_start" | "steer",
1060 + createdBy: "agent" | "user",
1061 + id = "boundary",
1062 + ordinal = 2,
1063 + ) =>
1064 + boundary(
1065 + {
1066 + type: "user_message",
1067 + messageId: MessageId.make(id),
1068 + inputIntent,
1069 + createdBy,
1070 + creationSource: "mcp",
1071 + text: "Run every check",
1072 + attachments: [],
1073 + },
1074 + id,
1075 + ordinal,
1076 + );
1077 + it.effect.each([
1078 + ["an agent-started turn", message("turn_start", "agent"), ["3"]],
1079 + [
1080 + "a notification",
1081 + boundary({
1082 + type: "notification",
1083 + source: { kind: "delegated_task", taskIds: [] },
1084 + outcome: "completed",
1085 + summary: "Checks finished",
1086 + }),
1087 + ["3"],
1088 + ],
1089 + ["a steer, paging on to its turn", message("steer", "user"), ["3", "2", "1"]],
1090 + ] as const)("stops paging earlier history at %s", ([, item, expected]) =>
1091 + Effect.gen(function* () {
1092 + const pages: Record<string, ReadonlyArray<unknown>> = {
1093 + "3": [item],
1094 + "2": [command("work-1", "completed", 0, 1)],
1095 + "1": [message("turn_start", "user", "opener", 0)],
1096 + };
1097 + const requests: string[] = [];
1098 + const harness = yield* makeHarness({
1099 + cached: cachedItem(command("tail", "completed", 0, 3)),
1100 + cachedHistory: { historyCursor: "3", hasMoreHistory: true },
1101 + historyHttpClient: HttpClient.make((request, url) => {
1102 + const cursor = url.searchParams.get("cursor")!;
1103 + requests.push(cursor);
1104 + const items = (pages[cursor] ?? []) as ReadonlyArray<OrchestrationV2TurnItem>;
1105 + return Effect.succeed(
1106 + historyPage(request, items.map(localRow), String(Number(cursor) - 1)),
1107 + );
1108 + }),
1109 + });
1110 + expect(yield* harness.loadEarlier()).toEqual({ _tag: "loaded" });
1111 + expect(requests).toEqual(expected);
1112 + }),
1113 + );
1114 it.effect("loads deferred work on demand and resumes a failed page", () =>
1115 Effect.gen(function* () {
1116 const anchor = {
packages/client-runtime/src/state/threads.ts
+12 -3
@@ -75,6 +75,17 @@ function formatHistoryError(error: unknown): string {
75 return "Could not load earlier activity.";
76 }
77
78 +// Steers join a running turn; every other user message opens one. The timeline shows every
79 +// notification as a response boundary, whether it opened its run or arrived mid-run.
80 +function startsTurn(item: OrchestrationV2TurnItem): boolean {
81 + return (
82 + item.type === "notification" ||
83 + (item.type === "user_message" &&
84 + item.inputIntent !== "steer" &&
85 + item.inputIntent !== "promoted_queued_to_steer")
86 + );
87 +}
88 +
89 function historyMetaFromCachedSnapshot(
90 snapshot: OrchestrationV2ThreadDetailSnapshot,
91 ): ThreadHistoryMeta {
@@ -777,9 +788,7 @@ export const makeEnvironmentThreadState = Effect.fn("EnvironmentThreadState.make
788 ? page.nextCursor !== null
789 : throughEntryId === undefined &&
790 page.hasMoreHistory &&
780 - !page.items.some(
781 - ({ item }) => item.type === "user_message" && item.createdBy === "user",
782 - ));
791 + !page.items.some(({ item }) => startsTurn(item)));
792 if (keepPaging && (page.nextCursor === null || page.nextCursor === requestCursor))
793 return yield* failLoad(
794 workAnchorId === undefined