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: preserve explicit TUI cancellation without an exit signal
[._.]/ Adam Eivye3fd91e638ed
diff --git a/server/services/tuiPromptRunner.js b/server/services/tuiPromptRunner.jsindex c765f983c8..d63e79fab4 100644--- a/server/services/tuiPromptRunner.js+++ b/server/services/tuiPromptRunner.js@@ -707,9 +707,12 @@ ${prompt}`;// for a bogus quota marker, bench the provider, or launch a fallback.const stopRequested = consumeRunStopRequested(runId);const hostInterrupted = killed && isHostShuttingDown();- const canceled = killed && (stopRequested || hostInterrupted);+ // A CLI can handle SIGTERM and exit through its shell with code 143+ // (or cleanly), leaving node-pty's signal at 0. The explicit stop marker+ // is authoritative regardless of how that process reports its exit.+ const canceled = stopRequested || hostInterrupted;const finalExitCode = typeof exitCode === 'number' ? exitCode : (killed ? 130 : 0);- const success = !killed && finalExitCode === 0;+ const success = !canceled && !killed && finalExitCode === 0;// The terminal-timeout detector holds a candidate banner until a real line// terminator proves the line is finished (#3715). Process exit IS that// proof — no further byte can turn `⎿ Request timed out` into a@@ -734,7 +737,7 @@ ${prompt}`;if (hostInterrupted) {error = `TUI interrupted by PortOS shutdown (signal ${signal})`;} else if (stopRequested) {- error = `TUI canceled (signal ${signal})`;+ error = killed ? `TUI canceled (signal ${signal})` : `TUI canceled (exit code ${finalExitCode})`;} else if (killed) {error = `TUI killed (signal ${signal})`;} else if (!success) {diff --git a/server/services/tuiPromptRunner.test.js b/server/services/tuiPromptRunner.test.jsindex cc8947b824..f548a8f1ca 100644--- a/server/services/tuiPromptRunner.test.js+++ b/server/services/tuiPromptRunner.test.js@@ -1551,14 +1551,18 @@ describe('executeTuiRun', () => {}));});- it('finalizes an explicit stop as canceled instead of a provider failure', async () => {+ it.each([+ { exitCode: null, signal: 'SIGTERM' },+ { exitCode: 143, signal: 0 },+ { exitCode: 0, signal: 0 },+ ])('finalizes an explicit stop as canceled for PTY exit %j', async (exit) => {const provider = { id: 'claude', type: 'tui', command: 'echo' };const onComplete = vi.fn();runnerMocks.consumeRunStopRequested.mockReturnValueOnce(true);const promise = executeTuiRun({ runId: 'run-stopped', provider, prompt: 'a prompt long enough', workspacePath: TEST_WORKSPACE, onComplete, timeout: 60000 });await flushAsync();- ptyInstances[0].emitExit({ exitCode: null, signal: 'SIGTERM' });+ ptyInstances[0].emitExit(exit);await promise;expect(runnerMocks.finalizeRunRecord).toHaveBeenCalledWith(expect.objectContaining({