diff --git a/packages/cli/src/ui/components/ShellConfirmationDialog.tsx b/packages/cli/src/ui/components/ShellConfirmationDialog.tsx index 04e57364..5a210577 100644 --- a/packages/cli/src/ui/components/ShellConfirmationDialog.tsx +++ b/packages/cli/src/ui/components/ShellConfirmationDialog.tsx @@ -8,6 +8,7 @@ import { ToolConfirmationOutcome } from '@google/gemini-cli-core'; import { Box, Text } from 'ink'; import React from 'react'; import { Colors } from '../colors.js'; +import { RenderInline } from '../utils/InlineMarkdownRenderer.js'; import { RadioButtonSelect, RadioSelectItem, @@ -86,7 +87,7 @@ export const ShellConfirmationDialog: React.FC< > {commands.map((cmd) => ( - {cmd} + ))} diff --git a/packages/cli/src/ui/components/messages/InfoMessage.tsx b/packages/cli/src/ui/components/messages/InfoMessage.tsx index c9129999..18175875 100644 --- a/packages/cli/src/ui/components/messages/InfoMessage.tsx +++ b/packages/cli/src/ui/components/messages/InfoMessage.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { Text, Box } from 'ink'; import { Colors } from '../../colors.js'; +import { RenderInline } from '../../utils/InlineMarkdownRenderer.js'; interface InfoMessageProps { text: string; @@ -23,7 +24,7 @@ export const InfoMessage: React.FC = ({ text }) => { - {text} + diff --git a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx index 2f93609e..690da7e5 100644 --- a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { Box, Text } from 'ink'; import { DiffRenderer } from './DiffRenderer.js'; import { Colors } from '../../colors.js'; +import { RenderInline } from '../../utils/InlineMarkdownRenderer.js'; import { ToolCallConfirmationDetails, ToolConfirmationOutcome, @@ -222,12 +223,17 @@ export const ToolConfirmationMessage: React.FC< bodyContent = ( - {infoProps.prompt} + + + {displayUrls && infoProps.urls && infoProps.urls.length > 0 && ( URLs to fetch: {infoProps.urls.map((url) => ( - - {url} + + {' '} + - + ))} )} diff --git a/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx b/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx index ff8d6257..4c05a28f 100644 --- a/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx +++ b/packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx @@ -22,10 +22,15 @@ interface RenderInlineProps { } const RenderInlineInternal: React.FC = ({ text }) => { + // Early return for plain text without markdown or URLs + if (!/[*_~`<[https?:]/.test(text)) { + return {text}; + } + const nodes: React.ReactNode[] = []; let lastIndex = 0; const inlineRegex = - /(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|.*?<\/u>)/g; + /(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|.*?<\/u>|https?:\/\/\S+)/g; let match; while ((match = inlineRegex.exec(text)) !== null) { @@ -126,6 +131,12 @@ const RenderInlineInternal: React.FC = ({ text }) => { )} ); + } else if (fullMatch.match(/^https?:\/\//)) { + renderedNode = ( + + {fullMatch} + + ); } } catch (e) { console.error('Error parsing inline markdown part:', fullMatch, e);