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/tools/edit.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/tools/edit.ts')
| -rw-r--r-- | packages/server/src/tools/edit.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/server/src/tools/edit.ts b/packages/server/src/tools/edit.ts index f7c911ec..7b327778 100644 --- a/packages/server/src/tools/edit.ts +++ b/packages/server/src/tools/edit.ts @@ -56,7 +56,7 @@ interface CalculatedEdit { */ export class EditTool extends BaseTool<EditToolParams, ToolResult> { static readonly Name = 'replace'; - private shouldAlwaysEdit = false; + private readonly config: Config; private readonly rootDirectory: string; private readonly client: GeminiClient; @@ -98,8 +98,9 @@ Expectation for parameters: type: 'object', }, ); - this.rootDirectory = path.resolve(config.getTargetDir()); - this.client = new GeminiClient(config); + this.config = config; + this.rootDirectory = path.resolve(this.config.getTargetDir()); + this.client = new GeminiClient(this.config); } /** @@ -234,7 +235,7 @@ Expectation for parameters: async shouldConfirmExecute( params: EditToolParams, ): Promise<ToolCallConfirmationDetails | false> { - if (this.shouldAlwaysEdit) { + if (this.config.getAlwaysSkipModificationConfirmation()) { return false; } const validationError = this.validateToolParams(params); @@ -295,7 +296,7 @@ Expectation for parameters: fileDiff, onConfirm: async (outcome: ToolConfirmationOutcome) => { if (outcome === ToolConfirmationOutcome.ProceedAlways) { - this.shouldAlwaysEdit = true; + this.config.setAlwaysSkipModificationConfirmation(true); } }, }; |
