fix(ui): show glob pattern in tool description
This commit is contained in:
@@ -4,6 +4,7 @@ import { readTaskTagSessionIdFromOutput } from './taskSessionIdParser';
|
||||
import { tryParseJsonOutput } from '../toolRenderers';
|
||||
import { getStreamingThrottleText } from '../../hooks/useStreamingTextThrottle';
|
||||
import { getStreamingOutputAppend, getToolOutput } from './toolOutput';
|
||||
import { getToolDescriptionFallback } from './toolRenderUtils';
|
||||
|
||||
describe('getToolOutput', () => {
|
||||
test('prefers authoritative state output', () => {
|
||||
@@ -64,3 +65,15 @@ describe('OpenChamber tool output', () => {
|
||||
expect(tryParseJsonOutput(JSON.stringify(result))).toEqual({ data: result, isJson: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe('getToolDescriptionFallback', () => {
|
||||
test('uses the glob pattern when the provided description and title are empty', () => {
|
||||
expect(getToolDescriptionFallback('glob', '', { pattern: 'packages/electron/README.md' }))
|
||||
.toBe('packages/electron/README.md');
|
||||
});
|
||||
|
||||
test('prefers an existing glob description over the pattern', () => {
|
||||
expect(getToolDescriptionFallback('glob', 'Electron docs', { pattern: 'packages/electron/README.md' }))
|
||||
.toBe('Electron docs');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,6 +58,7 @@ import { getDiffPatchEntries, getPatchText, type DiffPatchEntry } from './toolDi
|
||||
import { isEmbeddedSessionChat } from '@/components/layout/contextPanelEmbeddedChat';
|
||||
import { useStreamingTextThrottle } from '../../hooks/useStreamingTextThrottle';
|
||||
import { getStreamingOutputAppend, getToolOutput } from './toolOutput';
|
||||
import { getToolDescriptionFallback } from './toolRenderUtils';
|
||||
|
||||
const TOOL_ROW_TEXT_CLASS = '!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal';
|
||||
const TOOL_ROW_TITLE_CLASS = cn('typography-meta font-medium', TOOL_ROW_TEXT_CLASS);
|
||||
@@ -791,7 +792,7 @@ const getToolDescription = (part: ToolPartType, state: ToolStateUnion, currentDi
|
||||
}
|
||||
|
||||
const desc = input?.description || metadata?.description || ('title' in state && state.title) || '';
|
||||
return typeof desc === 'string' ? desc : '';
|
||||
return getToolDescriptionFallback(part.tool, desc, input);
|
||||
};
|
||||
|
||||
interface ToolScrollableSectionProps {
|
||||
|
||||
@@ -29,3 +29,16 @@ export const isStandaloneTool = (toolName: unknown): boolean => {
|
||||
export const isStaticTool = (toolName: unknown): boolean => {
|
||||
return STATIC_TOOL_NAMES.has(normalizeToolName(toolName));
|
||||
};
|
||||
|
||||
export const getToolDescriptionFallback = (
|
||||
toolName: unknown,
|
||||
description: unknown,
|
||||
input: Record<string, unknown> | undefined,
|
||||
): string => {
|
||||
if (typeof description === 'string' && description.trim().length > 0) {
|
||||
return description;
|
||||
}
|
||||
|
||||
const globPattern = normalizeToolName(toolName) === 'glob' ? input?.pattern : undefined;
|
||||
return typeof globPattern === 'string' ? globPattern : '';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user