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(relay): exclude remote (relay) projects from persistence (project-scope Task 5)

enes5d543263c277
diff --git a/src/core/workspace-files.test.ts b/src/core/workspace-files.test.ts
index 034d72ce0..4767d9253 100644
--- a/src/core/workspace-files.test.ts
+++ b/src/core/workspace-files.test.ts
@@ -108,6 +108,21 @@ describe('splitWorkspace', () => {
() => 1, '2026-07-11T00:00:00.000Z')
expect(index.entries[0].project!.unavailable).toBeUndefined()
})
+ it('never persists a remote (relay) project — no ref, no inline, no cache, in any branch', () => {
+ const ws2: Workspace = {
+ version: 2, activeProjectId: 'keep',
+ projects: [
+ project({ id: 'keep', name: 'normal', cwd: '/a/foo' }),
+ project({ id: 'r1', name: 'relay-cwdless', remote: true }),
+ project({ id: 'r2', name: 'relay-cwd', cwd: '/a/bar', remote: true }),
+ project({ id: 'r3', name: 'relay-ssh', ssh: { server: { host: 'h', user: 'u' } as any, remoteCwd: '~/app' }, remote: true })
+ ]
+ }
+ const { index, files } = splitWorkspace(ws2, () => 1, '2026-07-11T00:00:00.000Z')
+ // Only the normal project is emitted; every relay project is absent entirely.
+ expect(index.entries.map((e) => e.id)).toEqual(['keep'])
+ expect(files.has('/a/bar')).toBe(false) // relay cwd never written as a file
+ })
it('an unavailable ref is header-only: no file (local cwd) and no cache (ssh)', () => {
const local = splitWorkspace(
{ version: 2, activeProjectId: 'p1', projects: [project({ id: 'p1', cwd: '/a/foo', unavailable: true })] },
diff --git a/src/core/workspace-files.ts b/src/core/workspace-files.ts
index c220fadf9..68af08aae 100644
--- a/src/core/workspace-files.ts
+++ b/src/core/workspace-files.ts
@@ -161,6 +161,10 @@ export function splitWorkspace(
const entries: IndexEntryV3[] = []
const files = new Map<string, ProjectFileV1>()
for (const p of ws.projects) {
+ // A relay tab is a LIVE connection to another machine's project, not a workspace on this
+ // disk — it has no disk representation at all. Drop it entirely (no ref, no inline, no
+ // cache) BEFORE the unavailable handling, so it leaks in none of the branches below.
+ if (p.remote) continue
const header = { id: p.id, name: p.name, color: p.color, ...(p.closed ? { closed: true } : {}) }
if (p.unavailable) {
// Placeholder (folder missing / server unreachable at load): its nodes:[] is not real
diff --git a/src/renderer/state/projects.test.ts b/src/renderer/state/projects.test.ts
index 9b80c1075..f74dd54da 100644
--- a/src/renderer/state/projects.test.ts
+++ b/src/renderer/state/projects.test.ts
@@ -56,6 +56,19 @@ describe('toWorkspace', () => {
const json = JSON.stringify(ws)
expect(json).not.toMatch(/"session/i)
})
+
+ // A relay tab is a LIVE connection to another machine's project, not a workspace on this
+ // disk. `project.remote` is runtime-only; toWorkspace must drop the whole project so it can
+ // never be written into this client's workspace.json.
+ it('excludes remote (relay) projects but keeps normal ones', () => {
+ const normal = useProjects.getState().addProject('my-app', '/Users/me/dev/my-app')
+ const relay = useProjects.getState().addProject('shared')
+ useProjects.setState((s) => ({
+ projects: s.projects.map((p) => (p.id === relay.id ? { ...p, remote: true } : p))
+ }))
+ const ws = useProjects.getState().toWorkspace()
+ expect(ws.projects.map((p) => p.id)).toEqual([normal.id])
+ })
})
describe('setDinoHighScore', () => {
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index 8faa533b5..2bc03c4ad 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -345,6 +345,9 @@ export const useProjects = create<ProjectsState>((set, get) => ({
toWorkspace() {
const { projects, activeProjectId } = get()
- return { version: 2, activeProjectId, projects }
+ // A relay tab (`remote`) is a live connection to another machine's project, never a
+ // workspace on this disk — exclude it so it can't be written into this client's
+ // workspace.json (the disk writer skips it too; see core/workspace-files.ts).
+ return { version: 2, activeProjectId, projects: projects.filter((p) => !p.remote) }
}
}))
diff --git a/src/shared/types.ts b/src/shared/types.ts
index c39b5125f..5f5e3761c 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -223,6 +223,14 @@ export interface Project {
* Unavailable projects show a greyed tab and cannot be activated.
*/
unavailable?: boolean
+ /**
+ * This tab is a LIVE relay connection to another machine's project — not a workspace on
+ * THIS disk. Runtime-only, never persisted: set by `openRelayTab` (see relay-tab.ts) and
+ * excluded from both `toWorkspace()` and the on-disk index (see the `splitWorkspace` skip in
+ * core/workspace-files.ts). A relay tab is a connection bookmark, never a workspace on the
+ * peer's disk, so it must never land in this client's workspace.json.
+ */
+ remote?: boolean
}
/** The full workspace written to / read from disk. */