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.
Plan: project-scoped relay sharing
Branch: feat/relay-project-scope (worktree /root/nodeterm-projscope, off main @ 88da9e6)
Problem
A relay tab connects but shows an empty canvas. openRelayTab creates an empty
addProject(label), and canvas-sync.ts is "a pipe, not a store" — it relays future
mutations but never sends the peer the host's existing nodes. So B sees nothing.
Decision (user)
A picks ONE project to share when it starts hosting; B sees only that project, populated with A's actual nodes, kept live by the existing Stage-3 mutation sync. Not a security boundary (full trust — B already has shell access), but the intended UX: "I'm opening this project to you."
Architecture (why each piece lands where it does)
- The scope lives on the host relay session, not in the offer. The offer/pairing code is
unchanged — no project name leaks into a code that may be pasted around, and the pairing token
stays single-purpose.
relayHost.start(projectId)threads the id toconnectRelayHost, held assharedProjectIdon the session. - Scoped serve happens at the relay boundary (
relay-host.tsdispatch), NOT in the core. The peer'sworkspace:loadreq hits the genericplatform.dispatch(→ theworkspace:loadhandler atworkspace-store.ts:65, unchanged). We intercept the response for that one method whensharedProjectIdis set and filterprojectsto just the shared one. The core stays generic; the "this peer sees one project" policy lives exactly where the peer boundary is. - The client populates the tab from the host's workspace. After approval,
openRelayTabcallsapi.workspace.load()(bridged → host, already scoped to the one project) and creates the tab bound to the relay session with the host's nodes (viaadoptProject— fresh project id, node ids kept). Stage-3 sync then keeps it live. - The client never persists a relay tab. A runtime-only
project.remoteflag (mirroring howunavailableis stripped inworkspace-files.ts) excludes the whole entry fromtoWorkspace(). This also closes the T10 regression note: relay canvases must not land in B'sworkspace.json. (The per-nodedata.remotewas deleted in T10; this is the correct project-level replacement.)
Sharing is fixed for the hosting session (change project = stop + restart hosting). v1 scope.
Tasks (subagent-driven, TDD, review each)
Task 1 — Host: thread sharedProjectId through start → session
src/shared/ipc.ts/ preloadrelayHost.start:start(projectId?: string)→ send it withrelay:host:start.relay-host-service.tsinitRelayHost: therelay:host:starthandler takesprojectId, passes it toconnect({ ..., sharedProjectId: projectId }).relay-host.tsConnectRelayHostOptions: addsharedProjectId?: string; hold it on the session (exposesharedProjectId()or keep in closure for Task 2).- Test:
relay-host-service.test.ts—start('proj-1')passessharedProjectId:'proj-1'to the injectedconnect. Preload/ipc are typecheck-only.
Task 2 — Host: scope the workspace:load response to the shared project
relay-host.tsdispatch (~:205): whenm.method === IPC.workspaceLoadANDsharedProjectIdis set, afterplatform.dispatchresolves, transformres.result(aWorkspace) → keep only the project whoseid === sharedProjectId, setactiveProjectIdto it; if it's gone, empty list. All other methods pass through untouched. Extract the filter as a pure helper (scopeWorkspaceToProject(ws, projectId)insrc/shared/) so it's unit-testable.- Test: pure helper — full workspace → one project, activeProjectId set, missing id → empty.
- Test:
relay-host.test.ts— aworkspace:loadreq over a session withsharedProjectIdreturns only that project; agit:statusreq is unaffected; nosharedProjectId→ full workspace. - Security note for review: this is UX scope, not a trust boundary. Confirm it does not widen
anything (a peer still can't reach a method it couldn't before) and that a peer with no
sharedProjectIdbehaves exactly as today.
Task 3 — Host UI: pick the project when starting to host
RemoteAccessDialog.tsx+RemoteSection.tsx: beforerelayHost.start(), choose which project to share — default the active project; a small select of open (non-closed) projects. Pass its id tostart(projectId). Label the offer/host state with the project name.- Reads projects from
useProjects. Keep the copy honest: "Sharing — the joiner will see this project and can run commands on this Mac." - Test: a pure view-model if one falls out (e.g.
hostShareOptions(projects) → {id,name}[]default active first); else typecheck + the existing dialog tests stay green.
Task 4 — Client: populate the relay tab from the host workspace
relay-tab.tsopenRelayTab: afterraceApproval,const ws = await handle.api.workspace.load()→ takews.projects[0](the scoped single project; guard empty → fall back to an empty tab with the label). Create the tab via a new depadoptProject(project)(→useProjects.adoptProject, fresh id, keeps node ids) instead ofaddProject(label); mark itremote:true(Task 5). Bind the relay session to the adopted project's id; set active.- The Canvas active-project effect already loads
project.nodesinto React Flow, and Task-6'sSessionProvider key={session.id}already routes those nodes' transport to the relay api — so the adopted nodes' terminals co-attach to the host. Verify no extra wiring needed. - Test:
relay-tab.test.ts—openRelayTabwith a fake api whoseworkspace.load()returns a one-project workspace callsadoptProjectwith that project (nodes intact) and binds the session to it; empty workspace → falls back to a labelled empty tab (no throw).
Task 5 — Client: never persist a relay tab
src/shared/types.tsProject: add runtime-onlyremote?: boolean(doc it likeunavailable).workspace-files.ts: strip/skip aremoteproject entirely from the fanned-out index (it is a live connection, not a workspace on this disk) — mirror theunavailablehandling, but SKIP the whole entry rather than inline it.projects.tstoWorkspace: excluderemoteprojects (and confirm the tripwire test still holds — no runtime field is serialized).- Test:
projects.test.ts— aremote:trueproject is absent fromtoWorkspace(); a normal one survives.workspace-filestest — aremoteentry produces no index ref / inline entry.
Task 6 — Gate + docs
npm run typecheck+ fullnpx vitest rungreen.docs/remote-sessions.md: flip the "relay-tab canvas population" follow-up to landed; document project-scoped sharing (host picks one project, held on the session, scoped serve at the relay boundary, client adopts + never persists). Note the fixed-per-session limitation.- Two-instance manual check appended: A shares project X → B sees X's nodes, edits sync both ways, B's other-project access is not offered.
Merge gate
Crypto/carrier gate unchanged (this adds no crypto); full suite green; whole-diff review with a security pass on Task 2 (scope doesn't widen access); then merge to main.