claude-code-remote-pilot 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -120,11 +120,6 @@ function renderTable(sessions) {
120
120
  // ─── watch mode ───────────────────────────────────────────────────────────────
121
121
 
122
122
  function startWatch(manager, rl) {
123
- rl.removeAllListeners('close');
124
- rl.close();
125
- if (process.stdin.isTTY) process.stdin.setRawMode(true);
126
- process.stdin.resume();
127
-
128
123
  function draw() {
129
124
  process.stdout.write('\x1B[2J\x1B[0f');
130
125
  process.stdout.write(renderTable(manager.list()));
@@ -133,18 +128,40 @@ function startWatch(manager, rl) {
133
128
  draw();
134
129
  const interval = setInterval(draw, 2000);
135
130
 
136
- function onData(buf) {
137
- const key = buf.toString();
138
- if (key === 'q' || key === 'Q' || buf[0] === 3) {
139
- clearInterval(interval);
140
- process.stdin.removeListener('data', onData);
141
- if (process.stdin.isTTY) process.stdin.setRawMode(false);
142
- process.stdout.write('\x1B[2J\x1B[0f');
143
- startREPL(manager);
131
+ function exit() {
132
+ process.stdin.removeListener('keypress', onKeypress);
133
+ clearInterval(interval);
134
+ process.stdout.write('\x1B[2J\x1B[0f');
135
+ // Clear any character readline buffered while we were in watch mode
136
+ rl.write(null, { ctrl: true, name: 'u' });
137
+ rl.prompt();
138
+ }
139
+
140
+ function onKeypress(str, key) {
141
+ if (str === 'q' || str === 'Q' || (key && key.ctrl && key.name === 'c')) {
142
+ exit();
144
143
  }
145
144
  }
146
145
 
147
- process.stdin.on('data', onData);
146
+ process.stdin.on('keypress', onKeypress);
147
+ }
148
+
149
+ // ─── exit handling ───────────────────────────────────────────────────────────
150
+
151
+ async function handleExit(manager, rl) {
152
+ const sessions = manager.list();
153
+ if (!sessions.length) {
154
+ console.log('');
155
+ process.exit(0);
156
+ }
157
+ const answer = await questionRaw(rl, `\n Kill all ${sessions.length} session(s) before exiting? (y/n) `);
158
+ if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
159
+ manager.killAll();
160
+ console.log(' All sessions killed.\n');
161
+ } else {
162
+ console.log(' Sessions keep running. Use tmux to attach.\n');
163
+ }
164
+ process.exit(0);
148
165
  }
149
166
 
150
167
  // ─── REPL ─────────────────────────────────────────────────────────────────────
@@ -156,7 +173,7 @@ const HELP = `
156
173
  attach <name> Open tmux session in this terminal
157
174
  kill <name> Stop a session
158
175
  help Show this help
159
- exit Quit pilot (sessions keep running in tmux)
176
+ exit Quit pilot (asks whether to kill sessions)
160
177
  `;
161
178
 
162
179
  function startREPL(manager) {
@@ -219,8 +236,8 @@ function startREPL(manager) {
219
236
  }
220
237
  case 'exit':
221
238
  case 'quit': {
222
- console.log('\n Sessions keep running. Use tmux to attach.\n');
223
- process.exit(0);
239
+ await handleExit(manager, rl);
240
+ return;
224
241
  }
225
242
  default:
226
243
  console.log(` Unknown command: ${cmd}. Type help.`);
@@ -233,6 +250,7 @@ function startREPL(manager) {
233
250
  });
234
251
 
235
252
  rl.on('close', () => {
253
+ // stdin closed (Ctrl+D) — can't ask interactively, keep sessions running
236
254
  console.log('\n Sessions keep running. Use tmux to attach.\n');
237
255
  process.exit(0);
238
256
  });
@@ -51,6 +51,12 @@ class SessionManager {
51
51
  this.sessions.delete(name);
52
52
  }
53
53
 
54
+ killAll() {
55
+ for (const name of [...this.sessions.keys()]) {
56
+ try { this.kill(name); } catch {}
57
+ }
58
+ }
59
+
54
60
  list() {
55
61
  return [...this.sessions.values()].map(e => e.session);
56
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-remote-pilot",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Interactive Claude Code supervisor — spawn and monitor multiple Claude sessions from a single terminal.",
5
5
  "type": "commonjs",
6
6
  "bin": {