From efc6ae961fb4530f3adef68d8bcca61293888d75 Mon Sep 17 00:00:00 2001 From: Brandon Oxendine Date: Fri, 6 Nov 2026 11:33:05 +0100 Subject: [PATCH] explorer: Add open in app to a share menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy link becomes a split button like desktop's, which can also copy the ID or rad: URI, or open the URI in whichever app handles it. Commits and releases get their own share button too. Browsers don't tell us whether the app opened, so instead of redirecting we show a notice linking to the desktop download page, unless the window loses focus within a second. Co-authored-by: Rūdolfs Ošiņš --- explorer/src/lib/shareAction.ts | 17 ++ explorer/src/views/repos/Commit.svelte | 8 +- explorer/src/views/repos/Header.svelte | 30 +-- explorer/src/views/repos/Issue.svelte | 8 +- explorer/src/views/repos/Layout.svelte | 3 +- explorer/src/views/repos/Patch.svelte | 6 +- explorer/src/views/repos/Release.svelte | 8 + explorer/src/views/repos/Share.svelte | 280 ++++++++++++++++++++++-- explorer/tests/e2e/repo/issue.spec.ts | 11 + 9 files changed, 332 insertions(+), 39 deletions(-) create mode 100644 explorer/src/lib/shareAction.ts diff --git a/explorer/src/lib/shareAction.ts b/explorer/src/lib/shareAction.ts new file mode 100644 index 000000000..c7c3a9f4f --- /dev/null +++ b/explorer/src/lib/shareAction.ts @@ -0,0 +1,17 @@ +import storedWritable from "@app/lib/localStore"; +import { z } from "zod"; + +const shareActionSchema = z.enum([ + "openInApp", + "copyLink", + "copyId", + "copyUri", +]); +export type ShareAction = z.infer; + +export const shareAction = storedWritable( + "shareAction", + shareActionSchema, + "copyLink", + !window.localStorage, +); diff --git a/explorer/src/views/repos/Commit.svelte b/explorer/src/views/repos/Commit.svelte index c2aac61f6..b94e64b3f 100644 --- a/explorer/src/views/repos/Commit.svelte +++ b/explorer/src/views/repos/Commit.svelte @@ -20,6 +20,7 @@ import Link from "@app/components/Link.svelte"; import Popover from "@app/components/Popover.svelte"; import Separator from "./Separator.svelte"; + import Share from "./Share.svelte"; export let baseUrl: BaseUrl; export let commit: Commit; @@ -75,7 +76,7 @@ } - + {/if}
+ { - shareIcon = "link"; - }, 1000); - function tabRoute(): string { if (activeTab === "issues") { return routeToPath({ @@ -60,13 +54,6 @@ }); } } - - async function copyLink() { - const origin = new URL(config.nodes.fallbackPublicExplorer).origin; - await toClipboard(origin.concat(tabRoute())); - shareIcon = "checkmark"; - restoreIcon(); - } + + + + { + if (event.key === "Escape") hideNotice(); + }} /> + +
+ + +
+ + + + + { + $shareAction = item.kind; + closeFocused(); + void run(item.kind); + }}> + + {item.title} + + + +
+ + {#if notice} +
+
+ Opening in app. Didn't open? + (notice = false)}> + Get Radicle Desktop + +
+ (notice = false)}> + + +
+ {/if} +
diff --git a/explorer/tests/e2e/repo/issue.spec.ts b/explorer/tests/e2e/repo/issue.spec.ts index 1bf4c4b9a..84fcbd369 100644 --- a/explorer/tests/e2e/repo/issue.spec.ts +++ b/explorer/tests/e2e/repo/issue.spec.ts @@ -6,3 +6,14 @@ test("navigate single issue", async ({ page }) => { await expect(page).toHaveURL(/\/issues\/[0-9a-f]{40}/); }); + +test("open in app offers the download page", async ({ page }) => { + await page.goto(`${cobUrl}/issues`); + await page.getByText("This title has **markdown**").click(); + await page.getByRole("button", { name: "Share options" }).click(); + await page.getByText("Open in app").click(); + + await expect(page.getByRole("status")).toContainText("Didn't open?"); + await page.getByRole("link", { name: "Get Radicle Desktop" }).click(); + await expect(page).toHaveURL(/\/desktop$/); +});