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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
refactor(relay): delete RemoteTransport (Stage 4 Task 10)
enes18066d30faa8
diff --git a/src/renderer/terminal/remote-transport.test.ts b/src/renderer/terminal/remote-transport.test.tsdeleted file mode 100644index 63617f836..000000000--- a/src/renderer/terminal/remote-transport.test.ts+++ /dev/null@@ -1,37 +0,0 @@-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'-import { RemoteTransport } from './remote-transport'--// Minimal `window.nodeTerminal.remoteClient` fake: RemoteTransport is pure glue over it.-function fakeClient() {- return {- create: vi.fn(async () => '7'),- write: vi.fn(),- resize: vi.fn(),- kill: vi.fn(),- onData: vi.fn(() => () => {}),- onExit: vi.fn(() => () => {})- }-}--let client: ReturnType<typeof fakeClient>--beforeEach(() => {- client = fakeClient()- ;(globalThis as { window?: unknown }).window = { nodeTerminal: { remoteClient: client } }-})--afterEach(() => {- delete (globalThis as { window?: unknown }).window-})--describe('RemoteTransport.create', () => {- it('reports a warm (non-fresh) attach: a mirroring client must never replay or relaunch', async () => {- // Cold-restore (scrollback replay / agent resume) is the HOST's responsibility. Nothing is- // hydrated on a warm attach — the host's tmux redraws the pane and owns its history.- const transport = new RemoteTransport('conn-1')- await expect(transport.create({ cols: 80, rows: 24, persistKey: 'node-a' })).resolves.toEqual({- sessionId: '7',- fresh: false- })- })-})diff --git a/src/renderer/terminal/remote-transport.ts b/src/renderer/terminal/remote-transport.tsdeleted file mode 100644index 4ca56330a..000000000--- a/src/renderer/terminal/remote-transport.ts+++ /dev/null@@ -1,78 +0,0 @@-import type { PtyCreateOptions, PtyCreateResult } from '@shared/types'-import type { TerminalTransport } from './transport'--/**- * Remote transport: drives a host's PTYs over the relay by binding the IPC API exposed via- * preload (window.nodeTerminal.remoteClient) to the TerminalTransport interface — the exact- * shape of LocalTransport, but every call is scoped to a `connectionId` (a relay session- * established via remoteClient.connect()).- *- * `setFlow` and `destroy` are intentionally no-ops: flow control happens host-side (the host- * pauses/resumes its own PTYs against relay backpressure), and a remote node closing just- * detaches the client stream via `kill` — the host-side tmux session survives, exactly like- * LocalTransport's kill/destroy split, but the client never owns the lifecycle of the host's- * persistent session.- *- * The co-attach members (`onSize` / `onClosed` / `onRecycled` / `onResync`) are deliberately NOT- * implemented: the relay frame protocol carries no size, closed, recycled or resync frame, and a- * relay client is a mirror of the host's own terminal rather than an equal subscriber of the pty.- * Omitting the optional members makes TerminalNode fall back to today's behavior for relay-backed- * nodes (local FitAddon sizing, no closed overlay, no restart-on-recycle, no server-driven repaint)- * instead of silently doing nothing behind an implemented-looking method. See CLAUDE.md, "Three- * surfaces".- */-export class RemoteTransport implements TerminalTransport {- /** persistKey (host node id) -> the session (host streamId) this client attached for it. */- private readonly sessions = new Map<string, string>()-- constructor(private readonly connectionId: string) {}-- private get client() {- return window.nodeTerminal.remoteClient- }-- async create(options: PtyCreateOptions): Promise<PtyCreateResult> {- const sessionId = await this.client.create(this.connectionId, options)- if (options.persistKey) this.sessions.set(options.persistKey, sessionId)- // Cold-restore (scrollback replay / agent resume) is the host's responsibility; a mirroring- // client must never re-launch or replay, so it always reports a warm (non-fresh) attach.- return { sessionId, fresh: false }- }-- write(sessionId: string, data: string): void {- this.client.write(this.connectionId, sessionId, data)- }-- resize(sessionId: string, cols: number | null, rows: number | null): void {- // The relay frame protocol has no "not viewing" size: a mirrored client is not a subscriber of- // the host's size set, so a park signal (null) has nothing to say to it — drop it rather than- // sending a 0×0 the host would try to apply.- if (cols === null || rows === null) return- this.client.resize(this.connectionId, sessionId, cols, rows)- }-- setFlow(_sessionId: string, _resume: boolean): void {- // No-op: the host manages flow control on its own PTYs against relay backpressure.- }-- kill(sessionId: string): void {- this.client.kill(this.connectionId, sessionId)- }-- destroy(_persistKey: string): void {- // No-op: the client doesn't own the host's persistent (tmux) session lifecycle.- }-- recycle(_persistKey: string): void {- // No-op, for the same reason as `destroy` — and unreachable anyway: "move into worktree" is- // refused for a relay-backed node (Canvas.confirmMoveIntoWorktree), whose cwd lives on the host.- }-- onData(sessionId: string, listener: (data: string) => void): () => void {- return this.client.onData(this.connectionId, sessionId, listener)- }-- onExit(sessionId: string, listener: (exitCode: number) => void): () => void {- return this.client.onExit(this.connectionId, sessionId, listener)- }-}diff --git a/src/renderer/terminal/transport.ts b/src/renderer/terminal/transport.tsindex fe7745ba7..571a8ba41 100644--- a/src/renderer/terminal/transport.ts+++ b/src/renderer/terminal/transport.ts@@ -5,9 +5,10 @@ import type { ClientId } from '@shared/presence'* Abstraction over the terminal session layer.** The renderer/UI depends only on this interface; it does not know the concrete- * implementation. The MVP has a single implementation, LocalTransport (IPC over- * node-pty). A future RemoteTransport (a remote agent over WebSocket) implements- * the same interface, so remote access can be added without changing the UI.+ * implementation. There is a single implementation, LocalTransport, driven by the+ * active session's `NodeTerminalApi` (`useSession().api`): the preload for a local+ * session, or the ws-bridge over the relay tunnel for a remote tab. Remote access is+ * "swap the api object", not "swap the transport" (see docs/remote-sessions.md).*/export interface TerminalTransport {create(options: PtyCreateOptions): Promise<PtyCreateResult>@@ -44,9 +45,8 @@ export interface TerminalTransport {* The authoritative size of a co-attached session: min(cols) × min(rows) over all subscribers* ("smallest subscriber wins"). The terminal must render at this size (letterboxing the slack)* instead of its own FitAddon result, or the two viewers' screens diverge.- * OPTIONAL: a transport that cannot negotiate a shared size (RemoteTransport over the relay,- * whose frame protocol has no size frame) simply omits it, and the terminal falls back to- * driving its own FitAddon — today's behavior. Returns an unsubscribe function.+ * OPTIONAL: a transport that cannot negotiate a shared size simply omits it, and the terminal+ * falls back to driving its own FitAddon. Returns an unsubscribe function.*/onSize?(sessionId: string, listener: (size: { cols: number; rows: number }) => void): () => void/**