Skip to content

RFC: Desktop hyperlink hovercard #242

Closed

Description

@HMarzban

Verdict

Add a hovercard on the docs.plus pad (desktop) when the pointer rests on a link. Keep today's click preview toolbar. Mobile keeps the tap sheet.

@docs.plus/extension-hyperlink must not gain hovercard DOM, hovercard CSS, or a prebuilt fallback card. It must not call a URL. Slice 1 is host-only.

Hovercard is the product name (so it does not collide with preview). It is not a new word in extensions/README.md §Vocabulary. The content is read-only host UI, not a toolbar.

Headless (hard constraint)

The published packages own schema, commands, URL decisions, and pointer plugins. They do not own product chrome for this feature.

Be exact about today's package: it ships prebuilt preview / create / edit factories and styles.css. Click preview does not auto-mount them. popovers.previewHyperlink defaults to null. The click handler stores that slot as-is and opens nothing when it is null. Create and edit openers still fall back to the prebuilt factory when the slot is null. A factory that returns null is the real opt-out.

So "opt-in" is true for click preview only. It is false for create / edit commands. Hover must copy the click-path rule, not the opener ?? fallback.

Do not add a fourth prebuilt popover. Do not add hovercard rules to styles.css. Do not ship a hostname chip from the package. getSpecialUrlInfo may inform a host card. It is not a reason to draw one in the npm tarball.

A later package hook is allowed only if it is a factory slot (or an event) with default null and no prebuilt fallback. Slice 1 does not need that hook. Do not call openPreviewHyperlink on hover. That opener hardcodes kind 'preview' and falls back to the prebuilt toolbar.

Problem

Preview already names the click toolbar and the mobile sheet. That surface is copy, edit, remove, plus a title when the host has metadata. There is no hover path.

Hover and click are different jobs. One shared UI copies Google Docs' noisy stack.

A published extension cannot scrape Open Graph data. docs.plus already has GET /api/metadata. Other hosts stay blank until they bring their own card.

Touch devices have no hover. The pad mobile sheet already shows title, description, and actions on tap.

Related work that is not this issue: #174 (internal-link chip copy) and #146 (URL decision pipeline).

Decision

Two species, two names:

  • Preview — click or tap. Action toolbar or sheet. Already shipped.
  • Hovercard — desktop pad only. Read-only page context. Headed host UI. New.

Click, create, and edit win. Opening those surfaces destroys the hovercard. Hover leave must close only the hover instance. A blind close() tears down create / edit.

The first shippable slice is the docs.plus pad on desktop. Do not change the package to ship slice 1.

Slice 1 host rules (required)

Host-only is shippable. The shared controller already accepts a custom kind. These gaps must stay in the spec:

  1. Kind. Adopt a host kind (for example 'hovercard'). Do not reuse 'preview'. Do not call openPreviewHyperlink.
  2. Pad-only plugin. Attach hover to the pad editor DOM. Desktop composer uses the same previewHyperlink factory. A shared wrap would leak hover into the composer.
  3. Dual gate. !settings.editor.isMobile and (pointer: fine). Pointer alone is not desktop. Host mobile is UA-gated (getDeviceInfo / mobile-detect). Viewport resize is not mobile. iPad is the mobile shell, even with a mouse. Slice 1: no hovercard there.
  4. Hover-bridge. The pointer must be able to enter the card. A gap between the link and the card must not dismiss it at once.
  5. Leave. Close only when the mounted kind / element is the hover instance. Do not idle-sync the React create / edit portal by mistake.
  6. Display-only. Read L1 / L2 / L3 for paint. Do not flush() mark attrs from hover. Click preview stays the Yjs write path. A passer-by must not edit the room by resting the pointer.
  7. Fetch discipline. Debounce. Pass AbortSignal. Abort on leave and on click-wins. Do not fetch on every mouseenter. Reuse L2. fetchMetadata has no in-flight coalesce today; a hover herd can hit L3 N times for one cold URL. Host must not do that. Metadata shares the global REST limiter.

Extension (@docs.plus/extension-hyperlink)

Headless core stays as it is. Honest data the package already exposes (host reads, host paints):

  • stored mark href (not the resolved DOM link.href)
  • getSpecialUrlInfo — mailto:, tel:, catalog type
  • mark attrs title / image only if a host wrote them earlier

If we extract a hook after slice 1, match the click-preview slot (no opener fallback):

// HyperlinkOptions — default null, no prebuilt fallback
popovers: {
  // existing slots unchanged
  hovercard?: ((options: HovercardOptions) => HTMLElement | null) | null
}

null / omitted means no hover UI. A factory that returns null opts out. Do not nest this under popovers.previewHyperlink.

A new optional null slot is a minor. A prebuilt hovercard fallback, or default-on hover, is a breaking product change.

Rules if a hook lands later:

  • Host factory owns delay, chrome, fetch, and the hover-bridge.
  • Package plugin may gate (pointer: fine) the same way click owns pointer events. Host isMobile still wins in docs.plus.
  • Distinct popover kind from preview. The engine is one-shot: after hide(), rebuild.
  • Do not write mark attrs on hover.
  • Do not mount an aria-live region inside .ProseMirror.

docs.plus host

This is the headed consumer. Reuse the existing metadata pipeline. No new REST route.

  1. L1 — mark attrs title / image (read only on hover)
  2. L2 — 5-minute session cache in fetchMetadata
  3. L3 — GET /api/metadata?url=

Do not force the house envelope onto this route. That is settled.

Internal means same document: exact slug and same origin. Cross-doc docs.plus URLs stay external and may hit metadata. That is intended. Chip copy stays on #174.

First slice: pad desktop only.

  • Composer desktop: skip.
  • Pad mobile and composer mobile: unchanged.

Failed fetch degrades to href as title. safeImageSrc allows http(s) only.

Mobile

No hover. Keep tap → pad linkPreview sheet and composer preview dialog.

Do not add long-press. Tap already opens the sheet.

Composer must not call pad dismissSoftKeyboard. That rule stays.

If we later want "preview before open" on mobile, put title and description inside the existing sheet.

Keyboard

Click preview stays the accessible path for v1. Hover-only facts are not enough. Tab / :focus-visible plus the existing click preview must work without hover.

A GitHub-style shortcut (focus the link, then Option+↑) can wait.

What this is not

  • A prebuilt hovercard in the npm package
  • Hovercard rules in package styles.css
  • A zero-network chip drawn by the extension
  • Calling openPreviewHyperlink on hover
  • Writing Yjs mark attrs from hover (flush)
  • Hover on the iPad / mobile shell
  • Treating a narrow desktop window as mobile
  • Slack or Discord message unfurl as an editor block
  • Client scrape of arbitrary pages from the npm package
  • Replacing click preview with hover
  • Forcing the house envelope onto /api/metadata
  • Renaming the hyperlink mark
  • A second HyperlinkPopoverPortal in the composer
  • Adding card as a fifth house vocabulary word

Why this shape

  • GitHub: hovercard for context; click navigates. Keyboard: Option+↑.
  • Google Docs: hover details plus a click chip. Users often disable the hover.
  • Notion: rich hover on mentions; mobile has no hover.
  • TipTap: hosts bring UI. @tiptap/extension-link ships no hovercard.
  • This package: click preview is opt-in. Create / edit commands still use prebuilt UI when the slot is empty. Hover follows the click-preview rule.
  • Chat unfurl is the wrong editor pattern.

Suggested slices (not filed as tickets)

  1. Pad desktop hovercard in the webapp. No package change. Proves delay, click-wins, hover-bridge, abort, and display-only.
  2. Optional popovers.hovercard slot, default null, no prebuilt fallback. Only if another host needs the same pointer plugin.
  3. Composer desktop later, only if pad hover is wanted.

Acceptance criteria

  • Product copy uses hovercard for hover and preview for click / tap
  • Pad desktop shows a delayed hovercard on external links via L1 → L2 → L3
  • Same-document links skip OG; cross-doc docs.plus URLs may fetch
  • Click preview, create, and edit evict the hovercard
  • Hover leave closes only the hover instance
  • Hover uses a distinct controller kind; it does not call openPreviewHyperlink
  • Hover is pad-only; desktop composer does not show it
  • Hover requires !isMobile and (pointer: fine)
  • Pointer can enter the card (hover-bridge)
  • Hover does not write mark attrs
  • Fetch uses debounce + AbortSignal; leave / click-wins abort
  • Slice 1 adds no hovercard DOM, CSS, or prebuilt factory to the package
  • Any later package slot defaults to null and has no prebuilt fallback
  • Mobile tap sheet is unchanged; no long-press path
  • No live region inside .ProseMirror
  • Composer mobile still does not call pad dismissSoftKeyboard

Alternatives considered

  • Hover opens today's preview toolbar. Rejected. Preview is an action toolbar.
  • Rich card, or a hostname chip, inside the npm package. Rejected. Chrome for this feature belongs to the host.
  • Prebuilt hovercard fallback when the slot is empty. Rejected. Copy the click-preview null rule, not the create / edit opener fallback.
  • Defer L1 write on hover (same as click). Rejected for hover. Defer only stops write-while-open. It still stamps Yjs after the first rest. Hover is display-only.
  • Host-only forever, no package hook. Correct for slice 1.
  • Inline unfurl block (Slack / Discord). Rejected.

Adviser pass (2026-09-06)

Checked against the package, floating-popover, webapp popovers, metadata module, and mobile UA gate. Kept: L1–L3 reuse, no house envelope, no package fetch, click-preview null rule, host-only slice 1. Fixed: create / edit are not opt-in; "card" is not house vocabulary; hover must not call openPreviewHyperlink; dual desktop gate; hover-bridge; display-only write rule; abort / herd; same-document internal.

Blocked by

None — can start after this RFC is accepted.

Activity

  1. added
    enhancement
    Editor
    on Sep 6, 2026
  2. HMarzban commented on Sep 6, 2026

    @HMarzban
    CollaboratorAuthor

    Correction from review: the published extensions are headless.

    The first draft treated a zero-network hostname chip as something the package could ship. That was wrong. Schema, commands, URL decisions, and pointer plugins stay in @docs.plus/extension-hyperlink. Product chrome does not.

    Hover now follows the click-preview slot rule: null means no UI, and there is no prebuilt fallback. Slice 1 is docs.plus host-only. The issue body is updated.

  3. HMarzban commented on Sep 6, 2026

    @HMarzban
    CollaboratorAuthor

    Adviser pass (extension contract, host slice 1, interaction / mobile, metadata / safety). Claims were checked against the tree, then this body was updated.

    Kept. Click preview is null unless the host wires a factory. The package has no fetch client. Slice 1 can stay host-only. L1–L3 and the house-envelope skip are real.

    Fixed in the body.

    • Create / edit commands are not opt-in. Their openers fall back to prebuilt UI when the slot is null. Hover must copy the click rule, not that fallback.
    • The package ships prebuilt chrome today. “Headless” here means: do not add hover chrome, not “the tarball has no UI.”
    • Hovercard is a product name. It is not a new §Vocabulary word.
    • Do not call openPreviewHyperlink on hover. That opener is kind 'preview' and can fall back to the prebuilt toolbar.
    • Desktop is !isMobile and (pointer: fine). iPad is the mobile shell.
    • Require a hover-bridge. Require pad-only attach so composer does not leak.
    • Hover is display-only. Do not flush() Yjs from hover. Click preview stays the write path.
    • Abort on leave. Do not herd L3. Internal skip is same-document only.
  4. added this to the v2.3.0 milestone on Oct 26, 2026
  5. HMarzban commented on Oct 26, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-10-26

    The maintainer accepted this RFC and moved it to milestone v2.3.0. The answers below came through a multiple-choice prompt in the agent session. Each one is the option the maintainer picked.

    Hovercard

    • Which links. Only external http(s) links get a hovercard. Same-document links, mailto:, tel: and app schemes get none. Cross-document docs.plus links do get one.
    • What the card shows. The page's social image (og:image) when it has one, then the site icon and host, the title and the description. Mock: variant A plus the social image. The image loads through our own server, like link icons, so the linked site never sees the reader. It is hidden when it fails.
    • Timing. The card opens after the pointer rests 400 ms on a link. It closes 300 ms after the pointer leaves both the link and the card. Google Docs, Word and Notion publish no numbers for this, so this is a recorded choice, not a parity rule.

    One cache for hover and click

    • This replaces the L1 step. Rule 6 and the "L1 → L2 → L3" lines are superseded. The hovercard never reads stored mark title or image, as the Stop link preview metadata writes from reaching every peer #519 ruling (2026-10-18) already says for every preview.
    • The hovercard, the desktop click preview, the mobile link sheet and the media unfurl cards read one client cache (fetchMetadata.ts), keyed by URL. Callers of one URL share one request.
    • New wording for rule 7 and the matching acceptance line: "Cancel the dwell timer and drop the UI result on leave or click. A request already sent finishes into the shared cache." Aborting a sent request saves no rate-limit point, and it forces a second request for the click that follows.
    • The composer link dialog stays link-only in this slice. It reads no metadata today.

    Server metadata fetch (added to this issue's scope)

    • Honest identity. The server stops sending facebookexternalhit/1.1 in its User-Agent. Every outbound metadata request names docs.plus only. Sites that let in only Meta's crawler will show the plain link card. This overturns the old line in apps/hocuspocus.server/CLAUDE.md.
    • Own rate-limit bucket for GET /api/metadata, 10 times the base limit, like the link-icon route. Hover traffic can then never 429 the pad's own REST calls.
    • Spotify and SoundCloud move from oEmbed to the page scrape, so their cards get a description. YouTube stays on oEmbed.
    • Agent defaults, not asked: the description is capped at 300 characters. The GitHub repo card keeps the owner avatar.

    The measured baseline and the full design are kept in the maintainer's local notes. Measured with an honest User-Agent on 30 public URLs: 23 useful cards, 16 with title, description and a real image, p50 669 ms, p95 1416 ms. The 5 hard failures are bot walls (403 or a JavaScript challenge). No honest change fixes those.

  6. HMarzban commented on Oct 27, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling update, 2026-10-26

    The maintainer ran an architecture review of the hyperlink feature (the extension, its webapp host and the link-metadata API), then a grilling round. The answer was "all recommended" to every question. Each line below is the accepted recommendation.

    Privacy and the proxy rule

    • Q1. A preview's site icon (click preview, phone sheet, hovercard) loads only from our icon route, as pad link icons do. The fallback to the site's own logo URL is removed. On a miss, the preview and the hovercard show no icon, and the phone sheet keeps its grey box. This reverses one line of Load profile and preview favicons from our route, not from Google #517; the ruling is posted there.
    • Q2. The metadata log drops the linked page's path and keeps its host.
    • Q3. Chat comment and media-insert thumbnails (Vimeo, SoundCloud, Spotify, Loom) load through GET /api/metadata/image. YouTube thumbnails and older saved previews stay direct.
    • /privacy is rewritten to say exactly what the code does, including what still loads straight from other sites: embedded players, pasted media links and GIPHY.
    • The rule behind these: proxy a URL only when a passive render would show readers to a host the link author chose. Redis caches only the metadata JSON. Icon and image bytes have no server cache; the browser cache holds them.

    Link forms and editing

    • Q4–Q6. A link form value must be one whole link. "hello google.com" is refused. Trailing punctuation still works ("google.com."). A URL with a raw space is refused. Typing "Re:google.com" links only "google.com".
    • Q7. An edit that leaves the Text field untouched sends no text, so a co-editor's text change survives.
    • Q8. The package's prebuilt edit popover has the same race. It is filed as Keep a co-editor's link text when the prebuilt edit popover changes only the URL #643 and is not part of this push.

    Name

    • Q10. The product name stays "hovercard", as this RFC ruled. /privacy and CONTEXT.md use it.

    Server

    • Every scraped string is capped before Redis and the reply. The #fragment leaves the server cache key. The cache key prefix moves to meta:v2 in the same deploy. The icon and image routes share one image fetch, and the image route sends Vary: Accept-Language.
    • The own link-metadata rate-limit bucket (x10) stays, and it ships only together with the caps.

    Rust

    • Q11. A Rust microservice for link metadata is closed. Measured: our CPU work is 0.69% of a preview request; the rest is waiting on the remote site. Isolation would come from a separate process, not from a language. The reopen triggers are in the root CLAUDE.md Settled list.
    • Replacing metascraper with Bun's built-in HTMLRewriter is filed as Replace metascraper with an HTMLRewriter head extractor #644.

    Filed for later (v2.4.0)

  7. HMarzban commented on Nov 1, 2026

    @HMarzban
    CollaboratorAuthor

    Build update, 2026-11-01

    The hovercard is built and reviewed on local main. It is not pushed or deployed yet, so this issue stays open until the deploy.

    The extension (@docs.plus/extension-hyperlink, release 2.3.0 owed)

    • The new hovercard option shows a read-only card when a mouse pointer rests on a link. The host's fetchMetadata returns the title, description and picture. siteIcon, shouldShow and imageLayout ('cover' or 'adaptive') are optional.
    • The request starts after a 150 ms rest. The card opens at 500 ms at the earliest. It closes 300 ms after the pointer leaves the link and the card.
    • Modifier keys, the arrows, Home, End, PageUp, PageDown, F1 to F12 and Mod-C keep it open. Every other key, and any press, closes it.
    • hovercard.css styles the card through --hl-* tokens.
    • Every link the package opens goes through one navigate(href, { newTab }) option. newTab is true only for Mod or the middle button. So a plain open of another pad can route in place (RFC: should a link to another docs.plus pad open in the same window? #359).
    • Link keys: the I-beam stays at rest, and the hand shows only while Mod is held. Mod-K on a link opens its preview. Alt+Enter opens the link. Mod-click opens a new tab. The preview is now role="dialog", named "Link preview".

    The pad

    • The desktop pad passes padHovercard with imageLayout: 'cover'. All card data comes through our server. The phone, chat, history and /editor get no card, and neither does a link to a part of this pad.
    • Settings → Appearance has a "Show link previews on hover" switch. It is on by default and applies only while you are signed in.
    • A plain link underlines on hover, in place of the old opacity fade.

    The server

    • The html stage parses page heads with our own HTMLRewriter scraper, not metascraper. The worst crafted page now takes 39.5 ms at 1 MiB on one laptop.
    • The read stops at </head, and the scraper reads no body rule. So one page always gives the same card, which matters because the card is cached for 24 h.
    • The page picture goes through GET /api/metadata/image.

    Still owed

    • Push and deploy, then the production benchmark.
    • The extension 2.3.0 release.
    • Device and WebKit checks.
  8. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Refactor round, 2026-11-03. Ten commits on local main (ceb853258..be63d2138), not pushed yet. Behaviour stays the same, except for three small changes that make two rules agree:

    • On a Mac, Ctrl-click on a link to another pad now routes in place. Only Cmd-click opens a new tab, as the hint and the extension already said.
    • A preview opened from the keyboard skips a hidden or inert control for its first focus, as Tab already does.
    • The chat link dialog checks the link's stored href before an edit or a remove, as the pad's phone sheets do.

    Also in the round:

    • The metadata cache now stores only the proxied link card, so no caller can reach the scraped image URL.
    • hasMod is a new root export of the extension.
    • The server image relay and the route paths have their own files.
    • The dead metascraper side of the benchmark is gone.

    The remaining structure items are tracked in #678.

  9. 33 remaining items

  10. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-04. The earlier "not pushed yet" note is out of date. The work is on main in 4e1aca058, and deploy run 41854096960 shipped it.

    Left:

  11. HMarzban commented on Nov 6, 2026

    @HMarzban
    CollaboratorAuthor

    Closed by maintainer ruling, 2026-11-06. The desktop hovercard RFC is built and deployed. The follow-up issues keep their own close gates: #680, #681, #682, #683, #689, #692, #693 and #694 (production checks and the extension 2.3.0 publish), and #174. They stay open on their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesktopEditorExtensionFeatureMobileUIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions