Skip to content

[Tracking] Link UI structure follow-ups after the #242 review #678

Open

Description

@HMarzban

Summary

A strict code-quality review of the #242 / #174 link UI work found 22 structural items. On 2026-11-03 the maintainer chose the risk-reducing and no-risk ones, and they are committed on local main (ceb853258..be63d2138, not pushed yet). The items below are the rest. They keep behaviour the same and make later changes easier. None of them is a bug a reader sees.

Each item is optional. File a separate issue for an item before you build it. File and line references were read from code on 2026-11-03, not measured.

  • Area: @docs.plus/extension-hyperlink, the webapp link popovers, the link-metadata server
  • Source: the RFC: Desktop hyperlink hovercard #242 review, 2026-10-30, and the refactor round of 2026-11-03

Due before extension 2.3.0 publishes

  • Public names. Renaming an export after the first publish is a breaking change, so do these first.
    • wholeLink reads like a check, but it returns the link to store. Rename it, for example to toStoredLink. Two webapp files call it.
    • HyperlinkOptions.linkIcon and HovercardOptions.siteIcon are typed LinkIconResolver, but the root exports only LinkIconContext. Export LinkIconResolver too.
    • Name the hovercard callback contexts HovercardContext ({ href }) and HovercardShowContext ({ href; link }) in hovercard/types.ts. Only the name is new; the shape stays.

Candidates

Extension (extensions/extension-hyperlink)

  • One link-target module. "Which link did this event hit" and "open with Mod or the middle button" are each written three times: interactions/clickHandler.ts, hovercard/hovercardPlugin.ts, the openers and hovercard/content.ts. Move them into one linkTarget.ts with one bindOpenGestures helper.
  • Click handler modes. openPreviewPopoverFromClick is now a three-mode function with 3 call sites in clickHandler.ts, and the click handler repeats its point maths. Split the modes, or let the caller pass the point.
  • Mod cursor state. interactions/modCursor.ts keeps its handlers at module level and finds its document again through a cast chain. Bind the handlers per document instead.
  • Keyboard-open preview. focusPreviewFromKeyboard finds the preview it just opened again, through getState() and the 'preview' kind string. Add an internal mountPreview(opts): Popover | null, so callers pass the mounted element.
  • Link context lookup. Finding the link context takes two lookups and one cast, and returns a silent null where the caller already has the context. Pass the context down.
  • Icon resolver copy. The hovercard repeats resolve from linkIconMarkView nearly word for word. Share one helper.
  • Hovercard timing state. Pending is a bag of optional stamps (dataAt, pictureAt). Work out the open deadline when each event arrives instead: max(enteredAt + 500, now + 300) on data with a picture, and max(enteredAt + 500, now) otherwise. That matches the ruled timing in every order, and hovercard.cy.ts pins it.

Webapp (apps/webapp/src/components/TipTap/hyperlinkPopovers)

  • Two new-tab shapes. An open with a new-tab intent has two shapes: navigateHref(href, isAllowedUri, event) and padNavigate(href, { newTab }). Both now use the extension's hasMod, so they agree on keys. See Decision 2.
  • Filter link branches. Filter links branch in four places, and the descriptor uses optional fields to cover that. Use a FILTER_MODE_LABEL map and drop hideFilterSublabel.
  • Edit-form seed. The desktop and mobile popover entries copy the edit-form seed, and the two copies grew in lockstep. Share one seed.
  • Mod-cursor CSS copy. The webapp keeps a lockstep copy of the extension's Mod-held hand rule in document-styles.scss, because it does not import the extension's styles.css. Keep it, or ship the rule as its own small stylesheet.

Link-metadata server (apps/hocuspocus.server/src/modules/link-metadata)

  • Scraper threading. pipeline.ts threads scraper through four layers for one stage (name === 'html'), and capCard lives in the orchestrator. Bind the scraper in module.ts, keep one success builder, and move capCard to domain/card.ts.
  • Two owners for URL cleaning. utm_ parameters are stripped in two places, infra/headScraper.ts and canonicalize.ts. Keep one owner.
  • Deadline copies. The deadline pattern is written five times, and some readers take an AbortController only to abort it. Share one deadline helper.

Decisions

  1. Ship the public names separately, on milestone v2.3.0? They are due before extension 2.3.0, and everything else here waits for v2.4.0.
    • ➡️ Yes. Move that item to its own issue on v2.3.0. It is cheap now and breaking after the publish.
  2. One new-tab shape? Route the preview title link and the chat message body (HTMLBody.tsx) through padNavigate(href, { newTab: hasMod(event) }), and delete the event parameter of navigateHref.
    • ➡️ Yes. Mod-click on a link to this pad, in a chat message, then opens a new tab. It runs in place today. That matches Mod-click in the pad editor.
  3. One targeting rule for desktop Edit and Remove? Desktop Remove acts on the editor selection, because y-prosemirror moves the selection through a co-editor's change. Desktop Edit acts on the nodePos stored at open time, with an expectedHref guard. If a co-editor types above the link while the form is open, Edit then does nothing.
    • ➡️ First check whether the selection always sits on the link when the desktop form opens. If it does, make desktop Edit act on the selection too. If it does not, keep both rules and say why in apps/webapp/src/components/TipTap/CLAUDE.md.
  4. Close the "scraper rules written twice" item? The selector list is now 5 entries, after the </head cut, so little copying is left.
    • ➡️ Yes. It is no longer listed above.

Related

Activity

  1. added this to the v2.4.0 milestone on Nov 3, 2026
  2. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Status after the 2026-11-04 work, on local main, not pushed yet:

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

    EditorExtensionRefactor

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions