mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 20:14:44 -07:00
Override Gemini CLI trust with VScode workspace trust when in IDE (#7433)
This commit is contained in:
@@ -77,6 +77,7 @@ export class IdeClient {
|
||||
private ideProcessInfo: { pid: number; command: string } | undefined;
|
||||
private diffResponses = new Map<string, (result: DiffUpdateResult) => void>();
|
||||
private statusListeners = new Set<(state: IDEConnectionState) => void>();
|
||||
private trustChangeListeners = new Set<(isTrusted: boolean) => void>();
|
||||
|
||||
private constructor() {}
|
||||
|
||||
@@ -103,6 +104,14 @@ export class IdeClient {
|
||||
this.statusListeners.delete(listener);
|
||||
}
|
||||
|
||||
addTrustChangeListener(listener: (isTrusted: boolean) => void) {
|
||||
this.trustChangeListeners.add(listener);
|
||||
}
|
||||
|
||||
removeTrustChangeListener(listener: (isTrusted: boolean) => void) {
|
||||
this.trustChangeListeners.delete(listener);
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
if (!this.currentIde || !this.currentIdeDisplayName) {
|
||||
this.setState(
|
||||
@@ -422,6 +431,12 @@ export class IdeClient {
|
||||
IdeContextNotificationSchema,
|
||||
(notification) => {
|
||||
ideContext.setIdeContext(notification.params);
|
||||
const isTrusted = notification.params.workspaceState?.isTrusted;
|
||||
if (isTrusted !== undefined) {
|
||||
for (const listener of this.trustChangeListeners) {
|
||||
listener(isTrusted);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
this.client.onerror = (_error) => {
|
||||
|
||||
@@ -27,6 +27,7 @@ export const IdeContextSchema = z.object({
|
||||
workspaceState: z
|
||||
.object({
|
||||
openFiles: z.array(FileSchema).optional(),
|
||||
isTrusted: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user