Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(claude-code): render in-app browser tool calls, screenshots inline (#17129)

Arvin Xud26e6958aeff
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 50fcaeaa2f4..2c06f91e40e 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1307,8 +1307,16 @@
"workingPanel.browser.import.success_other": "Imported {{count}} browser sessions from Chrome",
"workingPanel.browser.import.title": "Import login information from Chrome",
"workingPanel.browser.title": "Browser",
+ "workingPanel.browser.tool.click": "Click element",
"workingPanel.browser.tool.elements_one": "{{count}} element",
"workingPanel.browser.tool.elements_other": "{{count}} elements",
+ "workingPanel.browser.tool.fill": "Fill input",
+ "workingPanel.browser.tool.navigate": "Open page",
+ "workingPanel.browser.tool.press": "Press key",
+ "workingPanel.browser.tool.readPage": "Read page text",
+ "workingPanel.browser.tool.screenshot": "Screenshot page",
+ "workingPanel.browser.tool.scroll": "Scroll page",
+ "workingPanel.browser.tool.snapshot": "Snapshot page",
"workingPanel.documents.close": "Close",
"workingPanel.documents.discard": "Discard",
"workingPanel.documents.edit": "Edit",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 5dece45fbe6..478813a3700 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1307,8 +1307,16 @@
"workingPanel.browser.import.success_other": "已从 Chrome 导入 {{count}} 个浏览器会话",
"workingPanel.browser.import.title": "从 Chrome 导入登录信息",
"workingPanel.browser.title": "浏览器",
+ "workingPanel.browser.tool.click": "点击元素",
"workingPanel.browser.tool.elements_one": "{{count}} 个元素",
"workingPanel.browser.tool.elements_other": "{{count}} 个元素",
+ "workingPanel.browser.tool.fill": "填写输入框",
+ "workingPanel.browser.tool.navigate": "打开页面",
+ "workingPanel.browser.tool.press": "按键",
+ "workingPanel.browser.tool.readPage": "读取页面文本",
+ "workingPanel.browser.tool.screenshot": "页面截图",
+ "workingPanel.browser.tool.scroll": "滚动页面",
+ "workingPanel.browser.tool.snapshot": "页面快照",
"workingPanel.documents.close": "关闭",
"workingPanel.documents.discard": "放弃",
"workingPanel.documents.edit": "编辑",
diff --git a/packages/builtin-tool-claude-code/package.json b/packages/builtin-tool-claude-code/package.json
index 93b7fbbf11d..7434fe61952 100644
--- a/packages/builtin-tool-claude-code/package.json
+++ b/packages/builtin-tool-claude-code/package.json
@@ -5,7 +5,7 @@
"exports": {
".": "./src/index.ts",
"./client": "./src/client/index.ts",
- "./client/labels": "./src/client/Inspector/linearMcpLabels.ts"
+ "./client/labels": "./src/client/labels.ts"
},
"main": "./src/index.ts",
"dependencies": {
diff --git a/packages/builtin-tool-claude-code/src/client/Inspector/BrowserMcp.tsx b/packages/builtin-tool-claude-code/src/client/Inspector/BrowserMcp.tsx
new file mode 100644
index 00000000000..e70c09b68a1
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/Inspector/BrowserMcp.tsx
@@ -0,0 +1,178 @@
+'use client';
+
+import { inspectorTextStyles, shinyTextStyles } from '@lobechat/shared-tool-ui/styles';
+import type { BuiltinInspector, BuiltinInspectorProps } from '@lobechat/types';
+import { createStaticStyles, cx } from 'antd-style';
+import type { LucideIcon } from 'lucide-react';
+import {
+ Camera,
+ Globe,
+ Keyboard,
+ MousePointerClick,
+ MoveVertical,
+ ScanText,
+ TextCursorInput,
+} from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import {
+ BROWSER_MCP_TOOL_NAMES,
+ type BrowserMcpApi,
+ browserMcpLabelFallback,
+ browserMcpLabelKey,
+ isBrowserMcpApiName,
+ parseBrowserMcpApi,
+} from './browserMcpLabels';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ chip: css`
+ overflow: hidden;
+ display: inline-flex;
+ flex-shrink: 1;
+ gap: 6px;
+ align-items: center;
+
+ min-width: 0;
+ margin-inline-start: 6px;
+ padding-block: 2px;
+ padding-inline: 10px;
+ border-radius: 999px;
+
+ background: ${cssVar.colorFillTertiary};
+ `,
+ icon: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextDescription};
+ `,
+ value: css`
+ overflow: hidden;
+
+ min-width: 0;
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 12px;
+ color: ${cssVar.colorText};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+}));
+
+interface BrowserMcpArgs {
+ dx?: number;
+ dy?: number;
+ key?: string;
+ ref?: string;
+ text?: string;
+ url?: string;
+ x?: number;
+ y?: number;
+}
+
+const API_ICONS: Record<BrowserMcpApi, LucideIcon> = {
+ click: MousePointerClick,
+ fill: TextCursorInput,
+ navigate: Globe,
+ press: Keyboard,
+ readPage: ScanText,
+ screenshot: Camera,
+ scroll: MoveVertical,
+ snapshot: ScanText,
+};
+
+/** Lead with the host — `https://` is noise and eats the chip's width. */
+const stripProtocol = (url: string): string => url.replace(/^https?:\/\//i, '');
+
+/** Arrow + distance reads in any locale, unlike "Scrolled down 500px". */
+const formatScroll = ({ dx, dy }: BrowserMcpArgs): string => {
+ const parts: string[] = [];
+ if (typeof dy === 'number' && dy !== 0) parts.push(`${dy > 0 ? '↓' : '↑'} ${Math.abs(dy)}px`);
+ if (typeof dx === 'number' && dx !== 0) parts.push(`${dx > 0 ? '→' : '←'} ${Math.abs(dx)}px`);
+ return parts.join(' ');
+};
+
+/**
+ * The one detail worth putting on the collapsed row. Screenshot / snapshot /
+ * readPage take no arguments — their label already says everything, so they get
+ * no chip rather than an empty one.
+ */
+const getChipValue = (api: BrowserMcpApi, args: BrowserMcpArgs): string => {
+ switch (api) {
+ case 'navigate': {
+ return args.url ? stripProtocol(args.url.trim()) : '';
+ }
+ case 'click': {
+ if (args.ref) return args.ref;
+ const { x, y } = args;
+ return typeof x === 'number' && typeof y === 'number' ? `(${x}, ${y})` : '';
+ }
+ case 'fill': {
+ return args.text?.trim() || args.ref || '';
+ }
+ case 'press': {
+ return args.key || '';
+ }
+ case 'scroll': {
+ return formatScroll(args);
+ }
+ default: {
+ return '';
+ }
+ }
+};
+
+/**
+ * One inspector for every `mcp__lobe_cc__browser_*` call. Without it the row
+ * falls back to the raw wire name (`claude-code > mcp__lobe_cc__browser_navigate`),
+ * which reads like an internal identifier rather than "the agent opened a page".
+ */
+const BrowserMcpInspector = memo<BuiltinInspectorProps<BrowserMcpArgs>>(
+ ({ apiName, args, partialArgs, isArgumentsStreaming, isLoading }) => {
+ const { t } = useTranslation('chat');
+ const api = parseBrowserMcpApi(apiName);
+ if (!api) return null;
+
+ const label = t(browserMcpLabelKey(api) as any, {
+ defaultValue: browserMcpLabelFallback(api),
+ });
+ const value = getChipValue(api, args || partialArgs || {});
+ const Icon = API_ICONS[api];
+
+ const isShiny = isArgumentsStreaming || isLoading;
+
+ return (
+ <div className={cx(inspectorTextStyles.root, isShiny && shinyTextStyles.shinyText)}>
+ <span>{value ? `${label}:` : label}</span>
+ {value && (
+ <span className={styles.chip}>
+ <Icon className={styles.icon} size={14} />
+ <span className={styles.value}>{value}</span>
+ </span>
+ )}
+ </div>
+ );
+ },
+);
+
+BrowserMcpInspector.displayName = 'ClaudeCodeBrowserMcpInspector';
+
+// `BuiltinInspector` is generic over its args; the registry only ever hands it
+// the parsed args of the call it's keyed under (same cast as `LinearRender`).
+const Inspector = BrowserMcpInspector as unknown as BuiltinInspector;
+
+const FixedBrowserMcpInspectors: Record<string, BuiltinInspector> = Object.fromEntries(
+ BROWSER_MCP_TOOL_NAMES.map((tool) => [tool, Inspector]),
+);
+
+// Proxy-guarded like the Linear map so a tool added to the desktop's MCP server
+// without a matching entry here still resolves (rather than silently falling
+// back to the raw wire name).
+export const BrowserMcpInspectors: Record<string, BuiltinInspector> = new Proxy(
+ FixedBrowserMcpInspectors,
+ {
+ get: (target, prop) => {
+ if (typeof prop !== 'string') return undefined;
+ return target[prop] || (isBrowserMcpApiName(prop) ? Inspector : undefined);
+ },
+ },
+);
diff --git a/packages/builtin-tool-claude-code/src/client/Inspector/browserMcpLabels.ts b/packages/builtin-tool-claude-code/src/client/Inspector/browserMcpLabels.ts
new file mode 100644
index 00000000000..38d5e9c79bd
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/Inspector/browserMcpLabels.ts
@@ -0,0 +1,80 @@
+// Label utilities for the in-app browser tools CC reaches through the desktop's
+// builtin MCP server (`mcp__lobe_cc__browser_*`, mounted by
+// `apps/desktop/.../browserMcpTools.ts`).
+//
+// Kept free of React / antd-style / lucide imports — same reason as
+// `linearMcpLabels`: the workflow-summary path (`toolDisplayNames.ts`) pulls
+// `formatBrowserMcpShortLabel` and must not drag the inspector component in.
+
+/** MCP server name the desktop registers; CC prefixes every tool with it. */
+export const BROWSER_MCP_PREFIX = 'mcp__lobe_cc__';
+
+/**
+ * Wire tool name (minus the prefix) → `BrowserManifest.api` name. The MCP tools
+ * use snake_case names while the underlying browser api is camelCase, so this
+ * map is also what lets one inspector / render pair key off a stable api name.
+ */
+const TOOL_TO_API = {
+ browser_click: 'click',
+ browser_fill: 'fill',
+ browser_navigate: 'navigate',
+ browser_press: 'press',
+ browser_read_page: 'readPage',
+ browser_screenshot: 'screenshot',
+ browser_scroll: 'scroll',
+ browser_snapshot: 'snapshot',
+} as const;
+
+export type BrowserMcpApi = (typeof TOOL_TO_API)[keyof typeof TOOL_TO_API];
+
+/** Full CC-facing tool names, e.g. `mcp__lobe_cc__browser_navigate`. */
+export const BROWSER_MCP_TOOL_NAMES: string[] = Object.keys(TOOL_TO_API).map(
+ (tool) => `${BROWSER_MCP_PREFIX}${tool}`,
+);
+
+/** `mcp__lobe_cc__browser_navigate` → `navigate`; anything else → undefined. */
+export const parseBrowserMcpApi = (apiName: string): BrowserMcpApi | undefined => {
+ if (!apiName.startsWith(BROWSER_MCP_PREFIX)) return undefined;
+ const tool = apiName.slice(BROWSER_MCP_PREFIX.length);
+ return TOOL_TO_API[tool as keyof typeof TOOL_TO_API];
+};
+
+export const isBrowserMcpApiName = (apiName: string): boolean => !!parseBrowserMcpApi(apiName);
+
+/**
+ * English source strings, doubling as the `defaultValue` for the `chat` locale
+ * keys — so a locale that hasn't been filled in yet still reads as a sentence
+ * instead of `mcp__lobe_cc__browser_read_page`.
+ */
+const API_LABELS: Record<BrowserMcpApi, string> = {
+ click: 'Click element',
+ fill: 'Fill input',
+ navigate: 'Open page',
+ press: 'Press key',
+ readPage: 'Read page text',
+ screenshot: 'Screenshot page',
+ scroll: 'Scroll page',
+ snapshot: 'Snapshot page',
+};
+
+export const browserMcpLabelKey = (api: BrowserMcpApi): string =>
+ `workingPanel.browser.tool.${api}`;
+
+export const browserMcpLabelFallback = (api: BrowserMcpApi): string => API_LABELS[api];
+
+/** Translate one `chat`-namespace key with its English fallback. */
+export type BrowserMcpTranslate = (key: string, defaultValue: string) => string;
+
+/**
+ * Short label for a browser MCP call, or null when `apiName` isn't one. Takes
+ * the translator so this module stays i18n-agnostic: the inspector passes
+ * react-i18next's `t`, the workflow summary passes the global `i18next.t`.
+ */
+export const formatBrowserMcpShortLabel = (
+ apiName: string,
+ translate: BrowserMcpTranslate,
+): string | null => {
+ const api = parseBrowserMcpApi(apiName);
+ if (!api) return null;
+ return translate(browserMcpLabelKey(api), browserMcpLabelFallback(api));
+};
diff --git a/packages/builtin-tool-claude-code/src/client/Inspector/index.ts b/packages/builtin-tool-claude-code/src/client/Inspector/index.ts
index 5629c036183..fa13ea7573a 100644
--- a/packages/builtin-tool-claude-code/src/client/Inspector/index.ts
+++ b/packages/builtin-tool-claude-code/src/client/Inspector/index.ts
@@ -10,6 +10,7 @@ import type { BuiltinInspector } from '@lobechat/types';
import { ClaudeCodeApiName } from '../../types';
import { AgentInspector } from './Agent';
import { AskUserQuestionInspector } from './AskUserQuestion';
+import { BrowserMcpInspectors } from './BrowserMcp';
import { EditInspector } from './Edit';
import { LinearMcpInspectors } from './LinearMcp';
import { MonitorInspector } from './Monitor';
@@ -71,12 +72,14 @@ const FixedClaudeCodeInspectors = {
[ClaudeCodeApiName.WebFetch]: WebFetchInspector,
[ClaudeCodeApiName.WebSearch]: WebSearchInspector,
[ClaudeCodeApiName.Write]: WriteInspector,
+ ...BrowserMcpInspectors,
...LinearMcpInspectors,
};
export const ClaudeCodeInspectors = new Proxy(FixedClaudeCodeInspectors, {
get: (target, prop) => {
if (typeof prop !== 'string') return undefined;
- return prop in target ? target[prop as keyof typeof target] : LinearMcpInspectors[prop];
+ if (prop in target) return target[prop as keyof typeof target];
+ return BrowserMcpInspectors[prop] ?? LinearMcpInspectors[prop];
},
}) as unknown as Record<string, BuiltinInspector>;
diff --git a/packages/builtin-tool-claude-code/src/client/Render/BrowserMcp.tsx b/packages/builtin-tool-claude-code/src/client/Render/BrowserMcp.tsx
new file mode 100644
index 00000000000..d851265b35a
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/Render/BrowserMcp.tsx
@@ -0,0 +1,160 @@
+'use client';
+
+import type { BuiltinRender, BuiltinRenderProps } from '@lobechat/types';
+import { Block, Flexbox, Highlighter, Image, PreviewGroup, Text } from '@lobehub/ui';
+import { createStaticStyles } from 'antd-style';
+import { Globe } from 'lucide-react';
+import { memo } from 'react';
+
+import {
+ BROWSER_MCP_TOOL_NAMES,
+ type BrowserMcpApi,
+ isBrowserMcpApiName,
+ parseBrowserMcpApi,
+} from '../Inspector/browserMcpLabels';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ row: css`
+ padding-block: 6px;
+ padding-inline: 10px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 8px;
+ `,
+}));
+
+/**
+ * A screenshot echoed back by the in-app browser. The MCP handler returns the
+ * capture as an image block, the CC adapter lifts it onto `pluginState.images`,
+ * and the runtime pipeline uploads it — so by render time `data` (base64) is
+ * gone and only the uploaded reference remains. Same lifecycle as `Read` on an
+ * image file; see `HeterogeneousToolResultImage`.
+ */
+interface BrowserMcpImage {
+ fileId?: string;
+ mediaType?: string;
+ url?: string;
+}
+
+interface BrowserMcpPluginState {
+ images?: BrowserMcpImage[];
+}
+
+type BrowserMcpRenderProps = BuiltinRenderProps<unknown, BrowserMcpPluginState, string>;
+
+const uploadedImages = (pluginState?: BrowserMcpPluginState): BrowserMcpImage[] =>
+ pluginState?.images?.filter((image) => !!image.url) ?? [];
+
+/**
+ * navigate / click / fill / press / scroll all resolve to a one-line outcome the
+ * executor already phrased for the model ("Opened https://… — \"Title\""), so
+ * the card just presents that line instead of restating the arguments the
+ * inspector chip already shows.
+ */
+const PageRow = memo<{ content?: string }>(({ content }) => {
+ if (!content) return null;
+
+ return (
+ <Flexbox horizontal align={'center'} className={styles.row} gap={6}>
+ <Globe size={14} />
+ <Text ellipsis>{content}</Text>
+ </Flexbox>
+ );
+});
+
+PageRow.displayName = 'ClaudeCodeBrowserPageRow';
+
+const PageAction = memo<BrowserMcpRenderProps>(({ content }) => <PageRow content={content} />);
+
+PageAction.displayName = 'ClaudeCodeBrowserPageAction';
+
+/**
+ * Screenshot: show the captured page inline. This is the whole point of the
+ * call — the agent looked at the page, and the user should see exactly what it
+ * saw without unfolding anything (`displayControls` expands this card once the
+ * image lands).
+ *
+ * When the upload failed the adapter leaves an `[Image: …]` placeholder in the
+ * content, so fall back to the text rather than rendering an empty card.
+ */
+const Screenshot = memo<BrowserMcpRenderProps>(({ content, pluginState }) => {
+ const images = uploadedImages(pluginState);
+
+ if (images.length === 0) return content ? <PageRow content={content} /> : null;
+
+ return (
+ <PreviewGroup>
+ <Flexbox gap={8}>
+ {images.map((image, index) => (
+ <Block
+ key={image.fileId || image.url || index}
+ style={{ alignSelf: 'flex-start', overflow: 'hidden', padding: 4 }}
+ variant={'outlined'}
+ >
+ {/* A full-page capture of the sidebar browser is tall (e.g. 720×1620), so
+ bound the height and let the user click through to the preview for the
+ full view — same treatment as an image `Read`. Never stretch to the card
+ width either: upscaling a narrow capture just makes it blurry. */}
+ <Image
+ alt={'Browser screenshot'}
+ maxHeight={600}
+ src={image.url}
+ style={{ borderRadius: 4, maxWidth: '100%' }}
+ />
+ </Block>
+ ))}
+ </Flexbox>
+ </PreviewGroup>
+ );
+});
+
+Screenshot.displayName = 'ClaudeCodeBrowserScreenshot';
+
+/**
+ * snapshot / readPage return a page dump (a11y tree or article text). Keep it
+ * scrollable and collapsed by default — it's context for the model, not
+ * something the user reads top to bottom.
+ */
+const PageDump = memo<BrowserMcpRenderProps>(({ content }) => {
+ if (!content) return null;
+
+ return (
+ <Highlighter
+ wrap
+ language={'text'}
+ showLanguage={false}
+ style={{ maxHeight: 240, overflow: 'auto' }}
+ variant={'borderless'}
+ >
+ {content}
+ </Highlighter>
+ );
+});
+
+PageDump.displayName = 'ClaudeCodeBrowserPageDump';
+
+const RENDER_BY_API: Record<BrowserMcpApi, BuiltinRender> = {
+ click: PageAction as BuiltinRender,
+ fill: PageAction as BuiltinRender,
+ navigate: PageAction as BuiltinRender,
+ press: PageAction as BuiltinRender,
+ readPage: PageDump as BuiltinRender,
+ screenshot: Screenshot as BuiltinRender,
+ scroll: PageAction as BuiltinRender,
+ snapshot: PageDump as BuiltinRender,
+};
+
+const renderFor = (apiName: string): BuiltinRender | undefined => {
+ const api = parseBrowserMcpApi(apiName);
+ return api ? RENDER_BY_API[api] : undefined;
+};
+
+const FixedBrowserMcpRenders: Record<string, BuiltinRender> = Object.fromEntries(
+ BROWSER_MCP_TOOL_NAMES.map((tool) => [tool, renderFor(tool)!]),
+);
+
+export const BrowserMcpRenders: Record<string, BuiltinRender> = new Proxy(FixedBrowserMcpRenders, {
+ get: (target, prop) => {
+ if (typeof prop !== 'string') return undefined;
+ return target[prop] || (isBrowserMcpApiName(prop) ? renderFor(prop) : undefined);
+ },
+});
diff --git a/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts b/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts
index fb723fb551f..9a509cae989 100644
--- a/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts
+++ b/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts
@@ -38,6 +38,30 @@ describe('resolveClaudeCodeRenderDisplayControl', () => {
});
});
+ describe('in-app browser screenshot', () => {
+ const screenshot = 'mcp__lobe_cc__browser_screenshot';
+
+ it('expands once the capture has been uploaded, so the page is visible without unfolding', () => {
+ expect(resolveClaudeCodeRenderDisplayControl(screenshot, uploaded)).toBe('expand');
+ });
+
+ it('stays collapsed while in flight or when the upload failed', () => {
+ expect(resolveClaudeCodeRenderDisplayControl(screenshot)).toBeUndefined();
+ expect(
+ resolveClaudeCodeRenderDisplayControl(screenshot, { images: [{ mediaType: 'image/png' }] }),
+ ).toBeUndefined();
+ });
+
+ it('leaves the other browser tools collapsed', () => {
+ expect(
+ resolveClaudeCodeRenderDisplayControl('mcp__lobe_cc__browser_navigate'),
+ ).toBeUndefined();
+ expect(
+ resolveClaudeCodeRenderDisplayControl('mcp__lobe_cc__browser_snapshot', uploaded),
+ ).toBeUndefined();
+ });
+ });
+
it('keeps the static map for every other api, regardless of pluginState', () => {
expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.Edit)).toBe('expand');
expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.TodoWrite)).toBe('expand');
diff --git a/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts b/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts
index 334a588a228..30949e78148 100644
--- a/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts
+++ b/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts
@@ -1,6 +1,7 @@
import type { RenderDisplayControl } from '@lobechat/types';
import { ClaudeCodeApiName } from '../../types';
+import { parseBrowserMcpApi } from '../Inspector/browserMcpLabels';
import {
isLinearMcpApiName,
LINEAR_MCP_PREFIX,
@@ -47,12 +48,17 @@ const hasUploadedImage = (pluginState?: unknown): boolean => {
* Display control for a CC tool, refined by the tool_result when the static map
* alone can't decide.
*
- * `Read` is the one API whose output shape depends on its target: on an image
- * file it renders uploaded thumbnails, on anything else the source text. A
- * thumbnail is the whole point of the card, so expand it; source text stays
- * collapsed rather than dumping a file into the transcript. `pluginState` is
- * undefined while the call is still in flight, so the card only pops open once
- * the image has actually landed.
+ * Two APIs are image-bearing, and for both the image IS the payload — so the
+ * card opens itself rather than making the user unfold it:
+ *
+ * - `Read` on an image file renders uploaded thumbnails; on anything else it's
+ * source text, which stays collapsed rather than dumping a file into the
+ * transcript.
+ * - the in-app browser's `screenshot` renders the captured page.
+ *
+ * Both gate on an actually-uploaded image: `pluginState` is undefined while the
+ * call is in flight, and a failed upload leaves no `url` — in either case the
+ * card would pop open empty, so it stays collapsed instead.
*/
export const resolveClaudeCodeRenderDisplayControl = (
apiName: string,
@@ -60,5 +66,8 @@ export const resolveClaudeCodeRenderDisplayControl = (
): RenderDisplayControl | undefined => {
if (apiName === ClaudeCodeApiName.Read && hasUploadedImage(pluginState)) return 'expand';
+ if (parseBrowserMcpApi(apiName) === 'screenshot' && hasUploadedImage(pluginState))
+ return 'expand';
+
return ClaudeCodeRenderDisplayControls[apiName];
};
diff --git a/packages/builtin-tool-claude-code/src/client/Render/index.ts b/packages/builtin-tool-claude-code/src/client/Render/index.ts
index 7a3f6c566c3..1264038260e 100644
--- a/packages/builtin-tool-claude-code/src/client/Render/index.ts
+++ b/packages/builtin-tool-claude-code/src/client/Render/index.ts
@@ -4,6 +4,7 @@ import type { BuiltinRender } from '@lobechat/types';
import { ClaudeCodeApiName } from '../../types';
import Agent from './Agent';
import AskUserQuestion from './AskUserQuestion';
+import { BrowserMcpRenders } from './BrowserMcp';
import Edit from './Edit';
import Glob from './Glob';
import Grep from './Grep';
@@ -48,13 +49,17 @@ const FixedClaudeCodeRenders = {
[ClaudeCodeApiName.WebFetch]: WebFetch,
[ClaudeCodeApiName.WebSearch]: WebSearch,
[ClaudeCodeApiName.Write]: Write,
+ // In-app browser tools CC drives through the desktop's builtin MCP server.
+ // Screenshot is the one that earns its card: it renders the captured page.
+ ...BrowserMcpRenders,
...LinearMcpRenders,
};
export const ClaudeCodeRenders = new Proxy(FixedClaudeCodeRenders, {
get: (target, prop) => {
if (typeof prop !== 'string') return undefined;
- return prop in target ? target[prop as keyof typeof target] : LinearMcpRenders[prop];
+ if (prop in target) return target[prop as keyof typeof target];
+ return BrowserMcpRenders[prop] ?? LinearMcpRenders[prop];
},
}) as unknown as Record<string, BuiltinRender>;
diff --git a/packages/builtin-tool-claude-code/src/client/labels.ts b/packages/builtin-tool-claude-code/src/client/labels.ts
new file mode 100644
index 00000000000..9b3f210fe80
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/labels.ts
@@ -0,0 +1,31 @@
+// Component-free barrel for the tool-label helpers, exported as
+// `@lobechat/builtin-tool-claude-code/client/labels`.
+//
+// The workflow summary (`toolDisplayNames.ts`) turns wire tool names into
+// human labels outside of React, so this entry must stay free of React /
+// antd-style / lucide imports — pulling `client/index.ts` instead would drag
+// the inspector components (and their `keyframes`-using style modules) in
+// transitively.
+
+export {
+ BROWSER_MCP_PREFIX,
+ BROWSER_MCP_TOOL_NAMES,
+ type BrowserMcpApi,
+ browserMcpLabelFallback,
+ browserMcpLabelKey,
+ type BrowserMcpTranslate,
+ formatBrowserMcpShortLabel,
+ isBrowserMcpApiName,
+ parseBrowserMcpApi,
+} from './Inspector/browserMcpLabels';
+export {
+ capitalize,
+ formatLinearMcpShortLabel,
+ getLinearToolSuffix,
+ isLinearMcpApiName,
+ LINEAR_MCP_PREFIX,
+ LINEAR_MCP_TOOL_NAMES,
+ type ParsedTool,
+ parseToolName,
+ staticLabelFor,
+} from './Inspector/linearMcpLabels';
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index bf692022c56..dffde1a0966 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1380,8 +1380,16 @@ export default {
'workingPanel.browser.import.success_other': 'Imported {{count}} browser sessions from Chrome',
'workingPanel.browser.import.title': 'Import login information from Chrome',
'workingPanel.browser.title': 'Browser',
+ 'workingPanel.browser.tool.click': 'Click element',
'workingPanel.browser.tool.elements_one': '{{count}} element',
'workingPanel.browser.tool.elements_other': '{{count}} elements',
+ 'workingPanel.browser.tool.fill': 'Fill input',
+ 'workingPanel.browser.tool.navigate': 'Open page',
+ 'workingPanel.browser.tool.press': 'Press key',
+ 'workingPanel.browser.tool.readPage': 'Read page text',
+ 'workingPanel.browser.tool.screenshot': 'Screenshot page',
+ 'workingPanel.browser.tool.scroll': 'Scroll page',
+ 'workingPanel.browser.tool.snapshot': 'Snapshot page',
'workingPanel.progress': 'Progress',
'workingPanel.progress.allCompleted': 'All tasks completed',
'workingPanel.resources': 'Resources',
diff --git a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
index 07449b91208..93242ddc4d4 100644
--- a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
+++ b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
@@ -84,6 +84,17 @@ describe('tool display names', () => {
expect(getToolDisplayName('mcp__claude_ai_Linear__save_issue')).toBe('Linear · Save issue');
expect(getToolDisplayName('mcp__linear-server__get_issue')).toBe('Linear · Get issue');
});
+
+ it('uses friendly labels for the in-app browser MCP tool names', () => {
+ // Title-casing the wire name yields "Mcp lobe cc browser navigate".
+ expect(getToolDisplayName('mcp__lobe_cc__browser_navigate')).toBe('Open page');
+ expect(getToolDisplayName('mcp__lobe_cc__browser_screenshot')).toBe('Screenshot page');
+ expect(getToolDisplayName('mcp__lobe_cc__browser_read_page')).toBe('Read page text');
+ });
+
+ it('leaves unknown MCP tools on the title-case fallback', () => {
+ expect(getToolDisplayName('mcp__lobe_cc__something_else')).toBe('Mcp__lobe_cc__something_else');
+ });
});
describe('shapeProseForWorkflowHeadline', () => {
diff --git a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
index f6c17e18813..7357421fd45 100644
--- a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
+++ b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
@@ -1,4 +1,7 @@
-import { formatLinearMcpShortLabel } from '@lobechat/builtin-tool-claude-code/client/labels';
+import {
+ formatBrowserMcpShortLabel,
+ formatLinearMcpShortLabel,
+} from '@lobechat/builtin-tool-claude-code/client/labels';
import { type ChatToolPayloadWithResult } from '@lobechat/types';
import { t } from 'i18next';
@@ -89,6 +92,13 @@ export const getToolDisplayName = (apiName: string): string => {
const linearLabel = formatLinearMcpShortLabel(apiName);
if (linearLabel) return linearLabel;
+ // MCP wire names title-case into gibberish ("Mcp lobe cc browser navigate"),
+ // so the browser tools resolve to their own labels before the fallback.
+ const browserLabel = formatBrowserMcpShortLabel(apiName, (key, defaultValue) =>
+ t(key, { defaultValue, ns: 'chat' }),
+ );
+ if (browserLabel) return browserLabel;
+
const defaultValue = toTitleCase(apiName);
const key = TOOL_API_DISPLAY_NAMES[apiName];
if (!key) return defaultValue;