Skip to content

The agent that grows with you

fix(desktop): ::preview inline frame works on remote/URL connections — read via the mode-aware fs bridge instead of bailing to a card (vestigial gate predated /api/fs) (#97829)

Teknium57746cbb842a
diff --git a/apps/desktop/src/components/assistant-ui/inline-preview-directive.tsx b/apps/desktop/src/components/assistant-ui/inline-preview-directive.tsx
index b575de8f032..ac52ba5839b 100644
--- a/apps/desktop/src/components/assistant-ui/inline-preview-directive.tsx
+++ b/apps/desktop/src/components/assistant-ui/inline-preview-directive.tsx
@@ -5,8 +5,8 @@ import { requestComposerSubmit } from '@/app/chat/composer/focus'
import { useSessionView } from '@/app/chat/session-view'
import { useIsDark } from '@/components/assistant-ui/embeds/use-is-dark'
import { PreviewAttachment } from '@/components/chat/preview-attachment'
+import { readDesktopFileText } from '@/lib/desktop-fs'
import { localPreviewTarget } from '@/lib/local-preview'
-import { isRemoteGateway } from '@/lib/media'
/**
* `::preview{file="…"}` — a workspace HTML file rendered LIVE inside the
@@ -253,9 +253,12 @@ export function InlinePreviewDirective({
}) {
const file = attrs.file ?? ''
- // Not renderable inline: hand the whole leaf to the classic card. Remote
- // gateways lack a local-file door; non-HTML has nothing to frame.
- if (!file || isRemoteGateway() || !HTML_FILE_RE.test(file)) {
+ // Not renderable inline: hand the leaf to the classic card. Non-HTML has
+ // nothing to frame. (Remote gateways used to bail here too — that predates
+ // the mode-aware fs bridge; the frame now reads through readDesktopFileText,
+ // which fetches over the authenticated /api/fs bridge in remote mode, so a
+ // URL connection — including a same-machine `hermes serve` — renders live.)
+ if (!file || !HTML_FILE_RE.test(file)) {
return file ? <PreviewAttachment source="explicit-link" target={file} /> : null
}
@@ -297,7 +300,7 @@ function InlineHtmlFrame({
let alive = true
- void Promise.resolve(window.hermesDesktop?.readFileText(path))
+ void Promise.resolve(readDesktopFileText(path))
.then(result => {
if (!alive) {
return