@bastani/atomic 0.10.0 → 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 (233) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +33 -3
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/core/agent-session-events.d.ts.map +1 -1
  9. package/dist/core/agent-session-events.js +21 -6
  10. package/dist/core/agent-session-events.js.map +1 -1
  11. package/dist/core/lifecycle-timings.d.ts +6 -0
  12. package/dist/core/lifecycle-timings.d.ts.map +1 -1
  13. package/dist/core/lifecycle-timings.js +12 -0
  14. package/dist/core/lifecycle-timings.js.map +1 -1
  15. package/dist/core/queued-message-delivery.d.ts +41 -0
  16. package/dist/core/queued-message-delivery.d.ts.map +1 -0
  17. package/dist/core/queued-message-delivery.js +48 -0
  18. package/dist/core/queued-message-delivery.js.map +1 -0
  19. package/dist/core/storage/node-sqlite-thread.d.ts +64 -0
  20. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -0
  21. package/dist/core/storage/node-sqlite-thread.js +326 -0
  22. package/dist/core/storage/node-sqlite-thread.js.map +1 -0
  23. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  24. package/dist/core/storage/node-sqlite.js +230 -104
  25. package/dist/core/storage/node-sqlite.js.map +1 -1
  26. package/dist/core/tasks/agent-panel-source.d.ts +5 -0
  27. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  28. package/dist/core/tasks/agent-panel-source.js +1 -1
  29. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  30. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +8 -1
  31. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  32. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  33. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +11 -5
  34. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  35. package/dist/modes/interactive/agent-view/agent-view-switcher.js +17 -5
  36. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  37. package/dist/modes/interactive/agent-view/contracts.d.ts +5 -0
  38. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  39. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  40. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  41. package/dist/modes/interactive/agent-view/install.js +6 -3
  42. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  43. package/dist/modes/interactive/agent-view/local-port.d.ts +5 -0
  44. package/dist/modes/interactive/agent-view/local-port.d.ts.map +1 -1
  45. package/dist/modes/interactive/agent-view/local-port.js +8 -0
  46. package/dist/modes/interactive/agent-view/local-port.js.map +1 -1
  47. package/dist/modes/interactive/agent-view/remote-port.d.ts +4 -1
  48. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  49. package/dist/modes/interactive/agent-view/remote-port.js +22 -8
  50. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  51. package/dist/modes/interactive/agent-view/transcript-slot.d.ts +9 -0
  52. package/dist/modes/interactive/agent-view/transcript-slot.d.ts.map +1 -1
  53. package/dist/modes/interactive/agent-view/transcript-slot.js +141 -1
  54. package/dist/modes/interactive/agent-view/transcript-slot.js.map +1 -1
  55. package/dist/modes/interactive/components/agent-panel.d.ts +6 -0
  56. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  57. package/dist/modes/interactive/components/agent-panel.js +40 -10
  58. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  59. package/dist/modes/interactive/components/atomic-working-status.d.ts +15 -0
  60. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  61. package/dist/modes/interactive/components/atomic-working-status.js +51 -3
  62. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  63. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  64. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  65. package/dist/modes/interactive/components/bash-execution.js +5 -1
  66. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  67. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -0
  68. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/branch-summary-message.js +5 -1
  70. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  71. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  72. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  73. package/dist/modes/interactive/components/chat-message-renderer.js +17 -6
  74. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  75. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  76. package/dist/modes/interactive/components/chat-session-host-events.js +35 -4
  77. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  78. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-rendering.js +70 -13
  80. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  81. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +7 -0
  82. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/chat-session-host-runtime.js +25 -4
  84. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  85. package/dist/modes/interactive/components/chat-session-host-state.d.ts +41 -1
  86. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  87. package/dist/modes/interactive/components/chat-session-host-state.js +24 -3
  88. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  89. package/dist/modes/interactive/components/chat-session-host-steering.d.ts.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-steering.js +2 -1
  91. package/dist/modes/interactive/components/chat-session-host-steering.js.map +1 -1
  92. package/dist/modes/interactive/components/chat-session-host.d.ts +13 -1
  93. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  94. package/dist/modes/interactive/components/chat-session-host.js +20 -2
  95. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  96. package/dist/modes/interactive/components/chat-transcript.d.ts +15 -0
  97. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  98. package/dist/modes/interactive/components/chat-transcript.js +14 -1
  99. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  100. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  101. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  102. package/dist/modes/interactive/components/compaction-boundary-message.js +5 -1
  103. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  104. package/dist/modes/interactive/components/custom-entry.d.ts +2 -0
  105. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  106. package/dist/modes/interactive/components/custom-entry.js +5 -1
  107. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  108. package/dist/modes/interactive/components/custom-message.d.ts +2 -0
  109. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  110. package/dist/modes/interactive/components/custom-message.js +5 -1
  111. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  112. package/dist/modes/interactive/components/model-column.d.ts +96 -0
  113. package/dist/modes/interactive/components/model-column.d.ts.map +1 -0
  114. package/dist/modes/interactive/components/model-column.js +207 -0
  115. package/dist/modes/interactive/components/model-column.js.map +1 -0
  116. package/dist/modes/interactive/components/prompt-slot.d.ts +73 -0
  117. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -0
  118. package/dist/modes/interactive/components/prompt-slot.js +201 -0
  119. package/dist/modes/interactive/components/prompt-slot.js.map +1 -0
  120. package/dist/modes/interactive/components/queued-messages-view.d.ts +6 -3
  121. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  122. package/dist/modes/interactive/components/queued-messages-view.js +7 -4
  123. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  124. package/dist/modes/interactive/components/session-selector.d.ts +2 -0
  125. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  126. package/dist/modes/interactive/components/session-selector.js +4 -0
  127. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  128. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -0
  129. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  130. package/dist/modes/interactive/components/skill-invocation-message.js +5 -1
  131. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  132. package/dist/modes/interactive/components/task-board.d.ts +12 -3
  133. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  134. package/dist/modes/interactive/components/task-board.js +33 -17
  135. package/dist/modes/interactive/components/task-board.js.map +1 -1
  136. package/dist/modes/interactive/components/task-inspector.d.ts +6 -1
  137. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  138. package/dist/modes/interactive/components/task-inspector.js +27 -7
  139. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  140. package/dist/modes/interactive/components/task-row.d.ts +4 -0
  141. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  142. package/dist/modes/interactive/components/task-row.js +7 -1
  143. package/dist/modes/interactive/components/task-row.js.map +1 -1
  144. package/dist/modes/interactive/components/task-transcript-page.d.ts +5 -0
  145. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  146. package/dist/modes/interactive/components/task-transcript-page.js +25 -0
  147. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  148. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  149. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  150. package/dist/modes/interactive/components/tool-execution.js +19 -2
  151. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-group-tracker.d.ts +20 -3
  153. package/dist/modes/interactive/components/tool-group-tracker.d.ts.map +1 -1
  154. package/dist/modes/interactive/components/tool-group-tracker.js +34 -7
  155. package/dist/modes/interactive/components/tool-group-tracker.js.map +1 -1
  156. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +14 -2
  157. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  158. package/dist/modes/interactive/components/transcript-block-clicks.js +23 -2
  159. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  160. package/dist/modes/interactive/interactive-agent-events.js +10 -2
  161. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  162. package/dist/modes/interactive/interactive-extension-runtime.d.ts +12 -1
  163. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  164. package/dist/modes/interactive/interactive-extension-runtime.js +37 -5
  165. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  166. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  167. package/dist/modes/interactive/interactive-input-handling.js +70 -46
  168. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  169. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  171. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  172. package/dist/modes/interactive/interactive-prompt-turn.js +17 -9
  173. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  174. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  175. package/dist/modes/interactive/interactive-queueing.js +2 -1
  176. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  177. package/dist/modes/interactive/interactive-render-chat.d.ts +18 -1
  178. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  179. package/dist/modes/interactive/interactive-render-chat.js +90 -10
  180. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  181. package/dist/modes/interactive/interactive-session-routing.js +2 -0
  182. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  183. package/dist/modes/interactive/interactive-task-projection.js +2 -2
  184. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  185. package/dist/modes/interactive/screen-hold.d.ts +41 -0
  186. package/dist/modes/interactive/screen-hold.d.ts.map +1 -0
  187. package/dist/modes/interactive/screen-hold.js +80 -0
  188. package/dist/modes/interactive/screen-hold.js.map +1 -0
  189. package/dist/modes/interactive/started-run-echo.d.ts +66 -0
  190. package/dist/modes/interactive/started-run-echo.d.ts.map +1 -0
  191. package/dist/modes/interactive/started-run-echo.js +75 -0
  192. package/dist/modes/interactive/started-run-echo.js.map +1 -0
  193. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -0
  194. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  195. package/dist/modes/interactive-engine/engine-custom-ui.js +25 -1
  196. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  197. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  198. package/dist/modes/interactive-engine/engine-quit-intent.js +3 -0
  199. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  200. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  201. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  202. package/dist/modes/interactive-engine/protocol.js +7 -1
  203. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  204. package/dist/modes/interactive-engine/remote-component.d.ts +10 -2
  205. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  206. package/dist/modes/interactive-engine/remote-component.js +19 -2
  207. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  208. package/dist/modes/interactive-engine/remote-renderer.d.ts +10 -0
  209. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  210. package/dist/modes/interactive-engine/remote-renderer.js +24 -4
  211. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  212. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts +50 -0
  213. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts.map +1 -0
  214. package/dist/modes/interactive-engine/transcript-frame-layout.js +95 -0
  215. package/dist/modes/interactive-engine/transcript-frame-layout.js.map +1 -0
  216. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  217. package/dist/modes/rpc/agent-panel-bridge.js +16 -0
  218. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  219. package/dist/modes/rpc/agent-view-engine-registry.d.ts.map +1 -1
  220. package/dist/modes/rpc/agent-view-engine-registry.js +36 -1
  221. package/dist/modes/rpc/agent-view-engine-registry.js.map +1 -1
  222. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  223. package/dist/modes/rpc/agent-view-rpc-panel.js +5 -1
  224. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  225. package/dist/modes/rpc/task-ui-bridge.js +1 -1
  226. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  227. package/docs/background-tasks.md +1 -1
  228. package/docs/development.md +2 -0
  229. package/docs/extensions/authoring.md +1 -1
  230. package/docs/keybindings.md +2 -2
  231. package/docs/storage.md +1 -0
  232. package/npm-shrinkwrap.json +49 -49
  233. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"remote-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/remote-port.ts"],"names":[],"mappings":"AAOA,OAAO,EAA8B,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAEjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAyB,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AASvF,mGAAmG;AACnG,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,OAAO,qBAAqB;IAChB,KAAK,CAAwB;IAC7B,UAAU,CAAgB;IAC3C,8FAA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AE,KAAK,CAAC,CAAC;IAC3D,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC;IACtF,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,KAAgD,CAAC;IACrD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;QACjC,KAAK,CAAC,UAAU,EAAE;QAClB,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;YAChC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;YAChE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,CAAC,CAAC;KACF,CAAC,CAAC;IACH,YAAY,CAAC,KAAK,CAAC,CAAC;IACpB,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the isolated engine, as the host's single chat screen shows it. The engine runs the subagent's port\n * (`LocalAgentViewPort`) and draws its transcript as a remote component the host paints where its main transcript is;\n * this proxy carries the status the engine reports for the view, and the view's commands.\n */\nimport type { TuiMouseEvent, TuiMouseEventResult } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { type RemoteTranscriptMount, remoteTranscriptMount } from \"../../interactive-engine/remote-component.ts\";\nimport type { AgentViewOpenData } from \"../../rpc/agent-view-rpc-types.ts\";\nimport { remoteAgentCommands } from \"./agent-commands.ts\";\nimport { remoteAgentPrompts } from \"./agent-prompts.ts\";\nimport { type AgentViewRuntime, createRemoteAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How long an open waits for the transcript's first frame before it shows the subagent anyway. */\nexport const FIRST_FRAME_TIMEOUT_MS = 2_000;\n\n/** The engine's transcript component, in the rows the transcript area gives it. */\nexport class RemoteAgentTranscript implements AgentTranscriptComponent {\n\tprivate readonly mount: RemoteTranscriptMount;\n\tprivate readonly heldPrompt: () => boolean;\n\t/** Rows of the engine's last frame above the rows shown, when it was taller than the area. */\n\tprivate hidden = 0;\n\n\tconstructor(mount: RemoteTranscriptMount, heldPrompt: () => boolean) {\n\t\tthis.mount = mount;\n\t\tthis.heldPrompt = heldPrompt;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.mount.rows = Math.max(1, height);\n\t\tconst lines = this.mount.component.render(width);\n\t\t// A frame drawn for another height until the next one is here: keep its last rows, where the latest are.\n\t\tthis.hidden = Math.max(0, lines.length - height);\n\t\tconst shown = this.hidden > 0 ? lines.slice(this.hidden) : lines;\n\t\treturn shown.length < height ? [...shown, ...Array.from({ length: height - shown.length }, () => \"\")] : shown;\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, this.mount.rows);\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\tvoid this.mount.component.handleInput(data);\n\t\treturn true;\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.heldPrompt();\n\t}\n\n\thandleInput(data: string): void {\n\t\tvoid this.mount.component.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\treturn this.mount.component.handleMouse({ ...event, y: event.y + this.hidden });\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\treturn this.mount.component.paintedRowKey(row + this.hidden);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.mount.component.invalidate();\n\t}\n}\n\n/** View `viewId` of the engine: its status as last reported, its transcript, and its steering. */\nexport class RemoteAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly viewId: string;\n\treadonly transcript: RemoteAgentTranscript;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly runtime: AgentViewRuntime;\n\tprivate readonly generation: number;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate readonly unsubscribe: (() => void)[] = [];\n\n\tconstructor(runtime: AgentViewRuntime, data: AgentViewOpenData, mount: RemoteTranscriptMount) {\n\t\tthis.runtime = runtime;\n\t\tthis.viewId = data.viewId;\n\t\tthis.agentKey = data.status.agentKey;\n\t\tthis.current = data.status;\n\t\tthis.generation = runtime.getGeneration();\n\t\tthis.transcript = new RemoteAgentTranscript(mount, () => this.current.heldPrompt);\n\t\tthis.steeringPort = createRemoteAgentSteering({\n\t\t\truntime,\n\t\t\tviewId: data.viewId,\n\t\t\tstatus: () => this.status(),\n\t\t\tonStatus: (listener) => this.subscribe(listener),\n\t\t});\n\t\tthis.steering = this.steeringPort.steering;\n\t\tthis.unsubscribe.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_agent_view_status\" && message.viewId === this.viewId)\n\t\t\t\t\tthis.setStatus(message.status);\n\t\t\t}),\n\t\t\t// The engine is gone, and its subagents with it: the screen shows main.\n\t\t\truntime.onGenerationEnded(() => this.setStatus({ ...this.current, gone: true })),\n\t\t\tmount.onClose(() => this.setStatus({ ...this.current, gone: true })),\n\t\t);\n\t}\n\n\tstatus(): AgentViewStatus {\n\t\treturn this.current;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tpause() {\n\t\treturn this.steeringPort.pause();\n\t}\n\n\tprompts(): Promise<readonly string[]> {\n\t\treturn remoteAgentPrompts(this.runtime, this.current.taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn remoteAgentCommands(this.runtime, this.viewId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\tconst answer = await this.runtime.requestAgentView<{ text?: string }>({\n\t\t\ttype: \"agent_view_last_message\",\n\t\t\tviewId: this.viewId,\n\t\t});\n\t\treturn answer.text;\n\t}\n\n\tretain(): () => void {\n\t\tthis.retained++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tif (--this.retained === 0) this.dispose();\n\t\t};\n\t}\n\n\tprivate setStatus(status: AgentViewStatus): void {\n\t\tif (this.disposed) return;\n\t\t// Once gone, the view stays gone: a late report of the closed view changes nothing.\n\t\tthis.current = this.current.gone ? { ...status, gone: true } : status;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const unsubscribe of this.unsubscribe.splice(0)) unsubscribe();\n\t\tthis.listeners.clear();\n\t\tif (this.runtime.getGeneration() !== this.generation) return;\n\t\tvoid this.runtime.requestAgentView({ type: \"agent_view_close\", viewId: this.viewId }).catch(() => {\n\t\t\t// The engine closes its views with it.\n\t\t});\n\t}\n}\n\n/**\n * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or\n * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw.\n */\nexport async function openRemoteAgentViewPort(\n\truntime: AgentViewRuntime,\n\ttaskId: TaskId,\n\tframe: { readonly width: number; readonly rows: number; readonly colorDepth?: number },\n): Promise<RemoteAgentViewPort | undefined> {\n\tconst data = await runtime.requestAgentView<AgentViewOpenData>({ type: \"agent_view_open\", taskId });\n\tconst mount = remoteTranscriptMount(runtime, data.viewId);\n\tif (mount === undefined || mount.closed) {\n\t\tvoid runtime.requestAgentView({ type: \"agent_view_close\", viewId: data.viewId }).catch(() => {});\n\t\tthrow new Error(\"The subagent's transcript did not open.\");\n\t}\n\tconst port = new RemoteAgentViewPort(runtime, data, mount);\n\tif (frame.colorDepth !== undefined) mount.component.hostColorDepth = frame.colorDepth;\n\tmount.rows = Math.max(1, frame.rows);\n\tmount.component.prime(Math.max(1, frame.width), mount.rows);\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst framed = await Promise.race([\n\t\tmount.firstFrame(),\n\t\tnew Promise<boolean>((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t}),\n\t]);\n\tclearTimeout(timer);\n\tif (!framed) {\n\t\tport.retain()();\n\t\treturn undefined;\n\t}\n\treturn port;\n}\n"]}
1
+ {"version":3,"file":"remote-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/remote-port.ts"],"names":[],"mappings":"AAOA,OAAO,EAA8B,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACjH,OAAO,EAA8B,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAEvH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAyB,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AASvF,mGAAmG;AACnG,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,OAAO,qBAAqB;IAChB,KAAK,CAAwB;IAC7B,UAAU,CAAgB;IAC3C,yFAAyF;IACjF,SAAS,CAAqC;IAC9C,MAAM,GAAG,CAAC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AC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the isolated engine, as the host's single chat screen shows it. The engine runs the subagent's port\n * (`LocalAgentViewPort`) and draws its transcript as a remote component the host paints where its main transcript is;\n * this proxy carries the status the engine reports for the view, and the view's commands.\n */\nimport type { TuiMouseEvent, TuiMouseEventResult } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { type RemoteTranscriptMount, remoteTranscriptMount } from \"../../interactive-engine/remote-component.ts\";\nimport { type PlacedTranscriptFrame, placeTranscriptFrame } from \"../../interactive-engine/transcript-frame-layout.ts\";\nimport type { AgentViewOpenData } from \"../../rpc/agent-view-rpc-types.ts\";\nimport { remoteAgentCommands } from \"./agent-commands.ts\";\nimport { remoteAgentPrompts } from \"./agent-prompts.ts\";\nimport { type AgentViewRuntime, createRemoteAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How long an open waits for the transcript's first frame before it shows the subagent anyway. */\nexport const FIRST_FRAME_TIMEOUT_MS = 2_000;\n\n/** The engine's transcript component, in the rows the transcript area gives it. */\nexport class RemoteAgentTranscript implements AgentTranscriptComponent {\n\tprivate readonly mount: RemoteTranscriptMount;\n\tprivate readonly heldPrompt: () => boolean;\n\t/** How the frame painted last was placed in the rows shown (`PlacedTranscriptFrame`). */\n\tprivate frameRows: PlacedTranscriptFrame[\"frameRows\"];\n\tprivate hidden = 0;\n\n\tconstructor(mount: RemoteTranscriptMount, heldPrompt: () => boolean) {\n\t\tthis.mount = mount;\n\t\tthis.heldPrompt = heldPrompt;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.mount.rows = Math.max(1, height);\n\t\tconst component = this.mount.component;\n\t\tconst lines = component.render(width);\n\t\t// A frame drawn for another height until the next one is here: its rows go where that frame will put them.\n\t\tconst placed = placeTranscriptFrame(lines, component.paintedLayout(), width, height);\n\t\tthis.frameRows = placed.frameRows;\n\t\tthis.hidden = placed.hidden;\n\t\treturn placed.lines;\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, this.mount.rows);\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\tvoid this.mount.component.handleInput(data);\n\t\treturn true;\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.heldPrompt();\n\t}\n\n\thandleInput(data: string): void {\n\t\tvoid this.mount.component.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tconst row = this.frameRow(event.y);\n\t\treturn row === undefined ? undefined : this.mount.component.handleMouse({ ...event, y: row });\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\tconst frameRow = this.frameRow(row);\n\t\treturn frameRow === undefined ? undefined : this.mount.component.paintedRowKey(frameRow);\n\t}\n\n\t/** The frame row painted at `row`: a row the host left blank until the next frame takes no click. */\n\tprivate frameRow(row: number): number | undefined {\n\t\tconst frameRows = this.frameRows;\n\t\tif (frameRows === undefined) return row + this.hidden;\n\t\tconst index = Math.floor(row);\n\t\treturn index >= 0 && index < frameRows.length ? frameRows[index] : undefined;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.mount.component.invalidate();\n\t}\n}\n\n/** View `viewId` of the engine: its status as last reported, its transcript, and its steering. */\nexport class RemoteAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly viewId: string;\n\treadonly transcript: RemoteAgentTranscript;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly runtime: AgentViewRuntime;\n\tprivate readonly generation: number;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate readonly unsubscribe: (() => void)[] = [];\n\n\tconstructor(runtime: AgentViewRuntime, data: AgentViewOpenData, mount: RemoteTranscriptMount) {\n\t\tthis.runtime = runtime;\n\t\tthis.viewId = data.viewId;\n\t\tthis.agentKey = data.status.agentKey;\n\t\tthis.current = data.status;\n\t\tthis.generation = runtime.getGeneration();\n\t\tthis.transcript = new RemoteAgentTranscript(mount, () => this.current.heldPrompt);\n\t\tthis.steeringPort = createRemoteAgentSteering({\n\t\t\truntime,\n\t\t\tviewId: data.viewId,\n\t\t\tstatus: () => this.status(),\n\t\t\tonStatus: (listener) => this.subscribe(listener),\n\t\t});\n\t\tthis.steering = this.steeringPort.steering;\n\t\tthis.unsubscribe.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_agent_view_status\" && message.viewId === this.viewId)\n\t\t\t\t\tthis.setStatus(message.status);\n\t\t\t}),\n\t\t\t// The engine is gone, and its subagents with it: the screen shows main.\n\t\t\truntime.onGenerationEnded(() => this.setStatus({ ...this.current, gone: true })),\n\t\t\tmount.onClose(() => this.setStatus({ ...this.current, gone: true })),\n\t\t);\n\t}\n\n\tstatus(): AgentViewStatus {\n\t\treturn this.current;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tpause() {\n\t\treturn this.steeringPort.pause();\n\t}\n\n\tprompts(): Promise<readonly string[]> {\n\t\treturn remoteAgentPrompts(this.runtime, this.current.taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn remoteAgentCommands(this.runtime, this.viewId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\tconst answer = await this.runtime.requestAgentView<{ text?: string }>({\n\t\t\ttype: \"agent_view_last_message\",\n\t\t\tviewId: this.viewId,\n\t\t});\n\t\treturn answer.text;\n\t}\n\n\tretain(): () => void {\n\t\tthis.retained++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tif (--this.retained === 0) this.dispose();\n\t\t};\n\t}\n\n\tprivate setStatus(status: AgentViewStatus): void {\n\t\tif (this.disposed) return;\n\t\t// Once gone, the view stays gone: a late report of the closed view changes nothing.\n\t\tthis.current = this.current.gone ? { ...status, gone: true } : status;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const unsubscribe of this.unsubscribe.splice(0)) unsubscribe();\n\t\tthis.listeners.clear();\n\t\tif (this.runtime.getGeneration() !== this.generation) return;\n\t\tvoid this.runtime.requestAgentView({ type: \"agent_view_close\", viewId: this.viewId }).catch(() => {\n\t\t\t// The engine closes its views with it.\n\t\t});\n\t}\n}\n\n/**\n * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or\n * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw.\n */\nexport async function openRemoteAgentViewPort(\n\truntime: AgentViewRuntime,\n\ttaskId: TaskId,\n\tframe: { readonly width: number; readonly rows: number; readonly colorDepth?: number },\n): Promise<RemoteAgentViewPort | undefined> {\n\tconst data = await runtime.requestAgentView<AgentViewOpenData>({ type: \"agent_view_open\", taskId });\n\tconst mount = remoteTranscriptMount(runtime, data.viewId);\n\tif (mount === undefined || mount.closed) {\n\t\tvoid runtime.requestAgentView({ type: \"agent_view_close\", viewId: data.viewId }).catch(() => {});\n\t\tthrow new Error(\"The subagent's transcript did not open.\");\n\t}\n\tconst port = new RemoteAgentViewPort(runtime, data, mount);\n\tif (frame.colorDepth !== undefined) mount.component.hostColorDepth = frame.colorDepth;\n\tmount.rows = Math.max(1, frame.rows);\n\tmount.component.prime(Math.max(1, frame.width), mount.rows);\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst framed = await Promise.race([\n\t\tmount.firstFrame(),\n\t\tnew Promise<boolean>((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t}),\n\t]);\n\tclearTimeout(timer);\n\tif (!framed) {\n\t\tport.retain()();\n\t\treturn undefined;\n\t}\n\treturn port;\n}\n"]}
@@ -11,6 +11,8 @@ export declare class AgentTranscriptSlot implements Component {
11
11
  port: AgentViewPort | undefined;
12
12
  /** The rows the transcript had in the last frame; undefined before one was drawn. */
13
13
  transcriptRows: number | undefined;
14
+ /** The rows the whole area had in the last frame, notices included. */
15
+ paintedRows: number | undefined;
14
16
  private notices;
15
17
  private readonly fallbackRows;
16
18
  constructor(fallbackRows: () => number);
@@ -24,6 +26,13 @@ export declare class AgentTranscriptSlot implements Component {
24
26
  clearNotices(): void;
25
27
  private renderNotices;
26
28
  }
29
+ /**
30
+ * Keep the dock below the transcript (prompt, footer, panel) as it was painted, at most `timeoutMs`, while the
31
+ * transcript above keeps drawing live: `/tasks` closes while the subagent it opens is on its way, and the main chat's
32
+ * prompt is not painted in between. A key press, a press on the held rows, another size or renderer, and the
33
+ * answered release show it live again. Only the fullscreen renderer holds; answers the release.
34
+ */
35
+ export declare function holdTranscriptDock(mode: InteractiveModeBase, timeoutMs: number): () => void;
27
36
  /** The rows a subagent's transcript is drawn in on `mode`'s screen: those of the last frame, else an estimate. */
28
37
  export declare function transcriptSlotRows(mode: InteractiveModeBase): number;
29
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transcript-slot.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/transcript-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAId,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,6BAA6B,CAAC;AAEnG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQpD,KAAK,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAwBjD;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IACpD,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,qFAAqF;IACrF,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,YAAY,YAAY,EAAE,MAAM,MAAM,EAErC;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAYnD;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9B;IAED,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,mBAAmB,GAAG,SAAS,CAKjE;IAED,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG7C;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAM9C;IAED,YAAY,IAAI,IAAI,CAEnB;IAED,OAAO,CAAC,aAAa;CAMrB;AAQD,kHAAkH;AAClH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CA+IxG"}
1
+ {"version":3,"file":"transcript-slot.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/transcript-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAKd,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,MAAM,qBA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C,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAiOxG"}
@@ -1,6 +1,8 @@
1
- import { isKeyRelease, isViewportTUI, Text, VStack, } from "@bastani/atomic-tui";
1
+ import { isKeyRelease, isViewportTUI, stripHintMarkers, Text, VStack, } from "@bastani/atomic-tui";
2
+ import { promptSlotDrewLive } from "../components/prompt-slot.js";
2
3
  import { TRANSCRIPT_JUMP_TO_END_URL } from "../components/transcript-follow-indicator.js";
3
4
  import { isFullscreenViewportAction } from "../interactive-mode-base.js";
5
+ import { screenHoldOf } from "../screen-hold.js";
4
6
  import { theme } from "../theme/theme.js";
5
7
  import { setViewedNoticeSink } from "./viewed-notices.js";
6
8
  /** Rows the prompt, footer and panel take below the transcript before the first frame says how many they take. */
@@ -30,6 +32,8 @@ export class AgentTranscriptSlot {
30
32
  port;
31
33
  /** The rows the transcript had in the last frame; undefined before one was drawn. */
32
34
  transcriptRows;
35
+ /** The rows the whole area had in the last frame, notices included. */
36
+ paintedRows;
33
37
  notices = [];
34
38
  fallbackRows;
35
39
  constructor(fallbackRows) {
@@ -46,6 +50,7 @@ export class AgentTranscriptSlot {
46
50
  const drawn = typeof transcript.renderSized === "function" ? transcript.renderSized(width, rows) : transcript.render(width);
47
51
  const lines = drawn.length > rows ? drawn.slice(drawn.length - rows) : drawn;
48
52
  this.transcriptRows = rows;
53
+ this.paintedRows = height;
49
54
  return [...lines, ...Array.from({ length: rows - lines.length }, () => ""), ...notices];
50
55
  }
51
56
  render(width) {
@@ -92,7 +97,65 @@ export class AgentTranscriptSlot {
92
97
  return lines;
93
98
  }
94
99
  }
100
+ /** An OSC 8 hyperlink's opening or closing sequence. */
101
+ const HYPERLINK = /\x1b\]8;[^\x07\x1b]*(?:\x07|\x1b\\)/g;
102
+ /** What the renderer ends every row it writes with; it adds it again to the held rows. */
103
+ const ROW_END = "\x1b[0m\x1b]8;;\x07";
104
+ /** A row as the screen showed it, without its links: drawn again, it writes the same text and styles. */
105
+ function heldRow(line) {
106
+ const row = line.endsWith(ROW_END) ? line.slice(0, -ROW_END.length) : line;
107
+ return stripHintMarkers(row).replace(HYPERLINK, "");
108
+ }
109
+ /**
110
+ * The rows the dock below the transcript painted last, drawn in its place while it is held. They are only text, with
111
+ * no links or clickable hints left in them: what they acted on is gone. A press on them shows the dock live and does
112
+ * nothing else; a frame of another size than the one they were painted in ends the hold too.
113
+ */
114
+ class HeldDockRows {
115
+ lines;
116
+ /** Whether the screen is still the one the rows were painted on, at the same size. */
117
+ sameScreen;
118
+ /** The dock drawn live: unseen while held, and shown for a frame of another size before the hold has ended. */
119
+ live;
120
+ onEnd;
121
+ constructor(lines, sameScreen, live, onEnd) {
122
+ this.lines = lines.map(heldRow);
123
+ this.sameScreen = sameScreen;
124
+ this.live = live;
125
+ this.onEnd = onEnd;
126
+ }
127
+ render(width) {
128
+ // The live dock is drawn too, unseen: what it shows from the engine (the panel) asks for its frames now, and
129
+ // has them when the hold ends rather than one paint later.
130
+ const live = this.live(width);
131
+ if (this.sameScreen(width))
132
+ return this.lines;
133
+ this.onEnd();
134
+ return live;
135
+ }
136
+ handleMouse(event) {
137
+ // A wheel turn scrolls as it does over the live dock.
138
+ if (event.type === "wheel")
139
+ return undefined;
140
+ if (event.type !== "press")
141
+ return { handled: true, render: false };
142
+ this.onEnd();
143
+ // The release comes back here: it is not a click on whatever is drawn live under the pointer by then.
144
+ return { capture: true };
145
+ }
146
+ invalidate() { }
147
+ }
95
148
  const slots = new WeakMap();
149
+ const dockHolds = new WeakMap();
150
+ /**
151
+ * Keep the dock below the transcript (prompt, footer, panel) as it was painted, at most `timeoutMs`, while the
152
+ * transcript above keeps drawing live: `/tasks` closes while the subagent it opens is on its way, and the main chat's
153
+ * prompt is not painted in between. A key press, a press on the held rows, another size or renderer, and the
154
+ * answered release show it live again. Only the fullscreen renderer holds; answers the release.
155
+ */
156
+ export function holdTranscriptDock(mode, timeoutMs) {
157
+ return dockHolds.get(mode)?.(timeoutMs) ?? (() => { });
158
+ }
96
159
  function focusedComponent(mode) {
97
160
  return mode.ui.getFocusedComponent?.();
98
161
  }
@@ -110,6 +173,8 @@ export function installTranscriptSlot(mode, switcher) {
110
173
  slots.set(mode, slot);
111
174
  let agentRoot;
112
175
  let unwatchPort;
176
+ let dock = { kind: "live" };
177
+ let holds = 0;
113
178
  const agentShown = () => switcher.viewed.kind === "agent";
114
179
  /** The question form of a held prompt takes the keys while it is open; the prompt has them otherwise. */
115
180
  const syncFocus = () => {
@@ -126,6 +191,20 @@ export function installTranscriptSlot(mode, switcher) {
126
191
  const tui = mode.ui;
127
192
  const shown = agentShown();
128
193
  if (isViewportTUI(tui)) {
194
+ const held = dock;
195
+ const part = shown ? slot : mode.transcriptScrollView;
196
+ if (held.kind === "held" && part !== undefined) {
197
+ if (held.root?.part !== part)
198
+ held.root = {
199
+ part,
200
+ root: new VStack([
201
+ { component: part, basis: 0, grow: 1, shrink: 1, minSize: 1 },
202
+ { component: held.rows, basis: "auto", grow: 0, shrink: 1, minSize: 1 },
203
+ ]),
204
+ };
205
+ tui.setLayoutRoot(held.root.root);
206
+ return;
207
+ }
129
208
  if (shown && mode.fullscreenDock !== undefined) {
130
209
  agentRoot ??= new VStack([
131
210
  { component: slot, basis: 0, grow: 1, shrink: 1, minSize: 1 },
@@ -213,6 +292,64 @@ export function installTranscriptSlot(mode, switcher) {
213
292
  };
214
293
  };
215
294
  let detach;
295
+ const endDockHold = (held, key) => {
296
+ if (dock !== held || held.kind !== "held")
297
+ return;
298
+ clearTimeout(held.timer);
299
+ held.offRenderer();
300
+ dock = { kind: "live" };
301
+ held.ended();
302
+ applyLayout();
303
+ // A scroll key that ends it is handled next by the screen, against its layout: laid out only at the next paint,
304
+ // it would find none to move. Any other key draws its own frame once it is handled.
305
+ if (key !== undefined && isFullscreenViewportAction(key, mode.keybindings))
306
+ mode.ui.renderNow();
307
+ else
308
+ mode.ui.requestRender();
309
+ };
310
+ // The screen's hold, which also ends a held dock on the user's key press (the startup input listeners call it before
311
+ // any other key handler). Clicks and wheel turns reach the screen as painted: the transcript above is live, the held
312
+ // rows are inert.
313
+ const screenHold = screenHoldOf(mode);
314
+ dockHolds.set(mode, (timeoutMs) => screenHold.begin("dock", (ended) => {
315
+ const tui = mode.ui;
316
+ const screen = tui.getScreenLines?.();
317
+ const rows = tui.terminal.rows;
318
+ const top = agentShown() ? slot.paintedRows : mode.transcriptScrollView?.viewportHeight;
319
+ if (dock.kind === "held" ||
320
+ !isViewportTUI(tui) ||
321
+ // An overlay over the screen is in the rows too; the screen without it is not what they show.
322
+ tui.hasOverlay() ||
323
+ mode.fullscreenDock === undefined ||
324
+ screen === undefined ||
325
+ screen.length !== rows ||
326
+ top === undefined ||
327
+ top < 1 ||
328
+ top >= rows ||
329
+ // Only rows painted from live content are kept: not the prompt's held rows, nor a panel yet to draw.
330
+ (mode.editorContainer !== undefined && !promptSlotDrewLive(mode.editorContainer)))
331
+ return undefined;
332
+ const hold = ++holds;
333
+ const end = (key) => {
334
+ if (dock.kind === "held" && dock.hold === hold)
335
+ endDockHold(dock, key);
336
+ };
337
+ const timer = setTimeout(end, timeoutMs);
338
+ timer.unref?.();
339
+ const columns = tui.terminal.columns;
340
+ const fullscreenDock = mode.fullscreenDock;
341
+ dock = {
342
+ kind: "held",
343
+ hold,
344
+ rows: new HeldDockRows(screen.slice(top), (width) => width === columns && tui.terminal.columns === columns && tui.terminal.rows === rows, (width) => fullscreenDock.render(width), () => queueMicrotask(end)),
345
+ timer,
346
+ offRenderer: mode.onTuiRendererChange(end),
347
+ ended,
348
+ root: undefined,
349
+ };
350
+ applyLayout();
351
+ return end;
352
+ }));
216
353
  const offChange = switcher.onChange(({ to }) => {
217
354
  unwatchPort?.();
218
355
  unwatchPort = undefined;
@@ -242,6 +379,9 @@ export function installTranscriptSlot(mode, switcher) {
242
379
  // Notices about the shown subagent alone (a refused command, its pause failing) are drawn under it only.
243
380
  setViewedNoticeSink(mode, { show: (text, kind) => mirror(kind === "info" ? "status" : kind, text) });
244
381
  return () => {
382
+ endDockHold(dock);
383
+ if (dockHolds.get(mode) !== undefined && slots.get(mode) === slot)
384
+ dockHolds.delete(mode);
245
385
  setViewedNoticeSink(mode, undefined);
246
386
  offChange();
247
387
  unwatchPort?.();
@@ -1 +1 @@
1
- {"version":3,"file":"transcript-slot.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/transcript-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,aAAa,EACb,IAAI,EAGJ,MAAM,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAA4B,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,kHAAkH;AAClH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,0GAA0G;AAC1G,MAAM,WAAW,GAAG,CAAC,CAAC;AAStB,SAAS,UAAU,CAAC,MAAc;IACjC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACrC,KAAK,SAAS;YACb,OAAO,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACvD,KAAK,OAAO;YACX,OAAO,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,0GAA0G;AAC1G,SAAS,WAAW,CAAC,KAAoB;IACxC,MAAM,IAAI,GAAG,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aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\tisViewportTUI,\n\tText,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n\tVStack,\n} from \"@bastani/atomic-tui\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"../components/transcript-follow-indicator.ts\";\nimport { type InteractiveModeBase, isFullscreenViewportAction } from \"../interactive-mode-base.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport type { AgentViewSwitcher } from \"./agent-view-switcher.ts\";\nimport type { AgentViewPort } from \"./contracts.ts\";\nimport { setViewedNoticeSink } from \"./viewed-notices.ts\";\n\n/** Rows the prompt, footer and panel take below the transcript before the first frame says how many they take. */\nconst ESTIMATED_DOCK_ROWS = 10;\n/** Notices kept at the bottom of a shown subagent's transcript; older ones leave as newer ones arrive. */\nconst MAX_NOTICES = 3;\n\ntype NoticeKind = \"status\" | \"warning\" | \"error\";\n\ninterface Notice {\n\treadonly kind: NoticeKind;\n\treadonly text: string;\n}\n\nfunction noticeText(notice: Notice): string {\n\tswitch (notice.kind) {\n\t\tcase \"status\":\n\t\t\treturn theme.fg(\"dim\", notice.text);\n\t\tcase \"warning\":\n\t\t\treturn theme.fg(\"warning\", `Warning: ${notice.text}`);\n\t\tcase \"error\":\n\t\t\treturn theme.fg(\"error\", `Error: ${notice.text}`);\n\t}\n}\n\n/** An SGR wheel report the transcript's own viewport reads, for a wheel turn over the transcript area. */\nfunction wheelReport(event: TuiMouseEvent): string {\n\tconst code = ((event.wheelDelta ?? 0) < 0 ? 64 : 65) | (event.alt ? 8 : 0);\n\treturn `\\x1b[<${code};${Math.max(1, Math.floor(event.x) + 1)};${Math.max(1, Math.floor(event.y) + 1)}M`;\n}\n\n/**\n * The transcript area while a subagent is shown: its transcript in the rows the screen gives it, and the screen's\n * status, warning and error notices below it, as the main chat adds them below its last message.\n */\nexport class AgentTranscriptSlot implements Component {\n\tport: AgentViewPort | undefined;\n\t/** The rows the transcript had in the last frame; undefined before one was drawn. */\n\ttranscriptRows: number | undefined;\n\tprivate notices: Notice[] = [];\n\tprivate readonly fallbackRows: () => number;\n\n\tconstructor(fallbackRows: () => number) {\n\t\tthis.fallbackRows = fallbackRows;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tconst port = this.port;\n\t\tif (height <= 0 || port === undefined) return [];\n\t\tconst noticeLines = this.renderNotices(width);\n\t\tconst notices = noticeLines.slice(Math.max(0, noticeLines.length - (height - 1)));\n\t\tconst rows = height - notices.length;\n\t\tconst transcript = port.transcript;\n\t\tconst drawn =\n\t\t\ttypeof transcript.renderSized === \"function\" ? transcript.renderSized(width, rows) : transcript.render(width);\n\t\tconst lines = drawn.length > rows ? drawn.slice(drawn.length - rows) : drawn;\n\t\tthis.transcriptRows = rows;\n\t\treturn [...lines, ...Array.from({ length: rows - lines.length }, () => \"\"), ...notices];\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, Math.max(1, this.fallbackRows()));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.port?.transcript.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tconst transcript = this.port?.transcript;\n\t\tif (transcript === undefined || event.y < 0 || event.y >= (this.transcriptRows ?? 0)) return undefined;\n\t\tif (event.type === \"wheel\") return transcript.handleViewKey(wheelReport(event)) ? { handled: true } : undefined;\n\t\treturn transcript.handleMouse?.(event);\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\tif (row < 0 || row >= (this.transcriptRows ?? 0)) return undefined;\n\t\treturn this.port?.transcript.paintedRowKey?.(row);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.port?.transcript.invalidate();\n\t}\n\n\taddNotice(kind: NoticeKind, text: string): void {\n\t\tconst last = this.notices.at(-1);\n\t\t// A status replaces the status just before it, as the main chat's next status line does.\n\t\tif (kind === \"status\" && last?.kind === \"status\") this.notices[this.notices.length - 1] = { kind, text };\n\t\telse this.notices.push({ kind, text });\n\t\tif (this.notices.length > MAX_NOTICES) this.notices.splice(0, this.notices.length - MAX_NOTICES);\n\t}\n\n\tclearNotices(): void {\n\t\tthis.notices = [];\n\t}\n\n\tprivate renderNotices(width: number): string[] {\n\t\tif (this.notices.length === 0) return [];\n\t\tconst lines = [\"\"];\n\t\tfor (const notice of this.notices) lines.push(...new Text(noticeText(notice), 1, 0).render(width));\n\t\treturn lines;\n\t}\n}\n\nconst slots = new WeakMap<InteractiveModeBase, AgentTranscriptSlot>();\n\nfunction focusedComponent(mode: InteractiveModeBase): object | null | undefined {\n\treturn (mode.ui as { getFocusedComponent?(): object | null }).getFocusedComponent?.();\n}\n\n/** The rows a subagent's transcript is drawn in on `mode`'s screen: those of the last frame, else an estimate. */\nexport function transcriptSlotRows(mode: InteractiveModeBase): number {\n\treturn slots.get(mode)?.transcriptRows ?? Math.max(1, mode.ui.terminal.rows - ESTIMATED_DOCK_ROWS);\n}\n\n/**\n * Draw the viewed subagent's transcript where the main transcript is, and main's again when main is shown. While a\n * subagent is shown, the mode's status, warning and error notices, which stay main's, are also drawn at the bottom of\n * its transcript, as are the notices about it alone (`notifyViewed`). Answers the uninstall.\n */\nexport function installTranscriptSlot(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tconst slot = new AgentTranscriptSlot(() => Math.max(1, mode.ui.terminal.rows - ESTIMATED_DOCK_ROWS));\n\tslots.set(mode, slot);\n\tlet agentRoot: Component | undefined;\n\tlet unwatchPort: (() => void) | undefined;\n\tconst agentShown = () => switcher.viewed.kind === \"agent\";\n\n\t/** The question form of a held prompt takes the keys while it is open; the prompt has them otherwise. */\n\tconst syncFocus = () => {\n\t\tconst viewed = switcher.viewed;\n\t\tconst wantsSlot = viewed.kind === \"agent\" && viewed.port.transcript.capturesInput();\n\t\tconst focused = focusedComponent(mode);\n\t\tif (wantsSlot && focused === mode.editor) mode.ui.setFocus(slot);\n\t\telse if (!wantsSlot && focused === slot) mode.ui.setFocus(mode.editor);\n\t};\n\n\t/** Install the layout of what is shown: the agent root over the same dock, or main's own root object again. */\n\tconst applyLayout = () => {\n\t\tconst tui = mode.ui;\n\t\tconst shown = agentShown();\n\t\tif (isViewportTUI(tui)) {\n\t\t\tif (shown && mode.fullscreenDock !== undefined) {\n\t\t\t\tagentRoot ??= new VStack([\n\t\t\t\t\t{ component: slot, basis: 0, grow: 1, shrink: 1, minSize: 1 },\n\t\t\t\t\t{ component: mode.fullscreenDock, basis: \"auto\", grow: 0, shrink: 1, minSize: 1 },\n\t\t\t\t]);\n\t\t\t\ttui.setLayoutRoot(agentRoot);\n\t\t\t} else if (mode.fullscreenLayoutRoot !== undefined) tui.setLayoutRoot(mode.fullscreenLayoutRoot);\n\t\t\treturn;\n\t\t}\n\t\t// The main-screen renderer draws its children in order: the transcript area is the document's place.\n\t\tconst children = tui.children;\n\t\tconst at = children.indexOf(shown ? mode.documentContainer : slot);\n\t\tif (at >= 0) children[at] = shown ? slot : mode.documentContainer;\n\t};\n\n\t/**\n\t * What the screen does differently while a subagent is shown, attached when one is first shown and detached when\n\t * main is again: with main shown the mode has nothing of this, exactly as before.\n\t */\n\tconst attach = (): (() => void) => {\n\t\t// A replaced renderer starts on main's root; a shown subagent keeps its place.\n\t\tconst offRenderer = mode.onTuiRendererChange(() => {\n\t\t\tif (agentShown()) applyLayout();\n\t\t});\n\t\t// Scroll keys go to the shown transcript, as they go to main's while main is shown. The screen's own viewport\n\t\t// declines them meanwhile (`shouldHandleViewportInput`).\n\t\tconst removeInput = mode.addTuiInputListener((data) => {\n\t\t\tconst viewed = switcher.viewed;\n\t\t\tif (viewed.kind !== \"agent\" || focusedComponent(mode) !== mode.editor) return undefined;\n\t\t\tif (!isFullscreenViewportAction(data, mode.keybindings)) return undefined;\n\t\t\tif (!isKeyRelease(data)) viewed.port.transcript.handleViewKey(data);\n\t\t\tmode.ui.requestRender();\n\t\t\treturn { consume: true };\n\t\t});\n\t\tconst own = mode as unknown as Record<string, unknown>;\n\t\tconst overridden = [\"showStatus\", \"showWarning\", \"showError\", \"jumpToTranscriptEnd\"] as const;\n\t\tconst ownBefore = new Map(\n\t\t\toverridden.filter((name) => Object.hasOwn(mode, name)).map((name) => [name, own[name]] as const),\n\t\t);\n\t\tconst showStatus = mode.showStatus;\n\t\tconst showWarning = mode.showWarning;\n\t\tconst showError = mode.showError;\n\t\tconst jumpToTranscriptEnd = mode.jumpToTranscriptEnd;\n\t\t// Main's notices stay main's, rows in its transcript as before; while a subagent is shown they are also drawn\n\t\t// under its transcript, where the reader is looking.\n\t\town.showStatus = function (this: InteractiveModeBase, message: string, ...rest: unknown[]): void {\n\t\t\t(showStatus as (...args: unknown[]) => void).call(this, message, ...rest);\n\t\t\tif (agentShown()) mirror(\"status\", message);\n\t\t};\n\t\town.showWarning = function (this: InteractiveModeBase, message: string, ...rest: unknown[]): void {\n\t\t\t(showWarning as (...args: unknown[]) => void).call(this, message, ...rest);\n\t\t\tconst target = rest[0];\n\t\t\tif (agentShown() && (target === undefined || target === mode.chatContainer)) mirror(\"warning\", message);\n\t\t};\n\t\town.showError = function (this: InteractiveModeBase, message: string): void {\n\t\t\tshowError.call(this, message);\n\t\t\tif (agentShown()) mirror(\"error\", message);\n\t\t};\n\t\t// The jump to the latest row acts on what is shown.\n\t\town.jumpToTranscriptEnd = function (this: InteractiveModeBase): void {\n\t\t\tconst viewed = switcher.viewed;\n\t\t\tif (viewed.kind !== \"agent\") {\n\t\t\t\tjumpToTranscriptEnd.call(this);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tviewed.port.transcript.handleViewKey(TRANSCRIPT_JUMP_TO_END_URL);\n\t\t\tmode.ui.requestRender();\n\t\t};\n\t\treturn () => {\n\t\t\toffRenderer();\n\t\t\tremoveInput();\n\t\t\tfor (const name of overridden) {\n\t\t\t\tif (ownBefore.has(name)) own[name] = ownBefore.get(name);\n\t\t\t\telse delete own[name];\n\t\t\t}\n\t\t};\n\t};\n\tlet detach: (() => void) | undefined;\n\n\tconst offChange = switcher.onChange(({ to }) => {\n\t\tunwatchPort?.();\n\t\tunwatchPort = undefined;\n\t\tslot.clearNotices();\n\t\tslot.port = to.kind === \"agent\" ? to.port : undefined;\n\t\tif (to.kind === \"agent\") {\n\t\t\tdetach ??= attach();\n\t\t\tunwatchPort = to.port.subscribe(() => {\n\t\t\t\tsyncFocus();\n\t\t\t\tmode.ui.requestRender();\n\t\t\t});\n\t\t}\n\t\tconst tui = mode.ui as { resetTextSelection?(): void };\n\t\ttui.resetTextSelection?.();\n\t\tapplyLayout();\n\t\tsyncFocus();\n\t\tif (to.kind === \"main\") {\n\t\t\tdetach?.();\n\t\t\tdetach = undefined;\n\t\t}\n\t\tmode.ui.requestRender();\n\t});\n\tconst mirror = (kind: NoticeKind, text: string) => {\n\t\tslot.addNotice(kind, text);\n\t\tmode.ui.requestRender();\n\t};\n\t// Notices about the shown subagent alone (a refused command, its pause failing) are drawn under it only.\n\tsetViewedNoticeSink(mode, { show: (text, kind) => mirror(kind === \"info\" ? \"status\" : kind, text) });\n\n\treturn () => {\n\t\tsetViewedNoticeSink(mode, undefined);\n\t\toffChange();\n\t\tunwatchPort?.();\n\t\tdetach?.();\n\t\tdetach = undefined;\n\t\tif (agentShown()) {\n\t\t\tslot.port = undefined;\n\t\t\tconst tui = mode.ui;\n\t\t\tif (isViewportTUI(tui) && mode.fullscreenLayoutRoot !== undefined)\n\t\t\t\ttui.setLayoutRoot(mode.fullscreenLayoutRoot);\n\t\t}\n\t\tif (slots.get(mode) === slot) slots.delete(mode);\n\t};\n}\n"]}
1
+ {"version":3,"file":"transcript-slot.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/transcript-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,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G,SAAS,CAAC;QACnB,IAAI,UAAU,EAAE,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS;gBAChE,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\tisViewportTUI,\n\tstripHintMarkers,\n\tText,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n\tVStack,\n} from \"@bastani/atomic-tui\";\nimport { promptSlotDrewLive } from \"../components/prompt-slot.ts\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"../components/transcript-follow-indicator.ts\";\nimport { type InteractiveModeBase, isFullscreenViewportAction } from \"../interactive-mode-base.ts\";\nimport { screenHoldOf } from \"../screen-hold.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport type { AgentViewSwitcher } from \"./agent-view-switcher.ts\";\nimport type { AgentViewPort } from \"./contracts.ts\";\nimport { setViewedNoticeSink } from \"./viewed-notices.ts\";\n\n/** Rows the prompt, footer and panel take below the transcript before the first frame says how many they take. */\nconst ESTIMATED_DOCK_ROWS = 10;\n/** Notices kept at the bottom of a shown subagent's transcript; older ones leave as newer ones arrive. */\nconst MAX_NOTICES = 3;\n\ntype NoticeKind = \"status\" | \"warning\" | \"error\";\n\ninterface Notice {\n\treadonly kind: NoticeKind;\n\treadonly text: string;\n}\n\nfunction noticeText(notice: Notice): string {\n\tswitch (notice.kind) {\n\t\tcase \"status\":\n\t\t\treturn theme.fg(\"dim\", notice.text);\n\t\tcase \"warning\":\n\t\t\treturn theme.fg(\"warning\", `Warning: ${notice.text}`);\n\t\tcase \"error\":\n\t\t\treturn theme.fg(\"error\", `Error: ${notice.text}`);\n\t}\n}\n\n/** An SGR wheel report the transcript's own viewport reads, for a wheel turn over the transcript area. */\nfunction wheelReport(event: TuiMouseEvent): string {\n\tconst code = ((event.wheelDelta ?? 0) < 0 ? 64 : 65) | (event.alt ? 8 : 0);\n\treturn `\\x1b[<${code};${Math.max(1, Math.floor(event.x) + 1)};${Math.max(1, Math.floor(event.y) + 1)}M`;\n}\n\n/**\n * The transcript area while a subagent is shown: its transcript in the rows the screen gives it, and the screen's\n * status, warning and error notices below it, as the main chat adds them below its last message.\n */\nexport class AgentTranscriptSlot implements Component {\n\tport: AgentViewPort | undefined;\n\t/** The rows the transcript had in the last frame; undefined before one was drawn. */\n\ttranscriptRows: number | undefined;\n\t/** The rows the whole area had in the last frame, notices included. */\n\tpaintedRows: number | undefined;\n\tprivate notices: Notice[] = [];\n\tprivate readonly fallbackRows: () => number;\n\n\tconstructor(fallbackRows: () => number) {\n\t\tthis.fallbackRows = fallbackRows;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tconst port = this.port;\n\t\tif (height <= 0 || port === undefined) return [];\n\t\tconst noticeLines = this.renderNotices(width);\n\t\tconst notices = noticeLines.slice(Math.max(0, noticeLines.length - (height - 1)));\n\t\tconst rows = height - notices.length;\n\t\tconst transcript = port.transcript;\n\t\tconst drawn =\n\t\t\ttypeof transcript.renderSized === \"function\" ? transcript.renderSized(width, rows) : transcript.render(width);\n\t\tconst lines = drawn.length > rows ? drawn.slice(drawn.length - rows) : drawn;\n\t\tthis.transcriptRows = rows;\n\t\tthis.paintedRows = height;\n\t\treturn [...lines, ...Array.from({ length: rows - lines.length }, () => \"\"), ...notices];\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, Math.max(1, this.fallbackRows()));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.port?.transcript.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tconst transcript = this.port?.transcript;\n\t\tif (transcript === undefined || event.y < 0 || event.y >= (this.transcriptRows ?? 0)) return undefined;\n\t\tif (event.type === \"wheel\") return transcript.handleViewKey(wheelReport(event)) ? { handled: true } : undefined;\n\t\treturn transcript.handleMouse?.(event);\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\tif (row < 0 || row >= (this.transcriptRows ?? 0)) return undefined;\n\t\treturn this.port?.transcript.paintedRowKey?.(row);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.port?.transcript.invalidate();\n\t}\n\n\taddNotice(kind: NoticeKind, text: string): void {\n\t\tconst last = this.notices.at(-1);\n\t\t// A status replaces the status just before it, as the main chat's next status line does.\n\t\tif (kind === \"status\" && last?.kind === \"status\") this.notices[this.notices.length - 1] = { kind, text };\n\t\telse this.notices.push({ kind, text });\n\t\tif (this.notices.length > MAX_NOTICES) this.notices.splice(0, this.notices.length - MAX_NOTICES);\n\t}\n\n\tclearNotices(): void {\n\t\tthis.notices = [];\n\t}\n\n\tprivate renderNotices(width: number): string[] {\n\t\tif (this.notices.length === 0) return [];\n\t\tconst lines = [\"\"];\n\t\tfor (const notice of this.notices) lines.push(...new Text(noticeText(notice), 1, 0).render(width));\n\t\treturn lines;\n\t}\n}\n\n/** An OSC 8 hyperlink's opening or closing sequence. */\nconst HYPERLINK = /\\x1b\\]8;[^\\x07\\x1b]*(?:\\x07|\\x1b\\\\)/g;\n/** What the renderer ends every row it writes with; it adds it again to the held rows. */\nconst ROW_END = \"\\x1b[0m\\x1b]8;;\\x07\";\n\n/** A row as the screen showed it, without its links: drawn again, it writes the same text and styles. */\nfunction heldRow(line: string): string {\n\tconst row = line.endsWith(ROW_END) ? line.slice(0, -ROW_END.length) : line;\n\treturn stripHintMarkers(row).replace(HYPERLINK, \"\");\n}\n\n/**\n * The rows the dock below the transcript painted last, drawn in its place while it is held. They are only text, with\n * no links or clickable hints left in them: what they acted on is gone. A press on them shows the dock live and does\n * nothing else; a frame of another size than the one they were painted in ends the hold too.\n */\nclass HeldDockRows implements Component {\n\tprivate readonly lines: string[];\n\t/** Whether the screen is still the one the rows were painted on, at the same size. */\n\tprivate readonly sameScreen: (width: number) => boolean;\n\t/** The dock drawn live: unseen while held, and shown for a frame of another size before the hold has ended. */\n\tprivate readonly live: (width: number) => string[];\n\tprivate readonly onEnd: () => void;\n\n\tconstructor(\n\t\tlines: string[],\n\t\tsameScreen: (width: number) => boolean,\n\t\tlive: (width: number) => string[],\n\t\tonEnd: () => void,\n\t) {\n\t\tthis.lines = lines.map(heldRow);\n\t\tthis.sameScreen = sameScreen;\n\t\tthis.live = live;\n\t\tthis.onEnd = onEnd;\n\t}\n\n\trender(width: number): string[] {\n\t\t// The live dock is drawn too, unseen: what it shows from the engine (the panel) asks for its frames now, and\n\t\t// has them when the hold ends rather than one paint later.\n\t\tconst live = this.live(width);\n\t\tif (this.sameScreen(width)) return this.lines;\n\t\tthis.onEnd();\n\t\treturn live;\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\t// A wheel turn scrolls as it does over the live dock.\n\t\tif (event.type === \"wheel\") return undefined;\n\t\tif (event.type !== \"press\") return { handled: true, render: false };\n\t\tthis.onEnd();\n\t\t// The release comes back here: it is not a click on whatever is drawn live under the pointer by then.\n\t\treturn { capture: true };\n\t}\n\n\tinvalidate(): void {}\n}\n\n/** What is below the transcript: drawn live, or held as painted while a subagent `/tasks` opened is on its way. */\ntype DockState =\n\t| { readonly kind: \"live\" }\n\t| {\n\t\t\treadonly kind: \"held\";\n\t\t\t/** Which hold this is: its release names it by number, so it keeps nothing of the held rows alive. */\n\t\t\treadonly hold: number;\n\t\t\treadonly rows: HeldDockRows;\n\t\t\treadonly timer: ReturnType<typeof setTimeout>;\n\t\t\t/** Stops listening for a replaced renderer, which ends the hold. */\n\t\t\treadonly offRenderer: () => void;\n\t\t\t/** Tells the screen's hold that this one ended. */\n\t\t\treadonly ended: () => void;\n\t\t\t/** The layout root while held, for the transcript part it was made with. */\n\t\t\troot: { readonly part: Component; readonly root: Component } | undefined;\n\t };\n\nconst slots = new WeakMap<InteractiveModeBase, AgentTranscriptSlot>();\nconst dockHolds = new WeakMap<InteractiveModeBase, (timeoutMs: number) => () => void>();\n\n/**\n * Keep the dock below the transcript (prompt, footer, panel) as it was painted, at most `timeoutMs`, while the\n * transcript above keeps drawing live: `/tasks` closes while the subagent it opens is on its way, and the main chat's\n * prompt is not painted in between. A key press, a press on the held rows, another size or renderer, and the\n * answered release show it live again. Only the fullscreen renderer holds; answers the release.\n */\nexport function holdTranscriptDock(mode: InteractiveModeBase, timeoutMs: number): () => void {\n\treturn dockHolds.get(mode)?.(timeoutMs) ?? (() => {});\n}\n\nfunction focusedComponent(mode: InteractiveModeBase): object | null | undefined {\n\treturn (mode.ui as { getFocusedComponent?(): object | null }).getFocusedComponent?.();\n}\n\n/** The rows a subagent's transcript is drawn in on `mode`'s screen: those of the last frame, else an estimate. */\nexport function transcriptSlotRows(mode: InteractiveModeBase): number {\n\treturn slots.get(mode)?.transcriptRows ?? Math.max(1, mode.ui.terminal.rows - ESTIMATED_DOCK_ROWS);\n}\n\n/**\n * Draw the viewed subagent's transcript where the main transcript is, and main's again when main is shown. While a\n * subagent is shown, the mode's status, warning and error notices, which stay main's, are also drawn at the bottom of\n * its transcript, as are the notices about it alone (`notifyViewed`). Answers the uninstall.\n */\nexport function installTranscriptSlot(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tconst slot = new AgentTranscriptSlot(() => Math.max(1, mode.ui.terminal.rows - ESTIMATED_DOCK_ROWS));\n\tslots.set(mode, slot);\n\tlet agentRoot: Component | undefined;\n\tlet unwatchPort: (() => void) | undefined;\n\tlet dock: DockState = { kind: \"live\" };\n\tlet holds = 0;\n\tconst agentShown = () => switcher.viewed.kind === \"agent\";\n\n\t/** The question form of a held prompt takes the keys while it is open; the prompt has them otherwise. */\n\tconst syncFocus = () => {\n\t\tconst viewed = switcher.viewed;\n\t\tconst wantsSlot = viewed.kind === \"agent\" && viewed.port.transcript.capturesInput();\n\t\tconst focused = focusedComponent(mode);\n\t\tif (wantsSlot && focused === mode.editor) mode.ui.setFocus(slot);\n\t\telse if (!wantsSlot && focused === slot) mode.ui.setFocus(mode.editor);\n\t};\n\n\t/** Install the layout of what is shown: the agent root over the same dock, or main's own root object again. */\n\tconst applyLayout = () => {\n\t\tconst tui = mode.ui;\n\t\tconst shown = agentShown();\n\t\tif (isViewportTUI(tui)) {\n\t\t\tconst held = dock;\n\t\t\tconst part = shown ? slot : mode.transcriptScrollView;\n\t\t\tif (held.kind === \"held\" && part !== undefined) {\n\t\t\t\tif (held.root?.part !== part)\n\t\t\t\t\theld.root = {\n\t\t\t\t\t\tpart,\n\t\t\t\t\t\troot: new VStack([\n\t\t\t\t\t\t\t{ component: part, basis: 0, grow: 1, shrink: 1, minSize: 1 },\n\t\t\t\t\t\t\t{ component: held.rows, basis: \"auto\", grow: 0, shrink: 1, minSize: 1 },\n\t\t\t\t\t\t]),\n\t\t\t\t\t};\n\t\t\t\ttui.setLayoutRoot(held.root.root);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (shown && mode.fullscreenDock !== undefined) {\n\t\t\t\tagentRoot ??= new VStack([\n\t\t\t\t\t{ component: slot, basis: 0, grow: 1, shrink: 1, minSize: 1 },\n\t\t\t\t\t{ component: mode.fullscreenDock, basis: \"auto\", grow: 0, shrink: 1, minSize: 1 },\n\t\t\t\t]);\n\t\t\t\ttui.setLayoutRoot(agentRoot);\n\t\t\t} else if (mode.fullscreenLayoutRoot !== undefined) tui.setLayoutRoot(mode.fullscreenLayoutRoot);\n\t\t\treturn;\n\t\t}\n\t\t// The main-screen renderer draws its children in order: the transcript area is the document's place.\n\t\tconst children = tui.children;\n\t\tconst at = children.indexOf(shown ? mode.documentContainer : slot);\n\t\tif (at >= 0) children[at] = shown ? slot : mode.documentContainer;\n\t};\n\n\t/**\n\t * What the screen does differently while a subagent is shown, attached when one is first shown and detached when\n\t * main is again: with main shown the mode has nothing of this, exactly as before.\n\t */\n\tconst attach = (): (() => void) => {\n\t\t// A replaced renderer starts on main's root; a shown subagent keeps its place.\n\t\tconst offRenderer = mode.onTuiRendererChange(() => {\n\t\t\tif (agentShown()) applyLayout();\n\t\t});\n\t\t// Scroll keys go to the shown transcript, as they go to main's while main is shown. The screen's own viewport\n\t\t// declines them meanwhile (`shouldHandleViewportInput`).\n\t\tconst removeInput = mode.addTuiInputListener((data) => {\n\t\t\tconst viewed = switcher.viewed;\n\t\t\tif (viewed.kind !== \"agent\" || focusedComponent(mode) !== mode.editor) return undefined;\n\t\t\tif (!isFullscreenViewportAction(data, mode.keybindings)) return undefined;\n\t\t\tif (!isKeyRelease(data)) viewed.port.transcript.handleViewKey(data);\n\t\t\tmode.ui.requestRender();\n\t\t\treturn { consume: true };\n\t\t});\n\t\tconst own = mode as unknown as Record<string, unknown>;\n\t\tconst overridden = [\"showStatus\", \"showWarning\", \"showError\", \"jumpToTranscriptEnd\"] as const;\n\t\tconst ownBefore = new Map(\n\t\t\toverridden.filter((name) => Object.hasOwn(mode, name)).map((name) => [name, own[name]] as const),\n\t\t);\n\t\tconst showStatus = mode.showStatus;\n\t\tconst showWarning = mode.showWarning;\n\t\tconst showError = mode.showError;\n\t\tconst jumpToTranscriptEnd = mode.jumpToTranscriptEnd;\n\t\t// Main's notices stay main's, rows in its transcript as before; while a subagent is shown they are also drawn\n\t\t// under its transcript, where the reader is looking.\n\t\town.showStatus = function (this: InteractiveModeBase, message: string, ...rest: unknown[]): void {\n\t\t\t(showStatus as (...args: unknown[]) => void).call(this, message, ...rest);\n\t\t\tif (agentShown()) mirror(\"status\", message);\n\t\t};\n\t\town.showWarning = function (this: InteractiveModeBase, message: string, ...rest: unknown[]): void {\n\t\t\t(showWarning as (...args: unknown[]) => void).call(this, message, ...rest);\n\t\t\tconst target = rest[0];\n\t\t\tif (agentShown() && (target === undefined || target === mode.chatContainer)) mirror(\"warning\", message);\n\t\t};\n\t\town.showError = function (this: InteractiveModeBase, message: string): void {\n\t\t\tshowError.call(this, message);\n\t\t\tif (agentShown()) mirror(\"error\", message);\n\t\t};\n\t\t// The jump to the latest row acts on what is shown.\n\t\town.jumpToTranscriptEnd = function (this: InteractiveModeBase): void {\n\t\t\tconst viewed = switcher.viewed;\n\t\t\tif (viewed.kind !== \"agent\") {\n\t\t\t\tjumpToTranscriptEnd.call(this);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tviewed.port.transcript.handleViewKey(TRANSCRIPT_JUMP_TO_END_URL);\n\t\t\tmode.ui.requestRender();\n\t\t};\n\t\treturn () => {\n\t\t\toffRenderer();\n\t\t\tremoveInput();\n\t\t\tfor (const name of overridden) {\n\t\t\t\tif (ownBefore.has(name)) own[name] = ownBefore.get(name);\n\t\t\t\telse delete own[name];\n\t\t\t}\n\t\t};\n\t};\n\tlet detach: (() => void) | undefined;\n\n\tconst endDockHold = (held: DockState, key?: string) => {\n\t\tif (dock !== held || held.kind !== \"held\") return;\n\t\tclearTimeout(held.timer);\n\t\theld.offRenderer();\n\t\tdock = { kind: \"live\" };\n\t\theld.ended();\n\t\tapplyLayout();\n\t\t// A scroll key that ends it is handled next by the screen, against its layout: laid out only at the next paint,\n\t\t// it would find none to move. Any other key draws its own frame once it is handled.\n\t\tif (key !== undefined && isFullscreenViewportAction(key, mode.keybindings)) mode.ui.renderNow();\n\t\telse mode.ui.requestRender();\n\t};\n\t// The screen's hold, which also ends a held dock on the user's key press (the startup input listeners call it before\n\t// any other key handler). Clicks and wheel turns reach the screen as painted: the transcript above is live, the held\n\t// rows are inert.\n\tconst screenHold = screenHoldOf(mode);\n\tdockHolds.set(mode, (timeoutMs) =>\n\t\tscreenHold.begin(\"dock\", (ended) => {\n\t\t\tconst tui = mode.ui;\n\t\t\tconst screen = (tui as { getScreenLines?(): string[] }).getScreenLines?.();\n\t\t\tconst rows = tui.terminal.rows;\n\t\t\tconst top = agentShown() ? slot.paintedRows : mode.transcriptScrollView?.viewportHeight;\n\t\t\tif (\n\t\t\t\tdock.kind === \"held\" ||\n\t\t\t\t!isViewportTUI(tui) ||\n\t\t\t\t// An overlay over the screen is in the rows too; the screen without it is not what they show.\n\t\t\t\ttui.hasOverlay() ||\n\t\t\t\tmode.fullscreenDock === undefined ||\n\t\t\t\tscreen === undefined ||\n\t\t\t\tscreen.length !== rows ||\n\t\t\t\ttop === undefined ||\n\t\t\t\ttop < 1 ||\n\t\t\t\ttop >= rows ||\n\t\t\t\t// Only rows painted from live content are kept: not the prompt's held rows, nor a panel yet to draw.\n\t\t\t\t(mode.editorContainer !== undefined && !promptSlotDrewLive(mode.editorContainer))\n\t\t\t)\n\t\t\t\treturn undefined;\n\t\t\tconst hold = ++holds;\n\t\t\tconst end = (key?: string) => {\n\t\t\t\tif (dock.kind === \"held\" && dock.hold === hold) endDockHold(dock, key);\n\t\t\t};\n\t\t\tconst timer = setTimeout(end, timeoutMs);\n\t\t\ttimer.unref?.();\n\t\t\tconst columns = tui.terminal.columns;\n\t\t\tconst fullscreenDock = mode.fullscreenDock;\n\t\t\tdock = {\n\t\t\t\tkind: \"held\",\n\t\t\t\thold,\n\t\t\t\trows: new HeldDockRows(\n\t\t\t\t\tscreen.slice(top),\n\t\t\t\t\t(width) => width === columns && tui.terminal.columns === columns && tui.terminal.rows === rows,\n\t\t\t\t\t(width) => fullscreenDock.render(width),\n\t\t\t\t\t() => queueMicrotask(end),\n\t\t\t\t),\n\t\t\t\ttimer,\n\t\t\t\toffRenderer: mode.onTuiRendererChange(end),\n\t\t\t\tended,\n\t\t\t\troot: undefined,\n\t\t\t};\n\t\t\tapplyLayout();\n\t\t\treturn end;\n\t\t}),\n\t);\n\n\tconst offChange = switcher.onChange(({ to }) => {\n\t\tunwatchPort?.();\n\t\tunwatchPort = undefined;\n\t\tslot.clearNotices();\n\t\tslot.port = to.kind === \"agent\" ? to.port : undefined;\n\t\tif (to.kind === \"agent\") {\n\t\t\tdetach ??= attach();\n\t\t\tunwatchPort = to.port.subscribe(() => {\n\t\t\t\tsyncFocus();\n\t\t\t\tmode.ui.requestRender();\n\t\t\t});\n\t\t}\n\t\tconst tui = mode.ui as { resetTextSelection?(): void };\n\t\ttui.resetTextSelection?.();\n\t\tapplyLayout();\n\t\tsyncFocus();\n\t\tif (to.kind === \"main\") {\n\t\t\tdetach?.();\n\t\t\tdetach = undefined;\n\t\t}\n\t\tmode.ui.requestRender();\n\t});\n\tconst mirror = (kind: NoticeKind, text: string) => {\n\t\tslot.addNotice(kind, text);\n\t\tmode.ui.requestRender();\n\t};\n\t// Notices about the shown subagent alone (a refused command, its pause failing) are drawn under it only.\n\tsetViewedNoticeSink(mode, { show: (text, kind) => mirror(kind === \"info\" ? \"status\" : kind, text) });\n\n\treturn () => {\n\t\tendDockHold(dock);\n\t\tif (dockHolds.get(mode) !== undefined && slots.get(mode) === slot) dockHolds.delete(mode);\n\t\tsetViewedNoticeSink(mode, undefined);\n\t\toffChange();\n\t\tunwatchPort?.();\n\t\tdetach?.();\n\t\tdetach = undefined;\n\t\tif (agentShown()) {\n\t\t\tslot.port = undefined;\n\t\t\tconst tui = mode.ui;\n\t\t\tif (isViewportTUI(tui) && mode.fullscreenLayoutRoot !== undefined)\n\t\t\t\ttui.setLayoutRoot(mode.fullscreenLayoutRoot);\n\t\t}\n\t\tif (slots.get(mode) === slot) slots.delete(mode);\n\t};\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { type AgentPanelItem, type AgentPanelState } from "../../../core/tasks/agent-panel-source.ts";
2
2
  import type { TaskId } from "../../../core/tasks/contracts.js";
3
+ import type { ModelColumn } from "./model-column.ts";
3
4
  import { type NavKey, type NavKeybindings, type NavKeyStyle, TwoPressConfirm } from "./nav-keys.ts";
4
5
  export type AgentPanelRow = AgentPanelItem;
5
6
  export type { AgentPanelState };
@@ -91,6 +92,11 @@ export interface AgentPanelRenderOptions {
91
92
  readonly viewedId?: string;
92
93
  /** Shell rows are a subagent's own shells, listed right under it: they are indented one step. */
93
94
  readonly nestShells?: boolean;
95
+ /**
96
+ * The open panel's model column: a row whose model became known while shown waits for its reasoning level, and the
97
+ * column does not narrow while it fits. Without it, each row shows its model as soon as it is known.
98
+ */
99
+ readonly modelColumn?: ModelColumn;
94
100
  }
95
101
  /** The main-chat row leads the panel whenever it lists a subagent. */
96
102
  export declare function panelShowsMain(rows: readonly Pick<AgentPanelRow, "kind">[]): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-panel.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/agent-panel.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EAIpB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAU/D,OAAO,EAEN,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,WAAW,EAGhB,eAAe,EACf,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,kGAAkG;AAClG,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,uGAAuG;AACvG,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAI9C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IACnD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAk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,CAAC;IACnC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA8B;IAC9D,OAAO,CAAC,oBAAoB,CAAS;IACrC,sGAAsG;IACtG,IAAI,QAAQ,IAAI,OAAO,CAEtB;IACD,WAAW,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAIhD;IACD,MAAM,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CA+B3C;IACD,qGAAqG;IACrG,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAatB;IACD,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAK7B;IACD,OAAO,CAAC,QAAQ;IAIhB,QAAQ,IAAI,aAAa,GAAG,SAAS,CAEpC;IACD,cAAc,IAAI,SAAS,GAAG,aAAa,CAE1C;IACD,WAAW,IAAI,aAAa,GAAG,SAAS,CAGvC;IACD,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,OAAO;IAGf,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,IAAI;IAMZ,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAsF7E;CACD;AAED,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,cAAc,GAAG,SAAS,GACrC,MAAM,CAwBR;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,MAAM,GAAG,SAAS,CAE9E"}
@@ -1,7 +1,7 @@
1
1
  import { truncateToWidth, visibleWidth } from "@bastani/atomic-tui";
2
2
  import { formatModelLabel } from "../../../core/model-label.js";
3
3
  import { isActivePanelState, isRestingPanelRow, panelRowListed } from "../../../core/tasks/agent-panel-rules.js";
4
- import { agentPanelTaskId, isInterruptedPanelTask, markInterruptedPanelTask, } from "../../../core/tasks/agent-panel-source.js";
4
+ import { agentPanelTaskId, isInterruptedPanelTask, markInterruptedPanelTask, modelHasReasoning, } from "../../../core/tasks/agent-panel-source.js";
5
5
  import { bindTaskClock, shownSpanMs, TaskElapsedClocks, taskClockOf, taskClockRunning, } from "../../../core/tasks/live-elapsed.js";
6
6
  import { getGlobalTheme } from "../theme/global-theme.js";
7
7
  import { ATOMIC_WORKING_FRAMES, atomicWorkingGlyph } from "./atomic-working-status.js";
@@ -388,6 +388,14 @@ function rightColumn(row, width) {
388
388
  const word = stateWord(row);
389
389
  return elapsed.length > 0 ? `${word} · ${elapsed}` : word;
390
390
  }
391
+ /** What a panel row reports to its view's `ModelColumn`, given its model column text `label`. */
392
+ function panelModelReport(row, label) {
393
+ return {
394
+ model: label.length > 0 && typeof row.model === "string" ? row.model : undefined,
395
+ settled: Boolean(row.thinking) || isFinishedPanelRow(row),
396
+ levelless: () => typeof row.model === "string" && modelHasReasoning(taskClockOf(row) ?? row, row.model) === false,
397
+ };
398
+ }
391
399
  /** The cells a nested shell row is indented by. */
392
400
  const NESTED_INDENT = 2;
393
401
  /** The main-chat row leads the panel whenever it lists a subagent. */
@@ -418,26 +426,48 @@ export function renderAgentPanelRows(rows, width, style, options = {}) {
418
426
  const span = nested(raw) ? w + NESTED_INDENT : w;
419
427
  if (span > nameWidth)
420
428
  nameWidth = span < 14 ? span : 14;
421
- const model = width >= AGENT_PANEL_MODEL_MIN_WIDTH ? panelModelText(raw) : "";
422
- models[i] = model;
423
- if (model.length > 0)
424
- modelWidth = Math.max(modelWidth, cellWidth(model));
429
+ models[i] = width >= AGENT_PANEL_MODEL_MIN_WIDTH ? panelModelText(raw) : "";
425
430
  tasks[i] = panelText(raw.task);
426
431
  rights[i] = rightColumn(raw, width);
427
432
  queues[i] = Number.isSafeInteger(raw.queued) && (raw.queued ?? 0) > 0 ? ` · ${raw.queued} queued` : undefined;
428
433
  }
434
+ const modelColumn = options.modelColumn;
435
+ // The widest label as the rows report it: a label still waiting for its level counts for whether any column fits.
436
+ let widest = 0;
437
+ for (const model of models)
438
+ if (model.length > 0)
439
+ widest = Math.max(widest, cellWidth(model));
440
+ // Too narrow for the column: the rows are seen afresh once it is wide enough again, as on a first paint.
441
+ if (modelColumn !== undefined && !(width >= AGENT_PANEL_MODEL_MIN_WIDTH))
442
+ modelColumn.forget();
443
+ else if (modelColumn !== undefined) {
444
+ const showing = modelColumn.paint(shown.map((row, i) => [row.id, panelModelReport(row, models[i])]), rows);
445
+ for (let i = 0; i < count; i++)
446
+ if (!showing.has(shown[i].id))
447
+ models[i] = "";
448
+ }
449
+ for (const model of models)
450
+ if (model.length > 0)
451
+ modelWidth = Math.max(modelWidth, cellWidth(model));
429
452
  // The model column shows only while every row keeps its whole right column and some of its task beside it. A nested
430
453
  // row's indent is inside the name column, so `nameWidth` spans it.
431
- if (modelWidth > 0) {
432
- const fixed = 6 + nameWidth + modelWidth + 2;
433
- for (let i = 0; i < count && modelWidth > 0; i++) {
454
+ const modelFits = (column) => {
455
+ const fixed = 6 + nameWidth + column + 2;
456
+ for (let i = 0; i < count; i++) {
434
457
  const queued = queues[i];
435
458
  const rightWidth = cellWidth(queued === undefined ? rights[i] : rights[i] + queued);
436
459
  const taskRoom = width - fixed - rightWidth - 2;
437
460
  if (fixed + rightWidth + 1 > width || (tasks[i].length > 0 && taskRoom < MIN_TASK_WIDTH))
438
- modelWidth = 0;
461
+ return false;
439
462
  }
440
- }
463
+ return true;
464
+ };
465
+ // An open panel's column does not narrow while it fits (`ModelColumn.column`).
466
+ const fits = (column) => width >= AGENT_PANEL_MODEL_MIN_WIDTH && modelFits(column);
467
+ if (modelColumn !== undefined)
468
+ modelWidth = modelColumn.column(width, modelWidth, fits, widest);
469
+ else if (modelWidth > 0 && !fits(modelWidth))
470
+ modelWidth = 0;
441
471
  const viewing = options.viewedId !== undefined;
442
472
  const lines = [];
443
473
  const line = (id, glyphText, name, knownNameWidth, task, right, dim, queued, model, indent = 0) => {