mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat: Add auto-accept indicator and toggle
- This commit introduces a visual indicator in the CLI to show when auto-accept for tool confirmations is enabled. Users can now also toggle this setting on/off using Shift + Tab. - This addresses user feedback for better visibility and control over the auto-accept feature, improving the overall user experience. - This behavior is similar to Claude Code, providing a familiar experience for users transitioning from that environment. - Added tests for the new auto indicator hook. Fixes https://b.corp.google.com/issues/413740468
This commit is contained in:
committed by
N. Taylor Mullen
parent
13a6a9a690
commit
aca27709df
39
packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts
Normal file
39
packages/cli/src/ui/hooks/useAutoAcceptIndicator.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useInput } from 'ink';
|
||||
import type { Config } from '@gemini-code/server';
|
||||
|
||||
export interface UseAutoAcceptIndicatorArgs {
|
||||
config: Config;
|
||||
}
|
||||
|
||||
export function useAutoAcceptIndicator({
|
||||
config,
|
||||
}: UseAutoAcceptIndicatorArgs): boolean {
|
||||
const currentConfigValue = config.getAlwaysSkipModificationConfirmation();
|
||||
const [showAutoAcceptIndicator, setShowAutoAcceptIndicator] =
|
||||
useState(currentConfigValue);
|
||||
|
||||
useEffect(() => {
|
||||
setShowAutoAcceptIndicator(currentConfigValue);
|
||||
}, [currentConfigValue]);
|
||||
|
||||
useInput((_input, key) => {
|
||||
if (key.tab && key.shift) {
|
||||
const alwaysAcceptModificationConfirmations =
|
||||
!config.getAlwaysSkipModificationConfirmation();
|
||||
config.setAlwaysSkipModificationConfirmation(
|
||||
alwaysAcceptModificationConfirmations,
|
||||
);
|
||||
// Update local state immediately for responsiveness
|
||||
setShowAutoAcceptIndicator(alwaysAcceptModificationConfirmations);
|
||||
}
|
||||
});
|
||||
|
||||
return showAutoAcceptIndicator;
|
||||
}
|
||||
Reference in New Issue
Block a user