diff options
| author | Taylor Mullen <[email protected]> | 2025-05-16 23:33:12 -0700 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-05-16 23:34:48 -0700 |
| commit | 5dcdbe64ab6ef2ca2692e75b8600b8726ac72178 (patch) | |
| tree | ecc774a5e10c5d2e6c65d11ba0008edf3c9cb09e /packages/server/src/config/config.ts | |
| parent | 58e02240612e0a0eddc1427a795f5003ee2b3d07 (diff) | |
refactor: Unify file modification confirmation state
- Modifies `EditTool` and `WriteFileTool` to share a single confirmation preference.
- The "Always Proceed" choice for file modifications is now stored in `Config.alwaysSkipModificationConfirmation`.
- This ensures that if a user chooses to always skip confirmation for one file modification tool, this preference is respected by the other.
- `WriteFileTool` constructor now accepts `Config` instead of `targetDir` to facilitate this shared state.
- Tests updated to reflect the new shared confirmation logic.
Fixes https://b.corp.google.com/issues/415897960
Diffstat (limited to 'packages/server/src/config/config.ts')
| -rw-r--r-- | packages/server/src/config/config.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/server/src/config/config.ts b/packages/server/src/config/config.ts index 8b9648c4..fdd7973e 100644 --- a/packages/server/src/config/config.ts +++ b/packages/server/src/config/config.ts @@ -43,6 +43,7 @@ export class Config { private readonly userAgent: string, private userMemory: string = '', // Made mutable for refresh private geminiMdFileCount: number = 0, + private alwaysSkipModificationConfirmation: boolean = false, ) { // toolRegistry still needs initialization based on the instance this.toolRegistry = createToolRegistry(this); @@ -114,6 +115,14 @@ export class Config { setGeminiMdFileCount(count: number): void { this.geminiMdFileCount = count; } + + getAlwaysSkipModificationConfirmation(): boolean { + return this.alwaysSkipModificationConfirmation; + } + + setAlwaysSkipModificationConfirmation(skip: boolean): void { + this.alwaysSkipModificationConfirmation = skip; + } } function findEnvFile(startDir: string): string | null { @@ -159,6 +168,7 @@ export function createServerConfig( userAgent?: string, userMemory?: string, geminiMdFileCount?: number, + alwaysSkipModificationConfirmation?: boolean, ): Config { return new Config( apiKey, @@ -175,6 +185,7 @@ export function createServerConfig( userAgent ?? 'GeminiCLI/unknown', // Default user agent userMemory ?? '', geminiMdFileCount ?? 0, + alwaysSkipModificationConfirmation ?? false, ); } @@ -188,7 +199,7 @@ function createToolRegistry(config: Config): ToolRegistry { new GrepTool(targetDir), new GlobTool(targetDir), new EditTool(config), - new WriteFileTool(targetDir), + new WriteFileTool(config), new WebFetchTool(), new ReadManyFilesTool(targetDir), new ShellTool(config), |
