feat: add childTitleTemplate attribute and update titleTemplate attri…#8787
feat: add childTitleTemplate attribute and update titleTemplate attri…#8787monotok wants to merge 4 commits intoTriliumNext:mainfrom
Conversation
Summary of ChangesHello @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 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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"); | ||
| } |
There was a problem hiding this comment.
The resolveTitleTemplate function should be improved to handle two important cases:
- Backward Compatibility: Currently, it ignores
titleTemplateon 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 withtitleTemplatecontinue to work until users migrate tochildTitleTemplate. - Inherited Templates: If a note is created in a folder that has a
child:templaterelation, it will eventually inherit that template. The title should be resolved from that template'stitleTemplateif no explicitchildTitleTemplateis defined on the parent. The current logic only checksparams.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");
}
eliandoran
left a comment
There was a problem hiding this comment.
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?
|
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 👍 |
|
@monotok , it would also be cool to write some integration tests. See |
…bute to behave as expected
… change of behaviour of the existing label
0dd3e6e to
e116643
Compare
|
I am not sure why running |
This pull request introduces the following changes:
Fixes issue #5080