The best way to control Claude Code, Codex and more from any computer or phone
fix(web): clear failed badges when threads are opened (#28616)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Bilal Irfan committed
Nov 14, 2026 at 19:56 UTC
47474723cbb05295fec5038ca9456186ba6e70fd
8 files changed
+129
-20
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+4
-2
@@ -79,6 +79,7 @@ import {
79
resolveThreadListV2SnoozeMenuSelection,
80
resolveThreadListV2SnoozePresets,
81
threadHasUnseenCompletion,
82
+ resolveThreadListV2RowStatus,
83
resolveThreadListV2Status,
84
resolveThreadListV2ProviderDrivers,
85
resolveThreadListV2SwipeActions,
@@ -772,7 +773,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
773
const selected = props.selected === true;
774
const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected);
775
775
- const status = resolveThreadListV2Status(thread);
776
+ const rawStatus = resolveThreadListV2Status(thread);
777
+ const status = resolveThreadListV2RowStatus(thread);
778
const isUnread = status === "ready" && threadHasUnseenCompletion(thread);
779
const workingLabel = STATUS_LABEL_BY_STATUS[status];
780
const showsWoke = status === "ready" && props.wokeAt !== null;
@@ -1298,7 +1300,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1300
</View>
1301
) : null}
1302
<View className="mt-1 flex-row items-center gap-2" style={{ paddingLeft: titleTextInset }}>
1301
- {(status === "failed" || status === "limited") && thread.runtime?.lastError ? (
1303
+ {(rawStatus === "failed" || rawStatus === "limited") && thread.runtime?.lastError ? (
1304
<Text
1305
className={cn(
1306
"flex-1 text-xs",
apps/mobile/src/features/threads/threadListV2.test.ts
+17
@@ -40,6 +40,7 @@ import {
40
resolveThreadListV2SnoozeMenuSelection,
41
resolveThreadListV2SwipeActions,
42
resolveThreadListV2SnoozePresets,
43
+ resolveThreadListV2RowStatus,
44
resolveThreadListV2Status,
45
resolveThreadListV2WokeAt,
46
threadListV2ListItemsAreEqual,
@@ -174,6 +175,22 @@ describe("resolveThreadListV2Status", () => {
175
);
176
});
177
178
+ it("settles a failure the user opened to ready in the row, keeping the raw status", () => {
179
+ const failed = presentThreadShell(
180
+ environmentId,
181
+ makeRawThreadShell({
182
+ status: "failed",
183
+ latestRunId: RunId.make("run-failed"),
184
+ latestRunCompletedAt: DateTime.makeUnsafe("2026-06-01T23:59:00.000Z"),
185
+ lastVisitedAt: DateTime.makeUnsafe(NOW),
186
+ }),
187
+ );
188
+
189
+ expect(resolveThreadListV2Status(failed)).toBe("failed");
190
+ expect(resolveThreadListV2RowStatus(failed)).toBe("ready");
191
+ expect(resolveThreadListV2RowStatus({ ...failed, lastVisitedAt: null })).toBe("failed");
192
+ });
193
+
194
it("shows a waiting guest message as Request, after the agent's own requests", () => {
195
const thread = presentThreadShell(
196
environmentId,
apps/mobile/src/features/threads/threadListV2.ts
+16
-2
@@ -8,7 +8,10 @@ import {
8
snoozeWakeLabel,
9
threadWokeAt,
10
} from "@t3tools/client-runtime/state/thread-settled";
11
-import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled";
11
+import {
12
+ hasUnseenRunFailure,
13
+ type SnoozePreset,
14
+} from "@t3tools/client-runtime/state/thread-settled";
15
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
16
import { resolveThreadProviderStack } from "@t3tools/client-runtime/state/models";
17
import {
@@ -296,6 +299,17 @@ export function resolveThreadListV2Status(
299
return "ready";
300
}
301
302
+/** Row status: a failure the user has already opened settles to ready, like Done. */
303
+export function resolveThreadListV2RowStatus(
304
+ thread: Parameters<typeof resolveThreadListV2Status>[0] &
305
+ Pick<EnvironmentThreadShell, "latestRun" | "lastVisitedAt">,
306
+): ThreadListV2Status {
307
+ const status = resolveThreadListV2Status(thread);
308
+ // A runtime failure without a failed run has nothing to date it, so it stays.
309
+ if (status !== "failed" || thread.latestRun?.status !== "failed") return status;
310
+ return hasUnseenRunFailure(thread) ? status : "ready";
311
+}
312
+
313
function parseTimestampMs(isoDate: string): number {
314
const parsed = Date.parse(isoDate);
315
return Number.isNaN(parsed) ? 0 : parsed;
@@ -506,7 +520,7 @@ function resolveThreadListV2ItemTimeLabel(
520
if (showSnoozeWakeLabel) return "";
521
if (
522
variant === "card" &&
509
- (resolveThreadListV2Status(thread) !== "ready" ||
523
+ (resolveThreadListV2RowStatus(thread) !== "ready" ||
524
item.wokeAt !== null ||
525
threadHasUnseenCompletion(thread))
526
)
apps/web/src/components/Sidebar.logic.test.ts
+30
@@ -14,6 +14,7 @@ import {
14
orderItemsByPreferredIds,
15
pinOrderKeyBetween,
16
resolveSidebarSweepKeys,
17
+ resolveSidebarRowStatus,
18
resolveSidebarThreadStatus,
19
resolveThreadStatusPill,
20
resolveWindowTitleThreadStatus,
@@ -331,6 +332,35 @@ describe("resolveSidebarThreadStatus", () => {
332
});
333
});
334
335
+describe("resolveSidebarRowStatus", () => {
336
+ const failedRuntime = {
337
+ status: "failed" as const,
338
+ activeRunId: null,
339
+ providerInstanceId: ProviderInstanceId.make("codex"),
340
+ providerName: "Codex",
341
+ lastError: "Provider turn failed.",
342
+ updatedAt: "2026-03-09T10:05:00.000Z",
343
+ };
344
+ const failed = {
345
+ hasActionableProposedPlan: false,
346
+ hasPendingApprovals: false,
347
+ hasPendingUserInput: false,
348
+ interactionMode: "default" as const,
349
+ runtime: failedRuntime,
350
+ latestRun: { ...makeLatestRun(), status: "failed" as const },
351
+ };
352
+
353
+ it("settles a failure the user opened to ready, without showing Done", () => {
354
+ expect(resolveSidebarRowStatus({ ...failed, lastVisitedAt: undefined })).toBe("failed");
355
+
356
+ const opened = { ...failed, lastVisitedAt: "2026-03-09T10:06:00.000Z" };
357
+ expect(resolveSidebarRowStatus(opened)).toBe("ready");
358
+ expect(hasUnseenCompletion(opened)).toBe(false);
359
+ // A runtime failure without a failed run has no date, so a visit cannot settle it.
360
+ expect(resolveSidebarRowStatus({ ...opened, latestRun: null })).toBe("failed");
361
+ });
362
+});
363
+
364
describe("searchSidebarThreads", () => {
365
const searchThread = (id: string, title: string, latestUserMessageAt: string) => ({
366
environmentId: localEnvironmentId,
apps/web/src/components/Sidebar.logic.ts
+14
-13
@@ -28,6 +28,7 @@ import type { SidebarProjectSortOrder, SidebarThreadSortOrder } from "@t3tools/c
28
import type { AsyncResult } from "effect/reactivity";
29
import {
30
effectiveSnoozed,
31
+ hasUnseenRunFailure,
32
type ThreadSnoozeShell,
33
} from "@t3tools/client-runtime/state/thread-settled";
34
import {
@@ -807,16 +808,6 @@ export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
808
return completedAt > lastVisitedAt;
809
}
810
810
-/** Unopened threads' failures still count as unseen, unlike completions. */
811
-function hasUnseenFailure(thread: ThreadStatusInput): boolean {
812
- if (thread.latestRun?.status !== "failed") return false;
813
- if (!thread.lastVisitedAt) return true;
814
- const completedAt = Date.parse(thread.latestRun.completedAt ?? "");
815
- const lastVisitedAt = Date.parse(thread.lastVisitedAt);
816
- if (Number.isNaN(completedAt) || Number.isNaN(lastVisitedAt)) return true;
817
- return completedAt > lastVisitedAt;
818
-}
819
-
811
// Suppress trailing double-click navigation; keyboard and synthetic clicks use detail 0.
812
export function isTrailingDoubleClick(detail: number): boolean {
813
return detail > 1;
@@ -991,6 +982,16 @@ export function resolveSidebarThreadStatus(thread: SidebarThreadStatusInput): Si
982
return "ready";
983
}
984
985
+/** Sidebar row status: a failure the user has already opened settles to ready, like Done. */
986
+export function resolveSidebarRowStatus(
987
+ thread: ThreadStatusInput & SidebarThreadStatusInput,
988
+): SidebarThreadStatus {
989
+ const status = resolveSidebarThreadStatus(thread);
990
+ // A runtime failure without a failed run has nothing to date it, so it stays.
991
+ if (status !== "failed" || thread.latestRun?.status !== "failed") return status;
992
+ return hasUnseenRunFailure(thread) ? status : "ready";
993
+}
994
+
995
/** What the window title says the open thread is doing, in the words its announcer uses. */
996
export function resolveWindowTitleThreadStatus(thread: SidebarThreadStatusInput): string | null {
997
// A guest waiting doesn't hide that the agent is still working.
@@ -1017,7 +1018,7 @@ export function resolveWindowTitleThreadStatus(thread: SidebarThreadStatusInput)
1018
export function resolveSidebarFolderDot(
1019
threads: ReadonlyArray<ThreadStatusInput & SidebarThreadStatusInput>,
1020
): "attention" | "failed" | "unread" | "working" | null {
1020
- const statuses = new Set(threads.map(resolveSidebarThreadStatus));
1021
+ const statuses = new Set(threads.map(resolveSidebarRowStatus));
1022
if (
1023
statuses.has("input") ||
1024
statuses.has("approval") ||
@@ -1029,7 +1030,7 @@ export function resolveSidebarFolderDot(
1030
if (statuses.has("failed")) return "failed";
1031
// Rows show Done only for ready threads, so the dot follows the same rule.
1032
const hasUnread = threads.some(
1032
- (thread) => resolveSidebarThreadStatus(thread) === "ready" && hasUnseenCompletion(thread),
1033
+ (thread) => resolveSidebarRowStatus(thread) === "ready" && hasUnseenCompletion(thread),
1034
);
1035
if (hasUnread) return "unread";
1036
if (statuses.has("working") || statuses.has("preparing")) return "working";
@@ -1277,7 +1278,7 @@ export function resolveThreadStatusPill(input: {
1278
};
1279
}
1280
1280
- if (hasUnseenFailure(thread)) {
1281
+ if (hasUnseenRunFailure(thread)) {
1282
return {
1283
label: "Failed",
1284
colorClass: "text-red-600 dark:text-red-300/90",
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+2
-2
@@ -86,7 +86,7 @@ import {
86
hasUnseenCompletion,
87
resolveSidebarRowAccessibility,
88
type SidebarDropVerb,
89
- resolveSidebarThreadStatus,
89
+ resolveSidebarRowStatus,
90
resolveThreadLastVisitedAt,
91
shouldRecedeSidebarThread,
92
resolveWorkingStartedAt,
@@ -731,7 +731,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
731
: null;
732
733
const isUnread = hasUnseenCompletion({ ...thread, lastVisitedAt });
734
- const status = resolveSidebarThreadStatus(thread);
734
+ const status = resolveSidebarRowStatus({ ...thread, lastVisitedAt });
735
const lastVisitedDate = lastVisitedAt === undefined ? null : parseTimestampDate(lastVisitedAt);
736
const wokeAtDate = props.wokeAt === null ? null : parseTimestampDate(props.wokeAt);
737
const isWoke =
packages/client-runtime/src/state/threadSettled.ts
+19
@@ -411,3 +411,22 @@ export function isThreadWokeUnseen(input: {
411
.filter((ms) => !Number.isNaN(ms));
412
return seenAt.every((ms) => ms < wokeAtMs);
413
}
414
+
415
+/**
416
+ * Whether the latest run failed after the user last saw the thread. Only the run dates the
417
+ * failure, since the shell's updatedAt also moves on renames. A failed run without a
418
+ * completion time, from older data, is dated by its start.
419
+ */
420
+export function hasUnseenRunFailure(
421
+ thread: Pick<EnvironmentThreadShell, "latestRun"> & {
422
+ readonly lastVisitedAt?: string | null | undefined;
423
+ },
424
+): boolean {
425
+ const run = thread.latestRun;
426
+ if (run?.status !== "failed") return false;
427
+ if (!thread.lastVisitedAt) return true;
428
+ const failedAtMs = Date.parse(run.completedAt ?? run.startedAt ?? run.requestedAt ?? "");
429
+ const lastVisitedAtMs = Date.parse(thread.lastVisitedAt);
430
+ if (Number.isNaN(failedAtMs) || Number.isNaN(lastVisitedAtMs)) return true;
431
+ return failedAtMs > lastVisitedAtMs;
432
+}
packages/client-runtime/src/state/threadSnoozed.test.ts
+27
-1
@@ -1,6 +1,6 @@
1
// @effect-diagnostics globalDate:off -- Tests exercise local calendar snooze boundaries.
2
import * as DateTime from "effect/DateTime";
3
-import { RuntimeRequestId } from "@t3tools/contracts";
3
+import { RunId, RuntimeRequestId } from "@t3tools/contracts";
4
import { ThreadId } from "@t3tools/contracts";
5
import { TurnId } from "@t3tools/contracts";
6
import type { SnoozePresetSetting } from "@t3tools/contracts/settings";
@@ -10,6 +10,7 @@ import {
10
canSnooze,
11
effectiveSnoozed,
12
hasQueuedTurnStart,
13
+ hasUnseenRunFailure,
14
pickSnoozePreset,
15
resolveSnoozePresets,
16
threadRaisedHandWhileSnoozed,
@@ -214,6 +215,31 @@ describe("effectiveSnoozed", () => {
215
});
216
});
217
218
+describe("hasUnseenRunFailure", () => {
219
+ it("dates a failure by its run, falling back to the run's start when it never completed", () => {
220
+ const run = {
221
+ runId: RunId.make("run-failed"),
222
+ status: "failed" as const,
223
+ requestedAt: "2026-04-10T09:00:00.000Z",
224
+ startedAt: "2026-04-10T09:01:00.000Z",
225
+ completedAt: "2026-04-10T09:05:00.000Z",
226
+ assistantMessageId: null,
227
+ };
228
+ const visitedAt = "2026-04-10T09:06:00.000Z";
229
+
230
+ expect(hasUnseenRunFailure({ latestRun: run, lastVisitedAt: null })).toBe(true);
231
+ expect(hasUnseenRunFailure({ latestRun: run, lastVisitedAt: visitedAt })).toBe(false);
232
+ const failedAgain = { ...run, completedAt: "2026-04-10T09:10:00.000Z" };
233
+ expect(hasUnseenRunFailure({ latestRun: failedAgain, lastVisitedAt: visitedAt })).toBe(true);
234
+
235
+ const undated = { ...run, completedAt: null };
236
+ expect(hasUnseenRunFailure({ latestRun: undated, lastVisitedAt: visitedAt })).toBe(false);
237
+ expect(
238
+ hasUnseenRunFailure({ latestRun: undated, lastVisitedAt: "2026-04-10T09:00:30.000Z" }),
239
+ ).toBe(true);
240
+ });
241
+});
242
+
243
describe("threadRaisedHandWhileSnoozed", () => {
244
it("is true for approvals, input, and failures", () => {
245
expect(