Skip to content

Commit 80df91b

Browse files
fix(web): keep answered questions visible after a turn settles (pingdotgg#21086)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent d4004c5 commit 80df91b

2 files changed

Lines changed: 123 additions & 1 deletion

File tree

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

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,123 @@ describe("deriveMessagesTimelineRows", () => {
23682368
]);
23692369
});
23702370

2371+
it("keeps answered questions in their own row outside tool groups and turn folds", () => {
2372+
const threadId = ThreadId.make("answered-question-thread");
2373+
const runId = RunId.make("answered-question-run");
2374+
const requestId = RuntimeRequestId.make("scope-question");
2375+
const at = (second: number) =>
2376+
DateTime.makeUnsafe(new Date(Date.UTC(2026, 9, 17, 12, 0, second)).toISOString());
2377+
const base = (id: string, ordinal: number, second: number) => ({
2378+
id: TurnItemId.make(id),
2379+
threadId,
2380+
runId,
2381+
nodeId: null,
2382+
providerThreadId: null,
2383+
providerTurnId: null,
2384+
nativeItemRef: null,
2385+
parentItemId: null,
2386+
ordinal,
2387+
status: "completed" as const,
2388+
title: null,
2389+
startedAt: at(second),
2390+
completedAt: at(second),
2391+
updatedAt: at(second),
2392+
});
2393+
const command = (id: string, ordinal: number, second: number) => ({
2394+
...base(id, ordinal, second),
2395+
type: "command_execution" as const,
2396+
input: `cat ${id}`,
2397+
});
2398+
const items = (settled: boolean) =>
2399+
[
2400+
{
2401+
...base("prompt", 0, 0),
2402+
type: "user_message" as const,
2403+
messageId: MessageId.make("prompt"),
2404+
text: "Pick a repository",
2405+
attachments: [],
2406+
inputIntent: "turn_start" as const,
2407+
createdBy: "user" as const,
2408+
creationSource: "web" as const,
2409+
},
2410+
command("before", 1, 1),
2411+
{
2412+
...base("question", 2, 2),
2413+
type: "user_input_request" as const,
2414+
requestId,
2415+
questions: [],
2416+
questionAnswer: {
2417+
requestId,
2418+
questionTextById: { scope: "Which repository?" },
2419+
answers: { scope: "The private one" },
2420+
attachmentsByQuestionId: {},
2421+
},
2422+
},
2423+
command("after", 3, 3),
2424+
settled
2425+
? {
2426+
...base("answer", 4, 5),
2427+
type: "assistant_message" as const,
2428+
messageId: MessageId.make("answer"),
2429+
text: "Done",
2430+
streaming: false,
2431+
}
2432+
: { ...command("running", 4, 4), status: "running" as const, completedAt: null },
2433+
].map((item, position) => ({
2434+
position,
2435+
visibility: "local" as const,
2436+
sourceThreadId: threadId,
2437+
sourceItemId: item.id,
2438+
item,
2439+
}));
2440+
const rows = (settled: boolean, expandedRunIds?: ReadonlySet<RunId>) =>
2441+
deriveMessagesTimelineRows({
2442+
timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({
2443+
visibleTurnItems: items(settled),
2444+
optimisticMessages: [],
2445+
}),
2446+
latestRun: {
2447+
runId,
2448+
status: settled ? "completed" : "running",
2449+
startedAt: DateTime.formatIso(at(0)),
2450+
completedAt: settled ? DateTime.formatIso(at(5)) : null,
2451+
},
2452+
runningRunId: settled ? null : runId,
2453+
isWorking: !settled,
2454+
activeTurnStartedAt: settled ? null : DateTime.formatIso(at(0)),
2455+
...(expandedRunIds === undefined ? {} : { expandedRunIds }),
2456+
turnDiffSummaries: [],
2457+
supportsConversationRollback: false,
2458+
});
2459+
const shape = (timeline: ReadonlyArray<MessagesTimelineRow>) =>
2460+
timeline.map((row) =>
2461+
row.kind === "turn-fold"
2462+
? "fold"
2463+
: row.kind === "message"
2464+
? `${row.message.role}:${row.message.id}`
2465+
: row.kind === "work" || row.kind === "work-live"
2466+
? `${row.kind}:${row.groupedEntries.map((entry) => entry.id).join(" + ")}`
2467+
: row.kind,
2468+
);
2469+
2470+
expect(shape(rows(true))).toEqual(["user:prompt", "fold", "work:question", "assistant:answer"]);
2471+
expect(shape(rows(true, new Set([runId])))).toEqual([
2472+
"user:prompt",
2473+
"fold",
2474+
"work:before",
2475+
"work:question",
2476+
"work:after",
2477+
"assistant:answer",
2478+
]);
2479+
expect(shape(rows(false))).toEqual([
2480+
"user:prompt",
2481+
"working",
2482+
"work:before",
2483+
"work:question",
2484+
"work-live:after + running",
2485+
]);
2486+
});
2487+
23712488
it("keeps imported V1 turns folded once the thread's first V2 run starts", () => {
23722489
const at = (second: number) => `2026-01-01T00:00:${String(second).padStart(2, "0")}Z`;
23732490
const message = (

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ function deriveTurnFolds(input: {
10861086
continue;
10871087
}
10881088
if (entry.kind === "work" && entry.entry.itemType === "notification") continue;
1089+
// User input stays visible after the surrounding work settles.
1090+
if (entry.kind === "work" && entry.entry.questionAnswer !== undefined) continue;
10891091
hiddenEntryIds.add(entry.id);
10901092
}
10911093
if (hiddenEntryIds.size === 0) {
@@ -1415,6 +1417,7 @@ export function deriveMessagesTimelineRows(input: {
14151417
entry.entry.sourceActivityKind === "runtime.error" ||
14161418
entry.entry.itemType === "system_notice" ||
14171419
entry.entry.itemType === "notification" ||
1420+
entry.entry.questionAnswer !== undefined ||
14181421
!runIdIsActiveResponse(entry.entry.runId) ||
14191422
entry.entry.sourceActivityKind === "context-compaction" ||
14201423
collapsedEntryIds.has(entry.id) ||
@@ -1585,7 +1588,8 @@ export function deriveMessagesTimelineRows(input: {
15851588
timelineEntry.entry.tone === "error" ||
15861589
timelineEntry.entry.sourceActivityKind === "runtime.error" ||
15871590
timelineEntry.entry.itemType === "system_notice" ||
1588-
timelineEntry.entry.itemType === "notification"
1591+
timelineEntry.entry.itemType === "notification" ||
1592+
timelineEntry.entry.questionAnswer !== undefined
15891593
) {
15901594
nextRows.push({
15911595
kind: "work",
@@ -1608,6 +1612,7 @@ export function deriveMessagesTimelineRows(input: {
16081612
nextEntry.entry.sourceActivityKind === "runtime.error" ||
16091613
nextEntry.entry.itemType === "system_notice" ||
16101614
nextEntry.entry.itemType === "notification" ||
1615+
nextEntry.entry.questionAnswer !== undefined ||
16111616
activeWorkEntryIds.has(nextEntry.id) ||
16121617
collapsedEntryIds.has(nextEntry.id) ||
16131618
collapsedSupersededEntryIds.has(nextEntry.id) ||

0 commit comments

Comments
 (0)