feat(coding-agent): add configurable working indicator closes #3413
This commit is contained in:
@@ -1922,7 +1922,7 @@ Extensions can interact with users via `ctx.ui` methods and customize how messag
|
||||
- Async operations with cancel (BorderedLoader)
|
||||
- Settings toggles (SettingsList)
|
||||
- Status indicators (setStatus)
|
||||
- Working message during streaming (setWorkingMessage)
|
||||
- Working message and indicator during streaming (`setWorkingMessage`, `setWorkingIndicator`)
|
||||
- Widgets above/below editor (setWidget)
|
||||
- Custom footers (setFooter)
|
||||
|
||||
@@ -2007,6 +2007,12 @@ ctx.ui.setStatus("my-ext", undefined); // Clear
|
||||
ctx.ui.setWorkingMessage("Thinking deeply...");
|
||||
ctx.ui.setWorkingMessage(); // Restore default
|
||||
|
||||
// Working indicator (shown during streaming)
|
||||
ctx.ui.setWorkingIndicator({ frames: ["●"] }); // Static dot
|
||||
ctx.ui.setWorkingIndicator({ frames: ["·", "•", "●", "•"], intervalMs: 120 });
|
||||
ctx.ui.setWorkingIndicator({ frames: [] }); // Hide indicator
|
||||
ctx.ui.setWorkingIndicator(); // Restore default spinner
|
||||
|
||||
// Widget above editor (default)
|
||||
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
||||
// Widget below editor
|
||||
@@ -2271,6 +2277,7 @@ All examples in [examples/extensions/](../examples/extensions/).
|
||||
| `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
|
||||
| **UI Components** |||
|
||||
| `status-line.ts` | Footer status indicator | `setStatus`, session events |
|
||||
| `working-indicator.ts` | Customize the streaming working indicator | `setWorkingIndicator`, `registerCommand` |
|
||||
| `custom-footer.ts` | Replace footer entirely | `registerCommand`, `setFooter` |
|
||||
| `custom-header.ts` | Replace startup header | `on("session_start")`, `setHeader` |
|
||||
| `modal-editor.ts` | Vim-style modal editor | `setEditorComponent`, `CustomEditor` |
|
||||
|
||||
@@ -994,7 +994,7 @@ If a dialog method includes a `timeout` field, the agent-side will auto-resolve
|
||||
|
||||
Some `ExtensionUIContext` methods are not supported or degraded in RPC mode because they require direct TUI access:
|
||||
- `custom()` returns `undefined`
|
||||
- `setWorkingMessage()`, `setFooter()`, `setHeader()`, `setEditorComponent()`, `setToolsExpanded()` are no-ops
|
||||
- `setWorkingMessage()`, `setWorkingIndicator()`, `setFooter()`, `setHeader()`, `setEditorComponent()`, `setToolsExpanded()` are no-ops
|
||||
- `getEditorText()` returns `""`
|
||||
- `getToolsExpanded()` returns `false`
|
||||
- `pasteToEditor()` delegates to `setEditorText()` (no paste/collapse handling)
|
||||
|
||||
@@ -735,6 +735,31 @@ ctx.ui.setStatus("my-ext", undefined);
|
||||
|
||||
**Examples:** [status-line.ts](../examples/extensions/status-line.ts), [plan-mode.ts](../examples/extensions/plan-mode.ts), [preset.ts](../examples/extensions/preset.ts)
|
||||
|
||||
### Pattern 4b: Working Indicator Customization
|
||||
|
||||
Customize the inline working indicator shown while pi is streaming a response.
|
||||
|
||||
```typescript
|
||||
// Static indicator
|
||||
ctx.ui.setWorkingIndicator({ frames: ["●"] });
|
||||
|
||||
// Custom animated indicator
|
||||
ctx.ui.setWorkingIndicator({
|
||||
frames: ["·", "•", "●", "•"],
|
||||
intervalMs: 120,
|
||||
});
|
||||
|
||||
// Hide the indicator entirely
|
||||
ctx.ui.setWorkingIndicator({ frames: [] });
|
||||
|
||||
// Restore pi's default spinner
|
||||
ctx.ui.setWorkingIndicator();
|
||||
```
|
||||
|
||||
This only affects the normal streaming working indicator. Compaction and retry loaders keep their built-in styling.
|
||||
|
||||
**Examples:** [working-indicator.ts](../examples/extensions/working-indicator.ts)
|
||||
|
||||
### Pattern 5: Widgets Above/Below Editor
|
||||
|
||||
Show persistent content above or below the input editor. Good for todo lists, progress.
|
||||
@@ -881,6 +906,7 @@ export default function (pi: ExtensionAPI) {
|
||||
- **Async with cancel**: [examples/extensions/qna.ts](../examples/extensions/qna.ts) - BorderedLoader for LLM calls
|
||||
- **Settings toggles**: [examples/extensions/tools.ts](../examples/extensions/tools.ts) - SettingsList for tool enable/disable
|
||||
- **Status indicators**: [examples/extensions/plan-mode.ts](../examples/extensions/plan-mode.ts) - setStatus and setWidget
|
||||
- **Working indicator**: [examples/extensions/working-indicator.ts](../examples/extensions/working-indicator.ts) - setWorkingIndicator
|
||||
- **Custom footer**: [examples/extensions/custom-footer.ts](../examples/extensions/custom-footer.ts) - setFooter with stats
|
||||
- **Custom editor**: [examples/extensions/modal-editor.ts](../examples/extensions/modal-editor.ts) - Vim-like modal editing
|
||||
- **Snake game**: [examples/extensions/snake.ts](../examples/extensions/snake.ts) - Full game with keyboard input, game loop
|
||||
|
||||
Reference in New Issue
Block a user