Skip to content

feat(markdown): show backlinks under Markdown notes - #29861

Open
nebourocket wants to merge 1 commit into
stablyai:mainfrom
nebourocket:feat/markdown-backlinks
Open

nebourocket wants to merge 1 commit into
stablyai:mainfrom
nebourocket:feat/markdown-backlinks

Conversation

@nebourocket

Copy link
Copy Markdown

ELI5

In Obsidian you can see which notes link to the note you're reading. Orca already follows [[links]] forward but couldn't show them backwards. Now there is a small Backlinks bar at the bottom of every Markdown note. Open it to see each note that links here, with the linking line. Click an entry to jump to that note.

What Changed

Before: Orca resolved [[note]], [[note|alias]] and [[note#Heading]] forward (#3363), but there was no way to see which notes point to the current one.

After: a collapsible Backlinks bar appears under the rich editor, the inline preview, and Markdown preview tabs. It starts collapsed. When opened, it shows:

  • the number of linking notes
  • one row per linking line: path, line number and the line itself
  • a refresh button
  • a warning if the search hit its result limit

Clicking a row opens that note through the same openMarkdownDocument used by doc links.

Mechanism:

  1. Search. It runs one workspace text search through the existing searchRuntimeFiles (so it works locally, over SSH and on paired runtimes). The search looks for the note's name, plain or URL-encoded, case-insensitively, over *.md, *.mdx, *.markdown, with a cap of 2,000 results. Every link to a note has to contain its name, so this finds all candidate lines without reading every file in the renderer.
  2. Confirm. Each candidate line is kept only if it really links here. [[wiki]] links go through the existing parseMarkdownDocLink / resolveMarkdownDocLink and the document index. [text](path) links, including the <…> form, titles and URL-encoding, are resolved relative to the linking note. As a result:
    • plain mentions of the name are excluded
    • links to a same-named note in another folder are excluded
    • ambiguous bare [[name]] links are excluded
    • external URLs and self-links are excluded

New files:

  • markdown-backlinks.ts: pure logic, unit-tested.
  • use-markdown-backlinks.ts: builds the search context like useMarkdownDocuments.
  • MarkdownBacklinksPanel.tsx: the bar. WithMarkdownBacklinks wraps both Markdown surfaces so their layouts stay the same.

Why

This is the piece of #3040 ("Obsidian-style markdown reader with back links") that is still missing after #3363 added aliases and heading links. Backlinks are the main reason people keep a note vault open next to the editor.

Choices:

  • Collapsed by default, computed on open. A closed bar mounts no hook and reads no store state, so ordinary editing pays nothing.
  • Search, then resolve, instead of a persistent link index. There is no new main-process service or cache to invalidate. Results always match the resolver that the links themselves use. The search is bounded by the existing search limits.
  • Bottom bar instead of another header toggle and side panel. This matches Obsidian's "linked mentions" placement. The change stays inside the two Markdown surfaces instead of threading new state through EditorPanel.

Known limits:

  • A root-relative href such as /docs/x.md is resolved against the worktree root.
  • Links whose text doesn't contain the note name at all (for example, a full path written only with percent-encoding of every character) are not found.
  • Results are not live-updated while the bar is open; use refresh.

Linked Issue

Fixes #3040. I commented there first, since it is assigned.

Visual Proof

Before: there was no Backlinks bar.

After, with rocket-engine.md open in preview, two notes link to it: one with [[rocket-engine|the engine]] and one with [Engine](./rocket-engine.md). A plain mention and an unrelated note are not listed.

backlinks
panel

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Unit tests in markdown-backlinks.test.ts cover:

  • wiki links and relative links, with aliases and headings
  • a same-named note in another folder
  • external URLs and self-links
  • ambiguous bare names
  • encoded, <…>, titled, table-escaped (\|) and differently cased links
  • the search query, including the URL-encoded alternative

New e2e test, tests/e2e/markdown-backlinks.spec.ts:

  1. Open a note in preview and open the bar.
  2. Check that it shows (2) with the right entries and without the false positives.
  3. Click an entry and check that the linking note opens.

Other checks:

  • All editor Vitest suites: 2,649 tests pass.
  • pnpm tc
  • pnpm run check:code-quality:changed
  • oxlint
  • localization extraction and catalogs
  • check:max-lines-ratchet

Tested on Linux (WSL2). Not tested on macOS, Windows or a real SSH host. The search goes through the same client the sidebar search uses on those routes.

AI Disclosure

Written with Claude Code (Claude Opus 5.5). I reviewed the code and verified it with the tests above.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Performance: nothing runs until the bar is opened. After that it is one bounded search per open, refresh or file change. Watcher refreshes of the document list do not restart the search.
  • Security: read-only, using existing search and open paths.
  • Cross-platform: path separators are normalised on both sides of the comparison.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred). Typecheck, the changed-code gate, oxlint, localization checks, the editor suites and the electron-vite build pass locally. CI will cover the full suites.

Add an Obsidian-style Backlinks bar under the rich editor, the inline
preview and Markdown preview tabs. Opening it runs one workspace text
search for the note's name (plain or URL-encoded) and keeps only lines
whose [[wiki link]] or [text](relative.md) link resolves to this note,
using the existing doc-link resolver. Each entry opens the linking note.
Copilot AI balanced review requested due to automatic review settings October 16, 2026 22:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6c0e8634-60f6-4cd0-a174-85364d05cdc5
📥 Commits

Reviewing files that changed from the base of the PR and between f9acfff and 5bbc453.

📒 Files selected for processing: 8
  • src/renderer/src/components/editor/EditorContent.tsx
  • src/renderer/src/components/editor/EditorMarkdownFileSurface.tsx
  • src/renderer/src/components/editor/MarkdownBacklinksPanel.tsx
  • src/renderer/src/components/editor/markdown-backlinks.test.ts
  • src/renderer/src/components/editor/markdown-backlinks.ts
  • src/renderer/src/components/editor/use-markdown-backlinks.ts
  • src/renderer/src/i18n/locales/en.json
  • tests/e2e/markdown-backlinks.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Adds Markdown backlink search for wiki links and relative Markdown links. The new panel displays matching source notes and supports opening them. The panel is integrated into rich-editor and preview surfaces. Unit and end-to-end tests cover matching, exclusions, search options, listing results, and opening a source note.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 5bbc4

The backlinks change is mergeable after normal checks; no actionable issue was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: displaying backlinks under Markdown notes.
Description check Passed The description is complete and aligned with the template. It explains the user-facing change, implementation, rationale, linked issue, visual proof, testing, limitations, and compatibility considerat…
Linked Issues check Passed Issue #3040 requests an Obsidian-style Markdown reader with back links and provides no narrower coding acceptance criteria. The PR adds a collapsed Backlinks panel to the rich editor, inline preview, …
Out of Scope Changes check Passed The changed files implement the backlink search, link confirmation, hook lifecycle, panel UI, localization, surface integration, unit tests, and end-to-end coverage. These changes directly support iss…
Full details: Description check

Explanation

The description is complete and aligned with the template. It explains the user-facing change, implementation, rationale, linked issue, visual proof, testing, limitations, and compatibility considerations.

Full details: Linked Issues check

Explanation

Issue #3040 requests an Obsidian-style Markdown reader with back links and provides no narrower coding acceptance criteria. The PR adds a collapsed Backlinks panel to the rich editor, inline preview, and Markdown preview. It searches Markdown files, resolves wiki and inline links, excludes invalid or self-links, shows source paths, line numbers, and line text, and opens the source document on selection. Unit tests and an end-to-end test cover the backlink behavior.

Full details: Out of Scope Changes check

Explanation

The changed files implement the backlink search, link confirmation, hook lifecycle, panel UI, localization, surface integration, unit tests, and end-to-end coverage. These changes directly support issue #3040. No unrelated change is demonstrated by the reviewed summary or inspected files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Obsidian-style markdown reader with back links

2 participants