Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(llm): point to the enable toggle and button for a disabled attribute
Elian Doran2164c3719850
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.htmlindex f1bdea6de6..2732c06f62 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@@ -178,8 +178,10 @@ class="admonition note"><li>An attribute that runs code, such as <code>#run</code>, <code>#widget</code> or <code>~renderNote</code>,is saved with a <code>disabled:</code> prefix (for example <code>#disabled:widget</code>),the same way a safe import disables it (see <a class="reference-link" href="#root/_help_YzMcWlCVeW09">Active content</a>).- The AI tells you which note it is on; review the code, then remove the <code>disabled:</code> prefix- to activate it.</li>+ The AI tells you which note it is on; review the code, then enable it with+ the toggle next to the active content badge beside the note's title or,+ for a <a class="reference-link" href="#root/_help_HcABDtFCkbFN">Render Note</a>,+ the <em>Enable render note</em> button in the note.</li></ul></li><li>Delete an attribute.</li>diff --git a/docs/User Guide/User Guide/AI.md b/docs/User Guide/User Guide/AI.mdindex 663c8ed62b..77e526728e 100644--- a/docs/User Guide/User Guide/AI.md+++ b/docs/User Guide/User Guide/AI.md@@ -123,7 +123,7 @@ Here are a few tools that Trilium provides for the LLM:* At attribute level:* Get the full list of attributes, or a specific attribute.* Set the value of an attribute.- * An attribute that runs code, such as `#run`, `#widget` or `~renderNote`, is saved with a `disabled:` prefix (for example `#disabled:widget`), the same way a safe import disables it (see <a class="reference-link" href="Basic%20Concepts%20and%20Features/Active%20content.md">Active content</a>). The AI tells you which note it is on; review the code, then remove the `disabled:` prefix to activate it.+ * An attribute that runs code, such as `#run`, `#widget` or `~renderNote`, is saved with a `disabled:` prefix (for example `#disabled:widget`), the same way a safe import disables it (see <a class="reference-link" href="Basic%20Concepts%20and%20Features/Active%20content.md">Active content</a>). The AI tells you which note it is on; review the code, then enable it with the toggle next to the active content badge beside the note's title or, for a <a class="reference-link" href="Note%20Types/Render%20Note.md">Render Note</a>, the _Enable render note_ button in the note.* Delete an attribute.* At tree level:* Get the direct children of a note.diff --git a/packages/trilium-core/src/assets/llm/skills/dashboards.md b/packages/trilium-core/src/assets/llm/skills/dashboards.mdindex 0ed6fb8f25..9f3177df36 100644--- a/packages/trilium-core/src/assets/llm/skills/dashboards.md+++ b/packages/trilium-core/src/assets/llm/skills/dashboards.md@@ -30,7 +30,7 @@ For widgets that compute something, fetch data, or respond to clicks, use a rend1. Create a note of type `render` as a **child of the dashboard** — this is the widget.2. Create a `code` note with mime `text/jsx` as a **child of the render note**, exporting a default component.-3. Call `set_attribute` on the render note with the relation `renderNote` pointing to the JSX note. Because it enables code execution, it is saved as `~disabled:renderNote` and the widget stays inactive until the user activates it. Tell the user exactly what to do, e.g.: "Open the widget note '<render note title>', review '<JSX note title>', then in the attribute area rename `~disabled:renderNote` to `~renderNote`."+3. Call `set_attribute` on the render note with the relation `renderNote` pointing to the JSX note. Because it enables code execution, it is saved as `~disabled:renderNote` and the widget stays inactive until the user enables it. Tell the user exactly what to do, e.g.: "Review '<JSX note title>', then open the widget note '<render note title>' and press **Enable render note**."JSX rules (load the `frontend_scripting` skill for the full API):@@ -76,7 +76,7 @@ export default function RecentNotesWidget() {## Anti-patterns (do NOT do this)- ❌ Putting the JSX code note directly under the dashboard — it would render as a code widget showing its own source. The JSX note belongs under the render note.-- ❌ Telling the user the widget is ready after setting `~renderNote` — it is saved as `~disabled:renderNote` and renders nothing until the user removes the `disabled:` prefix.+- ❌ Telling the user the widget is ready after setting `~renderNote` — it is saved as `~disabled:renderNote` and renders nothing until the user enables it.- ❌ Directing the user to set `~renderNote` on the dashboard note itself — it belongs on the `render`-type child.- ❌ Trying to write the `dashboard.json` attachment (or any view configuration) to lay out widgets — attachments cannot be modified by tools, and the dashboard picks up new widgets automatically; rely on auto-placement.- ❌ Using `getActiveContextNote()` inside a widget's JSX to get "this widget's note" — when the dashboard is open, the active note is the dashboard, not the widget. Use `originEntity` (the render note) instead.diff --git a/packages/trilium-core/src/assets/llm/skills/frontend_scripting.md b/packages/trilium-core/src/assets/llm/skills/frontend_scripting.mdindex 16d7eae26b..6aec7a71d9 100644--- a/packages/trilium-core/src/assets/llm/skills/frontend_scripting.md+++ b/packages/trilium-core/src/assets/llm/skills/frontend_scripting.md@@ -12,7 +12,7 @@ CRITICAL: In JSX notes, always use top-level `import` statements (e.g. `import {2. Add `#widget` label for widgets, or `#run=frontendStartup` for auto-run scripts.3. For mobile, use `#run=mobileStartup` instead.-NOTE: `#widget`, `#run` and `~renderNote` enable code execution, so `set_attribute` saves them with a `disabled:` prefix (`#disabled:widget`, `#disabled:run`, `~disabled:renderNote`) and they stay inactive. Set them anyway, then tell the user which note to open and that, once they have reviewed the code, they activate it by removing the `disabled:` prefix in its attribute area.+NOTE: `#widget`, `#run` and `~renderNote` enable code execution, so `set_attribute` saves them with a `disabled:` prefix (`#disabled:widget`, `#disabled:run`, `~disabled:renderNote`) and they stay inactive. Set them anyway, then tell the user which note to open and how to enable it once they have reviewed the code: a script or widget note has a toggle next to the badge beside its title; a render note shows an **Enable render note** button.## Script types@@ -128,7 +128,7 @@ import { ActionButton, Button, LinkButton, Modal,For rendering custom content inside a note:1. Create a "render note" (type: Render Note) where you want the content to appear.2. Create a JSX code note **as a child** of the render note, exporting a default component.-3. Set a `~renderNote` relation on the render note pointing to the child JSX note. It is saved as `~disabled:renderNote`, so ask the user to remove the `disabled:` prefix to activate it.+3. Set a `~renderNote` relation on the render note pointing to the child JSX note. It is saved as `~disabled:renderNote`, so ask the user to open the render note and press **Enable render note**.IMPORTANT: Always create the JSX code note as a child of the render note, not as a sibling or at the root. This keeps them organized together.diff --git a/packages/trilium-core/src/services/llm/tools/attribute_tools.ts b/packages/trilium-core/src/services/llm/tools/attribute_tools.tsindex 787eb5f8cc..79246ac428 100644--- a/packages/trilium-core/src/services/llm/tools/attribute_tools.ts+++ b/packages/trilium-core/src/services/llm/tools/attribute_tools.ts@@ -56,7 +56,7 @@ export const attributeTools = defineTools({},set_attribute: {- description: "Add or update an attribute on a note. If an attribute with the same type and name exists, it is updated; otherwise a new one is created. Use type 'label' for text values, 'relation' for linking to another note (value must be a noteId). Attributes that run code (such as #run, #widget, ~renderNote) are saved with a 'disabled:' prefix (e.g. #disabled:run) and stay inactive until the user reviews the code and removes the prefix; when that happens, tell the user which note to open and which attribute to rename.",+ description: "Add or update an attribute on a note. If an attribute with the same type and name exists, it is updated; otherwise a new one is created. Use type 'label' for text values, 'relation' for linking to another note (value must be a noteId). Attributes that run code (such as #run, #widget, ~renderNote) are saved with a 'disabled:' prefix (e.g. #disabled:run) and stay inactive until the user enables them; when that happens, tell the user which note to open and how to enable it (the reply says how).",inputSchema: z.object({noteId: z.string().describe("The ID of the note"),type: z.enum(["label", "relation"]).describe("The attribute type"),@@ -89,7 +89,8 @@ export const attributeTools = defineTools({value,disabled: true,message: `${sigil}${name.trim()} can run code, so it was saved as ${sigil}${disabledName} and is inactive. `- + `Tell the user to review the code and, if they trust it, remove the "disabled:" prefix from the attribute to activate it.`+ + `Tell the user which note to open and to enable it there once they have reviewed the code: `+ + `a render note shows an "Enable render note" button, other notes a toggle next to the badge beside the note title.`};}