mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +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. * 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.
21 lines
832 B
TypeScript
21 lines
832 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { detectFileReferences } from './fileReferences'
|
|
|
|
describe('detectFileReferences', () => {
|
|
it('keeps the leading slash of absolute paths and parses line numbers', () => {
|
|
const [reference] = detectFileReferences('{"path": "/Users/me/workspace/repos/app/src/a.ts:12"}')
|
|
|
|
expect(reference.filePath).toBe('/Users/me/workspace/repos/app/src/a.ts')
|
|
expect(reference.lineNumber).toBe(12)
|
|
})
|
|
|
|
it('detects relative html and htm paths', () => {
|
|
expect(detectFileReferences('{"path": "./out/report.html", "other": "docs/page.htm"}').map((ref) => ref.filePath))
|
|
.toEqual(['./out/report.html', 'docs/page.htm'])
|
|
})
|
|
|
|
it('ignores the path portion of URLs', () => {
|
|
expect(detectFileReferences('fetch https://example.com/assets/app.js')).toEqual([])
|
|
})
|
|
})
|