fix: remove extra initError (#173)
This commit is contained in:
parent
86c3a3234f
commit
1a64268bb0
|
@ -18,10 +18,7 @@ import { InputPrompt } from './components/InputPrompt.js';
|
||||||
import { Footer } from './components/Footer.js';
|
import { Footer } from './components/Footer.js';
|
||||||
import { ThemeDialog } from './components/ThemeDialog.js';
|
import { ThemeDialog } from './components/ThemeDialog.js';
|
||||||
import { ITermDetectionWarning } from './utils/itermDetection.js';
|
import { ITermDetectionWarning } from './utils/itermDetection.js';
|
||||||
import {
|
import { useStartupWarnings } from './hooks/useAppEffects.js';
|
||||||
useStartupWarnings,
|
|
||||||
useInitializationErrorEffect,
|
|
||||||
} from './hooks/useAppEffects.js';
|
|
||||||
import { shortenPath, type Config } from '@gemini-code/server';
|
import { shortenPath, type Config } from '@gemini-code/server';
|
||||||
import { Colors } from './colors.js';
|
import { Colors } from './colors.js';
|
||||||
import { Tips } from './components/Tips.js';
|
import { Tips } from './components/Tips.js';
|
||||||
|
@ -47,7 +44,6 @@ export const App = ({ config, cliVersion }: AppProps) => {
|
||||||
} = useThemeCommand();
|
} = useThemeCommand();
|
||||||
|
|
||||||
useStartupWarnings(setStartupWarnings);
|
useStartupWarnings(setStartupWarnings);
|
||||||
useInitializationErrorEffect(initError, history, setHistory);
|
|
||||||
|
|
||||||
const handleFinalSubmit = useCallback(
|
const handleFinalSubmit = useCallback(
|
||||||
(submittedValue: string) => {
|
(submittedValue: string) => {
|
||||||
|
@ -105,6 +101,37 @@ export const App = ({ config, cliVersion }: AppProps) => {
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{isThemeDialogOpen ? (
|
||||||
|
<ThemeDialog
|
||||||
|
onSelect={handleThemeSelect}
|
||||||
|
onHighlight={handleThemeHighlight}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Box flexDirection="column">
|
||||||
|
<HistoryDisplay history={history} onSubmit={submitQuery} />
|
||||||
|
<LoadingIndicator
|
||||||
|
isLoading={streamingState === StreamingState.Responding}
|
||||||
|
currentLoadingPhrase={currentLoadingPhrase}
|
||||||
|
elapsedTime={elapsedTime}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{isInputActive && (
|
||||||
|
<>
|
||||||
|
<Box>
|
||||||
|
<Text color={Colors.SubtleComment}>cwd: </Text>
|
||||||
|
<Text color={Colors.LightBlue}>
|
||||||
|
{shortenPath(config.getTargetDir(), /*maxLength*/ 70)}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<InputPrompt onSubmit={handleHistorySubmit} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{initError && streamingState !== StreamingState.Responding && (
|
{initError && streamingState !== StreamingState.Responding && (
|
||||||
<Box
|
<Box
|
||||||
borderStyle="round"
|
borderStyle="round"
|
||||||
|
@ -137,37 +164,6 @@ export const App = ({ config, cliVersion }: AppProps) => {
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isThemeDialogOpen ? (
|
|
||||||
<ThemeDialog
|
|
||||||
onSelect={handleThemeSelect}
|
|
||||||
onHighlight={handleThemeHighlight}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Box flexDirection="column">
|
|
||||||
<HistoryDisplay history={history} onSubmit={submitQuery} />
|
|
||||||
<LoadingIndicator
|
|
||||||
isLoading={streamingState === StreamingState.Responding}
|
|
||||||
currentLoadingPhrase={currentLoadingPhrase}
|
|
||||||
elapsedTime={elapsedTime}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{isInputActive && (
|
|
||||||
<>
|
|
||||||
<Box>
|
|
||||||
<Text color={Colors.SubtleComment}>cwd: </Text>
|
|
||||||
<Text color={Colors.LightBlue}>
|
|
||||||
{shortenPath(config.getTargetDir(), /*maxLength*/ 70)}
|
|
||||||
</Text>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<InputPrompt onSubmit={handleHistorySubmit} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Footer
|
<Footer
|
||||||
config={config}
|
config={config}
|
||||||
queryLength={query.length}
|
queryLength={query.length}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { useEffect } from 'react';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { HistoryItem } from '../types.js';
|
|
||||||
import { getErrorMessage } from '@gemini-code/server';
|
import { getErrorMessage } from '@gemini-code/server';
|
||||||
|
|
||||||
const warningsFilePath = path.join(os.tmpdir(), 'gemini-code-cli-warnings.txt');
|
const warningsFilePath = path.join(os.tmpdir(), 'gemini-code-cli-warnings.txt');
|
||||||
|
@ -41,28 +40,3 @@ export function useStartupWarnings(
|
||||||
}
|
}
|
||||||
}, [setStartupWarnings]); // Include setStartupWarnings in dependency array
|
}, [setStartupWarnings]); // Include setStartupWarnings in dependency array
|
||||||
}
|
}
|
||||||
|
|
||||||
// Effect to handle initialization errors
|
|
||||||
export function useInitializationErrorEffect(
|
|
||||||
initError: string | null,
|
|
||||||
history: HistoryItem[],
|
|
||||||
setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
|
|
||||||
) {
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
initError &&
|
|
||||||
!history.some(
|
|
||||||
(item) => item.type === 'error' && item.text?.includes(initError),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
setHistory((prev) => [
|
|
||||||
...prev,
|
|
||||||
{
|
|
||||||
id: Date.now(),
|
|
||||||
type: 'error',
|
|
||||||
text: `Initialization Error: ${initError}. Please check API key and configuration.`,
|
|
||||||
} as HistoryItem,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}, [initError, history, setHistory]); // Include setHistory in dependency array
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue