Update docs for ctx.ui.editor() and handoff example

- Added ctx.ui.editor() to hooks.md and custom-tools.md
- Added ctx.ui.editor() to CHANGELOG.md
- Added handoff.ts to examples/hooks/README.md
This commit is contained in:
Mario Zechner 2026-01-02 01:26:21 +01:00
parent af4c66117b
commit 02175d908b
4 changed files with 20 additions and 9 deletions

View file

@ -257,6 +257,23 @@ async execute(toolCallId, params, onUpdate, ctx, signal) {
}
```
### Multi-line Editor
For longer text editing, use `pi.ui.editor()` which supports Ctrl+G for external editor:
```typescript
async execute(toolCallId, params, onUpdate, ctx, signal) {
const text = await pi.ui.editor("Edit your response:", "prefilled text");
// Returns edited text or undefined if cancelled (Escape)
// Ctrl+Enter to submit, Ctrl+G to open $VISUAL or $EDITOR
if (!text) {
return { content: [{ type: "text", text: "Cancelled" }] };
}
// ...
}
```
## Session Lifecycle
Tools can implement `onSession` to react to session changes: