Repository navigation
Fix(tui): renaming a file updates bare embeds and counts them as uses - #36
Merged
Merged
Conversation
The Files view rewrote links with RewriteAssetLinks, which only knew root-relative and note-relative targets. On a local vault ![[pic.png]] for assets/pic.png stayed unchanged after a rename and the embed broke, and a note whose only link was a bare embed did not count as a use. Rename now goes through the desktop and server's resolver, still through open buffers, and the use count reads links the same way through a new AssetsReferencedBy. RewriteAssetLinks had no callers left, so it is gone.
adibhanna
changed the base branch from
claude/mcp-asset-tools-34-d9c88e
to
main
November 4, 2026 17:13
…es alone Review of the rename found four ways it edited what it should not: - A wikilink to a note followed a file of the same name, so [[TODO]] became [[TODO.old]] when inbox/TODO was renamed. A note now wins, as in the desktop's follow-link, in the rewrite and in the use count. - Code examples were rewritten, because wikiCodeMask paired single ticks and let any fence line close a fence. It now uses the desktop's closing rules and pairs inline runs of equal length. Note renames share the mask and get this too. - On a server, a second pass over notes the server had already rewritten read the new name against the old listing, so a case-only rename flattened paths. zn now leaves notes to the server and reloads open buffers. - Trashed notes were edited. They are skipped now, like the desktop and server. A Markdown link to a name holding an escape, like 50%20off.pdf, now escapes the percent sign, so it reads back as that file.
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses the resolver added in #35.
Problem
The Files view rewrote links with
RewriteAssetLinks, which only knew root-relative and note-relative targets. The desktop and server also resolve a bare file name by unique basename, so on a local vault![[pic.png]]forassets/pic.pngstayed unchanged after a rename and the embed broke. A note whose only link was a bare embed also did not count as a use.Change
a.mutateNote.vault.AssetsReferencedBy.RewriteAssetLinkshad no callers left, so it is removed. Its cases that still apply moved toasset_link_rename_test.go.[[TODO]]stays put when a file calledTODOis renamed. This also applies to MCPrename_asseton a local vault.znleaves notes to the server, which rewrites them itself, and reloads open buffers.50%20off.pdf, now escapes the percent sign so it reads back as that file.wikiCodeMasknow uses the desktop's fence closing rules and pairs inline backtick runs of equal length. Note renames share it.Behaviour change
[other](./assets/report.pdf)innotes/n.mdnow follows a rename, because the resolver falls back to the vault root like the desktop. It used to stay unchanged.For Adib to decide
The desktop and server still have the code-example gaps: their rewrites edit double-tick spans and nested fences, and the percent-escape case also differs. This PR only changes
zn, so the three copies now differ here.Testing
go test ./...andgo vet ./...pass.workflow_parity_test.goandasset_link_rename_test.gocover a closed note, an open buffer with unsaved text, a note of the same name, trashed notes, a server-style backend, each code form and percent names.zn tuiin tmux on throwaway vaults:assets/pic.pngtomy pic.pngrewrote![[pic.png]],![[assets/pic.png|300]]and[rel](../assets/pic.png), left code alone, and updated the open tab on screen and on disk. Renaminginbox/TODOleft[[TODO]]alone.f4a3d0f) with scratch paths: a case-only rename toPic.pngkept every path, refreshed the open tab and left the trash alone.Known limits
znno longer does it for it. Only the current znserver was tested.