mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-16 16:21:27 -07:00
split context (#24623)
This commit is contained in:
28
packages/cli/src/ui/contexts/InputContext.tsx
Normal file
28
packages/cli/src/ui/contexts/InputContext.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import type { TextBuffer } from '../components/shared/text-buffer.js';
|
||||
|
||||
export interface InputState {
|
||||
buffer: TextBuffer;
|
||||
userMessages: string[];
|
||||
shellModeActive: boolean;
|
||||
showEscapePrompt: boolean;
|
||||
copyModeEnabled: boolean | undefined;
|
||||
inputWidth: number;
|
||||
suggestionsWidth: number;
|
||||
}
|
||||
|
||||
export const InputContext = createContext<InputState | null>(null);
|
||||
|
||||
export const useInputState = () => {
|
||||
const context = useContext(InputContext);
|
||||
if (!context) {
|
||||
throw new Error('useInputState must be used within an InputProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -17,7 +17,7 @@ import type {
|
||||
PermissionConfirmationRequest,
|
||||
} from '../types.js';
|
||||
import type { CommandContext, SlashCommand } from '../commands/types.js';
|
||||
import type { TextBuffer } from '../components/shared/text-buffer.js';
|
||||
|
||||
import type {
|
||||
IdeContext,
|
||||
ApprovalMode,
|
||||
@@ -143,11 +143,6 @@ export interface UIState {
|
||||
initError: string | null;
|
||||
pendingGeminiHistoryItems: HistoryItemWithoutId[];
|
||||
thought: ThoughtSummary | null;
|
||||
shellModeActive: boolean;
|
||||
userMessages: string[];
|
||||
buffer: TextBuffer;
|
||||
inputWidth: number;
|
||||
suggestionsWidth: number;
|
||||
isInputActive: boolean;
|
||||
isResuming: boolean;
|
||||
shouldShowIdePrompt: boolean;
|
||||
@@ -162,7 +157,6 @@ export interface UIState {
|
||||
renderMarkdown: boolean;
|
||||
ctrlCPressedOnce: boolean;
|
||||
ctrlDPressedOnce: boolean;
|
||||
showEscapePrompt: boolean;
|
||||
shortcutsHelpVisible: boolean;
|
||||
cleanUiDetailsVisible: boolean;
|
||||
elapsedTime: number;
|
||||
@@ -207,7 +201,6 @@ export interface UIState {
|
||||
embeddedShellFocused: boolean;
|
||||
showDebugProfiler: boolean;
|
||||
showFullTodos: boolean;
|
||||
copyModeEnabled: boolean;
|
||||
bannerData: {
|
||||
defaultText: string;
|
||||
warningText: string;
|
||||
|
||||
Reference in New Issue
Block a user