Skip to content

The agent that grows with you

fix(desktop): render group MEDIA directives inline

funky-xamarinf924fac18557
diff --git a/apps/desktop/src/components/assistant-ui/markdown-text.media.test.tsx b/apps/desktop/src/components/assistant-ui/markdown-text.media.test.tsx
index 339bfb18fdf..946e240678d 100644
--- a/apps/desktop/src/components/assistant-ui/markdown-text.media.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/markdown-text.media.test.tsx
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { $connection } from '@/store/session'
-import { MarkdownImage, MarkdownTextContent } from './markdown-text'
+import { MarkdownImage, MarkdownTextContent, MessageTextContent } from './markdown-text'
const REMOTE_IMAGE_PATH = '/home/user/project/images/remote-preview.png'
const REMOTE_IMAGE_DATA_URL = 'data:image/png;base64,cmVtb3RlLWltYWdl'
@@ -79,3 +79,14 @@ describe('MarkdownImage media routing', () => {
expect(container.querySelector('audio')).toBeNull()
})
})
+
+describe('MessageTextContent MEDIA directives', () => {
+ afterEach(cleanup)
+
+ it('renders a raw audio MEDIA directive through the canonical player instead of exposing the directive', async () => {
+ const { container } = render(<MessageTextContent text="MEDIA:/tmp/group-voice.mp3" />)
+
+ await waitFor(() => expect(container.querySelector('audio[controls]')).not.toBeNull())
+ expect(container.textContent).not.toContain('MEDIA:')
+ })
+})
diff --git a/apps/desktop/src/components/assistant-ui/markdown-text.tsx b/apps/desktop/src/components/assistant-ui/markdown-text.tsx
index d0e04ca3f48..f8f5a72f8a6 100644
--- a/apps/desktop/src/components/assistant-ui/markdown-text.tsx
+++ b/apps/desktop/src/components/assistant-ui/markdown-text.tsx
@@ -17,6 +17,7 @@ import { TranscriptVideo } from '@/components/chat/transcript-video'
import { ZoomableImage } from '@/components/chat/zoomable-image'
import { ErrorBoundary } from '@/components/error-boundary'
import { detectArtifact } from '@/lib/artifact-detect'
+import { renderMediaTags } from '@/lib/chat-messages/parts'
import { normalizeExternalUrl, openExternalLink, PrettyLink } from '@/lib/external-link'
import { createMemoizedMathPlugin } from '@/lib/katex-memo'
import { parseMarkdownIntoBlocksCached } from '@/lib/markdown-blocks'
@@ -751,6 +752,16 @@ interface MarkdownTextContentProps extends MarkdownTextSurfaceProps {
text: string
}
+/** Render raw assistant-style message text through the complete Desktop text
+ * pipeline. `MEDIA:` directives must be transformed before Markdown rendering
+ * so the canonical link component can route them to inline players/previews.
+ * Fenced blocks stay plain code (`disableArtifacts`): a transcript rendered
+ * outside a session — a Bot Mode group room — has no session to own artifact
+ * versions. */
+export function MessageTextContent({ text }: { text: string }) {
+ return <MarkdownTextContent disableArtifacts isRunning={false} text={renderMediaTags(text)} />
+}
+
export function MarkdownTextContent({ isRunning, text, ...surfaceProps }: MarkdownTextContentProps) {
// No `smooth` on purpose — same as the assistant answer. `TextMessagePartProvider`
// mints a fresh part object on every `text` change, and useSmooth resets its
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index 4f358ab411b..e247ccc0f23 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -1574,6 +1574,10 @@ export {
} from '@/app/overlays/panel'
export { type RouteContribution, ROUTES_AREA, SIDEBAR_NAV_AREA, type SidebarNavContribution } from '@/app/routes'
+/** Canonical raw message renderer: applies Desktop message transforms (including
+ * `MEDIA:` delivery directives) and the same rich Markdown/media components as
+ * core chat. Prefer this over raw Streamdown for transcript-style messages. */
+export { MessageTextContent } from '@/components/assistant-ui/markdown-text'
/** THE full per-toolset config panel core Settings renders — provider picker,
* env vars / API keys, model catalog picker, and post-setup runners. Route-
* decoupled (the "manage keys" deep link is a no-op outside the router); pass