Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(conversations): show tool UI beside the tool card and keep app links in replies

oxoxDev4f19f83ae4a4
diff --git a/app/src/components/assistant-ui/markdown-text.tsx b/app/src/components/assistant-ui/markdown-text.tsx
index 761b1613a1..3adf061faa 100644
--- a/app/src/components/assistant-ui/markdown-text.tsx
+++ b/app/src/components/assistant-ui/markdown-text.tsx
@@ -26,6 +26,8 @@ import rehypeKatex from 'rehype-katex';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
+import { ExternalSchemeLink } from '../../features/conversations/tools/mcpUi/LinkActions';
+import { classifyHref, transformChatUrl } from '../../features/conversations/utils/format';
import { hasLatexContent, normalizeLatexDelimiters } from '../../utils/latex';
import { extractLanguage, extractTextContent } from '../markdown/CodeBlock';
import { MarkdownImage } from '../markdown/MarkdownImage';
@@ -91,6 +93,11 @@ const MATH_REMARK_PLUGINS = [remarkGfm, remarkMath];
const HIGHLIGHT_REHYPE_PLUGINS = [rehypeHighlight];
const MATH_REHYPE_PLUGINS = [rehypeHighlight, rehypeKatex];
+/** Chat links minus workspace references, which this surface cannot open. */
+function transformAssistantUrl(url: string): string {
+ return classifyHref(url) === 'workspace' ? '' : transformChatUrl(url);
+}
+
const MarkdownTextImpl = () => {
// Math is GATED, not always-on, and the gate is `hasLatexContent` rather than
// "contains a $". `remark-math` would otherwise read "$10 vs $20" as an inline
@@ -141,6 +148,7 @@ const MarkdownTextImpl = () => {
// normalised once rather than per frame.
preprocess={preprocess}
className="aui-md"
+ urlTransform={transformAssistantUrl}
components={defaultComponents}
defer
/>
@@ -298,6 +306,9 @@ const memoizedComponents = memoizeMarkdownComponents({
const citationIndex = citationMatch ? Number.parseInt(citationMatch[1], 10) - 1 : -1;
const source = citationIndex >= 0 ? sources[citationIndex] : undefined;
if (source) return <CitationMarker index={citationIndex} source={source} />;
+ if (href && classifyHref(href) === 'handoff') {
+ return <ExternalSchemeLink href={href}>{children}</ExternalSchemeLink>;
+ }
return (
<a
className={cn(
diff --git a/app/src/features/conversations/components/AgentMessageBubble.tsx b/app/src/features/conversations/components/AgentMessageBubble.tsx
index 3ca20c2972..67eabd4a0a 100644
--- a/app/src/features/conversations/components/AgentMessageBubble.tsx
+++ b/app/src/features/conversations/components/AgentMessageBubble.tsx
@@ -1,5 +1,5 @@
import { type ReactNode, useMemo } from 'react';
-import Markdown, { defaultUrlTransform } from 'react-markdown';
+import Markdown from 'react-markdown';
import rehypeHighlight from 'rehype-highlight';
import rehypeKatex from 'rehype-katex';
import remarkGfm from 'remark-gfm';
@@ -11,7 +11,8 @@ import { hasLatexContent, normalizeLatexDelimiters } from '../../../utils/latex'
import { openUrl } from '../../../utils/openUrl';
import { openWorkspacePath } from '../../../utils/tauriCommands/workspacePaths';
import { parseWorkspaceHref } from '../../../utils/workspaceLinks';
-import { isAllowedExternalHref } from '../utils/format';
+import { ExternalSchemeLink } from '../tools/mcpUi/LinkActions';
+import { classifyHref, isAllowedExternalHref, transformChatUrl } from '../utils/format';
const GFM_REMARK_PLUGINS = [remarkGfm];
const MATH_REMARK_PLUGINS = [remarkGfm, remarkMath];
@@ -20,11 +21,10 @@ const MATH_REMARK_PLUGINS = [remarkGfm, remarkMath];
const HIGHLIGHT_REHYPE_PLUGINS = [rehypeHighlight];
const MATH_REHYPE_PLUGINS = [rehypeHighlight, rehypeKatex];
-function transformMarkdownUrl(url: string): string {
- return parseWorkspaceHref(url) ? url : defaultUrlTransform(url);
-}
-
function MarkdownAnchor({ href, children }: { href?: string; children?: ReactNode }) {
+ if (href && classifyHref(href) === 'handoff') {
+ return <ExternalSchemeLink href={href}>{children}</ExternalSchemeLink>;
+ }
return (
<a
href={href}
@@ -79,7 +79,7 @@ export function BubbleMarkdown({
<div
className={`text-sm prose prose-sm max-w-none prose-p:my-1 prose-pre:my-0 prose-code:text-xs prose-headings:font-semibold prose-ul:my-0 prose-ol:my-0 prose-li:my-0 ${proseTone} [&_ul]:my-0 [&_ol]:my-0 [&_ul]:pl-0 [&_ol]:pl-0 [&_ul]:list-inside [&_ol]:list-inside [&_li]:my-0 [&_li]:pl-0 [&_li_p]:inline [&_li_p]:m-0`}>
<Markdown
- urlTransform={transformMarkdownUrl}
+ urlTransform={transformChatUrl}
components={markdownComponents}
remarkPlugins={hasMath ? MATH_REMARK_PLUGINS : GFM_REMARK_PLUGINS}
rehypePlugins={hasMath ? MATH_REHYPE_PLUGINS : HIGHLIGHT_REHYPE_PLUGINS}>
diff --git a/app/src/features/conversations/components/AssistantUiToolCall.tsx b/app/src/features/conversations/components/AssistantUiToolCall.tsx
index 3ea79ce477..4689ca5429 100644
--- a/app/src/features/conversations/components/AssistantUiToolCall.tsx
+++ b/app/src/features/conversations/components/AssistantUiToolCall.tsx
@@ -15,6 +15,8 @@ import type {
import { openUrl } from '../../../utils/openUrl';
import { ToolFailureCard } from '../aui/ToolFailureCard';
import { useLiveElapsed, useRunningSince } from '../aui/useLiveElapsed';
+import { McpUiBody } from '../tools/mcpUi/McpUiBody';
+import { readMcpUiPresentation } from '../tools/mcpUi/types';
import { isSearchBalanceError } from '../tools/parseWebSearchResult';
import {
FetchBody,
@@ -168,6 +170,7 @@ export function AssistantUiToolCallCard({
? FileBody({ args: parsedArgs, result: output })
: null;
const showOutput = !searchBody && hasDisplayValue(parsedValue(output));
+ const mcpUi = !running && readMcpUiPresentation(structured) ? structured : undefined;
// Managed search out of balance: say so plainly instead of leaving the user
// to decode the raw error.
const balanceHint =
@@ -249,6 +252,11 @@ export function AssistantUiToolCallCard({
{/* Search results are the call's whole point: visible without
opening the disclosure, as in assistant-ui's own web-search. */}
{searchBody ? <div className="ps-5.5 pt-1 pb-2">{searchBody}</div> : null}
+ {mcpUi !== undefined ? (
+ <div className="ps-5.5 pt-1 pb-2">
+ <McpUiBody structured={mcpUi} />
+ </div>
+ ) : null}
</>
}>
{richBody ? <div className="mt-2 ps-5.5">{richBody}</div> : undefined}