Skip to content

fix(tui): link bare URLs in prose and prompts - #712

Merged
mohitranka merged 1 commit into
mainfrom
fix/autolink-bare-urls
Sep 17, 2026
Merged

mohitranka merged 1 commit into
mainfrom
fix/autolink-bare-urls

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

What

A URL only carried a destination when it was written as markdown link syntax. A bare https://example.com in an answer, in tool output, or pasted into a prompt rendered as inert text: no underline, and nothing to click. It is the form a model writes most often, and the only form a prompt can contain, since prompt rows are not a markdown path at all.

This scans prose and prompt rows for bare http(s):// runs and attaches the same destination an explicit markdown link carries.

How

  • links::autolink_matches proposes byte ranges; destination_for remains the single gate, so detection never widens what may be emitted (file:, mailto:, javascript: stay plain).
  • links::link_label_style is now the one definition of how a link label looks, shared by the markdown path, the bare-URL path and the prompt path.
  • markdown::push_span autolinks body text; user_message_gutter returns HyperlinkLines so a pasted URL keeps its columns through the transcript's indent.

Deliberately out of scope

  • Headings. H1/H2 uppercase their label, so a destination there would point at text that no longer matches it.
  • Table cells. end_cell drops the link table on the way into the row, so an underline there would promise a click that cannot happen. Autolinking would have made that worse.

Both are documented in the new FORGE-DESIGN.md rule next to "the underline is a promise".

Tests

11 new tests: URL detection (sentence punctuation, bracket balance, quote wrapping, mid-word runs, hostless schemes, refused schemes), bare URLs in prose, two per row, a URL wrapping across rows, the heading exclusion, and a URL pasted into a prompt.

cargo test -p forge-tui: 1419 passed, 5 failed. All 5 are pre-existing environment failures in this sandbox (sandbox denied command: ... this host refused to apply confinement, from the background-task tests), unrelated to this change. cargo fmt --check clean, cargo clippy -p forge-tui clean.

A URL only carried a destination when it was written as markdown, so `https://example.com` in an answer, in tool output, or pasted into a prompt rendered as inert text: no underline and nothing to click.

Scan prose and prompt rows for bare `http(s)://` runs and attach the same destination an explicit markdown link carries. `destination_for` stays the single gate, so detection proposes and policy still decides.

Headings and table cells stay plain on purpose. A heading uppercases its label, so a destination there would point at text that no longer matches it, and a table cell drops its link table on the way into the row, so an underline there would promise a click that cannot happen.
@mohitranka
mohitranka merged commit c3a167d into main Sep 17, 2026
3 checks passed
@mohitranka
mohitranka deleted the fix/autolink-bare-urls branch September 17, 2026 11:30
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.

1 participant