Skip to content

Build your personal knowledge base with Trilium Notes

feat(ai): reinforce lack of permission for creating render notes

Elian Doranf44ee34b2dce
diff --git a/apps/server/src/assets/llm/skills/dashboards.md b/apps/server/src/assets/llm/skills/dashboards.md
index 92cc36863f..2867afad73 100644
--- a/apps/server/src/assets/llm/skills/dashboards.md
+++ b/apps/server/src/assets/llm/skills/dashboards.md
@@ -28,7 +28,7 @@ For widgets that compute something, fetch data, or respond to clicks, use a rend
1. 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. On the render note, set a `~renderNote` relation pointing to the JSX note (`set_attribute` with type `relation`, name `renderNote`, value = the JSX note's ID).
+3. Ask the user to activate the widget by adding a `~renderNote` relation on the render note pointing to the JSX note. You CANNOT set this relation yourself — it enables code execution, so `set_attribute` refuses it as dangerous. Tell the user exactly what to do, e.g.: "Open the widget note '<render note title>', click the attribute area at the top, and add `~renderNote` pointing to '<JSX note title>'." Mention which JSX note to target by title.
JSX rules (load the `frontend_scripting` skill for the full API):
@@ -74,6 +74,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.
-- ❌ Setting `~renderNote` on the dashboard note itself — it belongs on the `render`-type child.
+- ❌ Calling `set_attribute` with `~renderNote` — it will be rejected as dangerous. Ask the user to add the relation instead.
+- ❌ Directing the user to set `~renderNote` on the dashboard note itself — it belongs on the `render`-type child.
- ❌ Writing the `dashboard.json` attachment to lay out widgets — the UI owns it; rely on auto-placement.
- ❌ Setting `#viewType=dashboard` on a `text` note — the view type only applies to `book` (and search) notes.
diff --git a/apps/server/src/assets/llm/skills/frontend_scripting.md b/apps/server/src/assets/llm/skills/frontend_scripting.md
index 40edd4dff7..ddece2f525 100644
--- a/apps/server/src/assets/llm/skills/frontend_scripting.md
+++ b/apps/server/src/assets/llm/skills/frontend_scripting.md
@@ -12,6 +12,8 @@ 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` refuses them as dangerous. Create the code note yourself, then ask the user to add the activating attribute, telling them exactly which note to open and what to type into its attribute area.
+
## Script types
| Type | Language | Required attribute |
@@ -125,7 +127,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. On the render note, add a `~renderNote` relation pointing to the child JSX note.
+3. Ask the user to add a `~renderNote` relation on the render note pointing to the child JSX note (you cannot set this dangerous attribute yourself).
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.