Repository navigation
feat(markdown): show backlinks under Markdown notes - #29861
nebourocket wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
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:
Clicking a row opens that note through the same
openMarkdownDocumentused by doc links.Mechanism:
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.[[wiki]]links go through the existingparseMarkdownDocLink/resolveMarkdownDocLinkand the document index.[text](path)links, including the<…>form, titles and URL-encoding, are resolved relative to the linking note. As a result:[[name]]links are excludedNew files:
markdown-backlinks.ts: pure logic, unit-tested.use-markdown-backlinks.ts: builds the search context likeuseMarkdownDocuments.MarkdownBacklinksPanel.tsx: the bar.WithMarkdownBacklinkswraps 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:
EditorPanel.Known limits:
/docs/x.mdis resolved against the worktree root.Linked Issue
Fixes #3040. I commented there first, since it is assigned.
Visual Proof
Before: there was no Backlinks bar.
After, with
rocket-engine.mdopen 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.Testing
Unit tests in
markdown-backlinks.test.tscover:<…>, titled, table-escaped (\|) and differently cased linksNew e2e test,
tests/e2e/markdown-backlinks.spec.ts:(2)with the right entries and without the false positives.Other checks:
pnpm tcpnpm run check:code-quality:changedcheck:max-lines-ratchetTested 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
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (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.