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
fix(hosted-team): a reconnect prompt never rebinds a tab to another team (M8)
review87e17f0fea24
diff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.mdindex 09dbaac25..c69558aa8 100644--- a/docs/hosted-team-relay.md+++ b/docs/hosted-team-relay.md@@ -272,6 +272,9 @@ joining answers `E_JOIN_BUSY`.streak. Nothing else retries, and a pasted code never retries: it is told once.- Closing or deleting the tab cancels its team's attempt in any phase. At most one attempt and onelive connection exist per team.+- A code pasted into a greyed tab's prompt must be for that tab's team. A code for another team is+ refused there ("That invite code is for Y, not X. To join Y, paste the code in New Remote+ Connection."), so one team is never mounted inside another team's tab.- **Forget hosted team: <name>** in the palette removes the bookmark and stops the reconnect. Itchanges nothing on the host; the device stays a member until `team remove`.- A reconnect in place keeps the tab's last-seen nodes (the pre-existing re-fetch follow-up indiff --git a/src/renderer/lib/hostedJoin.test.ts b/src/renderer/lib/hostedJoin.test.tsindex 7b433abb9..d405625c3 100644--- a/src/renderer/lib/hostedJoin.test.ts+++ b/src/renderer/lib/hostedJoin.test.ts@@ -441,6 +441,53 @@ describe('hosted joiner', () => {expect(h.connects).toHaveLength(2)})+ it('M8: a code for ANOTHER team pasted into a greyed tab\'s prompt never rebinds that tab — refused, and said why', async () => {+ const h = harness([{ hostId: 'H1', label: 'box', approved: true, code: codeFor('H1') }])+ ;(h.deps.promptForCode as ReturnType<typeof vi.fn>).mockResolvedValue(codeFor('H2', 'lab'))+ const j = createHostedJoiner(h.deps)+ await j.bootReconnect()+ await goLive(h, 0, 'proj-1')+ h.setList([])+ h.closeCbs.get('c0')!(undefined)+ await flush()+ await j.forget('H1', 'box')+ // The greyed tab asks for a code, and the user pastes one for a different team.+ expect(j.reconnectTab('proj-1')).toBe(true)+ await flush()+ expect(h.connects).toHaveLength(1) // nothing connected: no second team inside box's tab+ expect(h.notices.at(-1)).toMatchObject({+ kind: 'error',+ text: 'That invite code is for lab, not box. To join lab, paste the code in New Remote Connection.'+ })+ // The same team's code still reconnects the tab in place.+ j.joinWithCode(codeFor('H1', 'box'), 'proj-1')+ h.connects[1].resolve('c1')+ await flush()+ expect(h.mounts.at(-1)!.req).toMatchObject({ hostId: 'H1', reconnectProjectId: 'proj-1' })+ })++ it('M8: two teams with the same name are told apart without naming the other one twice', async () => {+ const h = harness([{ hostId: 'H1', label: 'box', approved: true, code: codeFor('H1') }])+ const j = createHostedJoiner(h.deps)+ await j.bootReconnect()+ await goLive(h, 0, 'proj-1')+ j.joinWithCode(codeFor('H2', 'box'), 'proj-1')+ expect(h.connects).toHaveLength(1)+ expect(h.notices.at(-1)).toMatchObject({+ kind: 'error',+ text: 'That invite code is for a different team than box. To join it, paste the code in New Remote Connection.'+ })+ })++ it('M8: an unreadable code pasted into that prompt still goes to main, which answers for it', async () => {+ const h = harness([{ hostId: 'H1', label: 'box', approved: true, code: codeFor('H1') }])+ const j = createHostedJoiner(h.deps)+ await j.bootReconnect()+ await goLive(h, 0, 'proj-1')+ j.joinWithCode(`${JOIN_CODE_PREFIX}%%%`, 'proj-1')+ expect(h.connects).toHaveLength(2)+ })+it('R40: a code pasted for a team whose tab is greyed reconnects that tab, never a second one', async () => {const h = harness([{ hostId: 'H1', label: 'box', approved: true, code: codeFor('H1') }])const j = createHostedJoiner(h.deps)diff --git a/src/renderer/lib/hostedJoin.ts b/src/renderer/lib/hostedJoin.tsindex 4a3e4c4fa..5fa7bceeb 100644--- a/src/renderer/lib/hostedJoin.ts+++ b/src/renderer/lib/hostedJoin.ts@@ -237,6 +237,22 @@ export function createHostedJoiner(deps: HostedJoinerDeps): HostedJoiner {joinWithCode(raw, reconnectProjectId) {const code = raw.trim()const peek = peekJoinCode(code)+ // A code pasted into a hosted tab's own reconnect prompt reconnects THAT team only. A code for+ // another team would mount that team inside this tab, under this tab's name: refuse, and say+ // where it goes instead. (An unreadable code is main's to answer, below.)+ const tab = reconnectProjectId ? tabs.get(reconnectProjectId) : undefined+ if (tab && peek && peek.hostId !== tab.hostId) {+ const mine = team(tab.label)+ const theirs = peek.label.trim()+ deps.notify({+ kind: 'error',+ text:+ theirs && theirs !== tab.label.trim()+ ? `That invite code is for ${theirs}, not ${mine}. To join ${theirs}, paste the code in New Remote Connection.`+ : `That invite code is for a different team than ${mine}. To join it, paste the code in New Remote Connection.`+ })+ return+ }// A code the renderer cannot read still goes to main, which verifies codes and answers for// this one; its key is the text itself, so a double paste of it is still one attempt.const hostId = peek?.hostId ?? `unreadable:${code}`