@bastani/atomic 0.10.0-alpha.1 → 0.10.1-alpha.1

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 (234) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +22 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +35 -0
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +33 -3
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/core/agent-session-events.d.ts.map +1 -1
  10. package/dist/core/agent-session-events.js +21 -6
  11. package/dist/core/agent-session-events.js.map +1 -1
  12. package/dist/core/lifecycle-timings.d.ts +6 -0
  13. package/dist/core/lifecycle-timings.d.ts.map +1 -1
  14. package/dist/core/lifecycle-timings.js +12 -0
  15. package/dist/core/lifecycle-timings.js.map +1 -1
  16. package/dist/core/queued-message-delivery.d.ts +41 -0
  17. package/dist/core/queued-message-delivery.d.ts.map +1 -0
  18. package/dist/core/queued-message-delivery.js +48 -0
  19. package/dist/core/queued-message-delivery.js.map +1 -0
  20. package/dist/core/storage/node-sqlite-thread.d.ts +64 -0
  21. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -0
  22. package/dist/core/storage/node-sqlite-thread.js +326 -0
  23. package/dist/core/storage/node-sqlite-thread.js.map +1 -0
  24. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  25. package/dist/core/storage/node-sqlite.js +230 -104
  26. package/dist/core/storage/node-sqlite.js.map +1 -1
  27. package/dist/core/tasks/agent-panel-source.d.ts +5 -0
  28. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  29. package/dist/core/tasks/agent-panel-source.js +1 -1
  30. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  31. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +8 -1
  32. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  33. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  34. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +11 -5
  35. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  36. package/dist/modes/interactive/agent-view/agent-view-switcher.js +17 -5
  37. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  38. package/dist/modes/interactive/agent-view/contracts.d.ts +5 -0
  39. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  40. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  41. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  42. package/dist/modes/interactive/agent-view/install.js +6 -3
  43. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  44. package/dist/modes/interactive/agent-view/local-port.d.ts +5 -0
  45. package/dist/modes/interactive/agent-view/local-port.d.ts.map +1 -1
  46. package/dist/modes/interactive/agent-view/local-port.js +8 -0
  47. package/dist/modes/interactive/agent-view/local-port.js.map +1 -1
  48. package/dist/modes/interactive/agent-view/remote-port.d.ts +4 -1
  49. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  50. package/dist/modes/interactive/agent-view/remote-port.js +22 -8
  51. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  52. package/dist/modes/interactive/agent-view/transcript-slot.d.ts +9 -0
  53. package/dist/modes/interactive/agent-view/transcript-slot.d.ts.map +1 -1
  54. package/dist/modes/interactive/agent-view/transcript-slot.js +141 -1
  55. package/dist/modes/interactive/agent-view/transcript-slot.js.map +1 -1
  56. package/dist/modes/interactive/components/agent-panel.d.ts +6 -0
  57. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/agent-panel.js +40 -10
  59. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  60. package/dist/modes/interactive/components/atomic-working-status.d.ts +15 -0
  61. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/atomic-working-status.js +51 -3
  63. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  64. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  65. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/bash-execution.js +5 -1
  67. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  68. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -0
  69. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/branch-summary-message.js +5 -1
  71. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  72. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  73. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  74. package/dist/modes/interactive/components/chat-message-renderer.js +17 -6
  75. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  76. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  77. package/dist/modes/interactive/components/chat-session-host-events.js +35 -4
  78. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  80. package/dist/modes/interactive/components/chat-session-host-rendering.js +70 -13
  81. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  82. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +7 -0
  83. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/chat-session-host-runtime.js +25 -4
  85. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  86. package/dist/modes/interactive/components/chat-session-host-state.d.ts +41 -1
  87. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host-state.js +24 -3
  89. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-steering.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/chat-session-host-steering.js +2 -1
  92. package/dist/modes/interactive/components/chat-session-host-steering.js.map +1 -1
  93. package/dist/modes/interactive/components/chat-session-host.d.ts +13 -1
  94. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/chat-session-host.js +20 -2
  96. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  97. package/dist/modes/interactive/components/chat-transcript.d.ts +15 -0
  98. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/chat-transcript.js +14 -1
  100. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  101. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  102. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/compaction-boundary-message.js +5 -1
  104. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  105. package/dist/modes/interactive/components/custom-entry.d.ts +2 -0
  106. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/custom-entry.js +5 -1
  108. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  109. package/dist/modes/interactive/components/custom-message.d.ts +2 -0
  110. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/custom-message.js +5 -1
  112. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  113. package/dist/modes/interactive/components/model-column.d.ts +96 -0
  114. package/dist/modes/interactive/components/model-column.d.ts.map +1 -0
  115. package/dist/modes/interactive/components/model-column.js +207 -0
  116. package/dist/modes/interactive/components/model-column.js.map +1 -0
  117. package/dist/modes/interactive/components/prompt-slot.d.ts +73 -0
  118. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -0
  119. package/dist/modes/interactive/components/prompt-slot.js +201 -0
  120. package/dist/modes/interactive/components/prompt-slot.js.map +1 -0
  121. package/dist/modes/interactive/components/queued-messages-view.d.ts +6 -3
  122. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/queued-messages-view.js +7 -4
  124. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  125. package/dist/modes/interactive/components/session-selector.d.ts +2 -0
  126. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/session-selector.js +4 -0
  128. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  129. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -0
  130. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  131. package/dist/modes/interactive/components/skill-invocation-message.js +5 -1
  132. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  133. package/dist/modes/interactive/components/task-board.d.ts +12 -3
  134. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  135. package/dist/modes/interactive/components/task-board.js +33 -17
  136. package/dist/modes/interactive/components/task-board.js.map +1 -1
  137. package/dist/modes/interactive/components/task-inspector.d.ts +6 -1
  138. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  139. package/dist/modes/interactive/components/task-inspector.js +27 -7
  140. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  141. package/dist/modes/interactive/components/task-row.d.ts +4 -0
  142. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  143. package/dist/modes/interactive/components/task-row.js +7 -1
  144. package/dist/modes/interactive/components/task-row.js.map +1 -1
  145. package/dist/modes/interactive/components/task-transcript-page.d.ts +5 -0
  146. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/task-transcript-page.js +25 -0
  148. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  149. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  150. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  151. package/dist/modes/interactive/components/tool-execution.js +19 -2
  152. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  153. package/dist/modes/interactive/components/tool-group-tracker.d.ts +20 -3
  154. package/dist/modes/interactive/components/tool-group-tracker.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/tool-group-tracker.js +34 -7
  156. package/dist/modes/interactive/components/tool-group-tracker.js.map +1 -1
  157. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +14 -2
  158. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/transcript-block-clicks.js +23 -2
  160. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  161. package/dist/modes/interactive/interactive-agent-events.js +10 -2
  162. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  163. package/dist/modes/interactive/interactive-extension-runtime.d.ts +12 -1
  164. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  165. package/dist/modes/interactive/interactive-extension-runtime.js +37 -5
  166. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  167. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  168. package/dist/modes/interactive/interactive-input-handling.js +70 -46
  169. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  171. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  172. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  173. package/dist/modes/interactive/interactive-prompt-turn.js +17 -9
  174. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  175. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  176. package/dist/modes/interactive/interactive-queueing.js +2 -1
  177. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  178. package/dist/modes/interactive/interactive-render-chat.d.ts +18 -1
  179. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  180. package/dist/modes/interactive/interactive-render-chat.js +90 -10
  181. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  182. package/dist/modes/interactive/interactive-session-routing.js +2 -0
  183. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  184. package/dist/modes/interactive/interactive-task-projection.js +2 -2
  185. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  186. package/dist/modes/interactive/screen-hold.d.ts +41 -0
  187. package/dist/modes/interactive/screen-hold.d.ts.map +1 -0
  188. package/dist/modes/interactive/screen-hold.js +80 -0
  189. package/dist/modes/interactive/screen-hold.js.map +1 -0
  190. package/dist/modes/interactive/started-run-echo.d.ts +66 -0
  191. package/dist/modes/interactive/started-run-echo.d.ts.map +1 -0
  192. package/dist/modes/interactive/started-run-echo.js +75 -0
  193. package/dist/modes/interactive/started-run-echo.js.map +1 -0
  194. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -0
  195. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  196. package/dist/modes/interactive-engine/engine-custom-ui.js +25 -1
  197. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  198. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  199. package/dist/modes/interactive-engine/engine-quit-intent.js +3 -0
  200. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  201. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  202. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  203. package/dist/modes/interactive-engine/protocol.js +7 -1
  204. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  205. package/dist/modes/interactive-engine/remote-component.d.ts +10 -2
  206. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  207. package/dist/modes/interactive-engine/remote-component.js +19 -2
  208. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  209. package/dist/modes/interactive-engine/remote-renderer.d.ts +10 -0
  210. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  211. package/dist/modes/interactive-engine/remote-renderer.js +24 -4
  212. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  213. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts +50 -0
  214. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts.map +1 -0
  215. package/dist/modes/interactive-engine/transcript-frame-layout.js +95 -0
  216. package/dist/modes/interactive-engine/transcript-frame-layout.js.map +1 -0
  217. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  218. package/dist/modes/rpc/agent-panel-bridge.js +16 -0
  219. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  220. package/dist/modes/rpc/agent-view-engine-registry.d.ts.map +1 -1
  221. package/dist/modes/rpc/agent-view-engine-registry.js +36 -1
  222. package/dist/modes/rpc/agent-view-engine-registry.js.map +1 -1
  223. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  224. package/dist/modes/rpc/agent-view-rpc-panel.js +5 -1
  225. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  226. package/dist/modes/rpc/task-ui-bridge.js +1 -1
  227. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  228. package/docs/background-tasks.md +1 -1
  229. package/docs/development.md +2 -0
  230. package/docs/extensions/authoring.md +1 -1
  231. package/docs/keybindings.md +2 -2
  232. package/docs/storage.md +1 -0
  233. package/npm-shrinkwrap.json +49 -49
  234. package/package.json +6 -6
@@ -16,6 +16,8 @@ export declare class CustomEntryComponent extends Container {
16
16
  /** An entry that draws anything expands on a click, as Ctrl+O expands it; its renderer decides what that shows. */
17
17
  get expandsOnClick(): boolean;
18
18
  isExpanded(): boolean;
19
+ /** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */
20
+ render(width: number): string[];
19
21
  /** Every row of the entry, under the blank row it leads with. */
20
22
  clickArea(width: number): RowRange | undefined;
21
23
  setExpanded(expanded: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-entry.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,SAAS,EAAgB,MAAM,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AO,EAAa,KAAK,QAAQ,EAAoC,MAAM,8BAA8B,CAAC;AAE1G,2DAA2D;AAC3D,qBAAa,oBAAqB,SAAQ,SAAS;IAClD,QAAQ,CAAC,8BAA8B,QAAQ;IAC/C,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IACD,OAAO,CAAC,eAAe,CAAC,CAAY;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,YAAY,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,SAAI,EAO9E;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,mHAAmH;IACnH,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,uGAAuG;IAC9F,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvC;IAED,iEAAiE;IACjE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAI7C;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAInC;IAED,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGpC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,CAAC,OAAO;CAiBf"}
@@ -2,7 +2,7 @@ import { Box, Container, Spacer, Text } from "@bastani/atomic-tui";
2
2
  import { theme } from "../theme/theme.js";
3
3
  import { keyHint, keyText } from "./keybinding-hints.js";
4
4
  import { declaresHistoryReplayable } from "./renderer-disposal.js";
5
- import { rowsFrom, setRendererClickTarget } from "./transcript-block-clicks.js";
5
+ import { blockRows, rowsFrom, setRendererClickTarget } from "./transcript-block-clicks.js";
6
6
  /** Renders an extension-owned persistent session entry. */
7
7
  export class CustomEntryComponent extends Container {
8
8
  selectionTextMayChangeOnReplay = true;
@@ -32,6 +32,10 @@ export class CustomEntryComponent extends Container {
32
32
  isExpanded() {
33
33
  return this.expanded;
34
34
  }
35
+ /** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */
36
+ render(width) {
37
+ return blockRows(super.render(width));
38
+ }
35
39
  /** Every row of the entry, under the blank row it leads with. */
36
40
  clickArea(width) {
37
41
  const [spacer] = this.children;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-entry.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAiB,QAAQ,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE/F,2DAA2D;AAC3D,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACzC,8BAA8B,GAAG,IAAI,CAAC;IAC/C,IAAI,iBAAiB;QACpB,OAAO,yBAAyB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxD,CAAC;IACO,eAAe,CAAa;IAC5B,QAAQ,GAAG,KAAK,CAAC;IACjB,SAAS,CAAS;IAET,KAAK,CAAuB;IAC5B,QAAQ,CAAgB;IAEzC,YAAY,KAA2B,EAAE,QAAuB,EAAE,SAAS,GAAG,CAAC;QAC9E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,sBAAsB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAA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,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QAC7F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC;YACpF,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,sBAAsB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1G,SAAS,GAAG,GAAG,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import type { Component } from \"@bastani/atomic-tui\";\nimport { Box, Container, Spacer, Text } from \"@bastani/atomic-tui\";\nimport type { EntryRenderer } from \"../../../core/extensions/types.ts\";\nimport type { CustomEntry } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { keyHint, keyText } from \"./keybinding-hints.js\";\nimport { declaresHistoryReplayable } from \"./renderer-disposal.js\";\nimport { type RowRange, rowsFrom, setRendererClickTarget } from \"./transcript-block-clicks.ts\";\n\n/** Renders an extension-owned persistent session entry. */\nexport class CustomEntryComponent extends Container {\n\treadonly selectionTextMayChangeOnReplay = true;\n\tget historyReplayable(): boolean {\n\t\treturn declaresHistoryReplayable(this.customComponent);\n\t}\n\tprivate customComponent?: Component;\n\tprivate expanded = false;\n\tprivate outputPad: number;\n\n\tprivate readonly entry: CustomEntry<unknown>;\n\tprivate readonly renderer: EntryRenderer;\n\n\tconstructor(entry: CustomEntry<unknown>, renderer: EntryRenderer, outputPad = 1) {\n\t\tsuper();\n\t\tthis.entry = entry;\n\t\tthis.renderer = renderer;\n\t\tsetRendererClickTarget(this, { container: this, top: 0, firstRow: 1 });\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\thasContent(): boolean {\n\t\treturn this.customComponent !== undefined;\n\t}\n\n\t/** An entry that draws anything expands on a click, as Ctrl+O expands it; its renderer decides what that shows. */\n\tget expandsOnClick(): boolean {\n\t\treturn this.customComponent !== undefined;\n\t}\n\n\tisExpanded(): boolean {\n\t\treturn this.expanded;\n\t}\n\n\t/** Every row of the entry, under the blank row it leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\tconst [spacer] = this.children;\n\t\tif (this.customComponent === undefined || spacer === undefined) return undefined;\n\t\treturn rowsFrom(spacer.render(width).length, this.render(width).length);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.expanded === expanded) return;\n\t\tthis.expanded = expanded;\n\t\tthis.rebuild();\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.clear();\n\t\tthis.customComponent = undefined;\n\t\tlet component: Component | undefined;\n\t\ttry {\n\t\t\tcomponent = this.renderer(this.entry, { expanded: this.expanded, keyText, keyHint }, theme);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst box = new Box(this.outputPad, 1, (text) => theme.bg(\"customMessageBg\", text));\n\t\t\tbox.addChild(new Text(theme.fg(\"error\", `[${this.entry.customType}] renderer failed: ${message}`), 0, 0));\n\t\t\tcomponent = box;\n\t\t}\n\t\tif (!component) return;\n\t\tthis.customComponent = component;\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(component);\n\t}\n}\n"]}
1
+ {"version":3,"file":"custom-entry.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAiB,QAAQ,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE1G,2DAA2D;AAC3D,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACzC,8BAA8B,GAAG,IAAI,CAAC;IAC/C,IAAI,iBAAiB;QACpB,OAAO,yBAAyB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxD,CAAC;IACO,eAAe,CAAa;IAC5B,QAAQ,GAAG,KAAK,CAAC;IACjB,SAAS,CAAS;IAET,KAAK,CAAuB;IAC5B,QAAQ,CAAgB;IAEzC,YAAY,KAA2B,EAAE,QAAuB,EAAE,SAAS,GAAG,CAAC;QAC9E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,sBAAsB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE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,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,SAAgC,CAAC;QACrC,IAAI,CAAC;YACJ,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QAC7F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC;YACpF,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,sBAAsB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1G,SAAS,GAAG,GAAG,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import type { Component } from \"@bastani/atomic-tui\";\nimport { Box, Container, Spacer, Text } from \"@bastani/atomic-tui\";\nimport type { EntryRenderer } from \"../../../core/extensions/types.ts\";\nimport type { CustomEntry } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { keyHint, keyText } from \"./keybinding-hints.js\";\nimport { declaresHistoryReplayable } from \"./renderer-disposal.js\";\nimport { blockRows, type RowRange, rowsFrom, setRendererClickTarget } from \"./transcript-block-clicks.ts\";\n\n/** Renders an extension-owned persistent session entry. */\nexport class CustomEntryComponent extends Container {\n\treadonly selectionTextMayChangeOnReplay = true;\n\tget historyReplayable(): boolean {\n\t\treturn declaresHistoryReplayable(this.customComponent);\n\t}\n\tprivate customComponent?: Component;\n\tprivate expanded = false;\n\tprivate outputPad: number;\n\n\tprivate readonly entry: CustomEntry<unknown>;\n\tprivate readonly renderer: EntryRenderer;\n\n\tconstructor(entry: CustomEntry<unknown>, renderer: EntryRenderer, outputPad = 1) {\n\t\tsuper();\n\t\tthis.entry = entry;\n\t\tthis.renderer = renderer;\n\t\tsetRendererClickTarget(this, { container: this, top: 0, firstRow: 1 });\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\thasContent(): boolean {\n\t\treturn this.customComponent !== undefined;\n\t}\n\n\t/** An entry that draws anything expands on a click, as Ctrl+O expands it; its renderer decides what that shows. */\n\tget expandsOnClick(): boolean {\n\t\treturn this.customComponent !== undefined;\n\t}\n\n\tisExpanded(): boolean {\n\t\treturn this.expanded;\n\t}\n\n\t/** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */\n\toverride render(width: number): string[] {\n\t\treturn blockRows(super.render(width));\n\t}\n\n\t/** Every row of the entry, under the blank row it leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\tconst [spacer] = this.children;\n\t\tif (this.customComponent === undefined || spacer === undefined) return undefined;\n\t\treturn rowsFrom(spacer.render(width).length, this.render(width).length);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.expanded === expanded) return;\n\t\tthis.expanded = expanded;\n\t\tthis.rebuild();\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.clear();\n\t\tthis.customComponent = undefined;\n\t\tlet component: Component | undefined;\n\t\ttry {\n\t\t\tcomponent = this.renderer(this.entry, { expanded: this.expanded, keyText, keyHint }, theme);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst box = new Box(this.outputPad, 1, (text) => theme.bg(\"customMessageBg\", text));\n\t\t\tbox.addChild(new Text(theme.fg(\"error\", `[${this.entry.customType}] renderer failed: ${message}`), 0, 0));\n\t\t\tcomponent = box;\n\t\t}\n\t\tif (!component) return;\n\t\tthis.customComponent = component;\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(component);\n\t}\n}\n"]}
@@ -32,6 +32,8 @@ export declare class CustomMessageComponent extends Container {
32
32
  */
33
33
  get expandsOnClick(): boolean;
34
34
  isExpanded(): boolean;
35
+ /** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */
36
+ render(width: number): string[];
35
37
  /** Every row of the card, under the blank row this message leads with. */
36
38
  clickArea(width: number): RowRange | undefined;
37
39
  setExpanded(expanded: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EAAyB,KAAK,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAGxG,OAAO,EAAE,KAAK,QAAQ,EAAoC,MAAM,8BAA8B,CAAC;AAa/F;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,QAAQ,CAAC,iBAAiB,QAAQ;IAClC,IAAI,iBA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AAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,4BAA4B,EAmBhD;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,uGAAuG;IAC9F,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvC;IAED,0EAA0E;IAC1E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAG7C;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAUnC;IAED,OAAO,IAAI,IAAI,CAUd;IAED,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAKpC;IAEQ,UAAU,IAAI,IAAI,CAI1B;IAED,OAAO,CAAC,OAAO;IAaf,OAAO,CAAC,YAAY;CA2HpB"}
@@ -9,7 +9,7 @@ import { declaresHistoryReplayable, disposeRenderer } from "./renderer-disposal.
9
9
  import { TaskCompletionMessage } from "./task-completion-message.js";
10
10
  import { heartbeatDetailsFrom, TaskHeartbeatMessage } from "./task-heartbeat-message.js";
11
11
  import { ToolBlock } from "./tool-block.js";
12
- import { rowsFrom, setRendererClickTarget } from "./transcript-block-clicks.js";
12
+ import { blockRows, rowsFrom, setRendererClickTarget } from "./transcript-block-clicks.js";
13
13
  /**
14
14
  * Type guard ensuring a value returned by an extension's custom renderer is a
15
15
  * real TUI Component (exposes a callable `render`). Extension renderer output is
@@ -73,6 +73,10 @@ export class CustomMessageComponent extends Container {
73
73
  isExpanded() {
74
74
  return this._expanded;
75
75
  }
76
+ /** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */
77
+ render(width) {
78
+ return blockRows(super.render(width));
79
+ }
76
80
  /** Every row of the card, under the blank row this message leads with. */
77
81
  clickArea(width) {
78
82
  if (this.spacer === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"custom-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-message.ts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,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,CACd;YACD,WAAW,EAAE,IAAI,CAAC,WAAW;SAC7B,CACD,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { TextContent } from \"@bastani/atomic-ai/compat\";\nimport type { Component } from \"@bastani/atomic-tui\";\nimport { Box, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@bastani/atomic-tui\";\nimport type { MarkdownTransformer, MessageRenderer } from \"../../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../../core/messages.ts\";\nimport { TASK_COMPLETION_MESSAGE_TYPE } from \"../../../core/tasks/completion.js\";\nimport { TASK_HEARTBEAT_MESSAGE_TYPE } from \"../../../core/tasks/heartbeat-notice.js\";\nimport { stripTerminalControls } from \"../../../utils/ansi.js\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\nimport { keyHint, keyText } from \"./keybinding-hints.js\";\nimport { createMarkdownTransform, hasExtensionMarkdownTransform } from \"./markdown-transform.ts\";\nimport { declaresHistoryReplayable, disposeRenderer } from \"./renderer-disposal.js\";\nimport { TaskCompletionMessage, type TaskCompletionMessageOptions } from \"./task-completion-message.js\";\nimport { heartbeatDetailsFrom, TaskHeartbeatMessage } from \"./task-heartbeat-message.js\";\nimport { ToolBlock } from \"./tool-block.ts\";\nimport { type RowRange, rowsFrom, setRendererClickTarget } from \"./transcript-block-clicks.ts\";\n\n/**\n * Type guard ensuring a value returned by an extension's custom renderer is a\n * real TUI Component (exposes a callable `render`). Extension renderer output is\n * untrusted at runtime: a renderer that returns a string or other non-Component\n * value would otherwise be added as a child and crash `Container.render()` with\n * \"child.render is not a function\".\n */\nfunction isRenderableComponent(value: unknown): value is Component {\n\treturn typeof value === \"object\" && value !== null && typeof (value as { render?: unknown }).render === \"function\";\n}\n\n/**\n * Component that renders a custom message entry from extensions.\n * Uses distinct styling to differentiate from user messages.\n */\nexport class CustomMessageComponent extends Container {\n\treadonly ownsLeadingSpacer = true;\n\tget historyReplayable(): boolean {\n\t\treturn !this.selectionTextMayChangeOnReplay || declaresHistoryReplayable(this.customComponent);\n\t}\n\tget selectionTextMayChangeOnReplay(): boolean {\n\t\treturn this.customRenderer !== undefined || hasExtensionMarkdownTransform(this.markdownTransformers);\n\t}\n\tprivate disposed = false;\n\tprivate message: CustomMessage<unknown>;\n\tprivate customRenderer?: MessageRenderer;\n\tprivate box: Box;\n\tprivate spacer?: Spacer;\n\tprivate customComponent?: Component;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate _expanded = false;\n\tprivate outputPad: number;\n\tprivate renderLatex: boolean;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate messageId?: string;\n\tprivate timestamp?: string;\n\tprivate completionOptions?: TaskCompletionMessageOptions;\n\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\tcustomRenderer?: MessageRenderer,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\toutputPad = 1,\n\t\trenderLatex = true,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t\tmessageId?: string,\n\t\ttimestamp?: string,\n\t\tcompletionOptions?: TaskCompletionMessageOptions,\n\t) {\n\t\tsuper();\n\t\tthis.message = message;\n\t\tthis.customRenderer = customRenderer;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.outputPad = outputPad;\n\t\tthis.renderLatex = renderLatex;\n\t\tthis.markdownTransformers = markdownTransformers;\n\t\tthis.messageId = messageId;\n\t\tthis.timestamp = timestamp;\n\t\tthis.completionOptions = completionOptions;\n\n\t\t// Create box with purple background (used for default rendering)\n\t\tthis.box = new Box(1, 1, (t) => theme.bg(\"customMessageBg\", t));\n\n\t\t// The leading spacer is mounted in rebuild() alongside actual content, so a\n\t\t// renderer that suppresses output (returns null) leaves no blank row.\n\t\tthis.rebuild();\n\t}\n\n\t/**\n\t * A message that draws anything expands on a click, as Ctrl+O expands it: its card or renderer decides what that\n\t * shows, and a card with nothing more to show stays as it is.\n\t */\n\tget expandsOnClick(): boolean {\n\t\treturn this.spacer !== undefined;\n\t}\n\n\tisExpanded(): boolean {\n\t\treturn this._expanded;\n\t}\n\n\t/** Every row of the card, under the blank row this message leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\tif (this.spacer === undefined) return undefined;\n\t\treturn rowsFrom(this.spacer.render(width).length, this.render(width).length);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.disposed) return;\n\t\tif (this._expanded !== expanded) {\n\t\t\tthis._expanded = expanded;\n\t\t\tif (this.customComponent instanceof TaskCompletionMessage) {\n\t\t\t\tthis.customComponent.setExpanded(expanded);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.rebuild();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tsetRendererClickTarget(this);\n\t\tdisposeRenderer(this.customComponent);\n\t\tthis.customComponent = undefined;\n\t\tthis.completionOptions = undefined;\n\t\tthis.customRenderer = undefined;\n\t\tthis.box.clear();\n\t\tthis.clear();\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tif (this.disposed) return;\n\t\tif (this.outputPad === outputPad) return;\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tif (this.disposed) return;\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tif (this.disposed) return;\n\t\tconst previous = this.customComponent;\n\t\tsetRendererClickTarget(this);\n\t\tthis.customComponent = undefined;\n\t\tif (previous) this.removeChild(previous);\n\t\ttry {\n\t\t\tthis.buildDisplay(previous);\n\t\t} finally {\n\t\t\tif (previous !== this.customComponent) disposeRenderer(previous);\n\t\t}\n\t}\n\n\tprivate buildDisplay(previous?: Component): void {\n\t\tif (this.spacer) {\n\t\t\tthis.removeChild(this.spacer);\n\t\t\tthis.spacer = undefined;\n\t\t}\n\t\tthis.removeChild(this.box);\n\t\tif (this.message.customType === TASK_COMPLETION_MESSAGE_TYPE) {\n\t\t\tconst card = TaskCompletionMessage.fromMessage(\n\t\t\t\tthis.message,\n\t\t\t\tthis._expanded,\n\t\t\t\tthis.completionOptions,\n\t\t\t\tTaskCompletionMessage.isCard(previous) ? previous : undefined,\n\t\t\t);\n\t\t\tif (card) {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = card;\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (this.message.customType === TASK_HEARTBEAT_MESSAGE_TYPE) {\n\t\t\tconst details = heartbeatDetailsFrom(this.message.details);\n\t\t\tif (details) {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = new TaskHeartbeatMessage(details, this._expanded, this.outputPad);\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Try custom renderer first - it handles its own styling\n\t\tif (this.customRenderer) {\n\t\t\ttry {\n\t\t\t\tconst component = this.customRenderer(\n\t\t\t\t\tthis.message,\n\t\t\t\t\t{\n\t\t\t\t\t\texpanded: this._expanded,\n\t\t\t\t\t\toutputPad: this.outputPad,\n\t\t\t\t\t\tcwd: this.completionOptions?.cwd,\n\t\t\t\t\t\tkeyText,\n\t\t\t\t\t\tkeyHint,\n\t\t\t\t\t},\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t\t// Explicit null = \"handled; render nothing\". Skip the leading spacer\n\t\t\t\t// and the default box entirely so the entry occupies zero rows.\n\t\t\t\tif (component === null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Only mount the result if it is a real Component. A non-Component,\n\t\t\t\t// non-null return (string, number, plain object, …) is ignored so we\n\t\t\t\t// fall through to the default rendering path instead of crashing\n\t\t\t\t// Container.render().\n\t\t\t\tif (isRenderableComponent(component)) {\n\t\t\t\t\t// Custom renderer provides its own styled component\n\t\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\t\tthis.customComponent = component;\n\t\t\t\t\tthis.addChild(component);\n\t\t\t\t\tsetRendererClickTarget(this, { container: this, top: 0, firstRow: 1 });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = new ToolBlock({\n\t\t\t\t\tstatus: \"failure\",\n\t\t\t\t\ttitle: \"Message renderer failed\",\n\t\t\t\t\toutputPad: this.outputPad,\n\t\t\t\t});\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Default rendering uses our box, preceded by the standard leading spacer.\n\t\tthis.spacer = new Spacer(1);\n\t\tthis.addChild(this.spacer);\n\t\tthis.addChild(this.box);\n\t\tthis.box.clear();\n\t\tthis.box.setPaddingX(this.outputPad);\n\n\t\t// Default rendering: label + content\n\t\tconst label = theme.fg(\"customMessageLabel\", `\\x1b[1m[${this.message.customType}]\\x1b[22m`);\n\t\tthis.box.addChild(new Text(label, 0, 0));\n\t\tthis.box.addChild(new Spacer(1));\n\n\t\t// Extract text content\n\t\tlet text: string;\n\t\tif (typeof this.message.content === \"string\") {\n\t\t\ttext = this.message.content;\n\t\t} else {\n\t\t\ttext = this.message.content\n\t\t\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\\n\");\n\t\t}\n\n\t\tthis.box.addChild(\n\t\t\t// Raw terminal sequences in the text must not reach the terminal; Atomic styles after parsing (#4889).\n\t\t\tnew Markdown(\n\t\t\t\tstripTerminalControls(text),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tthis.markdownTheme,\n\t\t\t\t{\n\t\t\t\t\tcolor: (text: string) => theme.fg(\"customMessageText\", text),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\"custom\",\n\t\t\t\t\t\t() => false,\n\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t),\n\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"custom-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/custom-message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAqC,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAiB,QAAQ,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE1G;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IA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C;iBAClD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ;QAChB,uGAAuG;QACvG,IAAI,QAAQ,CACX,qBAAqB,CAAC,IAAI,CAAC,EAC3B,CAAC,EACD,CAAC,EACD,IAAI,CAAC,aAAa,EAClB;YACC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,EAAE,IAAI,CAAC;SAC5D,EACD;YACC,SAAS,EAAE,uBAAuB,CACjC,QAAQ,EACR,GAAG,EAAE,CAAC,KAAK,EACX,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,CACd;YACD,WAAW,EAAE,IAAI,CAAC,WAAW;SAC7B,CACD,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { TextContent } from \"@bastani/atomic-ai/compat\";\nimport type { Component } from \"@bastani/atomic-tui\";\nimport { Box, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@bastani/atomic-tui\";\nimport type { MarkdownTransformer, MessageRenderer } from \"../../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../../core/messages.ts\";\nimport { TASK_COMPLETION_MESSAGE_TYPE } from \"../../../core/tasks/completion.js\";\nimport { TASK_HEARTBEAT_MESSAGE_TYPE } from \"../../../core/tasks/heartbeat-notice.js\";\nimport { stripTerminalControls } from \"../../../utils/ansi.js\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\nimport { keyHint, keyText } from \"./keybinding-hints.js\";\nimport { createMarkdownTransform, hasExtensionMarkdownTransform } from \"./markdown-transform.ts\";\nimport { declaresHistoryReplayable, disposeRenderer } from \"./renderer-disposal.js\";\nimport { TaskCompletionMessage, type TaskCompletionMessageOptions } from \"./task-completion-message.js\";\nimport { heartbeatDetailsFrom, TaskHeartbeatMessage } from \"./task-heartbeat-message.js\";\nimport { ToolBlock } from \"./tool-block.ts\";\nimport { blockRows, type RowRange, rowsFrom, setRendererClickTarget } from \"./transcript-block-clicks.ts\";\n\n/**\n * Type guard ensuring a value returned by an extension's custom renderer is a\n * real TUI Component (exposes a callable `render`). Extension renderer output is\n * untrusted at runtime: a renderer that returns a string or other non-Component\n * value would otherwise be added as a child and crash `Container.render()` with\n * \"child.render is not a function\".\n */\nfunction isRenderableComponent(value: unknown): value is Component {\n\treturn typeof value === \"object\" && value !== null && typeof (value as { render?: unknown }).render === \"function\";\n}\n\n/**\n * Component that renders a custom message entry from extensions.\n * Uses distinct styling to differentiate from user messages.\n */\nexport class CustomMessageComponent extends Container {\n\treadonly ownsLeadingSpacer = true;\n\tget historyReplayable(): boolean {\n\t\treturn !this.selectionTextMayChangeOnReplay || declaresHistoryReplayable(this.customComponent);\n\t}\n\tget selectionTextMayChangeOnReplay(): boolean {\n\t\treturn this.customRenderer !== undefined || hasExtensionMarkdownTransform(this.markdownTransformers);\n\t}\n\tprivate disposed = false;\n\tprivate message: CustomMessage<unknown>;\n\tprivate customRenderer?: MessageRenderer;\n\tprivate box: Box;\n\tprivate spacer?: Spacer;\n\tprivate customComponent?: Component;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate _expanded = false;\n\tprivate outputPad: number;\n\tprivate renderLatex: boolean;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate messageId?: string;\n\tprivate timestamp?: string;\n\tprivate completionOptions?: TaskCompletionMessageOptions;\n\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\tcustomRenderer?: MessageRenderer,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\toutputPad = 1,\n\t\trenderLatex = true,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t\tmessageId?: string,\n\t\ttimestamp?: string,\n\t\tcompletionOptions?: TaskCompletionMessageOptions,\n\t) {\n\t\tsuper();\n\t\tthis.message = message;\n\t\tthis.customRenderer = customRenderer;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.outputPad = outputPad;\n\t\tthis.renderLatex = renderLatex;\n\t\tthis.markdownTransformers = markdownTransformers;\n\t\tthis.messageId = messageId;\n\t\tthis.timestamp = timestamp;\n\t\tthis.completionOptions = completionOptions;\n\n\t\t// Create box with purple background (used for default rendering)\n\t\tthis.box = new Box(1, 1, (t) => theme.bg(\"customMessageBg\", t));\n\n\t\t// The leading spacer is mounted in rebuild() alongside actual content, so a\n\t\t// renderer that suppresses output (returns null) leaves no blank row.\n\t\tthis.rebuild();\n\t}\n\n\t/**\n\t * A message that draws anything expands on a click, as Ctrl+O expands it: its card or renderer decides what that\n\t * shows, and a card with nothing more to show stays as it is.\n\t */\n\tget expandsOnClick(): boolean {\n\t\treturn this.spacer !== undefined;\n\t}\n\n\tisExpanded(): boolean {\n\t\treturn this._expanded;\n\t}\n\n\t/** Its rows: an expand hint in them is part of the block, which a click on it expands or collapses. */\n\toverride render(width: number): string[] {\n\t\treturn blockRows(super.render(width));\n\t}\n\n\t/** Every row of the card, under the blank row this message leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\tif (this.spacer === undefined) return undefined;\n\t\treturn rowsFrom(this.spacer.render(width).length, this.render(width).length);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tif (this.disposed) return;\n\t\tif (this._expanded !== expanded) {\n\t\t\tthis._expanded = expanded;\n\t\t\tif (this.customComponent instanceof TaskCompletionMessage) {\n\t\t\t\tthis.customComponent.setExpanded(expanded);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.rebuild();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tsetRendererClickTarget(this);\n\t\tdisposeRenderer(this.customComponent);\n\t\tthis.customComponent = undefined;\n\t\tthis.completionOptions = undefined;\n\t\tthis.customRenderer = undefined;\n\t\tthis.box.clear();\n\t\tthis.clear();\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tif (this.disposed) return;\n\t\tif (this.outputPad === outputPad) return;\n\t\tthis.outputPad = outputPad;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tif (this.disposed) return;\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tif (this.disposed) return;\n\t\tconst previous = this.customComponent;\n\t\tsetRendererClickTarget(this);\n\t\tthis.customComponent = undefined;\n\t\tif (previous) this.removeChild(previous);\n\t\ttry {\n\t\t\tthis.buildDisplay(previous);\n\t\t} finally {\n\t\t\tif (previous !== this.customComponent) disposeRenderer(previous);\n\t\t}\n\t}\n\n\tprivate buildDisplay(previous?: Component): void {\n\t\tif (this.spacer) {\n\t\t\tthis.removeChild(this.spacer);\n\t\t\tthis.spacer = undefined;\n\t\t}\n\t\tthis.removeChild(this.box);\n\t\tif (this.message.customType === TASK_COMPLETION_MESSAGE_TYPE) {\n\t\t\tconst card = TaskCompletionMessage.fromMessage(\n\t\t\t\tthis.message,\n\t\t\t\tthis._expanded,\n\t\t\t\tthis.completionOptions,\n\t\t\t\tTaskCompletionMessage.isCard(previous) ? previous : undefined,\n\t\t\t);\n\t\t\tif (card) {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = card;\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (this.message.customType === TASK_HEARTBEAT_MESSAGE_TYPE) {\n\t\t\tconst details = heartbeatDetailsFrom(this.message.details);\n\t\t\tif (details) {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = new TaskHeartbeatMessage(details, this._expanded, this.outputPad);\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Try custom renderer first - it handles its own styling\n\t\tif (this.customRenderer) {\n\t\t\ttry {\n\t\t\t\tconst component = this.customRenderer(\n\t\t\t\t\tthis.message,\n\t\t\t\t\t{\n\t\t\t\t\t\texpanded: this._expanded,\n\t\t\t\t\t\toutputPad: this.outputPad,\n\t\t\t\t\t\tcwd: this.completionOptions?.cwd,\n\t\t\t\t\t\tkeyText,\n\t\t\t\t\t\tkeyHint,\n\t\t\t\t\t},\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t\t// Explicit null = \"handled; render nothing\". Skip the leading spacer\n\t\t\t\t// and the default box entirely so the entry occupies zero rows.\n\t\t\t\tif (component === null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Only mount the result if it is a real Component. A non-Component,\n\t\t\t\t// non-null return (string, number, plain object, …) is ignored so we\n\t\t\t\t// fall through to the default rendering path instead of crashing\n\t\t\t\t// Container.render().\n\t\t\t\tif (isRenderableComponent(component)) {\n\t\t\t\t\t// Custom renderer provides its own styled component\n\t\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\t\tthis.customComponent = component;\n\t\t\t\t\tthis.addChild(component);\n\t\t\t\t\tsetRendererClickTarget(this, { container: this, top: 0, firstRow: 1 });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tthis.spacer = new Spacer(1);\n\t\t\t\tthis.customComponent = new ToolBlock({\n\t\t\t\t\tstatus: \"failure\",\n\t\t\t\t\ttitle: \"Message renderer failed\",\n\t\t\t\t\toutputPad: this.outputPad,\n\t\t\t\t});\n\t\t\t\tthis.addChild(this.spacer);\n\t\t\t\tthis.addChild(this.customComponent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Default rendering uses our box, preceded by the standard leading spacer.\n\t\tthis.spacer = new Spacer(1);\n\t\tthis.addChild(this.spacer);\n\t\tthis.addChild(this.box);\n\t\tthis.box.clear();\n\t\tthis.box.setPaddingX(this.outputPad);\n\n\t\t// Default rendering: label + content\n\t\tconst label = theme.fg(\"customMessageLabel\", `\\x1b[1m[${this.message.customType}]\\x1b[22m`);\n\t\tthis.box.addChild(new Text(label, 0, 0));\n\t\tthis.box.addChild(new Spacer(1));\n\n\t\t// Extract text content\n\t\tlet text: string;\n\t\tif (typeof this.message.content === \"string\") {\n\t\t\ttext = this.message.content;\n\t\t} else {\n\t\t\ttext = this.message.content\n\t\t\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\\n\");\n\t\t}\n\n\t\tthis.box.addChild(\n\t\t\t// Raw terminal sequences in the text must not reach the terminal; Atomic styles after parsing (#4889).\n\t\t\tnew Markdown(\n\t\t\t\tstripTerminalControls(text),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tthis.markdownTheme,\n\t\t\t\t{\n\t\t\t\t\tcolor: (text: string) => theme.fg(\"customMessageText\", text),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\"custom\",\n\t\t\t\t\t\t() => false,\n\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t),\n\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * When a row shows its model in the model column of the agent panel and /tasks, and how wide that column stays while
3
+ * one of those views is open.
4
+ *
5
+ * A subagent reports its model and its reasoning level apart, the level a moment after the model. Showing each as it
6
+ * arrives would widen the column twice and move every row's task twice. Instead, a row whose model becomes known while
7
+ * the view shows it waits for its level, at most `MODEL_LEVEL_WAIT_MS`, and then shows both at once. A row first seen
8
+ * with its model already known, a finished row, and a model without reasoning levels show the model at once, as
9
+ * before. The column never narrows while it still fits. It is measured again when the width changes or the view is
10
+ * opened again.
11
+ */
12
+ /** The longest a row whose model just became known waits for its reasoning level before it shows the model alone. */
13
+ export declare const MODEL_LEVEL_WAIT_MS = 1000;
14
+ /**
15
+ * A row's model cell: no model reported yet; its model `model` reported and its level awaited since `since` (on the
16
+ * `performance.now()` clock); or shown, from then on exactly as the row reports it until it reports no model.
17
+ */
18
+ export type ModelCell = {
19
+ readonly kind: "unknown";
20
+ } | {
21
+ readonly kind: "waiting";
22
+ readonly since: number;
23
+ readonly model: string;
24
+ } | {
25
+ readonly kind: "shown";
26
+ };
27
+ /** What a row reports now. */
28
+ export interface ModelCellReport {
29
+ /** The model it names, undefined for none. */
30
+ readonly model: string | undefined;
31
+ /** Nothing more is coming for it: its level is known, or the row finished. */
32
+ readonly settled: boolean;
33
+ /**
34
+ * Whether its model has no reasoning levels. Asked only when the row's model becomes known, or changes, while it
35
+ * waits, since the answer can take a lookup in the session's model registry.
36
+ */
37
+ readonly levelless: () => boolean;
38
+ }
39
+ /**
40
+ * The cell after a paint sees `report` at `now`. `cell` is undefined for a row the view has not painted yet. A row
41
+ * the view already listed, as on its first paint or when it scrolls into view, shows a known model at once, as it
42
+ * always did; a row `added` to the list since the view last painted is new, and its model waits for its level like
43
+ * one that becomes known.
44
+ */
45
+ export declare function nextModelCell(cell: ModelCell | undefined, report: ModelCellReport, now: number, added: boolean): ModelCell;
46
+ /** One open view's model cells and column width. */
47
+ export declare class ModelColumn {
48
+ private readonly cells;
49
+ /**
50
+ * The deadlines of the waiting rows painted last, by row id. A waiting row out of view needs no timer: its next
51
+ * paint shows its model if its time is up.
52
+ */
53
+ private waiting;
54
+ /**
55
+ * The list the view last painted from; undefined before its first paint, and after it was too narrow for the
56
+ * column. It is read only when it changes, and then only as far as a paint needs it.
57
+ */
58
+ private roster;
59
+ private heldWidth;
60
+ /** The widest column this view painted at `heldWidth`, and the one it painted last. */
61
+ private held;
62
+ private last;
63
+ private timer;
64
+ private timerAt;
65
+ private readonly onExpire;
66
+ /** `onExpire` repaints the view once a waiting row's time is up, so it shows its model without another change. */
67
+ constructor(onExpire?: () => void);
68
+ /**
69
+ * Moves the cell of each row painted now on by what it reports and returns the ids of the rows that show their
70
+ * model. `listed` is every row of the view, painted or not: rows scrolled out of view keep their cells. Only when it
71
+ * is another list than last time is any of it read: the last list, to tell a row added since from one scrolled into
72
+ * view, and the new one, to forget the kept cells of rows no longer in it. A paint otherwise costs what its painted
73
+ * rows cost.
74
+ */
75
+ paint(reports: Iterable<readonly [id: string, report: ModelCellReport]>, listed: readonly {
76
+ readonly id: string;
77
+ }[]): ReadonlySet<string>;
78
+ /** Forgets every cell, as when the view is too narrow for the column: its next paint is like a first one. */
79
+ forget(): void;
80
+ /**
81
+ * The column width to paint at `width`, for shown labels at most `measured` cells wide; `fits(column)` says whether
82
+ * a column that wide leaves every painted row its whole right column and some of its task. It is `measured`, or the
83
+ * widest column this view painted at this width that still fits, else the one it painted last if that fits: the
84
+ * column does not narrow while it fits. It is 0 when even the widest label the rows report, `widest`, shown or still
85
+ * waiting, does not fit, as labels are never cut to fit: there is then no column, exactly as without waiting.
86
+ */
87
+ column(width: number, measured: number, fits: (column: number) => boolean, widest?: number): number;
88
+ /** Forgets every cell and the column width, as a view opened again does. */
89
+ reset(): void;
90
+ dispose(): void;
91
+ private arm;
92
+ private disarm;
93
+ /** The rows whose wait ends by `deadline` show their model, and the view repaints. */
94
+ private expire;
95
+ }
96
+ //# sourceMappingURL=model-column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-column.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qHAAqH;AACrH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;I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AM,IAAI,IAAI,CAKb;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,EAAE,MAAM,SAAW,GAAG,MAAM,CAepG;IAED,4EAA4E;IAC5E,KAAK,IAAI,IAAI,CAKZ;IAED,OAAO,IAAI,IAAI,CAEd;IAED,OAAO,CAAC,GAAG;IAaX,OAAO,CAAC,MAAM;IAMd,sFAAsF;IACtF,OAAO,CAAC,MAAM;CAed"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * When a row shows its model in the model column of the agent panel and /tasks, and how wide that column stays while
3
+ * one of those views is open.
4
+ *
5
+ * A subagent reports its model and its reasoning level apart, the level a moment after the model. Showing each as it
6
+ * arrives would widen the column twice and move every row's task twice. Instead, a row whose model becomes known while
7
+ * the view shows it waits for its level, at most `MODEL_LEVEL_WAIT_MS`, and then shows both at once. A row first seen
8
+ * with its model already known, a finished row, and a model without reasoning levels show the model at once, as
9
+ * before. The column never narrows while it still fits. It is measured again when the width changes or the view is
10
+ * opened again.
11
+ */
12
+ /** The longest a row whose model just became known waits for its reasoning level before it shows the model alone. */
13
+ export const MODEL_LEVEL_WAIT_MS = 1000;
14
+ const UNKNOWN = { kind: "unknown" };
15
+ const SHOWN = { kind: "shown" };
16
+ /**
17
+ * The cell after a paint sees `report` at `now`. `cell` is undefined for a row the view has not painted yet. A row
18
+ * the view already listed, as on its first paint or when it scrolls into view, shows a known model at once, as it
19
+ * always did; a row `added` to the list since the view last painted is new, and its model waits for its level like
20
+ * one that becomes known.
21
+ */
22
+ export function nextModelCell(cell, report, now, added) {
23
+ const model = report.model;
24
+ if (cell === undefined) {
25
+ if (!added)
26
+ return model === undefined ? UNKNOWN : SHOWN;
27
+ cell = UNKNOWN;
28
+ }
29
+ switch (cell.kind) {
30
+ case "shown":
31
+ return model === undefined ? UNKNOWN : cell;
32
+ case "unknown":
33
+ if (model === undefined)
34
+ return cell;
35
+ return report.settled || report.levelless() ? SHOWN : { kind: "waiting", since: now, model };
36
+ case "waiting":
37
+ if (model === undefined)
38
+ return UNKNOWN;
39
+ if (report.settled || now - cell.since >= MODEL_LEVEL_WAIT_MS)
40
+ return SHOWN;
41
+ // A switch to another model, as on a fallback, keeps the wait's start; a model without levels ends it.
42
+ if (model === cell.model)
43
+ return cell;
44
+ return report.levelless() ? SHOWN : { kind: "waiting", since: cell.since, model };
45
+ }
46
+ }
47
+ /** One open view's model cells and column width. */
48
+ export class ModelColumn {
49
+ cells = new Map();
50
+ /**
51
+ * The deadlines of the waiting rows painted last, by row id. A waiting row out of view needs no timer: its next
52
+ * paint shows its model if its time is up.
53
+ */
54
+ waiting = new Map();
55
+ /**
56
+ * The list the view last painted from; undefined before its first paint, and after it was too narrow for the
57
+ * column. It is read only when it changes, and then only as far as a paint needs it.
58
+ */
59
+ roster;
60
+ heldWidth = -1;
61
+ /** The widest column this view painted at `heldWidth`, and the one it painted last. */
62
+ held = 0;
63
+ last = 0;
64
+ timer;
65
+ timerAt = Number.POSITIVE_INFINITY;
66
+ onExpire;
67
+ /** `onExpire` repaints the view once a waiting row's time is up, so it shows its model without another change. */
68
+ constructor(onExpire) {
69
+ this.onExpire = onExpire;
70
+ }
71
+ /**
72
+ * Moves the cell of each row painted now on by what it reports and returns the ids of the rows that show their
73
+ * model. `listed` is every row of the view, painted or not: rows scrolled out of view keep their cells. Only when it
74
+ * is another list than last time is any of it read: the last list, to tell a row added since from one scrolled into
75
+ * view, and the new one, to forget the kept cells of rows no longer in it. A paint otherwise costs what its painted
76
+ * rows cost.
77
+ */
78
+ paint(reports, listed) {
79
+ const now = performance.now();
80
+ const previous = this.roster;
81
+ let previousIds;
82
+ const added = (id) => {
83
+ if (previous === undefined || previous === listed)
84
+ return false;
85
+ if (previousIds === undefined) {
86
+ previousIds = new Set();
87
+ for (const row of previous)
88
+ previousIds.add(row.id);
89
+ }
90
+ return !previousIds.has(id);
91
+ };
92
+ const painted = new Set();
93
+ const shown = new Set();
94
+ const waiting = new Map();
95
+ let earliest = Number.POSITIVE_INFINITY;
96
+ for (const [id, report] of reports) {
97
+ const before = this.cells.get(id);
98
+ const cell = nextModelCell(before, report, now, before === undefined && added(id));
99
+ painted.add(id);
100
+ this.cells.set(id, cell);
101
+ if (cell.kind === "shown")
102
+ shown.add(id);
103
+ else if (cell.kind === "waiting") {
104
+ const due = cell.since + MODEL_LEVEL_WAIT_MS;
105
+ waiting.set(id, due);
106
+ earliest = Math.min(earliest, due);
107
+ }
108
+ }
109
+ this.waiting = waiting;
110
+ if (listed !== previous) {
111
+ this.roster = listed;
112
+ if (this.cells.size > painted.size) {
113
+ const ids = new Set();
114
+ for (const row of listed)
115
+ ids.add(row.id);
116
+ for (const id of this.cells.keys())
117
+ if (!painted.has(id) && !ids.has(id))
118
+ this.cells.delete(id);
119
+ }
120
+ }
121
+ this.arm(earliest);
122
+ return shown;
123
+ }
124
+ /** Forgets every cell, as when the view is too narrow for the column: its next paint is like a first one. */
125
+ forget() {
126
+ this.cells.clear();
127
+ this.waiting.clear();
128
+ this.roster = undefined;
129
+ this.disarm();
130
+ }
131
+ /**
132
+ * The column width to paint at `width`, for shown labels at most `measured` cells wide; `fits(column)` says whether
133
+ * a column that wide leaves every painted row its whole right column and some of its task. It is `measured`, or the
134
+ * widest column this view painted at this width that still fits, else the one it painted last if that fits: the
135
+ * column does not narrow while it fits. It is 0 when even the widest label the rows report, `widest`, shown or still
136
+ * waiting, does not fit, as labels are never cut to fit: there is then no column, exactly as without waiting.
137
+ */
138
+ column(width, measured, fits, widest = measured) {
139
+ if (width !== this.heldWidth) {
140
+ this.heldWidth = width;
141
+ this.held = 0;
142
+ this.last = 0;
143
+ }
144
+ let column = 0;
145
+ if (widest === 0 || fits(widest)) {
146
+ column = measured;
147
+ if (this.held > column && fits(this.held))
148
+ column = this.held;
149
+ else if (this.last > column && fits(this.last))
150
+ column = this.last;
151
+ }
152
+ if (column > this.held)
153
+ this.held = column;
154
+ this.last = column;
155
+ return column;
156
+ }
157
+ /** Forgets every cell and the column width, as a view opened again does. */
158
+ reset() {
159
+ this.forget();
160
+ this.heldWidth = -1;
161
+ this.held = 0;
162
+ this.last = 0;
163
+ }
164
+ dispose() {
165
+ this.reset();
166
+ }
167
+ arm(deadline) {
168
+ if (this.onExpire === undefined)
169
+ return;
170
+ if (deadline === Number.POSITIVE_INFINITY) {
171
+ this.disarm();
172
+ return;
173
+ }
174
+ if (this.timer !== undefined && this.timerAt === deadline)
175
+ return;
176
+ this.disarm();
177
+ this.timerAt = deadline;
178
+ this.timer = setTimeout(() => this.expire(deadline), Math.max(0, deadline - performance.now()));
179
+ this.timer.unref?.();
180
+ }
181
+ disarm() {
182
+ if (this.timer !== undefined)
183
+ clearTimeout(this.timer);
184
+ this.timer = undefined;
185
+ this.timerAt = Number.POSITIVE_INFINITY;
186
+ }
187
+ /** The rows whose wait ends by `deadline` show their model, and the view repaints. */
188
+ expire(deadline) {
189
+ this.timer = undefined;
190
+ this.timerAt = Number.POSITIVE_INFINITY;
191
+ let earliest = Number.POSITIVE_INFINITY;
192
+ let expired = false;
193
+ for (const [id, due] of this.waiting) {
194
+ if (due <= deadline) {
195
+ this.cells.set(id, SHOWN);
196
+ this.waiting.delete(id);
197
+ expired = true;
198
+ }
199
+ else
200
+ earliest = Math.min(earliest, due);
201
+ }
202
+ this.arm(earliest);
203
+ if (expired)
204
+ this.onExpire?.();
205
+ }
206
+ }
207
+ //# sourceMappingURL=model-column.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-column.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qHAAqH;AACrH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAwBxC,MAAM,OAAO,GAAc,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC/C,MAAM,KAAK,GAAc,EAAE,IAAI,EAAE,OAA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AAC,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACxC,IAAI,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACxC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtC,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACxB,OAAO,GAAG,IAAI,CAAC;YAChB,CAAC;;gBAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnB,IAAI,OAAO;YAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * When a row shows its model in the model column of the agent panel and /tasks, and how wide that column stays while\n * one of those views is open.\n *\n * A subagent reports its model and its reasoning level apart, the level a moment after the model. Showing each as it\n * arrives would widen the column twice and move every row's task twice. Instead, a row whose model becomes known while\n * the view shows it waits for its level, at most `MODEL_LEVEL_WAIT_MS`, and then shows both at once. A row first seen\n * with its model already known, a finished row, and a model without reasoning levels show the model at once, as\n * before. The column never narrows while it still fits. It is measured again when the width changes or the view is\n * opened again.\n */\n\n/** The longest a row whose model just became known waits for its reasoning level before it shows the model alone. */\nexport const MODEL_LEVEL_WAIT_MS = 1000;\n\n/**\n * A row's model cell: no model reported yet; its model `model` reported and its level awaited since `since` (on the\n * `performance.now()` clock); or shown, from then on exactly as the row reports it until it reports no model.\n */\nexport type ModelCell =\n\t| { readonly kind: \"unknown\" }\n\t| { readonly kind: \"waiting\"; readonly since: number; readonly model: string }\n\t| { readonly kind: \"shown\" };\n\n/** What a row reports now. */\nexport interface ModelCellReport {\n\t/** The model it names, undefined for none. */\n\treadonly model: string | undefined;\n\t/** Nothing more is coming for it: its level is known, or the row finished. */\n\treadonly settled: boolean;\n\t/**\n\t * Whether its model has no reasoning levels. Asked only when the row's model becomes known, or changes, while it\n\t * waits, since the answer can take a lookup in the session's model registry.\n\t */\n\treadonly levelless: () => boolean;\n}\n\nconst UNKNOWN: ModelCell = { kind: \"unknown\" };\nconst SHOWN: ModelCell = { kind: \"shown\" };\n\n/**\n * The cell after a paint sees `report` at `now`. `cell` is undefined for a row the view has not painted yet. A row\n * the view already listed, as on its first paint or when it scrolls into view, shows a known model at once, as it\n * always did; a row `added` to the list since the view last painted is new, and its model waits for its level like\n * one that becomes known.\n */\nexport function nextModelCell(\n\tcell: ModelCell | undefined,\n\treport: ModelCellReport,\n\tnow: number,\n\tadded: boolean,\n): ModelCell {\n\tconst model = report.model;\n\tif (cell === undefined) {\n\t\tif (!added) return model === undefined ? UNKNOWN : SHOWN;\n\t\tcell = UNKNOWN;\n\t}\n\tswitch (cell.kind) {\n\t\tcase \"shown\":\n\t\t\treturn model === undefined ? UNKNOWN : cell;\n\t\tcase \"unknown\":\n\t\t\tif (model === undefined) return cell;\n\t\t\treturn report.settled || report.levelless() ? SHOWN : { kind: \"waiting\", since: now, model };\n\t\tcase \"waiting\":\n\t\t\tif (model === undefined) return UNKNOWN;\n\t\t\tif (report.settled || now - cell.since >= MODEL_LEVEL_WAIT_MS) return SHOWN;\n\t\t\t// A switch to another model, as on a fallback, keeps the wait's start; a model without levels ends it.\n\t\t\tif (model === cell.model) return cell;\n\t\t\treturn report.levelless() ? SHOWN : { kind: \"waiting\", since: cell.since, model };\n\t}\n}\n\n/** One open view's model cells and column width. */\nexport class ModelColumn {\n\tprivate readonly cells = new Map<string, ModelCell>();\n\t/**\n\t * The deadlines of the waiting rows painted last, by row id. A waiting row out of view needs no timer: its next\n\t * paint shows its model if its time is up.\n\t */\n\tprivate waiting = new Map<string, number>();\n\t/**\n\t * The list the view last painted from; undefined before its first paint, and after it was too narrow for the\n\t * column. It is read only when it changes, and then only as far as a paint needs it.\n\t */\n\tprivate roster: readonly { readonly id: string }[] | undefined;\n\tprivate heldWidth = -1;\n\t/** The widest column this view painted at `heldWidth`, and the one it painted last. */\n\tprivate held = 0;\n\tprivate last = 0;\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\tprivate timerAt = Number.POSITIVE_INFINITY;\n\tprivate readonly onExpire: (() => void) | undefined;\n\n\t/** `onExpire` repaints the view once a waiting row's time is up, so it shows its model without another change. */\n\tconstructor(onExpire?: () => void) {\n\t\tthis.onExpire = onExpire;\n\t}\n\n\t/**\n\t * Moves the cell of each row painted now on by what it reports and returns the ids of the rows that show their\n\t * model. `listed` is every row of the view, painted or not: rows scrolled out of view keep their cells. Only when it\n\t * is another list than last time is any of it read: the last list, to tell a row added since from one scrolled into\n\t * view, and the new one, to forget the kept cells of rows no longer in it. A paint otherwise costs what its painted\n\t * rows cost.\n\t */\n\tpaint(\n\t\treports: Iterable<readonly [id: string, report: ModelCellReport]>,\n\t\tlisted: readonly { readonly id: string }[],\n\t): ReadonlySet<string> {\n\t\tconst now = performance.now();\n\t\tconst previous = this.roster;\n\t\tlet previousIds: Set<string> | undefined;\n\t\tconst added = (id: string): boolean => {\n\t\t\tif (previous === undefined || previous === listed) return false;\n\t\t\tif (previousIds === undefined) {\n\t\t\t\tpreviousIds = new Set();\n\t\t\t\tfor (const row of previous) previousIds.add(row.id);\n\t\t\t}\n\t\t\treturn !previousIds.has(id);\n\t\t};\n\t\tconst painted = new Set<string>();\n\t\tconst shown = new Set<string>();\n\t\tconst waiting = new Map<string, number>();\n\t\tlet earliest = Number.POSITIVE_INFINITY;\n\t\tfor (const [id, report] of reports) {\n\t\t\tconst before = this.cells.get(id);\n\t\t\tconst cell = nextModelCell(before, report, now, before === undefined && added(id));\n\t\t\tpainted.add(id);\n\t\t\tthis.cells.set(id, cell);\n\t\t\tif (cell.kind === \"shown\") shown.add(id);\n\t\t\telse if (cell.kind === \"waiting\") {\n\t\t\t\tconst due = cell.since + MODEL_LEVEL_WAIT_MS;\n\t\t\t\twaiting.set(id, due);\n\t\t\t\tearliest = Math.min(earliest, due);\n\t\t\t}\n\t\t}\n\t\tthis.waiting = waiting;\n\t\tif (listed !== previous) {\n\t\t\tthis.roster = listed;\n\t\t\tif (this.cells.size > painted.size) {\n\t\t\t\tconst ids = new Set<string>();\n\t\t\t\tfor (const row of listed) ids.add(row.id);\n\t\t\t\tfor (const id of this.cells.keys()) if (!painted.has(id) && !ids.has(id)) this.cells.delete(id);\n\t\t\t}\n\t\t}\n\t\tthis.arm(earliest);\n\t\treturn shown;\n\t}\n\n\t/** Forgets every cell, as when the view is too narrow for the column: its next paint is like a first one. */\n\tforget(): void {\n\t\tthis.cells.clear();\n\t\tthis.waiting.clear();\n\t\tthis.roster = undefined;\n\t\tthis.disarm();\n\t}\n\n\t/**\n\t * The column width to paint at `width`, for shown labels at most `measured` cells wide; `fits(column)` says whether\n\t * a column that wide leaves every painted row its whole right column and some of its task. It is `measured`, or the\n\t * widest column this view painted at this width that still fits, else the one it painted last if that fits: the\n\t * column does not narrow while it fits. It is 0 when even the widest label the rows report, `widest`, shown or still\n\t * waiting, does not fit, as labels are never cut to fit: there is then no column, exactly as without waiting.\n\t */\n\tcolumn(width: number, measured: number, fits: (column: number) => boolean, widest = measured): number {\n\t\tif (width !== this.heldWidth) {\n\t\t\tthis.heldWidth = width;\n\t\t\tthis.held = 0;\n\t\t\tthis.last = 0;\n\t\t}\n\t\tlet column = 0;\n\t\tif (widest === 0 || fits(widest)) {\n\t\t\tcolumn = measured;\n\t\t\tif (this.held > column && fits(this.held)) column = this.held;\n\t\t\telse if (this.last > column && fits(this.last)) column = this.last;\n\t\t}\n\t\tif (column > this.held) this.held = column;\n\t\tthis.last = column;\n\t\treturn column;\n\t}\n\n\t/** Forgets every cell and the column width, as a view opened again does. */\n\treset(): void {\n\t\tthis.forget();\n\t\tthis.heldWidth = -1;\n\t\tthis.held = 0;\n\t\tthis.last = 0;\n\t}\n\n\tdispose(): void {\n\t\tthis.reset();\n\t}\n\n\tprivate arm(deadline: number): void {\n\t\tif (this.onExpire === undefined) return;\n\t\tif (deadline === Number.POSITIVE_INFINITY) {\n\t\t\tthis.disarm();\n\t\t\treturn;\n\t\t}\n\t\tif (this.timer !== undefined && this.timerAt === deadline) return;\n\t\tthis.disarm();\n\t\tthis.timerAt = deadline;\n\t\tthis.timer = setTimeout(() => this.expire(deadline), Math.max(0, deadline - performance.now()));\n\t\tthis.timer.unref?.();\n\t}\n\n\tprivate disarm(): void {\n\t\tif (this.timer !== undefined) clearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tthis.timerAt = Number.POSITIVE_INFINITY;\n\t}\n\n\t/** The rows whose wait ends by `deadline` show their model, and the view repaints. */\n\tprivate expire(deadline: number): void {\n\t\tthis.timer = undefined;\n\t\tthis.timerAt = Number.POSITIVE_INFINITY;\n\t\tlet earliest = Number.POSITIVE_INFINITY;\n\t\tlet expired = false;\n\t\tfor (const [id, due] of this.waiting) {\n\t\t\tif (due <= deadline) {\n\t\t\t\tthis.cells.set(id, SHOWN);\n\t\t\t\tthis.waiting.delete(id);\n\t\t\t\texpired = true;\n\t\t\t} else earliest = Math.min(earliest, due);\n\t\t}\n\t\tthis.arm(earliest);\n\t\tif (expired) this.onExpire?.();\n\t}\n}\n"]}
@@ -0,0 +1,73 @@
1
+ import { type Component, Container, type TUI, type TuiMouseEvent } from "@bastani/atomic-tui";
2
+ import { ScreenHold } from "../screen-hold.ts";
3
+ /**
4
+ * The longest the prompt's slot keeps showing what it showed while a view is on its way: as long as a key in a view
5
+ * another process draws waits for that process to answer.
6
+ */
7
+ export declare const PROMPT_SLOT_HOLD_MS = 250;
8
+ /**
9
+ * `view` has nothing to draw while `awaiting` answers true, as a panel the engine draws before its first frame: the
10
+ * prompt's slot keeps its rows meanwhile. Only views registered here are asked; any other component draws at once.
11
+ */
12
+ export declare function awaitFirstContent(view: Component, awaiting: () => boolean): void;
13
+ /** A command that opens a view holds the prompt's slot; `settle` says the command is done. */
14
+ export interface PromptSlotHold {
15
+ settle(): void;
16
+ }
17
+ /** Keep `slot` as it is on screen until the view the running command opens is up, when it is the prompt's slot. */
18
+ export declare function holdPromptSlot(slot: Container): PromptSlotHold;
19
+ /**
20
+ * Whether what `slot` last drew is live and still current: not held rows, no view still waiting for its first frame,
21
+ * drawn onto the screen, and nothing mounted and no run's working status changed since.
22
+ */
23
+ export declare function promptSlotDrewLive(slot: Container): boolean;
24
+ /**
25
+ * Where the prompt is drawn, or the selector or panel that takes its place. A slash command that opens a view clears
26
+ * the prompt at once, but its view can mount only after an await, or draw only after another process answers. Until
27
+ * then the slot keeps the rows it drew before, so the screen goes from the prompt straight to the view and the rows
28
+ * around it stay put. Only these rows wait: everything else on the screen keeps drawing.
29
+ *
30
+ * The rows come back live when the view is up and has something to draw, when the command ends without one, on the
31
+ * user's next key, at another width, or after `PROMPT_SLOT_HOLD_MS`. The slot holds only through the screen's hold
32
+ * (`ScreenHold`): never while another part of the screen is held, and only rows it drew from live content.
33
+ *
34
+ * A prompt that draws a run's working status in its own rows is never held: the hold would stop that status moving, and
35
+ * could keep showing it after the run ended.
36
+ */
37
+ export declare class PromptSlot extends Container {
38
+ private state;
39
+ /** Counts changes of `children`. */
40
+ private generation;
41
+ /** What the last render drew. */
42
+ private drawn;
43
+ private showingHeldRows;
44
+ private readonly ui;
45
+ private readonly showsRunStatus;
46
+ private readonly screen;
47
+ /**
48
+ * `showsRunStatus` answers whether the prompt draws a run's working status in its rows now; `screen` is the hold of
49
+ * the screen the slot is on.
50
+ */
51
+ constructor(ui: Pick<TUI, "requestRender">, showsRunStatus?: () => boolean, screen?: ScreenHold);
52
+ /**
53
+ * Whether the last render drew live content that is still current (`promptSlotDrewLive`): what a held dock, which
54
+ * has the status area in it too, may keep.
55
+ */
56
+ get drewLive(): boolean;
57
+ /**
58
+ * Whether a hold may keep what the last render drew: live content of the children the slot has now, with no run's
59
+ * working status in it. A status drawn elsewhere on the screen is not in these rows.
60
+ */
61
+ private mayHold;
62
+ addChild(component: Component): void;
63
+ removeChild(component: Component): void;
64
+ clear(): void;
65
+ /** Keep showing what the slot drew last until the view a command opens is up or the command settles. */
66
+ hold(): PromptSlotHold;
67
+ render(width: number): string[];
68
+ /** Held rows are a picture of what was there: a click on them reaches nothing. */
69
+ handleMouse(event: TuiMouseEvent): ReturnType<Container["handleMouse"]>;
70
+ private showsHeldRows;
71
+ private beginHold;
72
+ }
73
+ //# sourceMappingURL=prompt-slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-slot.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/prompt-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAoB,KAAK,GAAG,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAKvC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,IAAI,CAEhF;AAMD,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC9B,MAAM,IAAI,IAAI,CAAC;CACf;AAID,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,CAE9D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAE3D;AAwBD;;;;;;;;;;;;GAYG;AACH,qBAAa,UAAW,SAAQ,SAAS;IACxC,OAAO,CAAC,KAAK,CAAqC;IAClD,oCAAoC;IACpC,OAAO,CAAC,UAAU,CAAK;IACvB,iCAAiC;IACjC,OAAO,CAAC,KAAK,CAaA;IACb,OAAO,CAAC,e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