Skip to content

Open a chat link to a local file instead of dropping its target - #60

Merged
devswha merged 1 commit into
devswha:mainfrom
Yoonwoo-Ha:fix/chat-file-links
Sep 26, 2026
Merged

devswha merged 1 commit into
devswha:mainfrom
Yoonwoo-Ha:fix/chat-file-links

Conversation

@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor

Problem

Agents link files they wrote. Codex ended an answer with:

기존 학습과 배포 기본값은 유지했습니다. [실험 결과와 근거](/home/rise/Downloads/EdgePose/output/test/…/REPORT.md)

In the chat the sentence ended with "실험 결과와 근거" and nothing after it. The path was gone, and there was nothing to click. The terminal shows 실험 결과와 근거 (output/test/…/REPORT.md).

Cause

parseInline follows only http(s): and mailto: targets, which is right for an <a href>. Every other link was reduced to its bare label, so a local file target was dropped along with the unsafe ones.

Fix

  • New inline node { type: "file", path, children } for a link whose target has no scheme (/abs/x.md, src/x.ts#L12, ~/y.md:3). A #… or :line[:col] suffix is dropped.
  • Markdown renders it as a .markdown-file button with the link's label that opens the path in the file viewer, the same viewer bare paths in the chat already open. The label is rendered with the viewer context off, so a code-span label does not nest a second button.
  • Where nothing can open a file (OpenFileContext is null), the path is shown after the label, as Codex's terminal does: label (path).
  • A target with any other scheme (javascript:, data:) or a bare #anchor still renders as the label text, as before.

Tests

  • src/lib/markdown.test.ts: file links, with and without line anchors. javascript:, data: and #section stay text.
  • bun test all pass, tsc --noEmit clean.
  • Live, in headless Chrome on the real Codex pane: the answer ends with a "실험 결과와 근거" button. Its title is Open /home/…/REPORT.md, and a click opens REPORT.md in the file viewer.

Related: #59 fixes the same kind of answer failing to bind to its rollout while the terminal is attached.

🤖 Generated with Claude Code

Agents link files they wrote (`[results](/repo/output/REPORT.md)`).
Only http(s) and mailto targets are safe to follow, so every other
link was reduced to its label: the sentence ended with the label and
the path was gone ("... 실험 결과와 근거" with nothing after it), while
the terminal shows "label (output/REPORT.md)".

A link whose target has no scheme is now a file: its label opens the
path (without a #L12 or :12 line anchor) in the file viewer, and where
no viewer is available the path is shown after the label. Targets
with any other scheme still render as plain label text.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
devswha added a commit that referenced this pull request Sep 26, 2026
devswha added a commit that referenced this pull request Sep 26, 2026
#60 was written before the Korean UI; its "Open <path>" tooltip now goes through t(), like the
bare-path button next to it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@devswha
devswha merged commit 18d8ee8 into devswha:main Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants