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.

Merge remote-tracking branch 'origin/main' into fix/relay-guest-no-ssh-dial

reviewd2f588f091e1
diff --cc src/renderer/canvas/Canvas.tsx
index 3ac1a7776,c1cc5ad2f..926d0a530
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -3734,10 -3766,12 +3771,13 @@@ export function Canvas()
// mount-time local one (the bug). Byte-identical on a local tab (`activeSession.api` IS
// `window.nodeTerminal`). Re-keyed on the api OBJECT below, in lockstep with the publisher, so a
// tab switch tears down + re-binds both together (and a local→local switch does neither).
+ // A relay tab's mutations come from ANOTHER machine's core, which can put anything on the wire,
+ // so its `origin: 'core'` vouches for nothing here: drop it, and the node's held launch stays
- // ours (strip theirs, carry our own — @shared/node-exec).
++ // ours (strip theirs, carry our own — @shared/node-exec). Nor may a relay peer's node bring a
++ // dial-capable SSH connection onto this machine (session/relay-ssh.ts).
const relay = activeSession.source === 'relay'
- return activeSession.api.canvas.onMutation((projectId, incoming) => {
- // A relay peer's node never brings a dial-capable SSH connection onto this machine.
- const mutation = relay ? sanitizeRelayMutation(incoming) : incoming
+ return activeSession.api.canvas.onMutation((projectId, received) => {
- const mutation = relay ? withoutCoreOrigin(received) : received
++ const mutation = relay ? sanitizeRelayMutation(withoutCoreOrigin(received)) : received
hasPeersRef.current = true // proof of a peer, whatever the presence table says
if (!orderRef.current?.accept(mutation)) return
if (projectId !== useProjects.getState().activeProjectId) {
diff --cc src/renderer/session/relay-ssh.wiring.test.ts
index e4b911d57,000000000..856aefa2a
mode 100644,000000..100644
--- a/src/renderer/session/relay-ssh.wiring.test.ts
+++ b/src/renderer/session/relay-ssh.wiring.test.ts
@@@ -1,39 -1,0 +1,39 @@@
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { describe, expect, it } from 'vitest'
+
+/**
+ * SECURITY (source-level): the guest-side SSH dial sites each refuse a relay tab on their own, in
+ * addition to the adopt boundary stripping `ssh` (relay-ssh.ts). These sites close over the
+ * Electron preload and live React state, so their wiring is pinned here; the decisions themselves
+ * are behaviour-tested in sshAttachments.test.ts and relay-ssh.test.ts.
+ */
+const read = (rel: string): string =>
+ readFileSync(join(__dirname, '..', rel), 'utf8').replace(/\r\n/g, '\n')
+
+describe('relay tabs never reach a guest-side ssh dial', () => {
+ const canvas = read('canvas/Canvas.tsx')
+ const node = read('nodes/TerminalNode.tsx')
+
+ it('the active-project effect dials only what planActiveProjectDials returns', () => {
+ expect(canvas).toContain('const dials = planActiveProjectDials(project)')
+ expect(canvas).toContain('if (dials.own) {')
+ expect(canvas).toContain('for (const attachment of dials.attachments) {')
+ expect(canvas).not.toMatch(/if \(project\.ssh\) \{\n\s+const ssh = project\.ssh\n\s+\/\/ SSH remote projects are free/)
+ })
+
+ it('the reconnect coordinator refuses a relay project', () => {
+ expect(canvas).toContain('if (!project?.ssh || !projectMayDialSsh(project)) return false')
+ })
+
+ it('relay canvas-sync mutations are stripped', () => {
- expect(canvas).toContain('const mutation = relay ? sanitizeRelayMutation(incoming) : incoming')
++ expect(canvas).toContain('const mutation = relay ? sanitizeRelayMutation(withoutCoreOrigin(received)) : received')
+ })
+
+ it('a relay terminal never resolves a guest-local ControlMaster', () => {
+ expect(node).toContain("const dialsSsh = sshRemoteTmux && session.source !== 'relay'")
+ expect(node).toMatch(/dialsSsh && ssh\n\s+\? await resolveSshRemote\(/)
+ expect(node).not.toMatch(/sshRemoteTmux && ssh\n\s+\? await resolveSshRemote\(/)
+ expect(node).toContain('if (!projectMayDialSsh(useProjects.getState().getProject(activeProjectId))) return undefined')
+ })
+})