From 651a5434036f1906f19523f1265686c168305060 Mon Sep 17 00:00:00 2001 From: Jaana Dogan Date: Mon, 21 Apr 2025 11:49:46 -0700 Subject: [PATCH] Remove gemini-stream.ts (#84) This module is no longer needed and the types can be provided from types. --- packages/cli/src/core/gemini-stream.ts | 19 ------------------- packages/cli/src/ui/App.tsx | 3 +-- packages/cli/src/ui/hooks/useGeminiStream.ts | 2 +- .../cli/src/ui/hooks/useLoadingIndicator.ts | 2 +- packages/cli/src/ui/types.ts | 14 ++++++++++++++ 5 files changed, 17 insertions(+), 23 deletions(-) delete mode 100644 packages/cli/src/core/gemini-stream.ts diff --git a/packages/cli/src/core/gemini-stream.ts b/packages/cli/src/core/gemini-stream.ts deleted file mode 100644 index d41c50d7..00000000 --- a/packages/cli/src/core/gemini-stream.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2025 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -// Only defining the state enum needed by the UI -export enum StreamingState { - Idle = 'idle', - Responding = 'responding', - WaitingForConfirmation = 'waiting_for_confirmation', -} - -// Copied from server/src/core/turn.ts for CLI usage -export enum GeminiEventType { - Content = 'content', - ToolCallRequest = 'tool_call_request', - // Add other event types if the UI hook needs to handle them -} diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index 724036e2..f3e8b742 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -6,7 +6,7 @@ import React, { useState, useMemo } from 'react'; import { Box, Text } from 'ink'; -import type { HistoryItem } from './types.js'; +import { StreamingState, type HistoryItem } from './types.js'; import { useGeminiStream } from './hooks/useGeminiStream.js'; import { useLoadingIndicator } from './hooks/useLoadingIndicator.js'; import { useInputHistory } from './hooks/useInputHistory.js'; @@ -15,7 +15,6 @@ import { HistoryDisplay } from './components/HistoryDisplay.js'; import { LoadingIndicator } from './components/LoadingIndicator.js'; import { InputPrompt } from './components/InputPrompt.js'; import { Footer } from './components/Footer.js'; -import { StreamingState } from '../core/gemini-stream.js'; import { ITermDetectionWarning } from './utils/itermDetection.js'; import { useStartupWarnings, diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 62851019..2728c394 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -30,11 +30,11 @@ import { type Part, } from '@google/genai'; import { + StreamingState, HistoryItem, IndividualToolCallDisplay, ToolCallStatus, } from '../types.js'; -import { StreamingState } from '../../core/gemini-stream.js'; import { toolRegistry } from '../../tools/tool-registry.js'; const addHistoryItem = ( diff --git a/packages/cli/src/ui/hooks/useLoadingIndicator.ts b/packages/cli/src/ui/hooks/useLoadingIndicator.ts index 1dab9756..6d1d77d4 100644 --- a/packages/cli/src/ui/hooks/useLoadingIndicator.ts +++ b/packages/cli/src/ui/hooks/useLoadingIndicator.ts @@ -9,7 +9,7 @@ import { WITTY_LOADING_PHRASES, PHRASE_CHANGE_INTERVAL_MS, } from '../constants.js'; -import { StreamingState } from '../../core/gemini-stream.js'; +import { StreamingState } from '../types.js'; export const useLoadingIndicator = (streamingState: StreamingState) => { const [elapsedTime, setElapsedTime] = useState(0); diff --git a/packages/cli/src/ui/types.ts b/packages/cli/src/ui/types.ts index df8325b3..41b2a944 100644 --- a/packages/cli/src/ui/types.ts +++ b/packages/cli/src/ui/types.ts @@ -7,6 +7,20 @@ import { ToolCallConfirmationDetails } from '@gemini-code/server'; import { ToolResultDisplay } from '../tools/tools.js'; +// Only defining the state enum needed by the UI +export enum StreamingState { + Idle = 'idle', + Responding = 'responding', + WaitingForConfirmation = 'waiting_for_confirmation', +} + +// Copied from server/src/core/turn.ts for CLI usage +export enum GeminiEventType { + Content = 'content', + ToolCallRequest = 'tool_call_request', + // Add other event types if the UI hook needs to handle them +} + export enum ToolCallStatus { Pending = 'Pending', Invoked = 'Invoked',