mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
feat: pair-agent auto-launches headed mode before pairing
When pair-agent detects headless mode, it auto-switches to headed (visible Chromium window) so the user can watch what the remote agent does. Use --headless to skip this. Fixed compiled binary path resolution (process.execPath, not process.argv[1] which is virtual /$bunfs/ in Bun compiled binaries). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+22
-1
@@ -922,10 +922,31 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:
|
||||
commandArgs.push(stdin.trim());
|
||||
}
|
||||
|
||||
const state = await ensureServer();
|
||||
let state = await ensureServer();
|
||||
|
||||
// ─── Pair-Agent (post-server, pre-dispatch) ──────────────
|
||||
if (command === 'pair-agent') {
|
||||
// Ensure headed mode — the user should see the browser window
|
||||
// when sharing it with another agent. Feels safer, more impressive.
|
||||
if (state.mode !== 'headed' && !hasFlag(commandArgs, '--headless')) {
|
||||
console.log('[browse] Opening GStack Browser so you can see what the remote agent does...');
|
||||
// In compiled binaries, process.argv[1] is /$bunfs/... (virtual).
|
||||
// Use process.execPath which is the real binary on disk.
|
||||
const browseBin = process.execPath;
|
||||
const connectProc = Bun.spawn([browseBin, 'connect'], {
|
||||
cwd: process.cwd(),
|
||||
stdio: ['ignore', 'inherit', 'inherit'],
|
||||
env: process.env,
|
||||
});
|
||||
await connectProc.exited;
|
||||
// Re-read state after headed mode switch
|
||||
const newState = readState();
|
||||
if (newState && await isServerHealthy(newState.port)) {
|
||||
state = newState as ServerState;
|
||||
} else {
|
||||
console.warn('[browse] Could not switch to headed mode. Continuing headless.');
|
||||
}
|
||||
}
|
||||
await handlePairAgent(state, commandArgs);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user