An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Persist incomplete selection notification preference https://github.com/siyuan-note/siyuan/issues/19452
Daniel54936453883b
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.tsindex a2b4eae00c..29688af4e5 100644--- a/app/src/types/api/index.d.ts+++ b/app/src/types/api/index.d.ts@@ -126,7 +126,7 @@ export type BazaarLocalInstallError = { "minAppVersion": string; "packageName":export type BazaarLocalInstallResult = (BazaarLocalInstallData & { "reason"?: never; }) | (BazaarLocalInstallError & { "updated"?: never; });-export type BazaarNotifications = { "browserCompatibility": boolean; "docTreeMaxList": boolean; "formatPainterTip"?: boolean; "selectAllTip"?: boolean; "tagMaxList": boolean; "workspaceNotSSD": boolean; };+export type BazaarNotifications = { "browserCompatibility": boolean; "docTreeMaxList": boolean; "formatPainterTip"?: boolean; "selectAllIncompleteTip"?: boolean; "selectAllTip"?: boolean; "tagMaxList": boolean; "workspaceNotSSD": boolean; };export type BazaarPackage = { "alternatives"?: Array<string>; "author": string; "backends": Array<string> | null; "bazaarIncompatible"?: boolean; "bootAppearances"?: Array<string>; "current": boolean; "deprecated"?: boolean; "deprecatedReason"?: Record<string, string>; "description": Record<string, string> | null; "disabledInPublish": boolean; "disallowInstall": boolean; "disallowUpdate": boolean; "displayName": Record<string, string> | null; "downloads": number; "enabled"?: boolean; "frontends": Array<string> | null; "funding": BazaarFunding | null; "hInstallDate": string; "hInstallSize": string; "hSize": string; "hUpdated": string; "hasStorageData"?: boolean; "icon"?: string; "iconURL": string; "installSize": number; "installTime": number; "installed": boolean; "installedIncompatible"?: boolean; "invalidReason"?: "missing-manifest" | "invalid-manifest" | "name-mismatch"; "kernels": Array<string> | null; "keywords": Array<string> | null; "minAppVersion": string; "modes"?: Array<string> | null; "name": string; "openIssues": number; "outdated": boolean; "preferredDeprecatedReason"?: string; "preferredDesc": string; "preferredFunding": string; "preferredName": string; "preferredReadme": string; "preview"?: string; "previewURL": string; "rating"?: BazaarPackageRating; "ratingAvailable": boolean; "readme": Record<string, string> | null; "repoHash": string; "repoRef"?: string; "repoURL": string; "size": number; "stars": number; "updateRequiredMinAppVer"?: string; "updateTime": number; "updated": string; "url": string; "userDisabledInPublish"?: boolean; "version": string; };diff --git a/kernel/api/appearance_notifications_test.go b/kernel/api/appearance_notifications_test.gonew file mode 100644index 0000000000..6e74b95c08--- /dev/null+++ b/kernel/api/appearance_notifications_test.go@@ -0,0 +1,72 @@+package api++import (+ "encoding/json"+ "os"+ "regexp"+ "testing"++ "github.com/siyuan-note/siyuan/kernel/util"+)++func TestAPIContractAppearanceNotifications(t *testing.T) {+ defaults := util.NewNotifications()+ if defaults.SelectAllIncompleteTip == nil || !*defaults.SelectAllIncompleteTip {+ t.Fatal("incomplete selection tip should default to enabled")+ }+ for _, value := range []string{"true", "false", "null"} {+ var config struct {+ Notifications *util.Notifications `json:"notifications"`+ }+ if err := json.Unmarshal([]byte(`{"notifications":{"selectAllIncompleteTip":`+value+`}}`), &config); err != nil {+ t.Fatal(err)+ }+ data, err := json.Marshal(config)+ if err != nil {+ t.Fatal(err)+ }+ if err = json.Unmarshal(data, &config); err != nil {+ t.Fatal(err)+ }+ got := config.Notifications.SelectAllIncompleteTip+ if value == "null" {+ if got != nil {+ t.Fatal("null should preserve the default-enabled fallback")+ }+ } else if got == nil || *got != (value == "true") {+ t.Fatalf("notification preference lost after round trip: %s", data)+ }+ if bazaarNotifications(config.Notifications).SelectAllIncompleteTip != got {+ t.Fatal("bazaar response lost notification preference")+ }+ }+ var legacy util.Notifications+ if err := json.Unmarshal([]byte(`{"selectAllTip":false}`), &legacy); err != nil {+ t.Fatal(err)+ }+ if legacy.SelectAllIncompleteTip != nil {+ t.Fatal("legacy config should retain the default-enabled fallback")+ }++ source, err := os.ReadFile("../../app/src/config/tabs/appearanceTab.ts")+ if err != nil {+ t.Fatal(err)+ }+ items := regexp.MustCompile(`(?s)const NOTIFICATIONS_ITEMS.*?= \[(.*?)\];`).FindSubmatch(source)+ if len(items) != 2 {+ t.Fatal("notification catalog not found")+ }+ data, err := json.Marshal(defaults)+ if err != nil {+ t.Fatal(err)+ }+ var fields map[string]bool+ if err = json.Unmarshal(data, &fields); err != nil {+ t.Fatal(err)+ }+ for _, match := range regexp.MustCompile(`field: "([^"]+)"`).FindAllSubmatch(items[1], -1) {+ if enabled, exists := fields[string(match[1])]; !exists || !enabled {+ t.Errorf("frontend notification %s lacks an enabled persistence default", match[1])+ }+ }+}diff --git a/kernel/api/bazaar.go b/kernel/api/bazaar.goindex f6eda61cca..17e266e639 100644--- a/kernel/api/bazaar.go+++ b/kernel/api/bazaar.go@@ -706,6 +706,7 @@ func bazaarNotifications(value *util.Notifications) *apicontract.BazaarNotificatret.WorkspaceNotSSD = value.WorkspaceNotSSDret.BrowserCompatibility = value.BrowserCompatibilityret.SelectAllTip = value.SelectAllTip+ ret.SelectAllIncompleteTip = value.SelectAllIncompleteTipret.FormatPainterTip = value.FormatPainterTipreturn ret}diff --git a/kernel/apicontract/bazaar.go b/kernel/apicontract/bazaar.goindex 551ab8da28..562d303612 100644--- a/kernel/apicontract/bazaar.go+++ b/kernel/apicontract/bazaar.go@@ -358,12 +358,13 @@ type BazaarStatusBar struct {MsgDataSyncDisabled bool `json:"msgDataSyncDisabled"`}type BazaarNotifications struct {- DocTreeMaxList bool `json:"docTreeMaxList"` // 文档面板展开上限提示,默认启用- TagMaxList bool `json:"tagMaxList"` // 标签面板展开上限提示,默认启用- WorkspaceNotSSD bool `json:"workspaceNotSSD"` // 工作空间未放置在固态硬盘警告,默认启用- BrowserCompatibility bool `json:"browserCompatibility"` // 浏览器兼容性提示,默认启用- SelectAllTip *bool `json:"selectAllTip,omitempty"` // 编辑器全选提示,nil 时默认启用- FormatPainterTip *bool `json:"formatPainterTip,omitempty"` // 格式刷启用和退出提示,nil 时默认启用+ DocTreeMaxList bool `json:"docTreeMaxList"` // 文档面板展开上限提示,默认启用+ TagMaxList bool `json:"tagMaxList"` // 标签面板展开上限提示,默认启用+ WorkspaceNotSSD bool `json:"workspaceNotSSD"` // 工作空间未放置在固态硬盘警告,默认启用+ BrowserCompatibility bool `json:"browserCompatibility"` // 浏览器兼容性提示,默认启用+ SelectAllTip *bool `json:"selectAllTip,omitempty"` // 编辑器全选提示,nil 时默认启用+ SelectAllIncompleteTip *bool `json:"selectAllIncompleteTip,omitempty"` // 编辑器全选不完整提示,nil 时默认启用+ FormatPainterTip *bool `json:"formatPainterTip,omitempty"` // 格式刷启用和退出提示,nil 时默认启用}type BazaarRatingResult struct {success *BazaarRatingDatadiff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.jsonindex ac12ae683f..fffb8e2c1f 100644--- a/kernel/apicontract/schema.json+++ b/kernel/apicontract/schema.json@@ -2065,6 +2065,9 @@"formatPainterTip": {"type": "boolean"},+ "selectAllIncompleteTip": {+ "type": "boolean"+ },"selectAllTip": {"type": "boolean"},diff --git a/kernel/util/appearance.go b/kernel/util/appearance.goindex a1ed9dff32..fd7218fd02 100644--- a/kernel/util/appearance.go+++ b/kernel/util/appearance.go@@ -61,23 +61,25 @@ var StatusBarCfg *StatusBar// Notifications 外观通知开关配置。https://github.com/siyuan-note/siyuan/issues/17797// Appearance.Notifications 为 nil 时表示旧配置尚未迁移,整体按默认启用处理。type Notifications struct {- DocTreeMaxList bool `json:"docTreeMaxList"` // 文档面板展开上限提示,默认启用- TagMaxList bool `json:"tagMaxList"` // 标签面板展开上限提示,默认启用- WorkspaceNotSSD bool `json:"workspaceNotSSD"` // 工作空间未放置在固态硬盘警告,默认启用- BrowserCompatibility bool `json:"browserCompatibility"` // 浏览器兼容性提示,默认启用- SelectAllTip *bool `json:"selectAllTip,omitempty"` // 编辑器全选提示,nil 时默认启用- FormatPainterTip *bool `json:"formatPainterTip,omitempty"` // 格式刷启用和退出提示,nil 时默认启用+ DocTreeMaxList bool `json:"docTreeMaxList"` // 文档面板展开上限提示,默认启用+ TagMaxList bool `json:"tagMaxList"` // 标签面板展开上限提示,默认启用+ WorkspaceNotSSD bool `json:"workspaceNotSSD"` // 工作空间未放置在固态硬盘警告,默认启用+ BrowserCompatibility bool `json:"browserCompatibility"` // 浏览器兼容性提示,默认启用+ SelectAllTip *bool `json:"selectAllTip,omitempty"` // 编辑器全选提示,nil 时默认启用+ SelectAllIncompleteTip *bool `json:"selectAllIncompleteTip,omitempty"` // 编辑器全选不完整提示,nil 时默认启用+ FormatPainterTip *bool `json:"formatPainterTip,omitempty"` // 格式刷启用和退出提示,nil 时默认启用}// NewNotifications 创建默认全部启用的通知配置。新增内置通知时在此统一调整默认值,避免多处分散。func NewNotifications() *Notifications {return &Notifications{- DocTreeMaxList: true,- TagMaxList: true,- WorkspaceNotSSD: true,- BrowserCompatibility: true,- SelectAllTip: new(true),- FormatPainterTip: new(true),+ DocTreeMaxList: true,+ TagMaxList: true,+ WorkspaceNotSSD: true,+ BrowserCompatibility: true,+ SelectAllTip: new(true),+ SelectAllIncompleteTip: new(true),+ FormatPainterTip: new(true),}}