Skip to content

feat: add daily note target database setting - #18550

Open
eloklam wants to merge 7 commits into
siyuan-note:devfrom
eloklam:feat/daily-note-db-add
Open

feat: add daily note target database setting#18550
eloklam wants to merge 7 commits into
siyuan-note:devfrom
eloklam:feat/daily-note-db-add

Conversation

@eloklam

@eloklam eloklam commented Aug 4, 2026

Copy link
Copy Markdown

Summary (EN)

Adds an optional per-notebook setting dailyNoteDatabaseID: when a NEW daily note is created for that notebook, the newly created daily note document is automatically added as a row to the configured target database (Attribute View). Existing daily notes are never re-added (idempotent), and an empty setting keeps the current behaviour unchanged. The notebook settings dialog gains a block picker so the target database is chosen from the list of existing databases rather than typed manually.

Summary (zh-CN)

新增可选的笔记本级设置 dailyNoteDatabaseID:当该笔记本创建新的日记时,自动将新建的日记文档作为一行添加到配置的目标数据库(属性视图)中。已存在的日记不会被重复添加(幂等),设置为空时保持原有行为不变。笔记本设置对话框新增块选择器,可从已有数据库列表中选择目标数据库,无需手动输入 ID。


Changes (EN)

  • kernel/conf/box.go: add DailyNoteDatabaseID field to BoxConf (persisted in the notebook's .siyuan/conf.json), default empty.
  • kernel/model/file.go: in CreateDailyNote, after a new daily note doc is created, if DailyNoteDatabaseID is set, resolve the AV id from the stored database block id and add the doc as a row via AddAttributeViewBlock. Best-effort: any failure only logs a warning and never fails daily note creation. Idempotent (only the newly-created branch runs, plus a bound-item pre-check).
  • kernel/model/import.go: preserve DailyNoteDatabaseID when importing notebook conf from .sy.zip.
  • kernel/api/notebook.go: setNotebookConf accepts and trims the new field (empty allowed, permissive validation).
  • app/src/menus/onGetnotebookconf.ts: extend the notebook settings dialog with a "Target database (Attribute View)" row: shows the currently selected database name/path (or block id) and a "Select database…" button opening a picker listing all databases (/api/av/searchAttributeView), including a "Clear" entry to disable.
  • app/appearance/langs/{en,zh-CN,zh-TW}.json: add dailyNoteDatabaseId, dailyNoteDatabaseIdHint, dailyNoteDatabasePick strings.
  • scripts/dailynote-database-smoke.mjs: smoke test covering row insertion, idempotency, and unset-setting behaviour.

Changes (zh-CN)

  • kernel/conf/box.goBoxConf 新增 DailyNoteDatabaseID 字段(持久化到笔记本 .siyuan/conf.json),默认空。
  • kernel/model/file.goCreateDailyNote 创建新日记后,若配置了 DailyNoteDatabaseID,从数据库块 ID 解析 AV id 并通过 AddAttributeViewBlock 将文档作为行加入。尽力而为:任何失败仅记录警告,不影响日记创建。幂等(仅在新建分支执行,并有已绑定预检查)。
  • kernel/model/import.go:从 .sy.zip 导入笔记本配置时保留 DailyNoteDatabaseID
  • kernel/api/notebook.gosetNotebookConf 接受并去除该字段首尾空白(允许为空,宽松校验)。
  • app/src/menus/onGetnotebookconf.ts:笔记本设置对话框新增「目标数据库(属性视图)」行:显示当前所选数据库名称/路径(或块 ID),并提供「选择数据库…」按钮打开选择器,列出所有数据库(/api/av/searchAttributeView),含「清空」项可禁用。
  • app/appearance/langs/{en,zh-CN,zh-TW}.json:新增 dailyNoteDatabaseIddailyNoteDatabaseIdHintdailyNoteDatabasePick 文案。
  • scripts/dailynote-database-smoke.mjs:覆盖行插入、幂等性、未设置行为的冒烟测试。

How it was verified (EN)

  • Kernel: CGO_ENABLED=1 go build -tags "fts5 sqlcipher" -o /tmp/siyuan-dbadd-kernel/SiYuan-Kernel . — success.
  • Frontend: cd app && corepack pnpm run build:desktop — webpack compiled successfully (only pre-existing size warnings).
  • Smoke (node scripts/dailynote-database-smoke.mjs, isolated temp workspace, fresh port, lang zh-TW):
    1. initial AV rowCount = 0
    2. setNotebookConf persists dailyNoteDatabaseID
    3. 1st createDailyNote → exactly 1 row, bound to the new note doc
    4. 2nd createDailyNote (same day) → same doc, still 1 row, same itemID (idempotent)
    5. notebook without the setting → daily note created normally
    • Result: SMOKE_TEST_OK: dailyNoteDatabaseID feature verified

How it was verified (zh-CN)

  • 内核:CGO_ENABLED=1 go build -tags "fts5 sqlcipher" -o /tmp/siyuan-dbadd-kernel/SiYuan-Kernel . — 成功。
  • 前端:cd app && corepack pnpm run build:desktop — webpack 编译成功(仅原有体积警告)。
  • 冒烟测试(node scripts/dailynote-database-smoke.mjs,隔离临时工作空间、独立端口、zh-TW):初始 0 行 → 设置持久化 → 首次创建日记恰好 1 行且绑定新文档 → 同日再次创建仍 1 行且 itemID 不变(幂等)→ 未设置时行为不变。结果:SMOKE_TEST_OK

eloklam and others added 7 commits August 4, 2026 13:20
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
@eloklam
eloklam marked this pull request as ready for review August 5, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant