2025-09-06 01:39:02 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
2026-02-19 16:16:03 -08:00
|
|
|
* Copyright 2026 Google LLC
|
2025-09-06 01:39:02 -04:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { createContext, useContext } from 'react';
|
|
|
|
|
import { type Key } from '../hooks/useKeypress.js';
|
|
|
|
|
import { type IdeIntegrationNudgeResult } from '../IdeIntegrationNudge.js';
|
|
|
|
|
import { type FolderTrustChoice } from '../components/FolderTrustDialog.js';
|
2026-01-22 10:30:44 -08:00
|
|
|
import {
|
|
|
|
|
type AuthType,
|
|
|
|
|
type EditorType,
|
|
|
|
|
type AgentDefinition,
|
|
|
|
|
} from '@google/gemini-cli-core';
|
2025-11-05 11:36:07 -08:00
|
|
|
import { type LoadableSettingScope } from '../../config/settings.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
import type { AuthState } from '../types.js';
|
2025-11-14 14:41:53 -08:00
|
|
|
import { type PermissionsDialogProps } from '../components/PermissionsModifyTrustDialog.js';
|
2025-11-25 11:54:09 -07:00
|
|
|
import type { SessionInfo } from '../../utils/sessionUtils.js';
|
2026-01-26 19:49:32 +00:00
|
|
|
import { type NewAgentsChoice } from '../components/NewAgentsNotification.js';
|
2026-02-27 10:15:06 -08:00
|
|
|
import type { OverageMenuIntent, EmptyWalletIntent } from './UIStateContext.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
|
|
|
|
|
export interface UIActions {
|
2026-02-12 11:56:07 -08:00
|
|
|
handleThemeSelect: (
|
|
|
|
|
themeName: string,
|
|
|
|
|
scope: LoadableSettingScope,
|
|
|
|
|
) => Promise<void>;
|
2025-10-20 10:50:09 -07:00
|
|
|
closeThemeDialog: () => void;
|
2025-09-06 01:39:02 -04:00
|
|
|
handleThemeHighlight: (themeName: string | undefined) => void;
|
|
|
|
|
handleAuthSelect: (
|
|
|
|
|
authType: AuthType | undefined,
|
2025-11-05 11:36:07 -08:00
|
|
|
scope: LoadableSettingScope,
|
2025-09-06 01:39:02 -04:00
|
|
|
) => void;
|
|
|
|
|
setAuthState: (state: AuthState) => void;
|
2025-10-16 18:08:42 -04:00
|
|
|
onAuthError: (error: string | null) => void;
|
2025-09-06 01:39:02 -04:00
|
|
|
handleEditorSelect: (
|
|
|
|
|
editorType: EditorType | undefined,
|
2025-11-05 11:36:07 -08:00
|
|
|
scope: LoadableSettingScope,
|
2025-09-06 01:39:02 -04:00
|
|
|
) => void;
|
|
|
|
|
exitEditorDialog: () => void;
|
|
|
|
|
exitPrivacyNotice: () => void;
|
|
|
|
|
closeSettingsDialog: () => void;
|
2025-09-23 12:50:09 -04:00
|
|
|
closeModelDialog: () => void;
|
2026-01-22 10:30:44 -08:00
|
|
|
openAgentConfigDialog: (
|
|
|
|
|
name: string,
|
|
|
|
|
displayName: string,
|
|
|
|
|
definition: AgentDefinition,
|
|
|
|
|
) => void;
|
|
|
|
|
closeAgentConfigDialog: () => void;
|
2025-11-14 14:41:53 -08:00
|
|
|
openPermissionsDialog: (props?: PermissionsDialogProps) => void;
|
2025-09-22 11:45:02 -07:00
|
|
|
closePermissionsDialog: () => void;
|
2025-09-06 01:39:02 -04:00
|
|
|
setShellModeActive: (value: boolean) => void;
|
|
|
|
|
vimHandleInput: (key: Key) => boolean;
|
|
|
|
|
handleIdePromptComplete: (result: IdeIntegrationNudgeResult) => void;
|
|
|
|
|
handleFolderTrustSelect: (choice: FolderTrustChoice) => void;
|
2026-02-19 16:16:03 -08:00
|
|
|
setIsPolicyUpdateDialogOpen: (value: boolean) => void;
|
2025-09-06 01:39:02 -04:00
|
|
|
setConstrainHeight: (value: boolean) => void;
|
|
|
|
|
onEscapePromptChange: (show: boolean) => void;
|
|
|
|
|
refreshStatic: () => void;
|
2026-02-09 12:24:28 -08:00
|
|
|
handleFinalSubmit: (value: string) => Promise<void>;
|
2025-09-06 01:39:02 -04:00
|
|
|
handleClearScreen: () => void;
|
2025-11-18 12:01:16 -05:00
|
|
|
handleProQuotaChoice: (
|
|
|
|
|
choice: 'retry_later' | 'retry_once' | 'retry_always' | 'upgrade',
|
|
|
|
|
) => void;
|
2026-01-20 16:23:01 -08:00
|
|
|
handleValidationChoice: (choice: 'verify' | 'change_auth' | 'cancel') => void;
|
2026-02-27 10:15:06 -08:00
|
|
|
handleOverageMenuChoice: (choice: OverageMenuIntent) => void;
|
|
|
|
|
handleEmptyWalletChoice: (choice: EmptyWalletIntent) => void;
|
2025-11-25 11:54:09 -07:00
|
|
|
openSessionBrowser: () => void;
|
|
|
|
|
closeSessionBrowser: () => void;
|
|
|
|
|
handleResumeSession: (session: SessionInfo) => Promise<void>;
|
|
|
|
|
handleDeleteSession: (session: SessionInfo) => Promise<void>;
|
2025-10-15 22:32:50 +05:30
|
|
|
setQueueErrorMessage: (message: string | null) => void;
|
2025-12-01 17:33:03 -08:00
|
|
|
popAllMessages: () => string | undefined;
|
2025-10-29 18:58:08 -07:00
|
|
|
handleApiKeySubmit: (apiKey: string) => Promise<void>;
|
|
|
|
|
handleApiKeyCancel: () => void;
|
2025-11-18 12:01:16 -05:00
|
|
|
setBannerVisible: (visible: boolean) => void;
|
2026-02-06 11:33:39 -08:00
|
|
|
setShortcutsHelpVisible: (visible: boolean) => void;
|
2026-02-12 14:25:24 -05:00
|
|
|
setCleanUiDetailsVisible: (visible: boolean) => void;
|
|
|
|
|
toggleCleanUiDetailsVisible: () => void;
|
|
|
|
|
revealCleanUiDetailsTemporarily: (durationMs?: number) => void;
|
|
|
|
|
handleWarning: (message: string) => void;
|
2025-11-19 15:49:39 -08:00
|
|
|
setEmbeddedShellFocused: (value: boolean) => void;
|
2026-03-10 17:13:20 -07:00
|
|
|
dismissBackgroundShell: (pid: number) => Promise<void>;
|
2026-01-30 09:53:09 -08:00
|
|
|
setActiveBackgroundShellPid: (pid: number) => void;
|
|
|
|
|
setIsBackgroundShellListOpen: (isOpen: boolean) => void;
|
2026-01-12 15:39:08 -05:00
|
|
|
setAuthContext: (context: { requiresRestart?: boolean }) => void;
|
2026-02-18 14:05:50 -08:00
|
|
|
onHintInput: (char: string) => void;
|
|
|
|
|
onHintBackspace: () => void;
|
|
|
|
|
onHintClear: () => void;
|
|
|
|
|
onHintSubmit: (hint: string) => void;
|
2026-01-16 15:24:53 -05:00
|
|
|
handleRestart: () => void;
|
2026-01-26 19:49:32 +00:00
|
|
|
handleNewAgentsSelect: (choice: NewAgentsChoice) => Promise<void>;
|
2026-02-25 23:38:44 -05:00
|
|
|
getPreferredEditor: () => EditorType | undefined;
|
2026-02-27 10:18:16 -08:00
|
|
|
clearAccountSuspension: () => void;
|
2025-09-06 01:39:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const UIActionsContext = createContext<UIActions | null>(null);
|
|
|
|
|
|
|
|
|
|
export const useUIActions = () => {
|
|
|
|
|
const context = useContext(UIActionsContext);
|
|
|
|
|
if (!context) {
|
|
|
|
|
throw new Error('useUIActions must be used within a UIActionsProvider');
|
|
|
|
|
}
|
|
|
|
|
return context;
|
|
|
|
|
};
|