Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

test(main): lock peer-registry boot wiring against regression (4b Task 5)

enes372ab75ea27a
diff --git a/src/main/index.ts b/src/main/index.ts
index 330f1ec37..dc0608a84 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -112,6 +112,8 @@ const ptyManager = new PtyManager()
// `onPeerGone` → `dropClient`, and nothing else tells the pty layer that subscriber is gone (a
// vanished peer sends no `pty:kill`) — the pause it owed would freeze the shared terminal for every
// viewer. Inert with zero peers: the registry holds no sink, so none of this ever runs.
+// Wired once here — do not double-wire (4b Task 4). A second wirePeerRegistry() call would silently
+// overwrite these deps (last write wins), so keep this the sole call site in src/main.
wirePeerRegistry({
setFlow: (id, sid, resume, owner) => ptyManager.setFlow(id, sid, resume, owner),
captureForResync: (sid) => ptyManager.captureForResync(sid),
diff --git a/src/main/peer-registry.test.ts b/src/main/peer-registry.test.ts
index 2f6e6f7e1..8958f9cde 100644
--- a/src/main/peer-registry.test.ts
+++ b/src/main/peer-registry.test.ts
@@ -176,6 +176,9 @@ describe('peer sink registry', () => {
unregisterPeerSink(id)
+ // The wired gone-hook actually reached PtyManager: onPeerGone → dropClient(id) ran, so the pty
+ // layer heard this subscriber leave. Without it the pause below would leak forever.
+ expect(gone).toEqual([id])
// The pause is returned by PtyManager.dropClient (the onPeerGone hook), never re-asserted or
// re-resumed here; the sweep that would have done it is gone with its last client.
expect(vi.getTimerCount()).toBe(0)