mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 02:01:29 +00:00
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:
parent
af4c66117b
commit
02175d908b
4 changed files with 20 additions and 9 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue