The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(conversations): collect the latest widget per template in a message
oxoxDev3db101752bc6
diff --git a/app/src/features/conversations/tools/mcpUi/McpWidgetStrip.tsx b/app/src/features/conversations/tools/mcpUi/McpWidgetStrip.tsxnew file mode 100644index 0000000000..cbb575bb59--- /dev/null+++ b/app/src/features/conversations/tools/mcpUi/McpWidgetStrip.tsx@@ -0,0 +1,15 @@+import { isTauri } from '../../../../utils/tauriCommands/common';+import { McpAppFrame } from './McpAppFrame';+import type { MessageWidget } from './messageWidgets';++/** Widgets shown on their own, between the work that produced them and the answer. */+export function McpWidgetStrip({ widgets }: { widgets: readonly MessageWidget[] }) {+ if (widgets.length === 0 || !isTauri()) return null;+ return (+ <div className="flex flex-col gap-3" data-slot="aui_mcp-widgets" data-testid="mcp-ui-widgets">+ {widgets.map(widget => (+ <McpAppFrame key={widget.key} presentation={widget.presentation} />+ ))}+ </div>+ );+}diff --git a/app/src/features/conversations/tools/mcpUi/messageWidgets.ts b/app/src/features/conversations/tools/mcpUi/messageWidgets.tsnew file mode 100644index 0000000000..217e70f956--- /dev/null+++ b/app/src/features/conversations/tools/mcpUi/messageWidgets.ts@@ -0,0 +1,42 @@+import { readOpenHumanToolArtifact } from '../../../../providers/assistantUiMessages';+import { hasWidget, type McpUiPresentation, readMcpUiPresentation } from './types';++export interface MessageWidget {+ /** Stable per widget template: the same key keeps the same frame mounted. */+ key: string;+ presentation: McpUiPresentation;+ /** Index of the message part the latest presentation came from. */+ partIndex: number;+}++interface ToolPartLike {+ type: string;+ artifact?: unknown;+}++/** One key per widget template: its server and its resource or inline document. */+export function widgetKey(presentation: McpUiPresentation): string {+ const source = presentation.inline_id+ ? `inline:${presentation.inline_id}`+ : `uri:${presentation.resource_uri ?? ''}`;+ return `${presentation.server_id ?? ''}|${source}`;+}++/**+ * The widgets one assistant message offers: the latest presentation of each+ * template, ordered by where that latest call sits in the message.+ */+export function collectMessageWidgets(parts: readonly ToolPartLike[]): MessageWidget[] {+ const latest = new Map<string, MessageWidget>();+ parts.forEach((part, partIndex) => {+ if (part.type !== 'tool-call') return;+ const presentation = readMcpUiPresentation(+ readOpenHumanToolArtifact(part.artifact)?.structured+ );+ if (!presentation || !hasWidget(presentation)) return;+ const key = widgetKey(presentation);+ latest.delete(key);+ latest.set(key, { key, presentation, partIndex });+ });+ return [...latest.values()].sort((a, b) => a.partIndex - b.partIndex);+}