Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The link routing works, but as submitted this PR stops the TUI from starting.
App() in packages/tui/src/app.tsx already declares const paths = useTuiPaths() further down (line 697), so the new declaration at line 461 is a redeclaration. Running OpenCode from this branch fails with SyntaxError: Identifier 'paths' has already been declared, and bun run typecheck in packages/tui fails with TS2451. The branch is up to date with dev, so this isn't caused by an out-of-date base.
How I checked: I ran the reproduction from #54816 with an absolute link (/tmp/example.md) and a relative one (plan/example.md). On dev both clicks show the "Only http and https links" error notice. On this branch the TUI wouldn't start. With the duplicate line removed locally, neither click shows an error notice, and both paths reach the system opener, the relative one resolved against the session directory. The open.test.ts and link.test.tsx tests pass.
Public API: unchanged. The new openHref and resolveOpenTarget are internal to @opencode/util.
|
AI-assisted independent resolver check of The seven owning Please cover encoded relative hrefs and fragments before treating session-relative Markdown routing as complete. The relative branch currently calls These checks import the actual utility source; they do not exercise renderer normalization, launch an OS handler, or establish a full TUI/typecheck/suite pass. No production code was changed. reviewed and tested locally. |
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.
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.
URL.canParse treats C:\ and C:/ paths as scheme "c:", so resolveOpenTarget returned undefined before path.isAbsolute. Check native absolute and drive-qualified paths first, and cover both slash styles in tests.
App already calls useTuiPaths later; the second binding broke startup with a redeclaration SyntaxError / TS2451. Keep one paths and define linkBase next to it.
Percent-escaped session-relative Markdown links and #fragments were passed through path.resolve as literal filenames. Decode URI spelling and strip fragment/query so plan%20notes.md#section opens plan notes.md, while literal % and # stay reachable via %25 and %23.
70857a2 to
fb6fe74
Compare
pedro757
left a comment
There was a problem hiding this comment.
Reviewed fb6fe74 on Linux with Bun 1.4.4. I recommend fixing the absolute-href normalization bug below before merging; confirmed through a real OpenTUI click, an existing-file check, and four added utility regression cases. No production code was changed.
Web compatibility: production build and app typecheck pass; built Chromium E2Es for artifact-link reopening and image preview/zoom/pan/reset both pass. The GUI file-link resolver (32 tests), shared Markdown image/session-link/inline-code helpers (71 tests), and desktop URL policy (2 tests) also pass. The web/desktop opening paths are unchanged and do not import this utility; none of the 1,460 generated web JavaScript source maps includes it or TUI sources. Existing HTTP-only openUrl behavior is unchanged.
The PR's original 9 utility tests and original TUI click test pass (the latter also passed 10 consecutive runs). Full verification is not green: an existing photon-node patch blocks a full install/TUI dependency check, and broader Bun GUI suites hit missing solid-js jsxDEV exports. No Windows/macOS runtime verification.
Absolute Markdown hrefs early-returned before decodeHrefPath, so /tmp/mobile%20menu.png and /tmp/plan.md#section were passed to the OS literally. Apply the same URI decode and fragment stripping used for relative hrefs; leave openPath and openUrl unchanged.
|
Thanks @pedro757 — addressed the P2 in a follow-up commit. Absolute Markdown hrefs (including drive-qualified ones) now go through `decodeHrefPath` the same way relatives do, so `/tmp/mobile%20menu.png` and `/tmp/plan.md#section` open as `/tmp/mobile menu.png` / `/tmp/plan.md`. `openPath` and `openUrl` are unchanged. Added regression coverage in `packages/util/src/open.test.ts`. |
There was a problem hiding this comment.
The earlier blocker is fixed: the duplicate paths declaration is gone and the TUI starts again.
I re-ran the #54816 reproduction against the current base, adding a relative link with an escaped space and a fragment (plan/my%20plan.md#top). On dev, clicking either link shows the "Only http and https links" error notice. With this PR there's no error notice, and the system opener receives /tmp/example.md and <project>/plan/my plan.md, so the new decoding works as intended. open.test.ts (10 tests) and link.test.tsx pass. tsgo shows no errors in the changed files.
Public API: unchanged. openHref and resolveOpenTarget are internal to @opencode/util.
No new concerns.
|
Tried this and the Markdown-link case works well for me. One gap I hit: agents mostly print bare paths in plain text (no link behind them), e.g. I have this working on a fork (resolves plain-text paths, joins wrapped rows, only opens if the file exists, and refuses |
|
@moritzWa Thanks! |
|
@rekram1-node could you take a look at this when you get a chance? Checks are green, the author addressed both rounds of review feedback on Oct 27, and the bot review says no new concerns. It's been waiting on a maintainer review since. It fixes #54816. |
pedro757
left a comment
There was a problem hiding this comment.
Reviewed 99248fe. Found a remote-path policy gap and an ineffective Meta-click regression test; details are inline.
Verification: bun test src/open.test.ts in packages/util passes all 10 tests, and bun test --timeout 30000 test/ui/link.test.tsx in packages/tui passes its test. A targeted UNC-rejection regression fails. Additional real OpenTUI renderer probes confirm that the UNC Markdown href reaches the resolver unchanged and that the mock mouse discards Meta. Windows path classification was checked with Node's path.win32; no native Windows/macOS opener or full-workspace verification was performed. No production code was changed.
Reject //server/share and \\server\share targets, including percent-encoded spellings, before they reach the OS handler. file URL paths that decode to a UNC target are rejected the same way.
The OpenTUI mouse mock only reports shift/alt/ctrl, so a meta option was silently dropped and the guard went untested. Cover every modifier directly, including meta, and drop the ineffective mock option.
# Conflicts: # packages/tui/src/ui/link.tsx
|
Follow-up pushed in d2850d1 (also merged current
Verification:
Public API is unchanged; the new policy only applies to |
|
Folded in the follow-up from YidaWeng#1 (andy-takker) and merged current
Verification:
|




Issue for this PR
Fixes #54816
Type of change
What does this PR do?
Clicking a local file Markdown link in the TUI always went through the HTTP-only opener, so absolute paths and
file://links showed an error toast.This adds
openHref/resolveOpenTargetso http(s) still opens in the browser, while absolute paths, Windows drive paths (C:\/C:/), localfile://URLs, and session-relative paths open with the OS handler. Remotefile://host/...and other schemes stay rejected. Modified clicks (Cmd/Ctrl/etc.) are left to the terminal.Relative links also resolved against the launch directory while the session's Location metadata was still loading.
linkBasenow uses the route'slocation.refbeforepaths.cwd, so a click during that window still resolves against the session directory.How did you verify your code works?
bun test src/open.test.tsinpackages/util(absolute paths, both Windows slash styles,file://, https, relative paths, unsafe schemes)bun test test/app-links.test.tsinpackages/tui— 2 passed (loaded and pending Location metadata);--rerun-each 5— 10/10 passedbun test test/ui/link.test.tsxinpackages/tui— 2 passed (modifier guard)openbun run checkfrom the repository root — 35/35 tasks passedutil/tuion the change setScreenshots / recordings
Covered in the earlier review thread on this PR (before toast / after no toast).
Checklist
Added by the opencode bot (AI-generated).
Related: #51756, #47765