Skip to content

fix(tui): a URL wrapped onto an indented row is one clickable URL - #1309

Merged
edwin-zvs merged 1 commit into
mainfrom
url-wrap-indent
Aug 25, 2026
Merged

edwin-zvs merged 1 commit into
mainfrom
url-wrap-indent

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

The bug

Clickable URLs are recovered from the rendered frame (so a link stays clickable even inside a session that has grabbed the mouse). That frame was flattened by concatenating every cell of every row with no separator.

A terminal hard wrap starts the continuation at column zero, so those URLs stitched back together by accident. Anything the renderer wrapped itself — markdown bodies, bullet continuations, box-drawn panels — indents the continuation, and those indent spaces terminated the URL run.

Repro, width 23:

  https://example.com/a
    bbb/ccc?q=1
click row 0  →  https://example.com/a     truncated
click row 1  →  NO HIT                    tail not clickable at all

That's worse than not linking at all: the user gets a confident click that opens a truncated, usually 404-ing URL, and nothing about the dead tail suggests the link was mis-read.

Worth noting the existing url_hit_reconstructs_wrapped_url_across_rows only passed because its first row happens to fill the bounds width exactly. The stitch was naive concatenation, with trailing padding accidentally acting as the terminator.

The fix

Join rows on one signal — whether the row above used its last cell:

  • Last cell holds content → the width cut it off, so the row beneath continues it, and the indent in front of that continuation is layout rather than text. Skip the indent, join.
  • Row ends in blank cells → it ended on its own terms. That padding still stops a URL from running into the line below.
  • Blank or missing row → always breaks the run.

Keying on content in the last cell rather than on where the continuation starts covers both wrap styles, because both come from the same cause: content that ran out of width.

The continuation is now clickable and underlined on hover; the skipped indent is neither, which keeps hit-testing and highlighting in agreement.

Accepted tradeoff

A URL that happens to end exactly in a row's last cell will absorb the start of the row beneath it. That is rare, its blast radius is one wrong link, and narrowing it further would mean guessing at content rather than reading layout. The rule is deliberately conservative in the direction that matters — over-joining opens a wrong URL, which is worse than under-joining — so a line with room left over is never treated as continued.

Note this failure mode is not new: the old code joined row-end to next-row-column-zero unconditionally.

Risk checked

The signal would break if anything painted the last column inside the bounds. It doesn't: capture_frame_text reads cell symbols, and the scroll overlay is a background tint that leaves symbols untouched.

Tests

Three new, plus both pre-existing wrap tests still green:

  • url_hit_stitches_across_an_indented_continuation — both halves resolve to the whole URL from either row, underline starts at the first real character, and the indent itself is not a hit.
  • url_hit_does_not_stitch_a_line_that_ended_on_its_own — a URL with padding after it does not swallow the prose below.
  • url_hit_does_not_stitch_across_a_blank_row.

Full workspace suite green (1459 CLI tests) apart from the pre-existing, unrelated availability::auto_unavailable_when_only_a_subscription_credential_exists, which fails on any machine exporting OPENROUTER_API_KEY (missing from that test's scrub list since #1303).

No recording: this is a hover/click interaction and vhs cannot drive a mouse.

Spec 0210-a-wrapped-url-is-one-url.md.

Binaries

Only crates/cli is touched → the relevant binary is construct:

/Users/moon/agentd/.claude/worktrees/url-wrap-indent/target/debug/construct

Clickable URLs are recovered from the rendered frame, which was built
by concatenating every cell of every row. A terminal hard wrap starts
the next row at column zero, so those URLs stitched back together;
anything the renderer wrapped itself indents the continuation, and the
indent's spaces terminated the URL run.

The result was worse than an unlinked URL: clicking the first row
opened a confident, truncated link, and the tail was not clickable at
all, so nothing suggested the URL had been mis-read.

Join rows on whether the row above used its last cell — content there
means the width cut it off, so the row beneath continues it and its
indent is layout rather than text. A row ending in blank cells ended on
its own terms, and that padding still stops a URL from running into the
line below. Blank and missing rows always break the run.

This also makes the continuation clickable and underlined on hover,
while leaving the skipped indent neither.

Spec 0210.
@edwin-zvs
edwin-zvs merged commit 06936d7 into main Aug 25, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the url-wrap-indent branch August 25, 2026 18:48
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