mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Warn if npm run start is out of date. (#20)
* 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. * Adding a new useAppEffects.ts file that wores some useEffect handlers in. * Updating package-lock.json to resolve `npm ci` issues. * Updating package-lock.json and package.json to resolve `npm ci` issues.
This commit is contained in:
61
packages/cli/src/ui/hooks/useAppEffects.ts
Normal file
61
packages/cli/src/ui/hooks/useAppEffects.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { useEffect } from 'react';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import type { HistoryItem } from '../types.js';
|
||||
|
||||
const warningsFilePath = path.join(os.tmpdir(), 'gemini-code-cli-warnings.txt');
|
||||
|
||||
// Effect to handle startup warnings
|
||||
export function useStartupWarnings(
|
||||
setStartupWarnings: React.Dispatch<React.SetStateAction<string[]>>,
|
||||
) {
|
||||
useEffect(() => {
|
||||
try {
|
||||
if (fs.existsSync(warningsFilePath)) {
|
||||
const warningsContent = fs.readFileSync(warningsFilePath, 'utf-8');
|
||||
setStartupWarnings(
|
||||
warningsContent.split('\n').filter((line) => line.trim() !== ''),
|
||||
);
|
||||
try {
|
||||
fs.unlinkSync(warningsFilePath);
|
||||
} catch (unlinkErr: any) {
|
||||
setStartupWarnings((prev) => [
|
||||
...prev,
|
||||
`Warning: Could not delete temporary warnings file.`,
|
||||
]);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
setStartupWarnings((prev) => [
|
||||
...prev,
|
||||
`Error checking/reading warnings file: ${err.message}`,
|
||||
]);
|
||||
}
|
||||
}, [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
|
||||
}
|
||||
Reference in New Issue
Block a user