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
instruct read-only TUI agents to write the .agent-done completion sentinel
[._.]/ Adam Eivycb1fb0956069
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex ce58befb61..27e64aa77f 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -41,6 +41,8 @@## Fixed+- **Read-only CoS agents (e.g. reference-watch) on a TUI provider now signal completion via the `.agent-done` sentinel.** The prompt builder's completion decision tree gave every other task shape (reasoning-only, TUI push+PR, CLI) an explicit sentinel instruction, but the `isReadOnly` branch emitted only the bare "Read-Only Task" notice with no sentinel — so a read-only TUI run (reference-watch records its proposals directly in the tracker, then just needs to signal done) never wrote `.agent-done`. The 2s sentinel poll in `spawnTuiAgent` — the primary finalize path and the channel that ingests the run summary — therefore never fired, and the run only completed via the idle-reaper / shell-exit fallback with no clean resolution summary captured. `agentPromptBuilder.js` now routes the read-only branch through a new `buildReadOnlyCompletionSection({ isTui, sentinelPath })` that keeps the do-not-modify guidance and, for TUI agents, appends the write-`.agent-done`-then-stop instruction. CLI/API read-only agents complete on process exit and never poll a sentinel, so they still get the bare notice.+- **Digital Twin Taste questionnaire no longer shows "Question 5 of 3" after follow-ups.** The progress header used total response count (core + follow-ups) as the current question number against a core-only total, so once branching follow-ups fired the counter overran the "of N". It now reports the 1-based index among core questions for that section, so the label stays "Question 2 of 3" even when follow-ups sit between cores.- **Schedule Timeline now explains why a task sits on "Now" instead of looking like a bug.** A weekly task that has never run, or a cron task whose scheduled slot passed while it was down, is genuinely *due now* — the scheduler will fire it on the next check as a first-run or catch-up. The timeline drew that NOW launch identically to an on-cadence launch, so a marker on "Now" next to a "Sun at 07:00" / "weekly" label read as wrong (e.g. `branch-cleanup` and `reference-watch` both showing NOW). Due-now launches are now tagged server-side (`dueNow` + the scheduler's reason and any missed cron slot) and rendered distinctly: an amber marker at Now (kept on a separate visual channel from the collision warning ring so a launch that is both due-now and colliding shows both states), a `first run` / `catch-up` / `overdue` badge on the Scheduled-order chip, and tooltips/legend explaining that it launches on the next check rather than waiting for the next cadence slot. On-cadence future launches are unchanged.diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex e37e898389..d63e9e3b1b 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -457,6 +457,28 @@ export function buildProgrammaticOutputCompletionSection(sentinelPath) {].join('\n');}+/**+ * Completion block for a **read-only** task (e.g. reference-watch, pr-reviewer's+ * scan stage). The agent must NOT commit/push/modify source; its real output is+ * recorded elsewhere DURING the run (a tracker issue, PLAN.md, a report).+ *+ * A TUI agent still needs a `.agent-done` sentinel to signal completion — the 2s+ * sentinel poll in `spawnTuiAgent` is the primary finalize path and the channel+ * that ingests the run summary. Without it a read-only TUI run only finalizes via+ * the idle reaper / shell-exit fallback, so the resolution summary is never+ * captured cleanly (the bug this repairs). CLI/API read-only agents complete on+ * process exit and never poll a sentinel, so they get the bare notice only.+ */+export function buildReadOnlyCompletionSection({ isTui = false, sentinelPath = null } = {}) {+ const notice = '## Read-Only Task\nDo NOT commit, push, or modify any files. Read data and report findings only.';+ if (!isTui || !sentinelPath) return notice;+ return [+ notice,+ '',+ `When you have finished, write a short markdown summary of what you found (and where you recorded it) to \`${sentinelPath}\`, then stop. PortOS polls this sentinel every 2s, finalizes the run, and closes the session for you — do NOT run \`/quit\` and do NOT wait for anything after writing the sentinel.`+ ].join('\n');+}+/*** Build the agent prompt.*@@ -930,7 +952,10 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet// over the isTui / CLI push-and-PR completion workflows below.sections.push(buildProgrammaticOutputCompletionSection(`${worktreeInfo?.worktreePath || workspaceDir}/.agent-done`));} else if (isReadOnly) {- sections.push('## Read-Only Task\nDo NOT commit, push, or modify any files. Read data and report findings only.');+ sections.push(buildReadOnlyCompletionSection({+ isTui,+ sentinelPath: `${worktreeInfo?.worktreePath || workspaceDir}/.agent-done`,+ }));} else if (isReviewLoopFollowUp) {sections.push(buildReviewLoopFollowUpSection(task.metadata || {}, { verbose: false }));} else if (isTui) {diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 38e353b933..eb9652060f 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -372,12 +372,27 @@ describe('buildLightContextPrompt', () => {expect(prompt).not.toMatch(/gh pr merge/);});- it('suppresses the completion block and warns when readOnly is set', () => {+ it('suppresses the PR completion workflow but still writes a sentinel when readOnly + TUI', () => {const prompt = buildLightContextPrompt(makeTask({ metadata: { readOnly: true } }),'/r', null, isTruthyMeta, { isTui: true });expect(prompt).toMatch(/Read-Only Task/);expect(prompt).not.toMatch(/## Completion Workflow/);+ // A read-only TUI agent must still be told to write .agent-done — the 2s+ // sentinel poll is its only clean finalize/summary path (regression: the+ // read-only branch used to emit the bare notice with no sentinel, so+ // reference-watch runs never signaled completion).+ expect(prompt).toMatch(/\.agent-done/);+ expect(prompt).toMatch(/polls this sentinel/);+ });++ it('read-only on a non-TUI (CLI) provider gets the bare notice, no sentinel', () => {+ const prompt = buildLightContextPrompt(+ makeTask({ metadata: { readOnly: true } }),+ '/r', null, isTruthyMeta, { isTui: false, providerId: 'claude-code' });+ expect(prompt).toMatch(/Read-Only Task/);+ // CLI/API agents complete on process exit and never poll a sentinel.+ expect(prompt).not.toMatch(/\.agent-done/);});it('renders the review-loop follow-up block when reviewLoopFollowUp is set', () => {