Skip to content

Commit 1083b05

Browse files
colonelpanic8claude
andcommitted
fix(web): keep answered questions visible after a turn settles
#11363 made an answered question its own timeline row: it never joined a tool group, the live activity row, or the "Worked for" turn fold. The orchestration V2 rewrite (#2829) dropped those exemptions from MessagesTimeline.logic.ts and they were never restored, so once a turn settles the answer disappears behind the fold, and expanding the fold only shows it merged into a "Ran N commands" summary. Treat work entries carrying a questionAnswer like notifications again: skip them when hiding a settled turn's work, stop the active-turn tail and settled tool grouping at them, and render each as its own row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3ff5b3c commit 1083b05

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
@@ -2366,6 +2366,123 @@ describe("deriveMessagesTimelineRows", () => {
23662366
]);
23672367
});
23682368

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

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ function deriveTurnFolds(input: {
10841084
continue;
10851085
}
10861086
if (entry.kind === "work" && entry.entry.itemType === "notification") continue;
1087+
// User input stays visible after the surrounding work settles.
1088+
if (entry.kind === "work" && entry.entry.questionAnswer !== undefined) continue;
10871089
hiddenEntryIds.add(entry.id);
10881090
}
10891091
if (hiddenEntryIds.size === 0) {
@@ -1413,6 +1415,7 @@ export function deriveMessagesTimelineRows(input: {
14131415
entry.entry.sourceActivityKind === "runtime.error" ||
14141416
entry.entry.itemType === "system_notice" ||
14151417
entry.entry.itemType === "notification" ||
1418+
entry.entry.questionAnswer !== undefined ||
14161419
!runIdIsActiveResponse(entry.entry.runId) ||
14171420
entry.entry.sourceActivityKind === "context-compaction" ||
14181421
collapsedEntryIds.has(entry.id) ||
@@ -1580,7 +1583,8 @@ export function deriveMessagesTimelineRows(input: {
15801583
timelineEntry.entry.tone === "error" ||
15811584
timelineEntry.entry.sourceActivityKind === "runtime.error" ||
15821585
timelineEntry.entry.itemType === "system_notice" ||
1583-
timelineEntry.entry.itemType === "notification"
1586+
timelineEntry.entry.itemType === "notification" ||
1587+
timelineEntry.entry.questionAnswer !== undefined
15841588
) {
15851589
nextRows.push({
15861590
kind: "work",
@@ -1603,6 +1607,7 @@ export function deriveMessagesTimelineRows(input: {
16031607
nextEntry.entry.sourceActivityKind === "runtime.error" ||
16041608
nextEntry.entry.itemType === "system_notice" ||
16051609
nextEntry.entry.itemType === "notification" ||
1610+
nextEntry.entry.questionAnswer !== undefined ||
16061611
activeWorkEntryIds.has(nextEntry.id) ||
16071612
collapsedEntryIds.has(nextEntry.id) ||
16081613
collapsedSupersededEntryIds.has(nextEntry.id) ||

0 commit comments

Comments
 (0)