fix(admin): fix a few bugs related to admin controls (#17590)

This commit is contained in:
Shreya Keshive
2026-01-27 12:14:11 -05:00
committed by GitHub
parent a63277c1d0
commit 7904f973a0
8 changed files with 191 additions and 22 deletions

View File

@@ -1888,6 +1888,15 @@ Logging in with Google... Restarting Gemini CLI to continue.
setEmbeddedShellFocused,
setAuthContext,
handleRestart: async () => {
if (process.send) {
const remoteSettings = config.getRemoteAdminSettings();
if (remoteSettings) {
process.send({
type: 'admin-settings-update',
settings: remoteSettings,
});
}
}
await runExitCleanup();
process.exit(RELAUNCH_EXIT_CODE);
},
@@ -1963,6 +1972,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
setAuthContext({});
setAuthState(AuthState.Updating);
}}
config={config}
/>
);
}

View File

@@ -10,6 +10,7 @@ import { LoginWithGoogleRestartDialog } from './LoginWithGoogleRestartDialog.js'
import { useKeypress } from '../hooks/useKeypress.js';
import { runExitCleanup } from '../../utils/cleanup.js';
import { RELAUNCH_EXIT_CODE } from '../../utils/processUtils.js';
import { type Config } from '@google/gemini-cli-core';
// Mocks
vi.mock('../hooks/useKeypress.js', () => ({
@@ -29,6 +30,10 @@ describe('LoginWithGoogleRestartDialog', () => {
.spyOn(process, 'exit')
.mockImplementation(() => undefined as never);
const mockConfig = {
getRemoteAdminSettings: vi.fn(),
} as unknown as Config;
beforeEach(() => {
vi.clearAllMocks();
exitSpy.mockClear();
@@ -37,13 +42,21 @@ describe('LoginWithGoogleRestartDialog', () => {
it('renders correctly', () => {
const { lastFrame } = render(
<LoginWithGoogleRestartDialog onDismiss={onDismiss} />,
<LoginWithGoogleRestartDialog
onDismiss={onDismiss}
config={mockConfig}
/>,
);
expect(lastFrame()).toMatchSnapshot();
});
it('calls onDismiss when escape is pressed', () => {
render(<LoginWithGoogleRestartDialog onDismiss={onDismiss} />);
render(
<LoginWithGoogleRestartDialog
onDismiss={onDismiss}
config={mockConfig}
/>,
);
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
keypressHandler({
@@ -62,7 +75,12 @@ describe('LoginWithGoogleRestartDialog', () => {
async (keyName) => {
vi.useFakeTimers();
render(<LoginWithGoogleRestartDialog onDismiss={onDismiss} />);
render(
<LoginWithGoogleRestartDialog
onDismiss={onDismiss}
config={mockConfig}
/>,
);
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
keypressHandler({

View File

@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { type Config } from '@google/gemini-cli-core';
import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { useKeypress } from '../hooks/useKeypress.js';
@@ -12,10 +13,12 @@ import { RELAUNCH_EXIT_CODE } from '../../utils/processUtils.js';
interface LoginWithGoogleRestartDialogProps {
onDismiss: () => void;
config: Config;
}
export const LoginWithGoogleRestartDialog = ({
onDismiss,
config,
}: LoginWithGoogleRestartDialogProps) => {
useKeypress(
(key) => {
@@ -23,6 +26,15 @@ export const LoginWithGoogleRestartDialog = ({
onDismiss();
} else if (key.name === 'r' || key.name === 'R') {
setTimeout(async () => {
if (process.send) {
const remoteSettings = config.getRemoteAdminSettings();
if (remoteSettings) {
process.send({
type: 'admin-settings-update',
settings: remoteSettings,
});
}
}
await runExitCleanup();
process.exit(RELAUNCH_EXIT_CODE);
}, 100);