@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/reference.md
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "TUI API reference"
|
|
3
3
|
sidebarTitle: "TUI API"
|
|
4
|
-
description: "Reference for Atomic TUI
|
|
4
|
+
description: "Reference for Atomic TUI tool blocks, custom component options, theme invalidation, debug logging, and host-native UI contracts."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
This page documents Atomic's extension TUI contracts exported from `@bastani/atomic`. For task-based extension patterns, see [Build TUI components](/tui). For the underlying terminal renderer, built-in layout primitives, mouse events, IME focus, and keyboard utilities, see [`@bastani/atomic-tui`](/libraries/tui).
|
|
8
|
+
|
|
7
9
|
## Tool blocks
|
|
8
10
|
|
|
9
|
-
Use `ToolBlock` from `@bastani/atomic` for a transcript item with a
|
|
11
|
+
Use `ToolBlock` from `@bastani/atomic` for a transcript item with a status glyph, one header row, and connected result rows. `new ToolBlock(spec)` accepts `status`, `title`, and optional `args`, `meta`, `details`, `body`, and `outputPad` (default `1`).
|
|
10
12
|
|
|
11
|
-
Supported `ToolBlockStatus` (aliases `NoticeStatus`) values:
|
|
13
|
+
Supported `ToolBlockStatus` (aliases `NoticeStatus`) values and their glyphs:
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
| Category | Status | Glyph | Meaning |
|
|
16
|
+
| --- | --- | --- | --- |
|
|
17
|
+
| General | `running` | `∀` | Tool call in progress |
|
|
18
|
+
| General | `success` | `●` | Completed successfully |
|
|
19
|
+
| General | `failure` | `✗` | Failed with an error |
|
|
20
|
+
| General | `stopped` | `◼` | Interrupted or not run (muted) |
|
|
21
|
+
| General | `warning` | `!` | Warning state |
|
|
22
|
+
| General | `paused` | `‖` | Paused (warning color) |
|
|
23
|
+
| General | `waiting` | `◌` | Released while waiting on a call; wakes automatically (dim) |
|
|
24
|
+
| General | `heartbeat` | `♥` | Periodic check on still-running work (muted) |
|
|
25
|
+
| General | `info` | `›` | Informational notice (muted) |
|
|
26
|
+
| Subagent / task | `agent-running` | `◯` | Running subagent (grey) |
|
|
27
|
+
| Subagent / task | `shell-running` | `⧗` | Running background shell (accent) |
|
|
28
|
+
| Subagent / task | `input` | `◆` | Subagent waiting for an answer (warning color) |
|
|
29
|
+
| Subagent / task | `task-queued` | `○` | Task waiting for its turn to run (dim) |
|
|
30
|
+
| Subagent / task | `task-stopping` | `◼` | Task currently stopping (warning color) |
|
|
31
|
+
| Subagent / task | `task-stopped` | `◯` | Stopped subagent or background task (red) |
|
|
15
32
|
|
|
16
|
-
`TASK_MARKS` from `@bastani/atomic` exports these glyphs for custom rendering. Exhaustive switches on `ToolBlockStatus` or `NoticeStatus` must handle all general states
|
|
33
|
+
`TASK_MARKS` from `@bastani/atomic` exports these task glyphs for custom rendering. Exhaustive switches on `ToolBlockStatus` or `NoticeStatus` must handle all 9 general states and all 6 subagent/task states.
|
|
17
34
|
|
|
18
|
-
A `NoticeLine` reports a task
|
|
35
|
+
A `NoticeLine` reports a task using task marks (`running` draws grey `◯`, `stopped` draws red `◯`, `paused` draws warning-colored `‖`). Under `NO_COLOR`, `agent-running` and `task-stopped` both render plain `◯` and are distinguished by their text.
|
|
19
36
|
|
|
20
37
|
```typescript
|
|
21
38
|
import { ToolBlock, ToolBlockRecords } from "@bastani/atomic";
|
|
@@ -28,259 +45,213 @@ const item = new ToolBlock({
|
|
|
28
45
|
});
|
|
29
46
|
```
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`host.replaceMessages(messages)` starts a fresh unread baseline. Use `host.replaceMessages(messages, { preserveUnread: true })` for a new snapshot of the same conversation; arrivals that have not painted yet remain unread.
|
|
38
|
-
|
|
39
|
-
An extra row supplied through `host.appendExtraEntry()` may exist nowhere else. Atomic keeps those rows in memory until the host is disposed without saving private extension data to disk.
|
|
48
|
+
- **Spacing and groups:** A `ToolBlock` adds no leading blank line; `ToolBlockGroup` separates multiple blocks with one blank line.
|
|
49
|
+
- **Records:** `new ToolBlockRecords(records, { preserveConnectors?: boolean })` renders each string or `Component` record with a leading `⎿` connector. Set `preserveConnectors: true` when child lines already carry their own connector formatting.
|
|
50
|
+
- **Markdown inside blocks:** `ToolBlockMarkdown(text)` sanitizes terminal control sequences, renders links as plain text plus URLs (not clickable terminal links), and renders images as `[image]`. The base `Markdown` component from `@bastani/atomic-tui` also accepts per-instance `{ hyperlinks: false, images: false }` in its sixth constructor argument.
|
|
51
|
+
- **Tool renderers:** In `renderCall`, return only the call title; in `renderResult`, return unframed result content (or `ToolBlockRecords` when multiple results need separate connectors). Atomic supplies the state glyph and outer connectors.
|
|
52
|
+
- **MCP headers:** Bundled MCP tools (`mcp__<server>__<tool>`) render `<server>/<tool>` in the call header before results arrive—including on resumed sessions before the server connects—without opening connections or exposing tool arguments.
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
### Heartbeat blocks (`HeartbeatBlock`)
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
## Component interface
|
|
46
|
-
|
|
47
|
-
`@bastani/atomic-tui` defines the base `Component` interface, and Atomic extends it with `ExtensionCustomComponent` for components returned by `ctx.ui.custom()`:
|
|
56
|
+
`HeartbeatBlock` renders a periodic status check using the `♥` glyph, one header row, connected record rows, and a dim inspect hint:
|
|
48
57
|
|
|
49
58
|
```typescript
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
capturesViewportInput?: boolean;
|
|
61
|
-
invalidate(): void;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Returned by ctx.ui.custom() in @bastani/atomic
|
|
65
|
-
type ExtensionCustomComponent = Omit<Component, "handleInput"> & {
|
|
66
|
-
handleInput?: (data: string) => boolean | undefined | Promise<boolean | undefined>;
|
|
67
|
-
dispose?(): void;
|
|
59
|
+
import { HeartbeatBlock, type HeartbeatBlockSpec } from "@bastani/atomic";
|
|
60
|
+
|
|
61
|
+
const spec: HeartbeatBlockSpec = {
|
|
62
|
+
title: "Task heartbeat",
|
|
63
|
+
subject: "test suite",
|
|
64
|
+
meta: ["2m 15s", "running"],
|
|
65
|
+
records: [["142 passed, 0 failed"]],
|
|
66
|
+
hint: "/tasks to inspect",
|
|
67
|
+
expandable: false,
|
|
68
|
+
expanded: false,
|
|
68
69
|
};
|
|
70
|
+
const block = new HeartbeatBlock(spec);
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
| --- | --- |
|
|
73
|
-
| `render(width)` | Return an array of lines; each line **must not exceed `width`**. |
|
|
74
|
-
| `renderSized?(width, height)` | Optional sized renderer called instead of `render()` when a layout allocates a fixed row count. |
|
|
75
|
-
| `handleInput?(data)` | Receive keyboard input when focused (a focused overlay also receives mouse input before the fullscreen viewport). On `ExtensionCustomComponent`, return `true` (or a promise resolving to `true`) when consuming input; return `false`, `undefined`, or reject to let matching fullscreen viewport keys or overlay mouse events fall through to the viewport. Non-overlay focused components leave mouse input with `@bastani/atomic-tui` so transcript scrolling, scrollbar dragging, and text selection remain available. |
|
|
76
|
-
| `handleMouse?(event)` | Optional normalized mouse event handler on base `@bastani/atomic-tui` components. |
|
|
77
|
-
| `paintedRowKey?(row)` | Optional stable identity for what the last render drew on `row` so click press/release pairs match the same item across repaints. |
|
|
78
|
-
| `selectionTextMayChangeOnReplay?` | Set `true` when rendered text depends on private state that cannot be replayed from history. |
|
|
79
|
-
| `historyReplayable?` | Set `true` as an own data property on chat render components that can be discarded and recreated from saved entries without losing state. |
|
|
80
|
-
| `wantsKeyRelease?` | If `true`, component receives key release events (Kitty protocol). Default: `false`. |
|
|
81
|
-
| `capturesViewportInput?` | If `true` while focused, fullscreen viewport keys such as PageUp/PageDown go to the component instead of scrolling the transcript, as they do for a focused overlay. `SelectList`, `SettingsList`, and the editor with open autocomplete set it; wrappers can forward it. Default: `false`. |
|
|
82
|
-
| `invalidate()` | Clear cached render state. Called on theme changes. |
|
|
83
|
-
| `dispose?()` | Optional cleanup hook on `ExtensionCustomComponent`, invoked when `ctx.ui.custom()` closes or dismisses the component. |
|
|
73
|
+
Each row inside `records` is either a `string` (truncated to width with `…`) or `{ text: string; wrap: true }` (wrapped across lines). When `expandable` is `true` and `expanded` is `false`, Atomic appends the expand key hint (`ctrl+o to expand`) to `hint`.
|
|
84
74
|
|
|
85
|
-
|
|
75
|
+
### Experimental: embedded chat host (`ChatSessionHost`)
|
|
86
76
|
|
|
87
|
-
|
|
77
|
+
<Warning>
|
|
78
|
+
`ChatSessionHost` is an experimental internal host exported from `@bastani/atomic` for embedded chats. It is not yet a guaranteed stable extension API and may change across releases.
|
|
79
|
+
</Warning>
|
|
88
80
|
|
|
89
|
-
|
|
81
|
+
When embedding `ChatSessionHost`:
|
|
90
82
|
|
|
91
|
-
|
|
83
|
+
- Forward the complete object returned by `ctx.ui.getChatRenderSettings()` (which includes `getToolDefinition`, `getCustomMessageRenderer`, and optional `createToolComponent` / `createCustomMessageComponent` factories) rather than copying only `getToolDefinition`, so tool renderers and repaint/expansion settings stay intact.
|
|
84
|
+
- Custom message renderers can read `options.cwd` for the receiving chat's working directory instead of assuming `process.cwd()`.
|
|
85
|
+
- `host.replaceMessages(messages)` starts a fresh unread baseline; pass `{ preserveUnread: true }` when applying a newer snapshot of the same conversation so unpainted arrivals stay unread.
|
|
86
|
+
- Rows added with `host.appendExtraEntry()` remain in memory until disposal without writing private extension data to disk.
|
|
87
|
+
- By default, Atomic keeps custom extension cards from saved chat history in memory when they scroll offscreen so stateful components are not lost. If your renderer can recreate a component deterministically from its saved message, set `historyReplayable: true` as an own data property on the component so Atomic can discard and re-render it on demand to save memory.
|
|
92
88
|
|
|
93
|
-
|
|
89
|
+
## Custom component options {#custom-component-options}
|
|
94
90
|
|
|
95
|
-
|
|
91
|
+
Complete options for `ctx.ui.custom(factory, options?)`:
|
|
96
92
|
|
|
97
|
-
|
|
93
|
+
| Option | Type | Behavior |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| `handlesCtrlC` | `boolean` | Default `false` (Atomic closes the component on first `Ctrl+C`). Set `true` only if your component handles `Ctrl+C` cleanly itself. |
|
|
96
|
+
| `handlesInternalUiAction` | `boolean` | Set `true` when the component claims internal UI actions such as clicking the jump-to-bottom link. |
|
|
97
|
+
| `signal` | `AbortSignal` | Dismisses the component and releases input ownership on abort (resolves `undefined` in CLI TUI; rejects with `signal.reason` in embedded SDK TUI hosts). |
|
|
98
|
+
| `purpose` | `"prompt" \| "navigation"` | Default `"prompt"` (for approvals and required decisions). Pass `"navigation"` for inspection/browsing views: suppresses prompt status events and hides `setWidget()` widgets, the agent panel, and queued previews while mounted inline (overlays do not hide them). |
|
|
99
|
+
| `blocked` | `{ kind: "question" \| "permission" \| "auth"; message: string }` | Reports Atomic as blocked via [program status](/terminal-setup#program-status). Inline components report blocked while visible; overlays report blocked until `done()` or `signal` abort even when hidden or covered. |
|
|
100
|
+
| `overlay` | `boolean` | Mounts the component as a floating overlay. |
|
|
101
|
+
| `overlayOptions` | `OverlayOptions \| (() => OverlayOptions)` | Static or dynamic overlay size, anchor, margins, and responsive visibility. |
|
|
102
|
+
| `onHandle` | `(handle: OverlayHandle) => void` | Receives the overlay handle for focus and visibility control. |
|
|
103
|
+
| `deferInlineCustomUiFocus` | `boolean` | Overlay-only. Keeps pending inline custom UI deferred in the background while the overlay holds focus. |
|
|
104
|
+
| `reserveTranscriptRows` | `boolean` | Overlay-only option for blocking bottom-anchored dialogs (`bottom-left`, `bottom-center`, `bottom-right`; rejects `row` and nonzero `offsetY`). Leaves at least 6 transcript rows visible above the overlay and extends scrollback. Embed `OVERLAY_ACTIVE_ROW_MARKER` (from `@bastani/atomic`) once per frame in the active row so Atomic windows cropped overlays around it on short terminals. |
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
import { CURSOR_MARKER, type Component, type Focusable, renderFakeCursor } from "@bastani/atomic-tui";
|
|
106
|
+
Main-chat inline custom UIs share the editor slot: completing an older mount leaves the current one visible, closing the current mount restores the previous pending inline UI, and the main editor returns only after the last inline owner closes. Reserving bottom prompts wait out of view while inline navigation or an overlay with `deferInlineCustomUiFocus` holds input.
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
Overlays inspecting host inline custom UI state via `ctx.ui.getHostCustomUiState()` or `ctx.ui.onHostCustomUiStateChange()` receive `HostCustomUiState`:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
interface HostCustomUiState {
|
|
112
|
+
blockingInlineCustomUiDepth: number; // Number of active non-overlay host custom UI mounts
|
|
113
|
+
blockingInlineCustomUiActive: boolean; // True when at least one inline custom UI is mounted
|
|
114
|
+
blockingInlineCustomUiFocusDeferred?: boolean;// True while inline custom UI waits behind a focused overlay
|
|
115
|
+
blockingInlineCustomUiNeedsInput?: boolean; // Distinguishes required prompts from navigation views
|
|
110
116
|
}
|
|
111
117
|
```
|
|
112
118
|
|
|
113
|
-
|
|
114
|
-
1. Sets `focused = true` on the component
|
|
115
|
-
2. Scans rendered output for `CURSOR_MARKER` (a zero-width APC escape sequence)
|
|
116
|
-
3. Positions the hardware terminal cursor at that location
|
|
117
|
-
4. Shows the hardware cursor only when `showHardwareCursor` is enabled
|
|
119
|
+
### Selector helpers {#selector-helpers}
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
- **`SelectorState`:** Holds search query, filtered rows, selection, and checked rows headless for unit testing. `SelectorState.items` is read-only and frozen; update rows via `state.setItems(rows)` or copy with `[...state.items]`.
|
|
122
|
+
- **`selectorHintEntries(state, options)`:** Returns the hint key entries for a `SelectorState`.
|
|
123
|
+
- **`themeSelectorStyle()` / `PLAIN_SELECTOR_STYLE`:** Returns themed or unstyled `SelectorStyle` colors.
|
|
124
|
+
- **Invalidation:** Call `selector.invalidate()` before `tui.requestRender()` when external data used by a custom `style` or `extraKeys` `enabled` callback changes (`labelStyle` runs on every render).
|
|
125
|
+
- **`UserMessageSelectorComponent`:** Implements the `/fork` picker on `Selector`: `new UserMessageSelectorComponent(messages, onSelect, onCancel, initialSelectedId?)` accepts `{ id, text }` user messages oldest first, 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.
|
|
120
126
|
|
|
121
|
-
|
|
127
|
+
### Input label helpers {#input-label-helpers}
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
- **`buildInputLabel(style, name, maxNameWidth, prefix, suffix)`:** Formats a truncated label `{ plain, styled }` (returning `undefined` when `maxNameWidth < 1`).
|
|
130
|
+
- **`applyInputLabelToEditorTopRule(style, kind, name, lines)`:** Decorates an editor's top `─` rule with `[stage: <name>]` or `[subagent: <name>]` when terminal width is at least `INPUT_LABEL_MIN_COLUMNS` (`40`).
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
import { Container, type Focusable, Input } from "@bastani/atomic-tui";
|
|
132
|
+
## Component interface
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
private searchInput: Input;
|
|
134
|
+
Atomic extends `@bastani/atomic-tui`'s base [`Component` interface](/libraries/tui#component-interface) with `ExtensionCustomComponent` for components returned by `ctx.ui.custom()`:
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
get focused(): boolean {
|
|
136
|
-
return this._focused;
|
|
137
|
-
}
|
|
138
|
-
set focused(value: boolean) {
|
|
139
|
-
this._focused = value;
|
|
140
|
-
this.searchInput.focused = value;
|
|
141
|
-
}
|
|
136
|
+
```typescript
|
|
137
|
+
import type { Component } from "@bastani/atomic-tui";
|
|
142
138
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
}
|
|
139
|
+
type ExtensionCustomComponent = Omit<Component, "handleInput"> & {
|
|
140
|
+
handleInput?: (data: string) => boolean | undefined | Promise<boolean | undefined>;
|
|
141
|
+
dispose?(): void;
|
|
142
|
+
};
|
|
149
143
|
```
|
|
150
144
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
- **Consuming input:** Return `true` (or a promise resolving to `true`) from `handleInput()` when your component consumes a fullscreen viewport key or an overlay mouse event. Returning `false`, `undefined`, or rejecting lets matching viewport keys or overlay mouse events fall through to the transcript viewport.
|
|
146
|
+
- **Async handlers:** Atomic evaluates async `handleInput()` return values when they settle; unhandled inputs fall through to whichever component holds focus when the promise settles.
|
|
147
|
+
- **Pass-through overlays:** A focused overlay without `handleInput` lets fullscreen viewport keys and mouse wheel events scroll the transcript behind it.
|
|
148
|
+
- **Non-overlay mouse behavior:** Focused inline components leave mouse scrolling, scrollbar dragging, and text selection with `@bastani/atomic-tui`.
|
|
149
|
+
- **Line resets:** The TUI appends full SGR and OSC 8 resets at the end of every rendered line; reapply styles per line or use `wrapTextWithAnsi()`.
|
|
154
150
|
|
|
155
|
-
|
|
151
|
+
See [`@bastani/atomic-tui` Component interface](/libraries/tui#component-interface) for every base `Component` member (`render`, `renderSized`, `handleMouse`, `paintedRowKey`, `selectionTextMayChangeOnReplay`, `historyReplayable`, `wantsKeyRelease`, `capturesViewportInput`, `invalidate`).
|
|
156
152
|
|
|
157
|
-
|
|
158
|
-
import { matchesKey, Key } from "@bastani/atomic-tui";
|
|
159
|
-
|
|
160
|
-
handleInput(data: string): boolean {
|
|
161
|
-
if (matchesKey(data, Key.up)) {
|
|
162
|
-
this.selectedIndex--;
|
|
163
|
-
return true;
|
|
164
|
-
} else if (matchesKey(data, Key.enter)) {
|
|
165
|
-
this.onSelect?.(this.selectedIndex);
|
|
166
|
-
return true;
|
|
167
|
-
} else if (matchesKey(data, Key.escape)) {
|
|
168
|
-
this.onCancel?.();
|
|
169
|
-
return true;
|
|
170
|
-
} else if (matchesKey(data, Key.ctrl("c"))) {
|
|
171
|
-
// CTRL+C
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
```
|
|
153
|
+
## Focusable interface (IME support)
|
|
177
154
|
|
|
178
|
-
|
|
179
|
-
- Basic keys: `Key.enter`, `Key.escape`, `Key.tab`, `Key.space`, `Key.backspace`, `Key.delete`, `Key.home`, `Key.end`
|
|
180
|
-
- Arrow keys: `Key.up`, `Key.down`, `Key.left`, `Key.right`
|
|
181
|
-
- With modifiers: `Key.ctrl("c")`, `Key.shift("tab")`, `Key.alt("left")`, `Key.ctrlShift("p")`
|
|
182
|
-
- String format also works: `"enter"`, `"ctrl+c"`, `"shift+tab"`, `"ctrl+shift+p"`
|
|
155
|
+
Components that display a text cursor and support CJK/IME input must implement `Focusable` (`focused: boolean`), emit `CURSOR_MARKER` right before `renderFakeCursor(...)`, and—for container dialogs wrapping an `Input` or `Editor`—propagate `focused` down to the child input. See [`@bastani/atomic-tui` Focusable interface](/libraries/tui#focusable-interface-ime-support) for the full implementation pattern.
|
|
183
156
|
|
|
184
|
-
|
|
157
|
+
## Keyboard input
|
|
185
158
|
|
|
186
|
-
|
|
159
|
+
Use `matchesKey(data, Key.*)` from `@bastani/atomic-tui` for keyboard handling (including Kitty protocol sequences), `decodePrintableKey(data)` for printable CSI-u / `modifyOtherKeys` text input, and `normalizePastedText(content)` for bracketed paste normalization. See [`@bastani/atomic-tui` Key detection](/libraries/tui#key-detection).
|
|
187
160
|
|
|
188
161
|
## Line width
|
|
189
162
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
import { visibleWidth, truncateToWidth } from "@bastani/atomic-tui";
|
|
194
|
-
|
|
195
|
-
render(width: number): string[] {
|
|
196
|
-
// Truncate long lines
|
|
197
|
-
return [truncateToWidth(this.text, width)];
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Utilities:
|
|
202
|
-
- `visibleWidth(str)`: display width (ignores ANSI codes).
|
|
203
|
-
- `truncateToWidth(str, width, ellipsis?)`: truncate with optional ellipsis.
|
|
204
|
-
- `wrapTextWithAnsi(str, width)`: word wrap preserving ANSI codes.
|
|
163
|
+
Every line returned by `render(width)` **must not exceed `width` columns** or the renderer throws an error. Use `visibleWidth()`, `truncateToWidth()`, and `wrapTextWithAnsi()` from `@bastani/atomic-tui` (see [`@bastani/atomic-tui` Utilities](/libraries/tui#utilities)).
|
|
205
164
|
|
|
206
165
|
## Invalidation and theme changes
|
|
207
166
|
|
|
208
|
-
When the theme
|
|
167
|
+
When the user switches themes or edits a watched custom theme file, the TUI calls `invalidate()` on every mounted component.
|
|
209
168
|
|
|
210
|
-
|
|
169
|
+
<Note>
|
|
170
|
+
The `Theme` object passed to Atomic extension callbacks (`ctx.ui.custom`, `setWidget`, `setFooter`, `renderCall`, `renderResult`) is a live proxy that always resolves against the active theme. Store that `theme` reference on your component and call `this.theme.fg(...)` / `this.theme.bg(...)` when rebuilding in `invalidate()`.
|
|
171
|
+
</Note>
|
|
211
172
|
|
|
212
|
-
|
|
173
|
+
### Why pre-baked theme strings go stale
|
|
213
174
|
|
|
214
|
-
|
|
175
|
+
If a component bakes ANSI color codes into a child `Text` string in its constructor and never rebuilds that string on `invalidate()`, the cached child retains the old theme's ANSI codes even after its render cache clears:
|
|
215
176
|
|
|
216
177
|
```typescript
|
|
178
|
+
import type { Theme } from "@bastani/atomic";
|
|
179
|
+
import { Container, Text } from "@bastani/atomic-tui";
|
|
180
|
+
|
|
181
|
+
// Wrong: pre-baked colors stay stale after theme switches
|
|
217
182
|
class BadComponent extends Container {
|
|
218
183
|
private content: Text;
|
|
219
184
|
|
|
220
185
|
constructor(message: string, theme: Theme) {
|
|
221
186
|
super();
|
|
222
|
-
// Pre-baked theme colors stored in Text component
|
|
223
187
|
this.content = new Text(theme.fg("accent", message), 1, 0);
|
|
224
188
|
this.addChild(this.content);
|
|
225
189
|
}
|
|
226
|
-
// No invalidate override: parent invalidate only clears
|
|
227
|
-
// child render caches, not the pre-baked content
|
|
228
190
|
}
|
|
229
191
|
```
|
|
230
192
|
|
|
231
|
-
### Rebuilding themed content on invalidate
|
|
193
|
+
### Rebuilding themed content on `invalidate()`
|
|
232
194
|
|
|
233
|
-
|
|
195
|
+
Store `private theme: Theme` and rebuild pre-baked strings inside `invalidate()`:
|
|
234
196
|
|
|
235
197
|
```typescript
|
|
198
|
+
import type { Theme } from "@bastani/atomic";
|
|
199
|
+
import { Container, Text } from "@bastani/atomic-tui";
|
|
200
|
+
|
|
236
201
|
class GoodComponent extends Container {
|
|
237
202
|
private message: string;
|
|
203
|
+
private theme: Theme;
|
|
238
204
|
private content: Text;
|
|
239
205
|
|
|
240
|
-
constructor(message: string) {
|
|
206
|
+
constructor(message: string, theme: Theme) {
|
|
241
207
|
super();
|
|
242
208
|
this.message = message;
|
|
209
|
+
this.theme = theme;
|
|
243
210
|
this.content = new Text("", 1, 0);
|
|
244
211
|
this.addChild(this.content);
|
|
245
212
|
this.updateDisplay();
|
|
246
213
|
}
|
|
247
214
|
|
|
248
215
|
private updateDisplay(): void {
|
|
249
|
-
|
|
250
|
-
this.content.setText(theme.fg("accent", this.message));
|
|
216
|
+
this.content.setText(this.theme.fg("accent", this.message));
|
|
251
217
|
}
|
|
252
218
|
|
|
253
219
|
override invalidate(): void {
|
|
254
|
-
super.invalidate();
|
|
255
|
-
this.updateDisplay(); // Rebuild with
|
|
220
|
+
super.invalidate(); // Clear child caches
|
|
221
|
+
this.updateDisplay(); // Rebuild with active theme
|
|
256
222
|
}
|
|
257
223
|
}
|
|
258
224
|
```
|
|
259
225
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
For components with complex content:
|
|
226
|
+
For complex component trees, clear and rebuild children on `invalidate()`:
|
|
263
227
|
|
|
264
228
|
```typescript
|
|
229
|
+
import type { Theme } from "@bastani/atomic";
|
|
230
|
+
import { Container, Spacer, Text } from "@bastani/atomic-tui";
|
|
231
|
+
|
|
232
|
+
interface SomeData {
|
|
233
|
+
items: { label: string; active: boolean }[];
|
|
234
|
+
}
|
|
235
|
+
|
|
265
236
|
class ComplexComponent extends Container {
|
|
266
237
|
private data: SomeData;
|
|
238
|
+
private theme: Theme;
|
|
267
239
|
|
|
268
|
-
constructor(data: SomeData) {
|
|
240
|
+
constructor(data: SomeData, theme: Theme) {
|
|
269
241
|
super();
|
|
270
242
|
this.data = data;
|
|
243
|
+
this.theme = theme;
|
|
271
244
|
this.rebuild();
|
|
272
245
|
}
|
|
273
246
|
|
|
274
247
|
private rebuild(): void {
|
|
275
|
-
this.clear();
|
|
276
|
-
|
|
277
|
-
// Build UI with current theme
|
|
278
|
-
this.addChild(new Text(theme.fg("accent", theme.bold("Title")), 1, 0));
|
|
248
|
+
this.clear();
|
|
249
|
+
this.addChild(new Text(this.theme.fg("accent", this.theme.bold("Title")), 1, 0));
|
|
279
250
|
this.addChild(new Spacer(1));
|
|
280
251
|
|
|
281
252
|
for (const item of this.data.items) {
|
|
282
253
|
const color = item.active ? "success" : "muted";
|
|
283
|
-
this.addChild(new Text(theme.fg(color, item.label), 1, 0));
|
|
254
|
+
this.addChild(new Text(this.theme.fg(color, item.label), 1, 0));
|
|
284
255
|
}
|
|
285
256
|
}
|
|
286
257
|
|
|
@@ -291,39 +262,30 @@ class ComplexComponent extends Container {
|
|
|
291
262
|
}
|
|
292
263
|
```
|
|
293
264
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
This pattern is needed when:
|
|
297
|
-
|
|
298
|
-
1. **Pre-baking theme colors:** using `theme.fg()` or `theme.bg()` to create styled strings stored in child components.
|
|
299
|
-
2. **Syntax highlighting:** using `highlightCode()`, which applies theme-based syntax colors.
|
|
300
|
-
3. **Complex layouts:** building child component trees that embed theme colors.
|
|
301
|
-
|
|
302
|
-
This pattern is not needed when:
|
|
303
|
-
|
|
304
|
-
1. **Using theme callbacks:** passing functions like `(text) => theme.fg("accent", text)` called during render.
|
|
305
|
-
2. **Simple containers:** grouping other components without adding themed content.
|
|
306
|
-
3. **Stateless render:** computing themed output fresh in every `render()` call without caching.
|
|
265
|
+
Rebuild in `invalidate()` whenever you pre-bake `theme.fg()`/`theme.bg()` into child components, cache `highlightCode()` output, or construct themed child trees in the constructor. You do **not** need this pattern when passing theme callbacks evaluated during `render()`, using plain layout containers, or computing styled lines fresh inside `render()`.
|
|
307
266
|
|
|
308
267
|
## Debug logging
|
|
309
268
|
|
|
310
|
-
|
|
269
|
+
Capture TUI rendering diagnostics and tune escape-key reassembly with these environment variables (legacy `PI_*` aliases work when the `ATOMIC_*` variable is unset):
|
|
311
270
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
271
|
+
| Variable | Behavior | Scope |
|
|
272
|
+
| --- | --- | --- |
|
|
273
|
+
| `ATOMIC_TUI_WRITE_LOG` | Captures raw ANSI bytes written to stdout. Pass a file path, or a directory path to write one `tui-<timestamp>-<pid>.log` file per process. | Both fullscreen (`TuiAltScreen`) and main-screen (`TuiMainScreen`) |
|
|
274
|
+
| `ATOMIC_TUI_DEBUG=1` | Writes render snapshots to `/tmp/tui/render-<timestamp>-<random>.log`. | Main-screen (`TuiMainScreen`) only |
|
|
275
|
+
| `ATOMIC_TUI_DEBUG_REDRAW=1` | Logs full-redraw triggers to `~/.atomic/agent/pi-tui-debug.log` (or `<agentDir>/pi-tui-debug.log` in Atomic; `<logDirectory>/pi-tui-debug.log` in standalone `@bastani/atomic-tui`, where `logDirectory` must be set). The `pi-` filename prefix is intentional. | Main-screen (`TuiMainScreen`) only |
|
|
276
|
+
| `ATOMIC_TUI_ESC_TIMEOUT` | Milliseconds to wait after a lone `ESC` byte before treating it as `Escape` instead of an `Alt`/escape sequence. Default: `10` ms locally, `100` ms when `SSH_CONNECTION` or `SSH_TTY` is set. | Both renderers |
|
|
317
277
|
|
|
318
278
|
```bash
|
|
319
279
|
ATOMIC_TUI_WRITE_LOG=/tmp/tui-ansi.log atomic
|
|
320
280
|
```
|
|
321
281
|
|
|
322
|
-
|
|
282
|
+
<Warning>
|
|
283
|
+
Captured terminal logs include rendered prompts, code, and tool outputs. Review and redact them before sharing in bug reports.
|
|
284
|
+
</Warning>
|
|
323
285
|
|
|
324
286
|
## Performance
|
|
325
287
|
|
|
326
|
-
Cache rendered output
|
|
288
|
+
Cache rendered output by width and clear the cache in `invalidate()`:
|
|
327
289
|
|
|
328
290
|
```typescript
|
|
329
291
|
class CachedComponent {
|
|
@@ -334,7 +296,7 @@ class CachedComponent {
|
|
|
334
296
|
if (this.cachedLines && this.cachedWidth === width) {
|
|
335
297
|
return this.cachedLines;
|
|
336
298
|
}
|
|
337
|
-
|
|
299
|
+
const lines = this.computeLines(width);
|
|
338
300
|
this.cachedWidth = width;
|
|
339
301
|
this.cachedLines = lines;
|
|
340
302
|
return lines;
|
|
@@ -347,36 +309,32 @@ class CachedComponent {
|
|
|
347
309
|
}
|
|
348
310
|
```
|
|
349
311
|
|
|
350
|
-
Call `invalidate()` when state changes, then `ctx.ui.requestRender()` from
|
|
312
|
+
Call `invalidate()` when state changes, then `ctx.ui.requestRender()` from extension context or `tui.requestRender()` from a `ctx.ui.custom()` factory.
|
|
351
313
|
|
|
352
314
|
## Host integration
|
|
353
315
|
|
|
354
|
-
These runtime contracts pair with [Build TUI components](/tui), which provides runnable `ctx.ui.custom()` examples and common interaction patterns.
|
|
355
|
-
|
|
356
316
|
### Controlling terminal autowrap
|
|
357
317
|
|
|
358
|
-
|
|
318
|
+
Inside Atomic's terminal UI, components never write escape sequences directly to `process.stdout`. Use `tui.terminal.setAutowrap` when a Windows overlay needs to toggle autowrap (DECAWM):
|
|
359
319
|
|
|
360
320
|
```typescript
|
|
361
|
-
await ctx.ui.custom((tui,
|
|
362
|
-
tui.terminal.setAutowrap?.(false);
|
|
321
|
+
await ctx.ui.custom((tui, _theme, _keybindings, done) => {
|
|
322
|
+
tui.terminal.setAutowrap?.(false);
|
|
363
323
|
return new MyOverlay({ onClose: done });
|
|
364
324
|
}, { overlay: true });
|
|
365
325
|
```
|
|
366
326
|
|
|
367
|
-
|
|
327
|
+
Atomic restores the previous autowrap mode when the component hides, closes, or disposes, or if the terminal host recovers from a crash or restart. In standalone hosts without `setAutowrap`, write escape sequences only when your component owns the terminal directly.
|
|
368
328
|
|
|
369
329
|
### Detecting fullscreen vs. main-screen mode
|
|
370
330
|
|
|
371
|
-
`tui.mode` is `"fullscreen"` when Atomic paints on the alternate screen and `"regular"` on the main-screen fallback (
|
|
331
|
+
`tui.mode` is `"fullscreen"` when Atomic paints on the alternate screen and `"regular"` on the main-screen fallback (`TERM=dumb`, CI, or non-TTY).
|
|
372
332
|
|
|
373
|
-
Each rendered frame updates `tui.mode` to match the active
|
|
333
|
+
Each rendered frame updates `tui.mode` to match the active renderer and invalidates components on mode changes. Because `tui.mode` starts as `"regular"` before the first frame paints, read `tui.mode` inside `render()` rather than caching it in your factory.
|
|
374
334
|
|
|
375
335
|
### Host-native session picker
|
|
376
336
|
|
|
377
|
-
Use `ctx.ui.hostSessionPicker(request)` for responsive session-list navigation and search
|
|
378
|
-
|
|
379
|
-
This API is available in interactive terminal sessions and absent in headless RPC or print mode; report that limitation instead of building a fallback picker.
|
|
337
|
+
Use `ctx.ui.hostSessionPicker(request)` for responsive session-list navigation and search even while an extension is busy. This capability exists in interactive terminal sessions and is absent in headless RPC or print mode; report that limitation instead of building a fallback picker.
|
|
380
338
|
|
|
381
339
|
```typescript
|
|
382
340
|
const picker = ctx.ui.hostSessionPicker?.({
|
|
@@ -394,22 +352,20 @@ picker.update(await loadMoreRows()); // merge late rows into the open picker
|
|
|
394
352
|
const path = await picker.result; // selected row's path, or undefined on cancel
|
|
395
353
|
```
|
|
396
354
|
|
|
397
|
-
Each row renders two lines
|
|
398
|
-
|
|
399
|
-
The request's `title` sets the picker heading (default `Resume session`). Set `variant: "runs"` (default `"sessions"`) for non-session rows so the heading defaults to `Resume run` and session-specific folder scope, named-only filter, and path keys are hidden.
|
|
355
|
+
Each row renders two lines (`name` or `firstMessage`, then age, message count, and summary). Set `title` and `detail` on rows to override those lines for non-session items such as runs; search matches `title`, `detail`, and the row's other text fields.
|
|
400
356
|
|
|
401
|
-
Set `canDelete: false` on a row to disable deletion even when `onDelete` is
|
|
357
|
+
Set `request.title` for the heading (default `Resume session`), and set `variant: "runs"` (default `"sessions"`) for non-session rows so the heading defaults to `Resume run` and session-only filters and path keys are hidden. Set `canDelete: false` on a row to disable `Ctrl+D` deletion even when `onDelete` is provided. Keep a row until deletion finishes, then remove it with `update()` or report errors with `error()`; rows cannot be selected while deletion is pending.
|
|
402
358
|
|
|
403
359
|
### Host-native input form
|
|
404
360
|
|
|
405
|
-
Use `ctx.ui.hostInputForm(request)` for a structured inline form in the editor slot
|
|
361
|
+
Use `ctx.ui.hostInputForm(request)` for a structured inline form in the editor slot (`Tab`/`Shift+Tab`, arrow keys, configured keybindings, `Enter`, `Escape`, and `Ctrl+C`). The promise rejects with `"The host could not read this input form."` if the host cannot read the form.
|
|
406
362
|
|
|
407
363
|
```typescript
|
|
408
364
|
try {
|
|
409
365
|
const values = await ctx.ui.hostInputForm?.({
|
|
410
366
|
title: "Release",
|
|
411
|
-
heading: "Prepare release",
|
|
412
|
-
submitLabel: "Publish",
|
|
367
|
+
heading: "Prepare release",
|
|
368
|
+
submitLabel: "Publish",
|
|
413
369
|
fields: [
|
|
414
370
|
{
|
|
415
371
|
name: "version",
|
|
@@ -430,8 +386,4 @@ try {
|
|
|
430
386
|
|
|
431
387
|
`HostInputFormRequest` accepts `title`, `fields`, optional `heading`, and optional `submitLabel`. Each `HostInputFormField` accepts `name`, `type` (`"string"`, `"text"`, `"number"`, `"integer"`, `"boolean"`, or `"select"`), `initialValue` (raw string), and optional `description`, `placeholder`, `required`, and `choices`. Returned values are raw strings; your extension owns parsing and domain coercion.
|
|
432
388
|
|
|
433
|
-
Every current interactive Atomic host exposes
|
|
434
|
-
|
|
435
|
-
Each field's header shows whether its value is ready: `✓`, or `✗` with the reason (`required`, `choose one`, `choose on or off`, `must be a whole number`, `must be a whole number within ±9007199254740991`, `must be a number`, `must be on or off`, or `not in choices`).
|
|
436
|
-
|
|
437
|
-
Integers must stay within JavaScript's safe integer range so values are not rounded. Enter on the submit button runs only when every field is ready. Booleans accept `true`, `false`, `on`, `off`, `1`, or `0`; anything else is refused rather than read as off.
|
|
389
|
+
Every current interactive Atomic host exposes this optional capability, while headless RPC and print modes omit it. Each field header shows `✓` when ready or `✗` with the reason (`required`, `choose one`, `choose on or off`, `must be a whole number`, `must be a whole number within ±9007199254740991`, `must be a number`, `must be on or off`, or `not in choices`). `Enter` on the submit button runs only when every field is ready; booleans accept `true`, `false`, `on`, `off`, `1`, or `0`.
|