Skip to content

tui: local Markdown file links are sent to the HTTP-only browser opener #54816

Open

Description

@parteekmalik

Description

Clicking a local-file Markdown link in an assistant reply fails with:
Only http and https links can be opened in the browser: /Users//workspace/.opencode/plan/example.md
The file exists. OpenCode is running in Cursor’s integrated terminal, where Cmd-click on other file references opens them in the editor.
Expected: local-file links should open in the editor or an appropriate file viewer rather than being passed to the browser opener.
Inspection of the installed executable shows that the transcript’s link-click handler calls a browser-opening function that rejects anything except HTTP/HTTPS URLs. No local-file link-routing setting was found in the CLI documentation.

Plugins

Local plan-write plugin, which saves Markdown plans. No custom TUI plugin. Behavior without the plugin has not been tested.

OpenCode version

2.0.27, installed through Homebrew (opencode-v2).

Steps to reproduce

  1. Run OpenCode in an IDE’s integrated terminal.
  2. Have an assistant response contain a Markdown link to an existing local file, such as plan.
  3. Click/Cmd-click the link.
  4. Observe the HTTP/HTTPS-only error instead of the file opening.

Screenshot and/or share link

No response

Operating System

macOS 27.0, Darwin 27.0.0, arm64. Shell: /bin/zsh.

Terminal

Cursor integrated terminal: TERM_PROGRAM=vscode, TERM=xterm-256color, COLORTERM=truecolor.

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report! I was able to reproduce this on 2.0.27, and it still happens on the latest dev (bcf23b6).

    Steps:

    1. The assistant replies with a Markdown link to an existing local file, e.g. [MYPLANLINK](/tmp/example.md).
    2. Click the link text in the transcript.
    3. A toast appears: Only http and https links can be opened in the browser: /tmp/example.md, and nothing opens.

    The TUI passes every clicked transcript link to a browser opener that deliberately accepts only http/https, so local paths always fail. I couldn't simulate Cmd-click inside Cursor specifically. However, the click handler only leaves Ctrl, Alt and Shift clicks to the terminal, not Cmd, so Cmd-click likely goes through the same path.

    The recording and screenshot below show it, and the script below reproduces it.

    Related: #47765 (opening files from chat in external apps) and #37891 / #44902 (file links in the desktop app).

    recording.mp4

    Screenshot

    Reproduction script (drive.ts)
    // Repro for anomalyco/opencode#54816: clicking a Markdown link to a local file in the TUI
    // transcript shows "Only http and https links can be opened in the browser: <path>".
    import { writeFileSync } from "node:fs"
    import { Effect } from "effect"
    import { Llm, OpenCodeDriver } from "opencode-drive"
    
    writeFileSync("/tmp/example.md", "# Example plan\n") // the linked file exists
    
    export default OpenCodeDriver.use(
      {
        ...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
        project: { git: true, files: { "plan/example.md": "# Example plan\n" } },
        tui: { recording: true, pointerOverlay: true },
      },
      ({ ui, llm }) =>
        Effect.gen(function* () {
          // The file exists in the project; link to it with an absolute path.
          yield* llm.queue(Llm.text("Saved the plan: [MYPLANLINK](/tmp/example.md) done."))
          yield* ui.submit("Write a plan")
          yield* ui.waitFor("MYPLANLINK")
          yield* Effect.sleep(500)
    
          // Locate the link text on screen.
          const frame = yield* ui.capture()
          let pos: { x: number; y: number } | undefined
          frame.lines.forEach((line, y) => {
            const text = line.spans.map((s) => s.text).join("")
            const x = text.indexOf("MYPLANLINK")
            if (x >= 0 && !pos) pos = { x: x + 3, y }
          })
          if (!pos) return yield* Effect.die("link not found on screen")
          yield* Effect.log(`clicking link at ${pos.x},${pos.y}`)
    
          yield* ui.mouse({ action: "move", ...pos })
          yield* ui.mouse({ action: "down", ...pos, button: "left" })
          yield* ui.mouse({ action: "up", ...pos, button: "left" })
    
          yield* ui.waitFor("Only http and https links can be opened", { timeout: 5000 })
          yield* Effect.sleep(1500)
          yield* ui.screenshot("error-toast")
          yield* Effect.log("REPRODUCED: HTTP-only error toast shown for local file link")
        }),
    )

    Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.

  2. YidaWeng commented on Oct 12, 2026

    @YidaWeng

    I'll take this — routing local absolute paths and file:// transcript links through the local file opener instead of the HTTP-only browser opener.

  3. YidaWeng commented on Oct 12, 2026

    @YidaWeng

    PR is up: #54838

  4. avvlas commented on Nov 10, 2026

    @avvlas

    Was just thinking of doing this exact fix, would love to see this shipped!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions