Skip to content

fix: extend isMarkdownFilename across remaining session-start call sites#92

Merged
breferrari merged 2 commits into
mainfrom
fix/extend-isMarkdownFilename-88
May 18, 2026
Merged

fix: extend isMarkdownFilename across remaining session-start call sites#92
breferrari merged 2 commits into
mainfrom
fix/extend-isMarkdownFilename-88

Conversation

@breferrari

Copy link
Copy Markdown
Owner

Summary

Sites changed

File Line Function Before After
session-start.ts 208 brainIndex() filter e.name.endsWith(".md") isMarkdownFilename(e.name)
session-start.ts 212 brainIndex() strip f.replace(/\.md$/, "") f.replace(/\.md$/i, "")
session-start.ts 258 listMd() filter e.name.endsWith(".md") isMarkdownFilename(e.name)
lib/session-start.ts 34 formatActiveWork() filter f.endsWith(".md") isMarkdownFilename(f)
lib/session-start.ts 35 formatActiveWork() strip f.replace(/\.md$/, "") f.replace(/\.md$/i, "")

isMarkdownFilename was already imported into session-start.ts at line 36 — no import shuffle.

Cross-platform behaviour

The change is pure-string filter and regex logic. No filesystem APIs touched.

Filesystem Effect
NTFS (Windows) — case-insensitive A Note.MD saved by a different tool was silently dropped; now listed. No regression for lowercase files.
APFS default (macOS) — case-insensitive Same as NTFS.
ext4 (Linux) — case-sensitive Note.md and Note.MD are distinct files; both are now listed instead of just lowercase. Cosmetic duplicate after extension strip; matches PR #87's precedent (isMarkdownFilename already accepts both).
APFS case-sensitive (macOS, opt-in) Same as ext4.

The new unit test passes synthetic filenames (no real FS) so behaviour is identical on every OS. Existing CI matrix exercises this on ubuntu / macos / windows × Node 22 / 24.

Test coverage

  • New test in formatActiveWork's describe block (session-start.test.ts:73–80): locks .MD/.Md/.md all pass the filter, extension stripped correctly, non-markdown file filtered out.
  • Existing isMarkdownFilename tests at session-start.test.ts:306–331 already cover uppercase / mixed-case / non-.md / no-extension cases at the helper level. No change needed there.
  • brainIndex() and listMd() are filesystem-driven; their case-insensitivity is covered by the existing integration test plus the helper-level coverage.

Out of scope (intentional)

  • lib/frontmatter.ts:34, 41 — same kind of endsWith(".md") in the validate-write hook. Different hook, different test surface. Worth a separate follow-up issue; not bundled here to keep the PR scoped to the session-start surface.

Test plan

  • npm test in .claude/scripts/: 522/522 (was 521, +1)
  • npm run typecheck: clean
  • CI matrix green on ubuntu / macos / windows × Node 22 / 24
  • Optional manual: create brain/Test.MD in a vault, run the hook, see Test appear in the Brain Topics section

🤖 Generated with Claude Code

PR #87 introduced the case-insensitive `isMarkdownFilename` helper for
the new `listMarkdownSources` scanner but left three pre-existing call
sites still using `endsWith(".md")` plus a case-sensitive `/\.md$/`
strip:

- `session-start.ts:208` — `brainIndex()` filter
- `session-start.ts:212` — `brainIndex()` strip
- `session-start.ts:258` — `listMd()` filter (vault file listing)

An audit also caught two more in `formatActiveWork()` in the lib
file (`lib/session-start.ts:34, 35`) — same module, same case-
sensitive bug, same fix shape. Bundled here per PR #87's "two bugs,
one PR" precedent.

On NTFS/APFS case-insensitive filesystems a file saved as `Note.MD`
or `note.Md` was silently dropped from the brain index, the active
work section, and the vault file listing. After this fix all three
sections route through the canonical helper and accept any case
variant, matching how Obsidian itself surfaces the same file.

New test in `formatActiveWork`'s suite locks `.MD`/`.Md`/`.md`
acceptance and case-insensitive extension stripping. The integration
test against the SessionStart hook continues to exercise the changed
filters end-to-end.

Closes #88

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR completes the session-start markdown filename case-insensitivity fix by replacing remaining .md string checks with the canonical isMarkdownFilename() helper.

Changes:

  • Updates brainIndex() and listMd() to include .MD / mixed-case markdown files.
  • Makes extension stripping case-insensitive.
  • Adds unit coverage for mixed-case active work filenames.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.claude/scripts/session-start.ts Applies case-insensitive markdown detection in brain index and vault listing.
.claude/scripts/lib/session-start.ts Applies the helper and case-insensitive strip in active work formatting.
.claude/scripts/tests/session-start.test.ts Adds mixed-case markdown extension coverage for active work formatting.
Comments suppressed due to low confidence (1)

.claude/scripts/session-start.ts:258

  • The case-insensitive vault listing path is still untested at the script level: the new test covers formatActiveWork(), while the integration test's vault file listing only encounters lowercase markdown names. Add a mixed/uppercase root or nested .MD fixture and assert it appears in ### Vault File Listing so this call site cannot regress independently of the helper tests.
			else if (e.isFile() && isMarkdownFilename(e.name)) results.push(`./${full}`);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .claude/scripts/session-start.ts
…hook level

The unit-level tests prove `isMarkdownFilename` accepts `.MD`/`.Md`,
but they don't prove each call site actually delegates to that
helper. Copilot's PR review and the /simplify quality agent both
flagged this independently.

Add an `Uppercase.MD` fixture to the integration test's synthetic
vault `before()` and assert it surfaces in two places:
- `### Brain Topics` section: bare `Uppercase` (case-insensitive
  strip via the new `/\.md$/i` regex).
- `### Vault File Listing` section: `Uppercase.MD` (case-insensitive
  filter via `isMarkdownFilename`).

A future refactor that bypasses the helper in either call site now
fails this test, not just the unit tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@breferrari breferrari merged commit e9f7edd into main May 18, 2026
8 checks passed
@breferrari breferrari deleted the fix/extend-isMarkdownFilename-88 branch May 18, 2026 19:35
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.

Extend isMarkdownFilename across listMd() and brainIndex() in session-start.ts

2 participants