Skip to content

Local/traecn hook fix - #341

Closed
duyinghua wants to merge 5 commits into
wxtsky:mainfrom
duyinghua:local/traecn-hook-fix
Closed

duyinghua wants to merge 5 commits into
wxtsky:mainfrom
duyinghua:local/traecn-hook-fix

Conversation

@duyinghua

Copy link
Copy Markdown

Fix the issue where TraeCN IDE is not supported

更新官方 Hook 事件配置与会话生命周期处理,补充回归测试和本地热重启构建支持,并发布 1.0.34-beta.0 测试版本。
为Trae CN的solo_agent主代理添加特殊判断,避免被当作子代理处理
…k handling

1. 回滚CFBundleShortVersionString和CFBundleVersion到1.0.34-beta.0
2. 删除不再需要的旧版Trae IDE托管hook清理逻辑代码
wxtsky pushed a commit that referenced this pull request Sep 23, 2026
Trae CN's hooks fire Claude-style event names, its bundle is Trae CN.app,
and its primary conversation is tagged agent_id=solo_agent rather than
being a folded subagent.
wxtsky added a commit that referenced this pull request Sep 23, 2026
`.traeIDE` backs BOTH built-ins — Trae (~/.trae/hooks.json) and Trae CN
(~/.trae-cn/hooks.json) — and both editions document the same six
Claude-style events: SessionStart, UserPromptSubmit, PreToolUse,
PostToolUse, Stop, Notification (docs.trae.ai/ide/hook-configuration-reference,
docs.trae.cn/ide_hook-configuration-reference). The Cursor-style camelCase
list it used to share with `.flat` never fires in either edition, so the
switch is right for international Trae too — it is not a CN-only change.

Trim #341's list to the documented set: SessionEnd / SubagentStart /
SubagentStop / PreCompact are not TraeCode events, and Notification is
async with its stdout ignored, so it needs no 86400s timeout.

Install now also drops CodeIsland entries left under the old camelCase
keys (as Trae CLI Next already does); the per-event loop only replaced
entries under current names, so upgraded configs kept dead keys forever.
User hooks under any key are preserved.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
wxtsky added a commit that referenced this pull request Sep 23, 2026
…app)

Trae CN has shipped as /Applications/Trae CN.app with bundle id
cn.trae.app since its first macOS build (Homebrew trae-cn cask; the
TraeCode CN 3.3.104 DMG still does), main binary `Electron`, helpers
`Trae CN Helper …`. CodeIsland assumed `TraeCN.app` or the international
`Trae.app`/`com.trae.app`, so Trae CN was never recognised as itself.

- Keep #341's bundle list (and its removal of `/trae.app/`, which made an
  open international Trae keep Trae CN sessions alive), but move it to
  CodeIslandCore so the bridge uses it too: `traecn` now matches the
  bundle in `sourceMatchesExecutablePath`, so `_ppid` resolves to the
  long-lived Trae CN process instead of the `bash -c` hook shell, which
  exits after every hook and idled/dropped the card. It stays an IDE
  host, so ancestry inference still never picks it (#220).
- findTraeCNPids also looks for the real bundle.
- Map cn.trae.app → traecn / "Trae CN" for native-app mode, the jump
  target, the terminal badge and IDE-terminal detection.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
wxtsky added a commit that referenced this pull request Sep 23, 2026
TRAE's desktop IDE puts `agent_id` + `agent_type` on EVERY hook as the
agent executing it (docs.trae.cn/enterprise_hook-configuration-reference,
请求体通用字段), main conversation included, and TraeCode has no
SubagentStart/SubagentStop events. The main agent's id is `solo_agent`
(what #341 observed), but just as well another built-in (`builder_v3`,
`chat_v3`, `custom_v3`, `solo_coder`, … are all in the TraeCode CN
3.3.104 agent catalog) or a user's custom agent.

#341 exempted only `solo_agent` on `traecn`, and only at the reducer's
routing branch — metadata extraction and the app's agent-scoped
permission/question handling still treated it as a subagent, and any
other agent id (or the international edition) still lost every turn
after the first Stop. Drop the id at HookEvent instead for `trae` and
`traecn`, so every consumer sees one main conversation; the raw value
stays in rawJSON. Claude-style routing is unchanged for other sources.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@wxtsky

wxtsky commented Sep 23, 2026

Copy link
Copy Markdown
Owner

感谢 @duyinghua!方向是对的:TRAE 的 IDE Hook 确实用 Claude 风格的事件名,Trae CN 的真实包名确实是 Trae CN.app,solo_agent 也确实不是子智能体。

你的分支没开「Allow edits by maintainers」,我没法把修改推上来,所以直接合进了 main。你的提交已压成一个、保留你的署名(ee7364a),后面跟着几处补充修改:

  1. 去掉 Info.plist 的版本号改动:发版由维护者来做。
  2. .traeIDE 事件表(4a698f2):国际版 Trae 也用这个格式。两边官方文档(docs.trae.ai / docs.trae.cn)列的都是同样 6 个事件:SessionStart / UserPromptSubmit / PreToolUse / PostToolUse / Stop / Notification,所以改成 Claude 风格对两个版本都对,之前装的驼峰事件名在两边都不会触发。不过 SessionEnd / Subagent* / PreCompact 不在文档里,已去掉。Notification 在 Trae 里是异步的,改成 5 秒超时。安装时也会清理旧的驼峰事件名条目,否则老用户配置里会一直残留这些 key。另外原 PR 会让现有测试 testBuiltInTraeKeepsLegacyIDEHooksPath 失败。
  3. 包名识别(f8bc91b):包名列表挪到了 Core,bridge 也用它。否则 _ppid 会指向跑 hook 的临时 bash -c,每次 hook 结束卡片就会变成空闲甚至消失。另外 bundle id 从 com.trae.app(国际版)改成 cn.trae.app,跳转和徽标都会用到。
  4. agent_id 处理(7fecfb4):企业版 Hook 文档 说明每个事件都带 agent_id,指的是当前执行 Hook 的智能体。主对话也可能是 builder_v3 或自定义智能体,不止 solo_agent,所以改成在 HookEvent 层对 trae/traecn 直接忽略 agent_id,替代 reducer 里只针对 solo_agent 的特判。

随下一个版本发布。再次感谢!

@wxtsky wxtsky closed this Sep 23, 2026
@wxtsky wxtsky mentioned this pull request Sep 23, 2026
@duyinghua

Copy link
Copy Markdown
Author

很专业的回复,感谢采纳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants