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 (codex): detect TUI child exit

Adam Eivyb8533732efb2
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index be93fffe98..53375d3f7c 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -136,13 +136,18 @@ export async function createAgentTuiSession({
return session;
}
+ // This shell exists only to host the CoS TUI. Make it follow the TUI's
+ // lifetime and preserve the TUI exit status; otherwise the login shell
+ // returns to its prompt when the provider exits and the spawner cannot
+ // observe completion until the wall-clock backstop fires.
+ const initialCommand = `${tuiConfig.commandLine}; exit $?`;
const sessionId = shellService.createShellSession(null, {
cwd,
kind: 'agent-tui',
agentId,
label: `${provider.name} ${agentId}`,
command: tuiConfig.commandLine,
- initialCommand: tuiConfig.commandLine,
+ initialCommand,
// Wait until the shell can actually RUN commands before injecting the CLI
// command — a fixed delay races a heavy interactive shell and the launched
// TUI can fall straight back to a half-loaded prompt (see shell.js
diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.js
index eb1043fd09..a1ed29b5c7 100644
--- a/server/services/agentTuiSpawning.test.js
+++ b/server/services/agentTuiSpawning.test.js
@@ -635,6 +635,16 @@ describe('spawnTuiAgent runtime', () => {
await completeDone;
});
+ it('makes the login shell exit with the TUI command instead of lingering after it exits', async () => {
+ runSpawn();
+ await flushMicrotasks();
+
+ expect(shellService.createShellSession).toHaveBeenCalledWith(
+ null,
+ expect.objectContaining({ initialCommand: 'codex; exit $?' }),
+ );
+ });
+
it('skips the owner-token probe when the provider supplies its own GITHUB_TOKEN so the explicit credential wins', async () => {
let resolveComplete;
const completeDone = new Promise((r) => { resolveComplete = r; });