@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.
Files changed (342) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +1 -1
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
  9. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  10. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  11. package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
  12. package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
  13. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  14. package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
  15. package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
  16. package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
  17. package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
  18. package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
  19. package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
  20. package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
  21. package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
  22. package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
  23. package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
  24. package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
  25. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  26. package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
  27. package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
  28. package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
  29. package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
  30. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  31. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  32. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  33. package/dist/builtin/intercom/package.json +1 -1
  34. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  35. package/dist/builtin/mcp/package.json +1 -1
  36. package/dist/builtin/subagents/package.json +1 -1
  37. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  38. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  39. package/dist/builtin/web-access/package.json +1 -1
  40. package/dist/cli/auth-cli.code.js +1 -1
  41. package/dist/cli/auth-cli.impl.js +3 -3
  42. package/dist/cli/auth-cli.js +3 -3
  43. package/dist/cli/blueprint-command.impl.js +3 -3
  44. package/dist/cli/blueprint-command.js +3 -3
  45. package/dist/cli/intercom-command.code.js +3 -3
  46. package/dist/cli/intercom-command.impl.js +3 -3
  47. package/dist/cli/intercom-command.js +3 -3
  48. package/dist/cli/list-models.impl.js +3 -3
  49. package/dist/cli/list-models.js +3 -3
  50. package/dist/cli/session-picker.code.js +1 -1
  51. package/dist/cli/session-picker.impl.js +3 -3
  52. package/dist/cli/session-picker.js +3 -3
  53. package/dist/cli/startup-ui.code.js +1 -1
  54. package/dist/cli/startup-ui.impl.js +3 -3
  55. package/dist/cli/startup-ui.js +3 -3
  56. package/dist/cli/storage-command.impl.js +3 -3
  57. package/dist/cli/storage-command.js +3 -3
  58. package/dist/cli/storage-search-session.code.js +1 -1
  59. package/dist/cli/storage-search-session.impl.js +3 -3
  60. package/dist/cli/storage-search-session.js +3 -3
  61. package/dist/cli/team-command.code.js +1 -1
  62. package/dist/cli/team-command.impl.js +3 -3
  63. package/dist/cli/team-command.js +3 -3
  64. package/dist/cli.js +2 -2
  65. package/dist/core/compaction/compactor.d.ts +0 -8
  66. package/dist/core/debug.impl.js +3 -3
  67. package/dist/core/debug.js +3 -3
  68. package/dist/core/export-html/card-projection.impl.js +3 -3
  69. package/dist/core/export-html/card-projection.js +3 -3
  70. package/dist/core/export-html/index.code.js +2 -2
  71. package/dist/core/export-html/index.impl.js +3 -3
  72. package/dist/core/export-html/index.js +3 -3
  73. package/dist/core/export-html/json-spans.impl.js +3 -3
  74. package/dist/core/export-html/json-spans.js +3 -3
  75. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  76. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  77. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  78. package/dist/core/export-html/tool-renderer.js +3 -3
  79. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  80. package/dist/core/extensions/jiti-loader.js +3 -3
  81. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  82. package/dist/core/extensions/jiti-static-loader.js +3 -3
  83. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  84. package/dist/core/extensions/loader-host-modules.js +3 -3
  85. package/dist/core/intercom-broker-control-host.code.js +1 -1
  86. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  87. package/dist/core/intercom-broker-control-host.js +3 -3
  88. package/dist/core/intercom-broker-control.code.js +2 -2
  89. package/dist/core/intercom-broker-control.impl.js +3 -3
  90. package/dist/core/intercom-broker-control.js +3 -3
  91. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  92. package/dist/core/package-manager-storage-adapters.js +3 -3
  93. package/dist/core/sdk.code.js +1 -1
  94. package/dist/core/sdk.impl.js +3 -3
  95. package/dist/core/sdk.js +3 -3
  96. package/dist/core/session-manager-core.js +3 -3
  97. package/dist/core/session-manager-list.impl.js +3 -3
  98. package/dist/core/session-manager-list.js +3 -3
  99. package/dist/core/session-manager.impl.js +3 -3
  100. package/dist/core/session-manager.js +3 -3
  101. package/dist/core/session-storage.impl.js +3 -3
  102. package/dist/core/session-storage.js +3 -3
  103. package/dist/core/storage/index.js +2 -2
  104. package/dist/core/storage/node-sqlite-thread.js +2 -2
  105. package/dist/core/storage/node-sqlite.js +2 -2
  106. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  107. package/dist/core/storage/offline-snapshot-file.js +3 -3
  108. package/dist/core/storage/provider.js +2 -2
  109. package/dist/core/storage/selection.js +2 -2
  110. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  111. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  112. package/dist/core/storage/session/branch-fork-source.js +3 -3
  113. package/dist/core/storage/session/card-view.impl.js +3 -3
  114. package/dist/core/storage/session/card-view.js +3 -3
  115. package/dist/core/storage/session/child-reader.code.js +2 -2
  116. package/dist/core/storage/session/child-reader.impl.js +3 -3
  117. package/dist/core/storage/session/child-reader.js +3 -3
  118. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  119. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  120. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  121. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  122. package/dist/core/storage/session/expanded-child-details.js +3 -3
  123. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  124. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  125. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  126. package/dist/core/storage/session/fork-row-index.js +3 -3
  127. package/dist/core/storage/session/fork-staging.code.js +1 -1
  128. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  129. package/dist/core/storage/session/fork-staging.js +3 -3
  130. package/dist/core/storage/session/fork-window.code.js +2 -2
  131. package/dist/core/storage/session/fork-window.impl.js +3 -3
  132. package/dist/core/storage/session/fork-window.js +3 -3
  133. package/dist/core/storage/session/history-pages.impl.js +3 -3
  134. package/dist/core/storage/session/history-pages.js +3 -3
  135. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  136. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  137. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  138. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  139. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  140. package/dist/core/storage/session/memory-session-store.js +3 -3
  141. package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
  142. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  143. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  144. package/dist/core/storage/session/released-history-files.code.js +1 -1
  145. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  146. package/dist/core/storage/session/released-history-files.js +3 -3
  147. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  148. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  149. package/dist/core/storage/session/session-resume.impl.js +3 -3
  150. package/dist/core/storage/session/session-resume.js +3 -3
  151. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  152. package/dist/core/storage/session/snapshot-cut.js +3 -3
  153. package/dist/core/storage/session/snapshot-history.code.js +2 -2
  154. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  155. package/dist/core/storage/session/snapshot-history.js +3 -3
  156. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  157. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  158. package/dist/core/storage/session/sql-session-store.js +3 -3
  159. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  160. package/dist/core/storage/session/tree-outline.js +3 -3
  161. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  162. package/dist/core/storage/session/tree-presentation.js +3 -3
  163. package/dist/core/storage/storage-status.impl.js +3 -3
  164. package/dist/core/storage/storage-status.js +3 -3
  165. package/dist/core/storage/team.impl.js +3 -3
  166. package/dist/core/storage/team.js +3 -3
  167. package/dist/core/structured-output/index.code.js +1 -1
  168. package/dist/core/structured-output/index.impl.js +3 -3
  169. package/dist/core/structured-output/index.js +3 -3
  170. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  171. package/dist/core/tasks/task-completion-entry.js +3 -3
  172. package/dist/core/tasks/task-file-history.code.js +2 -2
  173. package/dist/core/tasks/task-file-history.impl.js +3 -3
  174. package/dist/core/tasks/task-file-history.js +3 -3
  175. package/dist/core/tasks/task-reference-archive.code.js +2 -2
  176. package/dist/core/tasks/task-reference-archive.js +3 -3
  177. package/dist/core/tasks/task-reference-identity.js +3 -3
  178. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  179. package/dist/core/tasks/task-reference-stream.js +3 -3
  180. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  181. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  182. package/dist/core/tasks/task-view-source.impl.js +3 -3
  183. package/dist/core/tasks/task-view-source.js +3 -3
  184. package/dist/core/tools/read-url.impl.js +3 -3
  185. package/dist/core/tools/read-url.js +3 -3
  186. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  187. package/dist/core/worktree-snapshot/errors.code.js +1 -1
  188. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  189. package/dist/core/worktree-snapshot/errors.js +3 -3
  190. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  191. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  192. package/dist/extensions/codemode/execute.impl.js +3 -3
  193. package/dist/extensions/codemode/execute.js +3 -3
  194. package/dist/extensions/codemode/renderer.impl.js +3 -3
  195. package/dist/extensions/codemode/renderer.js +3 -3
  196. package/dist/extensions/mcp/cli.code.js +1 -1
  197. package/dist/extensions/mcp/cli.impl.js +3 -3
  198. package/dist/extensions/mcp/cli.js +3 -3
  199. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  200. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  201. package/dist/extensions/mcp/cli.lazy.js +3 -3
  202. package/dist/extensions/mcp/runtime.code.js +1 -1
  203. package/dist/extensions/mcp/runtime.impl.js +3 -3
  204. package/dist/extensions/mcp/runtime.js +3 -3
  205. package/dist/index.d.ts +21 -1
  206. package/dist/index.js +2 -2
  207. package/dist/main-first-time-setup.code.js +1 -1
  208. package/dist/main-first-time-setup.impl.js +3 -3
  209. package/dist/main-first-time-setup.js +3 -3
  210. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  211. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  212. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  213. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  214. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  215. package/dist/modes/print-mode.js +1 -1
  216. package/dist/package-manager-cli.code.js +2 -2
  217. package/dist/package-manager-cli.impl.js +3 -3
  218. package/dist/package-manager-cli.js +3 -3
  219. package/dist/startup-files.json +1 -1
  220. package/dist/startup-stages/6.js +1 -1
  221. package/dist/utils/startup-database-spare.code.js +1 -1
  222. package/dist/utils/startup-database-spare.impl.js +3 -3
  223. package/dist/utils/startup-database-spare.js +3 -3
  224. package/dist/utils/tools-manager.impl.js +3 -3
  225. package/dist/utils/tools-manager.js +3 -3
  226. package/docs/background-tasks/reference.md +182 -0
  227. package/docs/background-tasks.md +98 -405
  228. package/docs/build.md +67 -27
  229. package/docs/changelog.mdx +11 -1
  230. package/docs/codemode.md +108 -39
  231. package/docs/compaction/branch-summaries.md +54 -0
  232. package/docs/compaction/custom-compactors.md +161 -0
  233. package/docs/compaction/memory-compaction.md +77 -0
  234. package/docs/compaction/reference.md +86 -38
  235. package/docs/compaction.md +51 -252
  236. package/docs/computer-use.md +169 -321
  237. package/docs/containerization.md +71 -57
  238. package/docs/custom-provider/api-reference.md +119 -25
  239. package/docs/custom-provider/oauth.md +114 -132
  240. package/docs/custom-provider/override.md +37 -27
  241. package/docs/custom-provider/registration.md +107 -83
  242. package/docs/custom-provider/streaming.md +85 -71
  243. package/docs/custom-provider.md +85 -52
  244. package/docs/development.md +39 -29
  245. package/docs/docs.json +80 -67
  246. package/docs/environment-variables.md +94 -44
  247. package/docs/extensions/api-reference.md +86 -43
  248. package/docs/extensions/authoring.md +162 -154
  249. package/docs/extensions/events.md +80 -25
  250. package/docs/extensions/examples.md +90 -85
  251. package/docs/extensions/ui.md +206 -82
  252. package/docs/extensions.md +79 -108
  253. package/docs/getting-started/authentication.md +67 -36
  254. package/docs/getting-started/first-session.md +53 -43
  255. package/docs/getting-started/installation.md +117 -90
  256. package/docs/getting-started/project-instructions.md +48 -34
  257. package/docs/guides/configuration.md +82 -20
  258. package/docs/guides/non-interactive.md +66 -24
  259. package/docs/guides/resume-on-any-machine.md +135 -82
  260. package/docs/guides/team-setup.md +114 -105
  261. package/docs/guides.md +76 -32
  262. package/docs/herdr.md +16 -17
  263. package/docs/how-atomic-works.md +140 -0
  264. package/docs/index.md +58 -44
  265. package/docs/intercom/operations.md +141 -151
  266. package/docs/intercom/reference.md +85 -108
  267. package/docs/intercom.md +84 -145
  268. package/docs/json.md +120 -67
  269. package/docs/keybindings.md +85 -49
  270. package/docs/libraries/agent-core.md +137 -275
  271. package/docs/libraries/ai.md +100 -84
  272. package/docs/libraries/codemode.md +210 -300
  273. package/docs/libraries/schema.md +59 -53
  274. package/docs/libraries/storage-postgres.md +49 -35
  275. package/docs/libraries/telemetry.md +153 -354
  276. package/docs/libraries/tui.md +265 -393
  277. package/docs/libraries.md +42 -26
  278. package/docs/llama-cpp.md +171 -161
  279. package/docs/mcp-servers.md +90 -51
  280. package/docs/models/choose-a-model.md +188 -0
  281. package/docs/models/reference.md +74 -30
  282. package/docs/models.md +153 -88
  283. package/docs/orchestration/migrating-workflows.md +23 -16
  284. package/docs/orchestration/patterns.md +39 -44
  285. package/docs/orchestration.md +65 -26
  286. package/docs/packages/authoring.md +51 -29
  287. package/docs/packages/reference.md +42 -21
  288. package/docs/packages.md +69 -58
  289. package/docs/programmatic.md +118 -24
  290. package/docs/prompt-templates.md +84 -83
  291. package/docs/providers/reference.md +43 -48
  292. package/docs/providers.md +219 -451
  293. package/docs/quickstart.md +140 -120
  294. package/docs/reference/cli.md +135 -97
  295. package/docs/reference.md +20 -19
  296. package/docs/rpc/examples.md +76 -20
  297. package/docs/rpc/extension-ui.md +64 -38
  298. package/docs/rpc/protocol.md +361 -110
  299. package/docs/rpc.md +57 -17
  300. package/docs/sdk/reference.md +409 -534
  301. package/docs/sdk/storage.md +53 -13
  302. package/docs/sdk/structured-decisions.md +82 -56
  303. package/docs/sdk/web-server.md +57 -43
  304. package/docs/sdk.md +106 -84
  305. package/docs/security.md +42 -64
  306. package/docs/session-format.md +62 -38
  307. package/docs/sessions.md +99 -214
  308. package/docs/settings.md +165 -195
  309. package/docs/shell-aliases.md +9 -6
  310. package/docs/skills/authoring.md +69 -48
  311. package/docs/skills/reference.md +51 -20
  312. package/docs/skills.md +99 -148
  313. package/docs/slash-commands.md +129 -0
  314. package/docs/storage/custom-adapters.md +160 -85
  315. package/docs/storage/jsonl.md +81 -66
  316. package/docs/storage/postgres/pgbouncer.md +120 -126
  317. package/docs/storage/postgres/tuning.md +120 -143
  318. package/docs/storage/postgres.md +314 -330
  319. package/docs/storage/sqlite.md +71 -42
  320. package/docs/storage.md +298 -302
  321. package/docs/subagents/authoring.md +55 -38
  322. package/docs/subagents/reference.md +73 -33
  323. package/docs/subagents.md +119 -187
  324. package/docs/terminal-setup.md +51 -39
  325. package/docs/themes/reference.md +23 -19
  326. package/docs/themes.md +142 -127
  327. package/docs/tmux.md +47 -55
  328. package/docs/tools.md +147 -109
  329. package/docs/tui/reference.md +166 -214
  330. package/docs/tui.md +196 -341
  331. package/docs/usage.md +118 -138
  332. package/docs/verification.md +79 -51
  333. package/docs/web-access.md +121 -101
  334. package/docs/windows.md +26 -27
  335. package/docs/worktree-snapshots/reference.md +245 -0
  336. package/docs/worktree-snapshots.md +71 -259
  337. package/package.json +8 -8
  338. package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
  339. package/docs/guides/intercom.md +0 -32
  340. package/docs/guides/orchestration.md +0 -28
  341. package/docs/guides/subagents.md +0 -37
  342. package/docs/termux.md +0 -118
@@ -1,21 +1,38 @@
1
1
  ---
2
2
  title: "TUI API reference"
3
3
  sidebarTitle: "TUI API"
4
- description: "Reference for Atomic TUI component, focusable, keyboard, theme invalidation, debug logging, and host-native UI contracts."
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 state glyph, one header row, and connected result rows. It accepts `status`, `title`, and optional `args`, `meta`, `details`, `body`, and `outputPad` (default `1`).
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
- - General states: `running` (`∀`), `success`, `failure`, `stopped` (interrupted or not run, muted `◼`), `warning`, `paused` (warning-colored `‖`), `waiting` (dim `◌`, wakes automatically when what it waits on finishes), `heartbeat` (muted `♥`), and `info`.
14
- - Subagent and background-task states (shared with the agent panel and `/tasks`): `agent-running` (grey `◯`), `shell-running` (`⧗`), `input` (`◆`, waiting for an answer), `task-queued` (dim `○`), `task-stopping` (warning-colored `◼`), and `task-stopped` (red `◯`).
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 (including `waiting` and `heartbeat`) plus all six subagent and background-task 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, drawing `running` as a grey `◯`, `stopped` as a red `◯`, and `paused` as warning-colored `‖`. With `NO_COLOR`, running and stopped notices (like `agent-running` and `task-stopped` blocks) both show plain `◯`, distinguished by their text.
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
- A block does not add a leading blank line; its container controls spacing between items. `ToolBlockGroup` separates several blocks with one blank line. `ToolBlockMarkdown(text)` sanitizes terminal controls and renders Markdown with links shown as text and URLs, not clickable terminal links, and images shown as `[image]`.
32
-
33
- In ordinary tool renderers, return only the call title from `renderCall` and unframed result content from `renderResult`; Atomic supplies the state glyph and connectors. Return `ToolBlockRecords` when several results need separate connectors.
34
-
35
- When embedding `ChatSessionHost` (an experimental embedded-chat host exported from `@bastani/atomic`; not yet a guaranteed stable extension API), forward the complete `ctx.ui.getChatRenderSettings()` result. Its optional component factories preserve tool renderers and the embedded chat's repaint and expansion settings. Do not copy only `getToolDefinition`. Custom message renderers can use `options.cwd` for the receiving chat's working directory instead of assuming `process.cwd()` matches it.
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
- An extension card in saved chat history can also hold state that its saved message cannot reproduce, so the chat keeps the original component when it scrolls offscreen. If a renderer can recreate its component without losing state, set `historyReplayable: true` as an own data property on the component so the chat can discard and re-render it on demand. Keep private rows and stateful cards small in long-lived chats.
54
+ ### Heartbeat blocks (`HeartbeatBlock`)
42
55
 
43
- The `Markdown` component from `@bastani/atomic-tui` also accepts per-instance `hyperlinks: false` and `images: false` in its sixth constructor argument. These options do not change other components or terminal capabilities.
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
- // Base component interface from @bastani/atomic-tui
51
- interface Component {
52
- render(width: number): string[];
53
- renderSized?(width: number, height: number): string[];
54
- handleInput?(data: string): void;
55
- handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;
56
- paintedRowKey?(row: number): string | undefined;
57
- readonly selectionTextMayChangeOnReplay?: boolean;
58
- readonly historyReplayable?: boolean;
59
- wantsKeyRelease?: boolean;
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
- | Member | Description |
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
- The `@bastani/atomic-tui` `Component` type permits handlers returning `void`; Atomic treats a missing or `undefined` return as unhandled only for matching fullscreen viewport keys or mouse events deferred to a focused overlay. Components that mutate state for such inputs must return `true` so the viewport does not apply them a second time.
75
+ ### Experimental: embedded chat host (`ChatSessionHost`)
86
76
 
87
- A focused overlay without `handleInput` lets fullscreen viewport keys and mouse wheel reports reach the transcript, so notices and progress panels do not freeze scrolling behind them.
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
- Atomic evaluates an asynchronous handler when it settles. Only a promise resolving to `true` consumes the input; `false`, `undefined`, and rejection fall through to the viewport (going to whichever component holds focus when it settles).
81
+ When embedding `ChatSessionHost`:
90
82
 
91
- The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered line. Styles do not carry across lines; reapply styles per line or use `wrapTextWithAnsi()` when wrapping styled text.
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
- Bundled MCP tools (`mcp__<server>__<tool>`) render `<server>/<tool>` in the call header before results arrive, including on resumed sessions whose server has not connected yet. Atomic resolves the label from the registered tool owner or splits an unambiguous `mcp__<server>__<tool>` name (falling back to the raw tool name when ambiguous or hash-suffixed), without opening connections or exposing tool arguments.
89
+ ## Custom component options {#custom-component-options}
94
90
 
95
- ## Focusable interface (IME support)
91
+ Complete options for `ctx.ui.custom(factory, options?)`:
96
92
 
97
- Components that display a text cursor and need IME (Input Method Editor) support should implement the `Focusable` interface:
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
- ```typescript
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
- class MyInput implements Component, Focusable {
103
- focused: boolean = false; // Set by TUI when focus changes
104
-
105
- render(width: number): string[] {
106
- const marker = this.focused ? CURSOR_MARKER : "";
107
- // Emit marker right before the fake cursor
108
- return [`> ${beforeCursor}${marker}${renderFakeCursor(atCursor)}${afterCursor}`];
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
- When a `Focusable` component has focus, TUI:
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
- `renderFakeCursor()` wraps the cursor cell in zero-width markers that TUI draws in reverse video. When `showHardwareCursor` is enabled, TUI removes the fake cursor that directly follows `CURSOR_MARKER`, so the focused component shows only the terminal cursor. Fake cursors without a preceding `CURSOR_MARKER` stay visible. Code that renders a component outside TUI sees the markers and must strip them.
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
- The hardware cursor remains hidden by default. This keeps the fake cursor rendering, while still positioning the hardware cursor for terminals that track IME candidate windows with hidden cursors. Some terminals require a visible hardware cursor for IME positioning; enable it with `showHardwareCursor`, `setShowHardwareCursor(true)`, or `ATOMIC_HARDWARE_CURSOR=1`. The `Editor` and `Input` built-in components already implement this interface.
127
+ ### Input label helpers {#input-label-helpers}
122
128
 
123
- ### Container components with embedded inputs
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
- When a container component (dialog, selector, etc.) contains an `Input` or `Editor` child, the container must implement `Focusable` and propagate the focus state to the child. Otherwise, the hardware cursor won't be positioned correctly for IME input.
126
-
127
- ```typescript
128
- import { Container, type Focusable, Input } from "@bastani/atomic-tui";
132
+ ## Component interface
129
133
 
130
- class SearchDialog extends Container implements Focusable {
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
- // Focusable implementation - propagate to child input for IME cursor positioning
134
- private _focused = false;
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
- constructor() {
144
- super();
145
- this.searchInput = new Input();
146
- this.addChild(this.searchInput);
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
- Without this propagation, typing with an IME (Chinese, Japanese, Korean, etc.) will show the candidate window in the wrong position on screen.
152
-
153
- ## Keyboard input
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
- Use `matchesKey()` for key detection:
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
- ```typescript
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
- **Key identifiers** (use `Key.*` for autocomplete, or string literals):
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
- For custom text inputs, use `decodePrintableKey(data)` from `@bastani/atomic-tui` to decode printable Kitty CSI-u and modifyOtherKeys sequences. It returns `undefined` for plain text and non-text keys, so handle ordinary printable text separately.
157
+ ## Keyboard input
185
158
 
186
- For bracketed paste, remove the paste markers and pass the content to `normalizePastedText(content)` from the same package. It restores tmux-encoded control bytes, normalizes CRLF and CR to newlines, expands tabs to four spaces, and removes C0 control bytes other than newlines.
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
- **Critical:** Each line from `render()` must not exceed the `width` parameter.
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 changes, the TUI calls `invalidate()` on all components. Clear cached render state there so the new theme takes effect.
167
+ When the user switches themes or edits a watched custom theme file, the TUI calls `invalidate()` on every mounted component.
209
168
 
210
- ### Why pre-baked theme strings go stale
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
- If a component pre-bakes theme colors into strings (via `theme.fg()`, `theme.bg()`, etc.) and caches them, the cached strings contain ANSI escape codes from the old theme. Clearing the render cache alone does not update pre-baked strings stored separately.
173
+ ### Why pre-baked theme strings go stale
213
174
 
214
- **Wrong approach** (theme colors won't update):
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
- Components that build content with theme colors must rebuild that content when `invalidate()` is called:
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
- // Rebuild content with current theme
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(); // Clear child caches
255
- this.updateDisplay(); // Rebuild with new theme
220
+ super.invalidate(); // Clear child caches
221
+ this.updateDisplay(); // Rebuild with active theme
256
222
  }
257
223
  }
258
224
  ```
259
225
 
260
- ### Pattern: rebuild on invalidate
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(); // Remove all children
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
- ### When to rebuild on invalidate
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
- Three environment variables capture TUI rendering diagnostics (legacy `PI_*` aliases are also accepted when the `ATOMIC_*` variable is unset):
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
- - **`ATOMIC_TUI_WRITE_LOG`** (legacy `PI_TUI_WRITE_LOG`): captures the raw ANSI byte stream written to stdout. Pass a file path, or a directory path to write one `tui-<timestamp>-<pid>.log` file per process.
313
- - **`ATOMIC_TUI_DEBUG=1`** (legacy `PI_TUI_DEBUG=1`): writes main-screen render snapshots to `/tmp/tui/render-<timestamp>-<random>.log`.
314
- - **`ATOMIC_TUI_DEBUG_REDRAW=1`** (legacy `PI_TUI_DEBUG_REDRAW=1`): logs full-redraw triggers to `pi-tui-debug.log` in the TUI log directory.
315
-
316
- Review all captured logs for sensitive content before sharing.
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
- Use these captures when reporting a terminal-rendering bug.
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 when possible:
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
- // ... compute lines ...
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 the extension context or `tui.requestRender()` from a `ctx.ui.custom()` factory to trigger re-render.
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
- When running inside Atomic's terminal UI, components do not write escape sequences directly to `process.stdout`. Use the optional `tui.terminal.setAutowrap` setter when a Windows overlay needs to toggle autowrap:
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, theme, keybindings, done) => {
362
- tui.terminal.setAutowrap?.(false); // disable autowrap (DECAWM) on Windows terminals
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
- Only autowrap control is exposed. Atomic restores the previous mode when the component hides, closes, or disposes, or if the terminal host recovers from a crash or restart. Fullscreen mode retains its baseline mouse and autowrap behavior. In custom standalone hosts, `setAutowrap` may be absent; write escape sequences directly only when your component owns the terminal directly.
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 (used under `TERM=dumb`, in CI, or without a TTY).
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 terminal renderer, and Atomic invalidates the component whenever the mode changes. Before the first frame renders, `tui.mode` starts as `"regular"`, so read `tui.mode` inside `render()` rather than caching it inside the factory.
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, even while an extension is busy. Pass JSON-safe rows, update or close the picker, and handle selection, cancellation, and confirmed `Ctrl+D` deletion through the API.
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: `name` or `firstMessage`, followed by age, message count, and summary. Set `title` and `detail` to override those lines for non-session rows such as jobs or runs; search matches `title`, `detail`, and the row's other text fields.
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 present. Keep the row until deletion finishes, then remove it with `update()` or report errors with `error()` from `onDelete`; rows cannot be selected while deletion is pending. `SessionInfo` exports optional `title`, `detail`, and `canDelete` fields for synthetic rows.
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. It supports `Tab`/`Shift+Tab`, arrow keys, text editing, 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.
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", // optional panel heading label
412
- submitLabel: "Publish", // optional submit button label
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 the optional capability, while headless RPC and print surfaces omit it. Keep a legacy fallback only when compatibility with older hosts is required.
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`.