@google/gemini-cli 0.5.0-nightly.20250906.968e9389 → 0.5.0-nightly.20250909.2b05cf3b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/google-gemini-cli-0.3.4.tgz +0 -0
- package/dist/package.json +2 -2
- package/dist/src/config/config.js +10 -10
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.js +2 -2
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +20 -4
- package/dist/src/config/settingsSchema.js +13 -1
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/settingsSchema.test.js +62 -55
- package/dist/src/config/settingsSchema.test.js.map +1 -1
- package/dist/src/core/auth.d.ts +13 -0
- package/dist/src/core/auth.js +27 -0
- package/dist/src/core/auth.js.map +1 -0
- package/dist/src/core/initializer.d.ts +21 -0
- package/dist/src/core/initializer.js +28 -0
- package/dist/src/core/initializer.js.map +1 -0
- package/dist/src/core/theme.d.ts +12 -0
- package/dist/src/core/theme.js +20 -0
- package/dist/src/core/theme.js.map +1 -0
- package/dist/src/gemini.d.ts +2 -1
- package/dist/src/gemini.js +41 -44
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +91 -14
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/services/BuiltinCommandLoader.test.js +16 -17
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/services/CommandService.js +1 -1
- package/dist/src/services/CommandService.js.map +1 -1
- package/dist/src/services/CommandService.test.js +0 -22
- package/dist/src/services/CommandService.test.js.map +1 -1
- package/dist/src/ui/App.d.ts +1 -10
- package/dist/src/ui/App.js +13 -697
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/AppContainer.d.ts +17 -0
- package/dist/src/ui/AppContainer.js +836 -0
- package/dist/src/ui/AppContainer.js.map +1 -0
- package/dist/src/ui/AppContainer.test.d.ts +6 -0
- package/dist/src/ui/AppContainer.test.js +378 -0
- package/dist/src/ui/AppContainer.test.js.map +1 -0
- package/dist/src/ui/commands/corgiCommand.js +1 -1
- package/dist/src/ui/commands/corgiCommand.js.map +1 -1
- package/dist/src/ui/components/AppHeader.d.ts +10 -0
- package/dist/src/ui/components/AppHeader.js +22 -0
- package/dist/src/ui/components/AppHeader.js.map +1 -0
- package/dist/src/ui/components/Composer.d.ts +6 -0
- package/dist/src/ui/components/Composer.js +69 -0
- package/dist/src/ui/components/Composer.js.map +1 -0
- package/dist/src/ui/components/Composer.test.d.ts +6 -0
- package/dist/src/ui/components/Composer.test.js +340 -0
- package/dist/src/ui/components/Composer.test.js.map +1 -0
- package/dist/src/ui/components/ConfigInitDisplay.d.ts +6 -0
- package/dist/src/ui/components/ConfigInitDisplay.js +37 -0
- package/dist/src/ui/components/ConfigInitDisplay.js.map +1 -0
- package/dist/src/ui/components/DialogManager.d.ts +6 -0
- package/dist/src/ui/components/DialogManager.js +81 -0
- package/dist/src/ui/components/DialogManager.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +1 -5
- package/dist/src/ui/components/Footer.js +3 -4
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +5 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.js +5 -1
- package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -1
- package/dist/src/ui/components/Help.d.ts +1 -1
- package/dist/src/ui/components/Help.js +7 -2
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/Help.test.d.ts +6 -0
- package/dist/src/ui/components/Help.test.js +57 -0
- package/dist/src/ui/components/Help.test.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +0 -2
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +22 -0
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/MainContent.d.ts +6 -0
- package/dist/src/ui/components/MainContent.js +23 -0
- package/dist/src/ui/components/MainContent.js.map +1 -0
- package/dist/src/ui/components/Notifications.d.ts +6 -0
- package/dist/src/ui/components/Notifications.js +23 -0
- package/dist/src/ui/components/Notifications.js.map +1 -0
- package/dist/src/ui/components/ProQuotaDialog.d.ts +2 -2
- package/dist/src/ui/components/ProQuotaDialog.js +2 -2
- package/dist/src/ui/components/ProQuotaDialog.js.map +1 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +3 -3
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +1 -1
- package/dist/src/ui/components/QuittingDisplay.d.ts +6 -0
- package/dist/src/ui/components/QuittingDisplay.js +20 -0
- package/dist/src/ui/components/QuittingDisplay.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.js +20 -5
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +144 -79
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.d.ts +2 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +6 -12
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +10 -27
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.test.d.ts +6 -0
- package/dist/src/ui/components/ThemeDialog.test.js +65 -0
- package/dist/src/ui/components/ThemeDialog.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +0 -2
- package/dist/src/ui/components/messages/ToolGroupMessage.js +5 -3
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js +17 -15
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -1
- package/dist/src/ui/components/shared/ScopeSelector.d.ts +19 -0
- package/dist/src/ui/components/shared/ScopeSelector.js +11 -0
- package/dist/src/ui/components/shared/ScopeSelector.js.map +1 -0
- package/dist/src/ui/contexts/AppContext.d.ts +11 -0
- package/dist/src/ui/contexts/AppContext.js +15 -0
- package/dist/src/ui/contexts/AppContext.js.map +1 -0
- package/dist/src/ui/contexts/ConfigContext.d.ts +9 -0
- package/dist/src/ui/contexts/ConfigContext.js +16 -0
- package/dist/src/ui/contexts/ConfigContext.js.map +1 -0
- package/dist/src/ui/contexts/KeypressContext.js +7 -2
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/UIActionsContext.d.ts +36 -0
- package/dist/src/ui/contexts/UIActionsContext.js +20 -0
- package/dist/src/ui/contexts/UIActionsContext.js.map +1 -0
- package/dist/src/ui/contexts/UIStateContext.d.ts +91 -0
- package/dist/src/ui/contexts/UIStateContext.js +15 -0
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js +7 -5
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +13 -2
- package/dist/src/ui/hooks/slashCommandProcessor.js +13 -26
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +1 -1
- package/dist/src/ui/hooks/useFolderTrust.js +12 -13
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.d.ts +2 -1
- package/dist/src/ui/hooks/useMessageQueue.js +5 -3
- package/dist/src/ui/hooks/useMessageQueue.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.test.js +9 -0
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.d.ts +21 -0
- package/dist/src/ui/hooks/useQuotaAndFallback.js +122 -0
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +1 -0
- package/dist/src/ui/hooks/useQuotaAndFallback.test.d.ts +6 -0
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +269 -0
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.js +3 -2
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.js +155 -268
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useThemeCommand.d.ts +1 -1
- package/dist/src/ui/hooks/useThemeCommand.js +3 -14
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
- package/dist/src/ui/types.d.ts +11 -1
- package/dist/src/ui/types.js +1 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/kittyProtocolDetector.js +39 -29
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -1
- package/dist/src/utils/settingsUtils.d.ts +16 -6
- package/dist/src/utils/settingsUtils.js +35 -25
- package/dist/src/utils/settingsUtils.js.map +1 -1
- package/dist/src/utils/settingsUtils.test.js +418 -156
- package/dist/src/utils/settingsUtils.test.js.map +1 -1
- package/dist/src/zed-integration/schema.d.ts +596 -596
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/google-gemini-cli-0.3.1.tgz +0 -0
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
import { useMemo, useState, useCallback, useEffect, useRef } from 'react';
|
|
8
|
+
import { measureElement } from 'ink';
|
|
9
|
+
import { App } from './App.js';
|
|
10
|
+
import { AppContext } from './contexts/AppContext.js';
|
|
11
|
+
import { UIStateContext } from './contexts/UIStateContext.js';
|
|
12
|
+
import { UIActionsContext, } from './contexts/UIActionsContext.js';
|
|
13
|
+
import { ConfigContext } from './contexts/ConfigContext.js';
|
|
14
|
+
import { ToolCallStatus, AuthState, } from './types.js';
|
|
15
|
+
import { MessageType, StreamingState } from './types.js';
|
|
16
|
+
import { DEFAULT_GEMINI_FLASH_MODEL, IdeClient, ideContext, getErrorMessage, getAllGeminiMdFilenames, AuthType, clearCachedCredentialFile, } from '@google/gemini-cli-core';
|
|
17
|
+
import { validateAuthMethod } from '../config/auth.js';
|
|
18
|
+
import { loadHierarchicalGeminiMemory } from '../config/config.js';
|
|
19
|
+
import process from 'node:process';
|
|
20
|
+
import { useHistory } from './hooks/useHistoryManager.js';
|
|
21
|
+
import { useThemeCommand } from './hooks/useThemeCommand.js';
|
|
22
|
+
import { useAuthCommand } from './auth/useAuth.js';
|
|
23
|
+
import { useQuotaAndFallback } from './hooks/useQuotaAndFallback.js';
|
|
24
|
+
import { useEditorSettings } from './hooks/useEditorSettings.js';
|
|
25
|
+
import { useSettingsCommand } from './hooks/useSettingsCommand.js';
|
|
26
|
+
import { useSlashCommandProcessor } from './hooks/slashCommandProcessor.js';
|
|
27
|
+
import { useVimMode } from './contexts/VimModeContext.js';
|
|
28
|
+
import { useConsoleMessages } from './hooks/useConsoleMessages.js';
|
|
29
|
+
import { useTerminalSize } from './hooks/useTerminalSize.js';
|
|
30
|
+
import { useStdin, useStdout } from 'ink';
|
|
31
|
+
import ansiEscapes from 'ansi-escapes';
|
|
32
|
+
import * as fs from 'node:fs';
|
|
33
|
+
import { useTextBuffer } from './components/shared/text-buffer.js';
|
|
34
|
+
import { useLogger } from './hooks/useLogger.js';
|
|
35
|
+
import { useGeminiStream } from './hooks/useGeminiStream.js';
|
|
36
|
+
import { useVim } from './hooks/vim.js';
|
|
37
|
+
import { SettingScope } from '../config/settings.js';
|
|
38
|
+
import {} from '../core/initializer.js';
|
|
39
|
+
import { useFocus } from './hooks/useFocus.js';
|
|
40
|
+
import { useBracketedPaste } from './hooks/useBracketedPaste.js';
|
|
41
|
+
import { useKeypress } from './hooks/useKeypress.js';
|
|
42
|
+
import { keyMatchers, Command } from './keyMatchers.js';
|
|
43
|
+
import { useLoadingIndicator } from './hooks/useLoadingIndicator.js';
|
|
44
|
+
import { useFolderTrust } from './hooks/useFolderTrust.js';
|
|
45
|
+
import { useIdeTrustListener } from './hooks/useIdeTrustListener.js';
|
|
46
|
+
import {} from './IdeIntegrationNudge.js';
|
|
47
|
+
import { appEvents, AppEvent } from '../utils/events.js';
|
|
48
|
+
import {} from './utils/updateCheck.js';
|
|
49
|
+
import { setUpdateHandler } from '../utils/handleAutoUpdate.js';
|
|
50
|
+
import { ConsolePatcher } from './utils/ConsolePatcher.js';
|
|
51
|
+
import { registerCleanup, runExitCleanup } from '../utils/cleanup.js';
|
|
52
|
+
import { useMessageQueue } from './hooks/useMessageQueue.js';
|
|
53
|
+
import { useAutoAcceptIndicator } from './hooks/useAutoAcceptIndicator.js';
|
|
54
|
+
import { useWorkspaceMigration } from './hooks/useWorkspaceMigration.js';
|
|
55
|
+
import { useSessionStats } from './contexts/SessionContext.js';
|
|
56
|
+
import { useGitBranchName } from './hooks/useGitBranchName.js';
|
|
57
|
+
const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
|
|
58
|
+
function isToolExecuting(pendingHistoryItems) {
|
|
59
|
+
return pendingHistoryItems.some((item) => {
|
|
60
|
+
if (item && item.type === 'tool_group') {
|
|
61
|
+
return item.tools.some((tool) => ToolCallStatus.Executing === tool.status);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export const AppContainer = (props) => {
|
|
67
|
+
const { settings, config, initializationResult } = props;
|
|
68
|
+
const historyManager = useHistory();
|
|
69
|
+
const [corgiMode, setCorgiMode] = useState(false);
|
|
70
|
+
const [debugMessage, setDebugMessage] = useState('');
|
|
71
|
+
const [quittingMessages, setQuittingMessages] = useState(null);
|
|
72
|
+
const [showPrivacyNotice, setShowPrivacyNotice] = useState(false);
|
|
73
|
+
const [themeError, setThemeError] = useState(initializationResult.themeError);
|
|
74
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
75
|
+
const [geminiMdFileCount, setGeminiMdFileCount] = useState(initializationResult.geminiMdFileCount);
|
|
76
|
+
const [shellModeActive, setShellModeActive] = useState(false);
|
|
77
|
+
const [modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError] = useState(false);
|
|
78
|
+
const [historyRemountKey, setHistoryRemountKey] = useState(0);
|
|
79
|
+
const [updateInfo, setUpdateInfo] = useState(null);
|
|
80
|
+
const [isTrustedFolder, setIsTrustedFolder] = useState(config.isTrustedFolder());
|
|
81
|
+
// Helper to determine the effective model, considering the fallback state.
|
|
82
|
+
const getEffectiveModel = useCallback(() => {
|
|
83
|
+
if (config.isInFallbackMode()) {
|
|
84
|
+
return DEFAULT_GEMINI_FLASH_MODEL;
|
|
85
|
+
}
|
|
86
|
+
return config.getModel();
|
|
87
|
+
}, [config]);
|
|
88
|
+
const [currentModel, setCurrentModel] = useState(getEffectiveModel());
|
|
89
|
+
const [userTier, setUserTier] = useState(undefined);
|
|
90
|
+
const [isConfigInitialized, setConfigInitialized] = useState(false);
|
|
91
|
+
// Auto-accept indicator
|
|
92
|
+
const showAutoAcceptIndicator = useAutoAcceptIndicator({
|
|
93
|
+
config,
|
|
94
|
+
addItem: historyManager.addItem,
|
|
95
|
+
});
|
|
96
|
+
const logger = useLogger(config.storage);
|
|
97
|
+
const [userMessages, setUserMessages] = useState([]);
|
|
98
|
+
// Terminal and layout hooks
|
|
99
|
+
const { columns: terminalWidth, rows: terminalHeight } = useTerminalSize();
|
|
100
|
+
const { stdin, setRawMode } = useStdin();
|
|
101
|
+
const { stdout } = useStdout();
|
|
102
|
+
// Additional hooks moved from App.tsx
|
|
103
|
+
const { stats: sessionStats } = useSessionStats();
|
|
104
|
+
const branchName = useGitBranchName(config.getTargetDir());
|
|
105
|
+
// Layout measurements
|
|
106
|
+
const mainControlsRef = useRef(null);
|
|
107
|
+
const staticExtraHeight = 3;
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
(async () => {
|
|
110
|
+
// Note: the program will not work if this fails so let errors be
|
|
111
|
+
// handled by the global catch.
|
|
112
|
+
await config.initialize();
|
|
113
|
+
setConfigInitialized(true);
|
|
114
|
+
})();
|
|
115
|
+
registerCleanup(async () => {
|
|
116
|
+
const ideClient = await IdeClient.getInstance();
|
|
117
|
+
await ideClient.disconnect();
|
|
118
|
+
});
|
|
119
|
+
}, [config]);
|
|
120
|
+
useEffect(() => setUpdateHandler(historyManager.addItem, setUpdateInfo), [historyManager.addItem]);
|
|
121
|
+
// Watch for model changes (e.g., from Flash fallback)
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const checkModelChange = () => {
|
|
124
|
+
const effectiveModel = getEffectiveModel();
|
|
125
|
+
if (effectiveModel !== currentModel) {
|
|
126
|
+
setCurrentModel(effectiveModel);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
checkModelChange();
|
|
130
|
+
const interval = setInterval(checkModelChange, 1000); // Check every second
|
|
131
|
+
return () => clearInterval(interval);
|
|
132
|
+
}, [config, currentModel, getEffectiveModel]);
|
|
133
|
+
const { consoleMessages, handleNewMessage, clearConsoleMessages: clearConsoleMessagesState, } = useConsoleMessages();
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const consolePatcher = new ConsolePatcher({
|
|
136
|
+
onNewMessage: handleNewMessage,
|
|
137
|
+
debugMode: config.getDebugMode(),
|
|
138
|
+
});
|
|
139
|
+
consolePatcher.patch();
|
|
140
|
+
registerCleanup(consolePatcher.cleanup);
|
|
141
|
+
}, [handleNewMessage, config]);
|
|
142
|
+
const widthFraction = 0.9;
|
|
143
|
+
const inputWidth = Math.max(20, Math.floor(terminalWidth * widthFraction) - 3);
|
|
144
|
+
const suggestionsWidth = Math.max(20, Math.floor(terminalWidth * 0.8));
|
|
145
|
+
const mainAreaWidth = Math.floor(terminalWidth * 0.9);
|
|
146
|
+
const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
|
|
147
|
+
const isValidPath = useCallback((filePath) => {
|
|
148
|
+
try {
|
|
149
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
|
150
|
+
}
|
|
151
|
+
catch (_e) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}, []);
|
|
155
|
+
const buffer = useTextBuffer({
|
|
156
|
+
initialText: '',
|
|
157
|
+
viewport: { height: 10, width: inputWidth },
|
|
158
|
+
stdin,
|
|
159
|
+
setRawMode,
|
|
160
|
+
isValidPath,
|
|
161
|
+
shellModeActive,
|
|
162
|
+
});
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
const fetchUserMessages = async () => {
|
|
165
|
+
const pastMessagesRaw = (await logger?.getPreviousUserMessages()) || [];
|
|
166
|
+
const currentSessionUserMessages = historyManager.history
|
|
167
|
+
.filter((item) => item.type === 'user' &&
|
|
168
|
+
typeof item.text === 'string' &&
|
|
169
|
+
item.text.trim() !== '')
|
|
170
|
+
.map((item) => item.text)
|
|
171
|
+
.reverse();
|
|
172
|
+
const combinedMessages = [
|
|
173
|
+
...currentSessionUserMessages,
|
|
174
|
+
...pastMessagesRaw,
|
|
175
|
+
];
|
|
176
|
+
const deduplicatedMessages = [];
|
|
177
|
+
if (combinedMessages.length > 0) {
|
|
178
|
+
deduplicatedMessages.push(combinedMessages[0]);
|
|
179
|
+
for (let i = 1; i < combinedMessages.length; i++) {
|
|
180
|
+
if (combinedMessages[i] !== combinedMessages[i - 1]) {
|
|
181
|
+
deduplicatedMessages.push(combinedMessages[i]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
setUserMessages(deduplicatedMessages.reverse());
|
|
186
|
+
};
|
|
187
|
+
fetchUserMessages();
|
|
188
|
+
}, [historyManager.history, logger]);
|
|
189
|
+
const refreshStatic = useCallback(() => {
|
|
190
|
+
stdout.write(ansiEscapes.clearTerminal);
|
|
191
|
+
setHistoryRemountKey((prev) => prev + 1);
|
|
192
|
+
}, [setHistoryRemountKey, stdout]);
|
|
193
|
+
const { isThemeDialogOpen, openThemeDialog, handleThemeSelect, handleThemeHighlight, } = useThemeCommand(settings, setThemeError, historyManager.addItem, initializationResult.themeError);
|
|
194
|
+
const { authState, setAuthState, authError, onAuthError } = useAuthCommand(settings, config);
|
|
195
|
+
const { proQuotaRequest, handleProQuotaChoice } = useQuotaAndFallback({
|
|
196
|
+
config,
|
|
197
|
+
historyManager,
|
|
198
|
+
userTier,
|
|
199
|
+
setAuthState,
|
|
200
|
+
setModelSwitchedFromQuotaError,
|
|
201
|
+
});
|
|
202
|
+
// Derive auth state variables for backward compatibility with UIStateContext
|
|
203
|
+
const isAuthDialogOpen = authState === AuthState.Updating;
|
|
204
|
+
const isAuthenticating = authState === AuthState.Unauthenticated;
|
|
205
|
+
// Create handleAuthSelect wrapper for backward compatibility
|
|
206
|
+
const handleAuthSelect = useCallback(async (authType, scope) => {
|
|
207
|
+
if (authType) {
|
|
208
|
+
await clearCachedCredentialFile();
|
|
209
|
+
settings.setValue(scope, 'security.auth.selectedType', authType);
|
|
210
|
+
try {
|
|
211
|
+
await config.refreshAuth(authType);
|
|
212
|
+
setAuthState(AuthState.Authenticated);
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
onAuthError(`Failed to authenticate: ${e instanceof Error ? e.message : String(e)}`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (authType === AuthType.LOGIN_WITH_GOOGLE &&
|
|
219
|
+
config.isBrowserLaunchSuppressed()) {
|
|
220
|
+
await runExitCleanup();
|
|
221
|
+
console.log(`
|
|
222
|
+
----------------------------------------------------------------
|
|
223
|
+
Logging in with Google... Please restart Gemini CLI to continue.
|
|
224
|
+
----------------------------------------------------------------
|
|
225
|
+
`);
|
|
226
|
+
process.exit(0);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
setAuthState(AuthState.Authenticated);
|
|
230
|
+
}, [settings, config, setAuthState, onAuthError]);
|
|
231
|
+
// Sync user tier from config when authentication changes
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
// Only sync when not currently authenticating
|
|
234
|
+
if (authState === AuthState.Authenticated) {
|
|
235
|
+
setUserTier(config.getUserTier());
|
|
236
|
+
}
|
|
237
|
+
}, [config, authState]);
|
|
238
|
+
// Check for enforced auth type mismatch
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (settings.merged.security?.auth?.enforcedType &&
|
|
241
|
+
settings.merged.security?.auth.selectedType &&
|
|
242
|
+
settings.merged.security?.auth.enforcedType !==
|
|
243
|
+
settings.merged.security?.auth.selectedType) {
|
|
244
|
+
onAuthError(`Authentication is enforced to be ${settings.merged.security?.auth.enforcedType}, but you are currently using ${settings.merged.security?.auth.selectedType}.`);
|
|
245
|
+
}
|
|
246
|
+
else if (settings.merged.security?.auth?.selectedType &&
|
|
247
|
+
!settings.merged.security?.auth?.useExternal) {
|
|
248
|
+
const error = validateAuthMethod(settings.merged.security.auth.selectedType);
|
|
249
|
+
if (error) {
|
|
250
|
+
onAuthError(error);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, [
|
|
254
|
+
settings.merged.security?.auth?.selectedType,
|
|
255
|
+
settings.merged.security?.auth?.enforcedType,
|
|
256
|
+
settings.merged.security?.auth?.useExternal,
|
|
257
|
+
onAuthError,
|
|
258
|
+
]);
|
|
259
|
+
const [editorError, setEditorError] = useState(null);
|
|
260
|
+
const { isEditorDialogOpen, openEditorDialog, handleEditorSelect, exitEditorDialog, } = useEditorSettings(settings, setEditorError, historyManager.addItem);
|
|
261
|
+
const { isSettingsDialogOpen, openSettingsDialog, closeSettingsDialog } = useSettingsCommand();
|
|
262
|
+
const { showWorkspaceMigrationDialog, workspaceExtensions, onWorkspaceMigrationDialogOpen, onWorkspaceMigrationDialogClose, } = useWorkspaceMigration(settings);
|
|
263
|
+
const { toggleVimEnabled } = useVimMode();
|
|
264
|
+
const slashCommandActions = useMemo(() => ({
|
|
265
|
+
openAuthDialog: () => setAuthState(AuthState.Updating),
|
|
266
|
+
openThemeDialog,
|
|
267
|
+
openEditorDialog,
|
|
268
|
+
openPrivacyNotice: () => setShowPrivacyNotice(true),
|
|
269
|
+
openSettingsDialog,
|
|
270
|
+
quit: (messages) => {
|
|
271
|
+
setQuittingMessages(messages);
|
|
272
|
+
setTimeout(async () => {
|
|
273
|
+
await runExitCleanup();
|
|
274
|
+
process.exit(0);
|
|
275
|
+
}, 100);
|
|
276
|
+
},
|
|
277
|
+
setDebugMessage,
|
|
278
|
+
toggleCorgiMode: () => setCorgiMode((prev) => !prev),
|
|
279
|
+
}), [
|
|
280
|
+
setAuthState,
|
|
281
|
+
openThemeDialog,
|
|
282
|
+
openEditorDialog,
|
|
283
|
+
openSettingsDialog,
|
|
284
|
+
setQuittingMessages,
|
|
285
|
+
setDebugMessage,
|
|
286
|
+
setShowPrivacyNotice,
|
|
287
|
+
setCorgiMode,
|
|
288
|
+
]);
|
|
289
|
+
const { handleSlashCommand, slashCommands, pendingHistoryItems: pendingSlashCommandHistoryItems, commandContext, shellConfirmationRequest, confirmationRequest, } = useSlashCommandProcessor(config, settings, historyManager.addItem, historyManager.clearItems, historyManager.loadHistory, refreshStatic, toggleVimEnabled, setIsProcessing, setGeminiMdFileCount, slashCommandActions);
|
|
290
|
+
const performMemoryRefresh = useCallback(async () => {
|
|
291
|
+
historyManager.addItem({
|
|
292
|
+
type: MessageType.INFO,
|
|
293
|
+
text: 'Refreshing hierarchical memory (GEMINI.md or other context files)...',
|
|
294
|
+
}, Date.now());
|
|
295
|
+
try {
|
|
296
|
+
const { memoryContent, fileCount } = await loadHierarchicalGeminiMemory(process.cwd(), settings.merged.context?.loadMemoryFromIncludeDirectories
|
|
297
|
+
? config.getWorkspaceContext().getDirectories()
|
|
298
|
+
: [], config.getDebugMode(), config.getFileService(), settings.merged, config.getExtensionContextFilePaths(), config.isTrustedFolder(), settings.merged.context?.importFormat || 'tree', // Use setting or default to 'tree'
|
|
299
|
+
config.getFileFilteringOptions());
|
|
300
|
+
config.setUserMemory(memoryContent);
|
|
301
|
+
config.setGeminiMdFileCount(fileCount);
|
|
302
|
+
setGeminiMdFileCount(fileCount);
|
|
303
|
+
historyManager.addItem({
|
|
304
|
+
type: MessageType.INFO,
|
|
305
|
+
text: `Memory refreshed successfully. ${memoryContent.length > 0
|
|
306
|
+
? `Loaded ${memoryContent.length} characters from ${fileCount} file(s).`
|
|
307
|
+
: 'No memory content found.'}`,
|
|
308
|
+
}, Date.now());
|
|
309
|
+
if (config.getDebugMode()) {
|
|
310
|
+
console.log(`[DEBUG] Refreshed memory content in config: ${memoryContent.substring(0, 200)}...`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
const errorMessage = getErrorMessage(error);
|
|
315
|
+
historyManager.addItem({
|
|
316
|
+
type: MessageType.ERROR,
|
|
317
|
+
text: `Error refreshing memory: ${errorMessage}`,
|
|
318
|
+
}, Date.now());
|
|
319
|
+
console.error('Error refreshing memory:', error);
|
|
320
|
+
}
|
|
321
|
+
}, [config, historyManager, settings.merged]);
|
|
322
|
+
const cancelHandlerRef = useRef(() => { });
|
|
323
|
+
const { streamingState, submitQuery, initError, pendingHistoryItems: pendingGeminiHistoryItems, thought, cancelOngoingRequest, } = useGeminiStream(config.getGeminiClient(), historyManager.history, historyManager.addItem, config, settings, setDebugMessage, handleSlashCommand, shellModeActive, () => settings.merged.general?.preferredEditor, onAuthError, performMemoryRefresh, modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError, refreshStatic, () => cancelHandlerRef.current());
|
|
324
|
+
const { messageQueue, addMessage, clearQueue, getQueuedMessagesText } = useMessageQueue({
|
|
325
|
+
isConfigInitialized,
|
|
326
|
+
streamingState,
|
|
327
|
+
submitQuery,
|
|
328
|
+
});
|
|
329
|
+
cancelHandlerRef.current = useCallback(() => {
|
|
330
|
+
const pendingHistoryItems = [
|
|
331
|
+
...pendingSlashCommandHistoryItems,
|
|
332
|
+
...pendingGeminiHistoryItems,
|
|
333
|
+
];
|
|
334
|
+
if (isToolExecuting(pendingHistoryItems)) {
|
|
335
|
+
buffer.setText(''); // Just clear the prompt
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const lastUserMessage = userMessages.at(-1);
|
|
339
|
+
let textToSet = lastUserMessage || '';
|
|
340
|
+
const queuedText = getQueuedMessagesText();
|
|
341
|
+
if (queuedText) {
|
|
342
|
+
textToSet = textToSet ? `${textToSet}\n\n${queuedText}` : queuedText;
|
|
343
|
+
clearQueue();
|
|
344
|
+
}
|
|
345
|
+
if (textToSet) {
|
|
346
|
+
buffer.setText(textToSet);
|
|
347
|
+
}
|
|
348
|
+
}, [
|
|
349
|
+
buffer,
|
|
350
|
+
userMessages,
|
|
351
|
+
getQueuedMessagesText,
|
|
352
|
+
clearQueue,
|
|
353
|
+
pendingSlashCommandHistoryItems,
|
|
354
|
+
pendingGeminiHistoryItems,
|
|
355
|
+
]);
|
|
356
|
+
const handleFinalSubmit = useCallback((submittedValue) => {
|
|
357
|
+
addMessage(submittedValue);
|
|
358
|
+
}, [addMessage]);
|
|
359
|
+
const handleClearScreen = useCallback(() => {
|
|
360
|
+
historyManager.clearItems();
|
|
361
|
+
clearConsoleMessagesState();
|
|
362
|
+
console.clear();
|
|
363
|
+
refreshStatic();
|
|
364
|
+
}, [historyManager, clearConsoleMessagesState, refreshStatic]);
|
|
365
|
+
const { handleInput: vimHandleInput } = useVim(buffer, handleFinalSubmit);
|
|
366
|
+
/**
|
|
367
|
+
* Determines if the input prompt should be active and accept user input.
|
|
368
|
+
* Input is disabled during:
|
|
369
|
+
* - Initialization errors
|
|
370
|
+
* - Slash command processing
|
|
371
|
+
* - Tool confirmations (WaitingForConfirmation state)
|
|
372
|
+
* - Any future streaming states not explicitly allowed
|
|
373
|
+
*/
|
|
374
|
+
const isInputActive = !initError &&
|
|
375
|
+
!isProcessing &&
|
|
376
|
+
(streamingState === StreamingState.Idle ||
|
|
377
|
+
streamingState === StreamingState.Responding) &&
|
|
378
|
+
!proQuotaRequest;
|
|
379
|
+
// Compute available terminal height based on controls measurement
|
|
380
|
+
const availableTerminalHeight = useMemo(() => {
|
|
381
|
+
if (mainControlsRef.current) {
|
|
382
|
+
const fullFooterMeasurement = measureElement(mainControlsRef.current);
|
|
383
|
+
return terminalHeight - fullFooterMeasurement.height - staticExtraHeight;
|
|
384
|
+
}
|
|
385
|
+
return terminalHeight - staticExtraHeight;
|
|
386
|
+
}, [terminalHeight]);
|
|
387
|
+
const isFocused = useFocus();
|
|
388
|
+
useBracketedPaste();
|
|
389
|
+
// Context file names computation
|
|
390
|
+
const contextFileNames = useMemo(() => {
|
|
391
|
+
const fromSettings = settings.merged.context?.fileName;
|
|
392
|
+
return fromSettings
|
|
393
|
+
? Array.isArray(fromSettings)
|
|
394
|
+
? fromSettings
|
|
395
|
+
: [fromSettings]
|
|
396
|
+
: getAllGeminiMdFilenames();
|
|
397
|
+
}, [settings.merged.context?.fileName]);
|
|
398
|
+
// Initial prompt handling
|
|
399
|
+
const initialPrompt = useMemo(() => config.getQuestion(), [config]);
|
|
400
|
+
const initialPromptSubmitted = useRef(false);
|
|
401
|
+
const geminiClient = config.getGeminiClient();
|
|
402
|
+
useEffect(() => {
|
|
403
|
+
if (initialPrompt &&
|
|
404
|
+
isConfigInitialized &&
|
|
405
|
+
!initialPromptSubmitted.current &&
|
|
406
|
+
!isAuthenticating &&
|
|
407
|
+
!isAuthDialogOpen &&
|
|
408
|
+
!isThemeDialogOpen &&
|
|
409
|
+
!isEditorDialogOpen &&
|
|
410
|
+
!showPrivacyNotice &&
|
|
411
|
+
geminiClient?.isInitialized?.()) {
|
|
412
|
+
handleFinalSubmit(initialPrompt);
|
|
413
|
+
initialPromptSubmitted.current = true;
|
|
414
|
+
}
|
|
415
|
+
}, [
|
|
416
|
+
initialPrompt,
|
|
417
|
+
isConfigInitialized,
|
|
418
|
+
handleFinalSubmit,
|
|
419
|
+
isAuthenticating,
|
|
420
|
+
isAuthDialogOpen,
|
|
421
|
+
isThemeDialogOpen,
|
|
422
|
+
isEditorDialogOpen,
|
|
423
|
+
showPrivacyNotice,
|
|
424
|
+
geminiClient,
|
|
425
|
+
]);
|
|
426
|
+
const [idePromptAnswered, setIdePromptAnswered] = useState(false);
|
|
427
|
+
const [currentIDE, setCurrentIDE] = useState(null);
|
|
428
|
+
useEffect(() => {
|
|
429
|
+
const getIde = async () => {
|
|
430
|
+
const ideClient = await IdeClient.getInstance();
|
|
431
|
+
const currentIde = ideClient.getCurrentIde();
|
|
432
|
+
setCurrentIDE(currentIde || null);
|
|
433
|
+
};
|
|
434
|
+
getIde();
|
|
435
|
+
}, []);
|
|
436
|
+
const shouldShowIdePrompt = Boolean(currentIDE &&
|
|
437
|
+
!config.getIdeMode() &&
|
|
438
|
+
!settings.merged.ide?.hasSeenNudge &&
|
|
439
|
+
!idePromptAnswered);
|
|
440
|
+
const [showErrorDetails, setShowErrorDetails] = useState(false);
|
|
441
|
+
const [showToolDescriptions, setShowToolDescriptions] = useState(false);
|
|
442
|
+
const [ctrlCPressedOnce, setCtrlCPressedOnce] = useState(false);
|
|
443
|
+
const ctrlCTimerRef = useRef(null);
|
|
444
|
+
const [ctrlDPressedOnce, setCtrlDPressedOnce] = useState(false);
|
|
445
|
+
const ctrlDTimerRef = useRef(null);
|
|
446
|
+
const [constrainHeight, setConstrainHeight] = useState(true);
|
|
447
|
+
const [ideContextState, setIdeContextState] = useState();
|
|
448
|
+
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
|
|
449
|
+
const [showIdeRestartPrompt, setShowIdeRestartPrompt] = useState(false);
|
|
450
|
+
const { isFolderTrustDialogOpen, handleFolderTrustSelect, isRestarting } = useFolderTrust(settings, setIsTrustedFolder, refreshStatic);
|
|
451
|
+
const { needsRestart: ideNeedsRestart } = useIdeTrustListener();
|
|
452
|
+
const isInitialMount = useRef(true);
|
|
453
|
+
useEffect(() => {
|
|
454
|
+
if (ideNeedsRestart) {
|
|
455
|
+
// IDE trust changed, force a restart.
|
|
456
|
+
setShowIdeRestartPrompt(true);
|
|
457
|
+
}
|
|
458
|
+
}, [ideNeedsRestart]);
|
|
459
|
+
useEffect(() => {
|
|
460
|
+
if (isInitialMount.current) {
|
|
461
|
+
isInitialMount.current = false;
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const handler = setTimeout(() => {
|
|
465
|
+
refreshStatic();
|
|
466
|
+
}, 300);
|
|
467
|
+
return () => {
|
|
468
|
+
clearTimeout(handler);
|
|
469
|
+
};
|
|
470
|
+
}, [terminalWidth, refreshStatic]);
|
|
471
|
+
useEffect(() => {
|
|
472
|
+
const unsubscribe = ideContext.subscribeToIdeContext(setIdeContextState);
|
|
473
|
+
setIdeContextState(ideContext.getIdeContext());
|
|
474
|
+
return unsubscribe;
|
|
475
|
+
}, []);
|
|
476
|
+
useEffect(() => {
|
|
477
|
+
const openDebugConsole = () => {
|
|
478
|
+
setShowErrorDetails(true);
|
|
479
|
+
setConstrainHeight(false);
|
|
480
|
+
};
|
|
481
|
+
appEvents.on(AppEvent.OpenDebugConsole, openDebugConsole);
|
|
482
|
+
const logErrorHandler = (errorMessage) => {
|
|
483
|
+
handleNewMessage({
|
|
484
|
+
type: 'error',
|
|
485
|
+
content: String(errorMessage),
|
|
486
|
+
count: 1,
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
appEvents.on(AppEvent.LogError, logErrorHandler);
|
|
490
|
+
return () => {
|
|
491
|
+
appEvents.off(AppEvent.OpenDebugConsole, openDebugConsole);
|
|
492
|
+
appEvents.off(AppEvent.LogError, logErrorHandler);
|
|
493
|
+
};
|
|
494
|
+
}, [handleNewMessage]);
|
|
495
|
+
const handleEscapePromptChange = useCallback((showPrompt) => {
|
|
496
|
+
setShowEscapePrompt(showPrompt);
|
|
497
|
+
}, []);
|
|
498
|
+
const handleIdePromptComplete = useCallback((result) => {
|
|
499
|
+
if (result.userSelection === 'yes') {
|
|
500
|
+
handleSlashCommand('/ide install');
|
|
501
|
+
settings.setValue(SettingScope.User, 'hasSeenIdeIntegrationNudge', true);
|
|
502
|
+
}
|
|
503
|
+
else if (result.userSelection === 'dismiss') {
|
|
504
|
+
settings.setValue(SettingScope.User, 'hasSeenIdeIntegrationNudge', true);
|
|
505
|
+
}
|
|
506
|
+
setIdePromptAnswered(true);
|
|
507
|
+
}, [handleSlashCommand, settings]);
|
|
508
|
+
const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState);
|
|
509
|
+
const handleExit = useCallback((pressedOnce, setPressedOnce, timerRef) => {
|
|
510
|
+
if (pressedOnce) {
|
|
511
|
+
if (timerRef.current) {
|
|
512
|
+
clearTimeout(timerRef.current);
|
|
513
|
+
}
|
|
514
|
+
handleSlashCommand('/quit');
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
setPressedOnce(true);
|
|
518
|
+
timerRef.current = setTimeout(() => {
|
|
519
|
+
setPressedOnce(false);
|
|
520
|
+
timerRef.current = null;
|
|
521
|
+
}, CTRL_EXIT_PROMPT_DURATION_MS);
|
|
522
|
+
}
|
|
523
|
+
}, [handleSlashCommand]);
|
|
524
|
+
const handleGlobalKeypress = useCallback((key) => {
|
|
525
|
+
// Debug log keystrokes if enabled
|
|
526
|
+
if (settings.merged.general?.debugKeystrokeLogging) {
|
|
527
|
+
console.log('[DEBUG] Keystroke:', JSON.stringify(key));
|
|
528
|
+
}
|
|
529
|
+
const anyDialogOpen = isThemeDialogOpen ||
|
|
530
|
+
isAuthDialogOpen ||
|
|
531
|
+
isEditorDialogOpen ||
|
|
532
|
+
isSettingsDialogOpen ||
|
|
533
|
+
isFolderTrustDialogOpen ||
|
|
534
|
+
showPrivacyNotice;
|
|
535
|
+
if (anyDialogOpen) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
let enteringConstrainHeightMode = false;
|
|
539
|
+
if (!constrainHeight) {
|
|
540
|
+
enteringConstrainHeightMode = true;
|
|
541
|
+
setConstrainHeight(true);
|
|
542
|
+
}
|
|
543
|
+
if (keyMatchers[Command.SHOW_ERROR_DETAILS](key)) {
|
|
544
|
+
setShowErrorDetails((prev) => !prev);
|
|
545
|
+
}
|
|
546
|
+
else if (keyMatchers[Command.TOGGLE_TOOL_DESCRIPTIONS](key)) {
|
|
547
|
+
const newValue = !showToolDescriptions;
|
|
548
|
+
setShowToolDescriptions(newValue);
|
|
549
|
+
const mcpServers = config.getMcpServers();
|
|
550
|
+
if (Object.keys(mcpServers || {}).length > 0) {
|
|
551
|
+
handleSlashCommand(newValue ? '/mcp desc' : '/mcp nodesc');
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
else if (keyMatchers[Command.TOGGLE_IDE_CONTEXT_DETAIL](key) &&
|
|
555
|
+
config.getIdeMode() &&
|
|
556
|
+
ideContextState) {
|
|
557
|
+
handleSlashCommand('/ide status');
|
|
558
|
+
}
|
|
559
|
+
else if (keyMatchers[Command.QUIT](key)) {
|
|
560
|
+
if (!ctrlCPressedOnce) {
|
|
561
|
+
cancelOngoingRequest?.();
|
|
562
|
+
}
|
|
563
|
+
handleExit(ctrlCPressedOnce, setCtrlCPressedOnce, ctrlCTimerRef);
|
|
564
|
+
}
|
|
565
|
+
else if (keyMatchers[Command.EXIT](key)) {
|
|
566
|
+
if (buffer.text.length > 0) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
|
|
570
|
+
}
|
|
571
|
+
else if (keyMatchers[Command.SHOW_MORE_LINES](key) &&
|
|
572
|
+
!enteringConstrainHeightMode) {
|
|
573
|
+
setConstrainHeight(false);
|
|
574
|
+
}
|
|
575
|
+
}, [
|
|
576
|
+
constrainHeight,
|
|
577
|
+
setConstrainHeight,
|
|
578
|
+
setShowErrorDetails,
|
|
579
|
+
showToolDescriptions,
|
|
580
|
+
setShowToolDescriptions,
|
|
581
|
+
config,
|
|
582
|
+
ideContextState,
|
|
583
|
+
handleExit,
|
|
584
|
+
ctrlCPressedOnce,
|
|
585
|
+
setCtrlCPressedOnce,
|
|
586
|
+
ctrlCTimerRef,
|
|
587
|
+
buffer.text.length,
|
|
588
|
+
ctrlDPressedOnce,
|
|
589
|
+
setCtrlDPressedOnce,
|
|
590
|
+
ctrlDTimerRef,
|
|
591
|
+
handleSlashCommand,
|
|
592
|
+
cancelOngoingRequest,
|
|
593
|
+
isThemeDialogOpen,
|
|
594
|
+
isAuthDialogOpen,
|
|
595
|
+
isEditorDialogOpen,
|
|
596
|
+
isSettingsDialogOpen,
|
|
597
|
+
isFolderTrustDialogOpen,
|
|
598
|
+
showPrivacyNotice,
|
|
599
|
+
settings.merged.general?.debugKeystrokeLogging,
|
|
600
|
+
]);
|
|
601
|
+
useKeypress(handleGlobalKeypress, { isActive: true });
|
|
602
|
+
useKeypress((key) => {
|
|
603
|
+
if (key.name === 'r' || key.name === 'R') {
|
|
604
|
+
process.exit(0);
|
|
605
|
+
}
|
|
606
|
+
}, { isActive: showIdeRestartPrompt });
|
|
607
|
+
const filteredConsoleMessages = useMemo(() => {
|
|
608
|
+
if (config.getDebugMode()) {
|
|
609
|
+
return consoleMessages;
|
|
610
|
+
}
|
|
611
|
+
return consoleMessages.filter((msg) => msg.type !== 'debug');
|
|
612
|
+
}, [consoleMessages, config]);
|
|
613
|
+
// Computed values
|
|
614
|
+
const errorCount = useMemo(() => filteredConsoleMessages
|
|
615
|
+
.filter((msg) => msg.type === 'error')
|
|
616
|
+
.reduce((total, msg) => total + msg.count, 0), [filteredConsoleMessages]);
|
|
617
|
+
const nightly = props.version.includes('nightly');
|
|
618
|
+
const dialogsVisible = useMemo(() => showWorkspaceMigrationDialog ||
|
|
619
|
+
shouldShowIdePrompt ||
|
|
620
|
+
isFolderTrustDialogOpen ||
|
|
621
|
+
!!shellConfirmationRequest ||
|
|
622
|
+
!!confirmationRequest ||
|
|
623
|
+
isThemeDialogOpen ||
|
|
624
|
+
isSettingsDialogOpen ||
|
|
625
|
+
isAuthenticating ||
|
|
626
|
+
isAuthDialogOpen ||
|
|
627
|
+
isEditorDialogOpen ||
|
|
628
|
+
showPrivacyNotice ||
|
|
629
|
+
!!proQuotaRequest, [
|
|
630
|
+
showWorkspaceMigrationDialog,
|
|
631
|
+
shouldShowIdePrompt,
|
|
632
|
+
isFolderTrustDialogOpen,
|
|
633
|
+
shellConfirmationRequest,
|
|
634
|
+
confirmationRequest,
|
|
635
|
+
isThemeDialogOpen,
|
|
636
|
+
isSettingsDialogOpen,
|
|
637
|
+
isAuthenticating,
|
|
638
|
+
isAuthDialogOpen,
|
|
639
|
+
isEditorDialogOpen,
|
|
640
|
+
showPrivacyNotice,
|
|
641
|
+
proQuotaRequest,
|
|
642
|
+
]);
|
|
643
|
+
const pendingHistoryItems = useMemo(() => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems], [pendingSlashCommandHistoryItems, pendingGeminiHistoryItems]);
|
|
644
|
+
const uiState = useMemo(() => ({
|
|
645
|
+
history: historyManager.history,
|
|
646
|
+
isThemeDialogOpen,
|
|
647
|
+
themeError,
|
|
648
|
+
isAuthenticating,
|
|
649
|
+
isConfigInitialized,
|
|
650
|
+
authError,
|
|
651
|
+
isAuthDialogOpen,
|
|
652
|
+
editorError,
|
|
653
|
+
isEditorDialogOpen,
|
|
654
|
+
showPrivacyNotice,
|
|
655
|
+
corgiMode,
|
|
656
|
+
debugMessage,
|
|
657
|
+
quittingMessages,
|
|
658
|
+
isSettingsDialogOpen,
|
|
659
|
+
slashCommands,
|
|
660
|
+
pendingSlashCommandHistoryItems,
|
|
661
|
+
commandContext,
|
|
662
|
+
shellConfirmationRequest,
|
|
663
|
+
confirmationRequest,
|
|
664
|
+
geminiMdFileCount,
|
|
665
|
+
streamingState,
|
|
666
|
+
initError,
|
|
667
|
+
pendingGeminiHistoryItems,
|
|
668
|
+
thought,
|
|
669
|
+
shellModeActive,
|
|
670
|
+
userMessages,
|
|
671
|
+
buffer,
|
|
672
|
+
inputWidth,
|
|
673
|
+
suggestionsWidth,
|
|
674
|
+
isInputActive,
|
|
675
|
+
shouldShowIdePrompt,
|
|
676
|
+
isFolderTrustDialogOpen: isFolderTrustDialogOpen ?? false,
|
|
677
|
+
isTrustedFolder,
|
|
678
|
+
constrainHeight,
|
|
679
|
+
showErrorDetails,
|
|
680
|
+
filteredConsoleMessages,
|
|
681
|
+
ideContextState,
|
|
682
|
+
showToolDescriptions,
|
|
683
|
+
ctrlCPressedOnce,
|
|
684
|
+
ctrlDPressedOnce,
|
|
685
|
+
showEscapePrompt,
|
|
686
|
+
isFocused,
|
|
687
|
+
elapsedTime,
|
|
688
|
+
currentLoadingPhrase,
|
|
689
|
+
historyRemountKey,
|
|
690
|
+
messageQueue,
|
|
691
|
+
showAutoAcceptIndicator,
|
|
692
|
+
showWorkspaceMigrationDialog,
|
|
693
|
+
workspaceExtensions,
|
|
694
|
+
currentModel,
|
|
695
|
+
userTier,
|
|
696
|
+
proQuotaRequest,
|
|
697
|
+
contextFileNames,
|
|
698
|
+
errorCount,
|
|
699
|
+
availableTerminalHeight,
|
|
700
|
+
mainAreaWidth,
|
|
701
|
+
staticAreaMaxItemHeight,
|
|
702
|
+
staticExtraHeight,
|
|
703
|
+
dialogsVisible,
|
|
704
|
+
pendingHistoryItems,
|
|
705
|
+
nightly,
|
|
706
|
+
branchName,
|
|
707
|
+
sessionStats,
|
|
708
|
+
terminalWidth,
|
|
709
|
+
terminalHeight,
|
|
710
|
+
mainControlsRef,
|
|
711
|
+
currentIDE,
|
|
712
|
+
updateInfo,
|
|
713
|
+
showIdeRestartPrompt,
|
|
714
|
+
isRestarting,
|
|
715
|
+
}), [
|
|
716
|
+
historyManager.history,
|
|
717
|
+
isThemeDialogOpen,
|
|
718
|
+
themeError,
|
|
719
|
+
isAuthenticating,
|
|
720
|
+
isConfigInitialized,
|
|
721
|
+
authError,
|
|
722
|
+
isAuthDialogOpen,
|
|
723
|
+
editorError,
|
|
724
|
+
isEditorDialogOpen,
|
|
725
|
+
showPrivacyNotice,
|
|
726
|
+
corgiMode,
|
|
727
|
+
debugMessage,
|
|
728
|
+
quittingMessages,
|
|
729
|
+
isSettingsDialogOpen,
|
|
730
|
+
slashCommands,
|
|
731
|
+
pendingSlashCommandHistoryItems,
|
|
732
|
+
commandContext,
|
|
733
|
+
shellConfirmationRequest,
|
|
734
|
+
confirmationRequest,
|
|
735
|
+
geminiMdFileCount,
|
|
736
|
+
streamingState,
|
|
737
|
+
initError,
|
|
738
|
+
pendingGeminiHistoryItems,
|
|
739
|
+
thought,
|
|
740
|
+
shellModeActive,
|
|
741
|
+
userMessages,
|
|
742
|
+
buffer,
|
|
743
|
+
inputWidth,
|
|
744
|
+
suggestionsWidth,
|
|
745
|
+
isInputActive,
|
|
746
|
+
shouldShowIdePrompt,
|
|
747
|
+
isFolderTrustDialogOpen,
|
|
748
|
+
isTrustedFolder,
|
|
749
|
+
constrainHeight,
|
|
750
|
+
showErrorDetails,
|
|
751
|
+
filteredConsoleMessages,
|
|
752
|
+
ideContextState,
|
|
753
|
+
showToolDescriptions,
|
|
754
|
+
ctrlCPressedOnce,
|
|
755
|
+
ctrlDPressedOnce,
|
|
756
|
+
showEscapePrompt,
|
|
757
|
+
isFocused,
|
|
758
|
+
elapsedTime,
|
|
759
|
+
currentLoadingPhrase,
|
|
760
|
+
historyRemountKey,
|
|
761
|
+
messageQueue,
|
|
762
|
+
showAutoAcceptIndicator,
|
|
763
|
+
showWorkspaceMigrationDialog,
|
|
764
|
+
workspaceExtensions,
|
|
765
|
+
userTier,
|
|
766
|
+
proQuotaRequest,
|
|
767
|
+
contextFileNames,
|
|
768
|
+
errorCount,
|
|
769
|
+
availableTerminalHeight,
|
|
770
|
+
mainAreaWidth,
|
|
771
|
+
staticAreaMaxItemHeight,
|
|
772
|
+
staticExtraHeight,
|
|
773
|
+
dialogsVisible,
|
|
774
|
+
pendingHistoryItems,
|
|
775
|
+
nightly,
|
|
776
|
+
branchName,
|
|
777
|
+
sessionStats,
|
|
778
|
+
terminalWidth,
|
|
779
|
+
terminalHeight,
|
|
780
|
+
mainControlsRef,
|
|
781
|
+
currentIDE,
|
|
782
|
+
updateInfo,
|
|
783
|
+
showIdeRestartPrompt,
|
|
784
|
+
isRestarting,
|
|
785
|
+
currentModel,
|
|
786
|
+
]);
|
|
787
|
+
const uiActions = useMemo(() => ({
|
|
788
|
+
handleThemeSelect,
|
|
789
|
+
handleThemeHighlight,
|
|
790
|
+
handleAuthSelect,
|
|
791
|
+
setAuthState,
|
|
792
|
+
onAuthError,
|
|
793
|
+
handleEditorSelect,
|
|
794
|
+
exitEditorDialog,
|
|
795
|
+
exitPrivacyNotice: () => setShowPrivacyNotice(false),
|
|
796
|
+
closeSettingsDialog,
|
|
797
|
+
setShellModeActive,
|
|
798
|
+
vimHandleInput,
|
|
799
|
+
handleIdePromptComplete,
|
|
800
|
+
handleFolderTrustSelect,
|
|
801
|
+
setConstrainHeight,
|
|
802
|
+
onEscapePromptChange: handleEscapePromptChange,
|
|
803
|
+
refreshStatic,
|
|
804
|
+
handleFinalSubmit,
|
|
805
|
+
handleClearScreen,
|
|
806
|
+
onWorkspaceMigrationDialogOpen,
|
|
807
|
+
onWorkspaceMigrationDialogClose,
|
|
808
|
+
handleProQuotaChoice,
|
|
809
|
+
}), [
|
|
810
|
+
handleThemeSelect,
|
|
811
|
+
handleThemeHighlight,
|
|
812
|
+
handleAuthSelect,
|
|
813
|
+
setAuthState,
|
|
814
|
+
onAuthError,
|
|
815
|
+
handleEditorSelect,
|
|
816
|
+
exitEditorDialog,
|
|
817
|
+
closeSettingsDialog,
|
|
818
|
+
setShellModeActive,
|
|
819
|
+
vimHandleInput,
|
|
820
|
+
handleIdePromptComplete,
|
|
821
|
+
handleFolderTrustSelect,
|
|
822
|
+
setConstrainHeight,
|
|
823
|
+
handleEscapePromptChange,
|
|
824
|
+
refreshStatic,
|
|
825
|
+
handleFinalSubmit,
|
|
826
|
+
handleClearScreen,
|
|
827
|
+
onWorkspaceMigrationDialogOpen,
|
|
828
|
+
onWorkspaceMigrationDialogClose,
|
|
829
|
+
handleProQuotaChoice,
|
|
830
|
+
]);
|
|
831
|
+
return (_jsx(UIStateContext.Provider, { value: uiState, children: _jsx(UIActionsContext.Provider, { value: uiActions, children: _jsx(ConfigContext.Provider, { value: config, children: _jsx(AppContext.Provider, { value: {
|
|
832
|
+
version: props.version,
|
|
833
|
+
startupWarnings: props.startupWarnings || [],
|
|
834
|
+
}, children: _jsx(App, {}) }) }) }) }));
|
|
835
|
+
};
|
|
836
|
+
//# sourceMappingURL=AppContainer.js.map
|