Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/12181

Vanessae53fe42a466e
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index a01c94f6e7..5cf1a30700 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "The context has been cleared",
"emptyPlaceholder": "Write something, ' / ' for commands",
"publish": "Publish",
"publishService": "Publish service",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 42dae827a4..57acb711af 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "Se ha borrado el contexto",
"emptyPlaceholder": "Escribe algo, ' / ' para los comandos",
"publish": "Publicar",
"publishService": "Publicar servicio",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 91889e2d40..d403d10610 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "Le contexte a été effacé",
"emptyPlaceholder": "Écrivez quelque chose, ' / ' pour les commandes",
"publish": "Publier",
"publishService": "Publier le service",
diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json
index eff6c49010..49f4edc9de 100644
--- a/app/appearance/langs/ja_JP.json
+++ b/app/appearance/langs/ja_JP.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "コンテキストがクリアされました",
"emptyPlaceholder": "何か書いてください。コマンドの場合は「/」",
"publish": "公開する",
"publishService": "サービスを公開",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index f4d42ec392..1b99d3e5d8 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "上下文已清空",
"emptyPlaceholder": "寫點什麼,或按下 ' / ' 查看指令",
"publish": "發布",
"publishService": "發布服務",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 37a3c26ebf..bb5ebb1511 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "clearContextSucc": "上下文已清空",
"emptyPlaceholder": "写点什么,或按下 ' / ' 查看命令",
"publish": "发布",
"publishService": "发布服务",
diff --git a/app/src/ai/actions.ts b/app/src/ai/actions.ts
index abc46a4a68..d9bb472eb2 100644
--- a/app/src/ai/actions.ts
+++ b/app/src/ai/actions.ts
@@ -174,6 +174,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
if (customHTML) {
customHTML = `<div class="b3-menu__separator"></div>${customHTML}`;
}
+ const clearContext = "Clear context"
menu.addItem({
iconHTML: "",
type: "empty",
@@ -194,7 +195,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
<div class="b3-list-item b3-list-item--narrow" data-action="${window.siyuan.languages.aiFixGrammarSpell}">
${window.siyuan.languages.aiFixGrammarSpell}
</div>
- <div class="b3-list-item b3-list-item--narrow" data-action="Clear context">
+ <div class="b3-list-item b3-list-item--narrow" data-action="${clearContext}">
${window.siyuan.languages.clearContext}
</div>
<div class="b3-menu__separator"></div>
@@ -227,6 +228,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
const currentElement = listElement.querySelector(".b3-list-item--focus") as HTMLElement;
if (currentElement.dataset.type === "custom") {
customDialog(protyle, ids, elements);
+ menu.close();
} else {
fetchPost("/api/ai/chatGPTWithAction", {
ids,
@@ -234,8 +236,12 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
}, (response) => {
fillContent(protyle, response.data, elements);
});
+ if (currentElement.dataset.action === clearContext) {
+ showMessage(window.siyuan.languages.clearContextSucc)
+ } else {
+ menu.close();
+ }
}
- menu.close();
}
});
inputElement.addEventListener("compositionend", () => {
@@ -260,12 +266,17 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
} else if (target.classList.contains("b3-list-item")) {
if (target.dataset.type === "custom") {
customDialog(protyle, ids, elements);
+ menu.close();
} else {
fetchPost("/api/ai/chatGPTWithAction", {ids, action: target.dataset.action}, (response) => {
fillContent(protyle, response.data, elements);
});
+ if (target.dataset.action === clearContext) {
+ showMessage(window.siyuan.languages.clearContextSucc)
+ } else {
+ menu.close();
+ }
}
- menu.close();
event.stopPropagation();
event.preventDefault();
break;