fix: reclaim idle remote runtimes and retire replaced agents
Remote tasks could leave idle Runtime processes behind, and replaced Agent installations lacked a drain-and-exit lifecycle. Keep the current Agent resident, let displaced Agents finish existing work and reconnect for its results, then retire them without restarting obsolete installations. Reclaim Runtime processes when their last active task finishes, preserve pending questions and shared active tasks, and restore conversation history when the next turn starts. Remove the Remote Projects technical preview label from settings, errors, tests, and current documentation; the feature remains disabled by default. Validation recorded during implementation: 213 lifecycle tests and 28 focused UI/IPC tests passed, as did SettingsPanel and lint. Linux x64 real-Host checks used 8 provider requests. Broader tests and final typecheck encountered unrelated concurrent changes; details and coverage limits are documented. Release note: 远程任务结束后自动释放空闲运行进程,下一轮对话恢复历史;更新后的旧 Agent 等待已有任务完成再退出,当前 Agent 保持常驻。远程项目移除“技术预览”标识,仍默认关闭。
This commit is contained in:
@@ -48,6 +48,37 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('Agent daemon lifecycle', () => {
|
||||
it('keeps the current daemon resident and retires a superseded daemon only after detached work drains', async () => {
|
||||
vi.useFakeTimers()
|
||||
vi.spyOn(PrivateEndpoint.prototype, 'listen').mockResolvedValue()
|
||||
vi.spyOn(PrivateEndpoint.prototype, 'close').mockResolvedValue()
|
||||
let superseded = false
|
||||
let idle = false
|
||||
const drain = vi.fn(async () => idle)
|
||||
const daemon = daemonForTest({
|
||||
isSuperseded: () => superseded,
|
||||
runtimeProtocol: { runtimes: () => [], methods: {}, onAcpFrame: async () => {}, drain }
|
||||
})
|
||||
const retired = vi.fn()
|
||||
void daemon.retired.then(retired)
|
||||
try {
|
||||
await daemon.start()
|
||||
await vi.advanceTimersByTimeAsync(1_000)
|
||||
expect(drain).not.toHaveBeenCalled()
|
||||
expect(retired).not.toHaveBeenCalled()
|
||||
superseded = true
|
||||
await vi.advanceTimersByTimeAsync(250)
|
||||
expect(daemon.status().draining).toBe(true)
|
||||
expect(retired).not.toHaveBeenCalled()
|
||||
idle = true
|
||||
await vi.advanceTimersByTimeAsync(250)
|
||||
expect(retired).toHaveBeenCalledOnce()
|
||||
} finally {
|
||||
await daemon.stop()
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('returns the strict manifest-bound Linux daemon status', () => {
|
||||
const daemon = daemonForTest()
|
||||
const status = daemonStatusSchema.parse(daemon.status())
|
||||
|
||||
Reference in New Issue
Block a user