Repository navigation
Conversation
Transcript clicks always went through the HTTP-only browser opener, so absolute paths and file:// links showed an error toast. Route those targets through openHref while keeping openUrl strict for auth and docs.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
With this change, clicking an absolute local-file Markdown link no longer shows the error toast. I ran the #54816 reproduction script on the base (toast) and with this PR (no toast), and called openHref directly with absolute, file://, relative and ~ paths. bun test src/open.test.ts and the typecheck scripts for util and tui pass. There's no desktop in the sandbox, so I couldn't watch a file actually open.
Public API: no user-facing change. openHref and resolveOpenTarget are new exports of the internal @opencode/util/open (additive).
Concerns:
- Relative links are still rejected (inline). This is the most common form of file link a model writes.
- Cmd-click.
clickedLinkstill doesn't skip themetamodifier, so in VS Code or Cursor a Cmd-click is handled here instead of by the terminal. #54816 asks for that, and it's a one-line addition to the modifier check. - What one click hands to the OS (inline). This is a policy question for maintainers rather than a blocker.
Related: #47765
| } | ||
| } | ||
| } | ||
| if (path.isAbsolute(input)) return input |
There was a problem hiding this comment.
Models usually link project files relatively, e.g. [plan](plan/example.md) or src/foo.ts. Those still fail here and end in an error toast, just with different wording, and the test fixes that behaviour in place. Could the TUI resolve relative paths against the session directory before calling openHref, or at least not intercept links it can't handle, so the click falls through to the terminal? Otherwise #54816 is only fixed for absolute paths.
| } | ||
|
|
||
| /** Open an http(s) URL in the browser, or a local file path / file:// link with the OS handler. */ | ||
| export function openHref(input: string) { |
There was a problem hiding this comment.
One plain click now passes a path the model wrote straight to the OS default handler. On Linux that usually opens a viewer or editor. On Windows an .exe or .bat path (and, through path.isAbsolute, a \\server\share\… network path, which openUrl's tests deliberately reject) and on macOS a .command or .app path would be run. The desktop app's shell.openPath behaves similarly, so this may be acceptable. It's worth a maintainer decision, though, on whether the TUI should refuse UNC and executable targets, or only open files that exist. Right now a missing file resolves without any feedback.
Address review feedback on anomalyco#54838: resolve project-relative Markdown paths before opening, skip any modified click so the terminal can handle Cmd-click, and avoid toasting when a link cannot be opened.
|
Thanks for the review — pushed a follow-up that covers the actionable items:
On the OS-handler policy point (executables / UNC / missing files): left as-is to match desktop |
|
Thanks for working on this. Could TUI local-file links support opening in the same editor as My use case is clicking an assistant reply such as HTTP/HTTPS handling should stay unchanged, and relative paths should use the session directory. I'm asking about ordinary Markdown links, not a new file menu or automatic linking of bare paths. #48609 requests a similar editor preference for tool titles. Would editor-first behavior, or an opt-in setting, fit the intended design? I'd like to contribute a focused follow-up once the approach is agreed. Remote-session handling and terminal-editor suspend/resume would need explicit boundaries. |
|
Follow-up for Windows drive-qualified paths (e.g. from kvnloo/opencode#206):
Fix: resolve native absolute paths and drive-qualified paths ( |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window. Feel free to open a new pull request that follows our guidelines. |
Address review feedback on anomalyco#54838: resolve project-relative Markdown paths before opening, skip any modified click so the terminal can handle Cmd-click, and avoid toasting when a link cannot be opened.
|
Reopened as a new PR with the required template sections filled in (this one was auto-closed for compliance). Continuing here: will link the new PR URL next. |
|
Replacement PR with the template filled in: #55769 |
Address review feedback on anomalyco#54838: resolve project-relative Markdown paths before opening, skip any modified click so the terminal can handle Cmd-click, and avoid toasting when a link cannot be opened.


Summary
openHref/resolveOpenTargetin@opencode/util/openso http(s) links still open in the browser, while absolute paths and localfile://URLs use the OS file handler.openHreffor TUI transcript link clicks and the sharedLinkcomponent. LeaveopenUrlhttp(s)-only for auth/docs flows.file://host/...URLs and non-local schemes, matching desktop's local-file policy.Fixes #54816
Test plan
bun test src/open.test.tsfrompackages/utilresolveOpenTargetfor absolute paths,file://, https, javascript, and relative pathsAdded by the opencode bot (AI-generated).
Related: #47765