Skip to content

Commit 193cb02

Browse files
committed
fix: resume interrupted desktop turns after cli restart
1 parent 08747bf commit 193cb02

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/server/__tests__/conversation-service.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ describe('ConversationService', () => {
290290
)
291291
expect(env.CC_HAHA_DESKTOP_SERVER_URL).toBe('http://127.0.0.1:3456')
292292
expect(env.CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING).toBe('1')
293+
expect(env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN).toBe('1')
294+
})
295+
296+
test('buildChildEnv does not force interrupted-turn resume for non-SDK sessions', async () => {
297+
const service = new ConversationService() as any
298+
const env = (await service.buildChildEnv('/tmp')) as Record<string, string>
299+
300+
expect(env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN).toBeUndefined()
293301
})
294302

295303
test('uses bun entrypoint fallback on Windows dev mode', () => {

src/server/services/conversationService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,16 @@ export class ConversationService {
900900
CLAUDE_CODE_ENABLE_TASKS: '1',
901901
CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING: '1',
902902
CLAUDE_CODE_DIAGNOSTICS_FILE: cliDiagnosticsPath,
903+
// Desktop frequently restarts the SDK CLI in-place (stop generation,
904+
// runtime/model switch, reconnect). When the previous turn was
905+
// interrupted, print.ts only re-enqueues that interrupted user prompt if
906+
// this env flag is enabled. Without it, the resumed transcript keeps the
907+
// synthetic "[Request interrupted by user]" / "No response requested."
908+
// pair, but the interrupted prompt is not actively resumed on restart,
909+
// which can make follow-up turns appear to "forget" earlier user input.
910+
...(sdkUrl
911+
? { CLAUDE_CODE_RESUME_INTERRUPTED_TURN: '1' }
912+
: {}),
903913
CALLER_DIR: workDir,
904914
PWD: workDir,
905915
...(sdkUrl

0 commit comments

Comments
 (0)