Skip to content

Wiki links and a backlinks panel #201

Closed

Description

@imshashank

In Orbit's docs, referring to another document means finding it, copying its URL, and pasting a link. Nothing tells you afterwards that the link exists. Open a document and there is no way to know what else in the workspace points at it.

Backlinks are what make a wiki different from a folder of files. Without them, a document that nobody bookmarked is a document nobody will find again.

What to build

Link autocomplete in the editor. Typing a trigger, [[ or @, opens a picker of documents in the workspace, filtered as you type, and inserts a real reference rather than a URL string. The reference stores the doc id, so renaming the target does not break the link and the link text can follow the target's title.

A backlinks panel. At the bottom of a doc, or in the side panel next to the outline: every document that references this one, with the surrounding sentence for context. This is the half that delivers the value. Autocomplete on its own is a convenience; backlinks change how people find things.

Broken link handling. When a linked doc is archived or deleted, the link should render as clearly broken rather than as a dead click. When it is restored, the link works again.

Implementation notes

Store links as rows, not by parsing on read. A doc_link table joining source doc to target doc, written when a document is saved. Parsing every document's body to answer "what links here" does not scale and cannot be indexed. The table wants a unique index on source and target and an index on target for the backlinks query.

Access control on the backlinks panel. This is the part that is easy to get wrong and it is a real leak if you do. doc_access in packages/db/src/schema/content.ts grants per subject, and doc.visibility narrows further. Somebody looking at a public document must only see backlinks from documents they may read. Otherwise the panel leaks the existence and titles of private documents to anyone with the share link. Filter the backlink query by the reader's access, not by the target document's.

Published docs. publish_token makes a doc publicly readable at /d/[token]. Backlinks on a published page must show only other published documents, if any at all. Decide and say which.

The editor. TipTap 3, extensions live in apps/web/src/features/docs/editor/extensions.ts. A mention style node with a suggestion plugin is the standard shape. There is already an anchor plugin in that directory, so there is a precedent for a custom node.

Markdown round trip. Docs import and export markdown, via doc-import.tsx, doc-export-menu.tsx and markdown.ts. Decide how a wiki link serialises on export and how it parses on import. A link that survives an export and re-import is worth more than a clever syntax that does not.

Related

Mentioning an issue or a person inline is a sibling issue in this milestone and shares the suggestion plugin infrastructure. If both are picked up, coordinate on this thread.

Files

  • apps/web/src/features/docs/editor/extensions.ts
  • apps/web/src/features/docs/editor/rich-text-editor.tsx
  • packages/db/src/schema/content.ts
  • packages/core/src/content/
  • apps/web/src/features/docs/doc-outline.tsx for where a panel could live

Activity

  1. added this to the Docs as a real wiki milestone on Aug 8, 2026
  2. added
    enhancement
    help wanted
    p1 high
    area: docs-feature
    on Aug 8, 2026
  3. moved this to Backlog in Orbit roadmapon Aug 8, 2026
  4. added
    size: large
    points: 8
    schema change
    on Aug 8, 2026
  5. imshashank commented on Aug 8, 2026

    @imshashank
    ContributorAuthor

    Shares infrastructure with #204, so coordinate before starting.

    Both issues need a TipTap suggestion plugin on the same editor: this one for documents, #204 for issues, docs and people. Build it once and generically. Whoever starts first should say so on both threads.

    Both also share the same permission trap, which is the part worth the most care: a backlinks panel and an inline chip can each leak the existence and title of something the reader may not see. The rule is the same in both, filter by the reader access rather than by the target visibility.

  6. imshashank commented on Aug 15, 2026

    @imshashank
    ContributorAuthor

    Half of this shipped. Re-scoping to the half that did not.

    Done: the backlinks panel. packages/core/src/content/doc-service.ts has listDocBacklinks, capped at DOC_BACKLINK_LIMIT = 50, and it is attached to every doc through detailFor, so DocDetail.backlinks is part of the payload. It is rendered in doc-reader.tsx and doc-surface.tsx, and it is covered by tests in packages/core/tests/content/doc-service.test.ts and apps/web/tests/features/docs/. It respects docReadFilter, so a backlink from a document you cannot read does not appear, which is the part that would have been easy to get wrong.

    Not done: wiki links. There is no [[...]] syntax. Nothing in apps/web/src/features/docs/editor/markdown.ts or commands.ts parses one, and grepping the repository for a wikilink node returns nothing.

    Worth knowing before picking this up. The backlinks panel is built on a URL match, not on links:

    ilike(schema.doc.content, `%/docs/${doc.id}%`)

    That has two consequences for the remaining work:

    1. It only finds documents that contain a full /docs/<id> URL. A [[Title]] wiki link would not be found by it, so adding wiki link syntax means extending or replacing this query, not just adding a parser.
    2. It is a substring scan over doc.content per document view, unindexed. It is fine at current scale and it will not stay fine. If wiki links land, this is the moment to store links in a real table instead, which also makes "what does this link to" answerable rather than only "what links here".

    Revised scope. Wiki link syntax, resolution by title with an id fallback, an autocomplete on [[, and a link store that both the wiki links and the existing backlinks panel read from. The panel UI itself is done and should be kept.

    Related: #204, which wants inline mentions of docs and issues with a live render. That and this issue should probably share the link store rather than each building their own resolution path.

  7. imshashank commented on Sep 6, 2026

    @imshashank
    ContributorAuthor

    Backlinks shipped. The remaining half (a [[ link, resolution by title, and a real link store) now lives in #204 so there is one link-store issue instead of two. Closing this one.

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

    area: docs-featureenhancementhelp wantedp1 highpoints: 8schema changesize: large

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions