The best way to control Claude Code, Codex and more from any computer or phone
fix(web): a later thread error with the same text shows its banner again (#37419)
Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
shivam committed
Nov 20, 2026 at 05:57 UTC
5872b0a488847d12aa2351fe5af5e7b7b81077ab
9 files changed
+177
-9
apps/web/src/components/ChatView.logic.test.ts
+37
@@ -22,6 +22,7 @@ import {
22
isThreadEnvironmentLocked,
23
recallCheckoutIsRepo,
24
rememberCheckoutIsRepo,
25
+ threadErrorIsServerRuntime,
26
} from "./ChatView.logic";
27
import { ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
28
import { deriveProviderInstanceEntries } from "../providerInstances";
@@ -1640,3 +1641,39 @@ describe("prepareRevertedMessageAttachments", () => {
1641
expect(store.getComposerDraft(target)?.images.map(({ id }) => id)).toEqual(["restored"]);
1642
});
1643
});
1644
+
1645
+describe("threadErrorIsServerRuntime", () => {
1646
+ it("is true for a server thread's runtime error, and for a local copy of that same error", () => {
1647
+ expect(
1648
+ threadErrorIsServerRuntime({
1649
+ isServerThread: true,
1650
+ localServerError: null,
1651
+ runtimeError: "E",
1652
+ }),
1653
+ ).toBe(true);
1654
+ expect(
1655
+ threadErrorIsServerRuntime({
1656
+ isServerThread: true,
1657
+ localServerError: "E",
1658
+ runtimeError: "E",
1659
+ }),
1660
+ ).toBe(true);
1661
+ });
1662
+
1663
+ it("is false for a local error that differs from the runtime error, and for draft threads", () => {
1664
+ expect(
1665
+ threadErrorIsServerRuntime({
1666
+ isServerThread: true,
1667
+ localServerError: "E2",
1668
+ runtimeError: "E",
1669
+ }),
1670
+ ).toBe(false);
1671
+ expect(
1672
+ threadErrorIsServerRuntime({
1673
+ isServerThread: false,
1674
+ localServerError: null,
1675
+ runtimeError: "E",
1676
+ }),
1677
+ ).toBe(false);
1678
+ });
1679
+});
apps/web/src/components/ChatView.logic.ts
+12
@@ -1242,6 +1242,18 @@ export function chatActionErrorMessage(error: unknown, resolve: MessageResolver
1242
return thrownErrorMessage(error, resolve) ?? resolve(msg("An error occurred."));
1243
}
1244
1245
+/** A local copy of the runtime's error shares the runtime's key, so one dismissal covers both. */
1246
+export function threadErrorIsServerRuntime(input: {
1247
+ readonly isServerThread: boolean;
1248
+ readonly localServerError: string | null;
1249
+ readonly runtimeError: string | null;
1250
+}): boolean {
1251
+ return (
1252
+ input.isServerThread &&
1253
+ (input.localServerError === null || input.localServerError === input.runtimeError)
1254
+ );
1255
+}
1256
+
1257
export function releaseChatTimelineAnchor<T extends { readonly messageId: MessageId | null }>(
1258
current: T,
1259
): T {
apps/web/src/components/ChatView.tsx
+16
-2
@@ -41,7 +41,11 @@ import { ThreadFind, ThreadFindCanvas } from "./chat/ThreadFindProvider";
41
import { closeThreadFind, openThreadFind, useThreadFindOpen } from "./chat/threadFindStore";
42
import { THREAD_FIND_BAR_RESERVED_HEIGHT } from "./chat/ThreadFindBar";
43
import { usageLimitRecoveryBannerItem } from "./chat/UsageLimitRecoveryBanner";
44
-import { isThreadEnvironmentLocked, resolveDraftHeroState } from "./ChatView.logic";
44
+import {
45
+ isThreadEnvironmentLocked,
46
+ resolveDraftHeroState,
47
+ threadErrorIsServerRuntime,
48
+} from "./ChatView.logic";
49
import { useQueuedRunEdit } from "./chat/useQueuedRunEdit";
50
import { recallCheckoutIsRepo, rememberCheckoutIsRepo } from "./ChatView.logic";
51
import { useLogicalProjectEnvironments } from "../hooks/useLogicalProjectEnvironments";
@@ -979,7 +983,17 @@ export default function ChatView(props: ChatViewProps) {
983
const threadError = isServerThread
984
? (localServerError ?? serverRuntime?.lastError ?? null)
985
: localDraftError;
982
- const threadErrorBannerKey = getThreadErrorBannerKey(routeThreadKey, threadError);
986
+ const threadErrorBannerKey = getThreadErrorBannerKey(
987
+ routeThreadKey,
988
+ threadError,
989
+ threadErrorIsServerRuntime({
990
+ isServerThread,
991
+ localServerError,
992
+ runtimeError: serverRuntime?.lastError ?? null,
993
+ })
994
+ ? (serverRuntime?.lastErrorSource ?? null)
995
+ : null,
996
+ );
997
const visibleThreadError = shouldShowThreadErrorBanner(
998
routeThreadKey,
999
threadError,
apps/web/src/components/chat/ThreadErrorBanner.test.tsx
+17
@@ -42,4 +42,21 @@ describe("ThreadErrorBanner", () => {
42
),
43
).toBe(true);
44
});
45
+
46
+ it("reappears when a later run fails with the same error on the same thread", () => {
47
+ const error = "Turn failed";
48
+ const dismissedKey = getThreadErrorBannerKey("env:thread-c", error, "run-a");
49
+ dismissThreadErrorBannerForSession(dismissedKey);
50
+ const laterRunKey = getThreadErrorBannerKey("env:thread-c", error, "run-b");
51
+
52
+ expect(isThreadErrorBannerDismissedForSession(dismissedKey)).toBe(true);
53
+ expect(isThreadErrorBannerDismissedForSession(laterRunKey)).toBe(false);
54
+ expect(
55
+ shouldShowThreadErrorBanner(
56
+ "env:thread-c",
57
+ error,
58
+ isThreadErrorBannerDismissedForSession(laterRunKey),
59
+ ),
60
+ ).toBe(true);
61
+ });
62
});
apps/web/src/components/chat/ThreadErrorBanner.tsx
+6
-2
@@ -51,8 +51,12 @@ export function getThreadErrorBannerMessage(error: string): string {
51
: error;
52
}
53
54
-export function getThreadErrorBannerKey(threadKey: string, error: string | null): string | null {
55
- return error === null ? null : `${threadKey}\u0000${error}`;
54
+export function getThreadErrorBannerKey(
55
+ threadKey: string,
56
+ error: string | null,
57
+ source: string | null = null,
58
+): string | null {
59
+ return error === null ? null : `${threadKey}\u0000${source ?? ""}\u0000${error}`;
60
}
61
62
export function shouldShowThreadErrorBanner(
packages/client-runtime/src/state/models.ts
+2
@@ -114,6 +114,8 @@ export interface ThreadRuntimeSummary {
114
readonly lastError: string | null;
115
readonly lastErrorClass?: OrchestrationV2ProviderFailureClass | null;
116
readonly lastErrorCode?: string | null;
117
+ /** The record `lastError` came from, with its change time so a repeated failure differs. */
118
+ readonly lastErrorSource?: string | null;
119
readonly usageLimitResetAt?: string | null;
120
readonly updatedAt: string;
121
}
packages/client-runtime/src/state/threadExecution.test.ts
+39
@@ -179,7 +179,46 @@ describe("thread execution presentation", () => {
179
expect(deriveThreadRuntime(projection)).toMatchObject({
180
lastError: "Plan limit reached",
181
lastErrorClass: "usage_limit",
182
+ lastErrorSource: "limit-error@2026-07-28T10:00:00.000Z",
183
});
184
+ // A retried run fails again through the same item, so only its failure time tells it apart.
185
+ const later = DateTime.makeUnsafe("2026-07-28T10:05:00.000Z");
186
+ const source = (input: Partial<Parameters<typeof deriveThreadRuntime>[0]>) =>
187
+ deriveThreadRuntime({ ...projection, ...input })?.lastErrorSource;
188
+ expect(source({ turnItems: [{ ...item, completedAt: later, updatedAt: later }] })).toBe(
189
+ "limit-error@2026-07-28T10:05:00.000Z",
190
+ );
191
+ expect(source({ turnItems: [{ ...item, updatedAt: later }] })).toBe(
192
+ "limit-error@2026-07-28T10:00:00.000Z",
193
+ );
194
+ const session = (lastError: string) => ({
195
+ id: ProviderSessionId.make("failed-session"),
196
+ driver: ProviderDriverKind.make("pi"),
197
+ providerInstanceId: v2Projection.thread.providerInstanceId,
198
+ status: "error" as const,
199
+ cwd: "/repo",
200
+ model: null,
201
+ capabilities: {} as never,
202
+ createdAt: now,
203
+ updatedAt: later,
204
+ lastError,
205
+ });
206
+ // A session that repeats the failure keeps its source, whatever the session's own updates.
207
+ expect(source({ providerSessions: [session("Plan limit reached")] })).toBe(
208
+ "limit-error@2026-07-28T10:00:00.000Z",
209
+ );
210
+ // Otherwise a session error belongs to the latest ended run, kept while a newer run starts.
211
+ const ended = { ...failed, completedAt: now };
212
+ const starting = [ended, run("next", 2, "starting")];
213
+ expect(source({ runs: [ended], providerSessions: [session("Session failed")] })).toBe(
214
+ "limited@2026-07-28T10:00:00.000Z",
215
+ );
216
+ expect(source({ runs: starting, providerSessions: [session("Session failed")] })).toBe(
217
+ "limited@2026-07-28T10:00:00.000Z",
218
+ );
219
+ expect(source({ runs: starting, providerSessions: [session("Plan limit reached")] })).toBe(
220
+ "limit-error@2026-07-28T10:00:00.000Z",
221
+ );
222
expect(deriveResumableRunId(projection, deriveThreadRuntime(projection))).toBe(failed.id);
223
expect(
224
deriveThreadRuntime({
packages/client-runtime/src/state/threadExecution.ts
+40
-4
@@ -1,6 +1,7 @@
1
import {
2
latestExecutedRun,
3
latestRootProviderFailure,
4
+ latestRootProviderFailureItem,
5
latestUnheldRun,
6
threadErrorSummary,
7
usageLimitRunPresentedAsLatest,
@@ -405,6 +406,8 @@ export function deriveThreadStructureRuntime(
406
if (latestRun === null && !backgroundWorkHoldsRun) return null;
407
const activeRunId =
408
latestMatchingRun(projection, (run) => INTERRUPTIBLE_RUN_STATUSES.has(run.status))?.id ?? null;
409
+ const failureItem = latestRootProviderFailureItem(latestRunProjection, projection.turnItems);
410
+ const sessionError = providerSession?.lastError ?? null;
411
return {
412
status: usageLimitedRun
413
? "failed"
@@ -418,13 +421,46 @@ export function deriveThreadStructureRuntime(
421
: DateTime.formatIso(orchestrationV2RunWorkStartedAt(liveActivityRun)),
422
providerInstanceId: projection.thread.providerInstanceId,
423
providerName: providerSession?.driver ?? null,
421
- ...threadErrorSummary(
422
- latestRootProviderFailure(latestRunProjection, projection.turnItems),
423
- providerSession?.lastError ?? null,
424
- ),
424
+ ...threadErrorSummary(failureItem?.failure ?? null, sessionError),
425
+ lastErrorSource: threadErrorSource(failureItem, sessionError, projection),
426
};
427
}
428
429
+const isoOrEmpty = (at: DateTime.Utc | null) => (at === null ? "" : DateTime.formatIso(at));
430
+
431
+/**
432
+ * A session error belongs to the latest ended run, as that run's failure when the text matches.
433
+ * Session timestamps are not used: providers rewrite them on unrelated updates.
434
+ */
435
+function threadErrorSource(
436
+ failureItem: ReturnType<typeof latestRootProviderFailureItem>,
437
+ sessionError: string | null,
438
+ projection: Pick<ThreadStructure, "runs" | "turnItems">,
439
+): string | null {
440
+ const itemSource = (item: NonNullable<typeof failureItem>) =>
441
+ `${item.id}@${isoOrEmpty(item.completedAt)}`;
442
+ if (
443
+ failureItem !== null &&
444
+ (sessionError === null || sessionError === failureItem.failure.message)
445
+ ) {
446
+ return itemSource(failureItem);
447
+ }
448
+ if (sessionError === null) return null;
449
+ let ended: ThreadStructure["runs"][number] | null = null;
450
+ for (const run of projection.runs) {
451
+ if (run.status !== "failed" && run.status !== "completed") continue;
452
+ if (ended === null || run.ordinal > ended.ordinal) ended = run;
453
+ }
454
+ if (ended === null) return null;
455
+ const endedFailure =
456
+ failureItem?.runId === ended.id
457
+ ? failureItem
458
+ : latestRootProviderFailureItem(ended, projection.turnItems);
459
+ return endedFailure?.failure.message === sessionError
460
+ ? itemSource(endedFailure)
461
+ : `${ended.id}@${isoOrEmpty(ended.completedAt)}`;
462
+}
463
+
464
export interface UsageLimitNoticeRows {
465
readonly itemIds: ReadonlySet<ThreadStructureTurnItem["id"]>;
466
/** Hidden only when its text reads as the provider's limit message; see PROVIDER_LIMIT_NOTICE. */
packages/shared/src/orchestrationV2ThreadError.ts
+8
-1
@@ -15,6 +15,13 @@ export function latestRootProviderFailure(
15
run: OrchestrationV2Run | null,
16
turnItems: ReadonlyArray<FailureScanTurnItem>,
17
): OrchestrationV2ProviderFailure | null {
18
+ return latestRootProviderFailureItem(run, turnItems)?.failure ?? null;
19
+}
20
+
21
+export function latestRootProviderFailureItem(
22
+ run: OrchestrationV2Run | null,
23
+ turnItems: ReadonlyArray<FailureScanTurnItem>,
24
+): ErrorTurnItem | null {
25
if (run?.status !== "failed") return null;
26
let latest: ErrorTurnItem | null = null;
27
for (const item of turnItems) {
@@ -34,7 +41,7 @@ export function latestRootProviderFailure(
41
latest = item;
42
}
43
}
37
- return latest?.failure ?? null;
44
+ return latest;
45
}
46
47
export function threadErrorSummary(