fix(webui): keep completed subagent results with loaded prompts (#6630)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-12 10:34:57 +08:00
1 parent e6b0aec2a8
commit c37af82e3f
19 files changed
+157 -148

No files matched your search

+35
View File
@@ -9,6 +9,7 @@ import {
unitKeysForDisplay,
} from "@/components/thread/ThreadMessages";
import { preloadMarkdownText } from "@/components/MarkdownText";
import { projectThreadEvents } from "@/lib/thread-event-projection";
import type { UIMessage } from "@/lib/types";
// These DOM tests exercise disclosure/source contracts; the real shadow renderer runs in browser tests.
@@ -1179,6 +1180,40 @@ describe("ThreadMessages", () => {
expect(dividerIndex).toBe(branchPromptIndex - 1);
});
it("hides redundant task creation while retaining failed creates and other tool activity", async () => {
const messages = projectThreadEvents([
{ event: "user_message", chat_id: "a", starts_turn: true, turn_id: "turn", text: "Inspect" },
{ event: "message", chat_id: "a", turn_id: "turn", kind: "progress", text: "Tools", tool_events: [
{ call_id: "create", name: "subagent", phase: "end", arguments: { action: "create" } },
{ call_id: "failed", name: "subagent", phase: "error", arguments: { action: "create" }, error: "Creation failed" },
{ call_id: "check", name: "subagent", phase: "end", arguments: { action: "check" } },
{ call_id: "exec", name: "exec", phase: "end", arguments: { command: "pwd" } },
] },
{ event: "message", chat_id: "a", turn_id: "turn", text: "Done" },
]);
render(<ThreadMessages messages={messages} />);
openAssistantBlockMenu();
fireEvent.click(await screen.findByRole("button", { name: /worked/i }));
expect(screen.getByText(/could not create subtask/i)).toBeVisible();
expect(screen.getByText(/subtask status retrieved/i)).toBeVisible();
expect(screen.getByText(/ran command/i)).toBeVisible();
expect(screen.queryByText(/^subtask created/i)).not.toBeInTheDocument();
});
it("keeps the fork boundary after a hidden subagent create activity", () => {
const messages: UIMessage[] = [
{ id: "original", role: "user", content: "original", createdAt: 1 },
{ id: "created", role: "tool", kind: "trace", content: 'subagent({"action":"create"})',
traces: ['subagent({"action":"create"})'], createdAt: 2,
toolEvents: [{ call_id: "call-1", name: "subagent", phase: "end", arguments: { action: "create" } }] },
{ id: "branch", role: "user", content: "branch prompt", createdAt: 3 },
];
render(<ThreadMessages messages={messages} forkBoundaryMessageCount={2} />);
const divider = screen.getByText("Forked from history");
expect(divider.compareDocumentPosition(screen.getByText("branch prompt")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(screen.queryByText(/subtask created/i)).not.toBeInTheDocument();
});
it("keeps turn unit keys stable across replayed ids and mutable turn sequence", () => {
const liveUnits = buildDisplayUnits([
{ id: "optimistic-user", role: "user", content: "go", turnId: "turn-1", turnPhase: "user", turnSeq: 0, createdAt: 1 },