mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* feat(ctrl-w): add ps-node + windows-process-tree + tsx deps for close-priority feature * fix(ctrl-w): drop ps-node dep and add windows-process-tree to asarUnpack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add ptyProcessTree bridge with per-platform child-process enumeration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): ptyProcessTree uses args= for full command + warns on pid overwrite - Replace `comm=` with `args=` in defaultListPosix so the full command line is captured on both macOS (BSD ps) and Linux (GNU ps), avoiding the 15-char TASK_COMM_LEN truncation. - Add console.warn in registerPid when the same sessionId is overwritten with a different pid, making the race condition visible in logs. - Add test: registerPid warns exactly once on a pid change, not on a same-pid re-registration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): register local PTY pid with ptyProcessTree on spawn/exit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): unregister pids in cleanupAllSessions to match per-delete invariant Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add IPC handlers for pty child processes and confirm-close dialog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): guard BrowserWindow.fromWebContents null and document dialog dismiss contract Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): expose ptyGetChildProcesses and confirmCloseBusy on window.netcatty Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add i18n strings for close-busy-terminal dialog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add resolveCloseIntent pure function with 8 unit tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): expose handleCloseSidePanel via ref to App.tsx Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): wire resolveCloseIntent + local-shell busy confirmation into closeTab hotkey Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ctrl-w): add re-entrancy guard, aggregate busy count, sync sidebar ref, dedupe intent branches Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): auto-close workspace when its last session is closed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): sidebar close wins over focused terminal in priority chain Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): sidebar priority applies to single-session tabs too, not just workspaces Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): compute empty-workspace auto-close outside setSessions updater Addresses Codex P2 on #739: React 18+ does not guarantee updater execution timing under concurrent scheduling. Moving the decision outside the updater makes the microtask queue deterministic. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
|
|
const { createProcessTree } = require("./ptyProcessTree.cjs");
|
|
|
|
test("getChildProcesses returns [] when session has no registered pid", async () => {
|
|
const tree = createProcessTree({ platform: "darwin", listPosix: async () => [] });
|
|
assert.deepEqual(await tree.getChildProcesses("unknown-session"), []);
|
|
});
|
|
|
|
test("getChildProcesses calls listPosix with the registered ppid and returns its result", async () => {
|
|
const calls = [];
|
|
const listPosix = async (ppid) => {
|
|
calls.push(ppid);
|
|
return [
|
|
{ pid: 2001, command: "sleep 100" },
|
|
{ pid: 2002, command: "node server.js" },
|
|
];
|
|
};
|
|
const tree = createProcessTree({ platform: "linux", listPosix });
|
|
tree.registerPid("s1", 1234);
|
|
assert.deepEqual(await tree.getChildProcesses("s1"), [
|
|
{ pid: 2001, command: "sleep 100" },
|
|
{ pid: 2002, command: "node server.js" },
|
|
]);
|
|
assert.deepEqual(calls, [1234]);
|
|
});
|
|
|
|
test("unregisterPid clears mapping", async () => {
|
|
const tree = createProcessTree({
|
|
platform: "darwin",
|
|
listPosix: async () => [{ pid: 9, command: "x" }],
|
|
});
|
|
tree.registerPid("s1", 1234);
|
|
tree.unregisterPid("s1");
|
|
assert.deepEqual(await tree.getChildProcesses("s1"), []);
|
|
});
|
|
|
|
test("getChildProcesses on windows uses listWindows", async () => {
|
|
const calls = [];
|
|
const listWindows = async (pid) => {
|
|
calls.push(pid);
|
|
return [{ pid: 55, command: "python.exe" }];
|
|
};
|
|
const tree = createProcessTree({ platform: "win32", listWindows });
|
|
tree.registerPid("s1", 3000);
|
|
assert.deepEqual(await tree.getChildProcesses("s1"), [{ pid: 55, command: "python.exe" }]);
|
|
assert.deepEqual(calls, [3000]);
|
|
});
|
|
|
|
test("getChildProcesses returns [] when listPosix missing on posix", async () => {
|
|
const tree = createProcessTree({ platform: "darwin" });
|
|
tree.registerPid("s1", 1234);
|
|
assert.deepEqual(await tree.getChildProcesses("s1"), []);
|
|
});
|
|
|
|
test("getChildProcesses returns [] when listWindows missing on windows", async () => {
|
|
const tree = createProcessTree({ platform: "win32" });
|
|
tree.registerPid("s1", 3000);
|
|
assert.deepEqual(await tree.getChildProcesses("s1"), []);
|
|
});
|
|
|
|
test("registerPid warns when overwriting an existing sessionId with a different pid", async () => {
|
|
const warnCalls = [];
|
|
const origWarn = console.warn;
|
|
console.warn = (...args) => warnCalls.push(args);
|
|
try {
|
|
const tree = createProcessTree({ platform: "darwin", listPosix: async () => [] });
|
|
tree.registerPid("s1", 1234);
|
|
tree.registerPid("s1", 1234); // same pid — no warn
|
|
tree.registerPid("s1", 5678); // different — should warn
|
|
assert.equal(warnCalls.length, 1);
|
|
assert.match(warnCalls[0][0], /s1/);
|
|
assert.match(warnCalls[0][0], /1234/);
|
|
assert.match(warnCalls[0][0], /5678/);
|
|
} finally {
|
|
console.warn = origWarn;
|
|
}
|
|
});
|