zai-org / zai-org/feedback

[Bug] 桌面版 0.16.5 钩子三类问题:UserPromptSubmit/PostToolUse 配置钩子不执行;UI 新建的钩子重启后消失;UI 列表与 config.json 不一致

Open
#497 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
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.jsonhooks.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
复现
  1. ~/.zcode/cli/config.json 写入:
"hooks": {
  "enabled": true,
  "events": {
    "UserPromptSubmit": [
      { "matcher": "", "hooks": [
        { "type": "command", "command": "python3 /path/to/logger.py", "timeout": 5 }
      ]}
    ]
  }
}
  1. 完全重启应用,新会话发送任意消息
  2. 预期:logger.py 收到 stdin 事件并写文件;实际:无任何执行痕迹

问题 B:UI「钩子」页面新建的钩子重启后消失

  1. 设置 → 钩子 → 新建钩子,填事件/命令/参数,保存(保存后检查 config.json,确认已正确写入)
  2. 完全退出并重启应用
  3. 钩子页面「已安装」变回 0,刚建的钩子从 UI 消失

问题 C:UI 列表与 config.json 两套账

config.json 中存在 4 个钩子时,钩子页面「已安装」始终显示 0;「旧版」区只识别 ~/.claude 旧配置。且在钩子页面点「导入」等操作会用 UI 内部(空的)记录整体覆盖 config.jsonhooks.events,把手动配置的钩子(含正常工作的 SessionStart)一并清掉。

期望

  1. PostToolUse / UserPromptSubmit 配置钩子按文档正常执行
  2. UI 新建的钩子持久化,重启不丢
  3. UI「已安装」列表与 config.json 保持一致,或至少只读展示配置文件的钩子;页面操作不清空用户手写的配置

感谢团队,ZCode 体验整体很好,钩子是自动化工作流的关键一环,期待修复。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.