Skip to content

Open http(s) URL links from widget markdown#301

Merged
edwin-zvs merged 1 commit into
mainfrom
widget-url-click-open
May 31, 2026
Merged

Open http(s) URL links from widget markdown#301
edwin-zvs merged 1 commit into
mainfrom
widget-url-click-open

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Problem

Hovering over an [text](https://…) link inside a widget panel underlined the text (the in-frame auto-linkifier sees the visible URL portion), but clicking did nothing. The widget markdown renderer (render_inline_action_spans at crates/cli/src/ui.rs:3686) only recognized the agentd:action/... pattern when registering hit-targets — http(s)://... URLs fell through to plain text, and the click handler at crates/cli/src/app.rs:3953 had nothing to dispatch on.

Fix

Two changes, both in crates/cli:

  1. Detect URLs in markdown links: render_inline_action_spans now branches on agentd:action/, http://, https://, or "other". For URL links it pushes a new DynamicUiUrlHit (parallel to DynamicUiActionHit so no protocol change, no rename of the existing hit list, no churn on existing call sites). The visible label is rendered with an underline modifier so it reads as a link even at rest.
  2. Dispatch URL hits: handle_dynamic_ui_overlay_click now checks dynamic_ui_url_hits after the action-hit list (in both the inline-panel and dropdown branches) and calls the existing open_url() helper — same one that handles terminal-pane URL clicks via xdg-open / open / cmd /C start.

Also routes paragraph-style widget text through render_inline_action_spans so a URL in regular prose ("See docs for details.") gets the same treatment instead of rendering the raw [label](url) source unchanged.

Test

4 new unit tests in crates/cli/src/ui.rs:

  • http_link_in_widget_registers_url_hit — paragraph text containing one https link.
  • http_link_in_checklist_is_clickable_and_offset_correctly — http link inside a checkbox item, hit geometry offset by the glyph.
  • mixed_action_and_url_links_partition_correctly — action link on one line, URL on another, neither cross-contaminates the other's hit list.
  • non_http_link_schemes_do_not_register_url_hitsmailto: and file:// deliberately do not register (security guard against accidental dispatch).
cargo test -p agentd-cli   # 212 + 1 passed, 0 failed

🤖 Generated with Claude Code

Hovering an `[text](https://…)` link inside a widget panel underlined
the text (the in-frame auto-linkifier saw the visible URL portion) but
clicks did nothing — the markdown renderer only recognized
`agentd:action/...` patterns when registering hit-targets, so the label
half rendered as inert plain text alongside the bracketed source.

Detect `[text](http(s)://…)` alongside the existing `agentd:action/`
pattern in `render_inline_action_spans`, register a new
`DynamicUiUrlHit` (parallel to `DynamicUiActionHit` so neither protocol
nor existing call sites need to change), and dispatch via the existing
platform `open_url()` helper from `handle_dynamic_ui_overlay_click`
when a click lands on one.

Also route paragraph-style widget text through
`render_inline_action_spans` so inline URLs in regular sentences ("See
[docs](https://…) for details.") register the hit and render as just
the underlined label — not the raw `[label](url)` markdown source.

Four new tests cover the regression: bare URL in a paragraph, URL in a
checklist item, mixed action+URL across separate lines, and the
exclusion of non-http(s) schemes (mailto, file).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@edwin-zvs
edwin-zvs merged commit d418a97 into main May 31, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the widget-url-click-open branch May 31, 2026 17:15
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