2025-09-06 01:39:02 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* 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';
|
|
|
|
|
import { type AuthType, type EditorType } 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-09-06 01:39:02 -04:00
|
|
|
|
|
|
|
|
export interface UIActions {
|
2025-11-05 11:36:07 -08:00
|
|
|
handleThemeSelect: (themeName: string, scope: LoadableSettingScope) => 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;
|
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;
|
|
|
|
|
setConstrainHeight: (value: boolean) => void;
|
|
|
|
|
onEscapePromptChange: (show: boolean) => void;
|
|
|
|
|
refreshStatic: () => void;
|
|
|
|
|
handleFinalSubmit: (value: string) => void;
|
|
|
|
|
handleClearScreen: () => void;
|
2025-11-18 12:01:16 -05:00
|
|
|
handleProQuotaChoice: (
|
|
|
|
|
choice: 'retry_later' | 'retry_once' | 'retry_always' | 'upgrade',
|
|
|
|
|
) => void;
|
2025-10-15 22:32:50 +05:30
|
|
|
setQueueErrorMessage: (message: string | null) => void;
|
2025-10-16 17:04:13 -07:00
|
|
|
popAllMessages: (onPop: (messages: string | undefined) => void) => void;
|
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;
|
2025-11-19 15:49:39 -08:00
|
|
|
setEmbeddedShellFocused: (value: boolean) => 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;
|
|
|
|
|
};
|