fix(runtime): coalesce concurrent host terminal focus (#11841)
Bound exclusive host navigation to a generation-aware latest-wins single-flight so bulk open and switch fan-out stay responsive on large remote fleets. Add freeze repro harnesses and navigated settlement.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { formatTerminalFocus } from './terminal-format'
|
||||
|
||||
describe('formatTerminalFocus', () => {
|
||||
it('distinguishes superseded navigation from a winning focus', () => {
|
||||
expect(
|
||||
formatTerminalFocus({
|
||||
focus: {
|
||||
handle: 'term_stale',
|
||||
tabId: 'tab-stale',
|
||||
worktreeId: 'worktree-1',
|
||||
navigated: false
|
||||
}
|
||||
})
|
||||
).toBe(
|
||||
'Focus request for terminal term_stale was superseded or host navigation was skipped (tab tab-stale).'
|
||||
)
|
||||
expect(
|
||||
formatTerminalFocus({
|
||||
focus: { handle: 'term_winner', tabId: 'tab-winner', worktreeId: 'worktree-1' }
|
||||
})
|
||||
).toBe('Focused terminal term_winner (tab tab-winner).')
|
||||
})
|
||||
})
|
||||
@@ -164,6 +164,9 @@ export function formatTerminalSplit(result: { split: RuntimeTerminalSplit }): st
|
||||
}
|
||||
|
||||
export function formatTerminalFocus(result: { focus: RuntimeTerminalFocus }): string {
|
||||
if (result.focus.navigated === false) {
|
||||
return `Focus request for terminal ${result.focus.handle} was superseded or host navigation was skipped (tab ${result.focus.tabId}).`
|
||||
}
|
||||
return `Focused terminal ${result.focus.handle} (tab ${result.focus.tabId}).`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user