chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进

This commit is contained in:
Logan.Li committed 2026-09-14 22:10:22 +08:00
1 parent f71eef0eba
commit ae6093c9b3
163 files changed
+4911 -2494

No files matched your search

+48 -4
View File
@@ -1,7 +1,9 @@
import { describe, expect, it } from 'vitest'
import {
panesAfterConnectionStateChange,
resolveTerminalInputTargets,
shouldBroadcastTerminalInput,
shouldCollapseTerminalSplitForOverlay,
} from '../../src/utils/terminalPanes'
const panes = [
@@ -16,10 +18,7 @@ describe('terminal pane input routing', () => {
})
it('routes broadcast input to every ready shell in pane order', () => {
expect(resolveTerminalInputTargets(panes, 'left', true)).toEqual([
'shell-1',
'shell-3',
])
expect(resolveTerminalInputTargets(panes, 'left', true)).toEqual(['shell-1', 'shell-3'])
})
it('does not write when the source pane has no ready shell', () => {
@@ -34,3 +33,48 @@ describe('terminal pane input routing', () => {
expect(shouldBroadcastTerminalInput(false, false, 'ssh-connection')).toBe(false)
})
})
describe('panesAfterConnectionStateChange', () => {
const split = [
{ id: 'pane-a', shellId: 'shell-old', closed: { reason: 'stale' } },
{ id: 'pane-b', shellId: 'shell-2' },
{ id: 'pane-c', shellId: 'shell-3' },
]
it('clears every split shell when the pooled session drops', () => {
const next = panesAfterConnectionStateChange(split, 'reconnecting', 'shell-new')
expect(next.map((pane) => pane.shellId)).toEqual([null, null, null])
expect(next.every((pane) => pane.closed == null)).toBe(true)
expect(next.map((pane) => pane.id)).toEqual(['pane-a', 'pane-b', 'pane-c'])
})
it('rebinds the primary pane to the new shell after reconnect', () => {
const cleared = panesAfterConnectionStateChange(split, 'disconnected', null)
const next = panesAfterConnectionStateChange(cleared, 'connected', 'shell-new')
expect(next[0].shellId).toBe('shell-new')
expect(next[1].shellId).toBeNull()
expect(next[2].shellId).toBeNull()
})
it('keeps the split layout in memory while collapsing the overlay visually', () => {
expect(
shouldCollapseTerminalSplitForOverlay({
connectionState: 'disconnected',
needsReconnect: true,
showSuspendedOverlay: false,
})
).toBe(true)
expect(
shouldCollapseTerminalSplitForOverlay({
connectionState: 'connected',
needsReconnect: false,
showSuspendedOverlay: false,
})
).toBe(false)
expect(panesAfterConnectionStateChange(split, 'disconnected', null).map((pane) => pane.id)).toEqual([
'pane-a',
'pane-b',
'pane-c',
])
})
})