AtomCode 桌面通知系统与平台集成分析
持续深度分析 — 桌面通知、终端检测、平台兼容性 2026-06-23
1. 桌面通知系统架构
1.1 支持的通知方式
| 方式 | 平台 | 命令/API | 事件 |
|---|---|---|---|
| notify-send | Linux (libnotify) | notify-send | 桌面通知弹窗 |
| terminal-notifier | macOS | terminal-notifier | macOS 通知中心 |
| Swift 原生 | macOS | osascript | AppleScript 弹窗 |
| Kitty 协议 | 跨平台终端 | \x1b]777;notify; | Kitty 终端内通知 |
| TUI 内通知 | 跨平台 | NotificationConfig | 终端 UI 内提示 |
1.2 通知事件类型
| 事件 | 消息模板 | 场景 |
|---|---|---|
| AtomCode approval needed | AtomCode approval needed | 等待用户审批工具调用 |
| AtomCode done | AtomCode done | 任务完成 |
| AtomCode cancelled | AtomCode cancelled | 用户中止 |
| AtomCode failed | AtomCode failed | 任务失败 |
| Failed | Failed | 通用失败通知 |
1.3 通知流
任务状态变更
│
├──▶ TUI 内通知(实时)
│
├──▶ 桌面通知(如支持)
│ ├── Linux: notify-send "AtomCode" "Done"
│ ├── macOS: terminal-notifier -title "AtomCode" -message "Done"
│ └── 终端: \x1b]777;notify;AtomCode Done\x1b\\
│
├──▶ WebUI 通知(通过 SSE)
│
└──▶ Telemetry 事件2. 终端检测系统
2.1 识别的终端
| 终端名称 | 环境变量 | 特性支持 |
|---|---|---|
| Kitty | KITTY_WINDOW_ID | Kitty 键盘协议、通知 |
| WezTerm | WEZTERM_PANE | 图像、超链接 |
| Ghostty | ghostty | 新终端 |
| Apple Terminal | TERM_PROGRAM=Apple_Terminal | 基础功能 |
| iTerm2 | TERM_PROGRAM=iTerm.app | 图像、标记 |
| tmux | TMUX | 面板管理 |
2.2 Kitty 键盘协议
Kitty 键盘协议(渐进式键盘事件):
- KITTY_WINDOW_ID 存在时启用
- 增强按键事件(修饰键组合等)
- 支持: 大部分现代终端
- 回退: 终端不支持时还原为标准模式
ATOMCODE_KBD_NOT_ENHANCED:
禁用 Kitty 键盘协议
─────────────────────────────────
修复:
- JediTerm 鼠标移动乱码(不再启用 Kitty 键盘协议)
- panic 时 Kitty 协议残留3. MacOS 集成
3.1 特殊路径
/Applications/PgyVisitor_download.app/Library/LaunchDaemons/com.oray.pgy.plist
Library/Logs/PgyVisitor这些路径来自蒲公英(Pgyer)访客模式,表明 AtomCode 在 macOS 上可能通过 Pgyer 分发。
3.2 Swift/AppleScript
osascript(AppleScript)用于:
- 显示原生 macOS 对话框
- 申请文件权限
- 通知中心消息3.3 macOS 敏感路径
/Applications
/var/folders
Library/Logs4. 系统托盘与后台
4.1 通知后台配置
toml
[notifications]
# 默认启用桌面通知
# enabled = true4.2 NotificationConfig
rust
struct NotificationConfig {
// 通知启用状态
// 无已发现的具体字段结构
}5. 终端 UI 内通知字符串
从嵌入式 JS 提取的本地化通知文本:
javascript
"chat.stop": "Stop",
"chat.send": "Send",
"chat.queue": "Queue message (sent after the current turn finishes)",
"chat.queued": "Queued",
"chat.removeQueued": "Remove",
"chat.error": "[Error: {msg}]",
"chat.connError": "[Connection error: {msg}]",CSS 类名:
.ghost-btn
.header-remote-btn
.session-body
.app-sidebar
.chat-body
.chat-landing
.code-block-wrapper
.cwd-breadcrumb
.cwd-prefix
.dir-breadcrumb
.dir-browser
.effort-prefix
.provider-edit-btn
.sidebar-search6. NotificationConfig 配置
toml
[notification]
# enabled = true # 默认启用NotificationConfig 结构体在二进制中的位置:
rust
struct NotificationConfig通知系统受 ATOMCODE_PLAIN(纯文本模式)和 ATOMCODE_RETAIN(保留模式)影响。
7. 终端特性支持汇总
| 特性 | Kitty | WezTerm | iTerm2 | Terminal.app | Ghostty |
|---|---|---|---|---|---|
| 图像渲染 | ✅ | ✅ | ⬜ | ⬜ | ⬜ |
| 增强键盘 | ✅ | ✅ | ⬜ | ⬜ | ⬜ |
| 通知 | ✅ | ⬜ | ✅ | ⬜ | ⬜ |
| 超链接 | ✅ | ✅ | ✅ | ⬜ | ✅ |
| 标记/跳转 | ⬜ | ✅ | ✅ | ⬜ | ⬜ |
8. 新覆盖的盲区
| # | 之前未覆盖的领域 | 状态 | 发现 |
|---|---|---|---|
| 1 | 桌面通知系统 | ✅ | 4 种通知方式 + 5 种事件 |
| 2 | 终端检测机制 | ✅ | 6 种终端 + Kitty 协议 |
| 3 | macOS 集成细节 | ✅ | osascript, Pgyer |
| 4 | TUI 通知字符串 | ✅ | 本地化消息 + CSS 类名 |
| 5 | Kitty 键盘协议回退 | ✅ | KBD_NOT_ENHANCED 控制 |
本报告由持续分析循环生成
逆向命令索引
bash
# 提取通知相关
strings atomcode.bin.bak | grep -iE "notify-send|unfocused|KITTY_WINDOW|WEZTERM" | sort -u
# 输出: notify-send unfocused KITTY_WINDOW_ID WEZTERM_PANE
# 提取通知配置
strings atomcode.bin.bak | grep -iE "NotificationConfig" | sort -u