mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 18:14:29 -07:00
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
This commit is contained in:
committed by
N. Taylor Mullen
parent
58e0224061
commit
5dcdbe64ab
@@ -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);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user