diff --git a/src/server/__tests__/conversation-service.test.ts b/src/server/__tests__/conversation-service.test.ts index 87ba2ce7..aa438e22 100644 --- a/src/server/__tests__/conversation-service.test.ts +++ b/src/server/__tests__/conversation-service.test.ts @@ -549,6 +549,16 @@ describe('ConversationService', () => { expect(env.CC_HAHA_DESKTOP_AWAIT_MCP_TIMEOUT_MS).toBe('5000') }) + test('buildChildEnv enables stream idle watchdog for desktop CLI sessions', async () => { + const service = new ConversationService() as any + const env = (await service.buildChildEnv( + '/tmp', + 'ws://127.0.0.1:3456/sdk/test-session?token=test-token', + )) as Record + + expect(env.CLAUDE_ENABLE_STREAM_WATCHDOG).toBe('1') + }) + test('buildSessionCliArgs forwards the selected runtime model and effort to the CLI process', () => { const service = new ConversationService() as any const args = service.buildSessionCliArgs( diff --git a/src/server/services/conversationService.ts b/src/server/services/conversationService.ts index 7ce4b501..1bc74586 100644 --- a/src/server/services/conversationService.ts +++ b/src/server/services/conversationService.ts @@ -983,6 +983,8 @@ export class ConversationService { ...cleanEnv, CLAUDE_CODE_ENABLE_TASKS: '1', CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING: '1', + // Desktop must fail stuck provider streams instead of leaving the UI running forever. + CLAUDE_ENABLE_STREAM_WATCHDOG: cleanEnv.CLAUDE_ENABLE_STREAM_WATCHDOG || '1', CLAUDE_CODE_DIAGNOSTICS_FILE: cliDiagnosticsPath, CLAUDE_COWORK_MEMORY_PATH_OVERRIDE: this.resolveDesktopAutoMemoryPath(workDir), CALLER_DIR: workDir,