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
fix: stop instructing spawned TUI agents to run /quit
Adam Eivy71a0e305e85e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 817699cef5..d2c6e8940f 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -20,6 +20,7 @@ TBD## Fixed+- **TUI agents no longer try (and fail) to `/quit` at the end of a run.** The spawned-agent completion workflow used to tell the agent to write its `.agent-done` sentinel and then run `/quit`. In current Claude Code, `/quit` is a UI command that can't be invoked programmatically — so the agent attempted `Skill(quit)`, hit an error, and printed a confusing "please run /quit yourself" message before idling. The prompt now treats the sentinel as the sole done signal (PortOS finalizes the run within 2s of seeing it and closes the session itself) and explicitly tells the agent not to run `/quit`.- **Tabbed sub-nav strips no longer drift vertically on mobile.** The horizontally-scrolling sub-nav tabs (Media Gen and every other page that uses the shared `TabPills` primitive) could be dragged diagonally/vertically on iOS, producing an uneven, wonky scroll. Both `TabPills` scroll containers now set `touch-action: pan-x` so touch gestures pan the strip horizontally while vertical drags pass through to normal page scrolling.- **Chief of Staff pane overflow** — content panel collapses to a single `flex-1 min-h-0 min-w-0 overflow-y-auto overflow-x-hidden` div so tall tab content scrolls inside the panel instead of expanding it. Event log rows in both `EventLog` and `TerminalCoSPanel` get `break-all` so long unbreakable tokens (URLs, hashes, paths) wrap inside the 320px sidebar instead of pushing the column wider visually.- **Videos now load in the Media Gen preview on mobile.** Both the preview-modal (lightbox) `<video>` and the Video Gen page's inline result preview autoplayed unmuted, which iOS/Android block outside a direct user gesture — so the clip never started and the area showed only black ("not loading"). They now play `muted` (autoplay-eligible everywhere; controls let you unmute) and render the thumbnail as a `poster`, so the frame is visible immediately even while the clip buffers.diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex eca4933e72..346cda0463 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -359,7 +359,7 @@ export function buildCompletionGuidelineBullet({return '**This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.';}if (isTui) {- return `On successful completion, YOU run the Completion Workflow above (\`${tuiCompletionCommand}\`, write the sentinel, \`/quit\`).`;+ return `On successful completion, YOU run the Completion Workflow above (\`${tuiCompletionCommand}\`, then write the sentinel and stop — PortOS closes the session once it sees the sentinel; do NOT run \`/quit\`).`;}if (worktreeInfo && willOpenPR) {const reviewSuffix = willReviewLoop@@ -483,9 +483,11 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an// TUI completion section — delegate to the shared light-path builder so// both prompt paths emit byte-identical workflows. (Background: TUI owns- // its own `/simplify` → `/do:pr|/do:push` → sentinel → `/quit` sequence- // because the slashdo submodule mounts those commands at project level —- // see `buildTuiCompletionSection` below for the full contract.)+ // its own `/simplify` → `/do:pr|/do:push` → sentinel sequence because the+ // slashdo submodule mounts those commands at project level. Writing the+ // sentinel is the done signal — PortOS finalizes via the 2s poll and kills+ // the session, so the prompt does NOT ask the agent to `/quit` (it's a UI+ // command the agent can't invoke). See `buildTuiCompletionSection` below.)const tuiCompletionCommand = willOpenPR ? '/do:pr' : '/do:push';const tuiCompletionSection = isTui? buildTuiCompletionSection({@@ -856,7 +858,6 @@ function buildTuiCompletionSection({ willOpenPR, willReviewLoop, simplifyEnabledconst sentinelTail = willOpenPR ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';const merge = willOpenPR ? buildPostPRMergeSteps(3, { reviewers, reviewStopMode }) : { lines: [], nextStep: 3 };const sentinelStep = merge.nextStep;- const quitStep = sentinelStep + 1;return ['## Completion Workflow',@@ -865,7 +866,7 @@ function buildTuiCompletionSection({ willOpenPR, willReviewLoop, simplifyEnabledsimplifyStep,`2. \`${cmd}${reviewerArg}\`${reviewSuffix}`,...merge.lines,- `${sentinelStep}. Write a short markdown summary (~5–15 lines) to the completion sentinel — PortOS polls this every 2s; without it the agent sits idle until a 3-minute fallback fires.`,+ `${sentinelStep}. Write a short markdown summary (~5–15 lines) to the completion sentinel, then stop — this sentinel is the done signal. PortOS polls it every 2s, finalizes the run, and closes the session for you. Do NOT run \`/quit\` (it's a UI command, not something you can invoke) and do NOT wait for anything after writing the sentinel.`,'',' ```bash',` cat > "${sentinelPath}" <<'EOF'`,@@ -877,8 +878,7 @@ function buildTuiCompletionSection({ willOpenPR, willReviewLoop, simplifyEnabled'',sentinelTail,' EOF',- ' ```',- `${quitStep}. \`/quit\`.`+ ' ```'].join('\n');}diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 5d7d5b7fe8..a065065b87 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -173,7 +173,11 @@ describe('buildLightContextPrompt', () => {expect(prompt).toMatch(/`\/simplify`/);expect(prompt).toMatch(/`\/do:pr`/);expect(prompt).toMatch(/\.agent-done/);- expect(prompt).toMatch(/\/quit/);+ // The sentinel is the done signal — the agent must NOT be told to RUN+ // /quit (it's a UI command it can't invoke; PortOS closes the session on+ // poll). The prompt only mentions /quit to tell the agent NOT to run it.+ expect(prompt).not.toMatch(/^\s*\d+\.\s*`\/quit`/m);+ expect(prompt).toMatch(/NOT run `\/quit`/);// After /do:pr drives the Copilot review loop clean, the agent must// merge and verify — otherwise the PR sits open after the agent exits.expect(prompt).toMatch(/gh pr merge "<PR_URL>" --squash --delete-branch/);diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex 7f98c86bd8..b42366d0a5 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -183,9 +183,11 @@ export async function spawnTuiAgent({const rawFile = join(agentDir, 'raw.txt');const cwd = workspacePath && typeof workspacePath === 'string' ? workspacePath : PATHS.root;// The agent writes `.agent-done` in its workspace to signal completion (see- // the sentinel watcher below). Computed up front so both the watcher AND- // finish() can read it — finish() ingests it directly to survive the- // /quit-exit-vs-poll race (see ingestDoneSentinel).+ // the sentinel watcher below) and then stops — it does NOT run `/quit` (that+ // is a UI command the agent can't invoke). The 2s poll is the primary+ // finalize path; finish() also ingests the sentinel directly so the summary+ // is captured even if some other path (idle/exit) finalizes first. Computed+ // up front so both the watcher AND finish() can read it (see ingestDoneSentinel).const doneSentinelPath = workspacePath ? join(workspacePath, DONE_SENTINEL_NAME) : null;const promptPreview = prompt.replace(/\s+/g, ' ').slice(0, 100);const commandName = tuiConfig.command.split('/').pop();@@ -381,11 +383,11 @@ export async function spawnTuiAgent({// Ingest the .agent-done sentinel BEFORE draining, so its markdown summary// lands in outputBuffer/output.txt regardless of WHICH path finalized the- // agent. The completion workflow writes the sentinel and then runs /quit —- // the process exits within milliseconds, so handleExit almost always wins- // the race against the 2s doneSentinelTimer poll. Reading it here (not just- // in the poll) is what makes the resolution show up in the completed-agent- // details view. Idempotent via `sentinelIngested`.+ // agent. The completion workflow writes the sentinel and stops; the 2s+ // doneSentinelTimer poll is what normally calls finish(). Reading it here+ // (not just in the poll) keeps the resolution captured even when a+ // different path (idle-complete, shell-exit) finalizes first. Idempotent+ // via `sentinelIngested`.await ingestDoneSentinel();// Drain pending parsed lines AND raw chunks before the final state@@ -665,15 +667,14 @@ export async function spawnTuiAgent({}, 5000);// Sentinel-file watcher. The agent's prompt instructs it to write- // .agent-done in the workspace after running /simplify + /do:pr. This poll- // exists only to finalize PROMPTLY when the agent signals done WITHOUT- // exiting its TUI (e.g. it forgot /quit, or stays alive) — otherwise we'd- // wait out the much longer idle timeout. The actual sentinel READ happens in- // finish() (via ingestDoneSentinel) so the resolution is captured no matter- // which path finalizes: the far more common case is the agent writing the- // sentinel and then running /quit, whose process exit fires finish() long- // before this 2s poll ticks. Idle-complete is the fallback for a- // non-complying agent.+ // .agent-done in the workspace after running /simplify + /do:pr and then+ // stop (it does NOT `/quit` — that is a UI command it can't invoke). This+ // poll is the PRIMARY finalize path: it fires finish() within DONE_POLL_+ // INTERVAL_MS of the sentinel appearing, and finish()'s own cleanup kills+ // the still-running TUI session. The actual sentinel READ happens in finish()+ // (via ingestDoneSentinel) so the resolution is captured no matter which path+ // finalizes. Idle-complete is the fallback for a non-complying agent that+ // never writes the sentinel.const doneSentinelTimer = doneSentinelPath ? setInterval(() => {try {if (finalized) return;diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.jsindex 5c506a1fcc..6e493ae938 100644--- a/server/services/agentTuiSpawning.test.js+++ b/server/services/agentTuiSpawning.test.js@@ -640,15 +640,16 @@ describe('spawnTuiAgent runtime', () => {expect(openCalls).toHaveLength(0);});- // ── 10. Completion-sentinel ingestion on the shell-exit (/quit) race ─────────- // The completion workflow has the agent write `.agent-done` and then run- // `/quit`, which exits the TUI process within milliseconds — long before the- // 2s doneSentinelTimer poll fires. The shell-exit path therefore wins the- // race and finalizes the agent. finish() MUST still ingest the sentinel so- // its markdown resolution lands in outputBuffer / output.txt and shows up in- // the completed-agent details view. Regression guard for the lost-resolution- // bug where the summary only got ingested by the (slower) poll path.- it('shell-exit after sentinel write: ingests .agent-done summary into the persisted output (process /quit beats the 2s poll)', async () => {+ // ── 10. Completion-sentinel ingestion on the shell-exit path ─────────────────+ // The completion workflow has the agent write `.agent-done` and then stop+ // (it does NOT `/quit`). Normally the 2s doneSentinelTimer poll finalizes the+ // agent, but the TUI process can also exit on its own (or be killed) before+ // the poll ticks — when that shell-exit path wins the race, finish() MUST+ // still ingest the sentinel so its markdown resolution lands in outputBuffer /+ // output.txt and shows up in the completed-agent details view. Regression+ // guard for the lost-resolution bug where the summary only got ingested by+ // the poll path.+ it('shell-exit after sentinel write: ingests .agent-done summary into the persisted output (process exit beats the 2s poll)', async () => {const { appendFile } = await import('fs/promises');const sentinel = '## Summary\nImplemented the fix.\n\n## PR\nhttps://example.com/pr/42';vi.mocked(existsSync).mockReturnValue(true);