Skip to content

Conversation

@cr7pt0gr4ph7
Copy link
Contributor

@cr7pt0gr4ph7 cr7pt0gr4ph7 commented Dec 28, 2025

This adds support for the standard {{date}} and {{time}} placeholders of the offical Templates plugin, as well as support for {{status}} so custom templates can also access the Default Project Status setting.

Summary by CodeRabbit

  • New Features

    • Added {{date}}, {{time}}, and {{status}} template variables; templates support separate date, time, and combined datetime values.
    • Creation-date frontmatter now uses a more precise datetime value.
  • Documentation

    • Updated template variable descriptions to include {{date}}, {{time}}, and {{status}}.
  • Tests

    • Added tests verifying {{date}} (YYYY-MM-DD), {{time}} (HH:mm), and default {{status}} replacements.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Refactors date/time handling in src/file-writer.ts to add now, dateTime, date, and time, new formatter helpers, and extended template replacements (including {{date}}, {{time}}, {{status}}); updates settings description and adds tests for the new placeholders.

Changes

Cohort / File(s) Summary
Date/Time refactor
src/file-writer.ts
Adds now, dateTime, date, time; introduces private helpers formatDateTime(), formatDate(), formatTime(); uses dateTime for frontmatter creation-date; populates {{date}}, {{time}}, and {{status}} in template replacements; adjusts next-actions and fallback content generation.
Settings description
src/settings-tab.ts
Updates "Project Template File" setting description to document new template variables: {{date}}, {{time}}, and {{status}} alongside {{priority}}, {{sphere}}, and {{description}}.
Tests
tests/file-writer.test.ts
Adds tests verifying {{date}} is replaced as YYYY-MM-DD, {{time}} as HH:mm, and {{status}} uses default setting (e.g., live); mocks template reading and vault behavior to assert generated content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through lines at break of dawn,

I split the ticks so markers shone,
dateTime leads, then date and hour,
tiny helpers lend their power,
a rabbit's tweak — neat, swift, and drawn.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for {{date}}, {{time}}, and {{status}} placeholder replacements in custom templates, which aligns with all modifications across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31df107 and a62dd8f.

📒 Files selected for processing (2)
  • src/file-writer.ts
  • tests/file-writer.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.ts: All source files must start with two ABOUTME comments describing the file purpose
Use PascalCase for class names
Use camelCase for function and variable names
Use UPPER_SNAKE_CASE for exported constants

Files:

  • src/file-writer.ts
tests/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.ts: Use Jest with ts-jest preset for testing with an 80% code coverage threshold
Use generateDeterministicFakeApiKey() from tests/test-utils.ts for test API keys to avoid security scanner false positives

Files:

  • tests/file-writer.test.ts
🧠 Learnings (1)
📚 Learning: 2025-12-28T16:39:43.487Z
Learnt from: CR
Repo: tavva/flow PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:39:43.487Z
Learning: Applies to tests/**/*.ts : Use generateDeterministicFakeApiKey() from tests/test-utils.ts for test API keys to avoid security scanner false positives

Applied to files:

  • tests/file-writer.test.ts
🧬 Code graph analysis (1)
tests/file-writer.test.ts (2)
src/types/gtd.ts (1)
  • GTDProcessingResult (16-33)
tests/__mocks__/obsidian.ts (1)
  • TFile (3-11)
🔇 Additional comments (6)
tests/file-writer.test.ts (3)

429-477: LGTM! Well-structured test for {{date}} placeholder.

The test properly validates that the {{date}} placeholder is replaced with YYYY-MM-DD format (date only, no time component). The negative assertion ensures the time component is not included.


479-527: LGTM! Well-structured test for {{time}} placeholder.

The test properly validates that the {{time}} placeholder is replaced with HH:mm format (24-hour time only).


529-576: LGTM! Well-structured test for {{status}} placeholder.

The test properly validates that the {{status}} placeholder is replaced with the defaultStatus value from settings.

src/file-writer.ts (3)

400-403: LGTM! Templater syntax handling clarified.

The updated comment accurately reflects that both HH:mm and hh:mm patterns are replaced with 24-hour format. This addresses the previous review concern about misleading documentation.


496-497: LGTM! Correct usage in fallback method.

The fallback method correctly creates only dateTime since it generates content directly without processing template placeholders.


760-792: LGTM! Well-implemented formatter helper methods.

The three new private helper methods (formatDateTime, formatDate, formatTime) are cleanly implemented with:

  • Clear JSDoc documentation
  • Consistent formatting logic
  • Proper zero-padding
  • Appropriate method visibility (private)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/file-writer.ts (1)

773-792: Fix comment: time format is 24-hour (HH:mm), not 12-hour (hh:mm).

The helper methods are well-implemented and correctly format date/time values. However, the comment on line 785 says "(hh:mm)" which typically denotes 12-hour format, but the code produces 24-hour format. The comment should be updated for accuracy.

🔎 Proposed fix for the comment
 /**
- * Format a time for Flow frontmatter (hh:mm)
+ * Format a time for Flow frontmatter (HH:mm)
  */
 private formatTime(date: Date): string {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60317fa and d88f655.

📒 Files selected for processing (2)
  • src/file-writer.ts
  • src/settings-tab.ts
🔇 Additional comments (4)
src/settings-tab.ts (1)

354-354: LGTM! Documentation accurately reflects new template variables.

The updated description correctly documents the new {{date}}, {{time}}, and {{status}} placeholders alongside the existing ones, matching the implementation in file-writer.ts.

src/file-writer.ts (3)

372-375: LGTM! Clean date/time computation.

The granular date/time variables are well-structured and provide the necessary flexibility for template replacement. The separation of date, time, and dateTime aligns with the PR objectives to support both the Obsidian Templates plugin format and custom use cases.


389-392: LGTM! Template placeholder replacements are correctly implemented.

The regex patterns properly handle optional whitespace around placeholder names, and the global flag ensures all occurrences are replaced. The {{status}} replacement using defaultStatus aligns with the PR objectives.


496-497: LGTM! Fallback path maintains consistency.

The fallback implementation correctly uses the same date/time formatting approach as the template-based path, ensuring consistent behavior regardless of whether a custom template exists.

Also applies to: 516-516

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/file-writer.ts (1)

400-403: The misleading comment about 12-hour format handling remains.

As previously noted, the comment on line 400 claims to "Handle both 12-hour (hh:mm) and 24-hour (HH:mm) formats," but both Templater placeholders are replaced with dateTime, which uses 24-hour format exclusively.

If 24-hour standardization is intentional, remove or update the comment to reflect this. Otherwise, implement actual 12-hour conversion for the hh:mm placeholder.

🧹 Nitpick comments (1)
src/file-writer.ts (1)

439-450: Consider extracting checkbox creation logic to reduce duplication.

The logic for creating checkboxes and formatting action text (handling isDone, isWaiting, completion dates) is duplicated across multiple methods: buildProjectContent, buildProjectContentFallback, addToNextActionsFile, addActionToSection, and createSectionWithAction.

Extracting this to a helper method would improve maintainability and ensure consistency across all action creation points.

Example helper method
/**
 * Format an action item with appropriate checkbox and metadata
 */
private formatActionItem(
  action: string,
  isWaiting: boolean = false,
  isDone: boolean = false,
  dueDate?: string
): string {
  let checkbox: string;
  let actionText = action;

  if (isDone) {
    checkbox = "- [x]";
    const completionDate = new Date().toISOString().split("T")[0];
    actionText = `${action}${completionDate}`;
  } else if (isWaiting) {
    checkbox = "- [w]";
  } else {
    checkbox = "- [ ]";
  }

  const dueDateSuffix = dueDate ? ` 📅 ${dueDate}` : "";
  return `${checkbox} ${actionText}${dueDateSuffix}`;
}

Then replace duplicated logic with calls to this.formatActionItem(action, isWaiting, isDone, dueDate).

Also applies to: 456-470, 543-561, 564-578

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d88f655 and 31df107.

📒 Files selected for processing (1)
  • src/file-writer.ts
🔇 Additional comments (4)
src/file-writer.ts (4)

372-375: LGTM! Well-structured date/time handling.

The separation of dateTime, date, and time variables provides clear semantics: dateTime for frontmatter timestamps and date/time for template placeholders. This aligns well with the PR objective to support the Templates plugin's standard placeholders.


389-392: LGTM! Template placeholder replacements implemented correctly.

The new {{date}}, {{time}}, and {{status}} placeholders are properly replaced with appropriate values. The regex patterns correctly handle optional whitespace, and the status placeholder correctly references the default status setting.


496-497: LGTM! Fallback method correctly uses dateTime for frontmatter.

The fallback method appropriately uses dateTime for the creation-date frontmatter field, consistent with the template-based approach. Since the fallback builds content directly without template replacements, it doesn't need separate date and time variables.

Also applies to: 516-516


760-792: LGTM! Well-structured date/time formatting methods.

The three formatting methods are cleanly separated and correctly implement their respective formats:

  • formatDateTime: "YYYY-MM-DD HH:mm" for frontmatter timestamps
  • formatDate: "YYYY-MM-DD" for date-only placeholders
  • formatTime: "HH:mm" for time-only placeholders

The JSDoc has been corrected to accurately reflect the 24-hour format output.

- Add tests for {{date}} placeholder (YYYY-MM-DD format)
- Add tests for {{time}} placeholder (HH:mm format)
- Add tests for {{status}} placeholder (uses defaultStatus setting)
- Clarify comment about Templater date syntax handling
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/file-writer.ts (1)

372-392: File is missing required ABOUTME comments.

Per coding guidelines, all .ts files must start with two ABOUTME comments describing file purpose. The file currently begins with imports instead.

The implementation at lines 372-392 is clean: the single now variable ensures consistency across all date/time formatters, and the regex patterns properly handle whitespace. However, defaultStatus has a defined default value of "live" in src/types/settings.ts, so no additional validation is needed.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31df107 and a62dd8f.

📒 Files selected for processing (2)
  • src/file-writer.ts
  • tests/file-writer.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.ts: All source files must start with two ABOUTME comments describing the file purpose
Use PascalCase for class names
Use camelCase for function and variable names
Use UPPER_SNAKE_CASE for exported constants

Files:

  • src/file-writer.ts
tests/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.ts: Use Jest with ts-jest preset for testing with an 80% code coverage threshold
Use generateDeterministicFakeApiKey() from tests/test-utils.ts for test API keys to avoid security scanner false positives

Files:

  • tests/file-writer.test.ts
🧠 Learnings (1)
📚 Learning: 2025-12-28T16:39:43.487Z
Learnt from: CR
Repo: tavva/flow PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:39:43.487Z
Learning: Applies to tests/**/*.ts : Use generateDeterministicFakeApiKey() from tests/test-utils.ts for test API keys to avoid security scanner false positives

Applied to files:

  • tests/file-writer.test.ts
🧬 Code graph analysis (1)
tests/file-writer.test.ts (2)
src/types/gtd.ts (1)
  • GTDProcessingResult (16-33)
tests/__mocks__/obsidian.ts (1)
  • TFile (3-11)
🔇 Additional comments (6)
tests/file-writer.test.ts (3)

429-477: LGTM! Well-structured test for {{date}} placeholder.

The test properly validates that the {{date}} placeholder is replaced with YYYY-MM-DD format (date only, no time component). The negative assertion ensures the time component is not included.


479-527: LGTM! Well-structured test for {{time}} placeholder.

The test properly validates that the {{time}} placeholder is replaced with HH:mm format (24-hour time only).


529-576: LGTM! Well-structured test for {{status}} placeholder.

The test properly validates that the {{status}} placeholder is replaced with the defaultStatus value from settings.

src/file-writer.ts (3)

400-403: LGTM! Templater syntax handling clarified.

The updated comment accurately reflects that both HH:mm and hh:mm patterns are replaced with 24-hour format. This addresses the previous review concern about misleading documentation.


496-497: LGTM! Correct usage in fallback method.

The fallback method correctly creates only dateTime since it generates content directly without processing template placeholders.


760-792: LGTM! Well-implemented formatter helper methods.

The three new private helper methods (formatDateTime, formatDate, formatTime) are cleanly implemented with:

  • Clear JSDoc documentation
  • Consistent formatting logic
  • Proper zero-padding
  • Appropriate method visibility (private)

@tavva tavva merged commit a7c9556 into tavva:main Dec 28, 2025
3 checks passed
@tavva
Copy link
Owner

tavva commented Dec 28, 2025

Thanks @cr7pt0gr4ph7!

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.

2 participants