feat: add daily note target database setting - #18550
Open
eloklam wants to merge 7 commits into
Open
Conversation
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>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
eloklam
marked this pull request as ready for review
August 5, 2026 12:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: addDailyNoteDatabaseIDfield toBoxConf(persisted in the notebook's.siyuan/conf.json), default empty.kernel/model/file.go: inCreateDailyNote, after a new daily note doc is created, ifDailyNoteDatabaseIDis set, resolve the AV id from the stored database block id and add the doc as a row viaAddAttributeViewBlock. 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: preserveDailyNoteDatabaseIDwhen importing notebook conf from.sy.zip.kernel/api/notebook.go:setNotebookConfaccepts 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: adddailyNoteDatabaseId,dailyNoteDatabaseIdHint,dailyNoteDatabasePickstrings.scripts/dailynote-database-smoke.mjs: smoke test covering row insertion, idempotency, and unset-setting behaviour.Changes (zh-CN)
kernel/conf/box.go:BoxConf新增DailyNoteDatabaseID字段(持久化到笔记本.siyuan/conf.json),默认空。kernel/model/file.go:CreateDailyNote创建新日记后,若配置了DailyNoteDatabaseID,从数据库块 ID 解析 AV id 并通过AddAttributeViewBlock将文档作为行加入。尽力而为:任何失败仅记录警告,不影响日记创建。幂等(仅在新建分支执行,并有已绑定预检查)。kernel/model/import.go:从.sy.zip导入笔记本配置时保留DailyNoteDatabaseID。kernel/api/notebook.go:setNotebookConf接受并去除该字段首尾空白(允许为空,宽松校验)。app/src/menus/onGetnotebookconf.ts:笔记本设置对话框新增「目标数据库(属性视图)」行:显示当前所选数据库名称/路径(或块 ID),并提供「选择数据库…」按钮打开选择器,列出所有数据库(/api/av/searchAttributeView),含「清空」项可禁用。app/appearance/langs/{en,zh-CN,zh-TW}.json:新增dailyNoteDatabaseId、dailyNoteDatabaseIdHint、dailyNoteDatabasePick文案。scripts/dailynote-database-smoke.mjs:覆盖行插入、幂等性、未设置行为的冒烟测试。How it was verified (EN)
CGO_ENABLED=1 go build -tags "fts5 sqlcipher" -o /tmp/siyuan-dbadd-kernel/SiYuan-Kernel .— success.cd app && corepack pnpm run build:desktop— webpack compiled successfully (only pre-existing size warnings).node scripts/dailynote-database-smoke.mjs, isolated temp workspace, fresh port, lang zh-TW):setNotebookConfpersistsdailyNoteDatabaseIDcreateDailyNote→ exactly 1 row, bound to the new note doccreateDailyNote(same day) → same doc, still 1 row, same itemID (idempotent)SMOKE_TEST_OK: dailyNoteDatabaseID feature verifiedHow 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。