summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-06-30 15:53:05 -0700
committerGitHub <[email protected]>2025-06-30 22:53:05 +0000
commitdbd626054fe7e8a6b9514c0d1f52dc8beed1b701 (patch)
tree414e367c1b9dad6020642cc544da76802dc53d42
parentf19b9ed4f8444ff766338b1a16f58a05522b3ce1 (diff)
Remove unused method (#2721)
-rw-r--r--packages/cli/src/ui/App.tsx2
-rw-r--r--packages/cli/src/ui/components/AuthDialog.test.tsx13
-rw-r--r--packages/cli/src/ui/components/AuthDialog.tsx7
-rw-r--r--packages/cli/src/ui/hooks/useAuthCommand.ts25
4 files changed, 11 insertions, 36 deletions
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index 66d521fc..a805f721 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -153,7 +153,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
isAuthDialogOpen,
openAuthDialog,
handleAuthSelect,
- handleAuthHighlight,
isAuthenticating,
cancelAuthentication,
} = useAuthCommand(settings, setAuthError, config);
@@ -672,7 +671,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
<Box flexDirection="column">
<AuthDialog
onSelect={handleAuthSelect}
- onHighlight={handleAuthHighlight}
settings={settings}
initialErrorMessage={authError}
/>
diff --git a/packages/cli/src/ui/components/AuthDialog.test.tsx b/packages/cli/src/ui/components/AuthDialog.test.tsx
index 65e35332..15c6d68a 100644
--- a/packages/cli/src/ui/components/AuthDialog.test.tsx
+++ b/packages/cli/src/ui/components/AuthDialog.test.tsx
@@ -31,7 +31,6 @@ describe('AuthDialog', () => {
const { lastFrame } = render(
<AuthDialog
onSelect={() => {}}
- onHighlight={() => {}}
settings={settings}
initialErrorMessage="GEMINI_API_KEY environment variable not found"
/>,
@@ -59,11 +58,7 @@ describe('AuthDialog', () => {
);
const { lastFrame, stdin, unmount } = render(
- <AuthDialog
- onSelect={onSelect}
- onHighlight={() => {}}
- settings={settings}
- />,
+ <AuthDialog onSelect={onSelect} settings={settings} />,
);
await wait();
@@ -96,11 +91,7 @@ describe('AuthDialog', () => {
);
const { stdin, unmount } = render(
- <AuthDialog
- onSelect={onSelect}
- onHighlight={() => {}}
- settings={settings}
- />,
+ <AuthDialog onSelect={onSelect} settings={settings} />,
);
await wait();
diff --git a/packages/cli/src/ui/components/AuthDialog.tsx b/packages/cli/src/ui/components/AuthDialog.tsx
index 2a29bbd3..78b825e6 100644
--- a/packages/cli/src/ui/components/AuthDialog.tsx
+++ b/packages/cli/src/ui/components/AuthDialog.tsx
@@ -13,15 +13,13 @@ import { AuthType } from '@google/gemini-cli-core';
import { validateAuthMethod } from '../../config/auth.js';
interface AuthDialogProps {
- onSelect: (authMethod: string | undefined, scope: SettingScope) => void;
- onHighlight: (authMethod: string | undefined) => void;
+ onSelect: (authMethod: AuthType | undefined, scope: SettingScope) => void;
settings: LoadedSettings;
initialErrorMessage?: string | null;
}
export function AuthDialog({
onSelect,
- onHighlight,
settings,
initialErrorMessage,
}: AuthDialogProps): React.JSX.Element {
@@ -45,7 +43,7 @@ export function AuthDialog({
initialAuthIndex = 0;
}
- const handleAuthSelect = (authMethod: string) => {
+ const handleAuthSelect = (authMethod: AuthType) => {
const error = validateAuthMethod(authMethod);
if (error) {
setErrorMessage(error);
@@ -81,7 +79,6 @@ export function AuthDialog({
items={items}
initialIndex={initialAuthIndex}
onSelect={handleAuthSelect}
- onHighlight={onHighlight}
isFocused={true}
/>
{errorMessage && (
diff --git a/packages/cli/src/ui/hooks/useAuthCommand.ts b/packages/cli/src/ui/hooks/useAuthCommand.ts
index 766ebe2b..c19a91b6 100644
--- a/packages/cli/src/ui/hooks/useAuthCommand.ts
+++ b/packages/cli/src/ui/hooks/useAuthCommand.ts
@@ -13,11 +13,6 @@ import {
getErrorMessage,
} from '@google/gemini-cli-core';
-async function performAuthFlow(authMethod: AuthType, config: Config) {
- await config.refreshAuth(authMethod);
- console.log(`Authenticated via "${authMethod}".`);
-}
-
export const useAuthCommand = (
settings: LoadedSettings,
setAuthError: (error: string | null) => void,
@@ -35,16 +30,15 @@ export const useAuthCommand = (
useEffect(() => {
const authFlow = async () => {
- if (isAuthDialogOpen || !settings.merged.selectedAuthType) {
+ const authType = settings.merged.selectedAuthType;
+ if (isAuthDialogOpen || !authType) {
return;
}
try {
setIsAuthenticating(true);
- await performAuthFlow(
- settings.merged.selectedAuthType as AuthType,
- config,
- );
+ await config.refreshAuth(authType);
+ console.log(`Authenticated via "${authType}".`);
} catch (e) {
setAuthError(`Failed to login. Message: ${getErrorMessage(e)}`);
openAuthDialog();
@@ -57,10 +51,10 @@ export const useAuthCommand = (
}, [isAuthDialogOpen, settings, config, setAuthError, openAuthDialog]);
const handleAuthSelect = useCallback(
- async (authMethod: string | undefined, scope: SettingScope) => {
- if (authMethod) {
+ async (authType: AuthType | undefined, scope: SettingScope) => {
+ if (authType) {
await clearCachedCredentialFile();
- settings.setValue(scope, 'selectedAuthType', authMethod);
+ settings.setValue(scope, 'selectedAuthType', authType);
}
setIsAuthDialogOpen(false);
setAuthError(null);
@@ -68,10 +62,6 @@ export const useAuthCommand = (
[settings, setAuthError],
);
- const handleAuthHighlight = useCallback((_authMethod: string | undefined) => {
- // For now, we don't do anything on highlight.
- }, []);
-
const cancelAuthentication = useCallback(() => {
setIsAuthenticating(false);
}, []);
@@ -80,7 +70,6 @@ export const useAuthCommand = (
isAuthDialogOpen,
openAuthDialog,
handleAuthSelect,
- handleAuthHighlight,
isAuthenticating,
cancelAuthentication,
};