github / github/copilot-cli

Hooks in config.json are not preserved across session starts

Offen
#3,403 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:configuration area:plugins
Vorherrschende Sprache
Shell
Sterne
11.2k
Forks
1.9k
Ø Merge
14 Std. 16 Min.
Gemergte PRs (30 T.)
6

Beschreibung

## Bug

The `hooks` field in `~/.copilot/config.json` is documented as the location for user-level hooks (`copilot help config` states: "In global config.json these act as user-level hooks").

However, Copilot CLI **overwrites `config.json` on every session start**, dropping any `hooks` key that was previously written there. This makes it impossible for external tools (like [cmux](https://github.com/manaflow-ai/cmux)) to install persistent user-level hooks.

## Steps to Reproduce

1. Install cmux session restore hooks: `cmux hooks copilot install`
2. Verify `~/.copilot/config.json` now contains a `"hooks"` key with SessionStart, SessionEnd, etc.
3. Start a new `copilot` session
4. Check `~/.copilot/config.json` — the `"hooks"` key is gone

## Expected Behavior

The `hooks` field should be preserved when Copilot CLI rewrites `config.json` (e.g., when updating `expAssignmentsCache` or other managed state).

## Additional Context

- Copilot CLI version: 1.0.49
- Hooks in `settings.json` do **not** fire as user-level hooks (despite being a recognized config location)
- The file header says `// User settings belong in settings.json` but `copilot help config` says hooks go in `config.json`
- macOS, cmux latest

## Workaround

Currently none for global user-level hooks. Repo-level hooks (`.github/hooks/*.json`) work but require per-repo setup.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by locating the code that rewrites ~/.copilot/config.json and reproduce the session-start behavior with a hooks entry installed by cmux. The fix is complete when managed state updates no longer remove the hooks field; verify this with the documented reproduction steps.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cli, shell
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
62/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.