Show notification in screen reader mode (#10900)

This commit is contained in:
christine betts
2025-10-10 15:34:44 -04:00
committed by GitHub
parent a5e47c62e4
commit 0a7ee67707
3 changed files with 25 additions and 4 deletions
+5
View File
@@ -160,6 +160,11 @@ their corresponding top-level category object in your `settings.json` file.
- **Description:** Disable loading phrases for accessibility. - **Description:** Disable loading phrases for accessibility.
- **Default:** `false` - **Default:** `false`
- **`ui.accessibility.screenReader`** (boolean):
- **Description:** Show plaintext interactive view that is more screen reader
friendly.
- **Default:** `false`
- **`ui.customWittyPhrases`** (array of strings): - **`ui.customWittyPhrases`** (array of strings):
- **Description:** A list of custom phrases to display during loading states. - **Description:** A list of custom phrases to display during loading states.
When provided, the CLI will cycle through these phrases instead of the When provided, the CLI will cycle through these phrases instead of the
+1 -1
View File
@@ -452,7 +452,7 @@ const SETTINGS_SCHEMA = {
label: 'Screen Reader Mode', label: 'Screen Reader Mode',
category: 'UI', category: 'UI',
requiresRestart: true, requiresRestart: true,
default: undefined as boolean | undefined, default: false,
description: description:
'Render output in plain-text to be more screen reader accessible', 'Render output in plain-text to be more screen reader accessible',
showInDialog: true, showInDialog: true,
@@ -4,27 +4,43 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { Box, Text } from 'ink'; import { Box, Text, useIsScreenReaderEnabled } from 'ink';
import { useAppContext } from '../contexts/AppContext.js'; import { useAppContext } from '../contexts/AppContext.js';
import { useUIState } from '../contexts/UIStateContext.js'; import { useUIState } from '../contexts/UIStateContext.js';
import { theme } from '../semantic-colors.js'; import { theme } from '../semantic-colors.js';
import { StreamingState } from '../types.js'; import { StreamingState } from '../types.js';
import { UpdateNotification } from './UpdateNotification.js'; import { UpdateNotification } from './UpdateNotification.js';
import { homedir } from 'node:os';
import path from 'node:path';
const settingsPath = path.join(homedir(), '.gemini', 'settings.json');
export const Notifications = () => { export const Notifications = () => {
const { startupWarnings } = useAppContext(); const { startupWarnings } = useAppContext();
const { initError, streamingState, updateInfo } = useUIState(); const { initError, streamingState, updateInfo } = useUIState();
const isScreenReaderEnabled = useIsScreenReaderEnabled();
const showStartupWarnings = startupWarnings.length > 0; const showStartupWarnings = startupWarnings.length > 0;
const showInitError = const showInitError =
initError && streamingState !== StreamingState.Responding; initError && streamingState !== StreamingState.Responding;
if (!showStartupWarnings && !showInitError && !updateInfo) { if (
!showStartupWarnings &&
!showInitError &&
!updateInfo &&
!isScreenReaderEnabled
) {
return null; return null;
} }
return ( return (
<> <>
{isScreenReaderEnabled && (
<Text>
You are currently in screen reader-friendly view. To switch out, open{' '}
{settingsPath} and remove the entry for {'"screenReader"'}.
</Text>
)}
{updateInfo && <UpdateNotification message={updateInfo.message} />} {updateInfo && <UpdateNotification message={updateInfo.message} />}
{showStartupWarnings && ( {showStartupWarnings && (
<Box <Box