import { feature } from 'bun:bundle' import * as React from 'react' import { Box, Text } from 'src/ink.js' import { getPlatform } from 'src/utils/platform.js' import { isKeybindingCustomizationEnabled } from '../../keybindings/loadUserBindings.js' import { useShortcutDisplay } from '../../keybindings/useShortcutDisplay.js' import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js' import { isFastModeAvailable, isFastModeEnabled } from '../../utils/fastMode.js' import { getNewlineInstructions } from './utils.js' /** Format a shortcut for display in the help menu (e.g., "ctrl+o" → "ctrl + o") */ function formatShortcut(shortcut: string): string { return shortcut.replace(/\+/g, ' + ') } type Props = { dimColor?: boolean fixedWidth?: boolean gap?: number paddingX?: number } export function PromptInputHelpMenu(props: Props): React.ReactNode { const { dimColor, fixedWidth, gap, paddingX } = props // Get configured shortcuts from keybinding system const transcriptShortcut = formatShortcut( useShortcutDisplay('app:toggleTranscript', 'Global', 'ctrl+o'), ) const todosShortcut = formatShortcut( useShortcutDisplay('app:toggleTodos', 'Global', 'ctrl+t'), ) const undoShortcut = formatShortcut( useShortcutDisplay('chat:undo', 'Chat', 'ctrl+_'), ) const stashShortcut = formatShortcut( useShortcutDisplay('chat:stash', 'Chat', 'ctrl+s'), ) const cycleModeShortcut = formatShortcut( useShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab'), ) const modelPickerShortcut = formatShortcut( useShortcutDisplay('chat:modelPicker', 'Chat', 'alt+p'), ) const fastModeShortcut = formatShortcut( useShortcutDisplay('chat:fastMode', 'Chat', 'alt+o'), ) const externalEditorShortcut = formatShortcut( useShortcutDisplay('chat:externalEditor', 'Chat', 'ctrl+g'), ) const terminalShortcut = formatShortcut( useShortcutDisplay('app:toggleTerminal', 'Global', 'meta+j'), ) const imagePasteShortcut = formatShortcut( useShortcutDisplay('chat:imagePaste', 'Chat', 'ctrl+v'), ) // Compute terminal shortcut element outside JSX to satisfy feature() constraint const terminalShortcutElement = feature('TERMINAL_PANEL') ? ( getFeatureValue_CACHED_MAY_BE_STALE('tengu_terminal_panel', false) ? ( {terminalShortcut} for terminal ) : null ) : null return ( ! for bash mode / for commands @ for file paths & for background /btw for side question double tap esc to clear input {cycleModeShortcut}{' '} {process.env.USER_TYPE === 'ant' ? 'to cycle modes' : 'to auto-accept edits'} {transcriptShortcut} for verbose output {todosShortcut} to toggle tasks {terminalShortcutElement} {getNewlineInstructions()} {undoShortcut} to undo {getPlatform() !== 'windows' && ( ctrl + z to suspend )} {imagePasteShortcut} to paste images {modelPickerShortcut} to switch model {isFastModeEnabled() && isFastModeAvailable() && ( {fastModeShortcut} to toggle fast mode )} {stashShortcut} to stash prompt {externalEditorShortcut} to edit in $EDITOR {isKeybindingCustomizationEnabled() && ( /keybindings to customize )} ) }