The best way to control Claude Code, Codex and more from any computer or phone
fix(web): keep tool groups collapsed after a usage-limit pause (#24937)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Oct 29, 2026 at 08:29 UTC
fe219c4de18f5ee37c28cbd3914a5569b1579156
2 files changed
+66
-31
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+44
-30
@@ -3841,9 +3841,15 @@ it("keeps the working header in place across worktree setup handoff", () => {
3841
});
3842
3843
describe("failed turn transcript", () => {
3844
- it.each(["provider_error", "usage_limit"] as const)(
3845
- "keeps historical %s failures and preceding work visible without disclosures",
3846
- (failureClass) => {
3844
+ it.each([
3845
+ { position: "historical", failureClass: "provider_error" },
3846
+ { position: "historical", failureClass: "usage_limit" },
3847
+ { position: "latest", failureClass: "usage_limit" },
3848
+ ] as const)(
3849
+ "keeps $position $failureClass failures visible with preceding work grouped appropriately",
3850
+ ({ position, failureClass }) => {
3851
+ const isLatest = position === "latest";
3852
+ const commands = isLatest ? ["pwd", "ls", "false"] : ["pwd"];
3853
const runId = RunId.make("failed-run");
3854
const threadId = ThreadId.make("failed-thread");
3855
const at = DateTime.makeUnsafe("2026-09-20T12:00:00Z");
@@ -3880,23 +3886,24 @@ describe("failed turn transcript", () => {
3886
attachments: [],
3887
},
3888
},
3883
- {
3884
- position: 1,
3889
+ ...commands.map((input, index): OrchestrationV2ProjectedTurnItem => ({
3890
+ position: index + 1,
3891
visibility: "local",
3892
sourceThreadId: threadId,
3887
- sourceItemId: TurnItemId.make("command"),
3893
+ sourceItemId: TurnItemId.make(index === 0 ? "command" : `command-${index}`),
3894
item: {
3895
...base,
3890
- id: TurnItemId.make("command"),
3896
+ id: TurnItemId.make(index === 0 ? "command" : `command-${index}`),
3897
+ ordinal: index + 1,
3898
type: "command_execution",
3899
status: "completed",
3893
- input: "pwd",
3900
+ input,
3901
output: "",
3902
exitCode: 0,
3903
},
3897
- },
3904
+ })),
3905
{
3899
- position: 2,
3906
+ position: commands.length + 1,
3907
visibility: "local",
3908
sourceThreadId: threadId,
3909
sourceItemId: TurnItemId.make("failure"),
@@ -3918,20 +3925,24 @@ describe("failed turn transcript", () => {
3925
timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({
3926
visibleTurnItems: items,
3927
optimisticMessages: [],
3921
- }).map((entry) => ({
3922
- ...entry,
3923
- attempt: {
3924
- id: RunAttemptId.make("superseded-attempt"),
3925
- runId,
3926
- attemptOrdinal: 1,
3927
- rootNodeId: NodeId.make("superseded-root"),
3928
- status: "superseded" as const,
3929
- completedAt: null,
3930
- },
3931
- })),
3928
+ }).map((entry) =>
3929
+ isLatest
3930
+ ? entry
3931
+ : {
3932
+ ...entry,
3933
+ attempt: {
3934
+ id: RunAttemptId.make("superseded-attempt"),
3935
+ runId,
3936
+ attemptOrdinal: 1,
3937
+ rootNodeId: NodeId.make("superseded-root"),
3938
+ status: "superseded" as const,
3939
+ completedAt: null,
3940
+ },
3941
+ },
3942
+ ),
3943
latestRun: {
3933
- runId: RunId.make("newer-run"),
3934
- status: "completed",
3944
+ runId: isLatest ? runId : RunId.make("newer-run"),
3945
+ status: isLatest ? "failed" : "completed",
3946
startedAt: DateTime.formatIso(at),
3947
completedAt: DateTime.formatIso(at),
3948
},
@@ -3939,16 +3950,19 @@ describe("failed turn transcript", () => {
3950
turnDiffSummaries: [],
3951
supportsConversationRollback: false,
3952
});
3942
- expect(
3943
- rows.some(
3944
- (row) =>
3945
- row.kind === "turn-fold" || row.kind === "attempt-fold" || row.kind === "work-toggle",
3946
- ),
3947
- ).toBe(false);
3953
+ expect(rows.some((row) => row.kind === "turn-fold" || row.kind === "attempt-fold")).toBe(
3954
+ false,
3955
+ );
3956
const work = rows.flatMap((row) => (row.kind === "work" ? row.groupedEntries : []));
3949
- expect(work.map((entry) => entry.id)).toEqual(["command", "failure"]);
3957
+ expect(rows.find((row) => row.kind === "work-toggle")).toEqual(
3958
+ isLatest ? expect.objectContaining({ hiddenCount: 3, expanded: false }) : undefined,
3959
+ );
3960
+ expect(work.map((entry) => entry.id)).toEqual(
3961
+ isLatest ? ["failure"] : ["command", "failure"],
3962
+ );
3963
expect(work.at(-1)?.detail).toBe("The provider stopped this turn.\nRetry later.");
3964
expect(work.at(-1)?.createdAt).toBe("2026-09-20T12:00:00.000Z");
3965
+ if (isLatest) return;
3966
const entriesWithoutTools = deriveTimelineEntriesFromVisibleTurnItems({
3967
visibleTurnItems: items.filter((row) => row.item.type !== "command_execution"),
3968
optimisticMessages: [],
apps/web/src/components/chat/MessagesTimeline.logic.ts
+22
-1
@@ -973,6 +973,24 @@ function failedTimelineRunIds(
973
return failed;
974
}
975
976
+/** Usage-limit pauses keep their tool groups; any other failure itemizes the run's work. */
977
+function itemizedFailedRunIds(
978
+ entries: ReadonlyArray<TimelineEntry>,
979
+ failedRunIds: ReadonlySet<RunId>,
980
+) {
981
+ const usageLimited = new Set<RunId>();
982
+ const otherFailures = new Set<RunId>();
983
+ for (const entry of entries) {
984
+ const item = timelineEntryFailedItem(entry);
985
+ if (item?.runId) {
986
+ (item.failure.class === "usage_limit" ? usageLimited : otherFailures).add(item.runId);
987
+ }
988
+ }
989
+ return new Set(
990
+ [...failedRunIds].filter((runId) => !usageLimited.has(runId) || otherFailures.has(runId)),
991
+ );
992
+}
993
+
994
function deriveTurnFolds(input: {
995
timelineEntries: ReadonlyArray<TimelineEntry>;
996
terminalAssistantMessageIds: ReadonlySet<string>;
@@ -1410,6 +1428,7 @@ export function deriveMessagesTimelineRows(input: {
1428
const nextRows: MessagesTimelineRow[] = [];
1429
const terminalAssistantMessageIds = deriveTerminalAssistantMessageIds(timelineEntries);
1430
const failedRunIds = failedTimelineRunIds(timelineEntries, input.latestRun ?? null);
1431
+ const itemizedRunIds = itemizedFailedRunIds(timelineEntries, failedRunIds);
1432
const liveSubagentEntryIds = liveSubagentCardEntryIds(timelineEntries);
1433
const completeSupersededReplyIds = completeSupersededReplyEntryIds(timelineEntries);
1434
const supersededFoldsByAnchorEntryId = deriveSupersededAttemptFolds(
@@ -1772,7 +1791,7 @@ export function deriveMessagesTimelineRows(input: {
1791
if (timelineEntry.kind === "work") {
1792
if (
1793
isPendingApproval(timelineEntry.entry) ||
1775
- (timelineEntry.entry.runId != null && failedRunIds.has(timelineEntry.entry.runId)) ||
1794
+ (timelineEntry.entry.runId != null && itemizedRunIds.has(timelineEntry.entry.runId)) ||
1795
(timelineEntry.entry.itemType === "error" &&
1796
timelineEntry.entry.toolLifecycleStatus === "failed") ||
1797
timelineEntry.entry.tone === "error" ||
@@ -1798,6 +1817,8 @@ export function deriveMessagesTimelineRows(input: {
1817
!nextEntry ||
1818
nextEntry.kind !== "work" ||
1819
nextEntry.entry.sourceActivityKind === "context-compaction" ||
1820
+ (nextEntry.entry.itemType === "error" &&
1821
+ nextEntry.entry.toolLifecycleStatus === "failed") ||
1822
nextEntry.entry.tone === "error" ||
1823
nextEntry.entry.sourceActivityKind === "runtime.error" ||
1824
nextEntry.entry.itemType === "system_notice" ||