@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/extensions/ui.md
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "Build dialogs,
|
|
2
|
+
title: "Build custom UI"
|
|
3
|
+
sidebarTitle: "Build custom UI"
|
|
4
|
+
description: "Build dialogs, host-native pickers and forms, status widgets, custom components, overlays, and message renderers."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
<div id="custom-ui" />
|
|
8
8
|
|
|
9
|
-
Extensions interact with users through `ctx.ui` methods and customize how messages, entries, and tools
|
|
10
|
-
|
|
11
|
-
Check `ctx.hasUI` (or `ctx.mode === "tui"`) before
|
|
12
|
-
|
|
13
|
-
>
|
|
9
|
+
Extensions interact with users through `ctx.ui` methods and customize how messages, entries, and tools appear in the terminal.
|
|
10
|
+
|
|
11
|
+
Check `ctx.hasUI` (or `ctx.mode === "tui"`) before rendering terminal UI, and check `ctx.hasHumanInput` before calling dialogs in extensions that may run outside interactive mode. For reusable component patterns (`SelectList`, `BorderedLoader`, `SettingsList`, widgets, autocomplete, and custom footers), see [TUI components](/tui).
|
|
12
|
+
|
|
13
|
+
<Warning>
|
|
14
|
+
In **default interactive CLI mode** (`atomic`), extensions run in an isolated background worker process so slow code cannot freeze your keyboard. Dialogs, `ctx.ui.custom()`, widgets, status, notifications, and host-native pickers and forms work normally, while synchronous TUI callbacks, theme switching, working-indicator customization, and `registerMarkdownTransformer()` require an **embedded in-process TUI** host created via the SDK. There is no CLI flag to disable worker isolation.
|
|
15
|
+
</Warning>
|
|
16
|
+
|
|
17
|
+
## UI API compatibility matrix
|
|
18
|
+
|
|
19
|
+
Use this matrix to see what each UI API does across Atomic's four runtimes:
|
|
20
|
+
|
|
21
|
+
| API | Default interactive CLI (worker) | Embedded in-process TUI (SDK) | Headless RPC (`--mode rpc`) | Print / JSON (`-p`, `--mode json`, no `humanInput`) |
|
|
22
|
+
| --- | --- | --- | --- | --- |
|
|
23
|
+
| `select()`, `confirm()`, `input()` (incl. `{ timeout }`) | Supported (live countdown) | Supported (live countdown) | Supported via RPC dialog requests | Rejects with `HumanInputUnavailable` |
|
|
24
|
+
| `editor(title, prefill, { timeout })` | Supported, but `timeout` auto-cancels locally with **no countdown display** | Supported (live countdown) | Supported via RPC (`timeout` omitted from request) | Rejects with `HumanInputUnavailable` |
|
|
25
|
+
| `notify()`, `setStatus()`, `setTitle()`, `setEditorText()` | Supported | Supported | Supported (fire-and-forget RPC requests) | No-op |
|
|
26
|
+
| `setWidget(key, lines)` | Supported | Supported | Supported | No-op |
|
|
27
|
+
| `setWidget(key, factoryFn)` | Supported | Supported | **Throws** `Error("Component-factory widgets are unavailable in this RPC host.")` | No-op |
|
|
28
|
+
| `custom(factory, options)` | Supported (return value must be JSON-serializable) | Supported | Resolves `undefined` | Rejects with `HumanInputUnavailable` |
|
|
29
|
+
| `hostSessionPicker()`, `hostInputForm()` | Supported (runs natively in TUI host) | Supported | Omitted (`undefined`) | Omitted (`undefined`) |
|
|
30
|
+
| `hostQuestionnaire()` | Omitted (interactive TUI renders questionnaire directly) | Omitted | Supported when client advertises `questionnaire` capability; else resolves `undefined` | Omitted (`undefined`) |
|
|
31
|
+
| `requestRender()`, `getHostCustomUiState()`, `onHostCustomUiStateChange()`, `focusHostInlineCustomUi()`, `onWidgetRelease()` | Supported | Supported | No-op / default idle state | No-op / omitted |
|
|
32
|
+
| `pasteToEditor(text)` | Delegates to `setEditorText(text)` (**replaces** editor text; no paste collapse) | Full paste handling and large-paste collapse | Delegates to `setEditorText(text)` | No-op |
|
|
33
|
+
| `getToolsExpanded()` / `setToolsExpanded()` | Worker-local boolean only (does not read or change host TUI state) | Reads and toggles live TUI expansion | Worker-local boolean only | `false` / no-op |
|
|
34
|
+
| `getChatRenderSettings()` | Reads host `hideThinkingBlock`, `fullscreenScrollbar`, `fullscreenWheelScrollLines`, and tool/message renderers; hardcodes `hiddenThinkingLabel: "Thinking..."`, `showImages: false`, `imageWidthCells: 60`, `markdownTransformers: []` | Full live TUI settings | Static defaults | Static defaults |
|
|
35
|
+
| `setWorkingMessage()`, `setWorkingVisible()`, `setWorkingIndicator()`, `setHiddenThinkingLabel()` | Silent no-op | Supported | Silent no-op | Silent no-op |
|
|
36
|
+
| `setTheme()`, `getAllThemes()`, `getTheme()` | `setTheme()` returns `{ success: false, error: "Theme switching not supported in RPC mode" }`; `getAllThemes()` returns `[]`; `getTheme()` returns `undefined` | Supported | Same as worker | `setTheme()` returns `{ success: false, error: "UI not available" }`; `[]` / `undefined` |
|
|
37
|
+
| `onTerminalInput()`, `getEditorText()`, `setEditorComponent()`, `addAutocompleteProvider()`, `setHeader()`, `setFooter()` | Emits a one-time warning and does not run (`getEditorText()` returns `""`) | Supported | Silent no-op (`getEditorText()` returns `""`) | Silent no-op (`getEditorText()` returns `""`) |
|
|
38
|
+
| `atomic.registerMarkdownTransformer()` | Does not run | Supported | Does not run | Does not run |
|
|
14
39
|
|
|
15
40
|
## Dialogs
|
|
16
41
|
|
|
@@ -31,11 +56,11 @@ const text = await ctx.ui.editor("Edit:", "prefilled text");
|
|
|
31
56
|
ctx.ui.notify("Done!", "info"); // "info" | "warning" | "error"
|
|
32
57
|
```
|
|
33
58
|
|
|
34
|
-
Notifications emitted during extension loading or startup
|
|
59
|
+
Notifications emitted during extension loading or startup appear below the startup `RESOURCES` line.
|
|
35
60
|
|
|
36
61
|
### Timed dialogs with countdown
|
|
37
62
|
|
|
38
|
-
|
|
63
|
+
Pass `{ timeout }` (in milliseconds) to auto-dismiss a dialog:
|
|
39
64
|
|
|
40
65
|
```typescript
|
|
41
66
|
// Shows "Title (5s)", "Title (4s)", and auto-dismisses at 0
|
|
@@ -46,17 +71,19 @@ const confirmed = await ctx.ui.confirm(
|
|
|
46
71
|
);
|
|
47
72
|
```
|
|
48
73
|
|
|
49
|
-
Return values
|
|
74
|
+
Return values when a dialog times out or your own `signal` aborts:
|
|
50
75
|
|
|
51
76
|
- `select()` returns `undefined`
|
|
52
77
|
- `confirm()` returns `false`
|
|
53
78
|
- `input()` and `editor()` return `undefined`
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
<Note>
|
|
81
|
+
In default interactive CLI mode and RPC mode, `select()`, `confirm()`, and `input()` forward `timeout` to display a live countdown, whereas `editor()` cancels locally after `timeout` ms without rendering a countdown. If the session closes, cancels all pending input, or swaps its input host while a dialog is waiting, the promise rejects with an error whose `code` is `"HumanInputCancelled"` (or `"SessionClosed"` if the session already closed).
|
|
82
|
+
</Note>
|
|
56
83
|
|
|
57
84
|
### Manual dismissal with AbortSignal
|
|
58
85
|
|
|
59
|
-
Pass `{ signal }` to dismiss a dialog programmatically and
|
|
86
|
+
Pass `{ signal }` to dismiss a dialog programmatically and tell a timeout apart from a user cancellation:
|
|
60
87
|
|
|
61
88
|
```typescript
|
|
62
89
|
const controller = new AbortController();
|
|
@@ -83,15 +110,17 @@ See [examples/extensions/timed-confirm.ts](https://github.com/bastani-inc/atomic
|
|
|
83
110
|
|
|
84
111
|
## Host-native pickers and forms
|
|
85
112
|
|
|
86
|
-
These APIs render directly
|
|
113
|
+
These APIs render directly inside the terminal UI process so typing, search, validation, and keybindings stay instant even in default interactive CLI mode. They are `undefined` in print, JSON, and headless RPC modes, so guard calls with optional chaining.
|
|
87
114
|
|
|
88
115
|
### Session picker (`ctx.ui.hostSessionPicker`)
|
|
89
116
|
|
|
90
|
-
Open a searchable session-style picker with JSON-safe `HostSessionPickerRow` items (`SessionInfo` with `createdAt` and `modifiedAt`
|
|
117
|
+
Open a searchable session-style picker with JSON-safe `HostSessionPickerRow` items (`SessionInfo` with `createdAt` and `modifiedAt` flattened to epoch milliseconds):
|
|
91
118
|
|
|
92
119
|
```typescript
|
|
93
120
|
const picker = ctx.ui.hostSessionPicker?.({
|
|
94
121
|
title: "Resume session",
|
|
122
|
+
variant: "sessions", // "sessions" | "runs"
|
|
123
|
+
showRenameHint: false,
|
|
95
124
|
sessions: rows,
|
|
96
125
|
onDelete: async (path) => {
|
|
97
126
|
await deleteSession(path);
|
|
@@ -105,47 +134,154 @@ picker?.error("Could not refresh list");
|
|
|
105
134
|
const selectedPath = await picker?.result; // Selected path or undefined on cancel
|
|
106
135
|
```
|
|
107
136
|
|
|
137
|
+
Each `HostSessionPickerRow` accepts standard session metadata (`path`, `id`, `cwd`, `createdAt`, `modifiedAt`, `messageCount`, `firstMessage`, optional `summary`, `allMessagesText`, `name`) plus optional synthetic display fields (`title`, `detail`, `messageColor`: `"success" | "warning" | "accent" | "error"`, `canDelete`).
|
|
138
|
+
|
|
108
139
|
The returned `HostSessionPickerHandle` exposes `result`, `update(rows)`, `error(message)`, and `close()`. See [Host-native session picker](/tui/reference#host-native-session-picker).
|
|
109
140
|
|
|
110
141
|
### Structured input form (`ctx.ui.hostInputForm`)
|
|
111
142
|
|
|
112
|
-
Open an inline structured form with JSON-safe field descriptors (`string`, `text`, `number`, `integer`, `boolean`, or `select`) and raw `initialValue`
|
|
143
|
+
Open an inline structured form with JSON-safe field descriptors (`string`, `text`, `number`, `integer`, `boolean`, or `select`) and raw string `initialValue` entries:
|
|
113
144
|
|
|
114
145
|
```typescript
|
|
115
146
|
const values = await ctx.ui.hostInputForm?.({
|
|
116
147
|
title: "Configure endpoint",
|
|
148
|
+
heading: "API settings",
|
|
149
|
+
submitLabel: "Save",
|
|
117
150
|
fields: [
|
|
118
|
-
{
|
|
119
|
-
|
|
151
|
+
{
|
|
152
|
+
name: "url",
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "Base URL for API requests",
|
|
155
|
+
required: true,
|
|
156
|
+
placeholder: "https://api.example.com",
|
|
157
|
+
initialValue: "https://api.example.com",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "retries",
|
|
161
|
+
type: "integer",
|
|
162
|
+
description: "Maximum retry attempts",
|
|
163
|
+
initialValue: "3",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "mode",
|
|
167
|
+
type: "select",
|
|
168
|
+
choices: ["fast", "strict"],
|
|
169
|
+
initialValue: "fast",
|
|
170
|
+
},
|
|
120
171
|
],
|
|
121
172
|
});
|
|
122
173
|
```
|
|
123
174
|
|
|
124
|
-
`hostInputForm()` resolves to a
|
|
175
|
+
`HostInputFormField` supports `name`, `type`, `initialValue`, and optional `description`, `required`, `choices` (for `"select"`), and `placeholder`. `hostInputForm()` resolves to a `Record<string, string>` or `undefined` on cancel, and rejects with `"The host could not read this input form."` if the host cannot read the form. See [Host-native input form](/tui/reference#host-native-input-form).
|
|
125
176
|
|
|
126
177
|
### Native questionnaire (`ctx.ui.hostQuestionnaire`)
|
|
127
178
|
|
|
128
|
-
|
|
179
|
+
In headless RPC mode, optional `ctx.ui.hostQuestionnaire?(params, signal)` delegates a full `ask_user_question` questionnaire as a single RPC request when the client advertises `questionnaire` capability. It returns the `QuestionnaireResult`, or `undefined` when the host cannot display it (so the caller renders the questionnaire itself).
|
|
180
|
+
|
|
181
|
+
## Status, widgets, and editor controls
|
|
129
182
|
|
|
130
|
-
|
|
183
|
+
### Status bar and terminal title
|
|
131
184
|
|
|
132
|
-
|
|
185
|
+
These methods work in default interactive CLI mode, embedded in-process TUI, and RPC mode:
|
|
133
186
|
|
|
134
187
|
```typescript
|
|
135
|
-
// Status in footer (persistent until cleared)
|
|
188
|
+
// Status text in the footer (persistent until cleared with undefined)
|
|
136
189
|
ctx.ui.setStatus("my-ext", "Processing...");
|
|
137
190
|
ctx.ui.setStatus("my-ext", undefined);
|
|
138
191
|
|
|
139
|
-
//
|
|
192
|
+
// Terminal window/tab title
|
|
193
|
+
ctx.ui.setTitle("atomic - my-project");
|
|
194
|
+
|
|
195
|
+
// Request a TUI repaint after async extension state changes
|
|
140
196
|
ctx.ui.requestRender();
|
|
141
197
|
|
|
142
|
-
//
|
|
198
|
+
// Read built-in footer data (git branch, extension statuses, available providers)
|
|
199
|
+
const footerData = ctx.ui.getFooterDataProvider();
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Widgets
|
|
203
|
+
|
|
204
|
+
Place persistent status panels above or below the editor using either string lines or a component factory:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { Text } from "@bastani/atomic-tui";
|
|
208
|
+
|
|
209
|
+
// Plain string lines above (default) or below the editor
|
|
210
|
+
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
|
211
|
+
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" });
|
|
212
|
+
|
|
213
|
+
// Component factory (supported in default interactive CLI and embedded TUI; throws in standalone headless RPC)
|
|
214
|
+
ctx.ui.setWidget("my-widget", (_tui, theme) => ({
|
|
215
|
+
render: (width) => new Text(theme.fg("accent", "Custom widget"), 0, 0).render(width),
|
|
216
|
+
invalidate() {},
|
|
217
|
+
dispose() {
|
|
218
|
+
// Optional cleanup hook run when the widget is cleared or replaced
|
|
219
|
+
},
|
|
220
|
+
}));
|
|
221
|
+
|
|
222
|
+
// Clear the widget
|
|
223
|
+
ctx.ui.setWidget("my-widget", undefined);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
For taller content, opt into a host-managed scroll viewport (`ScrollableWidgetComponent` with optional `getScrollRequest?()`, `onScroll?()`, and `dispose?()`) and subscribe to host release notifications:
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
ctx.ui.setWidget(
|
|
230
|
+
"my-scrollable",
|
|
231
|
+
(_tui, _theme) => myScrollableComponent,
|
|
232
|
+
{ placement: "aboveEditor", scroll: { maxHeight: 12, maxHeightFraction: 0.35 } },
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const unsubscribeRelease = ctx.ui.onWidgetRelease?.("my-scrollable", () => {
|
|
236
|
+
// Clean up timers or subscriptions if the host releases this widget
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
For widgets driven by reactive snapshots or periodic timers, `@bastani/atomic` also exports `installReactiveWidget()` and `decideReactiveWidgetAction()` to coalesce mount, unmount, and redraw updates cleanly.
|
|
241
|
+
|
|
242
|
+
<Note>
|
|
243
|
+
Inline custom UIs opened with `{ purpose: "navigation" }` temporarily hide all `setWidget()` widgets above and below the editor (including the agent panel) along with queued-message and pending-shell previews. Widgets keep updating in the background and reappear once the navigation view closes. Overlays and `"prompt"` custom UIs do not hide widgets.
|
|
244
|
+
</Note>
|
|
245
|
+
|
|
246
|
+
### Editor text and host UI state
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// Prefill or replace the main input editor
|
|
250
|
+
ctx.ui.setEditorText("Draft prompt");
|
|
251
|
+
|
|
252
|
+
// Paste text (in embedded in-process TUI, applies large-paste collapse;
|
|
253
|
+
// in default CLI worker and RPC mode, replaces editor text via setEditorText)
|
|
254
|
+
ctx.ui.pasteToEditor("pasted content");
|
|
255
|
+
|
|
256
|
+
// Inspect or react to whether an inline blocking custom UI is mounted
|
|
257
|
+
const uiState = ctx.ui.getHostCustomUiState?.();
|
|
258
|
+
const stopObserving = ctx.ui.onHostCustomUiStateChange?.((nextState) => {
|
|
259
|
+
if (nextState.blockingInlineCustomUiActive) {
|
|
260
|
+
// Move keyboard focus back to a deferred inline custom UI when ready
|
|
261
|
+
ctx.ui.focusHostInlineCustomUi?.();
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Read active chat render preferences (see compatibility matrix for worker defaults)
|
|
266
|
+
const renderSettings = ctx.ui.getChatRenderSettings();
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### In-process TUI only
|
|
270
|
+
|
|
271
|
+
<Note>
|
|
272
|
+
The APIs below require direct access to the terminal UI process and **only work in embedded in-process TUI sessions** (created via the SDK). In default interactive CLI mode, working-indicator, hidden-thinking, and theme calls are silent no-ops/stubs, while header, footer, editor-read, and raw terminal input calls emit a warning and skip.
|
|
273
|
+
</Note>
|
|
274
|
+
|
|
275
|
+
#### Working indicator and collapsed thinking label
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Customize the loading text shown from prompt submission through the turn
|
|
143
279
|
ctx.ui.setWorkingMessage("Thinking deeply...");
|
|
144
|
-
ctx.ui.setWorkingMessage();
|
|
145
|
-
ctx.ui.setWorkingVisible(false);
|
|
280
|
+
ctx.ui.setWorkingMessage(); // Restore default
|
|
281
|
+
ctx.ui.setWorkingVisible(false); // Hide working row (compaction indicator stays visible)
|
|
146
282
|
ctx.ui.setWorkingVisible(true);
|
|
147
283
|
|
|
148
|
-
//
|
|
284
|
+
// Customize the animated working indicator (default pulses Atomic's ∀ spinner across 6 brightness tones)
|
|
149
285
|
ctx.ui.setWorkingIndicator({ frames: [ctx.ui.theme.fg("accent", "●")] });
|
|
150
286
|
ctx.ui.setWorkingIndicator({
|
|
151
287
|
frames: [
|
|
@@ -157,83 +293,67 @@ ctx.ui.setWorkingIndicator({
|
|
|
157
293
|
intervalMs: 120,
|
|
158
294
|
});
|
|
159
295
|
ctx.ui.setWorkingIndicator({ frames: [] }); // Hide indicator
|
|
160
|
-
ctx.ui.setWorkingIndicator(); // Restore default
|
|
296
|
+
ctx.ui.setWorkingIndicator(); // Restore default animated spinner
|
|
161
297
|
|
|
162
298
|
// Label shown when thinking blocks are collapsed (Ctrl+T)
|
|
163
299
|
ctx.ui.setHiddenThinkingLabel("Pondering...");
|
|
164
300
|
ctx.ui.setHiddenThinkingLabel(); // Restore default
|
|
301
|
+
```
|
|
165
302
|
|
|
166
|
-
|
|
167
|
-
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
|
168
|
-
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" });
|
|
169
|
-
ctx.ui.setWidget("my-widget", (tui, theme) => new Text(theme.fg("accent", "Custom"), 0, 0));
|
|
170
|
-
ctx.ui.setWidget("my-widget", undefined); // Clear
|
|
303
|
+
`ATOMIC_REDUCED_MOTION=1` makes the default spinner static, and `NO_COLOR` disables foreground colors. Custom frames render verbatim; apply theme colors with `ctx.ui.theme.fg(...)` when needed. See [Working indicator customization](/tui#pattern-4b-working-indicator-customization).
|
|
171
304
|
|
|
172
|
-
|
|
173
|
-
ctx.ui.setWidget(
|
|
174
|
-
"my-scrollable",
|
|
175
|
-
(tui, theme) => myScrollableComponent, // Implements ScrollableWidgetComponent (getScrollRequest?, onScroll?)
|
|
176
|
-
{ placement: "aboveEditor", scroll: { maxHeight: 12, maxHeightFraction: 0.35 } },
|
|
177
|
-
);
|
|
178
|
-
const unsubscribeRelease = ctx.ui.onWidgetRelease?.("my-scrollable", () => {
|
|
179
|
-
// Clean up resources when the host releases this widget
|
|
180
|
-
});
|
|
305
|
+
#### Custom header, footer, raw input, and tool expansion
|
|
181
306
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
ctx.ui.setHeader(
|
|
307
|
+
```typescript
|
|
308
|
+
// Replace startup header or footer (factories may return an optional dispose() cleanup hook)
|
|
309
|
+
ctx.ui.setHeader((_tui, theme) => new Text(theme.fg("accent", "Custom header"), 0, 0));
|
|
310
|
+
ctx.ui.setHeader(undefined); // Restore built-in header
|
|
185
311
|
|
|
186
|
-
ctx.ui.setFooter((
|
|
187
|
-
render(
|
|
312
|
+
ctx.ui.setFooter((_tui, theme, footerData) => ({
|
|
313
|
+
render(_width) {
|
|
188
314
|
const branch = footerData.getGitBranch() ?? "";
|
|
189
315
|
return [theme.fg("dim", `Custom footer ${branch}`)];
|
|
190
316
|
},
|
|
191
317
|
invalidate() {},
|
|
318
|
+
dispose() {},
|
|
192
319
|
}));
|
|
193
|
-
ctx.ui.setFooter(undefined);
|
|
194
|
-
|
|
195
|
-
// Read built-in footer data (git branch, extension statuses) directly
|
|
196
|
-
const footerData = ctx.ui.getFooterDataProvider();
|
|
320
|
+
ctx.ui.setFooter(undefined); // Restore built-in footer
|
|
197
321
|
|
|
198
|
-
//
|
|
199
|
-
ctx.ui.setTitle("atomic - my-project");
|
|
200
|
-
|
|
201
|
-
// Editor text and paste
|
|
202
|
-
ctx.ui.setEditorText("Prefill text");
|
|
322
|
+
// Read editor text synchronously
|
|
203
323
|
const current = ctx.ui.getEditorText();
|
|
204
|
-
ctx.ui.pasteToEditor("pasted content"); // Applies normal paste handling and large-paste collapse
|
|
205
324
|
|
|
206
|
-
//
|
|
325
|
+
// Intercept or transform raw terminal input before Atomic handles it
|
|
207
326
|
const stopInput = ctx.ui.onTerminalInput((data) => {
|
|
208
|
-
if (data === "\x07") return { consume: true };
|
|
209
|
-
return
|
|
327
|
+
if (data === "\x07") return { consume: true }; // Drop key
|
|
328
|
+
if (data === "a") return { data: "A" }; // Rewrite key data
|
|
329
|
+
return undefined; // Pass through unchanged
|
|
210
330
|
});
|
|
211
331
|
|
|
212
|
-
//
|
|
332
|
+
// Read or toggle tool output expansion (no-op if already equal to target value)
|
|
213
333
|
const wasExpanded = ctx.ui.getToolsExpanded();
|
|
214
334
|
ctx.ui.setToolsExpanded(true);
|
|
215
335
|
ctx.ui.setToolsExpanded(wasExpanded);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### Theme switching
|
|
216
339
|
|
|
217
|
-
|
|
218
|
-
const themes = ctx.ui.getAllThemes();
|
|
340
|
+
```typescript
|
|
341
|
+
const themes = ctx.ui.getAllThemes(); // [{ name: "dark", path: "/..." | undefined }, ...]
|
|
219
342
|
const lightTheme = ctx.ui.getTheme("light");
|
|
220
343
|
const result = ctx.ui.setTheme("light");
|
|
221
344
|
if (!result.success) {
|
|
222
345
|
ctx.ui.notify(`Failed: ${result.error}`, "error");
|
|
223
346
|
}
|
|
224
347
|
if (lightTheme) ctx.ui.setTheme(lightTheme);
|
|
225
|
-
ctx.ui.theme.fg("accent", "styled text");
|
|
226
348
|
```
|
|
227
349
|
|
|
228
|
-
Calling `setToolsExpanded()` with the current value is a no-op. `ATOMIC_REDUCED_MOTION=1` makes the default `∀` working indicator static, and `NO_COLOR` disables foreground colors. Custom frames render verbatim; apply theme colors with `ctx.ui.theme.fg(...)` when needed.
|
|
229
|
-
|
|
230
|
-
These APIs customize display only; they do not start turns or emit stream events. See [Working indicator customization](/tui#pattern-4b-working-indicator-customization) for timing details.
|
|
231
|
-
|
|
232
350
|
## Autocomplete providers
|
|
233
351
|
|
|
234
|
-
|
|
352
|
+
<Note>
|
|
353
|
+
`ctx.ui.addAutocompleteProvider()` requires an **embedded in-process TUI** host. In default interactive CLI mode, calling it emits a warning and does not register the provider.
|
|
354
|
+
</Note>
|
|
235
355
|
|
|
236
|
-
Return the complete result from the wrapped provider, including its metadata. Slash-command suggestions can set `completeOnConfirm: false` so `Enter` submits the typed command literally until the user navigates the list, while `Tab` still accepts the highlighted item.
|
|
356
|
+
Use `ctx.ui.addAutocompleteProvider()` to layer custom completion on top of built-in slash-command and path completion. Return the complete result from the wrapped provider, including its metadata. Slash-command suggestions can set `completeOnConfirm: false` so `Enter` submits the typed command literally until the user navigates the list, while `Tab` still accepts the highlighted item.
|
|
237
357
|
|
|
238
358
|
```typescript
|
|
239
359
|
atomic.on("session_start", (_event, ctx) => {
|
|
@@ -270,7 +390,7 @@ See [github-issue-autocomplete.ts](https://github.com/bastani-inc/atomic/blob/ma
|
|
|
270
390
|
|
|
271
391
|
## Custom components
|
|
272
392
|
|
|
273
|
-
Use `ctx.ui.custom()` to mount an interactive component until it calls `done(value)`. The `factory` callback may be synchronous or async (`Promise<ExtensionCustomComponent>`):
|
|
393
|
+
Use `ctx.ui.custom()` to mount an interactive component until it calls `done(value)`. Works in both default interactive CLI mode and embedded in-process TUI hosts. The `factory` callback may be synchronous or async (`Promise<ExtensionCustomComponent>`), and the component may define an optional `dispose?()` cleanup method that runs when it unmounts:
|
|
274
394
|
|
|
275
395
|
```typescript
|
|
276
396
|
import { Text, type Component } from "@bastani/atomic-tui";
|
|
@@ -307,7 +427,7 @@ The factory receives four arguments:
|
|
|
307
427
|
- `tui`: TUI instance for screen dimensions and focus management
|
|
308
428
|
- `theme`: current theme for styling
|
|
309
429
|
- `keybindings`: configured `KeybindingsManager` for shortcut matching
|
|
310
|
-
- `done(value)`: closes the component and resolves `ctx.ui.custom()` with `value` (must be JSON-serializable in default interactive mode)
|
|
430
|
+
- `done(value)`: closes the component and resolves `ctx.ui.custom()` with `value` (must be JSON-serializable in default interactive CLI mode)
|
|
311
431
|
|
|
312
432
|
Supported `options`:
|
|
313
433
|
|
|
@@ -319,10 +439,10 @@ Supported `options`:
|
|
|
319
439
|
| `onHandle` | `(handle: OverlayHandle) => void` | Receive the overlay handle to show or hide it programmatically. |
|
|
320
440
|
| `reserveTranscriptRows` | `boolean` | Overlay-only. Reserves at least six visible transcript rows above a bottom-anchored blocking dialog. |
|
|
321
441
|
| `handlesCtrlC` | `boolean` | Set `true` when the component handles `Ctrl+C` itself; otherwise Atomic closes it on the first `Ctrl+C` press. |
|
|
322
|
-
| `handlesInternalUiAction` | `boolean` |
|
|
323
|
-
| `deferInlineCustomUiFocus` | `boolean` |
|
|
324
|
-
| `blocked` | `{ kind: ProgramStatus["kind"], message: string }` |
|
|
325
|
-
| `signal` | `AbortSignal` | Dismiss the custom UI programmatically. In default interactive mode, aborting resolves `ctx.ui.custom()` with `undefined` (like user cancel);
|
|
442
|
+
| `handlesInternalUiAction` | `boolean` | Route Atomic's internal terminal click actions (such as clicking a jump-to-bottom transcript link) to this component's `handleInput()` instead of letting the host handle them directly. |
|
|
443
|
+
| `deferInlineCustomUiFocus` | `boolean` | When an inline custom UI is already open in the editor slot, keep keyboard focus on this overlay rather than shifting focus back to the inline UI while the overlay is visible. |
|
|
444
|
+
| `blocked` | `{ kind: ProgramStatus["kind"], message: string }` | Signals supporting terminals and multiplexers that Atomic is waiting for user input while this component is active. |
|
|
445
|
+
| `signal` | `AbortSignal` | Dismiss the custom UI programmatically. In default interactive CLI mode, aborting resolves `ctx.ui.custom()` with `undefined` (like user cancel); in an embedded in-process TUI, it rejects with the signal's abort reason. |
|
|
326
446
|
|
|
327
447
|
### Input handling contract
|
|
328
448
|
|
|
@@ -382,7 +502,11 @@ render(width: number): string[] {
|
|
|
382
502
|
|
|
383
503
|
## Custom editor
|
|
384
504
|
|
|
385
|
-
|
|
505
|
+
<Note>
|
|
506
|
+
`ctx.ui.setEditorComponent()` requires an **embedded in-process TUI** host. In default interactive CLI mode, calling it emits a warning and keeps the built-in editor.
|
|
507
|
+
</Note>
|
|
508
|
+
|
|
509
|
+
Replace the main input editor by extending `CustomEditor`:
|
|
386
510
|
|
|
387
511
|
```typescript
|
|
388
512
|
import { CustomEditor, type ExtensionAPI } from "@bastani/atomic";
|
|
@@ -450,7 +574,7 @@ Return-value contract for `registerMessageRenderer`:
|
|
|
450
574
|
- **`null`:** Suppresses the message completely (zero rows, no spacer, and no default fallback box). Useful for hiding rehydrated messages whose backing state no longer exists.
|
|
451
575
|
- **`undefined`:** Falls back to Atomic's default boxed `[customType]` rendering.
|
|
452
576
|
|
|
453
|
-
In fullscreen mode, clicking a custom message toggles `expanded` for that message alone (just as `Ctrl+O` toggles every block) and calls your renderer again.
|
|
577
|
+
In fullscreen mode, clicking a custom message toggles `expanded` for that message alone (just as `Ctrl+O` toggles every block) and calls your renderer again. In an embedded in-process TUI, a component can intercept clicks first by returning `{ handled: true }` from `handleMouse`; in default interactive CLI mode, rendered rows are sent without custom mouse callbacks. A tool's title row always toggles first.
|
|
454
578
|
|
|
455
579
|
Send matching messages with `atomic.sendMessage()`:
|
|
456
580
|
|
|
@@ -463,7 +587,7 @@ await atomic.sendMessage({
|
|
|
463
587
|
});
|
|
464
588
|
```
|
|
465
589
|
|
|
466
|
-
## Theme colors
|
|
590
|
+
## Theme colors and formatting helpers
|
|
467
591
|
|
|
468
592
|
All render functions receive the active `theme` object. See [Customize themes](/themes) and [Theme reference](/themes/reference) for all color tokens.
|
|
469
593
|
|
|
@@ -491,13 +615,13 @@ theme.getFgAnsi("accent")
|
|
|
491
615
|
theme.getBgAnsi("selectedBg")
|
|
492
616
|
```
|
|
493
617
|
|
|
494
|
-
Syntax highlighting helper for custom renderers:
|
|
618
|
+
Syntax highlighting helper for custom renderers (`highlightCode(code, lang?)` reads the active theme automatically and returns highlighted lines):
|
|
495
619
|
|
|
496
620
|
```typescript
|
|
497
621
|
import { highlightCode, getLanguageFromPath } from "@bastani/atomic";
|
|
498
622
|
|
|
499
623
|
const lang = getLanguageFromPath("/path/to/file.rs"); // "rust"
|
|
500
|
-
const highlighted = highlightCode("fn main() {}", lang
|
|
624
|
+
const highlighted = highlightCode("fn main() {}", lang);
|
|
501
625
|
```
|
|
502
626
|
|
|
503
627
|
Line-range label helper for `read`-like tools (`formatReadLineRange` accepts numbers, numeric strings, and `null`, returning `""` for missing or malformed ranges):
|