Repository navigation
fix(desktop): return relative image path for local-path-string inserts - #4492
Merged
Merged
Conversation
moveImageToFolder only applied the isRelative -> path.relative() conversion in the binary File branch. Inserting an image via a local path string (Format -> Image with a typed/picked path) hit the isPath branch, which copied the file into the relative assets dir but returned an absolute path, so the inserted markdown ignored the "prefer relative directory" preference. Extract a toResult() helper and apply it to both branches so path-string inserts persist the portable relative reference too. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 task done
1 task done
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.
Problem
With Insert action = Folder + Prefer relative directory enabled (
imageRelativeDirectoryName='assets', base = file), inserting an image via Format → Image with a typed or picked local path did not produce a relative reference. The image was copied into theassets/folder, but the inserted markdown used an absolute path, ignoring the "prefer relative directory" preference.Root cause
In
packages/desktop/src/renderer/src/util/fileSystem.ts,moveImageToFolderonly applied theisRelative→path.relative()conversion in the binaryFilebranch. A local path string (Format → Image) hits theisPathbranch, which returned the absolutehashFilePath/imagePathregardless ofisRelative.This is the persistence half of the Phase-G relative-path image work (#4428); the two new code paths (persist-as-relative and render-relative) must stay consistent, and the path-string persistence half was the gap.
Fix
Extract a
toResult()helper and apply it to both branches so path-string inserts persist the portable relative reference too.Testing
test/unit/specs/move-image-to-folder.spec.ts: asserts theFilebranch returns a relative path (already passing) and the path-string branch both copies intoassets/and returns a relative path (failing before the fix, passing after).typecheckandeslintclean.🤖 Generated with Claude Code