Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Mark approvals that wait outside the open conversation

Fei2411c0685dac3025
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9f80950..eb6ac17f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
- A Main Bot can stop another Bot's running turn. The Bot is told why, and its reply goes back to the Main Bot.
- In a group chat, a member that asks for an approval no longer holds up the round. You allow or reject the request in the group's details panel, and a line above the composer names the members who are waiting or at work. What a member says after the round moved on is posted in the group.
- A Bot that was working when DeepSeek Harness closed or restarted picks its work back up when DS Bot starts again. A group chat shows which member was cut off, and a Bot that was answering another Bot still sends its answer.
+- The sidebar marks a Bot or group chat that waits for your approval. Where the system allows notifications, a notification also names the Bot.
### Changed
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 21e804fe..faf68fbc 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -473,6 +473,7 @@ var ZH = {
"{name} was cut off by a restart again and stopped": "{name} 的工作又被重启打断,已停下",
"Picked up its work after a restart": "重启后接着做之前的工作",
"Asked to make the tool call it wrote as text": "工具调用被写成了文字,已让它重新调用",
+ "A Bot": "一个 Bot",
"{name} is waiting for your approval": "{name} 等你批准",
"{first} and {second} are waiting for your approval": "{first}、{second} 等你批准",
"{first}, {second} and {count} more are waiting for your approval": "{first}、{second} 等 {total} 个等你批准",
@@ -1892,6 +1893,7 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
.bt-tag{flex:none;max-width:96px;font-size:12px;line-height:16px;font-weight:400;padding:1px 6px;border-radius:4px;background:var(--bt-tag-bg);color:var(--bt-tag-ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bt-row-preview{font-size:13px;line-height:18px;color:var(--bt-ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bt-unread{width:8px;height:8px;border-radius:50%;background:#1084fe;flex:none;margin-right:2px;animation:bt-fade .13s cubic-bezier(.22,1,.36,1)}
+.bt-unread-wait{background:var(--bt-star)}
.bt-rail{align-items:center;padding:0 0 8px}
.bt-rail .bt-row{justify-content:center;padding:6px 0;min-height:44px}
.bt-side-foot{display:flex;padding-top:8px}
@@ -4616,7 +4618,8 @@ function useMarkedUnread(id, active, marked, actions) {
}, [active, marked]);
}
var PinMark = () => (0, import_react8.createElement)("span", { className: "bt-pin", "aria-hidden": true }, (0, import_react8.createElement)(PinMarkIcon));
-function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, wide, marked }) {
+var useApproval = (useWork, match) => useWork ? useWork((work) => (work.approvals ?? []).some(match)) : false;
+function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, useWork, wide, marked }) {
const id = bot.id;
const part = currentPart(bot);
const preview = useSessions((list) => previewOf(list, part, roster.exchangeTurns[part]));
@@ -4626,7 +4629,8 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
useMarkedUnread(id, active, marked, actions);
const main = isMainOf(roster, id);
const tile = roster.mainBotId === id;
- const alert = roster.questions?.[part] !== void 0;
+ const approval = useApproval(useWork, (entry) => entry.botId === id);
+ const alert = roster.questions?.[part] !== void 0 || approval;
const doing = useActivity((map) => map[id]);
const state = botState(running, doing, alert);
if (bot.hidden && !active && !main) return null;
@@ -4635,7 +4639,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
actions.openMenu({ kind: "bot", id, x: event.clientX, y: event.clientY });
};
const pinned = bot.pinned === true && !tile;
- const label = [bot.name, main ? t("Main Bot") : "", pinned ? t("Pinned") : "", running ? t("Working") : "", alert ? t("Waiting for your answer") : "", unread ? t("Unread activity") : ""].filter(Boolean).join(", ");
+ const label = [bot.name, main ? t("Main Bot") : "", pinned ? t("Pinned") : "", running ? t("Working") : "", approval ? t("Waiting for your approval") : alert ? t("Waiting for your answer") : "", unread ? t("Unread activity") : ""].filter(Boolean).join(", ");
if (tile && wide) {
return (0, import_react8.createElement)("div", { className: "bt-tile-wrap" }, (0, import_react8.createElement)(
"button",
@@ -4677,21 +4681,23 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
wide && unread && !active ? (0, import_react8.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
);
}
-function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, wide, marked }) {
+function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {
const id = room2.id;
const fallback = useSessions((list) => previewOf(list, id));
const preview = room2.preview?.replace(/\s+/g, " ").trim() || fallback;
const active = useSessionRetainInfo(id, (info) => (info?.retainedBy?.mainView ?? 0) > 0);
const unread = useSessionStatus((map) => map.get(id)?.completionUnread === true) || marked && !active;
useMarkedUnread(id, active, marked, actions);
+ const approval = useApproval(useWork, (entry) => entry.roomId === id);
if (room2.hidden && !active) return null;
const pinned = room2.pinned === true;
+ const label = [room2.name, pinned ? t("Pinned") : "", approval ? t("Waiting for your approval") : ""].filter(Boolean).join(", ");
return (0, import_react8.createElement)(
"button",
{
type: "button",
className: "bt-row",
- "aria-label": pinned ? `${room2.name}, ${t("Pinned")}` : room2.name,
+ "aria-label": label,
"aria-current": active ? "page" : void 0,
"data-room-id": id,
onClick: () => actions.openSession(id),
@@ -4708,7 +4714,7 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,
(0, import_react8.createElement)("span", { className: "bt-row-name" }, (0, import_react8.createElement)("span", { className: "bt-row-title" }, room2.name), pinned ? (0, import_react8.createElement)(PinMark) : null),
preview ? (0, import_react8.createElement)("span", { className: "bt-row-preview" }, preview) : null
) : null,
- wide && unread && !active ? (0, import_react8.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
+ wide && approval && !active ? (0, import_react8.createElement)("span", { className: "bt-unread bt-unread-wait", "aria-hidden": true }) : wide && unread && !active ? (0, import_react8.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
);
}
function AgentSessionRow({ session, agent, actions, renaming, index }) {
@@ -4897,7 +4903,7 @@ function TeamSidebar(props) {
const main = roster.byId[roster.mainBotId];
useListGlide(listRef, wide, order.map((entry) => entry.item.id).join(","));
useLandOnMainBot(roster, useSessions, actions);
- const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, wide };
+ const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide };
const typeToSearch = (event) => {
if (event.defaultPrevented || event.key.length !== 1 || event.key === " " || event.metaKey || event.ctrlKey || event.altKey || event.nativeEvent.isComposing) return;
if (event.target instanceof Element && event.target.closest("input,textarea,[contenteditable]")) return;
@@ -12561,6 +12567,38 @@ var USER_MESSAGE_CSS = `
.bt-umsg:hover .bt-utools,.bt-umsg:focus-within .bt-utools{opacity:1;visibility:visible}
`;
+// src/client/approval-notices.js
+function noticeApprovals({ work, roster, shownSession, openSession, since: since2 = Date.now() }) {
+ const told = /* @__PURE__ */ new Set();
+ const notify = () => {
+ const approvals = work.getSnapshot().approvals ?? [];
+ for (const id of told) {
+ if (!approvals.some((entry) => entry.id === id)) told.delete(id);
+ }
+ if (typeof Notification !== "function" || Notification.permission !== "granted") return;
+ for (const entry of approvals) {
+ if (told.has(entry.id)) continue;
+ told.add(entry.id);
+ if ((entry.at ?? 0) < since2) continue;
+ const place = entry.roomId ?? entry.sessionId;
+ if (document.visibilityState === "visible" && shownSession() === place) continue;
+ const { byId, roomsById } = roster.getSnapshot();
+ const room2 = entry.roomId ? roomsById[entry.roomId] : void 0;
+ const note = new Notification(t("{name} is waiting for your approval", { name: byId[entry.botId]?.name ?? t("A Bot") }), {
+ body: [room2?.name, entry.tool].filter(Boolean).join(" · "),
+ tag: `ds-bot-approval-${entry.id}`
+ });
+ note.onclick = () => {
+ window.focus();
+ openSession(entry.roomId ?? entry.botId);
+ note.close();
+ };
+ }
+ };
+ notify();
+ return work.subscribe(notify);
+}
+
// src/client/index.js
var inject = ["sessions", "uiWorkspace", "uiConversation", "slots", "theme", "layout", "configForms"];
function apply(ctx) {
@@ -13287,6 +13325,12 @@ function apply(ctx) {
const browserPages = browsers?.pages ?? createSource({});
const browserTabs = browsers?.tabs ?? createSource({});
const face = () => ({ actions, hooks: { roster, ui: ui2, activity, work, memoryNews, registry, turnClock, live, browserPages, browserTabs, surface, update } });
+ ctx.effect(() => noticeApprovals({
+ work,
+ roster,
+ shownSession: () => Object.values(ctx.sessions.list.getSnapshot().byId ?? {}).find((session) => (session?.retainedBy?.mainView ?? 0) > 0)?.id,
+ openSession: (id) => actions.openSession(id)
+ }), "ds-bot: approval notifications");
const assistantFace = (sessionId) => {
const binding = ctx.sessions.binding(sessionId);
if (binding === void 0) throw new Error(`ds-bot: unknown session "${sessionId}"`);
diff --git a/ds-bot/src/client/approval-notices.js b/ds-bot/src/client/approval-notices.js
new file mode 100644
index 00000000..4b863698
--- /dev/null
+++ b/ds-bot/src/client/approval-notices.js
@@ -0,0 +1,36 @@
+import { t } from './i18n.js'
+
+// A system notification for each approval that starts waiting while this window is in
+// the background or shows another conversation. Only where the platform already allows
+// notifications: DS Bot never asks for the permission.
+export function noticeApprovals({ work, roster, shownSession, openSession, since = Date.now() }) {
+ const told = new Set()
+ const notify = () => {
+ const approvals = work.getSnapshot().approvals ?? []
+ for (const id of told) {
+ if (!approvals.some(entry => entry.id === id)) told.delete(id)
+ }
+ if (typeof Notification !== 'function' || Notification.permission !== 'granted') return
+ for (const entry of approvals) {
+ if (told.has(entry.id)) continue
+ told.add(entry.id)
+ // Waiting before this window opened is no news: the sidebar shows it.
+ if ((entry.at ?? 0) < since) continue
+ const place = entry.roomId ?? entry.sessionId
+ if (document.visibilityState === 'visible' && shownSession() === place) continue
+ const { byId, roomsById } = roster.getSnapshot()
+ const room = entry.roomId ? roomsById[entry.roomId] : undefined
+ const note = new Notification(t('{name} is waiting for your approval', { name: byId[entry.botId]?.name ?? t('A Bot') }), {
+ body: [room?.name, entry.tool].filter(Boolean).join(' · '),
+ tag: `ds-bot-approval-${entry.id}`,
+ })
+ note.onclick = () => {
+ window.focus()
+ openSession(entry.roomId ?? entry.botId)
+ note.close()
+ }
+ }
+ }
+ notify()
+ return work.subscribe(notify)
+}
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index 92ee86c8..abc871a0 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -417,6 +417,7 @@ const ZH = {
'{name} was cut off by a restart again and stopped': '{name} 的工作又被重启打断,已停下',
'Picked up its work after a restart': '重启后接着做之前的工作',
'Asked to make the tool call it wrote as text': '工具调用被写成了文字,已让它重新调用',
+ 'A Bot': '一个 Bot',
'{name} is waiting for your approval': '{name} 等你批准',
'{first} and {second} are waiting for your approval': '{first}、{second} 等你批准',
'{first}, {second} and {count} more are waiting for your approval': '{first}、{second} 等 {total} 个等你批准',
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 97c34dfa..015c9426 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -32,6 +32,7 @@ import { ErrorToast, FEEDBACK_CSS } from './feedback.js'
import { ABOUT_CSS } from './about.js'
import { MEMBER_CSS, MemberDock } from './member-status.js'
import { USER_MESSAGE_CSS, UserMessageCell, canDrawUserMessages } from './user-message.js'
+import { noticeApprovals } from './approval-notices.js'
export const inject = ['sessions', 'uiWorkspace', 'uiConversation', 'slots', 'theme', 'layout', 'configForms']
@@ -694,6 +695,12 @@ export function apply(ctx) {
const browserPages = browsers?.pages ?? createSource({})
const browserTabs = browsers?.tabs ?? createSource({})
const face = () => ({ actions, hooks: { roster, ui, activity, work, memoryNews, registry, turnClock, live, browserPages, browserTabs, surface, update } })
+ ctx.effect(() => noticeApprovals({
+ work,
+ roster,
+ shownSession: () => Object.values(ctx.sessions.list.getSnapshot().byId ?? {}).find(session => (session?.retainedBy?.mainView ?? 0) > 0)?.id,
+ openSession: id => actions.openSession(id),
+ }), 'ds-bot: approval notifications')
const assistantFace = (sessionId) => {
const binding = ctx.sessions.binding(sessionId)
if (binding === undefined) throw new Error(`ds-bot: unknown session "${sessionId}"`)
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index ad6f0420..d9283696 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -23,7 +23,11 @@ function useMarkedUnread(id, active, marked, actions) {
const PinMark = () => h('span', { className: 'bt-pin', 'aria-hidden': true }, h(PinMarkIcon))
-function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, wide, marked }) {
+// Whether an approval waits for the user: for a Bot, in any of its Sessions; for a group,
+// from any of its members there.
+const useApproval = (useWork, match) => (useWork ? useWork(work => (work.approvals ?? []).some(match)) : false)
+
+function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useActivity, useWork, wide, marked }) {
const id = bot.id
const part = currentPart(bot)
const preview = useSessions(list => previewOf(list, part, roster.exchangeTurns[part]))
@@ -33,7 +37,8 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
useMarkedUnread(id, active, marked, actions)
const main = isMainOf(roster, id)
const tile = roster.mainBotId === id
- const alert = roster.questions?.[part] !== undefined
+ const approval = useApproval(useWork, entry => entry.botId === id)
+ const alert = roster.questions?.[part] !== undefined || approval
const doing = useActivity(map => map[id])
const state = botState(running, doing, alert)
if (bot.hidden && !active && !main) return null
@@ -42,7 +47,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
actions.openMenu({ kind: 'bot', id, x: event.clientX, y: event.clientY })
}
const pinned = bot.pinned === true && !tile
- const label = [bot.name, main ? t('Main Bot') : '', pinned ? t('Pinned') : '', running ? t('Working') : '', alert ? t('Waiting for your answer') : '', unread ? t('Unread activity') : ''].filter(Boolean).join(', ')
+ const label = [bot.name, main ? t('Main Bot') : '', pinned ? t('Pinned') : '', running ? t('Working') : '', approval ? t('Waiting for your approval') : alert ? t('Waiting for your answer') : '', unread ? t('Unread activity') : ''].filter(Boolean).join(', ')
if (tile && wide) {
return h('div', { className: 'bt-tile-wrap' }, h('button', {
type: 'button', className: 'bt-tile', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
@@ -64,17 +69,19 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)
}
-function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, wide, marked }) {
+function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {
const id = room.id
const fallback = useSessions(list => previewOf(list, id))
const preview = room.preview?.replace(/\s+/g, ' ').trim() || fallback
const active = useSessionRetainInfo(id, info => (info?.retainedBy?.mainView ?? 0) > 0)
const unread = useSessionStatus(map => map.get(id)?.completionUnread === true) || (marked && !active)
useMarkedUnread(id, active, marked, actions)
+ const approval = useApproval(useWork, entry => entry.roomId === id)
if (room.hidden && !active) return null
const pinned = room.pinned === true
+ const label = [room.name, pinned ? t('Pinned') : '', approval ? t('Waiting for your approval') : ''].filter(Boolean).join(', ')
return h('button', {
- type: 'button', className: 'bt-row', 'aria-label': pinned ? `${room.name}, ${t('Pinned')}` : room.name, 'aria-current': active ? 'page' : undefined,
+ type: 'button', className: 'bt-row', 'aria-label': label, 'aria-current': active ? 'page' : undefined,
'data-room-id': id, onClick: () => actions.openSession(id),
onContextMenu: (event) => { event.preventDefault(); actions.openMenu({ kind: 'room', id, x: event.clientX, y: event.clientY }) },
},
@@ -83,7 +90,8 @@ function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSess
wide ? h('span', { className: 'bt-row-body' },
h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, room.name), pinned ? h(PinMark) : null),
preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
- wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)
+ wide && approval && !active ? h('span', { className: 'bt-unread bt-unread-wait', 'aria-hidden': true })
+ : wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)
}
// One expanded DSH Agent Session row: title, relative stamp, rename field, and a
@@ -234,7 +242,7 @@ export function TeamSidebar(props) {
const main = roster.byId[roster.mainBotId]
useListGlide(listRef, wide, order.map(entry => entry.item.id).join(','))
useLandOnMainBot(roster, useSessions, actions)
- const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, wide }
+ const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide }
// Typing while the sidebar has focus starts a search.
const typeToSearch = (event) => {
if (event.defaultPrevented || event.key.length !== 1 || event.key === ' ' || event.metaKey || event.ctrlKey || event.altKey || event.nativeEvent.isComposing) return
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index 1d63c888..5b87ae7f 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -135,6 +135,7 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
.bt-tag{flex:none;max-width:96px;font-size:12px;line-height:16px;font-weight:400;padding:1px 6px;border-radius:4px;background:var(--bt-tag-bg);color:var(--bt-tag-ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bt-row-preview{font-size:13px;line-height:18px;color:var(--bt-ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bt-unread{width:8px;height:8px;border-radius:50%;background:#1084fe;flex:none;margin-right:2px;animation:bt-fade .13s cubic-bezier(.22,1,.36,1)}
+.bt-unread-wait{background:var(--bt-star)}
.bt-rail{align-items:center;padding:0 0 8px}
.bt-rail .bt-row{justify-content:center;padding:6px 0;min-height:44px}
.bt-side-foot{display:flex;padding-top:8px}
diff --git a/ds-bot/test/approval-notices.test.js b/ds-bot/test/approval-notices.test.js
new file mode 100644
index 00000000..c7792aed
--- /dev/null
+++ b/ds-bot/test/approval-notices.test.js
@@ -0,0 +1,64 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { fileURLToPath } from 'node:url'
+import { runInNewContext } from 'node:vm'
+import { build } from 'esbuild'
+
+const bundle = await build({
+ entryPoints: [fileURLToPath(new URL('../src/client/approval-notices.js', import.meta.url))],
+ bundle: true, format: 'cjs', platform: 'node', write: false,
+})
+
+// One window: the platform's Notification, whether the page shows, and the work source.
+function windowWith({ permission = 'granted', visibility = 'visible' } = {}) {
+ const shown = []
+ const opened = []
+ function Notification(title, options) {
+ const note = { title, ...options, closed: false, close() { note.closed = true } }
+ shown.push(note)
+ return note
+ }
+ Notification.permission = permission
+ const listeners = new Set()
+ let snapshot = { bots: {}, approvals: [] }
+ const work = {
+ getSnapshot: () => snapshot,
+ subscribe: (listener) => { listeners.add(listener); return () => listeners.delete(listener) },
+ set: (next) => { snapshot = next; for (const listener of listeners) listener() },
+ }
+ const roster = { getSnapshot: () => ({ byId: { b: { id: 'b', name: 'Writer' } }, roomsById: { r1: { id: 'r1', name: 'Ops' } } }) }
+ const module = { exports: {} }
+ runInNewContext(bundle.outputFiles[0].text, {
+ module, exports: module.exports, Notification,
+ document: { visibilityState: visibility },
+ window: { focus() {} },
+ })
+ return { ...module.exports, shown, opened, work, roster, openSession: id => opened.push(id) }
+}
+
+test('an approval that starts waiting while another conversation shows gets one notification', () => {
+ const page = windowWith()
+ page.noticeApprovals({ work: page.work, roster: page.roster, shownSession: () => 'a', openSession: page.openSession, since: 100 })
+ page.work.set({ bots: {}, approvals: [{ id: 'x1', botId: 'b', roomId: 'r1', sessionId: 'gb', tool: 'pwsh', at: 200 }] })
+ page.work.set({ bots: {}, approvals: [{ id: 'x1', botId: 'b', roomId: 'r1', sessionId: 'gb', tool: 'pwsh', at: 200 }] })
+ assert.deepEqual(page.shown.map(note => [note.title, note.body, note.tag]), [['Writer is waiting for your approval', 'Ops · pwsh', 'ds-bot-approval-x1']])
+ page.shown[0].onclick()
+ assert.deepEqual([page.opened, page.shown[0].closed], [['r1'], true])
+})
+
+test('no notification for the conversation on screen, for approvals older than the window, or without permission', () => {
+ const onScreen = windowWith()
+ onScreen.noticeApprovals({ work: onScreen.work, roster: onScreen.roster, shownSession: () => 'r1', openSession: onScreen.openSession, since: 100 })
+ onScreen.work.set({ bots: {}, approvals: [{ id: 'x1', botId: 'b', roomId: 'r1', tool: 'pwsh', at: 200 }, { id: 'x2', botId: 'b', sessionId: 'b', tool: 'pwsh', at: 50 }] })
+ assert.equal(onScreen.shown.length, 0)
+
+ const hidden = windowWith({ visibility: 'hidden' })
+ hidden.noticeApprovals({ work: hidden.work, roster: hidden.roster, shownSession: () => 'r1', openSession: hidden.openSession, since: 100 })
+ hidden.work.set({ bots: {}, approvals: [{ id: 'x1', botId: 'b', roomId: 'r1', tool: 'pwsh', at: 200 }] })
+ assert.equal(hidden.shown.length, 1)
+
+ const denied = windowWith({ permission: 'default' })
+ denied.noticeApprovals({ work: denied.work, roster: denied.roster, shownSession: () => 'a', openSession: denied.openSession, since: 100 })
+ denied.work.set({ bots: {}, approvals: [{ id: 'x1', botId: 'b', roomId: 'r1', tool: 'pwsh', at: 200 }] })
+ assert.equal(denied.shown.length, 0)
+})