Skip to content

Commit 244a95f

Browse files
PR Batch Testerclaude
andcommitted
test(web): cut usage-limit grouping tests to one regression case
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4609112 commit 244a95f

1 file changed

Lines changed: 62 additions & 124 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 62 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -3913,135 +3913,73 @@ describe("failed turn transcript", () => {
39133913
},
39143914
);
39153915

3916-
it.each([
3917-
{ position: "latest", pauseNotice: true },
3918-
{ position: "historical", pauseNotice: false },
3919-
] as const)(
3920-
"keeps tool groups in a $position run paused by a usage limit",
3921-
({ position, pauseNotice }) => {
3922-
const runId = RunId.make("limited-run");
3923-
const threadId = ThreadId.make("limited-thread");
3924-
const at = DateTime.makeUnsafe("2026-10-25T09:00:00Z");
3925-
const base = {
3926-
threadId,
3927-
runId,
3928-
nodeId: null,
3929-
providerThreadId: null,
3930-
providerTurnId: null,
3931-
nativeItemRef: null,
3932-
parentItemId: null,
3933-
title: null,
3934-
startedAt: at,
3935-
completedAt: at,
3936-
updatedAt: at,
3937-
};
3938-
const projected = (item: OrchestrationV2TurnItem): OrchestrationV2ProjectedTurnItem => ({
3939-
position: item.ordinal,
3940-
visibility: "local",
3941-
sourceThreadId: threadId,
3942-
sourceItemId: item.id,
3943-
item,
3944-
});
3945-
const command = (
3946-
id: string,
3947-
ordinal: number,
3948-
status: "completed" | "failed",
3949-
): OrchestrationV2TurnItem => ({
3916+
it("keeps tool groups collapsed when the latest run stops on a usage limit", () => {
3917+
const runId = RunId.make("limited-run");
3918+
const threadId = ThreadId.make("limited-thread");
3919+
const at = DateTime.makeUnsafe("2026-10-25T09:00:00Z");
3920+
const base = {
3921+
threadId,
3922+
runId,
3923+
nodeId: null,
3924+
providerThreadId: null,
3925+
providerTurnId: null,
3926+
nativeItemRef: null,
3927+
parentItemId: null,
3928+
title: null,
3929+
startedAt: at,
3930+
completedAt: at,
3931+
updatedAt: at,
3932+
};
3933+
const items: OrchestrationV2TurnItem[] = [
3934+
...["pwd", "ls", "false"].map((input, index): OrchestrationV2TurnItem => ({
39503935
...base,
3951-
id: TurnItemId.make(id),
3952-
ordinal,
3936+
id: TurnItemId.make(input),
3937+
ordinal: index,
39533938
type: "command_execution",
3954-
status,
3955-
input: id,
3939+
status: "completed",
3940+
input,
39563941
output: "",
3957-
exitCode: status === "completed" ? 0 : 1,
3958-
});
3959-
const items = [
3960-
projected({
3961-
...base,
3962-
id: TurnItemId.make("user"),
3963-
ordinal: 0,
3964-
type: "user_message",
3965-
status: "completed",
3966-
messageId: MessageId.make("user"),
3967-
createdBy: "user",
3968-
creationSource: "web",
3969-
inputIntent: "turn_start",
3970-
text: "Build it",
3971-
attachments: [],
3972-
}),
3973-
projected(command("pwd", 1, "completed")),
3974-
projected(command("ls", 2, "completed")),
3975-
projected(command("false", 3, "failed")),
3976-
projected({
3977-
...base,
3978-
id: TurnItemId.make("pause"),
3979-
ordinal: 4,
3980-
type: "system_notice",
3981-
status: "completed",
3982-
message: "Claude usage limit reached. This turn is paused until the limit resets.",
3983-
}),
3984-
projected({
3985-
...base,
3986-
id: TurnItemId.make("limit"),
3987-
ordinal: 5,
3988-
type: "error",
3989-
status: "failed",
3990-
failure: {
3991-
class: "usage_limit",
3992-
message: "You've hit your session limit",
3993-
code: null,
3994-
retryable: true,
3995-
},
3996-
}),
3997-
];
3998-
const timelineEntries = deriveTimelineEntriesFromVisibleTurnItems({
3999-
visibleTurnItems: pauseNotice ? items : items.filter((row) => row.item.id !== "pause"),
3942+
exitCode: 0,
3943+
})),
3944+
{
3945+
...base,
3946+
id: TurnItemId.make("limit"),
3947+
ordinal: 3,
3948+
type: "error",
3949+
status: "failed",
3950+
failure: { class: "usage_limit", message: "Limit hit", code: null, retryable: true },
3951+
},
3952+
];
3953+
const rows = deriveMessagesTimelineRows({
3954+
timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({
3955+
visibleTurnItems: items.map((item) => ({
3956+
position: item.ordinal,
3957+
visibility: "local",
3958+
sourceThreadId: threadId,
3959+
sourceItemId: item.id,
3960+
item,
3961+
})),
40003962
optimisticMessages: [],
4001-
});
4002-
const derive = (expandedWorkGroupIds?: ReadonlySet<string>) =>
4003-
deriveMessagesTimelineRows({
4004-
timelineEntries,
4005-
latestRun: {
4006-
runId: position === "latest" ? runId : RunId.make("continued-run"),
4007-
status: position === "latest" ? "failed" : "completed",
4008-
startedAt: DateTime.formatIso(at),
4009-
completedAt: DateTime.formatIso(at),
4010-
},
4011-
...(expandedWorkGroupIds ? { expandedWorkGroupIds } : {}),
4012-
isWorking: false,
4013-
turnDiffSummaries: [],
4014-
supportsConversationRollback: false,
4015-
});
4016-
4017-
const rows = derive();
4018-
expect(rows.some((row) => row.kind === "turn-fold" || row.kind === "attempt-fold")).toBe(
4019-
false,
4020-
);
4021-
const toggle = rows.find((row) => row.kind === "work-toggle");
4022-
expect(toggle).toMatchObject({ hiddenCount: 3, expanded: false, hasFailure: true });
4023-
expect(
4024-
rows.flatMap((row) =>
4025-
row.kind === "work" ? row.groupedEntries.map((entry) => entry.id) : [],
4026-
),
4027-
).toEqual(pauseNotice ? ["pause", "limit"] : ["limit"]);
4028-
expect(
4029-
rows.flatMap((row) => (row.kind === "work" ? row.groupedEntries : [])).at(-1),
4030-
).toMatchObject({ label: "Usage limit reached", toolLifecycleStatus: "failed" });
3963+
}),
3964+
latestRun: {
3965+
runId,
3966+
status: "failed",
3967+
startedAt: DateTime.formatIso(at),
3968+
completedAt: DateTime.formatIso(at),
3969+
},
3970+
isWorking: false,
3971+
turnDiffSummaries: [],
3972+
supportsConversationRollback: false,
3973+
});
40313974

4032-
const expanded = derive(new Set([toggle?.kind === "work-toggle" ? toggle.groupId : ""]));
4033-
const group = expanded.find((row) => row.kind === "work" && row.isExpandedToolGroup);
4034-
expect(
4035-
group?.kind === "work"
4036-
? group.groupedEntries.map((entry) => [entry.id, entry.toolLifecycleStatus])
4037-
: [],
4038-
).toEqual([
4039-
["pwd", "completed"],
4040-
["ls", "completed"],
4041-
["false", "failed"],
4042-
]);
4043-
},
4044-
);
3975+
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
3976+
hiddenCount: 3,
3977+
expanded: false,
3978+
});
3979+
expect(
3980+
rows.flatMap((row) => (row.kind === "work" ? row.groupedEntries.map((e) => e.id) : [])),
3981+
).toEqual(["limit"]);
3982+
});
40453983
});
40463984

40473985
describe("live subagents after their parent turn settles", () => {

0 commit comments

Comments
 (0)