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: tighten three over-promising comments

Adam Eivy73b74ddc3d39
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index d5c1a9bf3f..db72b35075 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -234,8 +234,11 @@ export async function spawnTuiAgent({
// shellService surfaces node-pty output as already-decoded UTF-8 strings
// (node-pty's internal StringDecoder handles multi-byte boundaries before
// we see chunks), so queueing strings here is sufficient — no Buffer
- // bookkeeping needed. Joined once per 250ms batch, never accumulating in
- // memory beyond a single tick.
+ // bookkeeping needed. pendingRawChunks holds whatever arrives during the
+ // 250ms debounce window AND while an appendFile is in-flight (the next
+ // scheduleRawFlush is gated by rawFlushing); join() runs once per flush
+ // tick, so peak in-memory raw data is bounded by one debounce-plus-IO
+ // window of TUI output (typically hundreds of KB on a chatty agent).
const flushPendingRawChunks = async () => {
if (rawFlushTimer) { clearTimeout(rawFlushTimer); rawFlushTimer = null; }
if (pendingRawChunks.length === 0) return;
@@ -338,9 +341,10 @@ export async function spawnTuiAgent({
? null
: await readFileTail(rawFile, RAW_TAIL_ANALYSIS_BYTES);
// `??` (not `||`) so an empty raw spool ('') stays distinguishable from
- // a read failure (null) — readFileTail's contract. An intentionally
- // empty raw transcript should run failure analysis against ''; only
- // a failed read falls back to outputBuffer.
+ // a read failure (null) — readFileTail's contract. A zero-byte raw.txt
+ // (file was created but the PTY never emitted) lets failure analysis
+ // run against ''; both a missing file AND a read error return null and
+ // fall back to outputBuffer (which has the spawn-startup notices).
const errorAnalysis = finalSuccess
? null
: analyzeAgentFailure(rawAnalysisText ?? outputBuffer, task, model);
diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.js
index 29ffabee86..8dc9d449e0 100644
--- a/server/services/agentTuiSpawning.test.js
+++ b/server/services/agentTuiSpawning.test.js
@@ -73,10 +73,11 @@ vi.mock('fs/promises', () => ({
appendFile: vi.fn().mockResolvedValue(undefined),
readFile: vi.fn().mockResolvedValue(''),
rm: vi.fn().mockResolvedValue(undefined),
- // raw.txt tail-read for failure analysis. Tests don't exercise the failure
- // path's analyzer (analyzeAgentFailure is mocked to return null), so a
- // simple stub that reports an empty file is sufficient. stat returns
- // size:0 so readFileTail short-circuits to '' without touching open/read.
+ // raw.txt tail-read for failure analysis. The default stat → open/read
+ // chain reports a zero-byte file so non-tail-read tests don't accidentally
+ // exercise the read path. The two tail-read tests below override stat
+ // and open via mockResolvedValueOnce to assert the IO contract on the
+ // failure / success finalize branches.
stat: vi.fn().mockResolvedValue({ size: 0 }),
open: vi.fn().mockResolvedValue({
read: vi.fn().mockResolvedValue({ bytesRead: 0 }),