Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/web/chat/components/ToolRendering/ToolContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function ToolContent({
);

case 'exit_plan_mode':
case 'ExitPlanMode':
return (
<PlanTool
input={toolInput}
Expand Down
1 change: 1 addition & 0 deletions src/web/chat/components/ToolRendering/ToolLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export function ToolLabel({ toolName, toolInput, workingDirectory, onClick }: To
);

case 'exit_plan_mode':
case 'ExitPlanMode':
return <span className="font-semibold">Plan</span>;

default:
Expand Down
36 changes: 24 additions & 12 deletions src/web/chat/utils/tool-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,44 @@ export function formatToolInput(input: any, maxLength: number = 50): string {
if (!input || typeof input !== 'object') {
return String(input || '');
}

const entries = Object.entries(input);
if (entries.length === 0) return '';


// Special handling for plan content - show a truncated preview
if (entries.length === 1 && entries[0][0] === 'plan') {
const planContent = entries[0][1];
if (typeof planContent === 'string') {
// Extract first line of the plan for preview
const firstLine = planContent.split('\n')[0].trim();
return firstLine.length > maxLength
? `"${firstLine.slice(0, maxLength)}..."`
: `"${firstLine}"`;
}
}

if (entries.length === 1) {
const [key, value] = entries[0];
const formattedValue = typeof value === 'string' && value.length > maxLength
? `"${value.slice(0, maxLength)}..."`
: typeof value === 'string'
? `"${value}"`
const formattedValue = typeof value === 'string' && value.length > maxLength
? `"${value.slice(0, maxLength)}..."`
: typeof value === 'string'
? `"${value}"`
: String(value);
return `${key}: ${formattedValue}`;
}

// Multiple parameters - show key value pairs separated by commas
const formatted = entries
.map(([key, value]) => {
const formattedValue = typeof value === 'string' && value.length > maxLength
? `"${value.slice(0, maxLength)}..."`
: typeof value === 'string'
? `"${value}"`
const formattedValue = typeof value === 'string' && value.length > maxLength
? `"${value.slice(0, maxLength)}..."`
: typeof value === 'string'
? `"${value}"`
: String(value);
return `${key}: ${formattedValue}`;
})
.join(', ');

return formatted.length > maxLength ? `${formatted.slice(0, maxLength)}...` : formatted;
}

Expand Down
Loading