mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 22:14:27 +00:00
📃 style: Match File Activity Icons To File Rows (#16445)
Co-authored-by: Lia <lia@librechat.ai>
This commit is contained in:
parent
a9b4916083
commit
fcb88717bc
8 changed files with 108 additions and 6 deletions
|
|
@ -29,12 +29,17 @@ jest.mock('~/components/Chat/Messages/Content/ProgressText', () => ({
|
|||
phase,
|
||||
inProgressText,
|
||||
finishedText,
|
||||
icon,
|
||||
}: {
|
||||
phase: 'running' | 'completed' | 'cancelled' | 'failed';
|
||||
inProgressText: string;
|
||||
finishedText: string;
|
||||
icon: React.ReactNode;
|
||||
}) => (
|
||||
<div data-testid="progress-text">{phase === 'running' ? inProgressText : finishedText}</div>
|
||||
<div data-testid="progress-text">
|
||||
{icon}
|
||||
{phase === 'running' ? inProgressText : finishedText}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
|
|
@ -132,6 +137,7 @@ describe('FileAuthoringCall', () => {
|
|||
);
|
||||
|
||||
expect(screen.getByTestId('progress-text')).toHaveTextContent('Updated SKILL.md');
|
||||
expect(document.querySelector('.lucide-file-pen-line')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('prefers the output diff over the args preview after edit_file completes', () => {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import {
|
|||
ArrowRightLeft,
|
||||
FileSearch,
|
||||
FileText,
|
||||
FilePlus2,
|
||||
FilePenLine,
|
||||
MessageCircleQuestion,
|
||||
ScrollText,
|
||||
Brain,
|
||||
|
|
@ -32,6 +34,8 @@ export type ToolIconType =
|
|||
| 'file_search'
|
||||
| 'skill'
|
||||
| 'read_file'
|
||||
| 'create_file'
|
||||
| 'edit_file'
|
||||
| 'bash_tool'
|
||||
| 'background_tasks'
|
||||
| 'ask_user_question'
|
||||
|
|
@ -49,6 +53,8 @@ const ICON_MAP: Record<ToolIconType, React.ComponentType<{ className?: string }>
|
|||
file_search: FileSearch,
|
||||
skill: ScrollText,
|
||||
read_file: FileText,
|
||||
create_file: FilePlus2,
|
||||
edit_file: FilePenLine,
|
||||
bash_tool: BashIcon,
|
||||
background_tasks: ListChecks,
|
||||
ask_user_question: MessageCircleQuestion,
|
||||
|
|
@ -88,6 +94,9 @@ export function getToolIconType(name: string): ToolIconType {
|
|||
if (name === 'read_file') {
|
||||
return 'read_file';
|
||||
}
|
||||
if (name === 'create_file' || name === 'edit_file') {
|
||||
return name;
|
||||
}
|
||||
if (name === 'bash_tool' || name === Constants.BASH_PROGRAMMATIC_TOOL_CALLING) {
|
||||
return 'bash_tool';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,6 +165,45 @@ describe('ActivityPhaseGroup', () => {
|
|||
expect(screen.getByText(LABEL).parentElement).toHaveClass('flex-1', 'text-left');
|
||||
});
|
||||
|
||||
test.each([
|
||||
['create_file', '', 'lucide-file-plus-2'],
|
||||
['edit_file', '', 'lucide-file-pen-line'],
|
||||
['create_file', 'Created skills/demo/SKILL.md', 'lucide-file-plus-2'],
|
||||
['create_file', 'Updated AGENTS.md with safe diagnostic guidance', 'lucide-file-pen-line'],
|
||||
['edit_file', 'Edited AGENTS.md', 'lucide-file-pen-line'],
|
||||
])(
|
||||
'shows the file-row glyph on settled and live phase headers for %s: %s',
|
||||
(name, output, glyph) => {
|
||||
const part = {
|
||||
type: ContentTypes.TOOL_CALL,
|
||||
[ContentTypes.TOOL_CALL]: {
|
||||
id: 'file-1',
|
||||
name,
|
||||
args: '{"path":"AGENTS.md"}',
|
||||
output,
|
||||
type: 'tool_call',
|
||||
},
|
||||
} as unknown as TMessageContentParts;
|
||||
const { rerender } = render(
|
||||
<ActivityPhaseGroup labelPart={labelPart} hasContent spanParts={[part]}>
|
||||
<div data-testid="phase-content" />
|
||||
</ActivityPhaseGroup>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('button', { name: LABEL }).querySelector(`.${glyph}`)).not.toBeNull();
|
||||
expect(
|
||||
screen.getByRole('button', { name: LABEL }).querySelector('.lucide-wrench'),
|
||||
).toBeNull();
|
||||
|
||||
rerender(
|
||||
<ActivityPhaseGroup labelPart={labelPart} hasContent liveParts={[part]}>
|
||||
<div data-testid="phase-content" />
|
||||
</ActivityPhaseGroup>,
|
||||
);
|
||||
expect(screen.getByRole('button').querySelector(`.${glyph}`)).not.toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
test('keeps the focus ring inside the clipped header', () => {
|
||||
render(
|
||||
<ActivityPhaseGroup labelPart={labelPart} hasContent>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,15 @@ describe('shared header glyphs', () => {
|
|||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
['create_file', 'lucide-file-plus-2'],
|
||||
['edit_file', 'lucide-file-pen-line'],
|
||||
])('renders %s with the same glyph as its file row', (name, glyph) => {
|
||||
const { container } = render(<StackedToolIcons toolNames={[name]} />);
|
||||
expect(container.querySelector(`.${glyph}`)).not.toBeNull();
|
||||
expect(container.querySelector('.lucide-wrench')).toBeNull();
|
||||
});
|
||||
|
||||
it('retains a bounded stack and overflow count', () => {
|
||||
const { container } = render(
|
||||
<StackedToolIcons
|
||||
|
|
|
|||
|
|
@ -847,6 +847,26 @@ describe('ToolCallGroup image hoisting', () => {
|
|||
expect(screen.queryByText(/web_search|file_search|retrieval/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('uses the edit glyph for a create_file overwrite without changing its tool label', () => {
|
||||
renderGroup({
|
||||
...baseProps,
|
||||
parts: [
|
||||
{
|
||||
part: makePart(
|
||||
'file-1',
|
||||
'Updated AGENTS.md with safe diagnostic guidance',
|
||||
'create_file',
|
||||
),
|
||||
idx: 0,
|
||||
},
|
||||
],
|
||||
lastContentIdx: 0,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('stacked-icons')).toHaveAttribute('data-tool-names', 'edit_file');
|
||||
expect(screen.getByRole('button', { name: 'Create File' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps repeated action counts and failed-call status in the compact summary', () => {
|
||||
renderGroup({
|
||||
...baseProps,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ describe('getToolIconType - ACTN-01: Action delimiter detection', () => {
|
|||
expect(getToolIconType('some_plain_tool')).toBe('generic');
|
||||
});
|
||||
|
||||
it('gives native file authoring tools their row glyphs without changing MCP identity', () => {
|
||||
expect(getToolIconType('create_file')).toBe('create_file');
|
||||
expect(getToolIconType('edit_file')).toBe('edit_file');
|
||||
expect(getToolIconType(`create_file${Constants.mcp_delimiter}remote`)).toBe('mcp');
|
||||
expect(getToolIconType(`edit_file${Constants.mcp_delimiter}remote`)).toBe('mcp');
|
||||
});
|
||||
|
||||
it('gives the native background-task tool its own icon while preserving MCP identity', () => {
|
||||
expect(getToolIconType(Constants.CHECK_BACKGROUND_TASK)).toBe('background_tasks');
|
||||
expect(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Tools, Constants, ContentTypes, stripToolCallErrorPrefix } from 'librechat-data-provider';
|
||||
import { Constants, ContentTypes, stripToolCallErrorPrefix } from 'librechat-data-provider';
|
||||
import type {
|
||||
Agents,
|
||||
TAttachment,
|
||||
|
|
@ -12,9 +12,8 @@ import { getBatchActivityLabelPart, getActivityLabelText } from '~/utils/activit
|
|||
import { hasPendingApprovalInPart, hasPendingAuthInPart } from '~/utils/groupToolCalls';
|
||||
import { ASK_USER_QUESTION, getSubmittedAskAnswer } from '~/utils/approval';
|
||||
import { getToolDisplayLabel, parseToolName } from '~/utils/toolLabels';
|
||||
import { getToolIconName, getToolMeta, summarizeSpan } from './outcome';
|
||||
import { boundIntentLabel, getToolCallIntent } from './Parts/intent';
|
||||
import { isBashProgrammaticToolCall } from './routing';
|
||||
import { getToolMeta, summarizeSpan } from './outcome';
|
||||
import { isError } from './ToolOutput';
|
||||
|
||||
/** How often a live fold's header may repaint. A streamed intent moves the
|
||||
|
|
@ -246,7 +245,7 @@ export function getSpanIconNames(parts: ReadonlyArray<TMessageContentParts | und
|
|||
const toolCall = part == null ? undefined : getStandardToolCall(part);
|
||||
if (toolCall != null) {
|
||||
const name = toolCall.name ?? '';
|
||||
icons.add(isBashProgrammaticToolCall(name, toolCall.args) ? Tools.bash_tool : name);
|
||||
icons.add(getToolIconName(name, toolCall.args, toolCall.output));
|
||||
continue;
|
||||
}
|
||||
const legacy = part == null ? null : getToolMeta(part);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,19 @@ function hasFailedOutput(output: unknown): boolean {
|
|||
return typeof output === 'string' && isError(output);
|
||||
}
|
||||
|
||||
/** A create_file overwrite displays the edit glyph in its own row. Headers use
|
||||
* the same identity, without changing the tool name used for labels/counts. */
|
||||
export function getToolIconName(
|
||||
name: string,
|
||||
args?: string | Record<string, unknown>,
|
||||
output?: string | null,
|
||||
): string {
|
||||
if (name === 'create_file' && output?.startsWith('Updated ')) {
|
||||
return 'edit_file';
|
||||
}
|
||||
return isBashProgrammaticToolCall(name, args) ? Tools.bash_tool : name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Group metadata must agree with the individual card, which resolves its
|
||||
* outcome from the run step's terminal verdict through `resolveToolCallPhase`.
|
||||
|
|
@ -105,7 +118,7 @@ export function getToolMeta(
|
|||
* agents" on completion even when the child returned no text. */
|
||||
const completed = !!tc.output || tc.progress === 1;
|
||||
const name = tc.name ?? '';
|
||||
const iconName = isBashProgrammaticToolCall(name, tc.args) ? Tools.bash_tool : name;
|
||||
const iconName = getToolIconName(name, tc.args, tc.output);
|
||||
/** Memory tools report failure in prose ("Invalid key ...") that generic
|
||||
* `isError` parsing does not recognize, so `MemoryCall` classifies it with
|
||||
* its own predicate. Reuse that here or a persisted call with no terminal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue