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): count a TUI's in-flight chrome as a started turn

[._.]/ Adam Eivy0a7114849398
diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.js
index 3a1224ae42..65e7de8abb 100644
--- a/server/lib/tuiHandshake.js
+++ b/server/lib/tuiHandshake.js
@@ -1860,9 +1860,11 @@ export function createStallNudgeGate({
// paste chip still the last thing painted, means the turn never started.
export const UNSUBMITTED_PROMPT_SETTLE_MS = 20000;
export const UNSUBMITTED_PROMPT_ENTER_MAX_ATTEMPTS = 3;
-// Output arriving this long after PortOS's own last keystroke cannot be the
-// echo of that keystroke, so it is a turn running. The same 30s that proves a
-// stall nudge took.
+// Evidence the turn started: the TUI's own in-flight chrome (a working counter,
+// `Generating…` — createGenerationActivityTracker) at any time, or any output
+// arriving this long after PortOS's last keystroke, which cannot be its echo.
+// The same 30s that proves a stall nudge took. The silence fallback covers a TUI
+// that paints no such chrome (OpenCode).
export const PROMPT_WORK_EVIDENCE_MS = STALL_NUDGE_RECOVERY_MS;
const UNSUBMITTED_PROMPT_TAIL_CAP = 4096;
// A selector or confirmation painted after the chip owns the Enter key; a bare
@@ -1879,8 +1881,8 @@ const SELECTOR_AFTER_PASTE_PATTERN = /enter\s*to\s*(?:select|confirm)|↑\s*\/\s
* - `observe(strippedText, nowMs)` — every ANSI-stripped chunk.
* - `takeEnter(nowMs, lastOutputAtMs)` — the 1-based bare-Enter number when one
* is due, else 0.
- * - `worked` — whether the run ever produced output that was not the echo of a
- * PortOS keystroke. A run whose stall-nudge budget runs out with this still
+ * - `worked` — whether the run ever painted in-flight chrome or produced output
+ * that was not the echo of a PortOS keystroke. A run whose stall-nudge budget runs out with this still
* false never started, and the caller fails it rather than parking it.
*
* @param {{ promptMarkerCount?: number, settleMs?: number, maxAttempts?: number, workEvidenceMs?: number }} [options]
@@ -1895,6 +1897,7 @@ export function createPromptSubmissionGate({
let worked = false;
let tail = '';
let enters = 0;
+ const generation = createGenerationActivityTracker();
const holdsUnsubmittedPaste = () => {
if (!isPasteCommitted(tail, { promptMarkerCount })) return false;
let lastMarkerEnd = -1;
@@ -1908,7 +1911,7 @@ export function createPromptSubmissionGate({
},
observe(strippedText, nowMs) {
if (worked || inputAt === null || !strippedText) return;
- if (nowMs - inputAt >= workEvidenceMs) {
+ if (generation.observe(strippedText) || nowMs - inputAt >= workEvidenceMs) {
worked = true;
tail = '';
return;
diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.js
index 5f21342553..ef598f17eb 100644
--- a/server/lib/tuiHandshake.test.js
+++ b/server/lib/tuiHandshake.test.js
@@ -2133,10 +2133,18 @@ describe('createPromptSubmissionGate', () => {
gate.noteInput(0, CHIP);
gate.observe('echo of our own keystroke', 29_000);
expect(gate.worked).toBe(false);
- gate.observe('• Working (31s • esc to interrupt)', 31_000);
+ gate.observe('Reading the repository…', 31_000);
expect(gate.worked).toBe(true);
expect(settled(gate, 31_000)).toBe(0);
});
+
+ it('treats in-flight chrome as a started turn, however soon it went quiet', () => {
+ const gate = createPromptSubmissionGate({ settleMs: 20_000, workEvidenceMs: 30_000 });
+ gate.noteInput(0, CHIP);
+ gate.observe('✻ Thinking… (4s · ↑ 1.2k tokens · esc to interrupt)', 4_000);
+ expect(gate.worked).toBe(true);
+ expect(settled(gate, 4_000)).toBe(0);
+ });
});
describe('createStallNudgeGate', () => {