From 5b3fb315d771b4ec66604194480a3c1955e81edb Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 27 Mar 2026 19:16:23 +0200 Subject: [PATCH] fix(core): on new database, opening hidden notes instead of the root --- packages/trilium-core/src/services/sql_init.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/trilium-core/src/services/sql_init.ts b/packages/trilium-core/src/services/sql_init.ts index 758549f144..29654cf97c 100644 --- a/packages/trilium-core/src/services/sql_init.ts +++ b/packages/trilium-core/src/services/sql_init.ts @@ -192,13 +192,13 @@ async function createInitialDatabase(skipDemoDb?: boolean) { } } - // Post-demo. + // Post-demo: pick the first visible (non-system) child of root as the start note. + // System notes have IDs starting with "_" and should not be navigated to on startup. + // Falls back to "root" if no visible child exists (e.g. empty database). sql.transactional(() => { - // this needs to happen after ZIP import, - // the previous solution was to move option initialization here, but then the important parts of initialization - // are not all in one transaction (because ZIP import is async and thus not transactional) - - const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition"); + const startNoteId = sql.getValue( + "SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 AND substr(noteId, 1, 1) != '_' ORDER BY notePosition" + ) ?? "root"; optionService.setOption( "openNoteContexts",