Tasks: io.modelcontextprotocol/tasks extension on modern servers (era fork) (#1731)
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
* Tasks: modern io.modelcontextprotocol/tasks extension (era fork core) Core + test-server implementation of the SEP-2663 tasks extension for modern (2026-07-28) connections, forked from the legacy 2025-11-25 tasks path. SDK v2 removed all tasks support AND era-gates the tasks/* spec methods out of the modern era on both the client (outbound) and server (inbound) sides, and its codec rejects a resultType:"task" result outright. So the Inspector drives the extension itself: task creation rides tools/call (a modern method) with the resultType:"task" frame rewritten at the transport to a CallToolResult carrying the handle in _meta; tasks/get/update/cancel go over a raw-wire request channel that bypasses the era gate (full modern envelope, string ids, consumed by the transport). input_required tasks reuse the existing pending-request modal via fulfilInputRequests, answered with tasks/update. No tasks/list, no tasks/result. Tab + run-as-task gate on the negotiated extension; the managed task store's refresh re-polls known handles on modern (no server list). Test server serves the extension via an Express interceptor (SDK can't) + a shared poll-driven runtime. Full integration coverage of both eras. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: tests + coverage (raw-wire, schemas, era integration) Adds unit coverage for modernTaskSchemas and the raw-wire request channel (transport-null guard, send failure, timeout, error response, teardown), plus end-to-end era integration tests (create/poll/input-required/update/cancel, synchronous passthrough, unknown-id error, modern store re-poll). Fixes the App and constructor-capabilities tests for the always-on tasks extension. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: docs + share test servers per era to de-flake coverage Document the tasks era-fork test configs in README and the new core/test-server files in AGENTS.md. Share one modern + one legacy test server across the era integration block (started lazily, stopped in afterAll) — starting a fresh Express server per test made connection negotiation flaky under the heavy concurrent coverage run. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Restore pr-screenshots deleted inadvertently The logging/subscriptions PR screenshots + README were staged-deleted in the working tree before this branch; restore them from v2/main so this PR doesn't remove other PRs' artifacts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: offer Run-as-task for any tool + PR screenshots On modern (SEP-2663) task creation is server-directed — the client declares the extension once and any tool may return a task — so the Tools screen now offers 'Run as task' for every tool on a modern connection (threaded via a modernTasks prop through InspectorView → ToolsScreen → ToolDetailPanel), rather than gating on the legacy per-tool taskSupport. Verified end-to-end in the web UI (remote proxy): create → poll tasks/get → input_required elicitation → tasks/update → inline result, plus the unchanged legacy tasks/list/result flow. Adds proof screenshots. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: address two follow-ups (task-input note + ordinary-path auto-poll) 1. The pending-request note now distinguishes a modern task round from an MRTR round: a new 'task-input-required' PendingRequestOrigin threads through fulfilInputRequests → the pending-request modal → MrtrOriginNote, which shows 'submitted via a tasks/update request (SEP-2663), not a retry' instead of the MRTR retry copy. 2. The ordinary (non-run-as-task) modern callTool path now auto-polls an unsolicited task handle: attemptToolCall detects the rewritten handle in the result _meta and drives it to termination (get → input_required/update → inline result), dispatching task events so the Tasks tab + toasts track it and the tool result resolves to the task's final result. The poll loop is shared with the streaming path via extracted helpers (submitModernTaskInput / modernTaskTerminalOutcome / modernTaskPollInterval). Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: address review (negotiated envelope version, input-round cap, clarifying comment) + fresh smoke screenshots Review of #1731: 1. withModernTaskEnvelope now stamps the NEGOTIATED protocol version (getProtocolVersion() ?? MODERN_PROTOCOL_VERSION) so the envelope matches the MCP-Protocol-Version header instead of a hardcoded constant. 2. A never-completing input_required task is now bounded by MRTR_MAX_ROUNDS in the shared submitModernTaskInput (threaded through both poll loops), so a non-conformant server can't re-prompt the user forever. New modern_loop_task test-server tool + integration test cover the cap. 3. ToolDetailPanel: comment clarifying that per-tool taskSupport:"forbidden" is deliberately ignored on modern (task creation is server-directed under SEP-2663). (The abort-during-poll observation is addressed in the PR reply: the cancel path uses tasks/cancel and disconnect rejects the in-flight raw request, so the poll stops; matches legacy.) Fresh web-UI smoke screenshots (modern connected, task completed, input_required with the corrected tasks/update note, input completed). Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Tasks modern era: fix uncancelable input-required loop + sticky cancel Two bug fixes reported during manual testing of the tasks era-fork (#1631): 1. A modern task paused at `input_required` (e.g. `modern_loop_task`, which never advances) could not be cancelled: the poll loop blocked on the pending-request modal, so `cancelRequestorTask` sent `tasks/cancel` but the modal kept re-prompting. Now each modern poll loop registers a per-task AbortController (`registerTaskInputAbort`), `cancelRequestorTask` aborts it to reject the pending elicitation and unblock the poll, and the embedded input requests are tagged with their owning task id (`RELATED_TASK_META_KEY`) so the pending-request UI's Cancel action cancels the TASK rather than sending a "cancel" answer the server would re-prompt on. 2. On the legacy server, cancelling a task briefly showed CANCELLED then flipped to COMPLETED when the in-flight tool call resolved. Cancellation is a deliberate terminal decision, so `ManagedRequestorTasksState` now remembers cancelled task ids and ignores any later non-cancelled status update. Also: move the compact task id onto its own line in the embedded monitoring sidebar so the status badge / Cancel Task control don't wrap; DRY the duplicated task poll-interval logic into a shared `taskPollInterval` helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Refresh tasks PR screenshots + capture both bug-fix scenarios Recapture the five tasks flow screenshots against the current build and add two demonstrating the post-review fixes: modern_loop_task cancelled from the pending-request modal (uncancelable-loop fix) and a legacy task staying CANCELLED after the in-flight call resolves (sticky-cancel fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 * Address re-review: sticky cancel on legacy refresh + App cancel-routing test Re-review of the cancelable-loop / sticky-cancel fix raised two non-blocking hardening items: 1. The legacy tasks/list refresh() rebuilt the list from the server, honoring only dismissedTaskIds — so a cooperative-cancel server that re-lists a user-cancelled task as completed could un-stick the cancel on a manual Refresh. The refresh path now pins a cancelledTaskIds task to "cancelled" (keeping it visible-as-cancelled, matching the live-merge handlers) rather than dropping it. Covered by a new state test. 2. Added an App.test.tsx case locking in the user-facing half of the fix: Cancel on a task-input-required elicitation calls cancelRequestorTask (not respond). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
320daf2f67
commit
2259b1a3e1
3 changed files with 2483 additions and 132 deletions
159
clients/web/src/test/core/mcp/inspectorClient-raw-wire.test.ts
Normal file
159
clients/web/src/test/core/mcp/inspectorClient-raw-wire.test.ts
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
import { describe, it, expect, vi } from "vitest";
|
||||
import { InspectorClient } from "@inspector/core/mcp/inspectorClient.js";
|
||||
import { ModernGetTaskResultSchema } from "@inspector/core/mcp/modernTaskSchemas.js";
|
||||
|
||||
/**
|
||||
* Unit coverage for the raw-wire request channel (#1631) that drives the modern
|
||||
* tasks/* methods the SDK v2 era gate refuses to send. Exercised directly (with
|
||||
* a fake transport) so the defensive branches — transport-null guard, send
|
||||
* rejection, timeout, error response, and disconnect cleanup — are deterministic
|
||||
* rather than dependent on server timing.
|
||||
*/
|
||||
describe("InspectorClient raw-wire channel (#1631)", () => {
|
||||
function makeClient(): InspectorClient {
|
||||
return new InspectorClient(
|
||||
{ type: "stdio", command: "noop", args: [] },
|
||||
// environment.transport is only used on connect(); these tests never
|
||||
// connect, they poke the private raw-wire methods directly.
|
||||
{ environment: { transport: () => ({}) as never } },
|
||||
);
|
||||
}
|
||||
|
||||
interface RawWireInternals {
|
||||
transport: { send: (m: unknown) => Promise<void> } | null;
|
||||
requestTimeout?: number;
|
||||
rawWireRequest: (
|
||||
method: string,
|
||||
params: Record<string, unknown>,
|
||||
schema: { parse: (v: unknown) => unknown },
|
||||
) => Promise<unknown>;
|
||||
consumeRawWireResponse: (message: unknown) => boolean;
|
||||
rejectPendingRawWireRequests: (reason: string) => void;
|
||||
}
|
||||
|
||||
function internals(client: InspectorClient): RawWireInternals {
|
||||
return client as unknown as RawWireInternals;
|
||||
}
|
||||
|
||||
it("throws when there is no transport", async () => {
|
||||
const client = makeClient();
|
||||
internals(client).transport = null;
|
||||
await expect(
|
||||
internals(client).rawWireRequest(
|
||||
"tasks/get",
|
||||
{},
|
||||
ModernGetTaskResultSchema,
|
||||
),
|
||||
).rejects.toThrow(/not connected/i);
|
||||
});
|
||||
|
||||
it("resolves when a matching response is consumed", async () => {
|
||||
const client = makeClient();
|
||||
let sent: { id: string } | undefined;
|
||||
internals(client).transport = {
|
||||
send: vi.fn(async (m: unknown) => {
|
||||
sent = m as { id: string };
|
||||
}),
|
||||
};
|
||||
const promise = internals(client).rawWireRequest(
|
||||
"tasks/get",
|
||||
{ taskId: "x" },
|
||||
ModernGetTaskResultSchema,
|
||||
);
|
||||
// Let the send microtask register the pending entry.
|
||||
await Promise.resolve();
|
||||
expect(sent?.id).toMatch(/^inspector-ext-/);
|
||||
const consumed = internals(client).consumeRawWireResponse({
|
||||
id: sent!.id,
|
||||
result: {
|
||||
taskId: "x",
|
||||
status: "completed",
|
||||
createdAt: "a",
|
||||
lastUpdatedAt: "b",
|
||||
ttlMs: null,
|
||||
result: { content: [] },
|
||||
},
|
||||
});
|
||||
expect(consumed).toBe(true);
|
||||
const result = (await promise) as { taskId: string };
|
||||
expect(result.taskId).toBe("x");
|
||||
});
|
||||
|
||||
it("ignores a response id it does not own", () => {
|
||||
const client = makeClient();
|
||||
expect(
|
||||
internals(client).consumeRawWireResponse({ id: 42, result: {} }),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects when the response is an error", async () => {
|
||||
const client = makeClient();
|
||||
let sent: { id: string } | undefined;
|
||||
internals(client).transport = {
|
||||
send: vi.fn(async (m: unknown) => {
|
||||
sent = m as { id: string };
|
||||
}),
|
||||
};
|
||||
const promise = internals(client).rawWireRequest(
|
||||
"tasks/cancel",
|
||||
{ taskId: "x" },
|
||||
ModernGetTaskResultSchema,
|
||||
);
|
||||
await Promise.resolve();
|
||||
internals(client).consumeRawWireResponse({
|
||||
id: sent!.id,
|
||||
error: { code: -32602, message: "Unknown taskId" },
|
||||
});
|
||||
await expect(promise).rejects.toThrow(/Unknown taskId/);
|
||||
});
|
||||
|
||||
it("rejects when the transport send fails", async () => {
|
||||
const client = makeClient();
|
||||
internals(client).transport = {
|
||||
send: vi.fn().mockRejectedValue(new Error("socket closed")),
|
||||
};
|
||||
await expect(
|
||||
internals(client).rawWireRequest(
|
||||
"tasks/get",
|
||||
{},
|
||||
ModernGetTaskResultSchema,
|
||||
),
|
||||
).rejects.toThrow(/socket closed/);
|
||||
});
|
||||
|
||||
it("rejects on timeout when no response arrives", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const client = makeClient();
|
||||
internals(client).requestTimeout = 10;
|
||||
internals(client).transport = {
|
||||
send: vi.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
const promise = internals(client).rawWireRequest(
|
||||
"tasks/get",
|
||||
{},
|
||||
ModernGetTaskResultSchema,
|
||||
);
|
||||
const assertion = expect(promise).rejects.toThrow(/timed out/);
|
||||
await vi.advanceTimersByTimeAsync(20);
|
||||
await assertion;
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects all pending requests on teardown", async () => {
|
||||
const client = makeClient();
|
||||
internals(client).transport = {
|
||||
send: vi.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
const promise = internals(client).rawWireRequest(
|
||||
"tasks/get",
|
||||
{},
|
||||
ModernGetTaskResultSchema,
|
||||
);
|
||||
await Promise.resolve();
|
||||
internals(client).rejectPendingRawWireRequests("Disconnected");
|
||||
await expect(promise).rejects.toThrow(/Disconnected/);
|
||||
});
|
||||
});
|
||||
136
clients/web/src/test/core/mcp/modernTaskSchemas.test.ts
Normal file
136
clients/web/src/test/core/mcp/modernTaskSchemas.test.ts
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
TASKS_EXTENSION_KEY,
|
||||
MODERN_PROTOCOL_VERSION,
|
||||
MODERN_TASK_HANDLE_META,
|
||||
TASKS_EXTENSION_CLIENT_CAPABILITY,
|
||||
ModernDetailedTaskSchema,
|
||||
ModernGetTaskResultSchema,
|
||||
ModernUpdateTaskResultSchema,
|
||||
ModernCancelTaskResultSchema,
|
||||
normalizeModernTask,
|
||||
readInputRequests,
|
||||
isModernCreateTaskResult,
|
||||
} from "@inspector/core/mcp/modernTaskSchemas.js";
|
||||
|
||||
describe("modernTaskSchemas (#1631)", () => {
|
||||
const baseTask = {
|
||||
taskId: "abc",
|
||||
status: "working" as const,
|
||||
createdAt: "2026-07-20T00:00:00Z",
|
||||
lastUpdatedAt: "2026-07-20T00:00:01Z",
|
||||
};
|
||||
|
||||
describe("constants", () => {
|
||||
it("exposes the SEP-2663 identifiers", () => {
|
||||
expect(TASKS_EXTENSION_KEY).toBe("io.modelcontextprotocol/tasks");
|
||||
expect(MODERN_PROTOCOL_VERSION).toBe("2026-07-28");
|
||||
expect(MODERN_TASK_HANDLE_META).toContain("modernTaskHandle");
|
||||
expect(
|
||||
TASKS_EXTENSION_CLIENT_CAPABILITY.extensions[TASKS_EXTENSION_KEY],
|
||||
).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("ModernDetailedTaskSchema", () => {
|
||||
it("parses a working task and passes unknown fields through (loose)", () => {
|
||||
const parsed = ModernDetailedTaskSchema.parse({
|
||||
...baseTask,
|
||||
ttlMs: 60000,
|
||||
pollIntervalMs: 500,
|
||||
somethingNew: "kept",
|
||||
});
|
||||
expect(parsed.taskId).toBe("abc");
|
||||
expect((parsed as Record<string, unknown>).somethingNew).toBe("kept");
|
||||
});
|
||||
|
||||
it("accepts a null ttlMs and inline result/error/inputRequests", () => {
|
||||
const completed = ModernGetTaskResultSchema.parse({
|
||||
...baseTask,
|
||||
status: "completed",
|
||||
ttlMs: null,
|
||||
result: { content: [{ type: "text", text: "done" }] },
|
||||
});
|
||||
expect(completed.result).toBeDefined();
|
||||
const failed = ModernDetailedTaskSchema.parse({
|
||||
...baseTask,
|
||||
status: "failed",
|
||||
error: { code: -1, message: "boom" },
|
||||
});
|
||||
expect(failed.error).toBeDefined();
|
||||
});
|
||||
|
||||
it("rejects a task missing required identity fields", () => {
|
||||
expect(() =>
|
||||
ModernDetailedTaskSchema.parse({ status: "working" }),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts empty update/cancel acks", () => {
|
||||
expect(ModernUpdateTaskResultSchema.parse({})).toEqual({});
|
||||
expect(
|
||||
ModernCancelTaskResultSchema.parse({ resultType: "complete" }),
|
||||
).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeModernTask", () => {
|
||||
it("maps ttlMs → ttl and pollIntervalMs → pollInterval", () => {
|
||||
const task = normalizeModernTask({
|
||||
...baseTask,
|
||||
ttlMs: 60000,
|
||||
pollIntervalMs: 250,
|
||||
});
|
||||
expect(task.ttl).toBe(60000);
|
||||
expect((task as { pollInterval?: number }).pollInterval).toBe(250);
|
||||
});
|
||||
|
||||
it("defaults ttl to null and omits pollInterval when absent", () => {
|
||||
const task = normalizeModernTask({ ...baseTask });
|
||||
expect(task.ttl).toBeNull();
|
||||
expect((task as { pollInterval?: number }).pollInterval).toBeUndefined();
|
||||
});
|
||||
|
||||
it("carries the status-specific members structurally", () => {
|
||||
const task = normalizeModernTask({
|
||||
...baseTask,
|
||||
status: "completed",
|
||||
ttlMs: null,
|
||||
result: { content: [] },
|
||||
});
|
||||
expect((task as { result?: unknown }).result).toEqual({ content: [] });
|
||||
});
|
||||
});
|
||||
|
||||
describe("readInputRequests", () => {
|
||||
it("returns the inputRequests map when present", () => {
|
||||
const requests = { confirm: { method: "elicitation/create" } };
|
||||
const out = readInputRequests({
|
||||
...baseTask,
|
||||
status: "input_required",
|
||||
inputRequests: requests,
|
||||
});
|
||||
expect(out).toBe(requests);
|
||||
});
|
||||
|
||||
it("returns undefined when absent", () => {
|
||||
expect(readInputRequests({ ...baseTask })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("isModernCreateTaskResult", () => {
|
||||
it("is true only for a resultType:task frame with a taskId", () => {
|
||||
expect(
|
||||
isModernCreateTaskResult({ resultType: "task", taskId: "x" }),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("is false for complete results, non-objects, and missing taskId", () => {
|
||||
expect(isModernCreateTaskResult({ resultType: "complete" })).toBe(false);
|
||||
expect(isModernCreateTaskResult({ resultType: "task" })).toBe(false);
|
||||
expect(isModernCreateTaskResult({ content: [] })).toBe(false);
|
||||
expect(isModernCreateTaskResult(null)).toBe(false);
|
||||
expect(isModernCreateTaskResult("task")).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -210,6 +210,68 @@ describe("ManagedRequestorTasksState", () => {
|
|||
expect(next[0]!.status).toBe("cancelled");
|
||||
});
|
||||
|
||||
it("keeps a cancelled task cancelled when a later completed update arrives (#1631)", async () => {
|
||||
// Cancellation is a deliberate terminal decision: a server that completes the
|
||||
// task anyway (cooperative cancel) or the in-flight call resolving must not
|
||||
// flip it back to completed.
|
||||
client.setStatus("connected");
|
||||
client.queueTaskPages({ tasks: [task("t1", "working")] });
|
||||
await state.refresh();
|
||||
|
||||
client.dispatchTypedEvent("taskCancelled", { taskId: "t1" });
|
||||
expect(state.getTasks()[0]!.status).toBe("cancelled");
|
||||
|
||||
// A late server notification and a client-origin update, both "completed":
|
||||
let changed = false;
|
||||
state.addEventListener("tasksChange", () => {
|
||||
changed = true;
|
||||
});
|
||||
client.dispatchTypedEvent("taskStatusChange", {
|
||||
taskId: "t1",
|
||||
task: task("t1", "completed"),
|
||||
});
|
||||
client.dispatchTypedEvent("requestorTaskUpdated", {
|
||||
taskId: "t1",
|
||||
task: task("t1", "completed"),
|
||||
});
|
||||
expect(changed).toBe(false);
|
||||
expect(state.getTasks()[0]!.status).toBe("cancelled");
|
||||
});
|
||||
|
||||
it("still applies a subsequent cancelled update for a cancelled task", async () => {
|
||||
client.setStatus("connected");
|
||||
client.queueTaskPages({ tasks: [task("t1", "working")] });
|
||||
await state.refresh();
|
||||
client.dispatchTypedEvent("taskCancelled", { taskId: "t1" });
|
||||
|
||||
// A cancelled-status update is not blocked (it agrees with the sticky state).
|
||||
const changePromise = waitForChange(state);
|
||||
client.dispatchTypedEvent("taskStatusChange", {
|
||||
taskId: "t1",
|
||||
task: { ...task("t1", "cancelled"), statusMessage: "stopped" },
|
||||
});
|
||||
const next = await changePromise;
|
||||
expect(next[0]!.status).toBe("cancelled");
|
||||
expect(next[0]!.statusMessage).toBe("stopped");
|
||||
});
|
||||
|
||||
it("keeps a cancelled task cancelled across a legacy refresh that re-lists it completed (#1631)", async () => {
|
||||
// A cooperative-cancel server may complete the task anyway and still return
|
||||
// it as "completed" from tasks/list. A manual Refresh must not un-stick the
|
||||
// user's cancel — the legacy refresh path pins it to "cancelled" too.
|
||||
client.setStatus("connected");
|
||||
client.queueTaskPages({ tasks: [task("t1", "working")] });
|
||||
await state.refresh();
|
||||
|
||||
client.dispatchTypedEvent("taskCancelled", { taskId: "t1" });
|
||||
expect(state.getTasks()[0]!.status).toBe("cancelled");
|
||||
|
||||
// Server now lists the same task as completed; refresh must keep it cancelled.
|
||||
client.queueTaskPages({ tasks: [task("t1", "completed")] });
|
||||
await state.refresh();
|
||||
expect(state.getTasks()[0]!.status).toBe("cancelled");
|
||||
});
|
||||
|
||||
it("taskCancelled is a no-op when the task is unknown", async () => {
|
||||
client.setStatus("connected");
|
||||
client.queueTaskPages({ tasks: [task("t1")] });
|
||||
|
|
|
|||
Loading…
Reference in a new issue