Repository navigation
fix(response-viewer): open markdown links to file paths in the preview, not as a same-origin URL - #665
Conversation
…w, not as a same-origin URL Codex cites files as [label](/abs/path). The chat view gave those links target=_blank, so a click opened <origin>/abs/path and landed on a Fastify 404. Path-shaped hrefs now take the linkified-path shape the file preview already opens; scheme, protocol-relative and fragment links are unchanged.
|
Thanks @JDProfresh, this is a careful fix: Markdown links whose target is a bare path (Codex's Four small things, which I'll apply on top at merge time unless you'd rather push them yourself:
None of these block the change. CI is green, so this merges with those touches on top. |
… its edges Merge-time fix for #665. - A markdown link converted to a preview link became `a.rv-path`, so its label ("Our incident record") took the path style: monospace, 0.92em and `word-break: break-all`, which split prose mid-word on a phone. The anchor now also carries `rv-path-link`, and `.rv-text a.rv-path.rv-path-link` resets font and word-break, as the File Viewer does for its labelled document links. - The first new test adds `/tmp/a.json?raw=true` (pins the `?query` strip) and `/tmp/` (pins the trailing-slash folder check, since findFilePathLinks finds no folder in a bare `/tmp/`), and checks the new class. - The `_linkifyFilePaths` JSDoc and docs/architecture-invariants.md say the function also rewrites anchors whose href is a scheme-less, non-`//` path, on purpose without FILE_PATH_LINK_PATTERN's root and extension filter. - Mobile Guide: "a web link" in the response viewer opens a tab. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… file paths in the preview, not as a same-origin URL Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Merged and shipped in 1.44.0. Thank you @JDProfresh! Codex's The four items, applied at merge:
|
Problem
Codex cites files as Markdown links whose target is a bare path, for example
[Our incident record](/home/me/llm-bench/runs/crash-20261017/incident-summary.json). In the Response Viewer, clicking one opened a new tab athttps://<codeman-host>/home/me/llm-bench/runs/crash-20261017/incident-summary.json, which answers:The same path written as prose or in backticks already opens the file preview, so only the form Codex uses most was broken. Seen with codex-cli 0.160.0 on Codeman 1.42.0; the code is unchanged on master.
Cause
_renderMarkdowngives every linktarget="_blank", and_linkifyFilePathsskips text inside an<a>, so a link whose href is a path stays a plain browser link that resolves against Codeman's own origin. The File Viewer already handles this for rendered documents (_rebaseFilePreviewMarkdownRefsturns workspace refs intoa.rv-path); the Response Viewer had no equivalent.Fix
_linkifyFilePathsnow gives a link with a scheme-less, non-//href the samea.rv-pathshape a linkified path gets, so the existing click delegate opens it in the file preview:#L42,?queryand a:42or:42:7suffix are dropped, so the link opens the file itself. The suffix is cut before the href is percent-decoded (as the File Viewer's rebase decodes), so an encoded%3Astays part of the name.data-linkified, as for prose paths), and a folder target opens the folder grid.https:,mailto:,//hostand#fragmentlinks are untouched, so new-tab, loopback web-tab and in-document behavior stay as they are. Tabs and newlines are removed before the scheme check, as the URL parser does, sohttp	://localhost:5173still counts as a URL.Out-of-workspace targets go through the attachment routes like any other clicked path, so the blocked trees and extension allowlist still apply.
Working-With-FilesandMobile-Guidein the wiki now mention the link form (the Mobile Guide said every Response Viewer link opens a tab).Independent of #545; if that lands, these links get its panel like any other
a.rv-path.Testing
test/response-viewer-file-links.test.ts: a path link becomesa.rv-pathwith the rightdata-pathand notarget/rel(absolute, relative with%20and:42:7, folders with and without a trailing slash, an encoded%3A);https:,mailto:,//host,#fragmentand a tab-split scheme keep their href; and a behavioral click through_bindResponseViewerInteractionscallsopenFilePreviewwith the path and prevents the navigation. Removing any one of the seven guards turns at least one of these red, and the behavior tests fail against master'sapp.js.npm test: 11806 passed. typecheck, lint, format:check, check:frontend-syntax and check:browser-excludes pass.https:link in the same message still opens in a new tab. Running on my own install since today, clicking the links in a live Codex session.