docs(coding-agent): document model_select hook

Add CHANGELOG entry and extension documentation for the new model_select
event that fires on model changes via /model, Ctrl+P, or session restore.
This commit is contained in:
Marc Krenn 2026-01-11 13:29:00 +01:00 committed by Mario Zechner
parent c41714662a
commit 943654cc93
2 changed files with 27 additions and 0 deletions

View file

@ -4,6 +4,7 @@
### Added
- `model_select` extension hook fires when model changes via `/model`, model cycling, or session restore with `source` field and `previousModel` ([#XXX](https://github.com/badlogic/pi-mono/pull/XXX))
- `ctx.ui.setWorkingMessage()` extension API to customize the "Working..." message during streaming ([#625](https://github.com/badlogic/pi-mono/pull/625) by [@nicobailon](https://github.com/nicobailon))
- Skill slash commands: loaded skills are registered as `/skill:name` commands for quick access. Toggle via `/settings` or `skills.enableSkillCommands` in settings.json. ([#630](https://github.com/badlogic/pi-mono/pull/630) by [@Dwsy](https://github.com/Dwsy))
- Slash command autocomplete now uses fuzzy matching (type `/skbra` to match `/skill:brave-search`)

View file

@ -290,6 +290,9 @@ user sends another prompt ◄─────────────────
├─► session_before_tree (can cancel or customize)
└─► session_tree
/model or Ctrl+P (model selection/cycling)
└─► model_select
exit (Ctrl+C, Ctrl+D)
└─► session_shutdown
```
@ -481,6 +484,29 @@ pi.on("context", async (event, ctx) => {
**Examples:** [plan-mode.ts](../examples/extensions/plan-mode.ts)
### Model Events
#### model_select
Fired when the model changes via `/model` command, model cycling (`Ctrl+P`), or session restore.
```typescript
pi.on("model_select", async (event, ctx) => {
// event.model - newly selected model
// event.previousModel - previous model (undefined if first selection)
// event.source - "set" | "cycle" | "restore"
const prev = event.previousModel
? `${event.previousModel.provider}/${event.previousModel.id}`
: "none";
const next = `${event.model.provider}/${event.model.id}`;
ctx.ui.notify(`Model changed (${event.source}): ${prev} -> ${next}`, "info");
});
```
Use this to update UI elements (status bars, footers) or perform model-specific initialization when the active model changes.
### Tool Events
#### tool_call