mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-19 19:02:48 +00:00
fix(cli): allow switching approval mode by clicking the indicator
This PR implements click-to-change-mode functionality for the `ApprovalModeIndicator` component, as requested in issue #27035. Added JSDoc and inline comments with links to https://github.com/google-gemini/gemini-cli/issues/27035 in `ApprovalModeIndicator.tsx` and `useApprovalModeIndicator.ts` to address maintainer feedback. Changes: - Refactored `useApprovalModeIndicator` hook to return an object with `cycleApprovalMode` and `toggleYolo` functions. - Added `cycleApprovalMode` to `UIActions` context to allow components to trigger mode changes. - Updated `AppContainer.tsx` to expose `cycleApprovalMode` via `uiActions`. - Updated `ApprovalModeIndicator.tsx` to use `useMouseClick` and call `cycleApprovalMode` on click. - Added a "click or " hint to the indicator text when mouse mode is enabled. - Updated unit tests for `useApprovalModeIndicator` and `ApprovalModeIndicator`. CC: @NTaylorMullen @gundermanc Closes: #27035
This commit is contained in:
@@ -28,6 +28,10 @@ export const ApprovalModeIndicator: FC<ApprovalModeIndicatorProps> = ({
|
||||
const { cycleApprovalMode } = useUIActions();
|
||||
const boxRef = useRef(null);
|
||||
|
||||
/**
|
||||
* Click handler for switching approval modes.
|
||||
* See: https://github.com/google-gemini/gemini-cli/issues/27035
|
||||
*/
|
||||
useMouseClick(boxRef, () => {
|
||||
cycleApprovalMode();
|
||||
});
|
||||
|
||||
@@ -91,6 +91,10 @@ export function useApprovalModeIndicator({
|
||||
}
|
||||
}, [config, addItem, onApprovalModeChange]);
|
||||
|
||||
/**
|
||||
* Cycles through available approval modes.
|
||||
* See: https://github.com/google-gemini/gemini-cli/issues/27035
|
||||
*/
|
||||
const cycleApprovalMode = useCallback(() => {
|
||||
const currentMode = config.getApprovalMode();
|
||||
let nextApprovalMode: ApprovalMode | undefined;
|
||||
|
||||
Reference in New Issue
Block a user