Files
orca/mobile/src/components/markdown-link-handler.ts
c2494f891b feat(mobile): ask where to open a link tapped in chat (#33525)
* feat(mobile): ask where to open a link tapped in chat

Tapping a web link in a chat message went straight to the system browser.
It now opens a sheet with Open in Orca browser (a browser tab on the host,
like terminal links), Open in Safari, and Copy link. The Orca option is left
out where a browser tab can't open (floating workspace, host without
browser streaming). Other markdown screens keep opening links directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): label the external link action "Open in browser"

The action hands the URL to the phone's default browser, which is not
always Safari, so it now says so on every platform, like the browser
setting does. The chat link routing moves into openMarkdownLink so
openMarkdownHref keeps its upstream signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): open mail links in chat directly instead of the link sheet

The Orca browser rejects mailto: URLs, so the sheet's first choice failed with "Enter a valid URL". Also folds openMarkdownLink back into openMarkdownHref and drops the label-list test.

* fix(mobile): send chat web-search result taps to the link sheet too

* chore(mobile): allowlist the chat link sheet strings until session screens are localized

* fix(mobile): offer the Orca browser for a link only on a connected host known to stream it

Before the screencast probe answered, while reconnecting, or with no host client, the link sheet
offered Open in Orca browser and the tap ended in a refusal toast or nothing. It now offers only
the phone's choices until the host is connected and supports it. Tests cover the sheet's three
actions, its two-action form and a failed copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): name the link sheet's phone choice "Open in system browser"

It opens whichever browser the phone is set to use, not a particular one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mobile): keep the chat link sheet with the chat it was opened from

The sheet's URL lived in the session screen, so it survived a notification
switching chats and reopened when returning from a file tab. It now lives in
the chat's row overlays next to the message actions sheet, which already
resets per conversation, and stays mounted until it has slid away. The Orca
browser choice now checks the live connection; showOfflineState is never
true while a chat is on screen.

* refactor(mobile): confirm a copied chat link like other copy actions

Copy link now flips to Copied with a success haptic, as the PR menu does,
instead of a session toast, so the chat overlay no longer threads showToast.
The link handler context defaults to the system browser, which drops the
null fallbacks from its readers.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
2026-11-05 19:45:51 +00:00

6 lines
302 B
TypeScript

import { createContext } from 'react'
import { openExternalLink } from '../platform/external-link'
// Screens that offer choices for a tapped web link provide this; elsewhere the system browser opens it.
export const MarkdownLinkHandlerContext = createContext<(url: string) => void>(openExternalLink)