9bfd16c6e5
Markdown links, autolinks and bare http(s)/www. URLs open externally through url_launcher (http, https and mailto only) in assistant markdown and operator messages; code is never linkified. Links use the host primary colour with an underline that thickens on hover, and offer Copy link on long press and right-click without breaking text selection.
33 lines
2.0 KiB
Markdown
33 lines
2.0 KiB
Markdown
# Clickable links in chat messages
|
|
|
|
- Detection (`lib/features/chat/ui/transcript/chat_links.dart`, pure): bare
|
|
`http(s)://` and `www.` links with trailing punctuation and unbalanced closing
|
|
brackets trimmed; `<https://…>`, `<mailto:…>` and `<user@host>` autolinks;
|
|
markdown destinations keep balanced parentheses and drop a `"title"`.
|
|
`chatLinkUri` is the only gate: `http`/`https` with a host, `mailto` with an
|
|
address, `www.` opened over https. Everything else stays plain text.
|
|
- Assistant markdown (`ChatMarkdownView`, also artifacts/run fields/stage
|
|
definitions) opens links through `onOpenLink` when given, else the
|
|
`ChatLinkScope` launcher (default: `url_launcher`, external application).
|
|
- Operator messages (`ChatLinkText`) keep the exact typed characters; only bare
|
|
links outside backtick code become links. Text without a link stays
|
|
`SelectableText`.
|
|
- Inline code and fenced code are never linkified.
|
|
- Style: host primary colour (`CupertinoTheme.primaryColor`), underline; hover
|
|
thickens the underline (paint-only, selection survives) with a click cursor.
|
|
- Copy link: long press adds it to the selection toolbar. On native desktop the
|
|
right-click selection toolbar carries it. On the web the browser owns the
|
|
right-click menu over text, so a link handles its own secondary click and the
|
|
DOM `contextmenu` event is suppressed only while the pointer is over a link.
|
|
Do not toggle `BrowserContextMenu` for this: on web every `SelectableRegion`
|
|
rebuilds without its platform menu wrapper, remounts its subtree, throws in
|
|
`StaticSelectionContainerDelegate.hasSize` and drops the selection.
|
|
|
|
Browser capture: `?links=1` on the chat fixture (`tool/perf/chat_scroll_fixture.dart`).
|
|
With the capture kit's semantics tree on, a CDP click lands on link semantics
|
|
nodes whose rects are the bounding box of a wrapped link, so verify clicks with
|
|
pointer events dispatched to `flutter-view`.
|
|
|
|
Observed, not caused by links: dragging a selection over text below a fenced
|
|
code block in the same answer also highlights the code block.
|