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.

feat(main): wire the peer registry to PtyManager at boot

enesffaff1e8974f
diff --git a/src/main/index.ts b/src/main/index.ts
index fb4206c09..330f1ec37 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -76,6 +76,7 @@ import {
} from './media-protocol'
import { initPlatform } from '../core/platform'
import { electronPlatform } from './platform-electron'
+import { wirePeerRegistry } from './peer-registry'
// Dev-only: NT_MULTI lets a SECOND instance run (host + client testing on one machine) with an
// isolated userData via NT_USER_DATA — its own device-id/session/license/workspace. Never active
@@ -104,6 +105,19 @@ function isSafeExternalUrl(url: unknown): url is string {
const settingsStore = new SettingsStore()
const sshStore = new SshStore()
const ptyManager = new PtyManager()
+
+// Relay PEER sinks (docs/remote-sessions.md 4b) — the desktop mirror of src/server/index.ts's
+// setFlowController / setResyncProvider / onClientGone. Wired at boot, BEFORE any peer can register
+// (4c), because a peer that leaves must hand its pty subscriptions back: `unregisterPeerSink` calls
+// `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.
+wirePeerRegistry({
+ setFlow: (id, sid, resume, owner) => ptyManager.setFlow(id, sid, resume, owner),
+ captureForResync: (sid) => ptyManager.captureForResync(sid),
+ onPeerGone: (id) => ptyManager.dropClient(id)
+})
+
// Set once the app window is ready; used by the quit hooks to tear down SSH-project masters and
// (via the closures below) to resolve a live SSH project's ControlMaster for remote workspace IO.
let sshProjectManager: ReturnType<typeof initSshProject> | undefined