Adding some wiring to allow the Ink app to warn if there are local development changes that haven't been captured in the recent build of the Gemini CLI.

This commit is contained in:
Evan Senter
2025-04-18 17:35:29 +01:00
parent e0339993ae
commit 1bfc62dcc2
5 changed files with 173 additions and 3 deletions

View File

@@ -1,5 +1,8 @@
import React, { useState, useEffect } from 'react';
import { Box, Text } from 'ink';
import fs from 'fs';
import path from 'path';
import os from 'os';
import type { HistoryItem } from './types.js';
import { useGeminiStream } from './hooks/useGeminiStream.js';
import { useLoadingIndicator } from './hooks/useLoadingIndicator.js';
@@ -12,6 +15,8 @@ import Footer from './components/Footer.js';
import { StreamingState } from '../core/gemini-stream.js';
import { PartListUnion } from '@google/genai';
const warningsFilePath = path.join(os.tmpdir(), 'gemini-code-cli-warnings.txt');
interface AppProps {
directory: string;
}
@@ -19,11 +24,31 @@ interface AppProps {
const App = ({ directory }: AppProps) => {
const [query, setQuery] = useState('');
const [history, setHistory] = useState<HistoryItem[]>([]);
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
const { streamingState, submitQuery, initError } =
useGeminiStream(setHistory);
const { elapsedTime, currentLoadingPhrase } =
useLoadingIndicator(streamingState);
useEffect(() => {
try {
if (fs.existsSync(warningsFilePath)) {
console.log('[App] Found warnings file:', warningsFilePath);
const warningsContent = fs.readFileSync(warningsFilePath, 'utf-8');
setStartupWarnings(warningsContent.split('\n').filter(line => line.trim() !== ''));
try {
fs.unlinkSync(warningsFilePath);
} catch (unlinkErr: any) {
console.warn(`[App] Warning: Could not delete warnings file: ${unlinkErr.message}`);
}
} else {
console.log('[App] No warnings file found.');
}
} catch (err: any) {
console.error(`[App] Error checking/reading warnings file: ${err.message}`);
}
}, []);
const handleInputSubmit = (value: PartListUnion) => {
submitQuery(value)
.then(() => {
@@ -63,6 +88,22 @@ const App = ({ directory }: AppProps) => {
<Box flexDirection="column" padding={1} marginBottom={1} width="100%">
<Header cwd={directory} />
{startupWarnings.length > 0 && (
<Box
borderStyle="round"
borderColor="yellow"
paddingX={1}
marginY={1}
flexDirection="column"
>
{startupWarnings.map((warning, index) => (
<Text key={index} color="yellow">
{warning}
</Text>
))}
</Box>
)}
<Tips />
{initError &&