feat(acp): notify when permission approval is requested

Send a system notification when an agent triggers a permission request while the app window is not visible.
This commit is contained in:
xintaofei
2026-04-14 15:31:12 +08:00
parent f9c0887346
commit 7808a5f0d0

View File

@@ -1300,6 +1300,7 @@ function isAlertedError(error: unknown): error is AlertedError {
export function AcpConnectionsProvider({ children }: { children: ReactNode }) { export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
const t = useTranslations("Folder.chat.acpConnections") const t = useTranslations("Folder.chat.acpConnections")
const tChat = useTranslations("Folder.chat")
const { pushAlert } = useAlertContext() const { pushAlert } = useAlertContext()
const { folder } = useFolderContext() const { folder } = useFolderContext()
const folderNameRef = useRef(folder?.name) const folderNameRef = useRef(folder?.name)
@@ -1694,6 +1695,19 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
fallback_kind: "tool", fallback_kind: "tool",
options: e.options, options: e.options,
}) })
// Send OS notification when permission approval is needed
{
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,
`${agentLabel}: ${tChat("permissionDialog.subtitle")}`
).catch(() => {})
}
}
break break
case "session_started": case "session_started":
flushStreamingQueue() flushStreamingQueue()
@@ -1970,6 +1984,7 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
flushStreamingQueue, flushStreamingQueue,
scheduleToolCallUpdateFlush, scheduleToolCallUpdateFlush,
t, t,
tChat,
] ]
) )