Files
orca/src/shared/file-link-location.ts
T
Brennan Benson 0ed6db77cf fix(mobile): open agent-cited external chat files (#14166)
* fix(mobile): open agent-cited external chat files

* fix(mobile): keep cited external files read-only

* refactor(mobile): derive cited-file mode from provenance

* fix(mobile): accept sentence-final cited paths

* fix(mobile): preserve cited SSH grant scope

* refactor(file-links): share location suffix parsing
2026-08-13 01:12:19 -07:00

20 lines
580 B
TypeScript

export type ParsedFileLinkLocation = {
pathText: string
line: number | null
column: number | null
}
export function parseFileLinkLocation(value: string): ParsedFileLinkLocation | null {
const match = /^(.*?)(?::(\d+))?(?::(\d+))?$/.exec(value)
const pathText = match?.[1]
if (!pathText) {
return null
}
const line = match[2] ? Number.parseInt(match[2], 10) : null
const column = match[3] ? Number.parseInt(match[3], 10) : null
if ((line !== null && line < 1) || (column !== null && column < 1)) {
return null
}
return { pathText, line, column }
}