[Bug] 桌面版 0.16.5 钩子三类问题:UserPromptSubmit/PostToolUse 配置钩子不执行;UI 新建的钩子重启后消失;UI 列表与 config.json 不一致
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
环境
- ZCode Desktop 0.16.5,macOS (Apple Silicon, darwin 25.6.0 arm64)
- 配置文件:
~/.zcode/cli/config.json,hooks.enabled: true
问题 A:UserPromptSubmit / PostToolUse 配置钩子不执行
config.json 中配置了 SessionStart / PreToolUse / PostToolUse / UserPromptSubmit 四个钩子(格式按文档:hooks.events.<Event>[].hooks[]),重启应用后:
- ✅
SessionStart:正常执行(additionalContext成功注入新会话) - ⚠️
PreToolUse:未充分验证 - ❌
PostToolUse/UserPromptSubmit:从未执行——脚本会向~/Documents/Claude/system/staging/raw-events/日期.jsonl追加记录(脚本手动运行验证过完全正常,stdin 收事件、exit 0),但新会话中发送消息、调用工具后记录文件零新增;日志(~/.zcode/cli/log/zcode-*.jsonl)中也无任何 hook 运行记录(hookCount: 0)
复现
- 在
~/.zcode/cli/config.json写入:
"hooks": {
"enabled": true,
"events": {
"UserPromptSubmit": [
{ "matcher": "", "hooks": [
{ "type": "command", "command": "python3 /path/to/logger.py", "timeout": 5 }
]}
]
}
}
- 完全重启应用,新会话发送任意消息
- 预期:logger.py 收到 stdin 事件并写文件;实际:无任何执行痕迹
问题 B:UI「钩子」页面新建的钩子重启后消失
- 设置 → 钩子 → 新建钩子,填事件/命令/参数,保存(保存后检查
config.json,确认已正确写入) - 完全退出并重启应用
- 钩子页面「已安装」变回 0,刚建的钩子从 UI 消失
问题 C:UI 列表与 config.json 两套账
config.json 中存在 4 个钩子时,钩子页面「已安装」始终显示 0;「旧版」区只识别 ~/.claude 旧配置。且在钩子页面点「导入」等操作会用 UI 内部(空的)记录整体覆盖 config.json 的 hooks.events,把手动配置的钩子(含正常工作的 SessionStart)一并清掉。
期望
PostToolUse/UserPromptSubmit配置钩子按文档正常执行- UI 新建的钩子持久化,重启不丢
- UI「已安装」列表与
config.json保持一致,或至少只读展示配置文件的钩子;页面操作不清空用户手写的配置
感谢团队,ZCode 体验整体很好,钩子是自动化工作流的关键一环,期待修复。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing ~/.zcode/cli/config.json with the Hooks settings page and the ~/.zcode/cli/log/zcode-*.jsonl records described in the report. Trace how hooks.events is loaded, displayed, and written during restart and import operations. Done means PostToolUse and UserPromptSubmit execute, UI-created hooks persist, and UI actions preserve manually configured hooks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, macos
- Domain
- desktop, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100