From bb52149a06012ddb5e5535d60decf40aa11ac344 Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Mon, 5 May 2025 20:48:34 +0000 Subject: [PATCH] Move Intro to Help and only display after help command. --- packages/cli/src/ui/App.tsx | 16 ++++++++++++---- .../src/ui/components/{Intro.tsx => Help.tsx} | 4 ++-- .../cli/src/ui/hooks/slashCommandProcessor.ts | 12 +++--------- packages/cli/src/ui/hooks/useGeminiStream.ts | 4 ++++ 4 files changed, 21 insertions(+), 15 deletions(-) rename packages/cli/src/ui/components/{Intro.tsx => Help.tsx} (94%) diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index e116c524..3052fb17 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useCallback, useMemo, useRef, useState } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { Box, Static, Text, useStdout } from 'ink'; import { StreamingState, type HistoryItem } from './types.js'; import { useGeminiStream } from './hooks/useGeminiStream.js'; @@ -19,7 +19,7 @@ import { ThemeDialog } from './components/ThemeDialog.js'; import { useStartupWarnings } from './hooks/useAppEffects.js'; import { shortenPath, type Config } from '@gemini-code/server'; import { Colors } from './colors.js'; -import { Intro } from './components/Intro.js'; +import { Help } from './components/Help.js'; import { LoadedSettings } from '../config/settings.js'; import { Tips } from './components/Tips.js'; import { ConsoleOutput } from './components/ConsolePatcher.js'; @@ -37,6 +37,7 @@ interface AppProps { export const App = ({ config, settings, cliVersion }: AppProps) => { const [history, setHistory] = useState([]); const [startupWarnings, setStartupWarnings] = useState([]); + const [showHelp, setShowHelp] = useState(false); const { isThemeDialogOpen, openThemeDialog, @@ -55,7 +56,13 @@ export const App = ({ config, settings, cliVersion }: AppProps) => { initError, debugMessage, slashCommands, - } = useGeminiStream(setHistory, refreshStatic, config, openThemeDialog); + } = useGeminiStream( + setHistory, + refreshStatic, + setShowHelp, + config, + openThemeDialog, + ); const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState); @@ -139,7 +146,6 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
- ); } @@ -167,6 +173,8 @@ export const App = ({ config, settings, cliVersion }: AppProps) => { )} + {showHelp && } + {startupWarnings.length > 0 && ( = ({ commands }) => ( +export const Help: React.FC = ({ commands }) => ( Abilities: diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index 5e10a245..33b59b68 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -29,6 +29,7 @@ const addHistoryItem = ( export const useSlashCommandProcessor = ( setHistory: React.Dispatch>, refreshStatic: () => void, + setShowHelp: React.Dispatch>, setDebugMessage: React.Dispatch>, getNextMessageId: (baseTimestamp: number) => number, openThemeDialog: () => void, @@ -38,15 +39,8 @@ export const useSlashCommandProcessor = ( name: 'help', description: 'for help on gemini-code', action: (_value: PartListUnion) => { - const helpText = - 'I am an interactive CLI tool assistant designed to ' + - 'help with software engineering tasks. I can use tools to read ' + - 'and write files, search code, execute bash commands, and more ' + - 'to assist with development workflows. I will explain commands ' + - 'and ask for permission before running them and will not ' + - 'commit changes unless explicitly instructed.'; - const timestamp = getNextMessageId(Date.now()); - addHistoryItem(setHistory, { type: 'info', text: helpText }, timestamp); + setDebugMessage('Opening help.'); + setShowHelp(true); }, }, { diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 2931bbc3..1761563b 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -48,6 +48,7 @@ const addHistoryItem = ( export const useGeminiStream = ( setHistory: React.Dispatch>, refreshStatic: () => void, + setShowHelp: React.Dispatch>, config: Config, openThemeDialog: () => void, ) => { @@ -74,6 +75,7 @@ export const useGeminiStream = ( const { handleSlashCommand, slashCommands } = useSlashCommandProcessor( setHistory, refreshStatic, + setShowHelp, setDebugMessage, getNextMessageId, openThemeDialog, @@ -154,6 +156,8 @@ export const useGeminiStream = ( messageIdCounterRef.current = 0; // Reset counter for this new submission let queryToSendToGemini: PartListUnion | null = null; + setShowHelp(false); + if (typeof query === 'string') { const trimmedQuery = query.trim(); setDebugMessage(`User query: '${trimmedQuery}'`);