mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
feat(cli): wire up useAgentStream in AppContainer (#24297)
Co-authored-by: Adam Weidman <adamfweidman@gmail.com> Co-authored-by: Adam Weidman <adamfweidman@google.com>
This commit is contained in:
@@ -89,6 +89,7 @@ import {
|
|||||||
buildUserSteeringHintPrompt,
|
buildUserSteeringHintPrompt,
|
||||||
logBillingEvent,
|
logBillingEvent,
|
||||||
ApiKeyUpdatedEvent,
|
ApiKeyUpdatedEvent,
|
||||||
|
LegacyAgentProtocol,
|
||||||
type InjectionSource,
|
type InjectionSource,
|
||||||
startMemoryService,
|
startMemoryService,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
@@ -118,6 +119,7 @@ import { computeTerminalTitle } from '../utils/windowTitle.js';
|
|||||||
import { useTextBuffer } from './components/shared/text-buffer.js';
|
import { useTextBuffer } from './components/shared/text-buffer.js';
|
||||||
import { useLogger } from './hooks/useLogger.js';
|
import { useLogger } from './hooks/useLogger.js';
|
||||||
import { useGeminiStream } from './hooks/useGeminiStream.js';
|
import { useGeminiStream } from './hooks/useGeminiStream.js';
|
||||||
|
import { useAgentStream } from './hooks/useAgentStream.js';
|
||||||
import { type BackgroundTask } from './hooks/useExecutionLifecycle.js';
|
import { type BackgroundTask } from './hooks/useExecutionLifecycle.js';
|
||||||
import { useVim } from './hooks/vim.js';
|
import { useVim } from './hooks/vim.js';
|
||||||
import { type LoadableSettingScope, SettingScope } from '../config/settings.js';
|
import { type LoadableSettingScope, SettingScope } from '../config/settings.js';
|
||||||
@@ -1161,6 +1163,46 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
|||||||
};
|
};
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
|
const streamAgent = useMemo(
|
||||||
|
() =>
|
||||||
|
config?.getAgentSessionInteractiveEnabled()
|
||||||
|
? new LegacyAgentProtocol({ config, getPreferredEditor })
|
||||||
|
: undefined,
|
||||||
|
[config, getPreferredEditor],
|
||||||
|
);
|
||||||
|
|
||||||
|
const activeStream = streamAgent
|
||||||
|
? // eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
useAgentStream({
|
||||||
|
agent: streamAgent,
|
||||||
|
addItem: historyManager.addItem,
|
||||||
|
onCancelSubmit,
|
||||||
|
isShellFocused: embeddedShellFocused,
|
||||||
|
logger,
|
||||||
|
})
|
||||||
|
: // eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
useGeminiStream(
|
||||||
|
config.getGeminiClient(),
|
||||||
|
historyManager.history,
|
||||||
|
historyManager.addItem,
|
||||||
|
config,
|
||||||
|
settings,
|
||||||
|
setDebugMessage,
|
||||||
|
handleSlashCommand,
|
||||||
|
shellModeActive,
|
||||||
|
getPreferredEditor,
|
||||||
|
onAuthError,
|
||||||
|
performMemoryRefresh,
|
||||||
|
modelSwitchedFromQuotaError,
|
||||||
|
setModelSwitchedFromQuotaError,
|
||||||
|
onCancelSubmit,
|
||||||
|
setEmbeddedShellFocused,
|
||||||
|
terminalWidth,
|
||||||
|
terminalHeight,
|
||||||
|
embeddedShellFocused,
|
||||||
|
consumePendingHints,
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
streamingState,
|
streamingState,
|
||||||
submitQuery,
|
submitQuery,
|
||||||
@@ -1180,27 +1222,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
|||||||
backgroundTasks,
|
backgroundTasks,
|
||||||
dismissBackgroundTask,
|
dismissBackgroundTask,
|
||||||
retryStatus,
|
retryStatus,
|
||||||
} = useGeminiStream(
|
} = activeStream;
|
||||||
config.getGeminiClient(),
|
|
||||||
historyManager.history,
|
|
||||||
historyManager.addItem,
|
|
||||||
config,
|
|
||||||
settings,
|
|
||||||
setDebugMessage,
|
|
||||||
handleSlashCommand,
|
|
||||||
shellModeActive,
|
|
||||||
getPreferredEditor,
|
|
||||||
onAuthError,
|
|
||||||
performMemoryRefresh,
|
|
||||||
modelSwitchedFromQuotaError,
|
|
||||||
setModelSwitchedFromQuotaError,
|
|
||||||
onCancelSubmit,
|
|
||||||
setEmbeddedShellFocused,
|
|
||||||
terminalWidth,
|
|
||||||
terminalHeight,
|
|
||||||
embeddedShellFocused,
|
|
||||||
consumePendingHints,
|
|
||||||
);
|
|
||||||
|
|
||||||
const pendingHistoryItems = useMemo(
|
const pendingHistoryItems = useMemo(
|
||||||
() => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems],
|
() => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems],
|
||||||
@@ -1783,7 +1805,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
|||||||
if (keyMatchers[Command.QUIT](key)) {
|
if (keyMatchers[Command.QUIT](key)) {
|
||||||
// If the user presses Ctrl+C, we want to cancel any ongoing requests.
|
// If the user presses Ctrl+C, we want to cancel any ongoing requests.
|
||||||
// This should happen regardless of the count.
|
// This should happen regardless of the count.
|
||||||
cancelOngoingRequest?.();
|
void cancelOngoingRequest?.();
|
||||||
|
|
||||||
handleCtrlCPress();
|
handleCtrlCPress();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user