From ea34ca4b92d89c7703fa117253c2fe3393433a7c Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Tue, 30 Jun 2026 00:20:55 +0300 Subject: [PATCH] fix(chat): disable markdown file-reference probing on mobile The file-reference annotation pass issues filesystem stat probes (fileReferenceExists -> /api/fs/stat) to decide which inline-code/link tokens become openable file links. On mobile surfaces this feature is disabled entirely: gate the annotation effect on !isMobileSurfaceRuntime() so the pass short-circuits before scheduling, guaranteeing no probe requests are ever sent from a mobile runtime. --- .../ui/src/components/chat/MarkdownRendererImpl.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/chat/MarkdownRendererImpl.tsx b/packages/ui/src/components/chat/MarkdownRendererImpl.tsx index b050fd25..5b5252f2 100644 --- a/packages/ui/src/components/chat/MarkdownRendererImpl.tsx +++ b/packages/ui/src/components/chat/MarkdownRendererImpl.tsx @@ -16,6 +16,7 @@ import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory'; import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs'; import type { EditorAPI } from '@/lib/api/types'; import { isDesktopLocalOriginActive, isDesktopShell, isVSCodeRuntime } from '@/lib/desktop'; +import { isMobileSurfaceRuntime } from '@/lib/runtimeSurface'; import { ensureOutsideFileGrantForDesktop } from '@/lib/outsideFileGrants'; import { getDirectoryForFilePath, isAbsoluteFilePath, isFilePathWithinDirectory, normalizeFilePath, toAbsoluteFilePath } from '@/lib/path-utils'; import { renderMarkdownBlocks, renderMarkdownSync } from './markdown/markdownCore'; @@ -570,6 +571,11 @@ const useFileReferenceInteractions = ({ } let cancelled = false; const fileReferenceLinkLimit = getFileReferenceLinkLimit(); + // On mobile surfaces, file-reference highlighting is disabled entirely — not + // just visually. The annotation pass is what issues the filesystem `stat` + // probes (fileReferenceExists → /api/fs/stat), so skipping it here guarantees + // no probe requests are ever sent from a mobile runtime. + const fileReferencesEnabled = enabled && !isMobileSurfaceRuntime(); const clearFileLinkAttributes = (candidate: HTMLElement) => { candidate.removeAttribute('data-openchamber-file-link'); @@ -592,7 +598,7 @@ const useFileReferenceInteractions = ({ unwrapBlockCodePathTokens(container); }; - if (!enabled) { + if (!fileReferencesEnabled) { clearAnnotatedFileLinks(); return; } @@ -616,7 +622,7 @@ const useFileReferenceInteractions = ({ }; const annotateFileLinks = () => { - if (enabled) { + if (fileReferencesEnabled) { wrapBlockCodePathTokens(container); } const candidates = container.querySelectorAll(