fix(files): resolve workspace paths and add sandboxed HTML preview (#367)

* fix(files): resolve workspace paths and add sandboxed HTML preview

Accept workspace-absolute paths in the file service and return repo-relative paths for file reads and directory listings. Serve raw content under a CSP sandbox and preview HTML files in a sandboxed iframe with a raw toggle.

Resolve file-click paths from the session directory and repo local path, detect absolute and html/htm file references while ignoring URLs, accept the legacy filePath input key and filediff metadata, fix the file browser navigating into an initially selected directory, and use focus-visible rings across shared UI primitives.

* fix(files): address review feedback on navigation and path fallback

Key initial directory navigation to the initial selection so viewport changes do not reset it, and open the mobile preview from a separate effect.

Fall back to the legacy filePath input when path is empty, and cover both with regression tests.
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-28 22:27:18 -04:00
1 parent 5bd688de4b
commit 68b13c8e35
19 files changed
+307 -58

No files matched your search

@@ -9,7 +9,7 @@ import { detectFileReferences } from '@/lib/fileReferences'
import { ExternalLink, Loader2, Shield } from 'lucide-react'
import { Badge } from '@/components/ui/badge'
import { CopyButton } from '@/components/ui/copy-button'
import { getToolSpecificRender } from './FileToolRender'
import { getToolInputPath, getToolSpecificRender } from './FileToolRender'
const DISPLAY_LIMIT = 30_000
const DISPLAY_HEAD_LENGTH = 20_000
@@ -174,7 +174,7 @@ export const ToolCallPart = memo(function ToolCallPart({ part, messageID, onFile
case 'write':
case 'edit':
case 'patch':
return (input.path as string) || null
return getToolInputPath(input) ?? null
case 'shell':
return displayCommand || null
case 'glob':