2025-09-06 01:39:02 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-10-10 15:34:44 -04:00
|
|
|
import { Box, Text, useIsScreenReaderEnabled } from 'ink';
|
2025-09-06 01:39:02 -04:00
|
|
|
import { useAppContext } from '../contexts/AppContext.js';
|
|
|
|
|
import { useUIState } from '../contexts/UIStateContext.js';
|
2025-09-10 10:57:07 -07:00
|
|
|
import { theme } from '../semantic-colors.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
import { StreamingState } from '../types.js';
|
|
|
|
|
import { UpdateNotification } from './UpdateNotification.js';
|
|
|
|
|
|
2025-10-14 02:31:39 +09:00
|
|
|
import { GEMINI_DIR } from '@google/gemini-cli-core';
|
2025-10-10 15:34:44 -04:00
|
|
|
import { homedir } from 'node:os';
|
|
|
|
|
import path from 'node:path';
|
|
|
|
|
|
2025-10-14 02:31:39 +09:00
|
|
|
const settingsPath = path.join(homedir(), GEMINI_DIR, 'settings.json');
|
2025-10-10 15:34:44 -04:00
|
|
|
|
2025-09-06 01:39:02 -04:00
|
|
|
export const Notifications = () => {
|
|
|
|
|
const { startupWarnings } = useAppContext();
|
|
|
|
|
const { initError, streamingState, updateInfo } = useUIState();
|
2025-10-10 15:34:44 -04:00
|
|
|
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
2025-09-06 01:39:02 -04:00
|
|
|
const showStartupWarnings = startupWarnings.length > 0;
|
|
|
|
|
const showInitError =
|
|
|
|
|
initError && streamingState !== StreamingState.Responding;
|
|
|
|
|
|
2025-10-10 15:34:44 -04:00
|
|
|
if (
|
|
|
|
|
!showStartupWarnings &&
|
|
|
|
|
!showInitError &&
|
|
|
|
|
!updateInfo &&
|
|
|
|
|
!isScreenReaderEnabled
|
|
|
|
|
) {
|
2025-09-06 01:39:02 -04:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2025-10-10 15:34:44 -04:00
|
|
|
{isScreenReaderEnabled && (
|
|
|
|
|
<Text>
|
|
|
|
|
You are currently in screen reader-friendly view. To switch out, open{' '}
|
|
|
|
|
{settingsPath} and remove the entry for {'"screenReader"'}.
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2025-09-06 01:39:02 -04:00
|
|
|
{updateInfo && <UpdateNotification message={updateInfo.message} />}
|
|
|
|
|
{showStartupWarnings && (
|
|
|
|
|
<Box
|
|
|
|
|
borderStyle="round"
|
2025-09-10 10:57:07 -07:00
|
|
|
borderColor={theme.status.warning}
|
2025-09-06 01:39:02 -04:00
|
|
|
paddingX={1}
|
|
|
|
|
marginY={1}
|
|
|
|
|
flexDirection="column"
|
|
|
|
|
>
|
|
|
|
|
{startupWarnings.map((warning, index) => (
|
2025-09-10 10:57:07 -07:00
|
|
|
<Text key={index} color={theme.status.warning}>
|
2025-09-06 01:39:02 -04:00
|
|
|
{warning}
|
|
|
|
|
</Text>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
{showInitError && (
|
|
|
|
|
<Box
|
|
|
|
|
borderStyle="round"
|
2025-09-10 10:57:07 -07:00
|
|
|
borderColor={theme.status.error}
|
2025-09-06 01:39:02 -04:00
|
|
|
paddingX={1}
|
|
|
|
|
marginBottom={1}
|
|
|
|
|
>
|
2025-09-10 10:57:07 -07:00
|
|
|
<Text color={theme.status.error}>
|
2025-09-06 01:39:02 -04:00
|
|
|
Initialization Error: {initError}
|
|
|
|
|
</Text>
|
2025-09-10 10:57:07 -07:00
|
|
|
<Text color={theme.status.error}>
|
2025-09-06 01:39:02 -04:00
|
|
|
{' '}
|
|
|
|
|
Please check API key and configuration.
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|