Files
adnify/docs/background-tasks.md
adnaan 126a43421f feat: enhance notification system with new settings and event handling
- Added new settings tabs for network, data, diagnostics, background, and notifications.
- Introduced a new module for summarizing agent events and publishing notifications.
- Implemented an event bus for editor notifications to decouple event handling from the main application logic.
- Created a Zustand store for managing notification state and snapshots.
- Developed a notification bridge to handle incoming notifications and display them in the UI.
- Added support for webhooks in the notification settings, allowing users to configure external notification endpoints.
- Implemented comprehensive tests for the notification system, ensuring reliability and correctness.
- Updated localization files to include new notification-related strings in English and Chinese.
2026-09-05 21:45:12 +08:00

3.1 KiB

后台任务

入口:设置 → 后台任务。适用于当前窗口内所有 Agent 会话、子代理和 Plan 执行,包括未选中的会话。

  • 显示任务栏进度:默认开启。Plan 以已完成及跳过的任务数 / 总任务数显示进度;普通对话没有可信百分比,显示不确定进度。等待工具确认、等待用户输入或暂停计划时显示暂停。最近一次执行失败显示错误 15 秒;完成、取消后清除。其他任务仍在执行时,优先显示运行状态。
  • 执行任务时保持电脑唤醒:默认关闭。开启后,只有执行中的任务会申请 Electron prevent-app-suspension,允许屏幕熄灭。所有窗口都停止执行或等待确认后释放。不会阻止用户手动休眠、合盖或系统强制休眠。
  • 电脑唤醒后检查连接:默认开启。唤醒 3 秒后检查当前所选模型的服务地址,以及 MCP 管理器中现有且不处于连接中的服务。异常在设置中保留,并显示提示;可手动重新检查,或逐个重新连接失败的 MCP。

模型检查使用 5 秒超时的 HEAD 请求,不发送 API key、认证请求头或提示词,不跟随重定向,并移除 URL 查询参数及片段。任何 HTTP 响应(包括 401、404、405)均表示网络可达,不代表认证有效或模型能够推理;认证和模型调用请使用模型设置里的测试功能。检查当前所选服务,不覆盖路由中的全部备用模型或计划里每个任务的模型。

MCP 使用 SDK ping,每个服务最多等待 5 秒。不会启动手动断开的服务器,不会自动重连或重放工具调用。跨窗口同时唤醒共用一次 MCP 检查。用户主动断开或替换了连接时,忽略旧连接的检查结果。报告仅保存在当前运行内存中,切换模型配置或刷新窗口后清除。

运行状态每 250 ms 合并一次,有变化时发送;未变化时每 20 秒发送续期心跳。主进程每 15 秒清理超过 60 秒未续期的状态。窗口刷新、崩溃、关闭、应用退出都会释放对应资源;电脑唤醒后须收到新心跳才重新申请防休眠。设置随偏好备份导出、导入和重置,且在窗口间同步。

Windows 支持任务栏进度、暂停和错误颜色;macOS 使用 Dock 进度,状态颜色和不确定进度表现由系统决定;Linux 仅部分桌面环境支持进度且不支持不确定模式。参见 Electron 窗口进度 API、电源控制 和 唤醒事件。

开发验证:node scripts/diagnostics/background-tasks-smoke.cjs 使用隔离配置和隐藏 Electron 窗口,检查真实电源阻止器、原生进度调用、多窗口设置同步、模拟唤醒后的恢复界面,以及刷新/关闭时的清理。不会让电脑实际休眠,也不会访问真实模型服务或 MCP。中英文截图保存在 .tmp/background-tasks-smoke。