Skip to content

Commit f5ea839

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 4e00d00 commit f5ea839

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
@@ -3905,135 +3905,73 @@ describe("failed turn transcript", () => {
39053905
},
39063906
);
39073907

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

4024-
const expanded = derive(new Set([toggle?.kind === "work-toggle" ? toggle.groupId : ""]));
4025-
const group = expanded.find((row) => row.kind === "work" && row.isExpandedToolGroup);
4026-
expect(
4027-
group?.kind === "work"
4028-
? group.groupedEntries.map((entry) => [entry.id, entry.toolLifecycleStatus])
4029-
: [],
4030-
).toEqual([
4031-
["pwd", "completed"],
4032-
["ls", "completed"],
4033-
["false", "failed"],
4034-
]);
4035-
},
4036-
);
3967+
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
3968+
hiddenCount: 3,
3969+
expanded: false,
3970+
});
3971+
expect(
3972+
rows.flatMap((row) => (row.kind === "work" ? row.groupedEntries.map((e) => e.id) : [])),
3973+
).toEqual(["limit"]);
3974+
});
40373975
});
40383976

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

0 commit comments

Comments
 (0)