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(share-team): a refused ⇧⌘T entry is dropped, not put back on top

review87e83afb8802
diff --git a/CLAUDE.md b/CLAUDE.md
index 0d094b6a1..f91b85c2c 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -8515,7 +8515,8 @@ invariants:
(so does every path through `reopenProject`); "Recently closed" lists neither the tab
(`isReopenableClosedProject`) nor its closed sessions (`isClosedTeamTab`); `planReopen` answers
`refuse` for ANY entry into a closed team tab BEFORE recreating a node into it (a `nodes` entry
- would otherwise be written into it and reopen it), and ⇧⌘T puts the entry back untouched;
+ would otherwise be written into it and reopen it), and ⇧⌘T drops that entry (kept on top it
+ would answer every later ⇧⌘T with the notice and hide every older entry);
`performCloseProject` does not push a project entry for a relay tab. What brings the tab back is
joining the team again with none of its tabs open, or an unshare + share (a reconnect keeps it
dismissed, `lib/hostedTeamTabs.ts`).
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 4f2e95caa..a484177a4 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -9358,10 +9358,11 @@ export function Canvas() {
permissionModeFor: (agentId) => projectPermissionMode(project, agentId)
})
)
- // A closed team tab: nothing is written into it or reopened, and the entry goes back on the
- // stack untouched (its persisted twin too), so it still restores once the tab is back.
+ // A closed team tab: nothing is written into it or reopened, and the entry is dropped. Put
+ // back on top it would answer every later ⇧⌘T with this notice and hide every older entry,
+ // and a closed team tab does not come back through ⇧⌘T anyway. A relay project is never
+ // saved, so it has no persisted twin to discard.
if (plan.action === 'refuse') {
- useReopenHistory.getState().push(entry)
setNotice({ kind: 'info', text: CLOSED_TEAM_TAB_NOTICE })
return true
}
diff --git a/src/renderer/canvas/handed-off-reopen.source.test.ts b/src/renderer/canvas/handed-off-reopen.source.test.ts
index 5aae4754f..9d7baafee 100644
--- a/src/renderer/canvas/handed-off-reopen.source.test.ts
+++ b/src/renderer/canvas/handed-off-reopen.source.test.ts
@@ -53,11 +53,14 @@ describe('handed-off reopen guard in Canvas', () => {
const human = between('const reopenProject = useCallback(', CALLBACK_END)
expect(human).toContain('return Promise.resolve(reopenProjectUnchecked(id))')
expect(human).toContain('ok && reopenProjectUnchecked(id)')
- // ⇧⌘T: a refused plan puts the entry back before its persisted twin would be discarded.
+ // ⇧⌘T: a refused plan says why and drops the entry (pushed back on top it would hide every
+ // older entry), before anything is discarded or recreated.
const last = between('const reopenLastClosedCommand = useCallback(', '}, [executeReopenPlan, writeDisk])')
const refused = last.indexOf("if (plan.action === 'refuse') {")
expect(refused).toBeGreaterThan(-1)
- expect(last.indexOf('useReopenHistory.getState().push(entry)', refused)).toBeGreaterThan(refused)
+ const refuseBody = last.slice(refused, last.indexOf('}', refused))
+ expect(refuseBody).toContain('CLOSED_TEAM_TAB_NOTICE')
+ expect(refuseBody).not.toContain('push(entry)')
expect(last.indexOf('discardClosedSession(')).toBeGreaterThan(refused)
// The sidebar's session restore checks before it consumes the entry.
const session = between('const reopenClosedSessionCommand = useCallback(', CALLBACK_END)
diff --git a/src/renderer/lib/reopenPlan.ts b/src/renderer/lib/reopenPlan.ts
index ef890af5d..d659c2363 100644
--- a/src/renderer/lib/reopenPlan.ts
+++ b/src/renderer/lib/reopenPlan.ts
@@ -8,7 +8,7 @@ import { isClosedTeamTab } from './closedHistory'
* whichever variant comes back; `'skip'` means the entry was stale (already reopened another
* way, its project was permanently deleted, or every node it held recreated to nothing) and the
* caller should keep popping. `'refuse'` means the entry's project is a CLOSED team tab
- * (`isClosedTeamTab`): nothing may be written into it or reopen it, and the caller keeps the entry
+ * (`isClosedTeamTab`): nothing may be written into it or reopen it, and the caller drops the entry
* and says why. */
export type ReopenPlan =
| { action: 'reopenProject'; projectId: string }