* fix(worktree): stop terminal removal fence error flashing on delete Deleting a worktree kills its PTYs for the filesystem teardown, then runs git worktree remove (~1s). During that window a doomed pane races a fresh respawn that main correctly fences with TerminalRemovalInProgressError, but the renderer surfaced that internal fence verbatim as a pane error banner until the worktree unmounted. - startFreshSpawn: skip the respawn when the pane's own worktree is being deleted (isDeleting) — no shell should spawn into a directory being removed and the pane is about to unmount. - reportError: swallow the removal fence at the single pane-error sink so it never reaches the banner, covering the parent-removal-fences-child case the own-worktree skip cannot see. - Share the fence messages between main (thrown) and renderer (recognized) via worktree-removal-fence-error.ts so the thrown text and predicate can't drift. * test(worktree): assert onError callback captured before invoking Optional invocation let the fence-suppression test false-pass if the transport onError wiring broke; require the callback so a broken wire fails loudly. Addresses CodeRabbit review on #10240.
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
TERMINAL_REMOVAL_IN_PROGRESS_MESSAGE,
|
|
WATCHER_REMOVAL_IN_PROGRESS_MESSAGE,
|
|
isWorktreeRemovalFenceError
|
|
} from './worktree-removal-fence-error'
|
|
|
|
describe('isWorktreeRemovalFenceError', () => {
|
|
it('recognizes the raw terminal and watcher fence messages', () => {
|
|
expect(isWorktreeRemovalFenceError(TERMINAL_REMOVAL_IN_PROGRESS_MESSAGE)).toBe(true)
|
|
expect(isWorktreeRemovalFenceError(WATCHER_REMOVAL_IN_PROGRESS_MESSAGE)).toBe(true)
|
|
})
|
|
|
|
it('recognizes the message after Electron IPC prefixes the reject', () => {
|
|
// Electron wraps a rejected ipcMain.handle error with its own prefix.
|
|
const wrapped = `Error invoking remote method 'pty:spawn': Error: ${TERMINAL_REMOVAL_IN_PROGRESS_MESSAGE}`
|
|
expect(isWorktreeRemovalFenceError(wrapped)).toBe(true)
|
|
})
|
|
|
|
it('does not match unrelated terminal errors', () => {
|
|
expect(isWorktreeRemovalFenceError('Failed to save terminal session state')).toBe(false)
|
|
expect(isWorktreeRemovalFenceError('shell exited with code 1')).toBe(false)
|
|
expect(isWorktreeRemovalFenceError('')).toBe(false)
|
|
})
|
|
})
|