mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Fix diff approval race between CLI and IDE (#7609)
Co-authored-by: Shreya Keshive <skeshive@gmail.com>
This commit is contained in:
@@ -217,12 +217,16 @@ export class IdeClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async closeDiff(filePath: string): Promise<string | undefined> {
|
async closeDiff(
|
||||||
|
filePath: string,
|
||||||
|
options?: { suppressNotification?: boolean },
|
||||||
|
): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
const result = await this.client?.callTool({
|
const result = await this.client?.callTool({
|
||||||
name: `closeDiff`,
|
name: `closeDiff`,
|
||||||
arguments: {
|
arguments: {
|
||||||
filePath,
|
filePath,
|
||||||
|
suppressNotification: options?.suppressNotification,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -239,8 +243,13 @@ export class IdeClient {
|
|||||||
// Closes the diff. Instead of waiting for a notification,
|
// Closes the diff. Instead of waiting for a notification,
|
||||||
// manually resolves the diff resolver as the desired outcome.
|
// manually resolves the diff resolver as the desired outcome.
|
||||||
async resolveDiffFromCli(filePath: string, outcome: 'accepted' | 'rejected') {
|
async resolveDiffFromCli(filePath: string, outcome: 'accepted' | 'rejected') {
|
||||||
const content = await this.closeDiff(filePath);
|
|
||||||
const resolver = this.diffResponses.get(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 (resolver) {
|
||||||
if (outcome === 'accepted') {
|
if (outcome === 'accepted') {
|
||||||
resolver({ status: 'accepted', content });
|
resolver({ status: 'accepted', content });
|
||||||
|
|||||||
Reference in New Issue
Block a user