From d97f646f620842ab61f23ef258a052fff7a744a1 Mon Sep 17 00:00:00 2001 From: Chris Hamer Date: Sat, 21 Feb 2026 19:08:07 +0000 Subject: [PATCH 1/5] feat: add childTitleTemplate attribute and update titleTemplate attribute to behave as expected --- apps/client/src/translations/en/translation.json | 3 ++- .../widgets/attribute_widgets/attribute_detail.ts | 1 + apps/server/src/services/notes.ts | 15 ++++++++++++--- packages/commons/src/lib/builtin_attributes.ts | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 04a372ddaef..6c84e8273fb 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -411,7 +411,8 @@ "share_index": "note with this label will list all roots of shared notes", "display_relations": "comma delimited names of relations which should be displayed. All other ones will be hidden.", "hide_relations": "comma delimited names of relations which should be hidden. All other ones will be displayed.", - "title_template": "default title of notes created as children of this note. The value is evaluated as JavaScript string \n and thus can be enriched with dynamic content via the injected now and parentNote variables. Examples:\n \n \n \n See wiki with details, API docs for parentNote and now for details.", + "title_template": "default title of notes created from this template note. The value is evaluated as JavaScript string \n and thus can be enriched with dynamic content via the injected now and parentNote variables. Examples:\n \n \n \n See wiki with details, API docs for parentNote and now for details.", + "child_title_template": "default title of notes created as children of this note. The value is evaluated as JavaScript string \n and thus can be enriched with dynamic content via the injected now and parentNote variables. Examples:\n \n \n \n See wiki with details, API docs for parentNote and now for details.", "template": "This note will appear in the selection of available template when creating new note", "toc": "#toc or #toc=show will force the Table of Contents to be shown, #toc=hide will force hiding it. If the label doesn't exist, the global setting is observed", "color": "defines color of the note in note tree, links etc. Use any valid CSS color value like 'red' or #a13d5f", diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts index 607af499525..b6a32048dd4 100644 --- a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts +++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts @@ -254,6 +254,7 @@ const ATTR_HELP: Record> = { displayRelations: t("attribute_detail.display_relations"), hideRelations: t("attribute_detail.hide_relations"), titleTemplate: t("attribute_detail.title_template"), + childTitleTemplate: t("attribute_detail.child_title_template"), template: t("attribute_detail.template"), toc: t("attribute_detail.toc"), color: t("attribute_detail.color"), diff --git a/apps/server/src/services/notes.ts b/apps/server/src/services/notes.ts index f4eb40579a1..01d8e7af920 100644 --- a/apps/server/src/services/notes.ts +++ b/apps/server/src/services/notes.ts @@ -113,10 +113,10 @@ function copyAttachments(origNote: BNote, newNote: BNote) { } } -function getNewNoteTitle(parentNote: BNote) { +function getNewNoteTitle(parentNote: BNote, params: NoteParams): string { let title = t("notes.new-note"); - const titleTemplate = parentNote.getLabelValue("titleTemplate"); + const titleTemplate = resolveTitleTemplate(parentNote, params); if (titleTemplate !== null) { try { @@ -140,6 +140,15 @@ function getNewNoteTitle(parentNote: BNote) { return title; } +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"); +} + interface GetValidateParams { parentNoteId: string; type: string; @@ -180,7 +189,7 @@ function createNewNote(params: NoteParams): { const parentNote = getAndValidateParent(params); if (params.title === null || params.title === undefined) { - params.title = getNewNoteTitle(parentNote); + params.title = getNewNoteTitle(parentNote, params); } if (params.content === null || params.content === undefined) { diff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.ts index 0f509c0d257..81667301400 100644 --- a/packages/commons/src/lib/builtin_attributes.ts +++ b/packages/commons/src/lib/builtin_attributes.ts @@ -70,6 +70,7 @@ export default [ { type: "label", name: "displayRelations" }, { type: "label", name: "hideRelations" }, { type: "label", name: "titleTemplate", isDangerous: true }, + { type: "label", name: "childTitleTemplate", isDangerous: true }, { type: "label", name: "template" }, { type: "label", name: "toc" }, { type: "label", name: "color" }, From e11664376fd299ad67d500a2ee92dbc923d93da2 Mon Sep 17 00:00:00 2001 From: Chris Hamer Date: Sun, 22 Feb 2026 23:41:29 +0000 Subject: [PATCH 2/5] docs: update the user guide with information on the new label and the change of behaviour of the existing label --- .../en/User Guide/User Guide/AI.html | 12 ++-- .../Advanced Usage/Default Note Title.html | 64 ++++++++++++++----- .../Developer Guide/Documentation.md | 2 +- docs/User Guide/!!!meta.json | 25 +++----- .../Advanced Usage/Default Note Title.md | 42 +++++++++--- 5 files changed, 93 insertions(+), 52 deletions(-) diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html index 2f1d30ec2b0..00bbfb1eb05 100644 --- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html +++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html @@ -4,21 +4,17 @@ maintaining and supporting it long-term proved to be unsustainable.

When upgrading to v0.102.0, your Chat notes will be preserved, but instead of the dedicated chat window they will be turned to a normal Code note, - revealing the underlying JSON of the conversation.

+ href="#root/_help_6f9hih2hXXZk">Code note, revealing the underlying + JSON of the conversation.

Alternative solutions (MCP)

Given the recent advancements of the AI scene, MCP has grown to be more powerful and facilitates easier integrations with various application.

As such, there are third-party solutions that integrate an MCP server that can be used with Trilium: