fix(webui): refine browser notifications (NAN-227)

Reconcile the original notification fix with the integrated main snapshot.

Group notification settings and simplify localized copy and documentation.
Preserve permission opt-out and notification click routing across app transitions.
Suppress late completion notifications for discarded temporary chats and align
notification settings skeletons with the loaded layout.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-20 13:45:04 +08:00
1 parent 7b2af031c0
commit 11152626f8
34 files changed
+728 -289

No files matched your search

+23 -1
View File
@@ -79,15 +79,37 @@ describe("NanobotClient", () => {
const broken = client.onTaskNotice(() => { throw new Error("optional notification failed"); });
const notice = vi.fn();
const unsubscribe = client.onTaskNotice(notice);
client.attach("away");
const event = { event: "turn_end", chat_id: "away", turn_id: "turn", outcome: "completed" };
lastSocket().fakeMessage(event);
expect(notice).toHaveBeenCalledWith({ event, temporary: false });
const replay = vi.fn();
client.onChat("away", replay);
client.onTranscript("away", replay);
expect(replay).toHaveBeenCalledWith(event);
expect(notice).toHaveBeenCalledOnce();
broken(); unsubscribe(); client.close();
});
it("ignores in-flight task notices after a Temporary Chat is discarded", async () => {
const client = new NanobotClient({ url: "ws://test", reconnect: false,
socketFactory: (url) => new FakeSocket(url) as unknown as WebSocket });
client.connect();
const socket = lastSocket();
socket.fakeOpen();
const created = client.newTemporaryChat();
socket.fakeMessage({ event: "attached", chat_id: "temporary", temporary: true });
await created;
const notice = vi.fn();
client.onTaskNotice(notice);
client.sendMessage("temporary", "work", undefined, { turnId: "temporary-turn" });
client.discardTemporaryChat("temporary");
socket.fakeMessage({ event: "turn_end", chat_id: "temporary", turn_id: "temporary-turn" });
expect(notice).not.toHaveBeenCalled();
client.attach("regular");
const event = { event: "turn_end", chat_id: "regular", turn_id: "regular-turn" };
socket.fakeMessage(event);
expect(notice).toHaveBeenCalledWith({ event, temporary: false });
client.close();
});
it("bounds regular replay tails but retains temporary events until discard", async () => {
const client = new NanobotClient({
url: "ws://test", reconnect: false,