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.
2.0 KiB
2.0 KiB
Clickable links in chat messages
- Detection (
lib/features/chat/ui/transcript/chat_links.dart, pure): barehttp(s)://andwww.links with trailing punctuation and unbalanced closing brackets trimmed;<https://…>,<mailto:…>and<user@host>autolinks; markdown destinations keep balanced parentheses and drop a"title".chatLinkUriis the only gate:http/httpswith a host,mailtowith an address,www.opened over https. Everything else stays plain text. - Assistant markdown (
ChatMarkdownView, also artifacts/run fields/stage definitions) opens links throughonOpenLinkwhen given, else theChatLinkScopelauncher (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 staysSelectableText. - 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
contextmenuevent is suppressed only while the pointer is over a link. Do not toggleBrowserContextMenufor this: on web everySelectableRegionrebuilds without its platform menu wrapper, remounts its subtree, throws inStaticSelectionContainerDelegate.hasSizeand 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.