mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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.
This commit is contained in:
1 parent
5bd688de4b
commit
cd7d139a31
19 files changed
+239
-58
No files matched your search
@@ -377,6 +377,35 @@ describe('MessagePart', () => {
|
||||
expect(screen.getByText('/test/file.txt')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('makes legacy filePath read, write, and filediff edit calls clickable', () => {
|
||||
const onFileClick = vi.fn()
|
||||
const legacy = (name: string, metadata: Record<string, unknown>) =>
|
||||
toolPart(name, {
|
||||
status: 'completed',
|
||||
input: { filePath: `/test/${name}.html` },
|
||||
content: [{ type: 'text', text: 'ok' }],
|
||||
metadata,
|
||||
})
|
||||
|
||||
renderWithProviders(
|
||||
<>
|
||||
<MessagePart part={legacy('read', {})} onFileClick={onFileClick} />
|
||||
<MessagePart part={legacy('write', {})} onFileClick={onFileClick} />
|
||||
<MessagePart
|
||||
part={legacy('edit', { filediff: { file: '/test/edit.html', patch: '@@ -1 +1 @@\n-a\n+b', additions: 1, deletions: 1 } })}
|
||||
onFileClick={onFileClick}
|
||||
/>
|
||||
</>,
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByText('/test/read.html'))
|
||||
fireEvent.click(screen.getByText('/test/write.html'))
|
||||
fireEvent.click(screen.getByText('/test/edit.html'))
|
||||
|
||||
expect(onFileClick.mock.calls.map(([filePath]) => filePath)).toEqual(['/test/read.html', '/test/write.html', '/test/edit.html'])
|
||||
expect(screen.getByText('+1')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders every file of a multi-file patch with per-file links', () => {
|
||||
const onFileClick = vi.fn()
|
||||
renderWithProviders(
|
||||
|
||||
Reference in new issue
Block a user