fix(webui): keep actions hidden while turn id resolves

This commit is contained in:
Xubin Ren
2026-08-16 00:14:42 +08:00
parent 48126f049d
commit 50391b2fb7
2 changed files with 22 additions and 1 deletions
@@ -147,7 +147,7 @@ export function ThreadMessages({
unit.type === "activity"
? liveActivityClusterIndices.has(index)
: isStreaming && (
unit.message.turnId
unit.message.turnId && activeTurnId !== null
? unit.message.turnId === activeTurnId
: index > currentTurnStartIndex
)
+21
View File
@@ -1171,6 +1171,27 @@ describe("ThreadMessages", () => {
.not.toBeInTheDocument();
});
it("falls back to the latest user boundary while the active turn id is pending", () => {
const { container } = render(
<ThreadMessages
messages={[
{ id: "old-user", role: "user", content: "old question", turnId: "old", createdAt: 1 },
{ id: "old", role: "assistant", content: "old answer", turnId: "old", createdAt: 2 },
{ id: "new-user", role: "user", content: "new question", turnId: "new", createdAt: 3 },
{ id: "live", role: "assistant", content: "live slice", turnId: "new", createdAt: 4 },
]}
isStreaming
activeTurnId={null}
onForkFromMessage={vi.fn()}
/>,
);
expect(container.querySelectorAll('[data-assistant-footer] [aria-label="Copy"]'))
.toHaveLength(1);
expect(container.querySelectorAll('[data-assistant-footer] [aria-label="Fork"]'))
.toHaveLength(1);
});
it("shows copy on adjacent assistant text slices", () => {
const messages: UIMessage[] = [
{ id: "a1", role: "assistant", content: "part one", createdAt: 1 },