YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
feat(chat): open links in side browser with external and copy actions (#7306)
Louis Beaumont6d36565e7570
diff --git a/.github/pr-assets/chat-link-actions/README.md b/.github/pr-assets/chat-link-actions/README.mdnew file mode 100644index 000000000..bb8a75862--- /dev/null+++ b/.github/pr-assets/chat-link-actions/README.md@@ -0,0 +1,33 @@+# Chat link actions: visual evidence++Captured September 25, 2026 from the production MarkdownBlock, ChatWebLink,+LinkPreviewAnchor, context menu, and toast components in a temporary isolated+Next.js preview. The preview loaded the app theme and fonts and used fictional+text with example.com. No customer data is present.++Implementation: 6fb9be894a85c7b598f0212361a97f84e244f71a.+Recreated baseline component: 43c6dd9ba (the implementation's parent).+Desktop: 1200 × 700 at device scale 1. Narrow: 520 × 700.++- before.png: original link at rest.+- after-idle.png: new link at rest; appearance intentionally unchanged.+- link-hover-preview.png: existing hover preview remains available.+- link-mouse-leave.png: preview dismissed after mouse leave.+- link-menu-light.png: right-click menu; preview does not overlap it.+- link-menu-external-hover.png: external-browser action highlighted.+- link-menu-keyboard.png: Shift+F10 opens the menu with keyboard focus.+- link-menu-dark.png: dark theme.+- link-copied.png: copy-success toast using a simulated native result.+- link-navigation-error.png: navigation-error toast using a simulated native result.+- link-copy-error.png: clipboard-error toast using a simulated native result.+- link-menu-no-sidebar.png: consumers without a side browser show external/copy only.+- link-menu-narrow.png: narrow viewport and wrapped link.+- link-menu-reduced-motion.png: keyboard menu with reduced motion at narrow width.++The capture exercised menu open/close, hover dismissal, Shift+F10, Escape,+copy-success, navigation-error and copy-error handling. Native navigation and+clipboard responses were stubbed in the temporary preview; no operating-system+clipboard was changed. These images do not verify native WebKit rendering,+external-browser launch, native clipboard integration, or cross-platform desktop+behavior. The temporary route and fixtures were removed before validation and+are not part of the patch.diff --git a/.github/pr-assets/chat-link-actions/after-idle.png b/.github/pr-assets/chat-link-actions/after-idle.pngnew file mode 100644index 000000000..143402476Binary files /dev/null and b/.github/pr-assets/chat-link-actions/after-idle.png differdiff --git a/.github/pr-assets/chat-link-actions/before.png b/.github/pr-assets/chat-link-actions/before.pngnew file mode 100644index 000000000..143402476Binary files /dev/null and b/.github/pr-assets/chat-link-actions/before.png differdiff --git a/.github/pr-assets/chat-link-actions/link-copied.png b/.github/pr-assets/chat-link-actions/link-copied.pngnew file mode 100644index 000000000..81a2c3261Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-copied.png differdiff --git a/.github/pr-assets/chat-link-actions/link-copy-error.png b/.github/pr-assets/chat-link-actions/link-copy-error.pngnew file mode 100644index 000000000..19609f827Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-copy-error.png differdiff --git a/.github/pr-assets/chat-link-actions/link-hover-preview.png b/.github/pr-assets/chat-link-actions/link-hover-preview.pngnew file mode 100644index 000000000..86c825ba7Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-hover-preview.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-dark.png b/.github/pr-assets/chat-link-actions/link-menu-dark.pngnew file mode 100644index 000000000..5e6e6c1baBinary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-dark.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-external-hover.png b/.github/pr-assets/chat-link-actions/link-menu-external-hover.pngnew file mode 100644index 000000000..75fa6c91aBinary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-external-hover.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-keyboard.png b/.github/pr-assets/chat-link-actions/link-menu-keyboard.pngnew file mode 100644index 000000000..21e32220aBinary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-keyboard.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-light.png b/.github/pr-assets/chat-link-actions/link-menu-light.pngnew file mode 100644index 000000000..186267d21Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-light.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-narrow.png b/.github/pr-assets/chat-link-actions/link-menu-narrow.pngnew file mode 100644index 000000000..407a15550Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-narrow.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-no-sidebar.png b/.github/pr-assets/chat-link-actions/link-menu-no-sidebar.pngnew file mode 100644index 000000000..ddcec69e6Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-no-sidebar.png differdiff --git a/.github/pr-assets/chat-link-actions/link-menu-reduced-motion.png b/.github/pr-assets/chat-link-actions/link-menu-reduced-motion.pngnew file mode 100644index 000000000..b3cda9788Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-menu-reduced-motion.png differdiff --git a/.github/pr-assets/chat-link-actions/link-mouse-leave.png b/.github/pr-assets/chat-link-actions/link-mouse-leave.pngnew file mode 100644index 000000000..143402476Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-mouse-leave.png differdiff --git a/.github/pr-assets/chat-link-actions/link-navigation-error.png b/.github/pr-assets/chat-link-actions/link-navigation-error.pngnew file mode 100644index 000000000..5c1151225Binary files /dev/null and b/.github/pr-assets/chat-link-actions/link-navigation-error.png differdiff --git a/apps/screenpipe-app-tauri/components/chat/chat-web-link.tsx b/apps/screenpipe-app-tauri/components/chat/chat-web-link.tsxnew file mode 100644index 000000000..819d86d8c--- /dev/null+++ b/apps/screenpipe-app-tauri/components/chat/chat-web-link.tsx@@ -0,0 +1,101 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com+"use client";++import React, { createContext, useContext, useState } from "react";+import { openUrl } from "@tauri-apps/plugin-opener";+import { useGT } from "gt-react";+import { commands } from "@/lib/utils/tauri";+import { toast } from "@/components/ui/use-toast";+import {+ ContextMenu,+ ContextMenuContent,+ ContextMenuItem,+ ContextMenuSeparator,+ ContextMenuTrigger,+} from "@/components/ui/context-menu";+import { LinkPreviewAnchor } from "./link-preview-anchor";++// Only surfaces that actually mount BrowserSidebar supply an owner. Other+// MarkdownBlock consumers (meeting notes, notifications) keep external links.+export const ChatLinkBrowserContext = createContext<string | null>(null);++type ChatWebLinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & { href: string };++export function ChatWebLink({ href, children, ...props }: ChatWebLinkProps) {+ const conversationId = useContext(ChatLinkBrowserContext);+ const ui = useGT();+ const [menuOpen, setMenuOpen] = useState(false);+ const run = async (action: () => Promise<unknown>, failure: string) => {+ try {+ await action();+ } catch {+ toast({ title: failure, variant: "destructive" });+ }+ };+ const openExternal = () => run(() => openUrl(href), ui("Couldn't open link"));+ const openInBrowser = () => run(async () => {+ if (!conversationId) return openUrl(href);+ const result = await commands.ownedBrowserNavigate(href, conversationId, true);+ if (result.status === "error") throw new Error(result.error);+ }, ui("Couldn't open link. Try Open in external browser."));++ return (+ <ContextMenu onOpenChange={setMenuOpen}>+ <ContextMenuTrigger asChild onContextMenu={(event) => event.stopPropagation()}>+ <span>+ <LinkPreviewAnchor+ {...props}+ href={href}+ disablePreview={menuOpen}+ target="_blank"+ rel="noopener noreferrer"+ onClick={(event) => {+ props.onClick?.(event);+ if (event.defaultPrevented) return;+ event.preventDefault();+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {+ void openExternal();+ } else {+ void openInBrowser();+ }+ }}+ onAuxClick={(event) => {+ props.onAuxClick?.(event);+ if (event.defaultPrevented || event.button !== 1) return;+ event.preventDefault();+ void openExternal();+ }}+ onKeyDown={(event) => {+ props.onKeyDown?.(event);+ if (event.defaultPrevented) return;+ if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10")) {+ event.preventDefault();+ const rect = event.currentTarget.getBoundingClientRect();+ event.currentTarget.dispatchEvent(new MouseEvent("contextmenu", {+ bubbles: true, cancelable: true, clientX: rect.left, clientY: rect.bottom,+ }));+ }+ }}+ >{children}</LinkPreviewAnchor>+ </span>+ </ContextMenuTrigger>+ <ContextMenuContent data-chat-actions-menu="" className="min-w-56 not-prose">+ {conversationId && <ContextMenuItem onSelect={() => void openInBrowser()}>+ {ui("Open in side browser")}+ </ContextMenuItem>}+ <ContextMenuItem onSelect={() => void openExternal()}>+ {ui("Open in external browser")}+ </ContextMenuItem>+ <ContextMenuSeparator />+ <ContextMenuItem onSelect={() => void run(async () => {+ const result = await commands.copyTextToClipboard(href);+ if (result.status === "error") throw new Error(result.error);+ toast({ title: ui("Link copied") });+ }, ui("Couldn't copy link"))}>+ {ui("Copy link")}+ </ContextMenuItem>+ </ContextMenuContent>+ </ContextMenu>+ );+}diff --git a/apps/screenpipe-app-tauri/components/chat/link-preview-anchor.tsx b/apps/screenpipe-app-tauri/components/chat/link-preview-anchor.tsxindex 143a1eb2a..acf663201 100644--- a/apps/screenpipe-app-tauri/components/chat/link-preview-anchor.tsx+++ b/apps/screenpipe-app-tauri/components/chat/link-preview-anchor.tsx@@ -37,6 +37,7 @@ type PreviewState =export interface LinkPreviewAnchorProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {href: string;+ disablePreview?: boolean;}function clearTimer(@@ -176,7 +177,9 @@ export function LinkPreviewAnchor({children,className,href,+ disablePreview = false,onBlur,+ onContextMenu,onFocus,onPointerEnter,onPointerLeave,@@ -201,7 +204,15 @@ export function LinkPreviewAnchor({? { status: "loading" }: resolvedState;+ useEffect(() => {+ if (!disablePreview) return;+ clearTimer(openTimer);+ clearTimer(closeTimer);+ setOpen(false);+ }, [disablePreview]);+const openSoon = () => {+ if (disablePreview) return;clearTimer(closeTimer);if (open) return;clearTimer(openTimer);@@ -275,17 +286,23 @@ export function LinkPreviewAnchor({if (!link) {return (- <a href={href} className={className} {...props}>+ <a href={href} className={className} onContextMenu={onContextMenu} {...props}>{children}</a>);}return (- <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>+ <PopoverPrimitive.Root open={open && !disablePreview} onOpenChange={setOpen}><PopoverPrimitive.Anchor asChild><ahref={href}+ onContextMenu={(event) => {+ clearTimer(openTimer);+ clearTimer(closeTimer);+ setOpen(false);+ onContextMenu?.(event);+ }}className={className}aria-describedby={open ? previewId : undefined}onBlur={(event) => {@@ -295,7 +312,7 @@ export function LinkPreviewAnchor({onFocus={(event) => {clearTimer(openTimer);clearTimer(closeTimer);- setOpen(true);+ if (!disablePreview) setOpen(true);onFocus?.(event);}}onPointerEnter={(event) => {diff --git a/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx b/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsxindex 6b5e3e39f..1780ecfdc 100644--- a/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx@@ -4,15 +4,24 @@import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";+import { ChatLinkBrowserContext } from "./chat-web-link";import { MarkdownBlock, stableStreamingMarkdownPrefix } from "./markdown-block";const {emitMock,+ ownedBrowserNavigateMock,+ openUrlMock,+ copyTextToClipboardMock,+ toastMock,openViewerWindowMock,setPendingNavigationMock,showWindowMock,routeNotificationDeeplinkMock,} = vi.hoisted(() => ({+ ownedBrowserNavigateMock: vi.fn(async () => ({ status: "ok" as const, data: null })),+ openUrlMock: vi.fn(async () => undefined),+ copyTextToClipboardMock: vi.fn(async () => ({ status: "ok" as const, data: null })),+ toastMock: vi.fn(),emitMock: vi.fn(async () => undefined),openViewerWindowMock: vi.fn(async (_path: string) => ({status: "ok" as const,@@ -24,11 +33,16 @@ const {vi.mock("@/lib/utils/tauri", () => ({commands: {+ ownedBrowserNavigate: ownedBrowserNavigateMock,+ copyTextToClipboard: copyTextToClipboardMock,openViewerWindow: openViewerWindowMock,showWindow: showWindowMock,},}));+vi.mock("@tauri-apps/plugin-opener", () => ({ openUrl: openUrlMock }));+vi.mock("@/components/ui/use-toast", () => ({ toast: toastMock }));+vi.mock("@tauri-apps/api/event", () => ({emit: emitMock,}));@@ -51,6 +65,86 @@ describe("MarkdownBlock", () => {vi.clearAllMocks();});++ const webUrl = "https://example.com/docs#setup";+ const renderWebLink = (owner: string | null = "chat-123") => render(+ <ChatLinkBrowserContext.Provider value={owner}>+ <MarkdownBlock text={`[Guide](${webUrl})`} isUser={false} />+ </ChatLinkBrowserContext.Provider>,+ );++ it("reveals web links in the owning chat's side browser", async () => {+ renderWebLink();+ fireEvent.click(screen.getByRole("link", { name: "Guide" }));+ await waitFor(() => expect(ownedBrowserNavigateMock).toHaveBeenCalledWith(webUrl, "chat-123", true));+ expect(openUrlMock).not.toHaveBeenCalled();+ });++ it.each([{ metaKey: true }, { ctrlKey: true }, { shiftKey: true }])("opens modified clicks externally (%j)", async (modifier) => {+ renderWebLink();+ fireEvent.click(screen.getByRole("link", { name: "Guide" }), modifier);+ await waitFor(() => expect(openUrlMock).toHaveBeenCalledWith(webUrl));+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ });++ it("opens middle clicks externally without navigating the side browser", async () => {+ renderWebLink();+ fireEvent(screen.getByRole("link", { name: "Guide" }), new MouseEvent("auxclick", { bubbles: true, cancelable: true, button: 1 }));+ await waitFor(() => expect(openUrlMock).toHaveBeenCalledWith(webUrl));+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ });++ it("keeps links external on surfaces without a side browser", async () => {+ renderWebLink(null);+ const link = screen.getByRole("link", { name: "Guide" });+ fireEvent.click(link);+ await waitFor(() => expect(openUrlMock).toHaveBeenCalledWith(webUrl));+ fireEvent.contextMenu(link);+ expect(screen.queryByRole("menuitem", { name: "Open in side browser" })).not.toBeInTheDocument();+ expect(screen.getByRole("menuitem", { name: "Open in external browser" })).toBeInTheDocument();+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ });++ it.each(["Open in side browser", "Open in external browser", "Copy link"])("supports the %s menu action", async (label) => {+ renderWebLink();+ fireEvent.contextMenu(screen.getByRole("link", { name: "Guide" }));+ fireEvent.click(screen.getByRole("menuitem", { name: label }));+ if (label === "Copy link") {+ await waitFor(() => expect(copyTextToClipboardMock).toHaveBeenCalledWith(webUrl));+ expect(openUrlMock).not.toHaveBeenCalled();+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ } else if (label === "Open in side browser") {+ await waitFor(() => expect(ownedBrowserNavigateMock).toHaveBeenCalledWith(webUrl, "chat-123", true));+ expect(openUrlMock).not.toHaveBeenCalled();+ } else {+ await waitFor(() => expect(openUrlMock).toHaveBeenCalledWith(webUrl));+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ }+ });++ it("supports the keyboard context menu without opening the URL", () => {+ renderWebLink();+ fireEvent.keyDown(screen.getByRole("link", { name: "Guide" }), { key: "F10", shiftKey: true });+ expect(screen.getByRole("menuitem", { name: "Open in side browser" })).toBeInTheDocument();+ expect(ownedBrowserNavigateMock).not.toHaveBeenCalled();+ expect(openUrlMock).not.toHaveBeenCalled();+ });++ it("reports failed navigation without unexpectedly opening an external browser", async () => {+ ownedBrowserNavigateMock.mockResolvedValueOnce({ status: "error", error: "unavailable" } as never);+ renderWebLink();+ fireEvent.click(screen.getByRole("link", { name: "Guide" }));+ await waitFor(() => expect(toastMock).toHaveBeenCalledWith(expect.objectContaining({ variant: "destructive" })));+ expect(openUrlMock).not.toHaveBeenCalled();+ });++ it("uses the current conversation after switching chats", () => {+ const { rerender } = renderWebLink();+ rerender(<ChatLinkBrowserContext.Provider value="chat-456"><MarkdownBlock text={`[Guide](${webUrl})`} isUser={false} /></ChatLinkBrowserContext.Provider>);+ fireEvent.click(screen.getByRole("link", { name: "Guide" }));+ expect(ownedBrowserNavigateMock).toHaveBeenCalledWith(webUrl, "chat-456", true);+ });+it("routes local viewer links to the in-chat preview callback instead of opening a viewer window", async () => {const onOpenViewerPath = vi.fn();@@ -85,6 +179,18 @@ describe("MarkdownBlock", () => {);});+ it("closes link previews and prevents the transcript menu from opening over the link menu", async () => {+ const transcriptMenu = vi.fn();+ render(<div onContextMenu={transcriptMenu}><ChatLinkBrowserContext.Provider value="chat-123"><MarkdownBlock text="[Repository](https://github.com/screenpipe/screenpipe)" isUser={false} /></ChatLinkBrowserContext.Provider></div>);+ const link = screen.getByRole("link", { name: "Repository" });+ fireEvent.focus(link);+ expect(screen.getByRole("tooltip")).toBeInTheDocument();+ fireEvent.contextMenu(link);+ await waitFor(() => expect(screen.queryByRole("tooltip")).not.toBeInTheDocument());+ expect(screen.getByRole("menuitem", { name: "Copy link" })).toBeInTheDocument();+ expect(transcriptMenu).not.toHaveBeenCalled();+ });+it("keeps wide tables readable in a keyboard-scrollable container", () => {render(<MarkdownBlockdiff --git a/apps/screenpipe-app-tauri/components/chat/markdown-block.tsx b/apps/screenpipe-app-tauri/components/chat/markdown-block.tsxindex f53c17c57..c6ea6fb56 100644--- a/apps/screenpipe-app-tauri/components/chat/markdown-block.tsx+++ b/apps/screenpipe-app-tauri/components/chat/markdown-block.tsx@@ -25,7 +25,7 @@ import { commands } from "@/lib/utils/tauri";import { useTimelineStore } from "@/lib/hooks/use-timeline-store";import { cn } from "@/lib/utils";import { sanitizeToolCallXml } from "@/lib/utils/sanitize-tool-call-xml";-import { LinkPreviewAnchor } from "@/components/chat/link-preview-anchor";+import { ChatWebLink } from "@/components/chat/chat-web-link";import { useGT } from "gt-react";@@ -210,7 +210,7 @@ export function MarkdownBlock({if (href?.startsWith("http://") || href?.startsWith("https://")) {return (- <LinkPreviewAnchor+ <ChatWebLinkhref={href}target="_blank"rel="noopener noreferrer"@@ -218,7 +218,7 @@ export function MarkdownBlock({{...props}>{children}- </LinkPreviewAnchor>+ </ChatWebLink>);}diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex bfaa97b50..9be26e300 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -21,6 +21,7 @@ import { Button } from "@/components/ui/button";import { SchedulePromptDialog } from "@/components/chat/schedule-prompt-dialog";import { AcpSignInDialog, type AcpSignInRequest } from "@/components/chat/standalone/acp-sign-in-dialog";import { acpAdapterInfo } from "@/lib/utils/preset-appearance";+import { ChatLinkBrowserContext } from "@/components/chat/chat-web-link";import { BrowserSidebar } from "@/components/browser-sidebar";import { toast } from "@/components/ui/use-toast";import type { AIPreset, JsonValue } from "@/lib/utils/tauri";@@ -2290,6 +2291,7 @@ export function StandaloneChat({}, [addSelectedTextToChat, conversationId, discardTemporarySideConversation, focusComposerAtEnd, setInput, startNewConversation, uiLanguage]);return (+ <ChatLinkBrowserContext.Provider value={conversationId}><div ref={dropRootRef} className={cn("flex flex-col bg-background", className ?? "h-screen")} data-testid="section-home"><StandaloneChatHeaderclassName={className}@@ -2683,5 +2685,6 @@ export function StandaloneChat({/></div>+ </ChatLinkBrowserContext.Provider>);}