Sanitize command names and descriptions (#17228)

This commit is contained in:
Emily Hedlund
2026-01-22 11:41:51 -05:00
committed by GitHub
parent 048c30513e
commit d956c5b221
6 changed files with 134 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { type SlashCommand, CommandKind } from '../commands/types.js';
import { KEYBOARD_SHORTCUTS_URL } from '../constants.js';
import { sanitizeForListDisplay } from '../utils/textUtils.js';
interface Help {
commands: readonly SlashCommand[];
@@ -77,7 +78,8 @@ export const Help: React.FC<Help> = ({ commands }) => (
{command.kind === CommandKind.MCP_PROMPT && (
<Text color={theme.text.secondary}> [MCP]</Text>
)}
{command.description && ' - ' + command.description}
{command.description &&
' - ' + sanitizeForListDisplay(command.description, 100)}
</Text>
{command.subCommands &&
command.subCommands
@@ -88,7 +90,8 @@ export const Help: React.FC<Help> = ({ commands }) => (
{' '}
{subCommand.name}
</Text>
{subCommand.description && ' - ' + subCommand.description}
{subCommand.description &&
' - ' + sanitizeForListDisplay(subCommand.description, 100)}
</Text>
))}
</Box>

View File

@@ -9,6 +9,8 @@ import { theme } from '../semantic-colors.js';
import { ExpandableText, MAX_WIDTH } from './shared/ExpandableText.js';
import { CommandKind } from '../commands/types.js';
import { Colors } from '../colors.js';
import { sanitizeForListDisplay } from '../utils/textUtils.js';
export interface Suggestion {
label: string;
value: string;
@@ -115,7 +117,7 @@ export function SuggestionsDisplay({
{suggestion.description && (
<Box flexGrow={1} paddingLeft={3}>
<Text color={textColor} wrap="truncate">
{suggestion.description}
{sanitizeForListDisplay(suggestion.description, 100)}
</Text>
</Box>
)}