ccnav 1.2.0 → 1.2.1

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.
package/README.md CHANGED
@@ -164,6 +164,13 @@ read that file, and a `+` after a cost means the session has changed since the l
164
164
  regional pricing, and server-tool fees other than web search. A forked session repeats its
165
165
  parent's history, so that history can be counted twice.
166
166
 
167
+ ## Troubleshooting
168
+
169
+ If a resumed session ignores the keyboard, or drops keys, set `CCNAV_DEBUG=1` before running
170
+ ccnav. Each launch appends two lines to `ccnav-debug.log` in your temp folder (`%TEMP%` on Windows,
171
+ `$TMPDIR` or `/tmp` elsewhere) recording ccnav's stdin state just before the agent starts. The
172
+ `after` line should show `destroyed=true`, meaning ccnav has stopped reading the terminal.
173
+
167
174
  ## Test
168
175
 
169
176
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccnav",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Claude Codex Navigator - pick a Claude Code or Codex session and resume it in its directory",
5
5
  "scripts": {
6
6
  "test": "node --test"
package/src/platform.mjs CHANGED
@@ -49,8 +49,37 @@ export const INSTALL_PKG = {
49
49
  };
50
50
  const hint = cmd => INSTALL_PKG[cmd] ? ` Install it: npm install -g ${INSTALL_PKG[cmd]}` : '';
51
51
 
52
+ // Before the agent takes over the terminal, ccnav must stop reading it. Ink only turns raw mode off
53
+ // and detaches its listener; the stream keeps reading, and on Windows that leaves a ReadConsole call
54
+ // pending in this process that wins keystrokes (Ctrl+C too) from the agent sharing the console.
55
+ // pause() does not stop a TTY read; closing the handle does. libuv reads through its own duplicate of
56
+ // the console handle (and never closes fd 0-2 on POSIX), so the child still inherits a working fd 0.
57
+ async function releaseStdin() {
58
+ const stdin = process.stdin;
59
+ const state = label => process.env.CCNAV_DEBUG && fs.appendFileSync(path.join(os.tmpdir(), 'ccnav-debug.log'),
60
+ `${new Date().toISOString()} ${label} isTTY=${stdin.isTTY} isRaw=${stdin.isRaw} reading=${stdin._handle?.reading}`
61
+ + ` flowing=${stdin.readableFlowing} destroyed=${stdin.destroyed} data=${stdin.listenerCount('data')}`
62
+ + ` readable=${stdin.listenerCount('readable')} keypress=${stdin.listenerCount('keypress')}\n`);
63
+ try {
64
+ state('before');
65
+ if (!stdin.isTTY || stdin.destroyed) return;
66
+ try { if (stdin.isRaw) stdin.setRawMode(false); } catch { /* already restored */ }
67
+ stdin.removeAllListeners('data');
68
+ stdin.removeAllListeners('readable');
69
+ stdin.removeAllListeners('keypress');
70
+ stdin.pause();
71
+ await new Promise(done => {
72
+ const timer = setTimeout(done, 250);
73
+ stdin.once('close', () => { clearTimeout(timer); done(); });
74
+ stdin.destroy();
75
+ });
76
+ state('after');
77
+ } catch { /* never block the launch on this */ }
78
+ }
79
+
52
80
  // Runs the agent in the foreground with the session's directory as cwd; resolves with its exit code.
53
- export function launchAgent(cmd, cwd, args) {
81
+ export async function launchAgent(cmd, cwd, args) {
82
+ await releaseStdin();
54
83
  return new Promise(resolve => {
55
84
  const legacy = IS_WIN && !has('pwsh');
56
85
  const passedArgs = legacy ? legacyWindowsArgs(cmd, args) : args;