mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 08:24:10 -07:00
refactor(cli): keyboard handling and AskUserDialog (#17414)
This commit is contained in:
@@ -30,6 +30,7 @@ export interface UseSelectionListOptions<T> {
|
||||
showNumbers?: boolean;
|
||||
wrapAround?: boolean;
|
||||
focusKey?: string;
|
||||
priority?: boolean;
|
||||
}
|
||||
|
||||
export interface UseSelectionListResult {
|
||||
@@ -288,6 +289,7 @@ export function useSelectionList<T>({
|
||||
showNumbers = false,
|
||||
wrapAround = true,
|
||||
focusKey,
|
||||
priority,
|
||||
}: UseSelectionListOptions<T>): UseSelectionListResult {
|
||||
const baseItems = toBaseItems(items);
|
||||
|
||||
@@ -397,17 +399,17 @@ export function useSelectionList<T>({
|
||||
|
||||
if (keyMatchers[Command.DIALOG_NAVIGATION_UP](key)) {
|
||||
dispatch({ type: 'MOVE_UP' });
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyMatchers[Command.DIALOG_NAVIGATION_DOWN](key)) {
|
||||
dispatch({ type: 'MOVE_DOWN' });
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyMatchers[Command.RETURN](key)) {
|
||||
dispatch({ type: 'SELECT_CURRENT' });
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle numeric input for quick selection
|
||||
@@ -426,7 +428,7 @@ export function useSelectionList<T>({
|
||||
numberInputTimer.current = setTimeout(() => {
|
||||
numberInputRef.current = '';
|
||||
}, NUMBER_INPUT_TIMEOUT_MS);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetIndex >= 0 && targetIndex < itemsLength) {
|
||||
@@ -455,12 +457,17 @@ export function useSelectionList<T>({
|
||||
// Number is out of bounds
|
||||
numberInputRef.current = '';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[dispatch, itemsLength, showNumbers],
|
||||
);
|
||||
|
||||
useKeypress(handleKeypress, { isActive: !!(isFocused && itemsLength > 0) });
|
||||
useKeypress(handleKeypress, {
|
||||
isActive: !!(isFocused && itemsLength > 0),
|
||||
priority,
|
||||
});
|
||||
|
||||
const setActiveIndex = (index: number) => {
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user