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
@@ -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"),
|
||||
|
||||
Reference in new issue
Block a user