Skip to content

fix(copilot-cli): preserve custom hooks during upgrade - #1235

Open
rudycelekli wants to merge 1 commit into
mksglu:nextfrom
rudycelekli:fix/copilot-preserve-custom-hooks-20261001
Open

rudycelekli wants to merge 1 commit into
mksglu:nextfrom
rudycelekli:fix/copilot-preserve-custom-hooks-20261001

Conversation

@rudycelekli

Copy link
Copy Markdown

What / Why / How

context-mode upgrade currently 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 in hooks/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

  • GitHub Copilot CLI (standalone user hook configuration)
  • The persistence change is shared across operating systems; native execution was checked on macOS with Node 22.19.0.

Test plan

  • RED: the new public configureAllHooks() regression fails on next 4621364: persisted settings lose both custom callbacks and the context-mode timeout.
  • GREEN: it preserves callbacks, ordering, metadata, unrelated settings/events and second-run idempotence.
  • Existing domain tests also cover adding context-mode alongside command/HTTP callbacks for each of the six events, retaining Bash/PowerShell metadata without running either command.
  • Focused adapter + hook suites: 33 passed.
  • Full repository Vitest suite via npm test --ignore-scripts: 213 files passed; 4,782 tests passed, 24 skipped. --ignore-scripts skips the generated-bundle pretest, as required by the repository ops TDD instructions.
  • npm run typecheck and git diff --check passed.

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

  • Tests updated in the existing adapter test file; red → green recorded
  • Full Vitest suite passes (bundle pretest intentionally skipped per ops policy)
  • Typecheck
  • Documentation: no new public options or install steps
  • No path construction changes
  • Targets next

AI assistance

Prepared with OpenAI Codex, with source/history and duplicate checks and independent patch review. No upstream merge performed.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
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.

1 participant