An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
Add error details to the abnormal status pop-up window (#17465)
Jeffrey Chene9a2dc2e4d2c
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 9d18f61df2..7519c24ef0 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -378,14 +378,17 @@ export const exitSiYuan = async (setCurrentWorkspace = true) => {});};-export const transactionError = () => {+export const transactionError = (msg?: string) => {if (document.getElementById("transactionError")) {return;}const dialog = new Dialog({disableClose: true,title: `${window.siyuan.languages.stateExcepted} v${Constants.SIYUAN_VERSION}`,- content: `<div class="b3-dialog__content" id="transactionError">${window.siyuan.languages.rebuildIndexTip}</div>+ content: `<div class="b3-dialog__content" id="transactionError">+ ${window.siyuan.languages.rebuildIndexTip}+ ${msg ? `<br><div style="margin-top: 8px; max-height: 50vh; white-space: pre-wrap;">${escapeHtml(msg.trim())}</div>` : ""}+</div><div class="b3-dialog__action"><button class="b3-button b3-button--text">${window.siyuan.languages._kernel[97]}</button><div class="fn__space"></div>diff --git a/app/src/index.ts b/app/src/index.tsindex 07d70143e6..cc86cfe782 100644--- a/app/src/index.ts+++ b/app/src/index.ts@@ -188,7 +188,7 @@ export class App {downloadProgress(data.data);break;case "txerr":- transactionError();+ transactionError(data.msg);break;case "syncing":processSync(data, this.plugins);diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.tsindex 99add9a906..3b80dcc877 100644--- a/app/src/mobile/util/onMessage.ts+++ b/app/src/mobile/util/onMessage.ts@@ -92,7 +92,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {openMobileFileById(app, data.data.id);break;case"txerr":- transactionError();+ transactionError(data.msg);break;case"statusbar":if (!document.querySelector("#keyboardToolbar").classList.contains("fn__none") ||diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex e15f22c5a0..db7c26637d 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -144,7 +144,7 @@ class App {progressStatus(data);break;case "txerr":- transactionError();+ transactionError(data.msg);break;case "syncing":processSync(data, this.plugins);diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 162c9013f5..644a5c7864 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -92,8 +92,19 @@ func flushTx(tx *Transaction) {start := time.Now()if txErr := performTx(tx); nil != txErr {switch txErr.code {- case TxErrCodeBlockNotFound:- util.PushTxErr("Transaction failed", txErr.code, nil)+ case TxErrCodeBlockNotFound, TxErrCodePushMsg:+ pushMsg := txErr.msg+ if pushMsg == "" {+ if TxErrCodeBlockNotFound == txErr.code {+ pushMsg = "Transaction failed: block not found"+ } else {+ pushMsg = "Transaction failed"+ }+ }+ if txErr.id != "" && !strings.Contains(pushMsg, txErr.id) {+ pushMsg += fmt.Sprintf(" [%s]", txErr.id)+ }+ util.PushTxErr(pushMsg, txErr.code, nil)returncase TxErrCodeDataIsSyncing:util.PushMsg(Conf.Language(222), 5000)@@ -118,7 +129,6 @@ func PerformTransactions(transactions *[]*Transaction) {tx.m = &sync.Mutex{}txQueue <- tx}- return}const (@@ -126,6 +136,7 @@ const (TxErrCodeDataIsSyncing = 1TxErrCodeWriteTree = 2TxErrHandleAttributeView = 3+ TxErrCodePushMsg = 4)type TxErr struct {@@ -150,7 +161,7 @@ func performTx(tx *Transaction) (ret *TxErr) {return}logging.LogErrorf("begin tx failed: %s", err)- ret = &TxErr{msg: err.Error()}+ ret = &TxErr{code: TxErrCodePushMsg, msg: err.Error()}return}@@ -332,7 +343,7 @@ func performTx(tx *Transaction) (ret *TxErr) {if cr := tx.commit(); nil != cr {logging.LogErrorf("commit tx failed: %s", cr)- return &TxErr{msg: cr.Error()}+ return &TxErr{code: TxErrCodePushMsg, msg: cr.Error()}}return}@@ -1201,6 +1212,8 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *TinsertedNode := subTree.Root.FirstChildif nil == insertedNode {+ logging.LogErrorf("invalid data tree: insert op id[%s] parent[%s] previous[%s] next[%s] root[%s]",+ operation.ID, operation.ParentID, operation.PreviousID, operation.NextID, tree.Root.ID)return &TxErr{code: TxErrCodeBlockNotFound, msg: "invalid data tree"}}var remains []*ast.Node@@ -1413,7 +1426,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {oldNode := treenode.GetNodeInTree(tree, id)if nil == oldNode {logging.LogErrorf("get node [%s] in tree [%s] failed", id, tree.Root.ID)- return &TxErr{msg: ErrBlockNotFound.Error(), id: id}+ return &TxErr{code: TxErrCodeBlockNotFound, msg: ErrBlockNotFound.Error(), id: id}}// 收集引用的定义块 ID@@ -1467,7 +1480,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {updatedNode := subTree.Root.FirstChildif nil == updatedNode {logging.LogErrorf("get fist node in sub tree [%s] failed", subTree.Root.ID)- return &TxErr{msg: ErrBlockNotFound.Error(), id: id}+ return &TxErr{code: TxErrCodeBlockNotFound, msg: ErrBlockNotFound.Error(), id: id}}if ast.NodeList == updatedNode.Type && ast.NodeList == oldNode.Parent.Type {updatedNode = updatedNode.FirstChild@@ -1718,7 +1731,7 @@ func (tx *Transaction) doUpdateUpdated(operation *Operation) (ret *TxErr) {node := treenode.GetNodeInTree(tree, id)if nil == node {logging.LogErrorf("get node [%s] in tree [%s] failed", id, tree.Root.ID)- return &TxErr{msg: ErrBlockNotFound.Error(), id: id}+ return &TxErr{code: TxErrCodeBlockNotFound, msg: ErrBlockNotFound.Error(), id: id}}node.SetIALAttr("updated", operation.Data.(string))