Complete multi-pane broadcast, standard terminal right-click actions, batch host selection with progress, and native ssh_close_shell so closing a pane tears down the remote shell. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import {
|
|
getTerminalBroadcastTargets,
|
|
terminalBroadcastTargetCount,
|
|
useTerminalBroadcastStore,
|
|
} from '../../src/stores/terminalBroadcastStore'
|
|
|
|
describe('terminal broadcast store', () => {
|
|
beforeEach(() => useTerminalBroadcastStore.getState().reset())
|
|
|
|
it('collects ready shells from every open terminal workspace and removes closed tabs', () => {
|
|
const store = useTerminalBroadcastStore.getState()
|
|
store.registerWorkspace({
|
|
tabId: 'tab-a',
|
|
targets: [
|
|
{ tabId: 'tab-a', paneId: 'left', shellId: 'shell-a', connectionId: 'conn-a', label: 'Host A' },
|
|
{ tabId: 'tab-a', paneId: 'right', shellId: 'shell-b', connectionId: 'conn-a', label: 'Host A' },
|
|
],
|
|
})
|
|
store.registerWorkspace({
|
|
tabId: 'tab-b',
|
|
targets: [
|
|
{ tabId: 'tab-b', paneId: 'main', shellId: 'shell-c', connectionId: 'conn-b', label: 'Host B' },
|
|
],
|
|
})
|
|
|
|
expect(getTerminalBroadcastTargets().map((target) => target.shellId)).toEqual([
|
|
'shell-a',
|
|
'shell-b',
|
|
'shell-c',
|
|
])
|
|
expect(terminalBroadcastTargetCount(useTerminalBroadcastStore.getState())).toBe(3)
|
|
|
|
useTerminalBroadcastStore.getState().unregisterWorkspace('tab-a')
|
|
expect(getTerminalBroadcastTargets().map((target) => target.shellId)).toEqual(['shell-c'])
|
|
})
|
|
|
|
it('deduplicates a shell defensively', () => {
|
|
useTerminalBroadcastStore.getState().registerWorkspace({
|
|
tabId: 'tab-a',
|
|
targets: [
|
|
{ tabId: 'tab-a', paneId: 'a', shellId: 'shared', connectionId: 'conn-a', label: 'A' },
|
|
{ tabId: 'tab-a', paneId: 'b', shellId: 'shared', connectionId: 'conn-a', label: 'A' },
|
|
],
|
|
})
|
|
expect(getTerminalBroadcastTargets()).toHaveLength(1)
|
|
})
|
|
})
|