Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,21 @@ export function AppShell() {
const handleAgentEnd = useCallback(() => {
setRefreshKey((k) => k + 1);
setExplorerRefreshKey((k) => k + 1);
}, []);

if (document.visibilityState === "visible") return;
if (!("Notification" in window)) return;

const fire = () => {
const title = selectedSession?.name ?? translate("i18n.sessionComplete");
new Notification(title, { body: translate("i18n.taskFinished") });
};

if (Notification.permission === "granted") {
fire();
} else if (Notification.permission === "default") {
void Notification.requestPermission().then((p) => { if (p === "granted") fire(); });
}
}, [selectedSession, translate]);

const handleAutoName = useCallback(async () => {
const sessionId = selectedSession?.id;
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/messages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@ export const enLocale: LocalePlugin = {
"i18n.thinkingUnavailable": "Thinking content unavailable",
"i18n.before": "Before",
"i18n.after": "After",
"i18n.sessionComplete": "Session complete",
"i18n.taskFinished": "Task finished.",
},
};
2 changes: 2 additions & 0 deletions lib/i18n/messages/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@ export const zhCNLocale: LocalePlugin = {
"i18n.thinkingUnavailable": "思考内容不可用",
"i18n.before": "之前",
"i18n.after": "之后",
"i18n.sessionComplete": "任务完成",
"i18n.taskFinished": "任务已完成。",
},
};