2026-01-12 15:39:08 -05:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2026-01-27 12:14:11 -05:00
|
|
|
import { type Config } from '@google/gemini-cli-core';
|
2026-01-12 15:39:08 -05:00
|
|
|
import { Box, Text } from 'ink';
|
|
|
|
|
import { theme } from '../semantic-colors.js';
|
|
|
|
|
import { useKeypress } from '../hooks/useKeypress.js';
|
2026-03-03 22:18:12 -08:00
|
|
|
import { relaunchApp } from '../../utils/processUtils.js';
|
2026-01-12 15:39:08 -05:00
|
|
|
|
|
|
|
|
interface LoginWithGoogleRestartDialogProps {
|
|
|
|
|
onDismiss: () => void;
|
2026-01-27 12:14:11 -05:00
|
|
|
config: Config;
|
2026-01-12 15:39:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const LoginWithGoogleRestartDialog = ({
|
|
|
|
|
onDismiss,
|
2026-01-27 12:14:11 -05:00
|
|
|
config,
|
2026-01-12 15:39:08 -05:00
|
|
|
}: LoginWithGoogleRestartDialogProps) => {
|
|
|
|
|
useKeypress(
|
|
|
|
|
(key) => {
|
|
|
|
|
if (key.name === 'escape') {
|
|
|
|
|
onDismiss();
|
2026-01-27 14:26:00 -08:00
|
|
|
return true;
|
2026-01-12 15:39:08 -05:00
|
|
|
} else if (key.name === 'r' || key.name === 'R') {
|
|
|
|
|
setTimeout(async () => {
|
2026-01-27 12:14:11 -05:00
|
|
|
if (process.send) {
|
|
|
|
|
const remoteSettings = config.getRemoteAdminSettings();
|
|
|
|
|
if (remoteSettings) {
|
|
|
|
|
process.send({
|
|
|
|
|
type: 'admin-settings-update',
|
|
|
|
|
settings: remoteSettings,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-03 22:18:12 -08:00
|
|
|
await relaunchApp();
|
2026-01-12 15:39:08 -05:00
|
|
|
}, 100);
|
2026-01-27 14:26:00 -08:00
|
|
|
return true;
|
2026-01-12 15:39:08 -05:00
|
|
|
}
|
2026-01-27 14:26:00 -08:00
|
|
|
return false;
|
2026-01-12 15:39:08 -05:00
|
|
|
},
|
|
|
|
|
{ isActive: true },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const message =
|
2026-03-10 12:10:26 -07:00
|
|
|
"You've successfully signed in with Google. Gemini CLI needs to be restarted.";
|
2026-01-12 15:39:08 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box borderStyle="round" borderColor={theme.status.warning} paddingX={1}>
|
|
|
|
|
<Text color={theme.status.warning}>
|
2026-03-10 12:10:26 -07:00
|
|
|
{message} Press R to restart, or Esc to choose a different
|
|
|
|
|
authentication method.
|
2026-01-12 15:39:08 -05:00
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|