feat: keep managed SSH prompts running on Hosts
Managed SSH prompts previously depended on Desktop-owned provider and transcript state, so accepted work could stop or become uncertain when the Desktop, network, or power disappeared. The Agent now owns accepted OpenCode prompt execution, model and tool rounds, cancellation, and the durable semantic transcript, while Desktop remains authoritative for permanent projects, conversations, tasks, and messages. Recovered work attaches to the original conversation without replay. The project switcher also groups managed SSH projects by saved Host and shows live Agent connectivity beside each group without opening a connection merely to read status. Remote project subtitles now show only the path, and the Agent lock advances to 0.11.14 with Runtime ACP v4. Release note: 托管 SSH 任务在桌面端、网络或电源中断后可继续在主机上运行,并能回到原会话精确恢复;项目菜单现按主机分组并显示实时连接状态。
This commit is contained in:
@@ -231,6 +231,76 @@ function harness(
|
||||
}
|
||||
|
||||
describe('RemoteAgentConnectionManager', () => {
|
||||
it('publishes the aggregate live connection state for each Host', async () => {
|
||||
let finishTransport!: () => void
|
||||
const gate = new Promise<void>((resolve) => {
|
||||
finishTransport = resolve
|
||||
})
|
||||
const test = harness(gate, undefined, 1_000)
|
||||
const states: string[] = []
|
||||
const unsubscribe =
|
||||
test.manager.onHostConnectionStateChange(({ state }) => {
|
||||
states.push(state)
|
||||
})
|
||||
|
||||
expect(
|
||||
test.manager.getHostConnectionState('host-1')
|
||||
).toBe('disconnected')
|
||||
const acquiring = test.manager.acquire('host-1', installation)
|
||||
await vi.waitFor(() =>
|
||||
expect(states).toEqual(['connecting'])
|
||||
)
|
||||
finishTransport()
|
||||
const lease = await acquiring
|
||||
expect(
|
||||
test.manager.getHostConnectionState('host-1')
|
||||
).toBe('ready')
|
||||
|
||||
test.clients[0]!.transportClose()
|
||||
expect(
|
||||
test.manager.getHostConnectionState('host-1')
|
||||
).toBe('error')
|
||||
lease.release()
|
||||
await test.manager.dispose()
|
||||
|
||||
expect(states).toEqual([
|
||||
'connecting',
|
||||
'ready',
|
||||
'error',
|
||||
'disconnected'
|
||||
])
|
||||
unsubscribe()
|
||||
})
|
||||
|
||||
it('clears a retained connection error when its Host is invalidated', async () => {
|
||||
const test = harness()
|
||||
const states: string[] = []
|
||||
test.manager.onHostConnectionStateChange(({ state }) => {
|
||||
states.push(state)
|
||||
})
|
||||
test.connectTransport.mockRejectedValueOnce(
|
||||
new Error('attach failed')
|
||||
)
|
||||
|
||||
await expect(
|
||||
test.manager.acquire('host-1', installation)
|
||||
).rejects.toThrow()
|
||||
expect(
|
||||
test.manager.getHostConnectionState('host-1')
|
||||
).toBe('error')
|
||||
|
||||
await test.manager.invalidateHost('host-1')
|
||||
expect(
|
||||
test.manager.getHostConnectionState('host-1')
|
||||
).toBe('disconnected')
|
||||
expect(states).toEqual([
|
||||
'connecting',
|
||||
'error',
|
||||
'disconnected'
|
||||
])
|
||||
await test.manager.dispose()
|
||||
})
|
||||
|
||||
it('deduplicates concurrent connects and ref-counts the shared connection', async () => {
|
||||
const test = harness()
|
||||
const [first, second] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user