Files
PiAgentUI/public/notification-sw.js
Evandro b3489e1ede
Build & Push Frontend Docker Image / build-and-push (push) Canceled after 0s
Build Validation / validate (push) Canceled after 6s
Build & Push Backend Docker Image / build-and-push (push) Failing after 10m10s
Build & Push Gateway Docker Image / build-and-push (push) Failing after 10m9s
🎉 Initial commit: PiAgentUI — AI Agent Desktop & Web UI
A professional workspace for AI coding agents with:
- Real-time streaming chat with SSE
- Session management (fork, clone, tree navigation)
- MCP tools browser & metadata panel
- Skills browser (global, project, package sources)
- Voice input & STT provider configuration
- Integrated terminal & file explorer
- Model selector with capability metadata
- Keyboard-first UI with command palette
- 8 languages (en, pt-BR, es, ja, zh-CN, ar, bn, hi)
- Tauri 2 desktop app
- React 19 + TypeScript + Vite 8 + Tailwind CSS 4
- Pi Agent extension runtime

Originally forked from OpenCodeUI, now an independent project.
License: GPL-3.0-only
2026-06-01 00:50:06 -03:00

40 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ============================================
// Notification Service Worker
// ============================================
// 专门用于显示通知(Android Chrome 不支持 new Notification())
// 不做缓存、不拦截 fetch,只处理通知相关事件
self.addEventListener('notificationclick', event => {
event.notification.close()
const data = event.notification.data
if (!data) return
// 构建跳转 URL
let url = '/'
if (data.sessionId) {
const dir = data.directory ? `?dir=${data.directory}` : ''
url = `/#/session/${data.sessionId}${dir}`
}
// 聚焦已有窗口或打开新窗口
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(windowClients => {
// 找到同源的已有窗口
for (const client of windowClients) {
if (client.url.startsWith(self.location.origin) && 'focus' in client) {
// 导航到目标 session
client.postMessage({
type: 'notification-click',
sessionId: data.sessionId,
directory: data.directory,
})
return client.focus()
}
}
// 没有已有窗口,打开新的
return clients.openWindow(url)
}),
)
})