Repository navigation
feat(chat): offer Copy link and Open link on a long-pressed link in the Android app - #1925
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Platform-gated menu and app integration src/lib/nativeApp.ts, src/components/MarkdownLinkMenu.tsx, src/App.tsx, src/components/RowMenu.tsx, src/components/RowMenu.css, src/lib/i18n/chat.*.ts, src/lib/i18n.test.ts |
Adds Android platform detection and an app-level menu for long-pressed rendered links. The menu supports copy and open, and offers share when navigator.share is available. Row menus and scrims inside accessible modals receive updated stacking behavior. Japanese, Korean, and Simplified Chinese translations add menu labels. |
Regression checks and supporting documentation scripts/link-menu-demo-regression.ts, scripts/ci-browser.sh, docs/development.md, DESIGN.md, changelog.d/chat-link-long-press.md |
Adds Playwright checks for menu actions, translations, file-preview layering, and interactions that should not open the menu. Browser CI runs the script. The development guide, design specification, and changelog describe the coverage and behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Suggested reviewers: jiunshinn
Merge Risk: 
Minimal · up to da25b
-
No concrete issue remains that needs to be resolved before merging.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description includes the required Change and Validation sections. It clearly explains the behavior, scope, regression coverage, and test results. It does not include a maintainer-approved issue link, but the description is otherwise complete.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 10 files. (4 skipped: 4 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Code review (Codex, gpt-6.1-sol, reasoning xhigh)First pass, on 01d1dc1: CHANGES REQUESTED, with two MAJOR findings.
Re-review, on da25b2b: no findings, APPROVE. Codex confirmed both are resolved: the z-order holds for other RowMenu users inside dialogs (New workspace's folders), and the parse helper works with |
|
Merge pass: this PR and #1920 (the Mac app window) both add a function at the end of |
|
Will do. Once #1920 is on main, I'll rebase this branch onto it, keep both |
|
Merge pass: #1920 is merged (718f0e0), so you can rebase now. Keep both |
…he Android app Android's WebView draws no menu for a long-pressed link: on an Android 16 emulator, a long press on a chat link in the app fired a touch contextmenu and then nothing, so the address could not be copied. Chrome, Safari and the iOS app's WKWebView show their own link menu, and the client cancels none of them. In the Android app only (Capacitor's getPlatform() is android), the WebView's own long press on a rendered Markdown link now opens the phone's sheet (RowMenu): Copy link, Open link (the tap's own way) and, where the WebView has navigator.share, Share link. The link's words are the title, with the whole address under them. A tap, a swipe, a press on other words and a mouse-typed contextmenu keep their meaning. scripts/link-menu-demo-regression.ts covers the sheet, each action, what must stay unchanged, and a browser keeping its own menu.
…ormed address Codex review of the link sheet found two ways it failed: - At phone width the sheet's scrim sat on --z-modal (30), under the file viewer (31), so a long press on a link in a file preview opened actions that could not be tapped. RowMenu's sheet now gets the is-over-modal class its popover already had when opened from inside a dialog, and both sit at --z-modal + 3: over the file viewer and Settings over a preview, under the palette. - Markdown links an address no URL parser takes (http://127.0.0.1:99999/), and new URL() threw while rendering the sheet, outside the transcript's error boundaries. The host is parsed in a try/catch (older Android WebViews lack URL.canParse), and such an address is its own title. The demo regression gains both cases; each fails with its fix reverted.
da25b2b to
610ca6d
Compare
|
Rebased onto current main
Verification on
The earlier Codex approval covers this code; only the rebase delta is new, so no new review was run. Rebase prepared by a maintainer agent and checked against the code. The merge decision stays with the maintainer's merge pass. |
|
Rebased onto current main, The only conflict was in Verification on
Codex: n/a for this rebase-only delta; the existing approved review remains the review of the behavior. Thanks for the contribution. Fixes prepared by a maintainer agent and checked against the code. The merge decision stays with the maintainer's merge pass. |
|
Merge pass review-work report. Overall: PASSED. This changes web client behaviour inside the Android app, so it ships with the server update. It was gated by the lane's Codex APPROVE (given after two MAJOR findings were fixed), an omo code reviewer, and the merge pass's own checks.
Scope:
Behaviour:
Tests:
LOW follow-ups:
Rebase 610ca6d (ext-pr-fixes): the branch was rebased onto main 6e729da.
CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
Change
On a phone, a link in a chat reply (or any other rendered Markdown) was hard to copy. The cause depends on the platform:
adb shell input swipe x y x y 1500) fired a touchcontextmenu(target: the link's span, not cancelled), and then nothing happened: no menu, no selection.-webkit-touch-callout: noneapplies tolabel, summary(styles.css). PaneCanvas's panecontextmenucapture returns early for touch. The iOS app leaves Capacitor'sios.allowsLinkPreviewunset, so WKWebView's default (true since iOS 10) gives it the system link menu.So this restores what is missing only where it is missing. A long press on a rendered Markdown link (
.markdown a[href]) in the Android app opens the phone's sheet (the existingRowMenu):copyText). Copying the link's words, which is all the WebView's text selection could do, does not get you the address.link.click(): the phone's browser in the app, or the web panel where there is one).navigator.share. Android's WebView has none (checked:typeof navigator.shareisundefinedin the app), so the app shows Copy link and Open link. Sharing from the app would need a native share plugin, which is left out here.Only the WebView's own long press opens it: its touch
contextmenuon a link, which the sheet cancels (the WebView would only select the link's words). A tap still opens the link. A swipe that starts on a link still scrolls. A long press on other words is untouched. A mouse-typedcontextmenu, which Android sends to end a dragged text selection, is ignored, as PaneCanvas already does. Outside the Android app (inAndroidApp(): Capacitor'sgetPlatform()isandroid), nothing listens.Design precedent: Android Chrome's own link menu (Copy link address / Open / Share link), cut to those three actions and drawn with the app's existing sheet. The browsers and the iOS app keep their system menus, as the brief preferred. DESIGN.md has the entry.
The sheet works for every rendered Markdown link, a file preview's included. RowMenu already lifted its popover over the dialog it opened from (
is-over-modal); its phone sheet now gets the same class. Both sit at--z-modal + 3, above the file viewer (+1) and Settings over a preview (+2) and below the palette. Before, a sheet opened from a link in a file preview was drawn under the preview. An address Markdown links but no URL parser takes (http://127.0.0.1:99999/) gets the sheet titled by itself. Before,new URL()threw in render, outside the transcript's error boundaries.New strings:
Open linkandShare link(ko/ja/zh in the chat dictionaries).Copy linkalready existed.Validation
Android app, real WebView (Android 16 emulator,
ovis-insets-36read-only, debug APK from this branch, "Try the demo", real touches throughadb shell input, page read over the WebView's DevTools socket):contextmenuwas cancelled, no selection, and the sheet showed Copy link / Open link / Cancel (the before/after screenshots are described above).navigator.clipboard.writeTextresolved with the full address, and Android's own paste key (KEYCODE_PASTEinto the message box) pasted exactlyhttps://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/.topResumedActivitycom.android.chrome). A plain tap on the link also brought Chrome to the front, with an uncancelled click on the link, and no sheet.scripts/link-menu-demo-regression.ts(new, enrolled in the browser lane). It runs the unmodified demo client at 390 px with phone emulation and a stand-in Capacitor bridge. A desktop Chromium turns no held touch into acontextmenu(checked: neither a CDP touch hold norInput.synthesizeTapGesturefires one), so each long press is the touch-typedcontextmenuthe WebView sends. It checks:the sheet, its items and their order, the title and wrapped address, and a bare address titled by its host;
Copy link puts the address on the clipboard;
Open link opens the same window a tap opens, and a tap still opens the link with no sheet;
other words and a mouse's menu are not cancelled;
a CDP touch swipe from a link scrolls the chat and opens nothing;
Share link (with a
navigator.share) shares{ url }, in Korean;a browser without the bridge leaves the
contextmenuuncancelled and shows no sheet.a malformed address gets its sheet, Copy link copies it as written, and the app stays up;
a link in the file preview (a dialog on a phone) opens its sheet over the preview, and Copy link takes a hit-tested
tap().Each check can fail (checked by mutation): with the Android gate inverted, the first case fails; with
new URL(href).hostback, the malformed case times out (the app crashed); with the sheet'sis-over-modalremoved, the file-preview tap times out. WithUI_EVIDENCE_DIRit captures the sheet at rest at 390: in English, in Korean with Share link, and over the file preview.iOS Safari emulation (Playwright WebKit with the
iPhone 15descriptor over the same demo build, chat linkhttps://datatracker.ietf.org/...):-webkit-touch-callout: none,user-select: noneorpointer-events: none(the callout is at its default,user-selectisauto);pointerdown,touchstartor touchcontextmenuis cancelled;So Safari's own link menu is left alone. A real iPhone was not tried.
bun run check fast(throughdori heavy) passes: typecheck, build, and unit tests (6720 pass).src/lib/i18n.test.ts(MarkdownLinkMenu.tsxis registered with the chat part) and the conventions tests pass.Reviewed by Codex (gpt-6.1-sol, xhigh), first pass: two MAJOR findings, both fixed here with regression cases. (1) The sheet opened under the file viewer; its layer is now over dialogs. (2) A malformed address crashed the app; the host is now parsed safely, with a try/catch rather than
URL.canParse, which older Android WebViews lack. Re-review of the fix commit: no findings, APPROVE.