disable markdown rendering of shell tool output (#625)

This commit is contained in:
Olcan 2025-05-30 12:43:59 -07:00 committed by GitHub
parent 31a7affb74
commit a0ba65944f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 11 deletions

View File

@ -72,6 +72,7 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
? 'low' ? 'low'
: 'medium' : 'medium'
} }
renderOutputAsMarkdown={tool.renderOutputAsMarkdown}
/> />
</Box> </Box>
{tool.status === ToolCallStatus.Confirming && {tool.status === ToolCallStatus.Confirming &&

View File

@ -21,6 +21,7 @@ export type TextEmphasis = 'high' | 'medium' | 'low';
export interface ToolMessageProps extends IndividualToolCallDisplay { export interface ToolMessageProps extends IndividualToolCallDisplay {
availableTerminalHeight: number; availableTerminalHeight: number;
emphasis?: TextEmphasis; emphasis?: TextEmphasis;
renderOutputAsMarkdown?: boolean;
} }
export const ToolMessage: React.FC<ToolMessageProps> = ({ export const ToolMessage: React.FC<ToolMessageProps> = ({
@ -30,6 +31,7 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
status, status,
availableTerminalHeight, availableTerminalHeight,
emphasis = 'medium', emphasis = 'medium',
renderOutputAsMarkdown = true,
}) => { }) => {
const contentHeightEstimate = const contentHeightEstimate =
availableTerminalHeight - STATIC_HEIGHT - RESERVED_LINE_COUNT; availableTerminalHeight - STATIC_HEIGHT - RESERVED_LINE_COUNT;
@ -76,7 +78,8 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
</Text> </Text>
</Box> </Box>
)} )}
{typeof displayableResult === 'string' && ( {typeof displayableResult === 'string' &&
renderOutputAsMarkdown && (
<Box flexDirection="column"> <Box flexDirection="column">
<MarkdownDisplay <MarkdownDisplay
text={displayableResult} text={displayableResult}
@ -85,6 +88,12 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
/> />
</Box> </Box>
)} )}
{typeof displayableResult === 'string' &&
!renderOutputAsMarkdown && (
<Box flexDirection="column">
<Text>{displayableResult}</Text>
</Box>
)}
{typeof displayableResult !== 'string' && ( {typeof displayableResult !== 'string' && (
<DiffRenderer <DiffRenderer
diffContent={displayableResult.fileDiff} diffContent={displayableResult.fileDiff}

View File

@ -541,6 +541,18 @@ export function mapToDisplay(
): HistoryItemToolGroup { ): HistoryItemToolGroup {
const tools = Array.isArray(tool) ? tool : [tool]; const tools = Array.isArray(tool) ? tool : [tool];
const toolsDisplays = tools.map((t): IndividualToolCallDisplay => { const toolsDisplays = tools.map((t): IndividualToolCallDisplay => {
// Determine if markdown rendering should be skipped for this tool
let renderOutputAsMarkdown = true; // Default to true
if (t.status === 'error') {
// For errors, the tool object might not be available, so check t.request.name
if (t.request.name === 'execute_bash_command') {
renderOutputAsMarkdown = false;
}
} else if ('tool' in t && t.tool?.name === 'execute_bash_command') {
// For other statuses, check t.tool.name if tool exists
renderOutputAsMarkdown = false;
}
switch (t.status) { switch (t.status) {
case 'success': case 'success':
return { return {
@ -550,15 +562,17 @@ export function mapToDisplay(
resultDisplay: t.response.resultDisplay, resultDisplay: t.response.resultDisplay,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
case 'error': case 'error':
return { return {
callId: t.request.callId, callId: t.request.callId,
name: t.request.name, name: t.request.name, // Use request.name as tool might be undefined
description: '', description: '', // No description available if tool is undefined
resultDisplay: t.response.resultDisplay, resultDisplay: t.response.resultDisplay,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
case 'cancelled': case 'cancelled':
return { return {
@ -568,6 +582,7 @@ export function mapToDisplay(
resultDisplay: t.response.resultDisplay, resultDisplay: t.response.resultDisplay,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
case 'awaiting_approval': case 'awaiting_approval':
return { return {
@ -577,6 +592,7 @@ export function mapToDisplay(
resultDisplay: undefined, resultDisplay: undefined,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: t.confirmationDetails, confirmationDetails: t.confirmationDetails,
renderOutputAsMarkdown,
}; };
case 'executing': case 'executing':
return { return {
@ -586,6 +602,7 @@ export function mapToDisplay(
resultDisplay: t.liveOutput ?? undefined, resultDisplay: t.liveOutput ?? undefined,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
case 'validating': // Add this case case 'validating': // Add this case
return { return {
@ -595,6 +612,7 @@ export function mapToDisplay(
resultDisplay: undefined, resultDisplay: undefined,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
case 'scheduled': case 'scheduled':
return { return {
@ -604,6 +622,7 @@ export function mapToDisplay(
resultDisplay: undefined, resultDisplay: undefined,
status: mapStatus(t.status), status: mapStatus(t.status),
confirmationDetails: undefined, confirmationDetails: undefined,
renderOutputAsMarkdown,
}; };
default: { default: {
// ensures every case is checked for above // ensures every case is checked for above

View File

@ -49,6 +49,7 @@ export interface IndividualToolCallDisplay {
resultDisplay: ToolResultDisplay | undefined; resultDisplay: ToolResultDisplay | undefined;
status: ToolCallStatus; status: ToolCallStatus;
confirmationDetails: ToolCallConfirmationDetails | undefined; confirmationDetails: ToolCallConfirmationDetails | undefined;
renderOutputAsMarkdown?: boolean;
} }
export interface HistoryItemBase { export interface HistoryItemBase {