feat(hooks): add setWidget API for multi-line status displays

- ctx.ui.setWidget(key, lines) for multi-line displays above editor
- Widgets appear below 'Working...' indicator, above editor
- Supports ANSI styling including strikethrough
- Added theme.strikethrough() method
- Plan-mode hook now shows todo list with checkboxes
- Completed items show checked box and strikethrough text
This commit is contained in:
Helmut Januschka 2026-01-03 16:01:05 +01:00 committed by Mario Zechner
parent 537d672f17
commit dc44816051
11 changed files with 127 additions and 6 deletions

View file

@ -421,6 +421,15 @@ ctx.ui.notify("Done!", "info"); // "info" | "warning" | "error"
ctx.ui.setStatus("my-hook", "Processing 5/10..."); // Set status
ctx.ui.setStatus("my-hook", undefined); // Clear status
// Set a multi-line widget (displayed above editor, below "Working..." indicator)
ctx.ui.setWidget("my-todos", [
theme.fg("accent", "Plan Progress:"),
theme.fg("success", "☑ ") + theme.fg("muted", theme.strikethrough("Read files")),
theme.fg("muted", "☐ ") + "Modify code",
theme.fg("muted", "☐ ") + "Run tests",
]);
ctx.ui.setWidget("my-todos", undefined); // Clear widget
// Set the core input editor text (pre-fill prompts, generated content)
ctx.ui.setEditorText("Generated prompt text here...");
@ -434,6 +443,12 @@ const currentText = ctx.ui.getEditorText();
- Text is sanitized (newlines/tabs replaced with spaces) and truncated to terminal width
- Use `ctx.ui.theme` to style status text with theme colors (see below)
**Widget notes:**
- Widgets are multi-line displays shown above the editor (below "Working..." indicator)
- Multiple hooks can set widgets using unique keys
- Use for progress lists, todo tracking, or any multi-line status
- Supports ANSI styling via `ctx.ui.theme` (including `strikethrough`)
**Styling with theme colors:**
Use `ctx.ui.theme` to apply consistent colors that respect the user's theme: