Skip to content

Derive Obsidian import file names from titles Obsidian can create - #1482

Open
isaacschaal wants to merge 1 commit into
DiscourseGraphs:mainfrom
isaacschaal:fix/import-note-filenames
Open

isaacschaal wants to merge 1 commit into
DiscourseGraphs:mainfrom
isaacschaal:fix/import-note-filenames

Conversation

@isaacschaal

@isaacschaal isaacschaal commented Sep 24, 2026 •

Copy link
Copy Markdown

Closes #1481

Reviewer brief

  • Result: Roam-origin nodes whose titles carry page references or tags now import with file names Obsidian can link to. [[EVD]] - x - [[@Smith 2020]] becomes EVD - x - @Smith 2020.md.
  • Review focus: noteFileNameFromTitle is new and only used for note titles. sanitizeFileName is 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 one checkInvalidChars already enforces.
  • Risk: a note already imported with #, ^ or brackets in its name gets renamed once on its next import, through the existing rename-on-retitle branch (fileManager.renameFile updates links). C# notes becomes C 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

Scope check

  • Ran $scope-check against the ENG ticket and final diff.
  • Scope beyond Done When: None. External contribution with no Linear ticket, so the linked issue sets the scope.

Standards check

  • Ran $dg-pr-adherence-check against the final diff and PR metadata.

Local delegated full review

  • Ran a comprehensive review of the entire final diff in a subagent with a fresh context. It flagged the empty-name case and an inaccurate comment, and both are fixed.

Written with Claude Code. I've read and tested every line.


Devin Review

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
@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown

@isaacschaal is attempting to deploy a commit to the Discourse Graphs Team on Vercel.

A member of the Team first needs to authorize it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +14 to +15
.replace(PAGE_REFERENCE, "$1")
.replace(REJECTED_IN_FILE_NAMES, "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Roam titles with page references or tags import into Obsidian as unlinkable notes

1 participant