Built-in design generation now runs as an agentic MCP tool-loop (reusing the agent-rs BuiltInProvider), gated behind OPENPENCIL_DESIGN_AGENT_LOOP / the Settings experimental toggle; the orchestrator stays the default. - design-agent system prompt + in-process design toolset (parity-locked with the MCP surface) + flag-gated Intent::Design routing - spawn_agents execution as sequential sub-loops + live creation-mode badges (per-agent glow + 'N/M designing...' header) - new MCP tools: get_guidelines, ToolSearch, get_screenshot, get_editor_state, export_nodes, spawn_agents; style-guide local audit - #27 AI panel restyle: rounded tool cards + green check-rings, gray user bubbles, model-pill bottom toolbar, header, empty-state pills, the PARALLEL AGENTS (agent_team_size) 1x-6x chip dropdown - multi-chat tabs: ChatSessions model (Deref-to-active) + tab row UI (switch / close / + / Cmd+T) with each run bound to its tab Large checkpoint commit spanning the working tree (Rust shell crates).
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import {
|
|
allocateRequestId,
|
|
registerPending,
|
|
resolvePending,
|
|
rejectPending,
|
|
} from '../utils/mcp-screenshot-rpc';
|
|
|
|
describe('mcp-screenshot-rpc', () => {
|
|
it('allocates unique request ids', () => {
|
|
const a = allocateRequestId();
|
|
const b = allocateRequestId();
|
|
expect(a).not.toBe(b);
|
|
expect(a).toMatch(/^[0-9a-f-]{36}$/);
|
|
});
|
|
|
|
it('resolvePending completes a registered request', async () => {
|
|
const id = allocateRequestId();
|
|
const promise = registerPending(id, 5000);
|
|
const response = {
|
|
requestId: id,
|
|
success: true,
|
|
pngBase64: 'aGVsbG8=',
|
|
};
|
|
const ok = resolvePending(response);
|
|
expect(ok).toBe(true);
|
|
const out = await promise;
|
|
expect(out.pngBase64).toBe('aGVsbG8=');
|
|
});
|
|
|
|
it('resolvePending returns false for unknown request id', () => {
|
|
expect(resolvePending({ requestId: 'nope', success: true })).toBe(false);
|
|
});
|
|
|
|
it('rejectPending surfaces the error to the pending promise', async () => {
|
|
const id = allocateRequestId();
|
|
const promise = registerPending(id, 5000);
|
|
rejectPending(id, new Error('client disconnected'));
|
|
await expect(promise).rejects.toThrow('client disconnected');
|
|
});
|
|
|
|
it('timeouts after the specified duration', async () => {
|
|
const id = allocateRequestId();
|
|
const promise = registerPending(id, 50);
|
|
await expect(promise).rejects.toThrow(/timed out/i);
|
|
});
|
|
});
|