Commit Graph

1 Commits

Author SHA1 Message Date
ethernet d408e6b6c3 refactor(e2e): extract shared mock inference server
The OpenAI-compatible mock server used by the desktop E2E suite
(apps/desktop/e2e/mock-server.ts) was hand-duplicated into
apps/desktop/scripts/dev-mock.mjs for local dev, which had already
drifted (dev-mock.mjs lacked scripted tool-call turns and had its own
copy of the SSE framing).

Extract the dependency-free core (models list, chat completions,
streaming/non-streaming, canned reply, prompt capture) into
scripts/mock-inference-server.mjs, runnable standalone via Node
(no npm install needed — only node:http/fs) or importable as a module.
It exposes an onCompletionRequest hook so callers can layer scripted
multi-turn tool-call sequences on top without forking the core.

apps/desktop/e2e/mock-server.ts now wraps the shared module, keeping
only the desktop-specific scripted turns (interim messages, sidebar
states, queue-stop, correction-switch, verification-stop, blocking
clarify) and all existing exports. apps/desktop/scripts/dev-mock.mjs
now imports the shared module directly instead of carrying its own
copy.

This makes the mock server reusable outside apps/desktop, e.g. from
tests/install/install-update-e2e.sh for a real CLI chat round-trip.
2026-08-05 00:49:56 -04:00