feat(subagent): add session-owned task messaging and cancellation (#5985)
let's go!
This commit is contained in:
1 parent
f75470e72f
commit
6ff96f2a8f
93 files changed
+5632
-1156
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AgentActivityCluster } from "@/components/thread/AgentActivityCluster";
|
||||
import { preloadMarkdownText } from "@/components/MarkdownText";
|
||||
import { setAppLanguage } from "@/i18n";
|
||||
import { DEFAULT_LOCAL_PREFS, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import type { CliAppInfo, McpPresetInfo, UIMessage } from "@/lib/types";
|
||||
|
||||
const BLENDER_CLI_APP: CliAppInfo = {
|
||||
@@ -98,6 +98,21 @@ function installReducedMotion() {
|
||||
}
|
||||
|
||||
describe("AgentActivityCluster", () => {
|
||||
afterEach(() => { localStorage.removeItem(LOCAL_PREFS_STORAGE_KEY); });
|
||||
|
||||
it("honors the activity preference for standalone completed activity with manual overrides", () => {
|
||||
render(<AgentActivityCluster messages={activityMessages()} isTurnStreaming={false} hasBodyBelow={false} />);
|
||||
const disclosure = screen.getByRole("button", { name: /Worked/ });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "false");
|
||||
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "true");
|
||||
fireEvent.click(disclosure);
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "false");
|
||||
act(() => { writeLocalPreferences(DEFAULT_LOCAL_PREFS); });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "false");
|
||||
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "true");
|
||||
});
|
||||
it("updates existing activity when the language changes without altering raw values", async () => {
|
||||
const query = "release notes";
|
||||
const path = "src/app.tsx";
|
||||
|
||||
@@ -58,7 +58,8 @@ function mockFetchRoutes(routes: Record<string, unknown>): void {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async (input: RequestInfo | URL) => {
|
||||
const route = routes[String(input)];
|
||||
const route = routes[String(input)]
|
||||
?? (/^\/api\/sessions\/[^/]+\/subagents$/.test(String(input)) ? { tasks: [] } : undefined);
|
||||
const body =
|
||||
typeof route === "function"
|
||||
? await (route as () => unknown | Promise<unknown>)()
|
||||
@@ -338,13 +339,7 @@ describe("App layout", () => {
|
||||
expires_in: 300,
|
||||
});
|
||||
vi.mocked(deriveWsUrl).mockReset().mockReturnValue("ws://test");
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: false,
|
||||
status: 404,
|
||||
}),
|
||||
);
|
||||
mockFetchRoutes({});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -366,6 +361,34 @@ describe("App layout", () => {
|
||||
expect(screen.queryByText("Loading nanobot…")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each([false, true])("enables task controls only when bootstrap advertises support: %s", async (supported) => {
|
||||
mockSessions = [{
|
||||
key: "websocket:chat-a", channel: "websocket", chatId: "chat-a",
|
||||
createdAt: null, updatedAt: null, title: "Inspection", preview: "Inspect config",
|
||||
}];
|
||||
window.history.replaceState(null, "", "/#/chat/websocket%3Achat-a");
|
||||
vi.mocked(fetchBootstrap).mockResolvedValue({
|
||||
token: "tok", api_token: "api-tok", ws_path: "/", expires_in: 300,
|
||||
terminal: { webui: { capabilities: supported ? ["webui.core.v1", "webui.subagents.v1"] : ["webui.core.v1"] } },
|
||||
});
|
||||
mockFetchRoutes({
|
||||
"/api/sessions/websocket%3Achat-a/subagents": { tasks: [{
|
||||
task_id: "task-1", label: "Config check", task_description: "Inspect configuration",
|
||||
state: "running", phase: "awaiting_model", elapsed_seconds: 2, iteration: 1,
|
||||
tool_events: [], usage: null, receipts: {}, result: null, partial: false,
|
||||
stop_reason: null, error: null, origin_turn_id: null, origin_message_id: null,
|
||||
created_at: 100, completed_at: null,
|
||||
}] },
|
||||
});
|
||||
render(<App />);
|
||||
await screen.findByRole("textbox");
|
||||
if (supported) await screen.findByRole("button", { name: /Config check Running/ });
|
||||
else expect(screen.queryByText("Config check")).not.toBeInTheDocument();
|
||||
const reads = vi.mocked(fetch).mock.calls.filter(([url]) => String(url).endsWith("/subagents"));
|
||||
expect(reads).toHaveLength(supported ? 1 : 0);
|
||||
expect(requestMutationSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows the auth form without an invalid-password error on first load", async () => {
|
||||
vi.mocked(fetchBootstrap).mockRejectedValueOnce(
|
||||
new Error("bootstrap failed: HTTP 401"),
|
||||
|
||||
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { redactActivityText } from "@/components/thread/activity/activity-text";
|
||||
import {
|
||||
describeGenericToolRun,
|
||||
canGroupGenericToolRuns,
|
||||
parseGenericToolTrace,
|
||||
type GenericToolStatus,
|
||||
} from "@/components/thread/activity/generic-tool-model";
|
||||
@@ -39,7 +40,12 @@ describe("generic tool activity semantics", () => {
|
||||
['read_file({"path":"docs/guide.md"})', "Read file", "docs/guide.md"],
|
||||
['memory_search({"query":"launch date"})', "Searched memory", "“launch date”"],
|
||||
['generate_image({"prompt":"private launch art"})', "Generated image", ""],
|
||||
['spawn({"label":"Research competitors","task":"private task"})', "Delegated task", "Research competitors"],
|
||||
['spawn({"label":"Research competitors","task":"private task"})', "Subtask created", "Research competitors"],
|
||||
['subagent("create")', "Subtask created", ""],
|
||||
['subagent({"action":"create","label":"Research competitors","task":"private task"})', "Subtask created", "Research competitors"],
|
||||
['subagent("check")', "Subtask status retrieved", ""],
|
||||
['subagent("send")', "Message queued for subtask", ""],
|
||||
['subagent("cancel")', "Stop request processed", ""],
|
||||
['message({"channel":"telegram","content":"private message"})', "Sent message", "telegram"],
|
||||
['my({"action":"check","key":"context_window_tokens"})', "Checked agent settings", "context_window_tokens"],
|
||||
['my({"action":"set","key":"model","value":"private-model"})', "Updated agent settings", "model"],
|
||||
@@ -125,6 +131,13 @@ describe("generic tool activity semantics", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps different subtask actions separate while grouping repeated status checks", () => {
|
||||
const item = (action: string) => ({ trace: parseGenericToolTrace(`subagent("${action}")`)!, status: "done" as const });
|
||||
expect(canGroupGenericToolRuns(item("create"), item("check"))).toBe(false);
|
||||
expect(canGroupGenericToolRuns(item("send"), item("cancel"))).toBe(false);
|
||||
expect(canGroupGenericToolRuns(item("check"), item("check"))).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Authorization: Bearer top-secret-token", "Authorization: <redacted>"],
|
||||
["API_KEY=sk-proj-1234567890abcdef", "API_KEY=<redacted>"],
|
||||
|
||||
@@ -28,6 +28,21 @@ describe("localized agent activity contracts", () => {
|
||||
expect(translated.actionTargetRich).toContain("<target></target>");
|
||||
|
||||
await setAppLanguage(locale);
|
||||
for (const [action, keys] of [
|
||||
["create", ["delegatingTask", "delegatedTask", "delegateTaskFailed"]],
|
||||
["check", ["checkingSubtask", "checkedSubtask", "checkSubtaskFailed"]],
|
||||
["send", ["messagingSubtask", "queuedSubtaskMessage", "messageSubtaskFailed"]],
|
||||
["cancel", ["stoppingSubtask", "requestedSubtaskStop", "stopSubtaskFailed"]],
|
||||
] as const) {
|
||||
for (const line of [`subagent("${action}")`, `subagent({"action":"${action}","task_id":"private-id","message":"private instructions"})`]) {
|
||||
const subtask = parseGenericToolTrace(line)!;
|
||||
for (const [index, status] of (["running", "done", "error"] as const).entries()) {
|
||||
expect(describeGenericToolRun([{ trace: subtask, status }], i18n.t)).toMatchObject({
|
||||
label: translated[keys[index]], detail: "", status,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const trace = parseGenericToolTrace('read_file({"path":"src/app.tsx"})')!;
|
||||
const rg = parseGenericToolTrace('rg({"args":["-n","hello world","src"]})')!;
|
||||
for (const status of ["running", "done", "error"] as const) {
|
||||
@@ -99,4 +114,24 @@ describe("localized agent activity contracts", () => {
|
||||
expect(screen.getByText("Could not search release notes")).toBeInTheDocument();
|
||||
expect(JSON.stringify(messages)).toBe(original);
|
||||
});
|
||||
|
||||
it("renders recorded subtask actions in Chinese and English without implying execution is complete", async () => {
|
||||
const messages: UIMessage[] = [{
|
||||
id: "subtask-replay", role: "tool", kind: "trace", createdAt: 1,
|
||||
content: 'subagent("create")',
|
||||
traces: ['subagent("create")', 'subagent("check")', 'subagent("send")', 'subagent("cancel")'],
|
||||
}];
|
||||
const original = JSON.stringify(messages);
|
||||
await setAppLanguage("zh-CN");
|
||||
render(<AgentActivityCluster messages={messages} isTurnStreaming={false} hasBodyBelow expanded />);
|
||||
for (const label of ["子任务已创建", "已获取子任务状态", "消息已加入子任务队列", "已处理停止请求"]) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument();
|
||||
}
|
||||
expect(screen.queryByText("已完成 Subagent")).not.toBeInTheDocument();
|
||||
await act(async () => setAppLanguage("en"));
|
||||
for (const label of ["Subtask created", "Subtask status retrieved", "Message queued for subtask", "Stop request processed"]) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument();
|
||||
}
|
||||
expect(JSON.stringify(messages)).toBe(original);
|
||||
});
|
||||
});
|
||||
@@ -1619,6 +1619,18 @@ describe("NanobotClient", () => {
|
||||
|
||||
expect(chatHandler).toHaveBeenCalledTimes(deliveredBeforeLateFrames);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
const otherChat = vi.fn();
|
||||
client.onChat("other-chat", otherChat);
|
||||
const taskUpdate = {
|
||||
event: "subagent_task", chat_id: "chat-canonical",
|
||||
task: { task_id: "child", origin_turn_id: "turn-canonical", state: "done", revision: 4 },
|
||||
};
|
||||
lastSocket().fakeMessage(taskUpdate);
|
||||
expect(chatHandler).toHaveBeenLastCalledWith(taskUpdate);
|
||||
expect(chatHandler).toHaveBeenCalledTimes(deliveredBeforeLateFrames + 1);
|
||||
expect(otherChat).not.toHaveBeenCalled();
|
||||
expect(client.hasUnsettledRun("chat-canonical")).toBe(false);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
});
|
||||
|
||||
it("notifies run status subscribers and replays running chats", () => {
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { SubagentTasksProvider, SubagentThreadMessages as ThreadMessages } from "@/components/thread/SubagentTasks";
|
||||
import { buildDisplayUnits, unitKeysForDisplay } from "@/components/thread/ThreadMessages";
|
||||
import { ThreadVisibilityContext } from "@/hooks/useThreadVisibility";
|
||||
import { setAppLanguage } from "@/i18n";
|
||||
import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import type { ConnectionStatus, InboundEvent, SubagentTaskSnapshot, UIMessage } from "@/lib/types";
|
||||
|
||||
const requestMutation = vi.fn();
|
||||
const chatHandlers = new Map<string, Set<(event: InboundEvent) => void>>();
|
||||
const statusHandlers = new Set<(status: ConnectionStatus) => void>();
|
||||
const client = {
|
||||
requestMutation,
|
||||
onChat: vi.fn((chatId: string, handler: (event: InboundEvent) => void) => {
|
||||
const handlers = chatHandlers.get(chatId) ?? new Set();
|
||||
chatHandlers.set(chatId, handlers);
|
||||
handlers.add(handler);
|
||||
return () => { handlers.delete(handler); };
|
||||
}),
|
||||
onStatus: vi.fn((handler: (status: ConnectionStatus) => void) => {
|
||||
statusHandlers.add(handler);
|
||||
handler("open");
|
||||
return () => { statusHandlers.delete(handler); };
|
||||
}),
|
||||
};
|
||||
function emitTask(snapshot: SubagentTaskSnapshot, chatId = "a") {
|
||||
act(() => { chatHandlers.get(chatId)?.forEach((handler) => handler({ event: "subagent_task", chat_id: chatId, task: snapshot })); });
|
||||
}
|
||||
const messages: UIMessage[] = [
|
||||
{ id: "prompt-a", role: "user", content: "Inspect config", turnId: "turn-a" },
|
||||
{ id: "answer-a", role: "assistant", content: "Main answer", turnId: "turn-a" },
|
||||
];
|
||||
|
||||
function task(overrides: Partial<SubagentTaskSnapshot> = {}): SubagentTaskSnapshot {
|
||||
return {
|
||||
task_id: "task-1", revision: 1, label: "Config check", task_description: "Check configuration values",
|
||||
state: "running", phase: "awaiting_model", elapsed_seconds: 2, iteration: 1,
|
||||
tool_events: [], usage: null, receipts: {}, result: null, partial: false,
|
||||
stop_reason: null, error: null, origin_turn_id: "turn-a", origin_message_id: null,
|
||||
created_at: 100, completed_at: null, ...overrides,
|
||||
};
|
||||
}
|
||||
function response(tasks: SubagentTaskSnapshot[]): Response {
|
||||
return new Response(JSON.stringify({ tasks }), { headers: { "content-type": "application/json" } });
|
||||
}
|
||||
function childThread(answer: string, active = true): Response {
|
||||
return new Response(JSON.stringify({ schemaVersion: 3, projection: "events", active_turn_id: active ? "child-turn" : null,
|
||||
events: [
|
||||
{ event: "user_message", chat_id: "task-1", starts_turn: true, projection_id: "child-prompt", turn_id: "child-turn", text: "Inspect configuration in the child session", created_at_ms: 100000 },
|
||||
{ event: "message", chat_id: "task-1", projection_id: "child-tool", turn_id: "child-turn", kind: "tool_hint", text: 'read_file({"path":"config.py"})',
|
||||
tool_events: [{ call_id: "read-1", name: "read_file", arguments: { path: "config.py" }, phase: "end", result: "configuration values" }] },
|
||||
{ event: "message", chat_id: "task-1", projection_id: "child-answer", turn_id: "child-turn", text: answer },
|
||||
],
|
||||
}), { headers: { "content-type": "application/json" } });
|
||||
}
|
||||
function layout({ enabled = true, liveEvents = true, historyEnabled = false, sessionKey = "websocket:a", visible = true, threadMessages = messages } = {}) {
|
||||
return <ThreadVisibilityContext.Provider value={visible}>
|
||||
<SubagentTasksProvider client={client} sessionKey={sessionKey} token="tok" enabled={enabled} liveEvents={liveEvents} historyEnabled={historyEnabled}>
|
||||
<div data-testid="messages"><ThreadMessages messages={threadMessages} /></div>
|
||||
<div data-testid="composer"><textarea aria-label="Message" /></div>
|
||||
</SubagentTasksProvider>
|
||||
</ThreadVisibilityContext.Provider>;
|
||||
}
|
||||
|
||||
describe("session-owned task UI", () => {
|
||||
beforeEach(async () => {
|
||||
localStorage.removeItem(LOCAL_PREFS_STORAGE_KEY);
|
||||
await setAppLanguage("en");
|
||||
requestMutation.mockReset();
|
||||
client.onChat.mockClear();
|
||||
client.onStatus.mockClear();
|
||||
chatHandlers.clear();
|
||||
statusHandlers.clear();
|
||||
vi.stubGlobal("fetch", vi.fn().mockImplementation(async () => response([task()])));
|
||||
});
|
||||
afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals(); localStorage.removeItem(LOCAL_PREFS_STORAGE_KEY); });
|
||||
|
||||
it("applies the browser activity preference to delegated work and its shared child chat", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn(async (url: string) => url.endsWith("/webui-thread")
|
||||
? childThread("Configuration verified", false)
|
||||
: response([task({ state: "done", completed_at: 102 })])));
|
||||
const user = userEvent.setup();
|
||||
const view = render(layout({ historyEnabled: true }));
|
||||
const work = await screen.findByRole("button", { name: /Delegated work/ });
|
||||
expect(work).toHaveAttribute("aria-expanded", "false");
|
||||
|
||||
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
|
||||
expect(work).toHaveAttribute("aria-expanded", "true");
|
||||
await user.click(screen.getByRole("button", { name: /Config check Completed/ }));
|
||||
const detail = screen.getByRole("dialog", { name: "Config check" });
|
||||
expect(await within(detail).findByText("Configuration verified")).toBeVisible();
|
||||
expect(within(detail).getByTestId("agent-activity-content")).toBeVisible();
|
||||
await user.click(within(detail).getByRole("button", { name: /Collapse activity details/ }));
|
||||
expect(within(detail).queryByTestId("agent-activity-content")).not.toBeInTheDocument();
|
||||
|
||||
act(() => { writeLocalPreferences(DEFAULT_LOCAL_PREFS); });
|
||||
expect(work).toHaveAttribute("aria-expanded", "false");
|
||||
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
|
||||
expect(within(detail).getByTestId("agent-activity-content")).toBeVisible();
|
||||
view.unmount();
|
||||
|
||||
render(layout({ historyEnabled: true }));
|
||||
expect(await screen.findByRole("button", { name: /Config check Completed/ })).toBeVisible();
|
||||
await user.click(screen.getByRole("button", { name: /Config check Completed/ }));
|
||||
expect(await within(screen.getByRole("dialog")).findByTestId("agent-activity-content")).toBeVisible();
|
||||
});
|
||||
|
||||
it("renders the child Session in the shared chat view and refreshes it from task events", async () => {
|
||||
let completed = false;
|
||||
const fetcher = vi.fn(async (url: string) => url.endsWith("/webui-thread")
|
||||
? childThread(completed ? "## Findings\n\n- **Verified** the full session\n\n| Check | Result |\n| --- | --- |\n| Configuration | Passed |" : "Checking the configuration", !completed)
|
||||
: response([task()]));
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
const user = userEvent.setup();
|
||||
const view = render(layout({ historyEnabled: true }));
|
||||
await user.click(await screen.findByRole("button", { name: /Config check Running/ }));
|
||||
const detail = screen.getByRole("dialog", { name: "Config check" });
|
||||
expect(await within(detail).findByText("Inspect configuration in the child session")).toBeVisible();
|
||||
expect(within(detail).getByText("Checking the configuration")).toBeVisible();
|
||||
expect(fetcher).toHaveBeenCalledWith(
|
||||
"/api/sessions/websocket%3Aa/subagents/task-1/webui-thread", expect.objectContaining({ signal: expect.any(AbortSignal) }),
|
||||
);
|
||||
completed = true;
|
||||
emitTask(task({ revision: 2, state: "done", completed_at: 102, result: "Bounded task summary" }));
|
||||
expect(await within(detail).findByRole("heading", { name: "Findings" })).toBeVisible();
|
||||
expect(within(detail).getByRole("table")).toHaveTextContent("ConfigurationPassed");
|
||||
expect(within(detail).getByText("Inspect configuration in the child session")).toBeVisible();
|
||||
// Opening and reading details never mutates execution; a fresh view reads the same saved child.
|
||||
expect(requestMutation).not.toHaveBeenCalled();
|
||||
view.unmount();
|
||||
fetcher.mockImplementation(async (url) => url.endsWith("/webui-thread") ? childThread("## Findings\n\nVerified the full session", false)
|
||||
: response([task({ revision: 2, state: "done", completed_at: 102 })]));
|
||||
render(layout({ historyEnabled: true }));
|
||||
await user.click(await screen.findByRole("button", { name: /Delegated work/ }));
|
||||
await user.click(screen.getByRole("button", { name: /Config check Completed/ }));
|
||||
expect(await within(screen.getByRole("dialog")).findByRole("heading", { name: "Findings" })).toBeVisible();
|
||||
});
|
||||
|
||||
it("coalesces history reads and discards an outstanding read when the session changes", async () => {
|
||||
let resolveFirst!: (value: Response) => void;
|
||||
let resolveOld!: (value: Response) => void;
|
||||
let reads = 0;
|
||||
const readSignals: AbortSignal[] = [];
|
||||
const fetcher = vi.fn(async (url: string, init?: RequestInit) => {
|
||||
if (!url.endsWith("/webui-thread")) return response([task()]);
|
||||
if (init?.signal) readSignals.push(init.signal);
|
||||
reads += 1;
|
||||
if (reads === 1) return new Promise<Response>((resolve) => { resolveFirst = resolve; });
|
||||
if (reads === 3) return new Promise<Response>((resolve) => { resolveOld = resolve; });
|
||||
return childThread("Latest child response", false);
|
||||
});
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
const user = userEvent.setup();
|
||||
const view = render(layout({ historyEnabled: true }));
|
||||
await user.click(await screen.findByRole("button", { name: /Config check Running/ }));
|
||||
await waitFor(() => expect(reads).toBe(1));
|
||||
emitTask(task({ revision: 2, iteration: 2 }));
|
||||
emitTask(task({ revision: 3, iteration: 3 }));
|
||||
expect(reads).toBe(1);
|
||||
await act(async () => { resolveFirst(childThread("Earlier checkpoint")); });
|
||||
expect(await within(screen.getByRole("dialog")).findByText("Latest child response")).toBeVisible();
|
||||
expect(reads).toBe(2);
|
||||
emitTask(task({ revision: 4, iteration: 4 }));
|
||||
await waitFor(() => expect(reads).toBe(3));
|
||||
const oldSignal = readSignals.at(-1);
|
||||
view.rerender(layout({ historyEnabled: true, sessionKey: "websocket:b" }));
|
||||
await screen.findByRole("button", { name: /Config check Running/ });
|
||||
expect(oldSignal?.aborted).toBe(true);
|
||||
await act(async () => { resolveOld(childThread("Old session response")); });
|
||||
await user.click(screen.getByRole("button", { name: /Config check Running/ }));
|
||||
expect(await within(screen.getByRole("dialog")).findByText("Latest child response")).toBeVisible();
|
||||
});
|
||||
|
||||
it("retries a failed history read through the shared history controls", async () => {
|
||||
let offline = true;
|
||||
vi.stubGlobal("fetch", vi.fn(async (url: string) => {
|
||||
if (!url.endsWith("/webui-thread")) return response([task()]);
|
||||
if (offline) throw new Error("offline");
|
||||
return childThread("Recovered child response");
|
||||
}));
|
||||
const user = userEvent.setup();
|
||||
render(layout({ historyEnabled: true }));
|
||||
await user.click(await screen.findByRole("button", { name: /Config check Running/ }));
|
||||
const detail = screen.getByRole("dialog");
|
||||
expect(await within(detail).findByRole("alert")).toHaveTextContent("Loading failed.");
|
||||
offline = false;
|
||||
await user.click(within(detail).getByRole("button", { name: "Retry" }));
|
||||
expect(await within(detail).findByText("Recovered child response")).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps the same work block under its prompt, folds completed work and restores it after refresh", async () => {
|
||||
const view = render(layout());
|
||||
const runningRow = await screen.findByRole("button", { name: /Config check Running/ });
|
||||
const work = runningRow.closest("section");
|
||||
const header = within(work!).getByRole("button", { name: /Delegated work/ });
|
||||
expect(screen.getByTestId("messages")).toContainElement(runningRow);
|
||||
expect(header).toHaveAttribute("aria-expanded", "true");
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: 2, state: "done", result: "Verified", completed_at: 102 })]));
|
||||
fireEvent(window, new Event("focus"));
|
||||
await waitFor(() => expect(header).toHaveAttribute("aria-expanded", "false"));
|
||||
fireEvent.click(header);
|
||||
const row = screen.getByRole("button", { name: /Config check Completed/ });
|
||||
expect(row).toBe(runningRow);
|
||||
expect(row.closest("section")).toBe(work);
|
||||
expect(within(screen.getByTestId("composer")).queryByText("Config check")).not.toBeInTheDocument();
|
||||
expect(work).toHaveAccessibleName("Delegated work");
|
||||
view.unmount();
|
||||
render(layout());
|
||||
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
|
||||
expect(screen.getByRole("button", { name: /Config check Completed/ })).toBeVisible();
|
||||
expect(requestMutation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows truthful partial output, interruption and receipts, and restores keyboard focus", async () => {
|
||||
vi.mocked(fetch).mockResolvedValue(response([task({
|
||||
state: "interrupted", partial: true, result: "Found a conflicting setting",
|
||||
stop_reason: "host_restarted", completed_at: 102, receipts: { a: "delivered", b: "undelivered" },
|
||||
})]));
|
||||
const user = userEvent.setup();
|
||||
render(layout());
|
||||
await user.click(await screen.findByRole("button", { name: /Delegated work/ }));
|
||||
const row = await screen.findByRole("button", { name: /Config check Interrupted/ });
|
||||
await user.click(row);
|
||||
const detail = screen.getByRole("dialog", { name: "Config check" });
|
||||
expect(within(detail).getByText(/has not been restarted automatically/)).toBeVisible();
|
||||
expect(detail).toHaveFocus();
|
||||
expect(within(detail).getByText("Interrupted")).toBeVisible();
|
||||
expect(within(detail).getByText("Found a conflicting setting")).toBeVisible();
|
||||
await user.click(within(detail).getByText("Message delivery"));
|
||||
expect(within(detail).getByText("Delivered: 1")).toBeVisible();
|
||||
expect(screen.queryByRole("button", { name: "Stop Config check" })).not.toBeInTheDocument();
|
||||
await user.keyboard("{Escape}");
|
||||
await waitFor(() => expect(row).toHaveFocus());
|
||||
});
|
||||
|
||||
it("keeps cancellation and an open detail consistent when an older read completes later", async () => {
|
||||
let resolveRefresh!: (value: Response) => void;
|
||||
let resolveStop!: (value: SubagentTaskSnapshot) => void;
|
||||
requestMutation.mockImplementation(() => new Promise((resolve) => { resolveStop = resolve; }));
|
||||
const user = userEvent.setup();
|
||||
render(layout());
|
||||
await user.click(await screen.findByRole("button", { name: /Config check Running/ }));
|
||||
await user.keyboard("{Escape}");
|
||||
await user.click(screen.getByRole("button", { name: "Stop Config check" }));
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { resolveRefresh = resolve; }));
|
||||
fireEvent(window, new Event("focus"));
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));
|
||||
await act(async () => { resolveStop(task({ revision: 3, state: "cancelled", completed_at: 102 })); });
|
||||
await user.click(screen.getByRole("button", { name: /Delegated work Finished: 1/ }));
|
||||
await screen.findByRole("button", { name: /Config check Cancelled/ });
|
||||
await act(async () => { resolveRefresh(response([task()])); });
|
||||
expect(screen.queryByRole("button", { name: "Stop Config check" })).not.toBeInTheDocument();
|
||||
expect(requestMutation).toHaveBeenCalledWith("subagent.cancel", { session_key: "websocket:a", task_id: "task-1" }, 20_000);
|
||||
});
|
||||
|
||||
it("does not request an unsupported feature and detaches events in hidden panes", async () => {
|
||||
const view = render(layout({ enabled: false }));
|
||||
expect(fetch).not.toHaveBeenCalled();
|
||||
view.rerender(layout({ visible: false }));
|
||||
expect(fetch).not.toHaveBeenCalled();
|
||||
view.rerender(layout());
|
||||
fireEvent.click(await screen.findByRole("button", { name: /Config check Running/ }));
|
||||
expect(screen.getByRole("dialog", { name: "Config check" })).toBeVisible();
|
||||
view.rerender(layout({ visible: false }));
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
fireEvent(window, new Event("focus"));
|
||||
expect(fetch).toHaveBeenCalledTimes(1);
|
||||
expect(chatHandlers.get("a")?.size).toBe(0);
|
||||
expect(statusHandlers.size).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps load failures visible and keeps stop failures across a successful refresh", async () => {
|
||||
const user = userEvent.setup();
|
||||
requestMutation.mockRejectedValue(new Error("Cannot stop task"));
|
||||
render(layout());
|
||||
await user.click(await screen.findByRole("button", { name: "Stop Config check" }));
|
||||
await screen.findByText("Cannot stop task");
|
||||
fireEvent(window, new Event("focus"));
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));
|
||||
expect(screen.getByText("Cannot stop task")).toBeVisible();
|
||||
vi.mocked(fetch).mockRejectedValue(new Error("offline"));
|
||||
fireEvent(window, new Event("focus"));
|
||||
await screen.findByText("Could not load subtasks.");
|
||||
expect(screen.getByRole("button", { name: /Config check Running/ })).toBeVisible();
|
||||
});
|
||||
|
||||
it("shows a read error for malformed or duplicate task records", async () => {
|
||||
vi.mocked(fetch).mockImplementation(async () => new Response(JSON.stringify({
|
||||
tasks: [{ ...task(), label: { unexpected: true } }],
|
||||
}), { headers: { "content-type": "application/json" } }));
|
||||
render(layout());
|
||||
await screen.findByText("Could not load subtasks.");
|
||||
expect(screen.queryByText("Config check")).not.toBeInTheDocument();
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task(), task()]));
|
||||
fireEvent(window, new Event("focus"));
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));
|
||||
expect(screen.getByText("Could not load subtasks.")).toBeVisible();
|
||||
expect(screen.queryByText("Config check")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("discards reads from the previous session after switching", async () => {
|
||||
let resolveOld!: (value: Response) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { resolveOld = resolve; }));
|
||||
const view = render(layout());
|
||||
vi.mocked(fetch).mockResolvedValue(response([task({ task_id: "task-b", label: "Other work" })]));
|
||||
view.rerender(layout({ sessionKey: "websocket:b" }));
|
||||
await screen.findByRole("button", { name: /Other work Running/ });
|
||||
await act(async () => { resolveOld(response([task()])); });
|
||||
expect(screen.queryByText("Config check")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps task details open through completion and renders Markdown results", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(layout());
|
||||
const row = await screen.findByRole("button", { name: /Config check Running/ });
|
||||
await user.click(row);
|
||||
const detail = screen.getByRole("dialog", { name: "Config check" });
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: 2, state: "done", completed_at: 102,
|
||||
result: "## Findings\n\n- **Release** resources\n- Cover exceptions\n\n```python\nawait connection.close()\n```\n\n| Check | Result |\n| --- | --- |\n| Cancellation | Passed |\n\n[Evidence](https://example.com/review)",
|
||||
})]));
|
||||
fireEvent(window, new Event("focus"));
|
||||
expect(await within(detail).findByRole("heading", { name: "Findings" })).toBeVisible();
|
||||
expect(within(detail).getByRole("list")).toHaveTextContent("Release resources");
|
||||
expect(within(detail).getByRole("table")).toHaveTextContent("CancellationPassed");
|
||||
expect(await within(detail).findByText("await connection.close()", { exact: false })).toBeVisible();
|
||||
expect(within(detail).getByRole("link", { name: /Evidence/ })).toHaveAttribute("href", "https://example.com/review");
|
||||
expect(detail).toBeVisible();
|
||||
await user.keyboard("{Escape}");
|
||||
await waitFor(() => expect(screen.getByRole("button", { name: /Delegated work/ })).toHaveFocus());
|
||||
expect(requestMutation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("anchors replay once when multiple prompts share a turn and preserves row order", async () => {
|
||||
const replay = [...messages, { id: "followup", role: "user", content: "Focus on errors", turnId: "turn-a" } satisfies UIMessage];
|
||||
const keys = unitKeysForDisplay(buildDisplayUnits(replay));
|
||||
expect(new Set(keys).size).toBe(keys.length);
|
||||
vi.mocked(fetch).mockImplementation(async () => response([
|
||||
task({ task_id: "second", label: "Second check", created_at: 101, origin_message_id: "old-prompt-id" }),
|
||||
task({ origin_message_id: "old-prompt-id" }),
|
||||
]));
|
||||
render(layout({ threadMessages: replay }));
|
||||
await screen.findByRole("button", { name: /Config check Running/ });
|
||||
expect(screen.getAllByRole("region", { name: "Delegated work" })).toHaveLength(1);
|
||||
const rows = screen.getAllByRole("button", { name: /check Running/ });
|
||||
expect(rows.map((row) => row.dataset.subagentId)).toEqual(["task-1", "second"]);
|
||||
vi.mocked(fetch).mockImplementation(async () => response([
|
||||
task({ task_id: "second", revision: 2, label: "Second check", created_at: 101, origin_message_id: "old-prompt-id", state: "error", error: "Unreadable file" }),
|
||||
task({ origin_message_id: "old-prompt-id" }),
|
||||
]));
|
||||
fireEvent(window, new Event("focus"));
|
||||
await screen.findByRole("button", { name: /Second check Failed/ });
|
||||
expect(screen.getAllByRole("button", { name: /check (Running|Failed)/ }).map((row) => row.dataset.subagentId)).toEqual(["task-1", "second"]);
|
||||
expect(screen.getByRole("button", { name: /Review needed: 1/ })).toBeVisible();
|
||||
expect(screen.getByText("Main answer").compareDocumentPosition(screen.getByText("Second check")) & Node.DOCUMENT_POSITION_PRECEDING).toBeTruthy();
|
||||
});
|
||||
|
||||
it("prefers the exact initiating follow-up over a turn fallback", async () => {
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task({ origin_message_id: "followup" })]));
|
||||
render(layout({ threadMessages: [...messages, { id: "followup", role: "user", content: "Check more", turnId: "turn-a" }] }));
|
||||
await screen.findByRole("button", { name: /Config check Running/ });
|
||||
const group = screen.getByRole("region", { name: "Delegated work" });
|
||||
expect(screen.getByText("Check more").compareDocumentPosition(group) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
});
|
||||
|
||||
it("keeps legacy work with an unknown origin separate from the latest request after refresh", async () => {
|
||||
vi.mocked(fetch).mockImplementation(async () => response([
|
||||
task({ task_id: "legacy", revision: 0, label: "Nanjing weather", state: "done", completed_at: 102,
|
||||
origin_turn_id: "websocket:a:1791046873588004336", result: "## Nanjing\n\n- **Rain**" }),
|
||||
task({ created_at: 200 }),
|
||||
]));
|
||||
const user = userEvent.setup();
|
||||
const view = render(layout());
|
||||
await screen.findByRole("button", { name: /Config check Running/ });
|
||||
const otherWork = screen.getByRole("region", { name: "Other delegated work" });
|
||||
const header = within(otherWork).getByRole("button", { name: /Other delegated work/ });
|
||||
expect(header).toHaveAttribute("aria-expanded", "false");
|
||||
expect(otherWork.compareDocumentPosition(screen.getByText("Inspect config")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(within(screen.getByRole("region", { name: "Delegated work" })).queryByText("Nanjing weather")).not.toBeInTheDocument();
|
||||
await user.click(header);
|
||||
expect(within(otherWork).getByText("These tasks have no matching request in the displayed messages.")).toBeVisible();
|
||||
await user.click(within(otherWork).getByRole("button", { name: /Nanjing weather Completed/ }));
|
||||
const detail = screen.getByRole("dialog", { name: "Nanjing weather" });
|
||||
expect(within(detail).getByRole("heading", { name: "Nanjing" })).toBeVisible();
|
||||
expect(within(detail).getByRole("list")).toHaveTextContent("Rain");
|
||||
await user.keyboard("{Escape}");
|
||||
view.unmount();
|
||||
render(layout());
|
||||
const restored = await screen.findByRole("region", { name: "Other delegated work" });
|
||||
expect(within(restored).getByRole("button", { name: /Other delegated work/ })).toHaveAttribute("aria-expanded", "false");
|
||||
expect(restored.compareDocumentPosition(screen.getByText("Inspect config")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(requestMutation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("reattaches work when its initiating prompt is loaded without duplicating it or closing details", async () => {
|
||||
vi.mocked(fetch).mockImplementation(async () => response([
|
||||
task({ task_id: "older", label: "Earlier check", origin_turn_id: "older-turn", origin_message_id: "older-prompt" }),
|
||||
task({ created_at: 200 }),
|
||||
]));
|
||||
const user = userEvent.setup();
|
||||
const view = render(layout());
|
||||
const otherWork = await screen.findByRole("region", { name: "Other delegated work" });
|
||||
await user.click(within(otherWork).getByRole("button", { name: /Earlier check Running/ }));
|
||||
const detail = screen.getByRole("dialog", { name: "Earlier check" });
|
||||
view.rerender(layout({ threadMessages: [
|
||||
{ id: "older-prompt", role: "user", content: "Inspect earlier work", turnId: "older-turn" },
|
||||
...messages,
|
||||
] }));
|
||||
expect(detail).toBeVisible();
|
||||
await user.keyboard("{Escape}");
|
||||
expect(screen.queryByRole("region", { name: "Other delegated work" })).not.toBeInTheDocument();
|
||||
const row = screen.getByRole("button", { name: /Earlier check Running/ });
|
||||
expect(screen.getAllByRole("button", { name: /Earlier check Running/ })).toHaveLength(1);
|
||||
expect(screen.getByText("Inspect earlier work").compareDocumentPosition(row) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(screen.getByText("Inspect config").compareDocumentPosition(row) & Node.DOCUMENT_POSITION_PRECEDING).toBeTruthy();
|
||||
await waitFor(() => expect(row).toHaveFocus());
|
||||
});
|
||||
|
||||
it("merges live work before the initial read without polling or rolling back completed work", async () => {
|
||||
let resolveRead!: (value: Response) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { resolveRead = resolve; }));
|
||||
render(layout());
|
||||
emitTask(task({ revision: 3, state: "done", result: "Verified", completed_at: 102 }));
|
||||
emitTask(task({ task_id: "task-2", label: "Sibling check", created_at: 101 }));
|
||||
await screen.findByRole("button", { name: /Sibling check Running/ });
|
||||
await act(async () => { resolveRead(response([task()])); });
|
||||
expect(screen.getByRole("button", { name: /Config check Completed/ })).toBeVisible();
|
||||
expect(screen.getAllByRole("region", { name: "Delegated work" })).toHaveLength(1);
|
||||
vi.useFakeTimers();
|
||||
await act(async () => { vi.advanceTimersByTime(10_000); });
|
||||
expect(fetch).toHaveBeenCalledTimes(1);
|
||||
expect(requestMutation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps elapsed time consistent when inspecting a task long after its last event", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.spyOn(performance, "now").mockImplementation(() => Date.now());
|
||||
render(layout());
|
||||
await act(async () => { await Promise.resolve(); });
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(10_000); });
|
||||
const row = screen.getByRole("button", { name: /Config check Running/ });
|
||||
expect(row).toHaveTextContent("12s");
|
||||
fireEvent.click(row);
|
||||
expect(screen.getByRole("dialog", { name: "Config check" })).toHaveTextContent("12s");
|
||||
expect(fetch).toHaveBeenCalledTimes(1);
|
||||
vi.mocked(performance.now).mockRestore();
|
||||
});
|
||||
|
||||
it("recovers missed siblings after reconnect even when an older read is still pending", async () => {
|
||||
let resolveOld!: (value: Response) => void;
|
||||
render(layout());
|
||||
await screen.findByRole("button", { name: /Config check Running/ });
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { resolveOld = resolve; }));
|
||||
fireEvent(window, new Event("focus"));
|
||||
emitTask(task({ revision: 3, state: "cancelled", completed_at: 102 }));
|
||||
vi.mocked(fetch).mockImplementationOnce(async () => response([
|
||||
task({ revision: 2 }), task({ task_id: "task-2", label: "Recovered check", created_at: 101 }),
|
||||
]));
|
||||
act(() => { statusHandlers.forEach((handler) => { handler("closed"); handler("open"); }); });
|
||||
await act(async () => { resolveOld(response([task()])); });
|
||||
await screen.findByRole("button", { name: /Recovered check Running/ });
|
||||
expect(screen.getByRole("button", { name: /Config check Cancelled/ })).toBeVisible();
|
||||
expect(fetch).toHaveBeenCalledTimes(3);
|
||||
emitTask({ ...task(), revision: -1 });
|
||||
expect(screen.getByText("Could not load subtasks.")).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps protocol 1 task controls usable on a host without event support", async () => {
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: undefined })]));
|
||||
vi.useFakeTimers();
|
||||
const view = render(layout({ liveEvents: false }));
|
||||
await act(async () => { await Promise.resolve(); });
|
||||
expect(screen.getByRole("button", { name: /Config check Running/ })).toBeVisible();
|
||||
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: undefined, state: "done", completed_at: 102 })]));
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(3000); });
|
||||
expect(screen.getByRole("button", { name: /Delegated work Finished: 1/ })).toBeVisible();
|
||||
expect(client.onChat).not.toHaveBeenCalled();
|
||||
view.rerender(layout({ liveEvents: false, visible: false }));
|
||||
const reads = vi.mocked(fetch).mock.calls.length;
|
||||
await act(async () => { vi.advanceTimersByTime(6000); });
|
||||
expect(fetch).toHaveBeenCalledTimes(reads);
|
||||
});
|
||||
});
|
||||
@@ -222,12 +222,14 @@ function wrap(
|
||||
children: ReactNode,
|
||||
modelName?: string | null,
|
||||
token = "tok",
|
||||
webuiCapabilities: string[] = [],
|
||||
) {
|
||||
return (
|
||||
<ClientProvider
|
||||
client={client as unknown as import("@/lib/nanobot-client").NanobotClient}
|
||||
token={token}
|
||||
modelName={modelName ?? null}
|
||||
webuiCapabilities={webuiCapabilities}
|
||||
>
|
||||
{children}
|
||||
</ClientProvider>
|
||||
@@ -491,6 +493,39 @@ describe("ThreadShell", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("renders one persisted task entry at the initiating prompt through the full shell", async () => {
|
||||
const client = makeClient();
|
||||
vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
|
||||
if (String(input).endsWith("/subagents")) return httpJson({ tasks: [{
|
||||
task_id: "completed-task", label: "Inspect settings", task_description: "Inspect settings",
|
||||
origin_turn_id: "delegation-turn", origin_message_id: null, created_at: 100, completed_at: 102,
|
||||
state: "done", phase: "done", elapsed_seconds: 2, iteration: 1, tool_events: [],
|
||||
usage: null, receipts: {}, result: "Verified", partial: false, stop_reason: "completed", error: null,
|
||||
}] });
|
||||
if (String(input).includes("/webui-thread")) return httpJson(transcriptFromSimpleMessages([
|
||||
{ role: "user", content: "Delegate inspection", turnId: "delegation-turn" },
|
||||
{ role: "assistant", content: "Parent conclusion", turnId: "delegation-turn" },
|
||||
]));
|
||||
return { ok: false, status: 404, json: async () => ({}) };
|
||||
}));
|
||||
const shell = () => wrap(client, <ThreadShell session={session("persisted-tasks")} title="Task history"
|
||||
onToggleSidebar={() => {}} />, null, "tok", ["webui.core.v1", "webui.subagents.v1"]);
|
||||
const view = render(shell());
|
||||
await screen.findByText("Delegate inspection");
|
||||
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
|
||||
const task = await screen.findByRole("button", { name: /Inspect settings Completed/ });
|
||||
await screen.findByText("Delegate inspection");
|
||||
expect(screen.getAllByRole("button", { name: /Inspect settings/ })).toHaveLength(1);
|
||||
expect(screen.getByTestId("thread-message-region")).toContainElement(task);
|
||||
expect(within(screen.getByTestId("thread-composer-motion")).queryByText("Inspect settings")).not.toBeInTheDocument();
|
||||
view.unmount();
|
||||
render(shell());
|
||||
await screen.findByText("Delegate inspection");
|
||||
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
|
||||
await screen.findByRole("button", { name: /Inspect settings Completed/ });
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("clears the welcome draft after a delayed new-chat send and an unchanged round-trip", async () => {
|
||||
const client = makeClient();
|
||||
const store = new ComposerDraftStore();
|
||||
|
||||
Reference in new issue
Block a user