Remove unused method (#2721)

This commit is contained in:
Tommaso Sciortino 2025-06-30 15:53:05 -07:00 committed by GitHub
parent f19b9ed4f8
commit dbd626054f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 36 deletions

View File

@ -153,7 +153,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
isAuthDialogOpen, isAuthDialogOpen,
openAuthDialog, openAuthDialog,
handleAuthSelect, handleAuthSelect,
handleAuthHighlight,
isAuthenticating, isAuthenticating,
cancelAuthentication, cancelAuthentication,
} = useAuthCommand(settings, setAuthError, config); } = useAuthCommand(settings, setAuthError, config);
@ -672,7 +671,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
<Box flexDirection="column"> <Box flexDirection="column">
<AuthDialog <AuthDialog
onSelect={handleAuthSelect} onSelect={handleAuthSelect}
onHighlight={handleAuthHighlight}
settings={settings} settings={settings}
initialErrorMessage={authError} initialErrorMessage={authError}
/> />

View File

@ -31,7 +31,6 @@ describe('AuthDialog', () => {
const { lastFrame } = render( const { lastFrame } = render(
<AuthDialog <AuthDialog
onSelect={() => {}} onSelect={() => {}}
onHighlight={() => {}}
settings={settings} settings={settings}
initialErrorMessage="GEMINI_API_KEY environment variable not found" initialErrorMessage="GEMINI_API_KEY environment variable not found"
/>, />,
@ -59,11 +58,7 @@ describe('AuthDialog', () => {
); );
const { lastFrame, stdin, unmount } = render( const { lastFrame, stdin, unmount } = render(
<AuthDialog <AuthDialog onSelect={onSelect} settings={settings} />,
onSelect={onSelect}
onHighlight={() => {}}
settings={settings}
/>,
); );
await wait(); await wait();
@ -96,11 +91,7 @@ describe('AuthDialog', () => {
); );
const { stdin, unmount } = render( const { stdin, unmount } = render(
<AuthDialog <AuthDialog onSelect={onSelect} settings={settings} />,
onSelect={onSelect}
onHighlight={() => {}}
settings={settings}
/>,
); );
await wait(); await wait();

View File

@ -13,15 +13,13 @@ import { AuthType } from '@google/gemini-cli-core';
import { validateAuthMethod } from '../../config/auth.js'; import { validateAuthMethod } from '../../config/auth.js';
interface AuthDialogProps { interface AuthDialogProps {
onSelect: (authMethod: string | undefined, scope: SettingScope) => void; onSelect: (authMethod: AuthType | undefined, scope: SettingScope) => void;
onHighlight: (authMethod: string | undefined) => void;
settings: LoadedSettings; settings: LoadedSettings;
initialErrorMessage?: string | null; initialErrorMessage?: string | null;
} }
export function AuthDialog({ export function AuthDialog({
onSelect, onSelect,
onHighlight,
settings, settings,
initialErrorMessage, initialErrorMessage,
}: AuthDialogProps): React.JSX.Element { }: AuthDialogProps): React.JSX.Element {
@ -45,7 +43,7 @@ export function AuthDialog({
initialAuthIndex = 0; initialAuthIndex = 0;
} }
const handleAuthSelect = (authMethod: string) => { const handleAuthSelect = (authMethod: AuthType) => {
const error = validateAuthMethod(authMethod); const error = validateAuthMethod(authMethod);
if (error) { if (error) {
setErrorMessage(error); setErrorMessage(error);
@ -81,7 +79,6 @@ export function AuthDialog({
items={items} items={items}
initialIndex={initialAuthIndex} initialIndex={initialAuthIndex}
onSelect={handleAuthSelect} onSelect={handleAuthSelect}
onHighlight={onHighlight}
isFocused={true} isFocused={true}
/> />
{errorMessage && ( {errorMessage && (

View File

@ -13,11 +13,6 @@ import {
getErrorMessage, getErrorMessage,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
async function performAuthFlow(authMethod: AuthType, config: Config) {
await config.refreshAuth(authMethod);
console.log(`Authenticated via "${authMethod}".`);
}
export const useAuthCommand = ( export const useAuthCommand = (
settings: LoadedSettings, settings: LoadedSettings,
setAuthError: (error: string | null) => void, setAuthError: (error: string | null) => void,
@ -35,16 +30,15 @@ export const useAuthCommand = (
useEffect(() => { useEffect(() => {
const authFlow = async () => { const authFlow = async () => {
if (isAuthDialogOpen || !settings.merged.selectedAuthType) { const authType = settings.merged.selectedAuthType;
if (isAuthDialogOpen || !authType) {
return; return;
} }
try { try {
setIsAuthenticating(true); setIsAuthenticating(true);
await performAuthFlow( await config.refreshAuth(authType);
settings.merged.selectedAuthType as AuthType, console.log(`Authenticated via "${authType}".`);
config,
);
} catch (e) { } catch (e) {
setAuthError(`Failed to login. Message: ${getErrorMessage(e)}`); setAuthError(`Failed to login. Message: ${getErrorMessage(e)}`);
openAuthDialog(); openAuthDialog();
@ -57,10 +51,10 @@ export const useAuthCommand = (
}, [isAuthDialogOpen, settings, config, setAuthError, openAuthDialog]); }, [isAuthDialogOpen, settings, config, setAuthError, openAuthDialog]);
const handleAuthSelect = useCallback( const handleAuthSelect = useCallback(
async (authMethod: string | undefined, scope: SettingScope) => { async (authType: AuthType | undefined, scope: SettingScope) => {
if (authMethod) { if (authType) {
await clearCachedCredentialFile(); await clearCachedCredentialFile();
settings.setValue(scope, 'selectedAuthType', authMethod); settings.setValue(scope, 'selectedAuthType', authType);
} }
setIsAuthDialogOpen(false); setIsAuthDialogOpen(false);
setAuthError(null); setAuthError(null);
@ -68,10 +62,6 @@ export const useAuthCommand = (
[settings, setAuthError], [settings, setAuthError],
); );
const handleAuthHighlight = useCallback((_authMethod: string | undefined) => {
// For now, we don't do anything on highlight.
}, []);
const cancelAuthentication = useCallback(() => { const cancelAuthentication = useCallback(() => {
setIsAuthenticating(false); setIsAuthenticating(false);
}, []); }, []);
@ -80,7 +70,6 @@ export const useAuthCommand = (
isAuthDialogOpen, isAuthDialogOpen,
openAuthDialog, openAuthDialog,
handleAuthSelect, handleAuthSelect,
handleAuthHighlight,
isAuthenticating, isAuthenticating,
cancelAuthentication, cancelAuthentication,
}; };