From 645133d9dd4cd85482d96887bb239b3ab550ac59 Mon Sep 17 00:00:00 2001 From: Rahat Ahmed Date: Wed, 3 Sep 2025 15:53:57 -0500 Subject: [PATCH] Fix diff approval race between CLI and IDE (#7609) Co-authored-by: Shreya Keshive --- packages/core/src/ide/ide-client.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/core/src/ide/ide-client.ts b/packages/core/src/ide/ide-client.ts index c13f68e83a..fc87967217 100644 --- a/packages/core/src/ide/ide-client.ts +++ b/packages/core/src/ide/ide-client.ts @@ -217,12 +217,16 @@ export class IdeClient { }); } - async closeDiff(filePath: string): Promise { + async closeDiff( + filePath: string, + options?: { suppressNotification?: boolean }, + ): Promise { try { const result = await this.client?.callTool({ name: `closeDiff`, arguments: { filePath, + suppressNotification: options?.suppressNotification, }, }); @@ -239,8 +243,13 @@ export class IdeClient { // Closes the diff. Instead of waiting for a notification, // manually resolves the diff resolver as the desired outcome. async resolveDiffFromCli(filePath: string, outcome: 'accepted' | 'rejected') { - const content = await this.closeDiff(filePath); const resolver = this.diffResponses.get(filePath); + const content = await this.closeDiff(filePath, { + // Suppress notification to avoid race where closing the diff rejects the + // request. + suppressNotification: true, + }); + if (resolver) { if (outcome === 'accepted') { resolver({ status: 'accepted', content });