Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(notebooks): keep default notebooks on the shared slate icon

tianma-iff45fc2ecb416
diff --git a/apps/api/src/demo-seed-data.ts b/apps/api/src/demo-seed-data.ts
index 50c25d95..aa59f117 100644
--- a/apps/api/src/demo-seed-data.ts
+++ b/apps/api/src/demo-seed-data.ts
@@ -18,13 +18,13 @@ import {
export { decodeDemoAttachment };
export const DEMO_SEED_NOTEBOOKS = [
- { id: "nb_inbox", parentId: null, name: "等待分类", slug: "inbox", icon: "notebook", color: "#0f766e", sortOrder: 10 },
- { id: "nb_projects", parentId: null, name: "工作项目", slug: "work-projects", icon: "notebook", color: "#2563eb", sortOrder: 20 },
- { id: "nb_learning", parentId: null, name: "学习资料", slug: "learning-resources", icon: "notebook", color: "#7c3aed", sortOrder: 30 },
- { id: "nb_creative", parentId: null, name: "灵感创作", slug: "creative-ideas", icon: "notebook", color: "#db2777", sortOrder: 40 },
- { id: "nb_personal", parentId: null, name: "生活个人", slug: "personal-life", icon: "notebook", color: "#ea580c", sortOrder: 50 },
- { id: "nb_demo_features", parentId: "nb_projects", name: "功能演示", slug: "demo-features", icon: "notebook", color: "#0891b2", sortOrder: 21 },
- { id: "nb_demo_features_en", parentId: "nb_projects", name: "Feature Demos", slug: "feature-demos", icon: "notebook", color: "#0e7490", sortOrder: 22 },
+ { id: "nb_inbox", parentId: null, name: "等待分类", slug: "inbox", icon: "notebook", color: null, sortOrder: 10 },
+ { id: "nb_projects", parentId: null, name: "工作项目", slug: "work-projects", icon: "notebook", color: null, sortOrder: 20 },
+ { id: "nb_learning", parentId: null, name: "学习资料", slug: "learning-resources", icon: "notebook", color: null, sortOrder: 30 },
+ { id: "nb_creative", parentId: null, name: "灵感创作", slug: "creative-ideas", icon: "notebook", color: null, sortOrder: 40 },
+ { id: "nb_personal", parentId: null, name: "生活个人", slug: "personal-life", icon: "notebook", color: null, sortOrder: 50 },
+ { id: "nb_demo_features", parentId: "nb_projects", name: "功能演示", slug: "demo-features", icon: "notebook", color: null, sortOrder: 21 },
+ { id: "nb_demo_features_en", parentId: "nb_projects", name: "Feature Demos", slug: "feature-demos", icon: "notebook", color: null, sortOrder: 22 },
];
export const DEMO_ARCHITECTURE_DIAGRAM_ZH: DiagramDocument = {
diff --git a/apps/api/src/notebook-default-color-migration.test.mjs b/apps/api/src/notebook-default-color-migration.test.mjs
new file mode 100644
index 00000000..f632aea9
--- /dev/null
+++ b/apps/api/src/notebook-default-color-migration.test.mjs
@@ -0,0 +1,43 @@
+import { describe, expect, test } from "bun:test";
+import { Database } from "bun:sqlite";
+import { globSync, readFileSync } from "node:fs";
+
+const applyMigrations = (sqlite, predicate) => {
+ for (const file of globSync("migrations/*.sql").sort().filter(predicate)) {
+ sqlite.exec(readFileSync(file, "utf8"));
+ }
+};
+
+describe("default notebook colors", () => {
+ test("clears untouched factory hues and keeps a saved appearance", () => {
+ const sqlite = new Database(":memory:");
+ try {
+ sqlite.exec("PRAGMA foreign_keys = ON");
+ applyMigrations(sqlite, (file) => file.split("/").at(-1) < "0078");
+ sqlite.exec(`
+ UPDATE notebooks SET icon = 'star', color = '#2563eb' WHERE slug = 'work-projects';
+ UPDATE notebooks SET is_bold = 1 WHERE slug = 'learning-resources';
+ INSERT INTO notebooks (id, workspace_id, parent_id, name, slug, icon, color, sort_order)
+ VALUES
+ ('nb_demo_features', 'ws_default', 'nb_projects', '功能演示', 'demo-features', 'notebook', '#0891b2', 21),
+ ('nb_trips', 'ws_default', NULL, 'Trips', 'trips', 'notebook', '#2563eb', 60),
+ ('nb_custom_inbox', 'ws_other', NULL, 'Inbox', 'inbox', 'notebook', '#112233', 10);
+ `);
+
+ sqlite.exec(readFileSync("migrations/0078_clear_default_notebook_colors.sql", "utf8"));
+
+ const colorOf = (id) => sqlite.query("SELECT color FROM notebooks WHERE id = ?").get(id).color;
+ expect(colorOf("nb_inbox")).toBeNull();
+ expect(colorOf("nb_personal")).toBeNull();
+ expect(colorOf("nb_creative")).toBeNull();
+ expect(colorOf("nb_demo_features")).toBeNull();
+ expect(colorOf("nb_projects")).toBe("#2563eb");
+ expect(colorOf("nb_learning")).toBe("#7c3aed");
+ expect(colorOf("nb_trips")).toBe("#2563eb");
+ expect(colorOf("nb_custom_inbox")).toBe("#112233");
+ expect(sqlite.query("PRAGMA foreign_key_check").all()).toEqual([]);
+ } finally {
+ sqlite.close();
+ }
+ });
+});
diff --git a/apps/api/src/workspace-provisioning.ts b/apps/api/src/workspace-provisioning.ts
index 5a4878be..4644cdda 100644
--- a/apps/api/src/workspace-provisioning.ts
+++ b/apps/api/src/workspace-provisioning.ts
@@ -45,7 +45,7 @@ export type DefaultNotebookRow = {
id: string;
name: string;
slug: string;
- color: string;
+ color: string | null;
sortOrder: number;
};
diff --git a/migrations/0078_clear_default_notebook_colors.sql b/migrations/0078_clear_default_notebook_colors.sql
new file mode 100644
index 00000000..85c8ba86
--- /dev/null
+++ b/migrations/0078_clear_default_notebook_colors.sql
@@ -0,0 +1,23 @@
+-- Notebook colors shipped with the original seeds, but the sidebar ignored
+-- them until appearance rendering. Clear only those untouched factory hues so
+-- default notebooks return to the shared slate icon. A saved appearance keeps
+-- its color, including a factory hue chosen again on a customized notebook.
+UPDATE notebooks
+SET
+ color = NULL,
+ updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
+WHERE (icon IS NULL OR icon = 'notebook')
+ AND text_color IS NULL
+ AND is_bold = 0
+ AND icon_inverted = 0
+ AND row_inverted = 0
+ AND color_target = 'icon'
+ AND (
+ (slug = 'inbox' AND lower(color) = '#0f766e')
+ OR (slug = 'work-projects' AND lower(color) = '#2563eb')
+ OR (slug = 'learning-resources' AND lower(color) = '#7c3aed')
+ OR (slug = 'creative-ideas' AND lower(color) = '#db2777')
+ OR (slug = 'personal-life' AND lower(color) = '#ea580c')
+ OR (slug = 'demo-features' AND lower(color) = '#0891b2')
+ OR (slug = 'feature-demos' AND lower(color) = '#0e7490')
+ );
diff --git a/packages/shared/src/default-workspace-seeds.ts b/packages/shared/src/default-workspace-seeds.ts
index 4ec0ef7e..b57a14e6 100644
--- a/packages/shared/src/default-workspace-seeds.ts
+++ b/packages/shared/src/default-workspace-seeds.ts
@@ -3,46 +3,48 @@ import { resolveSupportedLocale, type SupportedLocale } from "./i18n/locales";
export type DefaultNotebookSeed = {
key: "inbox" | "projects" | "learning" | "creative" | "personal";
slug: string;
- color: string;
+ color: string | null;
sortOrder: number;
names: Record<SupportedLocale, string>;
};
// zh-CN is the language the installation migrations seed. Keep it first so
// the localization guard can recognise names that nobody has changed yet.
+// color stays null so the sidebar uses the shared slate icon. A hue is stored
+// only after someone saves an appearance.
export const DEFAULT_NOTEBOOK_SEEDS: readonly DefaultNotebookSeed[] = [
{
key: "inbox",
slug: "inbox",
- color: "#0f766e",
+ color: null,
sortOrder: 10,
names: { "zh-CN": "等待分类", "en-US": "Inbox", ja: "受信トレイ", pl: "Skrzynka", ru: "Входящие" },
},
{
key: "projects",
slug: "work-projects",
- color: "#2563eb",
+ color: null,
sortOrder: 20,
names: { "zh-CN": "工作项目", "en-US": "Work Projects", ja: "仕事のプロジェクト", pl: "Projekty zawodowe", ru: "Рабочие проекты" },
},
{
key: "learning",
slug: "learning-resources",
- color: "#7c3aed",
+ color: null,
sortOrder: 30,
names: { "zh-CN": "学习资料", "en-US": "Learning Resources", ja: "学習資料", pl: "Materiały do nauki", ru: "Учебные материалы" },
},
{
key: "creative",
slug: "creative-ideas",
- color: "#db2777",
+ color: null,
sortOrder: 40,
names: { "zh-CN": "灵感创作", "en-US": "Creative Ideas", ja: "アイデアと創作", pl: "Pomysły i twórczość", ru: "Творческие идеи" },
},
{
key: "personal",
slug: "personal-life",
- color: "#ea580c",
+ color: null,
sortOrder: 50,
names: { "zh-CN": "生活个人", "en-US": "Personal Life", ja: "暮らしと個人", pl: "Życie prywatne", ru: "Личная жизнь" },
},