Skip to content

feat(hooks): support preserveUnownedHooks for Qwen Code - #3509

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3496-qwencode-preserve-hooks
Oct 17, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3496-qwencode-preserve-hooks

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Qwen Code hook generation merged .qwen/settings.json correctly for unrelated settings, but replaced every existing hook handler even with "preserveUnownedHooks": true — the adapter never consumed preserveUnowned and inherited supportsPreserveUnowned() === false.

  • QwencodeHooks now uses the shared ownership lock and mergeGeneratedHookLists helper (matcher-group shape), like Claude Code, Codex CLI and Cursor. It reads .qwen/.rulesync-hooks-lock.json (~/.qwen/... in global scope) and emits it as an auxiliary file only when preservation is on.
  • sequential keeps its meaning: the preservation helper now folds a preserved matcher group into an existing one only when its group-level keys other than matcher and hooks agree. A foreign { matcher: "Bash", sequential: true } group is therefore kept as its own group next to the generated { matcher: "Bash" } group, instead of losing sequential execution (or making the generated group's handlers sequential). For the other adapters, generated groups carry only matcher and hooks, so their behavior is unchanged unless a foreign group has extra group-level keys (e.g. a Factory Droid-style commandRegex), which are now preserved rather than dropped on merge.
  • Docs: docs/guide/configuration.md and docs/reference/file-formats.md list Qwen Code among the supported targets.

Tests

  • qwencode-hooks.test.ts: unrelated settings preserved, foreign sequential handler kept as its own group, lock contents, retraction of a formerly generated handler with an intact lock, idempotency across two runs, and default replacement (no lock) when preservation is off.
  • preserve-unowned-hook-commands.test.ts: groups with differing group-level keys are not merged, in both directions.

Closes #3496

🤖 Generated with Claude Code

https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv

dyoshikawa and others added 3 commits October 17, 2026 21:45
Qwen Code hook generation replaced every existing handler in
`.qwen/settings.json` even with `preserveUnownedHooks: true`. Wire the
adapter into the shared ownership lock and preservation helper, as Claude
Code, Codex CLI and Cursor already do, and emit the lock next to the
settings file.

A preserved matcher group now joins a generated group only when its
group-level keys other than `matcher` and `hooks` agree, so a foreign
`sequential` group is kept as its own group instead of losing (or
gaining) sequential execution.

Closes #3496

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv
…encode-preserve-hooks

# Conflicts:
#	docs/reference/file-formats.md
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit b0877b8 into main Oct 17, 2026
9 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3496-qwencode-preserve-hooks branch October 17, 2026 13:32
dyoshikawa added a commit that referenced this pull request Oct 17, 2026
…dex-hook-positions

Resolve the conflict with the Qwen Code preservation change (#3509): a
generated handler is updated in place, and a new one joins an existing group,
only when the group's matcher and group-level keys (such as `sequential`)
match its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv
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.

Extend preserveUnownedHooks to Qwen Code

1 participant