Skip to content

feat: add childTitleTemplate attribute and update titleTemplate attri…#8787

Draft
monotok wants to merge 4 commits intoTriliumNext:mainfrom
monotok:feature/titleTemplate
Draft

feat: add childTitleTemplate attribute and update titleTemplate attri…#8787
monotok wants to merge 4 commits intoTriliumNext:mainfrom
monotok:feature/titleTemplate

Conversation

@monotok
Copy link

@monotok monotok commented Feb 21, 2026

This pull request introduces the following changes:

Adds a new childTitleTemplate attribute.
Updates the titleTemplate attribute to ensure it behaves as expected.

Fixes issue #5080

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 21, 2026
@dosubot
Copy link

dosubot bot commented Feb 21, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @monotok, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the note creation process by introducing a dedicated attribute for titling child notes and clarifying the role of the existing template title attribute. These changes provide users with more precise control over how new notes are automatically titled, addressing a previous ambiguity in template application and improving the overall user experience for note organization.

Highlights

  • New childTitleTemplate attribute: Introduced a new attribute, childTitleTemplate, which allows defining a default title for notes created as children of a specific note. This provides more granular control over note titling.
  • Refined titleTemplate behavior: The existing titleTemplate attribute's behavior has been updated. It now specifically applies to notes created from a template note, distinguishing its use from notes created as direct children.
  • Improved title resolution logic: Implemented a new resolveTitleTemplate function to correctly determine which title template to use based on whether a note is being created from a template or as a child of an existing note.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • apps/client/src/translations/en/translation.json
    • Added a new translation entry for child_title_template.
    • Updated the description for title_template to reflect its new specific use case.
  • apps/client/src/widgets/attribute_widgets/attribute_detail.ts
    • Included childTitleTemplate in the ATTR_HELP constant to provide help text for the new attribute.
  • apps/server/src/services/notes.ts
    • Modified the getNewNoteTitle function to accept NoteParams and utilize the new resolveTitleTemplate function.
    • Introduced resolveTitleTemplate to determine whether to use titleTemplate (from a template note) or childTitleTemplate (from a parent note) for new note titles.
  • packages/commons/src/lib/builtin_attributes.ts
    • Added childTitleTemplate to the list of built-in attributes, marking it as dangerous.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new childTitleTemplate attribute and updates the logic for titleTemplate to support generating titles from template notes. The changes correctly separate the responsibility of title generation between templates and parent notes. However, the current implementation of resolveTitleTemplate has two significant issues: it breaks backward compatibility for existing users who rely on titleTemplate on parent notes, and it fails to account for templates inherited via the child:template relation. Addressing these will ensure a smoother transition and more consistent behavior when creating notes in folders with default templates.

Comment on lines +143 to +150
function resolveTitleTemplate(parentNote: BNote, params: NoteParams): string | null {
if (params.templateNoteId != null) {
const templateNote = becca.getNote(params.templateNoteId);
return templateNote ? templateNote.getLabelValue("titleTemplate") : null;
}

return parentNote.getLabelValue("childTitleTemplate");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The resolveTitleTemplate function should be improved to handle two important cases:

  1. Backward Compatibility: Currently, it ignores titleTemplate on the parent note. Since this was the previous behavior, removing it without a fallback will break existing user setups. Adding a fallback ensures that existing folders with titleTemplate continue to work until users migrate to childTitleTemplate.
  2. Inherited Templates: If a note is created in a folder that has a child:template relation, it will eventually inherit that template. The title should be resolved from that template's titleTemplate if no explicit childTitleTemplate is defined on the parent. The current logic only checks params.templateNoteId, which is typically only set when a template is explicitly chosen in the UI.
function resolveTitleTemplate(parentNote: BNote, params: NoteParams): string | null {
    if (params.templateNoteId != null) {
        const templateNote = becca.getNote(params.templateNoteId);
        return templateNote ? templateNote.getLabelValue("titleTemplate") : null;
    }

    const childTitleTemplate = parentNote.getLabelValue("childTitleTemplate");
    if (childTitleTemplate !== null) {
        return childTitleTemplate;
    }

    const inheritedTemplateId = parentNote.getRelationValue("child:template");
    if (inheritedTemplateId) {
        const templateNote = becca.getNote(inheritedTemplateId);
        const templateTitleTemplate = templateNote?.getLabelValue("titleTemplate");
        if (templateTitleTemplate != null) {
            return templateTitleTemplate;
        }
    }

    // Fallback to titleTemplate on parent for backward compatibility
    return parentNote.getLabelValue("titleTemplate");
}

Copy link
Contributor

@eliandoran eliandoran left a comment

Choose a reason for hiding this comment

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

Overall seems fine, but please also update the user guide. Ideally, we should also have a comparison between titleTemplate and childTitleTemplate.

And also clarify the case where you have both a titleTemplate and a childTitleTemplate. What happens then?

@eliandoran eliandoran marked this pull request as draft February 22, 2026 16:57
@monotok
Copy link
Author

monotok commented Feb 22, 2026

Hello, thanks for looking at it. I was waiting to see if the change was acceptable before updating the user guide. Will update the user guide 👍

@eliandoran
Copy link
Contributor

@monotok , it would also be cool to write some integration tests. See hidden_subtree.spec.ts from server as inspiration.

@monotok
Copy link
Author

monotok commented Feb 22, 2026

I am not sure why running pnpm edit-docs:edit-docs causes other files to change. Initially it changed 500+ doc files but I reverted that commit and force pushed.

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants