Derive Obsidian import file names from titles Obsidian can create - #1482
isaacschaal wants to merge 1 commit into
Conversation
Imported node titles arriving from Roam carry page references and tags ([[EVD]] - x - [[@smith 2020]]), and the import path only stripped the OS file-name set, so the brackets reached the note's file name. Obsidian creates such a file but cannot link to it, so the node imports and then sits disconnected from the rest of the graph. Unwrap page references and drop the characters Obsidian rejects in file names (the set checkInvalidChars already enforces when a user creates a node), in a function of its own with tests. Asset paths keep the narrower rule. A title that sanitizes to nothing falls back to the node instance id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmGT261gNCnNMmW8h6HXbn
|
@isaacschaal is attempting to deploy a commit to the Discourse Graphs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| .replace(PAGE_REFERENCE, "$1") | ||
| .replace(REJECTED_IN_FILE_NAMES, "") |
There was a problem hiding this comment.
🟡 Windows imports fail for reserved names
On Windows, noteFileNameFromTitle turns [[CON]] into CON, a reserved device name even with .md. The vault rejects the file, so importing or refreshing that node fails.
Learn more
Windows reserves device names such as CON, PRN, AUX, NUL, COM1, and LPT1 even when they carry an extension. This transformation turns a previously usable title containing brackets into one of those reserved names. processFileContent writes the resulting path through Obsidian's vault, and the import loop records a failure if that write throws.
Example: On Windows, a node titled [[CON]] previously imported as [[CON]].md. Its new filename is CON.md, which the filesystem refuses.
Recommended fix: Check the final basename against Windows device names, case-insensitively, and add a safe suffix or use the node ID when a match occurs. Cover both initial import and refresh in tests.
Was this helpful? React with 👍 or 👎 to provide feedback.
Closes #1481
Reviewer brief
[[EVD]] - x - [[@Smith 2020]]becomesEVD - x - @Smith 2020.md.noteFileNameFromTitleis new and only used for note titles.sanitizeFileNameis unchanged and still handles asset paths and the source-folder prefix, so attachment names don't move. The rejected set is the OS set plus the onecheckInvalidCharsalready enforces.#,^or brackets in its name gets renamed once on its next import, through the existing rename-on-retitle branch (fileManager.renameFileupdates links).C# notesbecomesC notes. If a title sanitizes to nothing, the node instance id is used instead. Slash handling is left as it was; see the issue.Verification
pnpm test:unitinapps/obsidian: 47 passed, 10 of them new cases fornoteFileNameFromTitle.turbo check-types --filter=./apps/obsidian: clean.Scope check
$scope-checkagainst the ENG ticket and final diff.Done When: None. External contribution with no Linear ticket, so the linked issue sets the scope.Standards check
$dg-pr-adherence-checkagainst the final diff and PR metadata.Local delegated full review
Written with Claude Code. I've read and tested every line.