mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 02:57:36 +00:00
* Native chat: open tool-row files through the terminal's file link popover Tool rows that name a file (Read, Write, Edit, edit cards) now link the file name. Chat file links, in tool rows and in reply text, show the same popover the terminal shows for file paths, built from one shared function. * Fix native chat filename activation and path resolution
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { routeMarkdownHref } from './markdown-href-routing'
|
|
import { createNativeChatFileHref } from '../../../src/shared/native-chat-href-routing'
|
|
|
|
describe('routeMarkdownHref', () => {
|
|
it('routes web and mail links to the system handler', () => {
|
|
expect(routeMarkdownHref('https://example.com/docs')).toEqual({
|
|
kind: 'web',
|
|
url: 'https://example.com/docs'
|
|
})
|
|
expect(routeMarkdownHref('http://localhost:3000/')).toEqual({
|
|
kind: 'web',
|
|
url: 'http://localhost:3000/'
|
|
})
|
|
expect(routeMarkdownHref(' mailto:dev@example.com ')).toEqual({
|
|
kind: 'web',
|
|
url: 'mailto:dev@example.com'
|
|
})
|
|
})
|
|
|
|
it('carries a #L fragment as a :line suffix', () => {
|
|
expect(routeMarkdownHref('docs/plan.md#L42')).toEqual({
|
|
kind: 'file',
|
|
pathText: 'docs/plan.md:42'
|
|
})
|
|
expect(routeMarkdownHref('docs/plan.md?plain=1#line-7')).toEqual({
|
|
kind: 'file',
|
|
pathText: 'docs/plan.md:7'
|
|
})
|
|
expect(routeMarkdownHref('docs/plan.md#usage')).toEqual({
|
|
kind: 'file',
|
|
pathText: 'docs/plan.md'
|
|
})
|
|
})
|
|
|
|
it('preserves the existing wrapped reply-location contract', () => {
|
|
expect(routeMarkdownHref(createNativeChatFileHref(' docs/report.md:12:4 '))).toEqual({
|
|
kind: 'file',
|
|
pathText: 'docs/report.md:12:4'
|
|
})
|
|
})
|
|
|
|
it('routes file: URIs to the file opener', () => {
|
|
expect(routeMarkdownHref('file:///Users/me/wt/src/app.tsx')).toEqual({
|
|
kind: 'file',
|
|
pathText: '/Users/me/wt/src/app.tsx'
|
|
})
|
|
expect(routeMarkdownHref('file:///Users/me/wt/src/app.tsx#L12')).toEqual({
|
|
kind: 'file',
|
|
pathText: '/Users/me/wt/src/app.tsx:12'
|
|
})
|
|
expect(routeMarkdownHref('file:///C:/repo/src/index.ts')).toEqual({
|
|
kind: 'file',
|
|
pathText: 'C:/repo/src/index.ts'
|
|
})
|
|
})
|
|
|
|
it('drops anchors, unknown schemes, and empty hrefs', () => {
|
|
expect(routeMarkdownHref('#section')).toEqual({ kind: 'none' })
|
|
expect(routeMarkdownHref('')).toEqual({ kind: 'none' })
|
|
expect(routeMarkdownHref('editor://file/x.ts')).toEqual({ kind: 'none' })
|
|
expect(routeMarkdownHref('javascript:alert(1)')).toEqual({ kind: 'none' })
|
|
expect(routeMarkdownHref('data:text/plain,hi')).toEqual({ kind: 'none' })
|
|
})
|
|
})
|