Skip to content

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

address review (claude): refresh stale completion-detection header + use getRunsPath in recovery script

[._.]/ Adam Eivybfb8063e2c97
diff --git a/scripts/seed-completeness-from-run.mjs b/scripts/seed-completeness-from-run.mjs
index cd36cda6d5..c43b429c5f 100644
--- a/scripts/seed-completeness-from-run.mjs
+++ b/scripts/seed-completeness-from-run.mjs
@@ -11,6 +11,7 @@ import { readFileSync } from 'fs';
import { join } from 'path';
import { collectManuscriptSections } from '../server/services/pipeline/arcPlanner.js';
import { seedReviewFromFindings, getReview } from '../server/services/pipeline/manuscriptReview.js';
+import { getRunsPath } from '../server/services/runner.js';
const [seriesId, runId] = process.argv.slice(2);
const dry = process.argv.includes('--dry');
@@ -19,7 +20,9 @@ if (!seriesId || !runId) {
process.exit(1);
}
-const responsePath = join(process.cwd(), 'data', 'runs', runId, 'tui-response.txt');
+// Resolve via the runner's own runs-path helper (honors a non-default dataDir)
+// rather than hardcoding ./data, matching where the TUI runner wrote the file.
+const responsePath = join(getRunsPath(), runId, 'tui-response.txt');
const parsed = JSON.parse(readFileSync(responsePath, 'utf8'));
const issues = Array.isArray(parsed.issues) ? parsed.issues : [];
console.log(`📥 ${issues.length} findings in ${responsePath}`);
diff --git a/server/lib/tuiPromptRunner.js b/server/lib/tuiPromptRunner.js
index 44b5de6ec6..6c57c06c2c 100644
--- a/server/lib/tuiPromptRunner.js
+++ b/server/lib/tuiPromptRunner.js
@@ -20,11 +20,16 @@
* - shellService wraps a login shell around the TUI; pasting `${cmd}\n`
* into a zsh prompt is slower and noisier than spawning the TUI directly.
*
- * Completion detection is intentionally minimal: idle-after-response, with a
- * hard timeout fallback. Per-binary input-prompt regexes were considered but
- * are fragile across versions and screen sizes; the idle threshold (~8s)
- * works universally and matches how a human knows the TUI finished — output
- * stopped scrolling.
+ * Completion detection, in priority order: the model's response-file write
+ * is the authoritative "done" signal (the wrapped prompt directs it to write
+ * its full answer to `tui-response.txt` and then finish) — checked
+ * unconditionally, even while a human watches. Output-idle is the fallback for
+ * runs that print inline instead of writing the file (paused while watched, so
+ * a viewer isn't snapped shut mid-read). The hard timeout is the backstop, and
+ * salvages an already-written file before failing. Per-binary input-prompt
+ * regexes were considered for idle but are fragile across versions and screen
+ * sizes; the idle threshold (~8s) works universally and matches how a human
+ * knows the TUI finished — output stopped scrolling.
*/
import { spawn as ptySpawn } from 'node-pty';