fix(ui): keep chat history idle when run status changes (#146802)

This commit is contained in:
Vincent Koc 2026-09-13 19:27:50 +08:00 • committed by GitHub
parent dee64cddf3
commit 50eefaed0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 2 deletions

View file

@ -280,6 +280,44 @@ describe("chat transcript invalidation", () => {
},
);
it.each(["done", "interrupted"] as const)(
"keeps settled history idle when %s status appears, refreshes or clears",
async (phase) => {
vi.spyOn(Date, "now").mockReturnValue(60_000);
const props = threadProps(`pane-terminal-status-${phase}`);
const transcript = createTestTranscript();
const container = document.body.appendChild(document.createElement("div"));
const rerender = () => {
render(renderChatThread(props, transcript), container);
transcript.hostUpdated();
};
try {
rerender();
transcript.hostConnected();
await flushDeferredRowPrune();
const bubbles = Array.from(container.querySelectorAll(".chat-bubble"));
expect(bubbles).toHaveLength(4);
const renderGroup = vi.spyOn(chatMessage, "renderMessageGroup");
for (const occurredAt of [59_000, 59_500, null]) {
props.runStatus =
occurredAt === null
? null
: { phase, runId: "finished-run", sessionKey: props.sessionKey, occurredAt };
rerender();
expect(renderGroup).not.toHaveBeenCalled();
const currentBubbles = Array.from(container.querySelectorAll(".chat-bubble"));
expect(currentBubbles).toHaveLength(bubbles.length);
currentBubbles.forEach((bubble, index) => expect(bubble).toBe(bubbles[index]));
expect(container.textContent).toContain("reply two");
}
} finally {
transcript.hostDisconnected();
}
},
);
it("keeps built row identities across an A to B to A presentation reset", () => {
const paneId = "pane-session-items";
const messagesA = [{ role: "assistant", content: "session A", timestamp: 1_000 }];

View file

@ -692,8 +692,6 @@ export function projectChatTranscript(
props.replyMessageAccess?.revision ?? 0,
props.replyMessageAccess?.navigationId ?? "",
turnRecap === null ? "" : `${turnRecap.runtimeMs}:${turnRecap.outputTokens ?? ""}`,
props.runStatus?.phase ?? "",
props.runStatus?.occurredAt ?? 0,
]);
state.transcriptRenderContext.onSetReply = props.onSetReply;
state.transcriptRenderContext.onAsyncQuestionSubmit = props.onAsyncQuestionSubmit;