refactor(cli): Centralize history management via useHistoryManager hook (#261)

This commit is contained in:
Allen Hutchison
2025-05-06 16:20:28 -07:00
committed by GitHub
parent adeda6a5b3
commit 7d13f24288
7 changed files with 293 additions and 455 deletions

View File

@@ -27,6 +27,7 @@ import { HistoryItemDisplay } from './components/HistoryItemDisplay.js';
import { useCompletion } from './hooks/useCompletion.js';
import { SuggestionsDisplay } from './components/SuggestionsDisplay.js';
import { isAtCommand, isSlashCommand } from './utils/commandUtils.js';
import { useHistory } from './hooks/useHistoryManager.js';
interface AppProps {
config: Config;
@@ -35,7 +36,7 @@ interface AppProps {
}
export const App = ({ config, settings, cliVersion }: AppProps) => {
const [history, setHistory] = useState<HistoryItem[]>([]);
const { history, addItem, updateItem, clearItems } = useHistory();
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
const [showHelp, setShowHelp] = useState<boolean>(false);
const {
@@ -57,7 +58,9 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
debugMessage,
slashCommands,
} = useGeminiStream(
setHistory,
addItem,
updateItem,
clearItems,
refreshStatic,
setShowHelp,
config,