Repository navigation
feat(md-notebook): resolve relative obsidian embeds inside the vault - #31673
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Relative embeds go through the existing Notes
[DESIGN-REVIEWED] 466ee64 Description read[DESCRIPTION-READ] 467f8d900eb97d7402cbcc6dec21a92cb915cd41194a52a137a494e606a3b75a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item renders an image the vault already holds and that Obsidian's relative-link setting writes. The rewritten backslash pin is declared, and it still checks that a backslash What this change shipsInventory (7 items) — 7 justifiedIntent: show Obsidian embeds written in relative link format (
[FIRST-PRINCIPLES-REVIEWED] 466ee64 Description read[DESCRIPTION-READ] ca4a974a5d63bdaaf2d7ea78fc65e6f33395d7c967e05c7776d88cf99cc6ebee That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The PR adds no new control or string; it only renders Notes
[UX-REVIEWED] 466ee64 Description read[DESCRIPTION-READ] 1e084e5743d782c008c8aa8efce8d587602993f236a5cd70b579179cd7b13fdb That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
695c7ca to
f4119d1
Compare
|
Rebased: main moved in docs/system-specs/modules/ (artifacts.md, dashboard-token-auth.md, learn-cron-dashboard.md, memory-skills-hooks.md, slack-gateway.md, workflows.md) since this head went green (f9e8bdf -> ea5dedb); CI re-running. The new base carries #31625, which fixes the [operator: bolichen97] |
An Obsidian vault set to the "relative path to file" link format writes its embeds as ![[../assets/a.png]] or ![[./a.png]]. The Notes app refused any embed with a dot segment, so those images showed as missing even though the file sits in the vault. A target that starts with ./ or ../ is now read from the note's folder alone, and still asks for nothing once it climbs above the vault root. Every other target keeps its two tries (vault root, then the note's folder) and its refusal of absolute paths and dot segments. Part of #10197
f4119d1 to
466ee64
Compare
|
Rebased: main moved in docs/system-specs/modules/ (29 specs beside md-notebook.md) and website/src/test/ since this head went green (ea5dedb -> 42f45e3); CI re-running. The new base carries #31803, which fixes the [operator: bolichen97] |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 466ee64, no conflict, no open change request.
Problem / Motivation
Goal: A note shows an Obsidian image embed written in Obsidian's relative link format (
![[../assets/a.png]],![[./a.png]]) as the picture it names, as long as that file is inside the vault.Obsidian can be set to write links as a "relative path to file". Its embeds then look like
![[../assets/diagram.png]]or![[./diagram.png]], read from the note's own folder. Since #31101 the Notes app renders![[file.png]]embeds, but it refuses any target with a.or..segment, so every embed in such a vault shows the missing-image glyph even though the file is right there.Why it matters
A vault kept in Obsidian with relative links writes every pasted screenshot this way. Attached to Kiro Crew, all of those images are missing at once, and the only workaround is rewriting every embed by hand, which breaks the vault for Obsidian.
Not a goal
attachmentFolderPathfrom.obsidian/app.jsonand the vault-wide lookup by a unique file name. Both need the backend to read vault configuration or list vault files, so they stay open on Notes app: resolve Obsidian image embeds and attachment paths in mixed-syntax vaults #10197...in the middle of a path that does not start with./or../(sub/../a.png): Obsidian never writes that, so it keeps asking for nothing../or../.What changed (motivation → approach → change)
An embed whose target starts with
./or../now renders the file it names, read from the note's folder, and asks for nothing once it would climb above the vault root../a.png,../assets/a.png(also with\)a.png,assets/a.png./..segment anywhere elseThe approach adds no resolver and no new request.
noteRelativeSegmentsinutils.tswalks the target's segments from the note's folder, as segments under the vault root, and returns null the moment a..would leave the root.NoteEmbedinNoteImage.tsxhands that result to the existingvaultRootImageSrc, so the same checks still apply to the one path it asks for (no dot segment left, no NUL, no hidden separator), and the guarded/api/file-rawstays the only way image bytes are read.The Notes spec,
docs/system-specs/modules/md-notebook.md, states the relative format in its Images paragraph.Backwards compatibility
Compatible: the only embeds that render differently start with
./or../and stay inside the vault; they asked for nothing before. Every other target makes the same requests as on main.Removes nothing: the diff adds one helper and one branch in
NoteEmbed; no path, key, route or function goes away.Tests
website/src/test/mdNotebookImages.test.tsx, inmd-notebook/Preview Obsidian embeds:/vault/notes,../assets/a.png,./b.pngand..\d.pngask for/vault/assets/a.png,/vault/notes/b.pngand/vault/d.png; a failed relative embed makes no second try;sub/../c.pngstill asks for nothing. Red onorigin/main'sNoteImage.tsx, green on this head...\..\a.png), because one level from/vault/notesis inside the vault and resolves by design. The row still pins that a backslash..cannot leave the vault.Proof: not provable -- frontend test (prove.py runs Python only)
All 436 tests in the 17 Notes test files pass. Determinism:
npx vitest run src/test/mdNotebookImages.test.tsx --sequence.shuffle --sequence.seed=<7919, 15838, 23757, 31676, 39595>passed 64 of 64 each time. The new test uses no timers, network or shared state.Manual verification
Rendered the built SPA in Chromium with the Notes API and
/api/file-rawstubbed (the sharedwebsite/scripts/libcapture fixtures), a note atprojects/network/vpc-topology.mdholding![[../assets/topology.svg|480]],![[./subnets.svg]]and![[../../../outside.svg]]. The page asked/api/file-rawfor exactly<vault>/projects/assets/topology.svgand<vault>/projects/network/subnets.svg, and nothing for the one that climbs out. Clicking an embed opened its source line in the block editor.Screenshots / video
A
../embed with a width, a./embed, and one that climbs out of the vault (kiro-dark):Clicking the
../embed opens its source line in the block editor:Related Issues
Part of #10197
Sibling sweep
N/A — a feature PR, not a fix.
Pattern harvest
N/A — a feature PR, not a fix.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.