feat(files): open markdown, HTML, and PDF files outside the workspace #9140
Mergedjuliusmarmingemerged 3 commits into
main fromrefs/pull/9140/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/files/filePath.ts lines 19 to 19OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1,8 +1,19 @@1+import { isWindowsAbsolutePath } from "@t3tools/shared/path";2+3+import { isAbsolutePath } from "~/terminal-links";4+15 export interface FileBreadcrumb {26 label: string;37 path: string;48 kind: "project" | "directory" | "file";59 }61011+/**12+ * Crumbs for a workspace-relative path start at the project. An absolute host13+ * path is outside the workspace, so its crumbs start at the filesystem root.14+ */715 export function fileBreadcrumbs(projectName: string, relativePath: string): FileBreadcrumb[] {8- const parts = relativePath.split("/").filter(Boolean);16+ const hostPath = isAbsolutePath(relativePath);17+ const separator = isWindowsAbsolutePath(relativePath) ? "\\" : "/";18+ const parts = relativePath.split(/[\\/]/).filter(Boolean);19+ const root = hostPath && separator === "/" ? "/" : "";apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx line 792Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -777,4 +778,6 @@777778 }778779779780 const parentDir = relativePath.split("/").slice(0, -1).join("/");780- const headerSubtitle = [projectName, parentDir].filter(Boolean).join(" · ");781+ // A host file outside the workspace is not under the project name.782+ const headerSubtitle = isAbsolutePath(relativePath)783+ ? parentDir
- apps/web/src/components/ChatMarkdown.tsx line 2322Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2310,3 +2313,8 @@23102313 mediaMimeTypeFromExtension(23112314 fileLinkMeta.basename.slice(fileLinkMeta.basename.lastIndexOf(".")),23122315 ) !== null;2316+ // Media outside the workspace keeps the expanded preview; other host2317+ // files (a report in a temp dir) open read-only in the files panel.2318+ const panelPath =2319+ fileLinkMeta.workspaceRelativePath ??2320+ (!canPreviewMedia && isAbsolutePath(fileLinkMeta.filePath) ? fileLinkMeta.filePath : null);
- apps/web/src/components/files/FilePreviewPanel.tsx line 1140Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1128,3 +1137,4 @@11281137 relativePath={relativePath}11291138 threadRef={threadRef}11301139 contents={file.data.contents}1140+ readOnly={isHostFile}apps/server/src/assets/AssetAccess.ts line 249Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -246,4 +246,4 @@246246 if (!canonicalFile) {247247 return yield* new AssetWorkspaceAssetNotFoundError({ resource: input.resource });248248 }249- if (mediaMimeTypeFromExtension(path.extname(canonicalFile)) === null) {249+ if (hostPreviewMimeTypeFromExtension(path.extname(canonicalFile)) === null) {
juliusmarminge merged thisf46a709
juliusmarminge closed this
Sign in to join this conversation.


Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
ea71a19· PR result:c0fa311· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.