Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/TerminalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,11 @@ function TerminalView({ tabId, paneId, paneContent, hidden }: TerminalViewProps)
// close-during-create race and stale deferred re-attach timers.
const layouts = appStore.getState().panes.layouts
if (!collectAllTerminalIds(layouts).has(tid)) {
log.debug('attach gate declined: terminal not referenced by any layout', {
terminalId: tid,
paneId: paneIdRef.current,
intent,
})
return
}
const term = termRef.current
Expand Down
9 changes: 9 additions & 0 deletions src/store/terminalDetachMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ type PanesStateSlice = { panes: { layouts: Record<string, PaneNode | undefined>
* reported dead or unrecoverable (terminal.inventory / terminals.changed).
* There is no live subscription to release, and the server replies with an
* error for terminal.detach on a non-existent terminal — so skip them.
*
* MAINTENANCE WARNING: this skip-list is maintained BY HAND. If you add a
* new reducer/action that removes terminalIds from layouts because the
* SERVER already reported those terminals dead, you MUST register it here —
* otherwise this middleware sends a redundant terminal.detach for each one
* and the server answers with an error (harmless but noisy). Conversely,
* never register an action that removes a LIVE terminal from the layouts:
* skipping it would leak the server-side subscription — the exact bug this
* middleware exists to prevent (see PR #534).
*/
const skipDetachActionTypes = new Set<string>([
clearDeadTerminals.type,
Expand Down
Loading