fix: pair-agent server dies 15s after CLI exits

The server monitors BROWSE_PARENT_PID and self-terminates when the
parent exits. For pair-agent, the connect subprocess is the parent,
so the server dies 15s after connect finishes. Disable parent-PID
monitoring for pair-agent sessions so the server outlives the CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-06 16:23:10 -07:00
parent ad47077040
commit 05d1a50e70
+8 -1
View File
@@ -839,6 +839,11 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:
BROWSE_PORT: '34567',
BROWSE_SIDEBAR_CHAT: '1',
};
// If parent explicitly set BROWSE_PARENT_PID=0 (pair-agent disabling
// self-termination), pass it through so startServer doesn't override it.
if (process.env.BROWSE_PARENT_PID === '0') {
serverEnv.BROWSE_PARENT_PID = '0';
}
const newState = await startServer(serverEnv);
// Print connected status
@@ -975,7 +980,9 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:
const connectProc = Bun.spawn([browseBin, 'connect'], {
cwd: process.cwd(),
stdio: ['ignore', 'inherit', 'inherit'],
env: process.env,
// Disable parent-PID monitoring: pair-agent needs the server to outlive
// the connect subprocess. Setting to 0 tells the server not to self-terminate.
env: { ...process.env, BROWSE_PARENT_PID: '0' },
});
await connectProc.exited;
// Re-read state after headed mode switch