fix(copilot-cli): preserve custom hooks during upgrade - #1235
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / Why / How
context-mode upgradecurrently replaces every declared Copilot CLI event array with a single context-mode callback. If a user keeps policy checks, audit hooks or other custom handlers inhooks/context-mode.json, the upgrade silently removes them; it also removes timeout and other metadata on the context-mode callback.Update the exact context-mode dispatcher entry in place, retaining its metadata and ordering. Preserve unrelated command and HTTP handlers, other event names and top-level settings. Add the context-mode callback when it is missing, and keep repeated upgrades idempotent. The existing flat hook schema and all six events remain intact.
The overwrite was introduced with the Copilot CLI adapter in #787. This change only affects its standalone user hook configuration, not other hook files or the bundled plugin.
Affected platforms
Test plan
configureAllHooks()regression fails onnext4621364: persisted settings lose both custom callbacks and the context-mode timeout.npm test --ignore-scripts: 213 files passed; 4,782 tests passed, 24 skipped.--ignore-scriptsskips the generated-bundle pretest, as required by the repository ops TDD instructions.npm run typecheckandgit diff --checkpassed.A live Copilot model session and client transcript were not exercised; the reproduction covers real persisted configuration through the public adapter API, not downstream client execution. Native Linux/Windows execution is not claimed; upstream CI remains authoritative for those platforms. No user configuration, generated bundles or provider credentials were changed during validation.
Checklist
nextAI assistance
Prepared with OpenAI Codex, with source/history and duplicate checks and independent patch review. No upstream merge performed.