Skip to content

feat(chat): offer Copy link and Open link on a long-pressed link in the Android app - #1925

Merged
devswha merged 2 commits into
mainfrom
feat/chat-link-long-press
Oct 25, 2026
Merged

devswha merged 2 commits into
mainfrom
feat/chat-link-long-press

Conversation

@devswha

@devswha devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner

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:

  • Android app (Capacitor WebView): no link menu at all. Android's WebView draws no menu of its own for a long-pressed link. On an Android 16 emulator running the app built from main, "Try the demo" with a real 1.5 s long press on a chat link (adb shell input swipe x y x y 1500) fired a touch contextmenu (target: the link's span, not cancelled), and then nothing happened: no menu, no selection.
  • Chrome, Safari and the iOS app: unchanged, and they keep their own menu. The client cancels no long press on a link. The only -webkit-touch-callout: none applies to label, summary (styles.css). PaneCanvas's pane contextmenu capture returns early for touch. The iOS app leaves Capacitor's ios.allowsLinkPreview unset, 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 existing RowMenu):

  • Copy link puts the link's address on the clipboard (copyText). Copying the link's words, which is all the WebView's text selection could do, does not get you the address.
  • Open link opens it the way a tap does (link.click(): the phone's browser in the app, or the web panel where there is one).
  • Share link, only where the WebView has navigator.share. Android's WebView has none (checked: typeof navigator.share is undefined in 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.
  • The link's words are the sheet's title, with the whole address wrapped under them. For a bare address, its host is the title.

Only the WebView's own long press opens it: its touch contextmenu on 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-typed contextmenu, which Android sends to end a dragged text selection, is ignored, as PaneCanvas already does. Outside the Android app (inAndroidApp(): Capacitor's getPlatform() is android), 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 link and Share link (ko/ja/zh in the chat dictionaries). Copy link already existed.

Validation

  • Android app, real WebView (Android 16 emulator, ovis-insets-36 read-only, debug APK from this branch, "Try the demo", real touches through adb shell input, page read over the WebView's DevTools socket):

    • Long press on the chat's datatracker link: the contextmenu was cancelled, no selection, and the sheet showed Copy link / Open link / Cancel (the before/after screenshots are described above).
    • Copy link: navigator.clipboard.writeText resolved with the full address, and Android's own paste key (KEYCODE_PASTE into the message box) pasted exactly https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/.
    • Open link: Chrome came to the front (topResumedActivity com.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 a contextmenu (checked: neither a CDP touch hold nor Input.synthesizeTapGesture fires one), so each long press is the touch-typed contextmenu the 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 contextmenu uncancelled 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).host back, the malformed case times out (the app crashed); with the sheet's is-over-modal removed, the file-preview tap times out. With UI_EVIDENCE_DIR it 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 15 descriptor over the same demo build, chat link https://datatracker.ietf.org/...):

    • nothing on the link or its ancestors sets -webkit-touch-callout: none, user-select: none or pointer-events: none (the callout is at its default, user-select is auto);
    • none of a long press's touch pointerdown, touchstart or touch contextmenu is cancelled;
    • no sheet is drawn, and there are no page errors.

    So Safari's own link menu is left alone. A real iPhone was not tried.

  • bun run check fast (through dori heavy) passes: typecheck, build, and unit tests (6720 pass). src/lib/i18n.test.ts (MarkdownLinkMenu.tsx is 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.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8956961 and da25b2b.

Files selected for processing: 14
  • DESIGN.md
  • changelog.d/chat-link-long-press.md
  • docs/development.md
  • scripts/ci-browser.sh
  • scripts/link-menu-demo-regression.ts
  • src/App.tsx
  • src/components/MarkdownLinkMenu.tsx
  • src/components/RowMenu.css
  • src/components/RowMenu.tsx
  • src/lib/i18n.test.ts
  • src/lib/i18n/chat.ja.ts
  • src/lib/i18n/chat.ko.ts
  • src/lib/i18n/chat.zh.ts
  • src/lib/nativeApp.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Android users can long-press a rendered link to copy, open, or—when supported—share it. Tapping links continues to open them.
    • Link menus display above modal sheets when needed.
    • Added Japanese, Korean, and Simplified Chinese labels for the new actions.
  • Tests
    • Added browser regression coverage for link menus and existing interactions.

The app now provides an Android-only menu for long-pressed rendered Markdown links. The menu supports copy and open actions, and adds share when the WebView supports it. A browser regression script checks menu behavior and cases that retain existing behavior.

Changes: Android Link Menu

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: Low

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: adding Copy link and Open link for long-pressed links in the Android app.
Description check Passed 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 li…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Code review (Codex, gpt-6.1-sol, reasoning xhigh)

First pass, on 01d1dc1: CHANGES REQUESTED, with two MAJOR findings.

  1. The sheet opened behind the file viewer. At phone width RowMenu's .modal-scrim sat at --z-modal (30), under .file-viewer-scrim (31), so a long press on a link in a file preview gave actions no tap could reach.
    Resolved in da25b2b. RowMenu's sheet gets the is-over-modal class its popover already had when opened inside a dialog. Both sit at --z-modal + 3: above the file viewer (+1) and Settings over a preview (+2), and below the palette (35). The regression's file-preview case taps Copy link with Playwright's hit-tested tap(), and it times out with the class removed.
  2. A malformed address crashed the app. Markdown links http://127.0.0.1:99999/, and new URL(href) threw while rendering, outside the transcript's error boundaries.
    Resolved in da25b2b. The host is parsed in a try/catch (older Android WebViews have no URL.canParse), and such an address is its own title. The regression's malformed-address case fails with new URL(href).host back.

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 URL.canParse unavailable.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: this PR and #1920 (the Mac app window) both add a function at the end of src/lib/nativeApp.ts: this PR adds inAndroidApp, #1920 adds inMacApp. The two conflict on those adjacent lines. #1920 merges first for 0.4.15. Once it is in, please rebase and keep both functions; that is the whole conflict. The review of this PR runs meanwhile, so the rebase delta is all that is left to check.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Will do. Once #1920 is on main, I'll rebase this branch onto it, keep both inAndroidApp and inMacApp in src/lib/nativeApp.ts, rerun check fast and the link-menu regression, and push once. If CodeRabbit's review (in progress) asks for changes before then, they go into that same push.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: #1920 is merged (718f0e0), so you can rebase now. Keep both inMacApp and inAndroidApp in src/lib/nativeApp.ts. The review already passed, so only the rebase delta is left to check before this is queued. If it lands before the 0.4.15 release PR merges, it goes in; otherwise it ships next.

mp added 2 commits October 26, 2026 00:54
…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.
@devswha
devswha force-pushed the feat/chat-link-long-press branch from da25b2b to 610ca6d Compare October 25, 2026 15:59
@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto current main 6e729daf7 and pushed once: da25b2b12 → 610ca6d51.

Verification on 610ca6d51:

  • bun run check fast (through the load gate): exit 0; workflow syntax, generated types/themes, typecheck, build and unit tests all pass, 0 failures; the report marks the source state verified.
  • scripts/link-menu-demo-regression.ts: all 7 cases pass (Copy/Open/Share link, a malformed address, other words and a mouse's menu keep their own long press, the sheet over a file preview, and the browser keeps its own menu).
  • i18n tests: 22 pass.

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.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto current main, 6e729daf7feae84cb25ab88a1dc2788324da5d66. The rebased commits are 2812de92e and 610ca6d51; their original authorship is preserved. Invoked the push once with the required lease; Git reported "Everything up-to-date", and the PR head read-back confirms 610ca6d51be51c99adf00abd195ec6dfacc63919.

The only conflict was in src/lib/nativeApp.ts. Both inMacApp from main and inAndroidApp from this PR are retained unchanged. git range-diff confirms the rebase delta only changes the insertion context around these helpers; the second commit is unchanged. There were no unresolved review threads.

Verification on 610ca6d51be51c99adf00abd195ec6dfacc63919:

  • bun test src/lib/i18n.test.ts: 22 passed, 0 failed.
  • dori heavy ext-pr-fixes -- bun scripts/link-menu-demo-regression.ts: exit 0, all 7 reported browser cases passed, including malformed addresses and the file-preview sheet.
  • dori heavy ext-pr-fixes -- bun run check fast: exit 0; workflow syntax, generated types/themes, typecheck, build and unit tests passed (6,803 passed, 0 failed, 13 skipped). The verification report confirms the source remained unchanged throughout the run.
  • nativeApp.ts diagnostics and git diff --check: clean.

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.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

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.

Lane Verdict
Codex (lane) APPROVE, after two MAJOR findings were fixed
Code review (omo-native-code-reviewer) PASS: no HIGH or MEDIUM findings, 5 LOW

Scope:

  • The listener is added once and cleaned up. It does nothing outside the Android app (inAndroidApp).
  • It skips a mouse contextmenu and anything that isn't .markdown a[href].
  • It only calls preventDefault. Browsers and iOS register no listener, and the script asserts that their contextmenu stays uncancelled.

Behaviour:

  • Copy link uses copyText.
  • Open link uses link.click(), so it is routed exactly as a tap is.
  • No javascript: href can reach it: Markdown links allow only http, https and mailto, and code links must start with http(s)://.
  • A malformed address no longer crashes the sheet.
  • The sheet stacks above a file preview and Settings, and below the palette. It reuses RowMenu's focus and Escape handling.

Tests:

  • link-menu-demo-regression.ts passes its 7 cases. It fails when the Android check is reverted (:146) and when the mouse guard is removed (:189).
  • The i18n tests (22) pass, the typecheck passes, and ja, ko and zh are complete.

LOW follow-ups:

  • A path-less address is shown twice, because link.href adds a trailing /.
  • A Partial<PointerEvent> cast where instanceof would do.
  • An unused pressedLink export.
  • The DESIGN.md precedent is Android Chrome rather than one of the listed coding-agent apps.

Rebase 610ca6d (ext-pr-fixes): the branch was rebased onto main 6e729da.

  • git range-diff shows only the context of the src/lib/nativeApp.ts hunk moved: inAndroidApp now sits next to inMacApp from feat(app): open Ovis in Ovis for Mac's own window #1920. The second commit is identical.
  • The i18n tests (22) pass, and so does the typecheck.
  • The lane's check fast had 0 failures, and the link-menu regression passed 7 of 7.
  • git merge-tree is clean, and there are no unresolved threads.

CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it.

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