parent
133f0230c3
commit
7b03a64b85
|
@ -8,6 +8,7 @@ import { ToolConfirmationOutcome } from '@google/gemini-cli-core';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Colors } from '../colors.js';
|
import { Colors } from '../colors.js';
|
||||||
|
import { RenderInline } from '../utils/InlineMarkdownRenderer.js';
|
||||||
import {
|
import {
|
||||||
RadioButtonSelect,
|
RadioButtonSelect,
|
||||||
RadioSelectItem,
|
RadioSelectItem,
|
||||||
|
@ -86,7 +87,7 @@ export const ShellConfirmationDialog: React.FC<
|
||||||
>
|
>
|
||||||
{commands.map((cmd) => (
|
{commands.map((cmd) => (
|
||||||
<Text key={cmd} color={Colors.AccentCyan}>
|
<Text key={cmd} color={Colors.AccentCyan}>
|
||||||
{cmd}
|
<RenderInline text={cmd} />
|
||||||
</Text>
|
</Text>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, Box } from 'ink';
|
import { Text, Box } from 'ink';
|
||||||
import { Colors } from '../../colors.js';
|
import { Colors } from '../../colors.js';
|
||||||
|
import { RenderInline } from '../../utils/InlineMarkdownRenderer.js';
|
||||||
|
|
||||||
interface InfoMessageProps {
|
interface InfoMessageProps {
|
||||||
text: string;
|
text: string;
|
||||||
|
@ -23,7 +24,7 @@ export const InfoMessage: React.FC<InfoMessageProps> = ({ text }) => {
|
||||||
</Box>
|
</Box>
|
||||||
<Box flexGrow={1}>
|
<Box flexGrow={1}>
|
||||||
<Text wrap="wrap" color={Colors.AccentYellow}>
|
<Text wrap="wrap" color={Colors.AccentYellow}>
|
||||||
{text}
|
<RenderInline text={text} />
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import React from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import { DiffRenderer } from './DiffRenderer.js';
|
import { DiffRenderer } from './DiffRenderer.js';
|
||||||
import { Colors } from '../../colors.js';
|
import { Colors } from '../../colors.js';
|
||||||
|
import { RenderInline } from '../../utils/InlineMarkdownRenderer.js';
|
||||||
import {
|
import {
|
||||||
ToolCallConfirmationDetails,
|
ToolCallConfirmationDetails,
|
||||||
ToolConfirmationOutcome,
|
ToolConfirmationOutcome,
|
||||||
|
@ -222,12 +223,17 @@ export const ToolConfirmationMessage: React.FC<
|
||||||
|
|
||||||
bodyContent = (
|
bodyContent = (
|
||||||
<Box flexDirection="column" paddingX={1} marginLeft={1}>
|
<Box flexDirection="column" paddingX={1} marginLeft={1}>
|
||||||
<Text color={Colors.AccentCyan}>{infoProps.prompt}</Text>
|
<Text color={Colors.AccentCyan}>
|
||||||
|
<RenderInline text={infoProps.prompt} />
|
||||||
|
</Text>
|
||||||
{displayUrls && infoProps.urls && infoProps.urls.length > 0 && (
|
{displayUrls && infoProps.urls && infoProps.urls.length > 0 && (
|
||||||
<Box flexDirection="column" marginTop={1}>
|
<Box flexDirection="column" marginTop={1}>
|
||||||
<Text>URLs to fetch:</Text>
|
<Text>URLs to fetch:</Text>
|
||||||
{infoProps.urls.map((url) => (
|
{infoProps.urls.map((url) => (
|
||||||
<Text key={url}> - {url}</Text>
|
<Text key={url}>
|
||||||
|
{' '}
|
||||||
|
- <RenderInline text={url} />
|
||||||
|
</Text>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -22,10 +22,15 @@ interface RenderInlineProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
|
const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
|
||||||
|
// Early return for plain text without markdown or URLs
|
||||||
|
if (!/[*_~`<[https?:]/.test(text)) {
|
||||||
|
return <Text>{text}</Text>;
|
||||||
|
}
|
||||||
|
|
||||||
const nodes: React.ReactNode[] = [];
|
const nodes: React.ReactNode[] = [];
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
const inlineRegex =
|
const inlineRegex =
|
||||||
/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>)/g;
|
/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g;
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = inlineRegex.exec(text)) !== null) {
|
while ((match = inlineRegex.exec(text)) !== null) {
|
||||||
|
@ -126,6 +131,12 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
|
||||||
)}
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
} else if (fullMatch.match(/^https?:\/\//)) {
|
||||||
|
renderedNode = (
|
||||||
|
<Text key={key} color={Colors.AccentBlue}>
|
||||||
|
{fullMatch}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error parsing inline markdown part:', fullMatch, e);
|
console.error('Error parsing inline markdown part:', fullMatch, e);
|
||||||
|
|
Loading…
Reference in New Issue