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.

fix(renderer): ask the SESSION whether a node's core is remote, not the node

enes5958e8643882
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 79cff103e..cb628ee23 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -62,6 +62,7 @@ import { loseWebglContexts, registerWebglClient, type WebglClientHandle } from '
import { PARK_MAX, planParkEviction } from '../terminal/park-budget'
import {
mayDisposeOffscreen,
+ offscreenCoreIsRemote,
offscreenDisposeMs,
planOffscreenVisibility
} from '../terminal/offscreen-policy'
@@ -959,20 +960,26 @@ export function TerminalNode({
// The affordance is absent, not merely refused on click.
const sshProject = useProjects((s) => !!s.projects.find((p) => p.id === s.activeProjectId)?.ssh)
const remoteSession = sshProject || isRemoteSessionNode(data)
- // "Does this node's session live on another machine?" for the offscreen-dispose gate. It starts
- // from the SAME question the ↪ affordance asks and then adds `data.remote` — a RELAY tab's
- // terminals, whose session lives on the host at the other end of the relay tunnel. Both are
- // excluded in v1 (offscreen-policy.ts): a revive re-runs the spawn path, and doing that while
- // the ControlMaster or the relay link happens to be down surfaces the offline overlay / a spawn
- // error on a node the user never touched.
+ // "Does this node's session live on another machine?" for the offscreen-dispose gate — asked in
+ // TWO halves, because the two ways of being remote are independent facts:
+ // 1. the PROJECT is an SSH project / this node is an SSH-project terminal (`remoteSession`, the
+ // same question the ↪ affordance asks), and
+ // 2. the SESSION's core is elsewhere (`offscreenCoreIsRemote`): a RELAY tab's terminals run on
+ // the paired desktop, a remote-server tab's on that server. Nothing on the node's `data` says
+ // so — that is a property of the tab it renders under — which is why this half must be asked
+ // of `session.source` and not of a node field. (The Server Edition's own browser session is
+ // `'local'`: its core is the server it is served from, up whenever the UI is, so those nodes
+ // stay eligible — the whole point of the feature on that surface.)
+ // Both are excluded in v1 (offscreen-policy.ts): a revive re-runs the spawn path, and doing that
+ // while the ControlMaster or the relay link happens to be down surfaces the offline overlay / a
+ // spawn error on a node the user never touched.
//
// `isRemoteSessionNode` is deliberately NOT widened for this: it is the worktree gate, and
- // worktrees exclude relay nodes on purpose (a relay node's repo is the host's, and that gate
- // asks a different question). The union belongs here, at the one call site that means it.
- // A ref because a project can BECOME an SSH project (or a tab a relay tab) long after the
- // lifecycle run that would otherwise have captured the answer.
+ // worktrees exclude relay nodes on purpose (that gate asks a different question). The union
+ // belongs here, at the one call site that means it. A ref because a project can BECOME an SSH
+ // project long after the lifecycle run that would otherwise have captured the answer.
const offscreenRemoteRef = useRef(false)
- offscreenRemoteRef.current = remoteSession || !!data.remote
+ offscreenRemoteRef.current = remoteSession || offscreenCoreIsRemote(session.source)
const canMoveIntoWorktree =
!!parentWtPath &&
!parentWtStale &&
diff --git a/src/renderer/terminal/offscreen-policy.test.ts b/src/renderer/terminal/offscreen-policy.test.ts
index eaf72af44..06604327f 100644
--- a/src/renderer/terminal/offscreen-policy.test.ts
+++ b/src/renderer/terminal/offscreen-policy.test.ts
@@ -3,6 +3,7 @@ import {
OFFSCREEN_DISPOSE_MS_DEFAULT,
offscreenDisposeMs,
mayDisposeOffscreen,
+ offscreenCoreIsRemote,
planOffscreenVisibility
} from './offscreen-policy'
@@ -21,6 +22,17 @@ describe('offscreen dispose policy', () => {
expect(mayDisposeOffscreen({ visible: false, remote: true, selected: false })).toBe(false)
expect(mayDisposeOffscreen({ visible: false, remote: false, selected: true })).toBe(false)
})
+ // The second link in "a relay-sourced node never disposes": this predicate answers `true`, and
+ // the row above proves `remote: true` refuses. Pinned as a test rather than as a comment because
+ // the first attempt at this gate read a node field (`data.remote`) that is only ever set on a
+ // PROJECT — a constant `false` that no type could catch and no test then covered.
+ it('a session whose core is on another machine is remote; both local surfaces are not', () => {
+ expect(offscreenCoreIsRemote('relay')).toBe(true)
+ expect(offscreenCoreIsRemote('server')).toBe(true)
+ // Electron's own session AND the Server Edition's browser session: the core is at the other end
+ // of a preload / a same-machine socket, up whenever the UI is.
+ expect(offscreenCoreIsRemote('local')).toBe(false)
+ })
})
describe('planOffscreenVisibility', () => {
diff --git a/src/renderer/terminal/offscreen-policy.ts b/src/renderer/terminal/offscreen-policy.ts
index 246ff3e2c..36da363ad 100644
--- a/src/renderer/terminal/offscreen-policy.ts
+++ b/src/renderer/terminal/offscreen-policy.ts
@@ -9,8 +9,25 @@
* machinery and a re-spawn while the ControlMaster is down would surface the offline overlay for
* a node the user never touched. Follow-up once demand exists.
*/
+import type { SessionSource } from '../session/session'
+
export const OFFSCREEN_DISPOSE_MS_DEFAULT = 10 * 60_000
+/**
+ * Does this node's CORE live on another machine? That — not the node's own fields — is what decides
+ * whether a revive would run a spawn across a link that can be down.
+ *
+ * Asked of the session the node renders under, because that is where the answer actually is: a
+ * relay tab's terminals run on the paired desktop, a remote-server tab's on that server, and
+ * neither node carries a field saying so (`data.ssh`/`data.sshRemoteTmux` describe an SSH PROJECT,
+ * which is a different thing and is asked separately). `'local'` covers the Electron app AND the
+ * Server Edition's own browser session — the core is at the other end of a preload or a
+ * same-machine websocket, always up when the UI is, so those stay eligible.
+ */
+export function offscreenCoreIsRemote(source: SessionSource): boolean {
+ return source !== 'local'
+}
+
/** Setting is in minutes; 0 or negative = feature off; undefined = default. */
export function offscreenDisposeMs(settingMinutes: number | undefined): number | null {
if (settingMinutes === undefined) return OFFSCREEN_DISPOSE_MS_DEFAULT