From 25a2bd0922fb9c3dda1771689f3956277c0bfe5c Mon Sep 17 00:00:00 2001 From: xintaofei Date: Tue, 31 Mar 2026 15:43:00 +0800 Subject: [PATCH] =?UTF-8?q?Agent=E5=9C=A8=E5=AE=9E=E6=97=B6=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E4=B8=AD=E5=9B=A0=E4=B8=BA=E9=94=99=E8=AF=AF=E8=80=8C?= =?UTF-8?q?=E4=B8=AD=E6=96=AD=E6=97=B6=E5=8F=91=E9=80=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/acp-connections-context.tsx | 23 ++++++++++++++++++++--- src/i18n/messages/ar.json | 3 ++- src/i18n/messages/de.json | 3 ++- src/i18n/messages/en.json | 3 ++- src/i18n/messages/es.json | 3 ++- src/i18n/messages/fr.json | 3 ++- src/i18n/messages/ja.json | 3 ++- src/i18n/messages/ko.json | 3 ++- src/i18n/messages/pt.json | 3 ++- src/i18n/messages/zh-CN.json | 3 ++- src/i18n/messages/zh-TW.json | 3 ++- src/lib/notification.ts | 2 +- 12 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/contexts/acp-connections-context.tsx b/src/contexts/acp-connections-context.tsx index 50afb9a..31d3b7a 100644 --- a/src/contexts/acp-connections-context.tsx +++ b/src/contexts/acp-connections-context.tsx @@ -42,7 +42,7 @@ import { CONNECTION_IDLE_TIMEOUT_MS, IDLE_SWEEP_INTERVAL_MS, } from "@/lib/constants" -import { notifyTurnComplete } from "@/lib/notification" +import { sendSystemNotification } from "@/lib/notification" import { applySavedModePreference, applySavedConfigPreferences, @@ -1704,7 +1704,7 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) { const agentLabel = AGENT_LABELS[nc.agentType] const fn = folderNameRef.current const title = fn ? `${fn} - Codeg` : "Codeg" - notifyTurnComplete( + sendSystemNotification( title, t("notificationTurnComplete", { agent: agentLabel }) ).catch(() => {}) @@ -1712,11 +1712,28 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) { } break } - case "error": + case "error": { flushStreamingQueue() dispatch({ type: "ERROR", contextKey, message: e.message }) pushAlertRef.current("error", t("eventErrorTitle"), e.message) + // Send OS notification for agent errors + { + const nc = storeRef.current.connections.get(contextKey) + if (nc) { + const agentLabel = AGENT_LABELS[nc.agentType] + const fn = folderNameRef.current + const title = fn ? `${fn} - Codeg` : "Codeg" + sendSystemNotification( + title, + t("notificationError", { + agent: agentLabel, + message: e.message, + }) + ).catch(() => {}) + } + } break + } case "available_commands": flushStreamingQueue() dispatch({ diff --git a/src/i18n/messages/ar.json b/src/i18n/messages/ar.json index c171571..7619b12 100644 --- a/src/i18n/messages/ar.json +++ b/src/i18n/messages/ar.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "فشل اتصال {agent}", "toolFallbackTitle": "أداة", "eventErrorTitle": "خطأ الوكيل", - "notificationTurnComplete": "{agent} أنهى الاستجابة" + "notificationTurnComplete": "{agent} أنهى الاستجابة", + "notificationError": "{agent} خطأ: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/de.json b/src/i18n/messages/de.json index 9a24d0d..f5b025c 100644 --- a/src/i18n/messages/de.json +++ b/src/i18n/messages/de.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "{agent} Verbindung fehlgeschlagen", "toolFallbackTitle": "Werkzeug", "eventErrorTitle": "Agentenfehler", - "notificationTurnComplete": "{agent} hat die Antwort abgeschlossen" + "notificationTurnComplete": "{agent} hat die Antwort abgeschlossen", + "notificationError": "{agent} Fehler: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index ae94ffe..bc761b1 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -1351,7 +1351,8 @@ "connectFailedTitle": "{agent} connection failed", "toolFallbackTitle": "Tool", "eventErrorTitle": "Agent Error", - "notificationTurnComplete": "{agent} has finished responding" + "notificationTurnComplete": "{agent} has finished responding", + "notificationError": "{agent} error: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/es.json b/src/i18n/messages/es.json index e99f98e..360ebca 100644 --- a/src/i18n/messages/es.json +++ b/src/i18n/messages/es.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "Falló la conexión de {agent}", "toolFallbackTitle": "Herramienta", "eventErrorTitle": "Error del agente", - "notificationTurnComplete": "{agent} ha terminado de responder" + "notificationTurnComplete": "{agent} ha terminado de responder", + "notificationError": "{agent} error: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/fr.json b/src/i18n/messages/fr.json index 161f2f6..8d01df9 100644 --- a/src/i18n/messages/fr.json +++ b/src/i18n/messages/fr.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "Échec de la connexion de {agent}", "toolFallbackTitle": "Outil", "eventErrorTitle": "Erreur de l'agent", - "notificationTurnComplete": "{agent} a terminé de répondre" + "notificationTurnComplete": "{agent} a terminé de répondre", + "notificationError": "{agent} erreur : {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/ja.json b/src/i18n/messages/ja.json index 36d281e..c3320fb 100644 --- a/src/i18n/messages/ja.json +++ b/src/i18n/messages/ja.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "{agent} の接続に失敗しました", "toolFallbackTitle": "ツール", "eventErrorTitle": "エージェントエラー", - "notificationTurnComplete": "{agent} の応答が完了しました" + "notificationTurnComplete": "{agent} の応答が完了しました", + "notificationError": "{agent} エラー:{message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/ko.json b/src/i18n/messages/ko.json index de600b8..47a8579 100644 --- a/src/i18n/messages/ko.json +++ b/src/i18n/messages/ko.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "{agent} 연결 실패", "toolFallbackTitle": "도구", "eventErrorTitle": "에이전트 오류", - "notificationTurnComplete": "{agent} 응답이 완료되었습니다" + "notificationTurnComplete": "{agent} 응답이 완료되었습니다", + "notificationError": "{agent} 오류: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/pt.json b/src/i18n/messages/pt.json index 7b1d17a..33b9425 100644 --- a/src/i18n/messages/pt.json +++ b/src/i18n/messages/pt.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "Falha na conexão de {agent}", "toolFallbackTitle": "Ferramenta", "eventErrorTitle": "Erro do agente", - "notificationTurnComplete": "{agent} terminou de responder" + "notificationTurnComplete": "{agent} terminou de responder", + "notificationError": "{agent} erro: {message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/zh-CN.json b/src/i18n/messages/zh-CN.json index 5e61727..dc7312c 100644 --- a/src/i18n/messages/zh-CN.json +++ b/src/i18n/messages/zh-CN.json @@ -1351,7 +1351,8 @@ "connectFailedTitle": "{agent} 连接失败", "toolFallbackTitle": "工具", "eventErrorTitle": "Agent 错误", - "notificationTurnComplete": "{agent} 已完成响应" + "notificationTurnComplete": "{agent} 已完成响应", + "notificationError": "{agent} 错误:{message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/i18n/messages/zh-TW.json b/src/i18n/messages/zh-TW.json index b781849..1b6e74d 100644 --- a/src/i18n/messages/zh-TW.json +++ b/src/i18n/messages/zh-TW.json @@ -1350,7 +1350,8 @@ "connectFailedTitle": "{agent} 連線失敗", "toolFallbackTitle": "工具", "eventErrorTitle": "Agent 錯誤", - "notificationTurnComplete": "{agent} 已完成回應" + "notificationTurnComplete": "{agent} 已完成回應", + "notificationError": "{agent} 錯誤:{message}" }, "connectionLifecycle": { "tasks": { diff --git a/src/lib/notification.ts b/src/lib/notification.ts index df5ddc6..5c538d9 100644 --- a/src/lib/notification.ts +++ b/src/lib/notification.ts @@ -1,7 +1,7 @@ import { getTransport } from "./transport" import { isDesktop } from "./transport" -export async function notifyTurnComplete( +export async function sendSystemNotification( title: string, body: string ): Promise {