@bastani/atomic 0.10.14 → 0.10.15-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +1 -1
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
- package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
- package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
- package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
- package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
- package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
- package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/auth-cli.code.js +1 -1
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +1 -1
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/compaction/compactor.d.ts +0 -8
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +2 -2
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/sdk.code.js +1 -1
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +3 -3
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +2 -2
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +2 -2
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +2 -2
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +2 -2
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +2 -2
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +1 -1
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +1 -1
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +21 -1
- package/dist/index.js +2 -2
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +2 -2
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/utils/startup-database-spare.code.js +1 -1
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks/reference.md +182 -0
- package/docs/background-tasks.md +98 -405
- package/docs/build.md +67 -27
- package/docs/changelog.mdx +11 -1
- package/docs/codemode.md +108 -39
- package/docs/compaction/branch-summaries.md +54 -0
- package/docs/compaction/custom-compactors.md +161 -0
- package/docs/compaction/memory-compaction.md +77 -0
- package/docs/compaction/reference.md +86 -38
- package/docs/compaction.md +51 -252
- package/docs/computer-use.md +169 -321
- package/docs/containerization.md +71 -57
- package/docs/custom-provider/api-reference.md +119 -25
- package/docs/custom-provider/oauth.md +114 -132
- package/docs/custom-provider/override.md +37 -27
- package/docs/custom-provider/registration.md +107 -83
- package/docs/custom-provider/streaming.md +85 -71
- package/docs/custom-provider.md +85 -52
- package/docs/development.md +39 -29
- package/docs/docs.json +80 -67
- package/docs/environment-variables.md +94 -44
- package/docs/extensions/api-reference.md +86 -43
- package/docs/extensions/authoring.md +162 -154
- package/docs/extensions/events.md +80 -25
- package/docs/extensions/examples.md +90 -85
- package/docs/extensions/ui.md +206 -82
- package/docs/extensions.md +79 -108
- package/docs/getting-started/authentication.md +67 -36
- package/docs/getting-started/first-session.md +53 -43
- package/docs/getting-started/installation.md +117 -90
- package/docs/getting-started/project-instructions.md +48 -34
- package/docs/guides/configuration.md +82 -20
- package/docs/guides/non-interactive.md +66 -24
- package/docs/guides/resume-on-any-machine.md +135 -82
- package/docs/guides/team-setup.md +114 -105
- package/docs/guides.md +76 -32
- package/docs/herdr.md +16 -17
- package/docs/how-atomic-works.md +140 -0
- package/docs/index.md +58 -44
- package/docs/intercom/operations.md +141 -151
- package/docs/intercom/reference.md +85 -108
- package/docs/intercom.md +84 -145
- package/docs/json.md +120 -67
- package/docs/keybindings.md +85 -49
- package/docs/libraries/agent-core.md +137 -275
- package/docs/libraries/ai.md +100 -84
- package/docs/libraries/codemode.md +210 -300
- package/docs/libraries/schema.md +59 -53
- package/docs/libraries/storage-postgres.md +49 -35
- package/docs/libraries/telemetry.md +153 -354
- package/docs/libraries/tui.md +265 -393
- package/docs/libraries.md +42 -26
- package/docs/llama-cpp.md +171 -161
- package/docs/mcp-servers.md +90 -51
- package/docs/models/choose-a-model.md +188 -0
- package/docs/models/reference.md +74 -30
- package/docs/models.md +153 -88
- package/docs/orchestration/migrating-workflows.md +23 -16
- package/docs/orchestration/patterns.md +39 -44
- package/docs/orchestration.md +65 -26
- package/docs/packages/authoring.md +51 -29
- package/docs/packages/reference.md +42 -21
- package/docs/packages.md +69 -58
- package/docs/programmatic.md +118 -24
- package/docs/prompt-templates.md +84 -83
- package/docs/providers/reference.md +43 -48
- package/docs/providers.md +219 -451
- package/docs/quickstart.md +140 -120
- package/docs/reference/cli.md +135 -97
- package/docs/reference.md +20 -19
- package/docs/rpc/examples.md +76 -20
- package/docs/rpc/extension-ui.md +64 -38
- package/docs/rpc/protocol.md +361 -110
- package/docs/rpc.md +57 -17
- package/docs/sdk/reference.md +409 -534
- package/docs/sdk/storage.md +53 -13
- package/docs/sdk/structured-decisions.md +82 -56
- package/docs/sdk/web-server.md +57 -43
- package/docs/sdk.md +106 -84
- package/docs/security.md +42 -64
- package/docs/session-format.md +62 -38
- package/docs/sessions.md +99 -214
- package/docs/settings.md +165 -195
- package/docs/shell-aliases.md +9 -6
- package/docs/skills/authoring.md +69 -48
- package/docs/skills/reference.md +51 -20
- package/docs/skills.md +99 -148
- package/docs/slash-commands.md +129 -0
- package/docs/storage/custom-adapters.md +160 -85
- package/docs/storage/jsonl.md +81 -66
- package/docs/storage/postgres/pgbouncer.md +120 -126
- package/docs/storage/postgres/tuning.md +120 -143
- package/docs/storage/postgres.md +314 -330
- package/docs/storage/sqlite.md +71 -42
- package/docs/storage.md +298 -302
- package/docs/subagents/authoring.md +55 -38
- package/docs/subagents/reference.md +73 -33
- package/docs/subagents.md +119 -187
- package/docs/terminal-setup.md +51 -39
- package/docs/themes/reference.md +23 -19
- package/docs/themes.md +142 -127
- package/docs/tmux.md +47 -55
- package/docs/tools.md +147 -109
- package/docs/tui/reference.md +166 -214
- package/docs/tui.md +196 -341
- package/docs/usage.md +118 -138
- package/docs/verification.md +79 -51
- package/docs/web-access.md +121 -101
- package/docs/windows.md +26 -27
- package/docs/worktree-snapshots/reference.md +245 -0
- package/docs/worktree-snapshots.md +71 -259
- package/package.json +8 -8
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
- package/docs/guides/intercom.md +0 -32
- package/docs/guides/orchestration.md +0 -28
- package/docs/guides/subagents.md +0 -37
- package/docs/termux.md +0 -118
package/docs/tui.md
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Build TUI components"
|
|
3
|
-
sidebarTitle: "TUI components"
|
|
3
|
+
sidebarTitle: "Build TUI components"
|
|
4
4
|
description: "Build custom interactive terminal UI components, overlays, selectors, widgets, and editors for Atomic extensions."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Extensions and custom tools can render
|
|
7
|
+
Extensions and custom tools can render interactive terminal UI (TUI) components with `ctx.ui.custom()`, overlays, widgets, status indicators, and custom editors. For low-level rendering primitives (`TuiMainScreen`, `TuiAltScreen`, `Component`, `Focusable`, `matchesKey`, and built-in primitives), see [`@bastani/atomic-tui`](/libraries/tui). For full Atomic extension contracts (`ToolBlock`, `ExtensionCustomComponent`, advanced `ctx.ui.custom()` options, theme invalidation, debug logging, and host-native dialogs), see [TUI API reference](/tui/reference).
|
|
8
8
|
|
|
9
|
-
## Using
|
|
9
|
+
## Using `ctx.ui.custom()`
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Pass a synchronous or `async` component factory (`ExtensionCustomComponent | Promise<ExtensionCustomComponent>`) to `ctx.ui.custom()`. The factory receives `(tui, theme, keybindings, done)`, and `ctx.ui.custom()` resolves with the value you pass to `done()`. Components can also implement `dispose?(): void` for cleanup when dismissed.
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
atomic.on("session_start", async (_event, ctx) => {
|
|
15
15
|
const result = await ctx.ui.custom((tui, theme, keybindings, done) => {
|
|
16
|
-
return new MyComponent(done);
|
|
16
|
+
return new MyComponent(theme, done);
|
|
17
17
|
});
|
|
18
18
|
ctx.ui.notify(`Selected: ${result}`, "info");
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Common options for `ctx.ui.custom(factory, options?)`:
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
| Option | Default | Purpose |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `overlay` | `false` | Mount the component as a floating overlay instead of replacing the editor slot (see [Overlays](#overlays)). |
|
|
27
|
+
| `overlayOptions` | Centered, max 80 cols | Static `OverlayOptions` object or `() => OverlayOptions` callback evaluated on render. |
|
|
28
|
+
| `onHandle` | — | Receives an `OverlayHandle` for programmatic focus and visibility control. |
|
|
29
|
+
| `handlesCtrlC` | `false` | By default, Atomic closes a custom component on the first `Ctrl+C` so a wedged component cannot trap input. Set `true` only if your component handles `Ctrl+C` cleanly itself. |
|
|
30
|
+
| `signal` | — | `AbortSignal` that dismisses the component when aborted (resolves `undefined` in Atomic's CLI TUI; rejects with `signal.reason` in embedded SDK TUI hosts). |
|
|
31
|
+
| `blocked` | — | `{ kind: "question" \| "permission" \| "auth", message: string }`. Reports Atomic as waiting for user input through [program status](/terminal-setup#program-status). |
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
For advanced options (`purpose`, `handlesInternalUiAction`, `deferInlineCustomUiFocus`, `reserveTranscriptRows`, `OVERLAY_ACTIVE_ROW_MARKER`, and `HostCustomUiState`), see [Custom component options](/tui/reference#custom-component-options).
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
<Note>
|
|
36
|
+
Do not rely on host process globals from `render()` or `handleInput()`, and pass only JSON-safe values to `done()`. Return `true` for consumed viewport keys or overlay mouse events and `false` to let the transcript handle them. Non-overlay components leave mouse scrolling and selection with the transcript.
|
|
37
|
+
</Note>
|
|
36
38
|
|
|
37
39
|
## Overlays
|
|
38
40
|
|
|
@@ -54,9 +56,9 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
54
56
|
overlay: true,
|
|
55
57
|
overlayOptions: {
|
|
56
58
|
// Size: number or percentage string
|
|
57
|
-
width: "50%",
|
|
58
|
-
minWidth: 40,
|
|
59
|
-
maxHeight: "80%",
|
|
59
|
+
width: "50%", // 50% of terminal width
|
|
60
|
+
minWidth: 40, // minimum 40 columns
|
|
61
|
+
maxHeight: "80%", // max 80% of terminal height
|
|
60
62
|
|
|
61
63
|
// Position: anchor-based (default: "center")
|
|
62
64
|
anchor: "right-center", // 9 positions: center, top-left, top-center, etc.
|
|
@@ -64,16 +66,15 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
64
66
|
offsetY: 0,
|
|
65
67
|
|
|
66
68
|
// Or percentage/absolute positioning
|
|
67
|
-
row: "25%",
|
|
68
|
-
col: 10,
|
|
69
|
+
row: "25%", // 25% from top
|
|
70
|
+
col: 10, // column 10
|
|
69
71
|
|
|
70
72
|
// Margins
|
|
71
|
-
margin: 2,
|
|
73
|
+
margin: 2, // all sides, or { top, right, bottom, left }
|
|
72
74
|
|
|
73
75
|
// Responsive: hide on narrow terminals
|
|
74
76
|
visible: (termWidth, termHeight) => termWidth >= 80,
|
|
75
77
|
},
|
|
76
|
-
// Get handle for programmatic focus and visibility control
|
|
77
78
|
onHandle: (handle) => {
|
|
78
79
|
// handle.focus() - focus this overlay and bring it to the visual front
|
|
79
80
|
// handle.unfocus() - release input to normal fallback
|
|
@@ -85,133 +86,55 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
85
86
|
);
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
### Overlay focus
|
|
89
|
+
### Overlay focus and lifecycle
|
|
89
90
|
|
|
90
|
-
A focused visible overlay keeps input ownership across temporary non-overlay UI
|
|
91
|
+
A focused visible overlay keeps input ownership across temporary non-overlay UI: if it opens another inline `ctx.ui.custom()` component, that component receives input while active, and the overlay reclaims input when it closes. Call `handle.unfocus()` to release input to the fallback target, or `handle.unfocus({ target })` to focus a specific component (or `null` for none).
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
### Overlay lifecycle
|
|
95
|
-
|
|
96
|
-
Overlay components are disposed when closed. Create fresh instances rather than reusing references:
|
|
93
|
+
Overlay components are disposed when closed, so always create fresh instances instead of reusing closed references:
|
|
97
94
|
|
|
98
95
|
```typescript
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
menu = new MenuComponent(done);
|
|
103
|
-
return menu;
|
|
104
|
-
}, { overlay: true });
|
|
105
|
-
setActiveComponent(menu); // Disposed
|
|
106
|
-
|
|
107
|
-
// Correct - re-call to re-show
|
|
108
|
-
const showMenu = () => ctx.ui.custom((_, __, ___, done) =>
|
|
109
|
-
new MenuComponent(done), { overlay: true });
|
|
110
|
-
|
|
111
|
-
await showMenu(); // First show
|
|
112
|
-
await showMenu(); // "Back" = just call again
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
See [overlay-qa-tests.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/overlay-qa-tests.ts) for examples covering anchors, margins, stacking, responsive visibility, and animation.
|
|
116
|
-
|
|
117
|
-
## Built-in components
|
|
118
|
-
|
|
119
|
-
Import from `@bastani/atomic-tui`:
|
|
96
|
+
// Correct: call ctx.ui.custom() again to re-open a fresh instance
|
|
97
|
+
const showMenu = () =>
|
|
98
|
+
ctx.ui.custom((_, __, ___, done) => new MenuComponent(done), { overlay: true });
|
|
120
99
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Text
|
|
126
|
-
|
|
127
|
-
Multi-line text with word wrapping.
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
const text = new Text(
|
|
131
|
-
"Hello World", // content
|
|
132
|
-
1, // paddingX (default: 1)
|
|
133
|
-
1, // paddingY (default: 1)
|
|
134
|
-
(s) => bgGray(s) // optional background function
|
|
135
|
-
);
|
|
136
|
-
text.setText("Updated");
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Box
|
|
140
|
-
|
|
141
|
-
Container with padding and background color.
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
const box = new Box(
|
|
145
|
-
1, // paddingX
|
|
146
|
-
1, // paddingY
|
|
147
|
-
(s) => bgGray(s) // background function
|
|
148
|
-
);
|
|
149
|
-
box.addChild(new Text("Content", 0, 0));
|
|
150
|
-
box.setBgFn((s) => bgBlue(s));
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Container
|
|
154
|
-
|
|
155
|
-
Groups child components vertically.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
const container = new Container();
|
|
159
|
-
container.addChild(component1);
|
|
160
|
-
container.addChild(component2);
|
|
161
|
-
container.removeChild(component1);
|
|
100
|
+
await showMenu(); // First show
|
|
101
|
+
await showMenu(); // Re-show cleanly
|
|
162
102
|
```
|
|
163
103
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Empty vertical space.
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
const spacer = new Spacer(2); // 2 empty lines
|
|
170
|
-
```
|
|
104
|
+
See [overlay-qa-tests.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/overlay-qa-tests.ts) for examples covering anchors, margins, stacking, responsive visibility, and animation.
|
|
171
105
|
|
|
172
|
-
|
|
106
|
+
## Built-in primitives
|
|
173
107
|
|
|
174
|
-
|
|
108
|
+
Import layout and content primitives from `@bastani/atomic-tui` (provided by Atomic without installing it):
|
|
175
109
|
|
|
176
110
|
```typescript
|
|
177
|
-
|
|
178
|
-
"# Title\n\nSome **bold** text",
|
|
179
|
-
1, // paddingX
|
|
180
|
-
1, // paddingY
|
|
181
|
-
theme // MarkdownTheme (see below)
|
|
182
|
-
);
|
|
183
|
-
md.setText("Updated markdown");
|
|
111
|
+
import { Box, Container, Image, Markdown, Spacer, Text } from "@bastani/atomic-tui";
|
|
184
112
|
```
|
|
185
113
|
|
|
186
|
-
|
|
114
|
+
| Component | Purpose | Typical usage |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `Text` | Multi-line wrapped text with padding and optional background | `new Text(theme.fg("accent", "Ready"), 1, 0)` |
|
|
117
|
+
| `Box` | Padded container with optional background color | `new Box(1, 1, (s) => theme.bg("selectedBg", s))` |
|
|
118
|
+
| `Container` | Vertical group of child components | `container.addChild(child); container.removeChild(child);` |
|
|
119
|
+
| `Spacer` | Vertical blank rows | `new Spacer(1)` |
|
|
120
|
+
| `Markdown` | Styled Markdown renderer with optional syntax highlighting | `new Markdown(md, 1, 1, getMarkdownTheme())` |
|
|
121
|
+
| `Image` | Inline image for Kitty/iTerm2-capable terminals (text fallback elsewhere) | `new Image(base64Data, "image/png", imageTheme, { maxWidthCells: 80 })` |
|
|
187
122
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
const image = new Image(
|
|
192
|
-
base64Data, // base64-encoded image
|
|
193
|
-
"image/png", // MIME type
|
|
194
|
-
theme, // ImageTheme
|
|
195
|
-
{ maxWidthCells: 80, maxHeightCells: 24 }
|
|
196
|
-
);
|
|
197
|
-
```
|
|
123
|
+
See [`@bastani/atomic-tui` built-in components](/libraries/tui#built-in-components) for full constructor signatures, options, and additional primitives (`Input`, `Editor`, `Loader`, `CancellableLoader`, `TruncatedText`, `WindowedContainer`, `VStack`, `HStack`, `ScrollView`).
|
|
198
124
|
|
|
199
125
|
## Creating custom components
|
|
200
126
|
|
|
201
|
-
|
|
127
|
+
Implement `render(width)`, `invalidate()`, and optional `handleInput(data)` to build a custom interactive component:
|
|
202
128
|
|
|
203
129
|
```typescript
|
|
204
|
-
import {
|
|
205
|
-
matchesKey, Key,
|
|
206
|
-
truncateToWidth, visibleWidth
|
|
207
|
-
} from "@bastani/atomic-tui";
|
|
130
|
+
import { Key, matchesKey, truncateToWidth } from "@bastani/atomic-tui";
|
|
208
131
|
|
|
209
132
|
class MySelector {
|
|
210
133
|
private items: string[];
|
|
211
134
|
private selected = 0;
|
|
212
135
|
private cachedWidth?: number;
|
|
213
136
|
private cachedLines?: string[];
|
|
214
|
-
|
|
137
|
+
|
|
215
138
|
public onSelect?: (item: string) => void;
|
|
216
139
|
public onCancel?: () => void;
|
|
217
140
|
|
|
@@ -229,7 +152,7 @@ class MySelector {
|
|
|
229
152
|
this.invalidate();
|
|
230
153
|
return true;
|
|
231
154
|
} else if (matchesKey(data, Key.enter)) {
|
|
232
|
-
this.onSelect?.(this.items[this.selected]);
|
|
155
|
+
this.onSelect?.(this.items[this.selected]!);
|
|
233
156
|
return true;
|
|
234
157
|
} else if (matchesKey(data, Key.escape)) {
|
|
235
158
|
this.onCancel?.();
|
|
@@ -258,41 +181,45 @@ class MySelector {
|
|
|
258
181
|
}
|
|
259
182
|
```
|
|
260
183
|
|
|
261
|
-
|
|
184
|
+
Use it inside a slash command handler:
|
|
262
185
|
|
|
263
186
|
```typescript
|
|
264
187
|
atomic.registerCommand("pick", {
|
|
265
188
|
description: "Pick an item",
|
|
266
|
-
handler: async (
|
|
189
|
+
handler: async (_args, ctx) => {
|
|
267
190
|
const items = ["Option A", "Option B", "Option C"];
|
|
268
191
|
const selector = new MySelector(items);
|
|
269
|
-
|
|
270
|
-
const selected = await ctx.ui.custom<string | undefined>((
|
|
192
|
+
|
|
193
|
+
const selected = await ctx.ui.custom<string | undefined>((tui, _theme, _keybindings, done) => {
|
|
271
194
|
selector.onSelect = (item) => done(item);
|
|
272
195
|
selector.onCancel = () => done(undefined);
|
|
273
|
-
return
|
|
196
|
+
return {
|
|
197
|
+
render: (w) => selector.render(w),
|
|
198
|
+
invalidate: () => selector.invalidate(),
|
|
199
|
+
handleInput: (data) => {
|
|
200
|
+
const handled = selector.handleInput(data);
|
|
201
|
+
if (handled) tui.requestRender();
|
|
202
|
+
return handled;
|
|
203
|
+
},
|
|
204
|
+
};
|
|
274
205
|
});
|
|
275
206
|
|
|
276
207
|
if (selected) {
|
|
277
208
|
ctx.ui.notify(`Selected: ${selected}`, "info");
|
|
278
209
|
}
|
|
279
|
-
}
|
|
210
|
+
},
|
|
280
211
|
});
|
|
281
212
|
```
|
|
282
213
|
|
|
283
214
|
## Theming
|
|
284
215
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
**In `renderCall`/`renderResult`**, use the `theme` parameter:
|
|
216
|
+
Always use the `theme` passed to your callback (`ctx.ui.custom`, `ctx.ui.setWidget`, `renderCall`, `renderResult`) rather than importing a theme singleton directly:
|
|
288
217
|
|
|
289
218
|
```typescript
|
|
290
219
|
renderResult(result, options, theme, context) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// Use theme.bg() for background colors
|
|
295
|
-
const styled = theme.bg("toolPendingBg", theme.fg("accent", "text"));
|
|
220
|
+
const status = theme.fg("success", "Done!");
|
|
221
|
+
const badge = theme.bg("toolPendingBg", theme.fg("accent", "pending"));
|
|
222
|
+
return new Text(`${status} ${badge}`, 0, 0);
|
|
296
223
|
}
|
|
297
224
|
```
|
|
298
225
|
|
|
@@ -311,38 +238,28 @@ renderResult(result, options, theme, context) {
|
|
|
311
238
|
| Thinking | `thinkingText`, `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh` |
|
|
312
239
|
| Modes | `bashMode` |
|
|
313
240
|
|
|
314
|
-
**Background colors** (`theme.bg(color, text)`):
|
|
315
|
-
|
|
316
|
-
`selectedBg`, `userMessageBg`, `customMessageBg`, `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`, `scrollbarThumb`, `searchMatchBg`
|
|
241
|
+
**Background colors** (`theme.bg(color, text)`): `selectedBg`, `userMessageBg`, `customMessageBg`, `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`, `scrollbarThumb`, `searchMatchBg`.
|
|
317
242
|
|
|
318
|
-
|
|
243
|
+
For `Markdown` components, call `getMarkdownTheme()` from `@bastani/atomic`:
|
|
319
244
|
|
|
320
245
|
```typescript
|
|
321
246
|
import { getMarkdownTheme } from "@bastani/atomic";
|
|
322
247
|
import { Markdown } from "@bastani/atomic-tui";
|
|
323
248
|
|
|
324
|
-
renderResult(result,
|
|
325
|
-
|
|
326
|
-
return new Markdown(result.details.markdown, 0, 0, mdTheme);
|
|
249
|
+
renderResult(result, _options, _theme, _context) {
|
|
250
|
+
return new Markdown(result.details.markdown, 0, 0, getMarkdownTheme());
|
|
327
251
|
}
|
|
328
252
|
```
|
|
329
253
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
interface MyTheme {
|
|
334
|
-
selected: (s: string) => string;
|
|
335
|
-
normal: (s: string) => string;
|
|
336
|
-
}
|
|
337
|
-
```
|
|
254
|
+
If your component stores pre-baked themed strings in child components, rebuild them in `invalidate()` so live theme changes take effect; see [Invalidation and theme changes](/tui/reference#invalidation-and-theme-changes).
|
|
338
255
|
|
|
339
256
|
## Common patterns
|
|
340
257
|
|
|
341
|
-
|
|
258
|
+
Use these built-in Atomic patterns instead of building interactive widgets from scratch.
|
|
342
259
|
|
|
343
|
-
###
|
|
260
|
+
### Selection dialog (`Selector`)
|
|
344
261
|
|
|
345
|
-
|
|
262
|
+
Use `Selector` from `@bastani/atomic` for searchable, keyboard- and mouse-accessible pickers (the same component behind `/model`, `/login`, `/thinking`, `/trust`, and `ctx.ui.select`/`confirm`):
|
|
346
263
|
|
|
347
264
|
```typescript
|
|
348
265
|
import { DynamicBorder, Selector } from "@bastani/atomic";
|
|
@@ -350,7 +267,7 @@ import { DynamicBorder, Selector } from "@bastani/atomic";
|
|
|
350
267
|
const choice = await ctx.ui.custom<string | null>((tui, _theme, _kb, done) => {
|
|
351
268
|
const selector = new Selector<string>({
|
|
352
269
|
title: "Pick a preset",
|
|
353
|
-
search: true,
|
|
270
|
+
search: true, // typing filters; Esc clears search, then cancels
|
|
354
271
|
items: [
|
|
355
272
|
{ id: "fast", value: "fast", label: "fast", description: "small model, low effort", mark: "on", tag: "current" },
|
|
356
273
|
{ id: "deep", value: "deep", label: "deep", description: "large model, high effort", mark: "off" },
|
|
@@ -371,48 +288,39 @@ const choice = await ctx.ui.custom<string | null>((tui, _theme, _kb, done) => {
|
|
|
371
288
|
});
|
|
372
289
|
```
|
|
373
290
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
| `
|
|
381
|
-
| `
|
|
382
|
-
| `
|
|
383
|
-
| `
|
|
384
|
-
| `
|
|
385
|
-
| `
|
|
386
|
-
| `
|
|
387
|
-
| `
|
|
388
|
-
| `
|
|
389
|
-
| `
|
|
390
|
-
| `
|
|
391
|
-
| `
|
|
392
|
-
| `
|
|
393
|
-
| `
|
|
394
|
-
| `
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
`setItems()`
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
`
|
|
405
|
-
|
|
406
|
-
For live lists, call `selector.setItems(nextItems)` and `tui.requestRender()`. Selection stays on the same `id` when still enabled and matching, otherwise moves to the first enabled match, and removed checked items are dropped.
|
|
407
|
-
|
|
408
|
-
`UserMessageSelectorComponent` implements the `/fork` picker on `Selector`: `new UserMessageSelectorComponent(messages, onSelect, onCancel, initialSelectedId?)` accepts user messages oldest first (`{ id, text }`), renders two-line rows, selects `initialSelectedId` or the newest message, and filters as you type. Focus the component directly; `getMessageList()` returns the component, and `onSelect`/`onCancel` are assignable properties.
|
|
409
|
-
|
|
410
|
-
### Pattern 1b: Selection dialog (`SelectList`)
|
|
411
|
-
|
|
412
|
-
The lower-level `SelectList` from `@bastani/atomic-tui` is still available when you need a bare list inside your own layout, such as autocomplete rows. Frame it with `DynamicBorder`.
|
|
291
|
+
Navigation supports `Up`/`Down` (wrapping), `PageUp`/`PageDown`, `Home`/`End` (when search is off), `Enter`, `Right` (when search is empty), `Esc` (clears search, then cancels), `Ctrl+C`, mouse click, and wheel scrolling. Without a search box, `?` opens key help and `j`/`k` navigate.
|
|
292
|
+
|
|
293
|
+
Key `SelectorOptions` and item fields:
|
|
294
|
+
|
|
295
|
+
| Option | Default | Effect |
|
|
296
|
+
| --- | --- | --- |
|
|
297
|
+
| `title` / `subtitle` | — | Heading and dim wrapped subtitle (`\n` starts new lines). |
|
|
298
|
+
| `layout` | `"one-line"` | `"two-line"` places each description under its label (good for sessions or runs). |
|
|
299
|
+
| `mode` | `"single"` | `"multi"` adds checkboxes; `Space` toggles and `Enter` calls `onConfirm` with checked rows. |
|
|
300
|
+
| `search` / `searchPlaceholder` / `initialQuery` | `false` | Enables type-to-search with optional placeholder and starting query. |
|
|
301
|
+
| `maxVisible` | `10` | Maximum visible rows before scrolling. |
|
|
302
|
+
| `emptyText` | — | Message shown when `items` is empty. |
|
|
303
|
+
| `numbered` | `false` | Numbers rows `1.` `2.`; without search, digits `1`–`9` choose or toggle directly. |
|
|
304
|
+
| `wrap` | `false` | Wraps long titles and labels instead of truncating. |
|
|
305
|
+
| `initialId` / `initialChecked` | First `mark: "on"` or enabled row | Starting selection ID (and starting checked IDs in `"multi"` mode). |
|
|
306
|
+
| `closeOnSelect` | `true` | Single-select only. Set `false` to keep the picker open after `onSelect`. |
|
|
307
|
+
| `confirmLabel` / `cancelLabel` / `previewLabel` | `"choose"` or `"confirm"` / `"cancel"` | Custom hint text for `Enter`, `Esc`, and `Space` preview. |
|
|
308
|
+
| `spaceConfirms` / `rightConfirms` | `false` / `true` | Allow `Space` to confirm, or disable `Right` (`app.list.open`) confirmation. |
|
|
309
|
+
| `minDescriptionWidth` | — | Reserves columns for one-line descriptions, shortening labels first. |
|
|
310
|
+
| `selectedDetail` | — | Callback `(item) => string \| undefined` rendering extra detail for the selected row. |
|
|
311
|
+
| `onPreview` | — | `Space` previews the selected row; hint shows `space <previewLabel>`. |
|
|
312
|
+
| `onSelectionChange` | — | Fires when navigation or filtering changes the selected row ID (or `undefined`). |
|
|
313
|
+
| `extraKeys` | — | Custom key actions with hints and `enabled(item)` predicates. |
|
|
314
|
+
| `helpTitle` / `keybindings` / `style` | `title` / global / active theme | Title for `?` help overlay, keybindings source, and colors (`PLAIN_SELECTOR_STYLE` for unstyled). |
|
|
315
|
+
| Item fields | — | `group` (section label), `disabled`, `mark` (`"on"`/`"off"`/`"checked"`/`"unchecked"`), `tag` + `tagTone` (`"accent"` \| `"success"` \| `"warning"` \| `"error"` \| `"muted"` \| `"dim"`), `labelStyle`, `searchText`, `searchTextMode` (`"extend"` \| `"replace"`). |
|
|
316
|
+
|
|
317
|
+
For live updates, call `selector.setItems(nextItems)` and `tui.requestRender()`; selection stays on the same `id` when still enabled and matching. Call `selector.setNotice({ text, tone })` for a one-line status under the list, and call `selector.retrySelection()` if an async `onSelect`/`onConfirm` callback fails and should re-enable input. For headless testing (`SelectorState`, `selectorHintEntries`) and `UserMessageSelectorComponent`, see [Selector helpers](/tui/reference#selector-helpers).
|
|
318
|
+
|
|
319
|
+
### Bare list (`SelectList`)
|
|
320
|
+
|
|
321
|
+
Use `SelectList` from `@bastani/atomic-tui` when you need a minimal list inside your own layout (such as custom autocomplete rows) framed with `DynamicBorder`:
|
|
413
322
|
|
|
414
323
|
```typescript
|
|
415
|
-
import type { ExtensionAPI } from "@bastani/atomic";
|
|
416
324
|
import { DynamicBorder } from "@bastani/atomic";
|
|
417
325
|
import { Container, type SelectItem, SelectList, Text } from "@bastani/atomic-tui";
|
|
418
326
|
|
|
@@ -421,19 +329,14 @@ atomic.registerCommand("pick", {
|
|
|
421
329
|
const items: SelectItem[] = [
|
|
422
330
|
{ value: "opt1", label: "Option 1", description: "First option" },
|
|
423
331
|
{ value: "opt2", label: "Option 2", description: "Second option" },
|
|
424
|
-
{ value: "opt3", label: "Option 3" },
|
|
332
|
+
{ value: "opt3", label: "Option 3" },
|
|
425
333
|
];
|
|
426
334
|
|
|
427
335
|
const result = await ctx.ui.custom<string | null>((tui, theme, _kb, done) => {
|
|
428
336
|
const container = new Container();
|
|
429
|
-
|
|
430
|
-
// Top border
|
|
431
337
|
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
432
|
-
|
|
433
|
-
// Title
|
|
434
338
|
container.addChild(new Text(theme.fg("accent", theme.bold("Pick an Option")), 1, 0));
|
|
435
339
|
|
|
436
|
-
// SelectList with theme
|
|
437
340
|
const selectList = new SelectList(items, Math.min(items.length, 10), {
|
|
438
341
|
selectedPrefix: (t) => theme.fg("accent", t),
|
|
439
342
|
selectedText: (t) => theme.fg("accent", t),
|
|
@@ -445,10 +348,7 @@ atomic.registerCommand("pick", {
|
|
|
445
348
|
selectList.onCancel = () => done(null);
|
|
446
349
|
container.addChild(selectList);
|
|
447
350
|
|
|
448
|
-
// Help text
|
|
449
351
|
container.addChild(new Text(theme.fg("dim", "↑↓ Navigate • Enter Select • Escape Cancel"), 1, 0));
|
|
450
|
-
|
|
451
|
-
// Bottom border
|
|
452
352
|
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
453
353
|
|
|
454
354
|
return {
|
|
@@ -462,18 +362,16 @@ atomic.registerCommand("pick", {
|
|
|
462
362
|
};
|
|
463
363
|
});
|
|
464
364
|
|
|
465
|
-
if (result) {
|
|
466
|
-
ctx.ui.notify(`Selected: ${result}`, "info");
|
|
467
|
-
}
|
|
365
|
+
if (result) ctx.ui.notify(`Selected: ${result}`, "info");
|
|
468
366
|
},
|
|
469
367
|
});
|
|
470
368
|
```
|
|
471
369
|
|
|
472
370
|
**Examples:** [preset.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/preset.ts), [tools.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tools.ts)
|
|
473
371
|
|
|
474
|
-
###
|
|
372
|
+
### Cancellable loader (`BorderedLoader`)
|
|
475
373
|
|
|
476
|
-
|
|
374
|
+
Use `BorderedLoader` for async operations that users should be able to cancel with `Escape`:
|
|
477
375
|
|
|
478
376
|
```typescript
|
|
479
377
|
import { BorderedLoader } from "@bastani/atomic";
|
|
@@ -484,7 +382,6 @@ atomic.registerCommand("fetch", {
|
|
|
484
382
|
const loader = new BorderedLoader(tui, theme, "Fetching data...");
|
|
485
383
|
loader.onAbort = () => done(null);
|
|
486
384
|
|
|
487
|
-
// Do async work
|
|
488
385
|
fetchData(loader.signal)
|
|
489
386
|
.then((data) => done(data))
|
|
490
387
|
.catch(() => done(null));
|
|
@@ -503,9 +400,9 @@ atomic.registerCommand("fetch", {
|
|
|
503
400
|
|
|
504
401
|
**Examples:** [qna.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/qna.ts), [handoff.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/handoff.ts)
|
|
505
402
|
|
|
506
|
-
###
|
|
403
|
+
### Settings toggles (`SettingsList`)
|
|
507
404
|
|
|
508
|
-
|
|
405
|
+
Use `SettingsList` from `@bastani/atomic-tui` with `getSettingsListTheme()` from `@bastani/atomic`:
|
|
509
406
|
|
|
510
407
|
```typescript
|
|
511
408
|
import { getSettingsListTheme } from "@bastani/atomic";
|
|
@@ -527,11 +424,10 @@ atomic.registerCommand("settings", {
|
|
|
527
424
|
Math.min(items.length + 2, 15),
|
|
528
425
|
getSettingsListTheme(),
|
|
529
426
|
(id, newValue) => {
|
|
530
|
-
// Handle value change
|
|
531
427
|
ctx.ui.notify(`${id} = ${newValue}`, "info");
|
|
532
428
|
},
|
|
533
|
-
() => done(undefined),
|
|
534
|
-
{ enableSearch: true },
|
|
429
|
+
() => done(undefined),
|
|
430
|
+
{ enableSearch: true },
|
|
535
431
|
);
|
|
536
432
|
container.addChild(settingsList);
|
|
537
433
|
|
|
@@ -550,23 +446,20 @@ atomic.registerCommand("settings", {
|
|
|
550
446
|
|
|
551
447
|
**Examples:** [tools.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tools.ts)
|
|
552
448
|
|
|
553
|
-
###
|
|
449
|
+
### Status indicator
|
|
554
450
|
|
|
555
|
-
|
|
451
|
+
Display persistent mode indicators in the footer:
|
|
556
452
|
|
|
557
453
|
```typescript
|
|
558
|
-
// Set status (shown in footer)
|
|
559
454
|
ctx.ui.setStatus("my-ext", ctx.ui.theme.fg("accent", "● active"));
|
|
560
|
-
|
|
561
|
-
// Clear status
|
|
562
|
-
ctx.ui.setStatus("my-ext", undefined);
|
|
455
|
+
ctx.ui.setStatus("my-ext", undefined); // clear
|
|
563
456
|
```
|
|
564
457
|
|
|
565
458
|
**Examples:** [status-line.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/status-line.ts), [plan-mode/index.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/plan-mode/index.ts), [preset.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/preset.ts)
|
|
566
459
|
|
|
567
|
-
###
|
|
460
|
+
### Working indicator {#pattern-4b-working-indicator-customization}
|
|
568
461
|
|
|
569
|
-
Customize the inline Working indicator shown from accepted
|
|
462
|
+
Customize the inline Working indicator shown from accepted prompt submission through response streaming:
|
|
570
463
|
|
|
571
464
|
```typescript
|
|
572
465
|
// Static indicator
|
|
@@ -586,23 +479,19 @@ ctx.ui.setWorkingIndicator({
|
|
|
586
479
|
// Hide the indicator entirely
|
|
587
480
|
ctx.ui.setWorkingIndicator({ frames: [] });
|
|
588
481
|
|
|
589
|
-
// Restore Atomic's default one-cell
|
|
482
|
+
// Restore Atomic's default one-cell ∀ pulse
|
|
590
483
|
ctx.ui.setWorkingIndicator();
|
|
591
484
|
```
|
|
592
485
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
Working appears during prompt startup and response streaming, then disappears on completion, failure, or a no-turn result. Manual retry clears stale status; automatic retry and fallback messages take precedence.
|
|
596
|
-
|
|
597
|
-
The default is a one-cell `∀` pulse beside a message selected once per turn. Theme `workingIndicator` tones customize its colors. `NO_COLOR` disables foreground and background colors and text styles (bold, italic, dim, underline, inverse, and strikethrough), rendering the indicator unstyled. `ATOMIC_REDUCED_MOTION=1` makes it static. Custom frames and intervals render unchanged.
|
|
486
|
+
By default, Atomic shows a one-cell `∀` pulse beside a turn status message in a standalone row (custom editors can opt in to embedding it in their top border with `embedWorkingStatus: true`). `NO_COLOR` disables colors and text styles, and `ATOMIC_REDUCED_MOTION=1` freezes the built-in pulse (custom frames and intervals render verbatim).
|
|
598
487
|
|
|
599
|
-
|
|
488
|
+
Working appears during prompt startup and response streaming and disappears on completion, failure, or a no-turn result. Automatic retry, fallback, and compaction loaders use their own built-in indicators and take precedence; successful mid-turn compaction restores Working automatically.
|
|
600
489
|
|
|
601
490
|
**Examples:** [working-indicator.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/working-indicator.ts)
|
|
602
491
|
|
|
603
|
-
###
|
|
492
|
+
### Editor widgets
|
|
604
493
|
|
|
605
|
-
Show persistent content above or below the input editor
|
|
494
|
+
Show persistent content above or below the input editor (such as todo lists or progress panels):
|
|
606
495
|
|
|
607
496
|
```typescript
|
|
608
497
|
// Simple string array (above editor by default)
|
|
@@ -611,106 +500,77 @@ ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
|
|
611
500
|
// Render below the editor
|
|
612
501
|
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" });
|
|
613
502
|
|
|
614
|
-
//
|
|
503
|
+
// Component factory with theme
|
|
615
504
|
ctx.ui.setWidget("my-widget", (_tui, theme) => {
|
|
616
|
-
const lines = items.map((item
|
|
505
|
+
const lines = items.map((item) =>
|
|
617
506
|
item.done
|
|
618
507
|
? theme.fg("success", "✓ ") + theme.fg("muted", item.text)
|
|
619
508
|
: theme.fg("dim", "○ ") + item.text
|
|
620
509
|
);
|
|
621
|
-
return {
|
|
622
|
-
render: () => lines,
|
|
623
|
-
invalidate: () => {},
|
|
624
|
-
};
|
|
510
|
+
return { render: () => lines, invalidate: () => {} };
|
|
625
511
|
});
|
|
626
512
|
|
|
627
513
|
// Clear
|
|
628
514
|
ctx.ui.setWidget("my-widget", undefined);
|
|
629
515
|
```
|
|
630
516
|
|
|
631
|
-
|
|
632
|
-
The listener runs after the host removes that key, so the extension can reset local mount state and re-register on its next refresh. Replacing a widget with another factory is not a release. Ordinary content changes should continue to update the existing component with `requestRender()` rather than repeatedly calling `setWidget()`.
|
|
517
|
+
To react when the host clears a widget during a UI reset, subscribe with `ctx.ui.onWidgetRelease(key, listener)` when available (replacing a widget with another factory does not trigger release). For ordinary updates, mutate your component state and call `requestRender()` rather than re-registering `setWidget()`.
|
|
633
518
|
|
|
634
519
|
#### Scrollable widgets
|
|
635
520
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
For a cap that follows terminal resizing, use `scroll: { maxHeight: 10, maxHeightFraction: 1 / 3 }`. The fraction applies to live terminal rows, rounded down with a one-row minimum, then capped at `maxHeight`. Actual allocation may still be zero when other dock content uses all available rows. Omitting the fraction keeps the fixed cap.
|
|
521
|
+
Pass `scroll: { maxHeight: 6 }` (or `{ maxHeight: 10, maxHeightFraction: 1 / 3 }` to scale with live terminal rows) to give a widget its own fullscreen viewport with mouse-wheel scrolling and a one-column overflow scrollbar. Render the full content rather than a pre-clipped slice:
|
|
639
522
|
|
|
640
523
|
```typescript
|
|
641
524
|
import type { ScrollableWidgetComponent, WidgetScrollRequest } from "@bastani/atomic";
|
|
642
525
|
import { truncateToWidth } from "@bastani/atomic-tui";
|
|
643
526
|
|
|
644
527
|
let position: WidgetScrollRequest = { version: 0, scrollTop: 0 };
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
scroll: { maxHeight: 6 },
|
|
657
|
-
|
|
528
|
+
ctx.ui.setWidget(
|
|
529
|
+
"scrolling-items",
|
|
530
|
+
() =>
|
|
531
|
+
({
|
|
532
|
+
render: (width) => items.map((item) => truncateToWidth(item.label, width)),
|
|
533
|
+
invalidate() {},
|
|
534
|
+
getScrollRequest: () => position,
|
|
535
|
+
onScroll: (_state) => {
|
|
536
|
+
// state reports { scrollTop, viewportHeight, contentHeight } in rendered rows
|
|
537
|
+
},
|
|
538
|
+
}) satisfies ScrollableWidgetComponent,
|
|
539
|
+
{ placement: "belowEditor", scroll: { maxHeight: 6 } },
|
|
540
|
+
);
|
|
658
541
|
|
|
659
|
-
//
|
|
542
|
+
// Increment version only when intentionally repositioning, then request a render
|
|
660
543
|
position = { version: position.version + 1, scrollTop: 10 };
|
|
661
544
|
ctx.ui.requestRender();
|
|
662
545
|
```
|
|
663
546
|
|
|
664
|
-
`getScrollRequest` and `onScroll` are optional
|
|
665
|
-
|
|
666
|
-
`installReactiveWidget` accepts the same `scroll`, `getScrollRequest`, and `onScroll` options. Existing widgets remain unscrolled unless they opt in. Native wheel input requires fullscreen mode and a terminal that forwards mouse events; the main-screen fallback (such as `TERM=dumb` or non-TTY sessions) does not provide a native viewport. No Option/Alt key setup is required for wheel input.
|
|
547
|
+
`getScrollRequest` and `onScroll` are optional, and `installReactiveWidget` accepts the same `scroll` options. Keep `version` unchanged during ordinary content updates so user wheel scrolling is preserved. Native wheel scrolling requires fullscreen mode and a mouse-capable terminal.
|
|
667
548
|
|
|
668
549
|
**Examples:** [plan-mode/index.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/plan-mode/index.ts)
|
|
669
550
|
|
|
670
|
-
###
|
|
551
|
+
### Custom footer
|
|
671
552
|
|
|
672
|
-
Replace the footer
|
|
553
|
+
Replace the footer and read live Git branch and extension statuses from `footerData`:
|
|
673
554
|
|
|
674
555
|
```typescript
|
|
675
|
-
ctx.ui.setFooter((tui,
|
|
556
|
+
ctx.ui.setFooter((tui, _theme, footerData) => ({
|
|
676
557
|
invalidate() {},
|
|
677
|
-
render(
|
|
678
|
-
// footerData.getGitBranch(): string | null
|
|
679
|
-
// footerData.getExtensionStatuses(): ReadonlyMap<string, string>
|
|
558
|
+
render(_width: number): string[] {
|
|
680
559
|
return [`${ctx.model?.id} (${footerData.getGitBranch() || "no git"})`];
|
|
681
560
|
},
|
|
682
|
-
dispose: footerData.onBranchChange(() => tui.requestRender()),
|
|
561
|
+
dispose: footerData.onBranchChange(() => tui.requestRender()),
|
|
683
562
|
}));
|
|
684
563
|
|
|
685
564
|
ctx.ui.setFooter(undefined); // restore default
|
|
686
565
|
```
|
|
687
566
|
|
|
688
|
-
`ctx.ui.getFooterDataProvider()` exposes the same read-only
|
|
689
|
-
|
|
690
|
-
For a viewer with a different cwd, subscribe with that cwd to retain its branch watcher, and read the live branch during each render using the same raw cwd string:
|
|
691
|
-
|
|
692
|
-
```typescript
|
|
693
|
-
// viewerCwd is fixed for this viewer's lifetime.
|
|
694
|
-
ctx.ui.setFooter((tui, theme, footerData) => ({
|
|
695
|
-
invalidate() {},
|
|
696
|
-
render(width: number): string[] {
|
|
697
|
-
return [`${ctx.model?.id} (${footerData.getGitBranch(viewerCwd) || "no git"})`];
|
|
698
|
-
},
|
|
699
|
-
dispose: footerData.onBranchChange(() => tui.requestRender(), viewerCwd),
|
|
700
|
-
}));
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
The returned unsubscribe function belongs to the viewer: call it on disposal or before replacing the viewer's cwd, then subscribe for the new cwd. Embedded UIs using `ctx.ui.getFooterDataProvider()` must likewise release their own subscription. Active viewers using the same raw cwd share the cached provider and watcher; the last unsubscribe releases that alternate-cwd resource. Do not call the parent provider's `dispose()` from an individual viewer.
|
|
704
|
-
|
|
705
|
-
An unleased `getGitBranch(viewerCwd)` lookup is transient: it does not retain an alternate-cwd cache or watcher, so an unscoped callback alone does not enable branch updates for that directory. Scoped subscriptions retain resources, but notifications still reach the same branch-change listeners; they are not filtered by cwd. Omitting the cwd argument retains the provider's own cwd behavior shown in the default recipe above.
|
|
706
|
-
|
|
707
|
-
Token stats available via `ctx.sessionManager.getBranch()` and `ctx.model`.
|
|
567
|
+
`ctx.ui.getFooterDataProvider()` exposes the same read-only provider to embedded extension UIs. For a viewer showing a different working directory (`viewerCwd`), pass `viewerCwd` to both `footerData.onBranchChange(listener, viewerCwd)` and `footerData.getGitBranch(viewerCwd)`, and call the returned unsubscribe function on disposal (never call the parent provider's `dispose()`). An unsubscribed `getGitBranch(viewerCwd)` lookup is transient and does not retain a branch watcher.
|
|
708
568
|
|
|
709
569
|
**Examples:** [custom-footer.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/custom-footer.ts)
|
|
710
570
|
|
|
711
|
-
###
|
|
571
|
+
### Custom editor (vim mode)
|
|
712
572
|
|
|
713
|
-
|
|
573
|
+
Extend `CustomEditor` (not base `Editor`) to customize editing while keeping Atomic's app keybindings (`Escape` to abort, `Ctrl+D` to exit, model switching, and autocomplete):
|
|
714
574
|
|
|
715
575
|
```typescript
|
|
716
576
|
import { CustomEditor, type ExtensionAPI } from "@bastani/atomic";
|
|
@@ -722,41 +582,32 @@ class VimEditor extends CustomEditor {
|
|
|
722
582
|
private mode: Mode = "insert";
|
|
723
583
|
|
|
724
584
|
handleInput(data: string): boolean {
|
|
725
|
-
// Escape: switch to normal mode, or pass through for app handling
|
|
726
585
|
if (matchesKey(data, "escape")) {
|
|
727
586
|
if (this.mode === "insert") {
|
|
728
587
|
this.mode = "normal";
|
|
729
588
|
return true;
|
|
730
589
|
}
|
|
731
|
-
// In normal mode, escape aborts agent (handled by CustomEditor)
|
|
732
590
|
return super.handleInput(data);
|
|
733
591
|
}
|
|
734
592
|
|
|
735
|
-
|
|
736
|
-
if (this.mode === "insert") {
|
|
737
|
-
return super.handleInput(data);
|
|
738
|
-
}
|
|
593
|
+
if (this.mode === "insert") return super.handleInput(data);
|
|
739
594
|
|
|
740
|
-
// Normal mode: vim-style navigation
|
|
741
595
|
switch (data) {
|
|
742
596
|
case "i": this.mode = "insert"; return true;
|
|
743
|
-
case "h": return super.handleInput("\x1b[D");
|
|
744
|
-
case "j": return super.handleInput("\x1b[B");
|
|
745
|
-
case "k": return super.handleInput("\x1b[A");
|
|
746
|
-
case "l": return super.handleInput("\x1b[C");
|
|
597
|
+
case "h": return super.handleInput("\x1b[D");
|
|
598
|
+
case "j": return super.handleInput("\x1b[B");
|
|
599
|
+
case "k": return super.handleInput("\x1b[A");
|
|
600
|
+
case "l": return super.handleInput("\x1b[C");
|
|
747
601
|
}
|
|
748
|
-
// Pass unhandled keys to super (ctrl+c, etc.), but filter printable chars
|
|
749
602
|
if (data.length === 1 && data.charCodeAt(0) >= 32) return false;
|
|
750
603
|
return super.handleInput(data);
|
|
751
604
|
}
|
|
752
605
|
|
|
753
606
|
render(width: number): string[] {
|
|
754
607
|
const lines = super.render(width);
|
|
755
|
-
// Add mode indicator to bottom border (use truncateToWidth for ANSI-safe truncation)
|
|
756
608
|
if (lines.length > 0) {
|
|
757
609
|
const label = this.mode === "normal" ? " NORMAL " : " INSERT ";
|
|
758
610
|
const lastLine = lines[lines.length - 1]!;
|
|
759
|
-
// Pass "" as ellipsis to avoid adding "..." when truncating
|
|
760
611
|
lines[lines.length - 1] = truncateToWidth(lastLine, width - label.length, "") + label;
|
|
761
612
|
}
|
|
762
613
|
return lines;
|
|
@@ -765,28 +616,33 @@ class VimEditor extends CustomEditor {
|
|
|
765
616
|
|
|
766
617
|
export default function (atomic: ExtensionAPI) {
|
|
767
618
|
atomic.on("session_start", (_event, ctx) => {
|
|
768
|
-
|
|
769
|
-
ctx.ui.setEditorComponent((tui, theme, keybindings) =>
|
|
770
|
-
new VimEditor(tui, theme, keybindings)
|
|
771
|
-
);
|
|
619
|
+
ctx.ui.setEditorComponent((tui, theme, keybindings) => new VimEditor(tui, theme, keybindings));
|
|
772
620
|
});
|
|
773
621
|
}
|
|
774
622
|
```
|
|
775
623
|
|
|
776
|
-
|
|
624
|
+
Pass `undefined` to `ctx.ui.setEditorComponent(undefined)` to restore the default editor. Custom editors exposing `setAutocompleteMaxVisible()` inherit the active `autocompleteMaxVisible` setting.
|
|
625
|
+
|
|
626
|
+
`new CustomEditor(tui, theme, keybindings, options?)` accepts `CustomEditorOptions`:
|
|
777
627
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
628
|
+
| Option | Type | Purpose |
|
|
629
|
+
| --- | --- | --- |
|
|
630
|
+
| `promptPrefix` | `string` | Custom prompt prefix rendered before input text. |
|
|
631
|
+
| `placeholder` | `string \| (() => string)` | Static or dynamic placeholder shown when the editor is empty. |
|
|
632
|
+
| `embedWorkingStatus` | `boolean` | When `true`, renders the streaming working indicator inside the editor's top rule instead of a standalone row. |
|
|
633
|
+
| `topRuleLabel` | `() => string \| undefined` | Optional dynamic label drawn on the editor's top rule. |
|
|
634
|
+
| `paddingX` | `number` | Horizontal padding (inherited from `EditorOptions`). |
|
|
635
|
+
| `autocompleteMaxVisible` | `number` | Maximum visible autocomplete rows (inherited from `EditorOptions`). |
|
|
636
|
+
|
|
637
|
+
<Note>
|
|
638
|
+
`setEditorComponent`, `setFooter`, `setHeader`, `onTerminalInput`, and `addAutocompleteProvider` require synchronous terminal callbacks and run only in single-process TUI hosts (they warn and do not run in default isolated interactive mode). See [Extension UI](/extensions/ui).
|
|
639
|
+
</Note>
|
|
784
640
|
|
|
785
641
|
**Examples:** [modal-editor.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/modal-editor.ts)
|
|
786
642
|
|
|
787
|
-
###
|
|
643
|
+
### Attached composer
|
|
788
644
|
|
|
789
|
-
When an extension or custom SDK host embeds a secondary chat editor, `applyAttachedComposer(style, label, placeholder, lines)`
|
|
645
|
+
When an extension or custom SDK host embeds a secondary chat editor, `applyAttachedComposer(style, label, placeholder, lines)` styles its rules with accent color, adds a bold `label` to the top rule, and displays a dim `placeholder` while empty:
|
|
790
646
|
|
|
791
647
|
```typescript
|
|
792
648
|
import { applyAttachedComposer, CustomEditor, type ExtensionAPI, type Theme } from "@bastani/atomic";
|
|
@@ -821,30 +677,29 @@ export default function (atomic: ExtensionAPI) {
|
|
|
821
677
|
}
|
|
822
678
|
```
|
|
823
679
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
## Key rules
|
|
827
|
-
|
|
828
|
-
1. **Always use theme from callback.** Do not import theme directly; use `theme` passed to `ctx.ui.custom((tui, theme, keybindings, done) => ...)`.
|
|
829
|
-
|
|
830
|
-
2. **Always type `DynamicBorder` color parameters.** Write `(s: string) => theme.fg("accent", s)`, not `(s) => theme.fg("accent", s)`.
|
|
680
|
+
`applyAttachedComposer()` replaces plain `─` rules and editor overflow rules (`↑ N more` / `↓ N more`). For the bottom border, it scans upward from the end of `lines` to find and recolor the last rule line even when non-rule lines (such as a hint or autocomplete menu) follow it. It inserts `placeholder` only when the editor has a single empty prompt row (the bottom rule is at line index `2` and line `1` is bare `❯`). Long labels truncate with `…`, and below `INPUT_LABEL_MIN_COLUMNS` (`40`) columns the rules render without the label. Pass `undefined` for `label` or `placeholder` to omit either.
|
|
831
681
|
|
|
832
|
-
|
|
682
|
+
For `buildInputLabel()` and `applyInputLabelToEditorTopRule()`, see [Input label helpers](/tui/reference#input-label-helpers).
|
|
833
683
|
|
|
834
|
-
|
|
684
|
+
## Key rules
|
|
835
685
|
|
|
836
|
-
|
|
686
|
+
<Tip>
|
|
687
|
+
- **Always use `theme` from callbacks.** Do not import a theme singleton directly; use the `theme` passed to `ctx.ui.custom()`, `setWidget()`, `renderCall()`, or `renderResult()`.
|
|
688
|
+
- **Type `DynamicBorder` parameters explicitly.** Write `(s: string) => theme.fg("accent", s)`.
|
|
689
|
+
- **Call `tui.requestRender()` after state changes** inside `handleInput()`.
|
|
690
|
+
- **Prefer built-in components.** `Selector`, `SelectList`, `SettingsList`, and `BorderedLoader` cover most interactive UI cases.
|
|
691
|
+
</Tip>
|
|
837
692
|
|
|
838
693
|
## Examples
|
|
839
694
|
|
|
840
|
-
- **Selection UI
|
|
841
|
-
- **Async with cancel
|
|
842
|
-
- **Settings toggles
|
|
843
|
-
- **Status
|
|
844
|
-
- **Working indicator
|
|
845
|
-
- **Custom footer
|
|
846
|
-
- **Custom editor
|
|
847
|
-
- **
|
|
848
|
-
- **Custom tool rendering
|
|
849
|
-
|
|
850
|
-
|
|
695
|
+
- **Selection UI:** [preset.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/preset.ts) (`SelectList` with `DynamicBorder`)
|
|
696
|
+
- **Async with cancel:** [qna.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/qna.ts) (`BorderedLoader`)
|
|
697
|
+
- **Settings toggles:** [tools.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tools.ts) (`SettingsList`)
|
|
698
|
+
- **Status and widgets:** [plan-mode/index.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/plan-mode/index.ts) (`setStatus`, `setWidget`)
|
|
699
|
+
- **Working indicator:** [working-indicator.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/working-indicator.ts) (`setWorkingIndicator`)
|
|
700
|
+
- **Custom footer:** [custom-footer.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/custom-footer.ts) (`setFooter`)
|
|
701
|
+
- **Custom editor:** [modal-editor.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/modal-editor.ts) (Vim-like modal editing)
|
|
702
|
+
- **Interactive game loop:** [snake.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/snake.ts) (keyboard input and loop)
|
|
703
|
+
- **Custom tool rendering:** [todo.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/todo.ts) (`renderCall` and `renderResult`)
|
|
704
|
+
|
|
705
|
+
Continue to [TUI API reference](/tui/reference) for `ToolBlock`, `ExtensionCustomComponent`, theme invalidation, debug logging, and host-native UI contracts.
|