feat(hooks): expose setTitle to HookUIContext (#446)

This commit is contained in:
Aliou Diallo 2026-01-04 20:55:52 +01:00 committed by GitHub
parent affa618b43
commit 5cb7af1ddc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 34 additions and 1 deletions

View file

@ -437,6 +437,9 @@ ctx.ui.setWidget("my-todos", [
]);
ctx.ui.setWidget("my-todos", undefined); // Clear widget
// Set the terminal window/tab title
ctx.ui.setTitle("pi - my-project");
// Set the core input editor text (pre-fill prompts, generated content)
ctx.ui.setEditorText("Generated prompt text here...");
@ -457,6 +460,10 @@ const currentText = ctx.ui.getEditorText();
- Supports ANSI styling via `ctx.ui.theme` (including `strikethrough`)
- **Caution:** Keep widgets small (a few lines). Large widgets from multiple hooks can cause viewport overflow and TUI flicker. Max 10 lines total across all string widgets.
**Terminal title notes:**
- Uses OSC escape sequence (works in most modern terminals like iTerm2, Terminal.app, Windows Terminal)
- Useful for showing project name, current task, or session status in the terminal tab/window title
**Custom widget components:**
For more complex widgets, pass a factory function to `setWidget()`: