Files
apes-sidebar/src/client/tool-icons.tsx
T
Menghuan1918 2a39a0c8b2 chore: adapt the tasks/workflow/teams work to DSH 0.1.7-rc.1 (rebase onto v0.21.1)
Rebases the whole branch onto main's new 0.1.7-rc.1 baseline and lands the
adaptation the new host contract requires: the ui-primitives icon family rename
(Icon<Name><14|16> -> Icon<Name>Regular/Medium, with the 14px defaults pinned
back explicitly) and the StateDot redraw, the rewritten dsh-settings surface
(entry-id namespace, DSH schemastery with collected volatile returns,
configure auto:false), session format v4 (producer-owned source kind plus the
rewritten tool-result shape, parsers accepting both), the client snapshot move
to projectionsBySession.subagentCatalog with the jobs.list route behind it, the
^0.1.7-rc.1 peer floor with vendor and bare-import devDeps, the reduced chunk
set mirrored in all eight places, and the capability hand-backs (read-only
previews, terminal, browser).

Verified: typecheck and lint clean; 119 files / 1200 tests; build with no old
contract residue in the bundles; mount e2e 7/7; the tasks page still passes its
70-assertion real-browser contract.
2026-09-27 22:18:19 +08:00

55 lines
2.1 KiB
TypeScript

/**
* Tool-call glyphs for the live activity lines of the Tasks page (the
* "icon + tool + args" row on running agent nodes). A small explicit map of
* the common tool families onto host primitive icons; anything unmapped
* gets the generic ellipsis glyph. All icons are the host's own components
* (currentColor — zero color literals, the theme contract stays intact).
*/
import type { ReactNode } from 'react'
import {
IconCodeOutlineRegular,
IconEditOutlineRegular,
IconEllipsisOutlineRegular,
IconGlobeOutlineRegular,
IconPlayOutlineRegular,
IconSearchOutlineRegular,
IconThinkOutlineRegular,
} from '@deepseek-ai/dsh-client-ui-primitives'
/** One glyph renderer (host icon components accept a pixel size). */
type Glyph = (size: number) => ReactNode
/** The explicit tool-family map (longest-prefix wins at lookup). */
const TOOL_GLYPHS: ReadonlyArray<readonly [string, Glyph]> = [
['read', size => <IconCodeOutlineRegular size={size} />],
['write', size => <IconEditOutlineRegular size={size} />],
['edit', size => <IconEditOutlineRegular size={size} />],
['glob', size => <IconSearchOutlineRegular size={size} />],
['grep', size => <IconSearchOutlineRegular size={size} />],
['search', size => <IconSearchOutlineRegular size={size} />],
['bash', size => <IconPlayOutlineRegular size={size} />],
['shell', size => <IconPlayOutlineRegular size={size} />],
['web', size => <IconGlobeOutlineRegular size={size} />],
['fetch', size => <IconGlobeOutlineRegular size={size} />],
['think', size => <IconThinkOutlineRegular size={size} />],
]
/** The fallback glyph for unmapped tools. */
const FALLBACK_GLYPH: Glyph = size => <IconEllipsisOutlineRegular size={size} />
/**
* The glyph of one tool name: exact match first, then a prefix match so
* `mcp__fs__read_file`-style names still land on their family glyph. The
* lookup is case-insensitive.
*/
export function toolGlyph(toolName: string): Glyph {
const name = toolName.toLowerCase()
for (const [key, glyph] of TOOL_GLYPHS) {
if (name === key) return glyph
}
for (const [key, glyph] of TOOL_GLYPHS) {
if (name.includes(key)) return glyph
}
return FALLBACK_GLYPH
}