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(hosted): refuse a team invite code pasted into a Team Access tab's reconnect prompt (R46)

review315bf3133ba7
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index c868ec5ce..511f221a8 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -4473,7 +4473,8 @@ export function Canvas() {
void reconnectRelayTab(projectId, {
promptForOffer: async () => {
const offer = await promptDialog({ message: "Paste the host's new pairing code:" })
- // A join code pasted here reconnects THIS tab through its team's attempt owner.
+ // A join code pasted here goes to the joiner, which refuses it: only a Team Access tab
+ // reaches this prompt, and a team must not be mounted into it (R46).
if (offer && isJoinCode(offer) && hostedJoinerRef.current) {
hostedJoinerRef.current.joinWithCode(offer, projectId)
return null
diff --git a/src/renderer/canvas/hosted-team.source.test.ts b/src/renderer/canvas/hosted-team.source.test.ts
index 490f65652..4ad76f059 100644
--- a/src/renderer/canvas/hosted-team.source.test.ts
+++ b/src/renderer/canvas/hosted-team.source.test.ts
@@ -41,6 +41,11 @@ describe('hosted team glue in Canvas', () => {
body.indexOf('void reconnectRelayTab(projectId, {')
)
expect(body).toContain(`promptDialog({ message: "Paste the host's new pairing code:" })`)
+ // R46: a join code pasted there goes to the joiner WITH this tab's id, which refuses to rebind a
+ // tab it did not open (lib/hostedJoin.test.ts); a pairing offer is returned untouched.
+ const divert = body.indexOf('hostedJoinerRef.current.joinWithCode(offer, projectId)')
+ expect(divert).toBeGreaterThan(-1)
+ expect(body.indexOf('return offer', divert)).toBeGreaterThan(divert)
})
it('the relay tab is built with hosted options, a long approval wait and no alert ONLY when hosted', () => {
diff --git a/src/renderer/lib/hostedJoin.test.ts b/src/renderer/lib/hostedJoin.test.ts
index 0302e2295..a73892c55 100644
--- a/src/renderer/lib/hostedJoin.test.ts
+++ b/src/renderer/lib/hostedJoin.test.ts
@@ -98,14 +98,30 @@ describe('hosted joiner', () => {
expect(h.connects).toHaveLength(1)
})
- it('a code pasted into a greyed tab\'s prompt reconnects THAT tab (never a second one)', async () => {
+ it('R46: a code pasted into a Team Access tab\'s reconnect prompt never rebinds that tab — refused, and said where it goes', async () => {
+ // A greyed tab this joiner never opened is a Team Access tab (a hosted tab reconnects from its
+ // bookmark and never reaches the pairing prompt). Rebinding it would mount the team inside it,
+ // under its name, with no cross-team check (there is no team to check against).
const h = harness()
- h.open.add('proj-7') // the greyed tab the prompt was raised on
+ h.open.add('proj-7') // the Team Access tab the prompt was raised on
const j = createHostedJoiner(h.deps)
+ const refused = {
+ kind: 'error',
+ text: 'That is a hosted team invite code — paste it with New Remote Connection to open the team in its own tab.'
+ }
j.joinWithCode(codeFor('H1'), 'proj-7')
+ expect(h.connects).toHaveLength(0)
+ expect(h.notices.at(-1)).toMatchObject(refused)
+ // An unreadable code is refused there too: whatever main made of it, it would land in that tab.
+ j.joinWithCode(`${JOIN_CODE_PREFIX}%%%`, 'proj-7')
+ expect(h.connects).toHaveLength(0)
+ expect(h.notices.at(-1)).toMatchObject(refused)
+ // The same code from New Remote Connection opens the team in its own tab.
+ j.joinWithCode(codeFor('H1'))
h.connects[0].resolve('c0')
await flush()
- expect(h.mounts[0].req).toMatchObject({ hostId: 'H1', reconnectProjectId: 'proj-7', manual: true, retry: false })
+ expect(h.mounts[0].req).toMatchObject({ hostId: 'H1', manual: true, retry: false })
+ expect(h.mounts[0].req.reconnectProjectId).toBeUndefined()
})
it('a pasted code the renderer cannot read is still handed to main, which answers for it', async () => {
diff --git a/src/renderer/lib/hostedJoin.ts b/src/renderer/lib/hostedJoin.ts
index a9708fa49..a7e655a51 100644
--- a/src/renderer/lib/hostedJoin.ts
+++ b/src/renderer/lib/hostedJoin.ts
@@ -31,6 +31,10 @@ import {
* whose device the host no longer knows waits for an owner like a first join (R40). */
export const WAITING_NOTICE_DELAY_MS = 2500
+/** Said when a hosted team's invite code is pasted into a Team Access tab's reconnect prompt. */
+export const HOSTED_CODE_IN_TEAM_ACCESS_TAB =
+ 'That is a hosted team invite code — paste it with New Remote Connection to open the team in its own tab.'
+
/** How a mount ended, as the canvas reports it: a live tab, or the error it failed with. `declined`
* = this user declined the SAS themselves (nothing to tell them). */
export type HostedMountOutcome = { projectId: string } | { error: unknown; declined: boolean }
@@ -260,6 +264,13 @@ export function createHostedJoiner(deps: HostedJoinerDeps): HostedJoiner {
// 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
+ // A tab this joiner did not open is a Team Access tab: a hosted tab reconnects from its
+ // bookmark and never reaches the pairing prompt. Rebinding it would mount the team there,
+ // under that tab's name, with no team to check the code against. Refuse, readable or not.
+ if (reconnectProjectId && !tab) {
+ deps.notify({ kind: 'error', text: HOSTED_CODE_IN_TEAM_ACCESS_TAB })
+ return
+ }
if (tab && peek && peek.hostId !== tab.hostId) {
const mine = team(tab.label)
const theirs = peek.label.trim()