Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): re-check cancellation before spawning MTPLX
Adam Eivyc5b4c6e9c50d
diff --git a/docs/features/mtplx.md b/docs/features/mtplx.mdindex ee9a7d1d02..dfee97410a 100644--- a/docs/features/mtplx.md+++ b/docs/features/mtplx.md@@ -29,15 +29,17 @@ valid CoS coding-agent runner.1. On **AI Providers**, enable the matching preset. Its card shows an MTPLXrequirements checklist (installed / server responding / model available).-2. Pull a checkpoint yourself — `mtplx pull` fetches MTPLX's default verified- model, `mtplx pull <hf-repo-id>` any other MTP model. PortOS never downloads- weights, and `mtplx serve` exits immediately when its cache is empty.-3. Click **Install & start MTPLX** on that checklist. PortOS installs the+2. Click **Install & start MTPLX** on that checklist. PortOS installs thepackage from upstream's Homebrew tap (`brew install youssofal/mtplx/mtplx`),falling back to `python3 -m pip install mtplx` on a host without Homebrew,then runs `mtplx serve --port <the port your provider points at> --model <amodel already in your MTPLX cache>` and waits for `/v1/models` to answer.Progress streams into the install modal.+3. **If it reports that no weights are cached**, pull a checkpoint yourself —+ `mtplx pull` fetches MTPLX's default verified model, `mtplx pull+ <hf-repo-id>` any other MTP model — then click **Start MTPLX** again. PortOS+ never downloads weights, and `mtplx serve` exits before it binds a port when+ its cache is empty.4. Use **Refresh Models** once the server is up; PortOS then reads `/v1/models`on demand. The seed model alias is `mtplx` — refresh it if your runningserver publishes a different one.diff --git a/server/services/localRuntimeSetup.js b/server/services/localRuntimeSetup.jsindex 4bff64fb59..abe4b623a1 100644--- a/server/services/localRuntimeSetup.js+++ b/server/services/localRuntimeSetup.js@@ -235,6 +235,11 @@ const SETUP_ROWS = Object.freeze({return { success: false, error: `its cache holds ${count} model${count === 1 ? '' : 's'}, but none passed its own file check — an interrupted \`mtplx pull\` leaves a partial download behind. Re-run \`mtplx pull <hf-repo-id>\` in a terminal, then try again.` };}if (model) emit(`Serving the cached MTPLX model ${model}.`);+ // The cache lookup is an awaited subprocess — the modal can close while it+ // runs, and the caller's cancellation check happened BEFORE it. Without+ // this, a cancelled setup still spawns a detached daemon nobody asked to+ // keep.+ if (isCancelled()) return { success: false, error: 'Cancelled before the server was started.' };// `mtplx start` is interactive (it prompts for a model); `serve` is the// API-only server, which is the half PortOS actually talks to. The daemon// must bind where the PROVIDER points — a user who moved MTPLX to 8010diff --git a/server/services/localRuntimeSetup.test.js b/server/services/localRuntimeSetup.test.jsindex 4f279975ee..8b0384b1e0 100644--- a/server/services/localRuntimeSetup.test.js+++ b/server/services/localRuntimeSetup.test.js@@ -361,6 +361,29 @@ describe('runLocalRuntimeSetup', () => {expect(result.success).toBe(true);});+ it('does not spawn a daemon when the modal closed while the cache was being read', async () => {+ // The cache lookup is an awaited subprocess, and the caller's cancellation+ // check ran BEFORE it — without a re-check, a closed modal still leaves a+ // detached MTPLX server running.+ let cancelled = false;+ mtplxCache.listMtplxCachedModels.mockImplementation(async () => {+ cancelled = true; // the user closes the modal while `mtplx models` runs+ return cachedModels([{ repo_id: 'Example/MTP-Model', validation: { ok: true } }]);+ });+ pathLookup.findCommandOnPath.mockReturnValue('/opt/homebrew/bin/mtplx');+ probe.probeOpenAiModels.mockResolvedValue(unreachable);+ const restore = pinPlatform('darwin');++ const result = await runLocalRuntimeSetup('mtplx', {+ endpoint: 'http://127.0.0.1:8000/v1',+ isCancelled: () => cancelled,+ });+ restore();++ expect(child.spawn).not.toHaveBeenCalled();+ expect(result).toMatchObject({ success: false, error: expect.stringMatching(/Cancelled/) });+ });+it('reports what a dying daemon printed, skipping its ASCII-art banner', async () => {const daemon = fakeChild();child.spawn.mockReturnValue(daemon);