diff options
| author | Jacob Richman <[email protected]> | 2025-08-12 14:05:49 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-12 21:05:49 +0000 |
| commit | d219f9013206aad5a1361e436ad4a45114e9cd49 (patch) | |
| tree | 58216dc659e809bc896b03de21a9a1c713126d6b /packages/cli/src/ui/components/AuthDialog.tsx | |
| parent | 74fd0841d0d7148127e586fce4c550a01ff40e90 (diff) | |
Switch from useInput to useKeypress. (#6056)
Diffstat (limited to 'packages/cli/src/ui/components/AuthDialog.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/AuthDialog.tsx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/packages/cli/src/ui/components/AuthDialog.tsx b/packages/cli/src/ui/components/AuthDialog.tsx index ae076ee7..1262f894 100644 --- a/packages/cli/src/ui/components/AuthDialog.tsx +++ b/packages/cli/src/ui/components/AuthDialog.tsx @@ -5,12 +5,13 @@ */ import React, { useState } from 'react'; -import { Box, Text, useInput } from 'ink'; +import { Box, Text } from 'ink'; import { Colors } from '../colors.js'; import { RadioButtonSelect } from './shared/RadioButtonSelect.js'; import { LoadedSettings, SettingScope } from '../../config/settings.js'; import { AuthType } from '@google/gemini-cli-core'; import { validateAuthMethod } from '../../config/auth.js'; +import { useKeypress } from '../hooks/useKeypress.js'; interface AuthDialogProps { onSelect: (authMethod: AuthType | undefined, scope: SettingScope) => void; @@ -108,23 +109,26 @@ export function AuthDialog({ } }; - useInput((_input, key) => { - if (key.escape) { - // Prevent exit if there is an error message. - // This means they user is not authenticated yet. - if (errorMessage) { - return; + useKeypress( + (key) => { + if (key.name === 'escape') { + // Prevent exit if there is an error message. + // This means they user is not authenticated yet. + if (errorMessage) { + return; + } + if (settings.merged.selectedAuthType === undefined) { + // Prevent exiting if no auth method is set + setErrorMessage( + 'You must select an auth method to proceed. Press Ctrl+C twice to exit.', + ); + return; + } + onSelect(undefined, SettingScope.User); } - if (settings.merged.selectedAuthType === undefined) { - // Prevent exiting if no auth method is set - setErrorMessage( - 'You must select an auth method to proceed. Press Ctrl+C twice to exit.', - ); - return; - } - onSelect(undefined, SettingScope.User); - } - }); + }, + { isActive: true }, + ); return ( <Box |
