Skip to content

fix: templated occurrence filename counts as representing the title - #2248

Open
raphaelfaouakhiri wants to merge 2 commits into
callumalpass:mainfrom
raphaelfaouakhiri:patch/occurrence-title-represented-by-filename
Open

fix: templated occurrence filename counts as representing the title#2248
raphaelfaouakhiri wants to merge 2 commits into
callumalpass:mainfrom
raphaelfaouakhiri:patch/occurrence-title-represented-by-filename

Conversation

@raphaelfaouakhiri

Copy link
Copy Markdown
Contributor

Closes #2246

Problem

With storeTitleInFilename enabled, occurrences materialized through the occurrence filename template (#2126 / #2134) are always created with the title property in frontmatter: the titleIsRepresentedByFilename check (from the collision handling fix) compares the unique filename against the plain title, and a templated name like Pay rent — 2026-09 never matches it. Since the title property takes precedence over the filename when reading, every view then shows the occurrence without its period suffix — defeating the purpose of the template.

Fix

When the occurrence filename template was used, compare the unique filename against the generated occurrence filename instead of the plain title. If the templated name was used as-is, it represents the title and the property is omitted (display falls back to the filename, suffix included) — the same rule regular tasks already follow when filename == title.

The intent of the collision handling fix is preserved:

  • templated filename gets a collision suffix (Pay rent — 2026-09-1) → title property is kept;
  • filename sanitization changed the title (Pay: rentPay rent) → title property is kept.

One behavior worth noting: editing the title of an already-materialized occurrence writes the title property back (title ≠ filename again), which is correct and consistent with the collision handling.

Tests

New tests/unit/issues/issue-2246-occurrence-template-title-frontmatter.test.ts (3 cases: template used as-is omits title; collision suffix keeps it; sanitization keeps it). First case written before the fix and observed failing.

Verified no regressions in tests/unit/services and the issue-1623/2107 suites; the 2 failures in task-occurrence-materialization.test.ts ("advances completion-anchored parents") and ICSNoteService.folder-template.test.ts fail identically on current main without this change (date-dependent / pre-existing).

🤖 Generated with Claude Code

raphaelfaouakhiri and others added 2 commits August 20, 2026 21:32
…allumalpass#2246)

With storeTitleInFilename enabled, occurrences named by the occurrence
filename template were always born with the title property, because the
titleIsRepresentedByFilename check compared the unique filename against
the plain title — which a templated name never matches. The title
property then wins over the filename when reading, so every view showed
the occurrence without its period suffix.

Compare against the generated occurrence filename instead when the
template was used. Collision suffixes and sanitization losses still
preserve the title property, keeping the intent of the collision
handling fix.
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.

Occurrence filename template: occurrences are created with the title property, so views display the title without the period suffix

2 participants