@bastani/atomic 0.10.19-alpha.1 → 0.10.20-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 (331) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/_shared/adapter-open-DXXV6ATH.js +22 -0
  3. package/dist/_shared/adapter-open-DXXV6ATH.js.map +1 -0
  4. package/dist/_shared/dist-KOELCESV.js +2 -2
  5. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  6. package/dist/_shared/lib-4PES5P4V.js +2 -2
  7. package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js +439 -217
  8. package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js.map +1 -1
  9. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +19 -11
  10. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
  11. package/dist/_shared/mode-shared-2QJSCUM6.js +9 -9
  12. package/dist/_shared/p0-cli-BB45ZQY6.js +2 -2
  13. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  14. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  15. package/dist/_shared/{sdk-BHX35EPK.js → sdk-5ZFNDXUJ.js} +119 -40
  16. package/dist/_shared/sdk-5ZFNDXUJ.js.map +1 -0
  17. package/dist/_shared/session-data-AHTU7IS6.js +5 -4
  18. package/dist/_shared/session-data-AHTU7IS6.js.map +1 -1
  19. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  20. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -1
  21. package/dist/_shared/{startup-0-0-4EDVBK5P.js → startup-0-0-FPPQF42L.js} +69 -26
  22. package/dist/_shared/startup-0-0-FPPQF42L.js.map +1 -0
  23. package/dist/_shared/{startup-0-1-H5IXVRXQ.js → startup-0-1-Q7GBLBEL.js} +158 -37
  24. package/dist/_shared/startup-0-1-Q7GBLBEL.js.map +1 -0
  25. package/dist/_shared/{startup-0-2-YZZOC22D.js → startup-0-2-JNYN24UI.js} +40 -6
  26. package/dist/_shared/startup-0-2-JNYN24UI.js.map +1 -0
  27. package/dist/_shared/startup-0-3-DE2NCS6A.js +26 -41
  28. package/dist/_shared/startup-0-3-DE2NCS6A.js.map +1 -1
  29. package/dist/_shared/{startup-0-4-ZMJV547D.js → startup-0-4-ZZXFKE55.js} +85 -19
  30. package/dist/_shared/startup-0-4-ZZXFKE55.js.map +1 -0
  31. package/dist/_shared/{startup-0-5-HZX3ZPTP.js → startup-0-5-WN2IYA25.js} +112 -15
  32. package/dist/_shared/startup-0-5-WN2IYA25.js.map +1 -0
  33. package/dist/_shared/{startup-10-0-TDQNBDDL.js → startup-10-0-O6DAT7U4.js} +65 -117
  34. package/dist/_shared/startup-10-0-O6DAT7U4.js.map +1 -0
  35. package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
  36. package/dist/_shared/startup-14-0-MLX36RBG.js +8 -5
  37. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  38. package/dist/_shared/{startup-15-0-YUKGAC63.js → startup-15-0-E7RYG5YF.js} +8 -8
  39. package/dist/_shared/{startup-15-0-YUKGAC63.js.map → startup-15-0-E7RYG5YF.js.map} +1 -1
  40. package/dist/_shared/startup-15-1-WQZBOTMZ.js +73 -28
  41. package/dist/_shared/startup-15-1-WQZBOTMZ.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +31 -21
  43. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  44. package/dist/_shared/startup-8-1-QZMXUGHI.js +34 -24
  45. package/dist/_shared/startup-8-1-QZMXUGHI.js.map +1 -1
  46. package/dist/_shared/storage-command-7MGXLJGZ.js +9 -5
  47. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  48. package/dist/_shared/{storage-status-K7PX2RXA.js → storage-status-T6FUXRIM.js} +7 -23
  49. package/dist/_shared/{storage-status-K7PX2RXA.js.map → storage-status-T6FUXRIM.js.map} +1 -1
  50. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  51. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  52. package/dist/_shared/team-DOQKICG2.js +3 -2
  53. package/dist/_shared/team-DOQKICG2.js.map +1 -1
  54. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  55. package/dist/binary-self-update.js +47 -18
  56. package/dist/binary-self-update.js.map +1 -1
  57. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  58. package/dist/builtin/intercom/package.json +1 -1
  59. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  60. package/dist/builtin/mcp/package.json +1 -1
  61. package/dist/builtin/subagents/CHANGELOG.md +15 -0
  62. package/dist/builtin/subagents/package.json +1 -1
  63. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  64. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  65. package/dist/builtin/web-access/package.json +1 -1
  66. package/dist/cli/args.js +2 -2
  67. package/dist/cli/auth-cli.code.js +5 -5
  68. package/dist/cli/auth-cli.impl.js +3 -3
  69. package/dist/cli/auth-cli.js +3 -3
  70. package/dist/cli/blueprint-command.code.js +3 -3
  71. package/dist/cli/blueprint-command.impl.js +3 -3
  72. package/dist/cli/blueprint-command.js +3 -3
  73. package/dist/cli/intercom-command.code.js +3 -3
  74. package/dist/cli/intercom-command.impl.js +3 -3
  75. package/dist/cli/intercom-command.js +3 -3
  76. package/dist/cli/list-models.code.js +3 -3
  77. package/dist/cli/list-models.impl.js +3 -3
  78. package/dist/cli/list-models.js +3 -3
  79. package/dist/cli/session-picker.code.js +2 -2
  80. package/dist/cli/session-picker.impl.js +3 -3
  81. package/dist/cli/session-picker.js +3 -3
  82. package/dist/cli/startup-ui.code.js +2 -2
  83. package/dist/cli/startup-ui.impl.js +3 -3
  84. package/dist/cli/startup-ui.js +3 -3
  85. package/dist/cli/storage-command.impl.js +3 -3
  86. package/dist/cli/storage-command.js +3 -3
  87. package/dist/cli/storage-search-session.code.js +2 -2
  88. package/dist/cli/storage-search-session.impl.js +3 -3
  89. package/dist/cli/storage-search-session.js +3 -3
  90. package/dist/cli/team-command.code.js +3 -3
  91. package/dist/cli/team-command.impl.js +3 -3
  92. package/dist/cli/team-command.js +3 -3
  93. package/dist/cli.js +2 -2
  94. package/dist/core/agent-session-runtime.d.ts +2 -1
  95. package/dist/core/debug.impl.js +3 -3
  96. package/dist/core/debug.js +3 -3
  97. package/dist/core/export-html/card-projection.code.js +1 -1
  98. package/dist/core/export-html/card-projection.impl.js +3 -3
  99. package/dist/core/export-html/card-projection.js +3 -3
  100. package/dist/core/export-html/index.code.js +44 -41
  101. package/dist/core/export-html/index.code.js.map +1 -1
  102. package/dist/core/export-html/index.impl.js +3 -3
  103. package/dist/core/export-html/index.js +3 -3
  104. package/dist/core/export-html/json-spans.impl.js +3 -3
  105. package/dist/core/export-html/json-spans.js +3 -3
  106. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  107. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  108. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  109. package/dist/core/export-html/template.js +12 -25
  110. package/dist/core/export-html/tool-renderer.code.js +1 -1
  111. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  112. package/dist/core/export-html/tool-renderer.js +3 -3
  113. package/dist/core/extensions/context-types.d.ts +3 -0
  114. package/dist/core/extensions/context-types.js.map +1 -1
  115. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  116. package/dist/core/extensions/jiti-loader.js +3 -3
  117. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  118. package/dist/core/extensions/jiti-static-loader.js +3 -3
  119. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  120. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  121. package/dist/core/extensions/loader-host-modules.js +3 -3
  122. package/dist/core/extensions/loader-virtual-modules.js +2 -2
  123. package/dist/core/extensions/runner-context.d.ts +1 -0
  124. package/dist/core/extensions/runner-context.js +17 -1
  125. package/dist/core/extensions/runner-context.js.map +1 -1
  126. package/dist/core/extensions/runner.d.ts +1 -0
  127. package/dist/core/extensions/runtime-types.d.ts +1 -0
  128. package/dist/core/extensions/runtime-types.js.map +1 -1
  129. package/dist/core/intercom-broker-control-host.code.js +1 -1
  130. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  131. package/dist/core/intercom-broker-control-host.js +3 -3
  132. package/dist/core/intercom-broker-control.code.js +3 -3
  133. package/dist/core/intercom-broker-control.impl.js +3 -3
  134. package/dist/core/intercom-broker-control.js +3 -3
  135. package/dist/core/model-registry.js +2 -2
  136. package/dist/core/model-runtime-streaming.d.ts +3 -1
  137. package/dist/core/model-runtime.d.ts +2 -0
  138. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  139. package/dist/core/package-manager-storage-adapters.js +3 -3
  140. package/dist/core/sdk.code.js +3 -3
  141. package/dist/core/sdk.impl.js +3 -3
  142. package/dist/core/sdk.js +3 -3
  143. package/dist/core/session-manager-core.d.ts +4 -0
  144. package/dist/core/session-manager-core.js +46 -18
  145. package/dist/core/session-manager-core.js.map +1 -1
  146. package/dist/core/session-manager-history.d.ts +1 -1
  147. package/dist/core/session-manager-list.impl.js +3 -3
  148. package/dist/core/session-manager-list.js +3 -3
  149. package/dist/core/session-manager.code.js +2 -2
  150. package/dist/core/session-manager.impl.js +3 -3
  151. package/dist/core/session-manager.js +3 -3
  152. package/dist/core/session-storage.impl.js +3 -3
  153. package/dist/core/session-storage.js +3 -3
  154. package/dist/core/settings-manager.js +1 -1
  155. package/dist/core/storage/adapter-open.js +3 -0
  156. package/dist/core/storage/adapter-open.js.map +1 -0
  157. package/dist/core/storage/index.js +2 -2
  158. package/dist/core/storage/node-sqlite-thread.js +2 -2
  159. package/dist/core/storage/node-sqlite.js +2 -2
  160. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  161. package/dist/core/storage/offline-snapshot-file.js +3 -3
  162. package/dist/core/storage/prefix.js +1 -0
  163. package/dist/core/storage/prefix.js.map +1 -1
  164. package/dist/core/storage/provider.js +2 -2
  165. package/dist/core/storage/selection.js +2 -2
  166. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  167. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  168. package/dist/core/storage/session/branch-fork-source.js +3 -3
  169. package/dist/core/storage/session/card-view.impl.js +3 -3
  170. package/dist/core/storage/session/card-view.js +3 -3
  171. package/dist/core/storage/session/child-reader.code.js +7 -7
  172. package/dist/core/storage/session/child-reader.code.js.map +1 -1
  173. package/dist/core/storage/session/child-reader.d.ts +1 -0
  174. package/dist/core/storage/session/child-reader.impl.js +3 -3
  175. package/dist/core/storage/session/child-reader.js +3 -3
  176. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  177. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  178. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  179. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  180. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  181. package/dist/core/storage/session/expanded-child-details.js +3 -3
  182. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  183. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  184. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  185. package/dist/core/storage/session/fork-row-index.js +3 -3
  186. package/dist/core/storage/session/fork-staging.code.js +2 -2
  187. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  188. package/dist/core/storage/session/fork-staging.js +3 -3
  189. package/dist/core/storage/session/fork-window.code.js +5 -4
  190. package/dist/core/storage/session/fork-window.code.js.map +1 -1
  191. package/dist/core/storage/session/fork-window.impl.js +3 -3
  192. package/dist/core/storage/session/fork-window.js +3 -3
  193. package/dist/core/storage/session/history-pages.impl.js +3 -3
  194. package/dist/core/storage/session/history-pages.js +3 -3
  195. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  196. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  197. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  198. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  199. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  200. package/dist/core/storage/session/memory-session-store.js +3 -3
  201. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  202. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  203. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  204. package/dist/core/storage/session/released-history-files.code.js +3 -3
  205. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  206. package/dist/core/storage/session/released-history-files.js +3 -3
  207. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  208. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  209. package/dist/core/storage/session/session-resume.impl.js +3 -3
  210. package/dist/core/storage/session/session-resume.js +3 -3
  211. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  212. package/dist/core/storage/session/snapshot-cut.js +3 -3
  213. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  214. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  215. package/dist/core/storage/session/snapshot-history.js +3 -3
  216. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  217. package/dist/core/storage/session/sql-session-store.d.ts +3 -17
  218. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  219. package/dist/core/storage/session/sql-session-store.js +3 -3
  220. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  221. package/dist/core/storage/session/tree-outline.js +3 -3
  222. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  223. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  224. package/dist/core/storage/session/tree-presentation.js +3 -3
  225. package/dist/core/storage/session/types.d.ts +2 -0
  226. package/dist/core/storage/session/usage-observations.d.ts +27 -0
  227. package/dist/core/storage/session/usage-observations.js +3 -0
  228. package/dist/core/storage/session/usage-observations.js.map +1 -0
  229. package/dist/core/storage/storage-status.code.js +1 -1
  230. package/dist/core/storage/storage-status.impl.js +3 -3
  231. package/dist/core/storage/storage-status.js +3 -3
  232. package/dist/core/storage/team.impl.js +3 -3
  233. package/dist/core/storage/team.js +3 -3
  234. package/dist/core/structured-output/index.code.js +1 -1
  235. package/dist/core/structured-output/index.impl.js +3 -3
  236. package/dist/core/structured-output/index.js +3 -3
  237. package/dist/core/subscription-usage-identity.d.ts +9 -0
  238. package/dist/core/subscription-usage-observations.d.ts +15 -0
  239. package/dist/core/subscription-usage-storage.js +3 -0
  240. package/dist/core/subscription-usage-storage.js.map +1 -0
  241. package/dist/core/subscription-usage.d.ts +20 -3
  242. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  243. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  244. package/dist/core/tasks/task-completion-entry.js +3 -3
  245. package/dist/core/tasks/task-file-history.code.js +3 -3
  246. package/dist/core/tasks/task-file-history.impl.js +3 -3
  247. package/dist/core/tasks/task-file-history.js +3 -3
  248. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  249. package/dist/core/tasks/task-reference-archive.js +3 -3
  250. package/dist/core/tasks/task-reference-identity.code.js +1 -1
  251. package/dist/core/tasks/task-reference-identity.js +3 -3
  252. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  253. package/dist/core/tasks/task-reference-stream.js +3 -3
  254. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  255. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  256. package/dist/core/tasks/task-view-source.impl.js +3 -3
  257. package/dist/core/tasks/task-view-source.js +3 -3
  258. package/dist/core/tools/read-url.code.js +2 -2
  259. package/dist/core/tools/read-url.impl.js +3 -3
  260. package/dist/core/tools/read-url.js +3 -3
  261. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  262. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  263. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  264. package/dist/core/worktree-snapshot/errors.js +3 -3
  265. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  266. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  267. package/dist/extensions/codemode/execute.code.js +2 -2
  268. package/dist/extensions/codemode/execute.impl.js +3 -3
  269. package/dist/extensions/codemode/execute.js +3 -3
  270. package/dist/extensions/codemode/renderer.code.js +2 -2
  271. package/dist/extensions/codemode/renderer.impl.js +3 -3
  272. package/dist/extensions/codemode/renderer.js +3 -3
  273. package/dist/extensions/mcp/cli.code.js +3 -3
  274. package/dist/extensions/mcp/cli.impl.js +3 -3
  275. package/dist/extensions/mcp/cli.js +3 -3
  276. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  277. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  278. package/dist/extensions/mcp/cli.lazy.js +3 -3
  279. package/dist/extensions/mcp/runtime.code.js +1 -1
  280. package/dist/extensions/mcp/runtime.impl.js +3 -3
  281. package/dist/extensions/mcp/runtime.js +3 -3
  282. package/dist/index.d.ts +1 -1
  283. package/dist/index.js +8 -8
  284. package/dist/main-first-time-setup.code.js +2 -2
  285. package/dist/main-first-time-setup.impl.js +3 -3
  286. package/dist/main-first-time-setup.js +3 -3
  287. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  288. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  289. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  290. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  291. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  292. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  293. package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -0
  294. package/dist/modes/interactive-engine/protocol.d.ts +4 -0
  295. package/dist/modes/print-mode.js +1 -1
  296. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  297. package/dist/modes/rpc/rpc-types.d.ts +5 -0
  298. package/dist/package-manager-cli.code.js +6 -6
  299. package/dist/package-manager-cli.impl.js +3 -3
  300. package/dist/package-manager-cli.js +3 -3
  301. package/dist/rpc-entry.js +1 -1
  302. package/dist/startup-files.json +1 -1
  303. package/dist/startup-stages/10.js +1 -1
  304. package/dist/startup-stages/4.js +1 -1
  305. package/dist/startup-stages/6.js +1 -1
  306. package/dist/startup-stages/7.js +1 -1
  307. package/dist/startup-stages/8.js +1 -1
  308. package/dist/utils/startup-database-spare.code.js +3 -3
  309. package/dist/utils/startup-database-spare.impl.js +3 -3
  310. package/dist/utils/startup-database-spare.js +3 -3
  311. package/dist/utils/tools-manager.code.js +1 -1
  312. package/dist/utils/tools-manager.impl.js +3 -3
  313. package/dist/utils/tools-manager.js +3 -3
  314. package/docs/changelog.mdx +31 -3
  315. package/docs/extensions/api-reference.md +6 -0
  316. package/docs/getting-started/installation.md +3 -3
  317. package/docs/guides/subscription-usage.md +28 -82
  318. package/docs/reference/cli.md +4 -2
  319. package/docs/rpc/protocol.md +30 -2
  320. package/docs/sdk/reference.md +26 -1
  321. package/docs/sessions.md +3 -1
  322. package/docs/slash-commands.md +1 -1
  323. package/docs/usage.md +1 -1
  324. package/package.json +8 -8
  325. package/dist/_shared/sdk-BHX35EPK.js.map +0 -1
  326. package/dist/_shared/startup-0-0-4EDVBK5P.js.map +0 -1
  327. package/dist/_shared/startup-0-1-H5IXVRXQ.js.map +0 -1
  328. package/dist/_shared/startup-0-2-YZZOC22D.js.map +0 -1
  329. package/dist/_shared/startup-0-4-ZMJV547D.js.map +0 -1
  330. package/dist/_shared/startup-0-5-HZX3ZPTP.js.map +0 -1
  331. package/dist/_shared/startup-10-0-TDQNBDDL.js.map +0 -1
@@ -1,18 +1,18 @@
1
1
  import { __name } from "./rolldown-runtime-BGM3D5V3.js";
2
2
  import { APP_NAME, APP_TITLE, CHANGELOG_URL, CONFIG_DIR_NAME, UpdatedInstallError, VERSION, VERSION_ADOPTION_ENDPOINT, canonicalizePathAsync, createChildProcessEnvironment, createModuleRequire, detectInstallChangeAsync, engineHeapRuntimeArgsForHost, findHelperExecutableAsync, getAgentDir, getAuthPath, getChangelogPath, getCwdRelativePath, getDebugLogPath, getDocsPath, getShareViewerUrl, helperLaunchAsync, isBunBinary, isModuleLoadFailure, loadOnDemand, markLifecycleTiming, missingHelperOptions, processCompileCacheDeferral, setDebugSetting, shortenHomePath, updatedInstallError } from "./p0-cli-BB45ZQY6.js";
3
- import { BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, CountdownTimer, DynamicBorder, MissingSessionCwdError, NO_QUEUED_MESSAGES, TrustDecisionSelector, asyncScope, carryRowSource, chatPosition, chatReceipt, deduplicateDiagnostics, fetchSubscriptionUsage, findProviderDefaultModel, formatAppendRecoveryNotice, formatMissingSessionCwdPrompt, formatNoModelsAvailableMessage, getEngineSessionStats, getMissingSessionCwdOptions, getPiUserAgent, isGitUnavailableError, isInstallTelemetryEnabled, isInteractiveEngineResourceReadinessError, isPathInside, isTrustDecision, isUnknownModel, keepDroppedQueuedMessages, markEventLoopShutdown, markEventLoopStartupComplete, noteRowSource, noteSavedSeq, onSessionProviderRequestDispatched, parseSlashCommand, placeTranscriptFrame, projectTrustWarningVisible, queuedMessagesUnderWay, quitAsInteractiveApp, raceWithAbortSignal, readSubscriptionCredential, recordStartupThinkingLevel, rowSource, safeTrustChoiceIndex, savedRowKey, savedSeqOf, setDeprecationWarningSink, setMarkitDiagnosticSink, shouldRenderEngineDiagnosticAsChatError, takeQueuedMessagesDroppedAt, usageCostBreakdown, userMessageOrigin, yieldToEventLoop, yieldToTimerTurn } from "./startup-0-0-4EDVBK5P.js";
4
- import { ExtensionInputComponent, ExtensionSelectorComponent, ReopenedCompletionHeaders, cancelInitialBinding, codexAccountId, createCustomMessage, ensurePngTranscoder, ensureTool, formatResumeTimings, formatToolStatus, getBuiltinExtensionEntryLabel, getPromptCacheTtlMs as getPromptCacheTtlMs$1, initialBindScope, isOfflineModeEnabled, isVerbatimCompactionMessage, isWorkspaceError, latestResumeTimings, normalizeMessageContent, normalizeModelFailureSignal, observedOpenAiDirectUsage, observedSubscriptionUsage, prewarmModelApi, readHostInputFormRequest, registerInitialBindings, stripVerbatimCompactionPrefix, subscriptionBearer, subscriptionCredentialKey, taskPromptHost, thinkingLevelForModelSwitch } from "./startup-0-1-H5IXVRXQ.js";
3
+ import { BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, CountdownTimer, DynamicBorder, MissingSessionCwdError, NO_QUEUED_MESSAGES, TrustDecisionSelector, asyncScope, carryRowSource, chatPosition, chatReceipt, deduplicateDiagnostics, fetchSubscriptionUsage, findProviderDefaultModel, formatAppendRecoveryNotice, formatMissingSessionCwdPrompt, formatNoModelsAvailableMessage, getEngineSessionStats, getMissingSessionCwdOptions, getPiUserAgent, isGitUnavailableError, isInstallTelemetryEnabled, isInteractiveEngineResourceReadinessError, isPathInside, isTrustDecision, isUnknownModel, keepDroppedQueuedMessages, markEventLoopShutdown, markEventLoopStartupComplete, noteRowSource, noteSavedSeq, onSessionProviderRequestDispatched, parseSlashCommand, placeTranscriptFrame, projectTrustWarningVisible, queuedMessagesUnderWay, quitAsInteractiveApp, raceWithAbortSignal, readSubscriptionCredential, recordStartupThinkingLevel, rowSource, safeTrustChoiceIndex, savedRowKey, savedSeqOf, sessionParent, setDeprecationWarningSink, setMarkitDiagnosticSink, shouldRenderEngineDiagnosticAsChatError, takeQueuedMessagesDroppedAt, usageCostBreakdown, userMessageOrigin, yieldToEventLoop, yieldToTimerTurn } from "./startup-0-0-FPPQF42L.js";
4
+ import { ExtensionInputComponent, ExtensionSelectorComponent, ReopenedCompletionHeaders, cancelInitialBinding, codexAccountId, createCustomMessage, ensurePngTranscoder, ensureTool, formatResumeTimings, formatToolStatus, getBuiltinExtensionEntryLabel, getPromptCacheTtlMs as getPromptCacheTtlMs$1, initialBindScope, isOfflineModeEnabled, isVerbatimCompactionMessage, isWorkspaceError, latestResumeTimings, normalizeMessageContent, normalizeModelFailureSignal, observedOpenAiDirectUsage, observedSubscriptionUsage, prewarmModelApi, readHostInputFormRequest, registerInitialBindings, stripVerbatimCompactionPrefix, subscriptionBearer, subscriptionCredentialKey, taskPromptHost, thinkingLevelForModelSwitch, usageObservationStore, withHistoryLoadObserver } from "./startup-0-1-Q7GBLBEL.js";
5
5
  import { KeybindingsManager as KeybindingsManager$1, OVERLAY_ACTIVE_ROW_MARKER, Theme, clickableKeyTextHint, consumeStartupInput, formatKeyText, getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, isNavHelpKey, keyDisplayText, keyHint, keyText, keyTextHint, loadAllHighlightLanguages, navEntryKeyParts, onThemeChange, recordTimeSinceReset, refreshCustomThemes, renderNavKeyOverlay, setRegisteredThemes, slashCommandHint, stopThemeWatcher, theme } from "./p2-shell-main-B2WIALFD.js";
6
6
  import { ProjectTrustStore, failureDebugFields, getProjectTrustPathAsync, hasTrustRequiringProjectResourcesAsync, reportDebugAsync } from "./p1b-elig-BY2G5BUE.js";
7
- import { WorkingRunMeter, compactionMeta, findExactModelReferenceMatch, getPowerShellConfigAsync, killSupervisedProcessTrees, killTrackedDetachedChildren, runInProgress, sessionLifetime, showStartupInput, showStartupSelector, taskTranscriptSource } from "./startup-0-2-YZZOC22D.js";
7
+ import { WorkingRunMeter, compactionMeta, findExactModelReferenceMatch, getPowerShellConfigAsync, killSupervisedProcessTrees, killTrackedDetachedChildren, readUsageAccountKey, runInProgress, sessionLifetime, showStartupInput, showStartupSelector, taskTranscriptSource, usageCredentialToken } from "./startup-0-2-JNYN24UI.js";
8
8
  import { AtomicWorkedStatusComponent, AtomicWorkingLoader, DEFAULT_WORKING_MESSAGE, buildContextEntries, getOwnerTaskStore, isResumeFailure, parseGitUrl, resolveModelScopeFromModels, resolveModelScopeWithDiagnostics, sessionEntryToDisplayMessages, watchAtomicWorkingClock, watchOwnerTaskStoreBinding } from "./startup-0-3-DE2NCS6A.js";
9
9
  import { SESSION_HISTORY_SCAN_ENTRIES, findDecisionError, isDecisionConfigError, isRpcRequestAcceptedFailure, isRpcTransportFailure } from "./settings-startup-HXQLSUWM.js";
10
10
  import { readAhead } from "./startup-8-0-34CBHPZH.js";
11
- import { CredentialSynchronizationError, DefaultPackageManager, chunkedToolResult, chunkedToolResultEntry, findInitialModel, firstSubagentAttempt, getSkillCatalog, isOAuthLoginCancelled, resolveRestoredModelReference, uncachedCopilotModelHint } from "./startup-0-5-HZX3ZPTP.js";
12
- import { formatModelLabel } from "./startup-0-4-ZMJV547D.js";
11
+ import { CredentialSynchronizationError, DefaultPackageManager, chunkedToolResult, chunkedToolResultEntry, findInitialModel, firstSubagentAttempt, getSkillCatalog, isOAuthLoginCancelled, resolveRestoredModelReference, uncachedCopilotModelHint } from "./startup-0-5-WN2IYA25.js";
12
+ import { SessionLoadingStatus, formatModelLabel } from "./startup-0-4-ZZXFKE55.js";
13
13
  import { ENGINE_SHUTDOWN_GRACE_MS, FooterDataProvider, appendBoundedStderr, compareWorktreeSnapshot, currentWorktreeSnapshots, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeWorktreeRestoreStatus, describeWorktreeSnapshot, dismissedAgentPanelItems, ownerTaskViewSource, sourceError, subscribeAgentPanel, worktreeRestoreNotices } from "./startup-8-1-QZMXUGHI.js";
14
- import { tryExecuteSessionSlashCommand } from "./startup-15-0-YUKGAC63.js";
15
- import { SessionManager } from "./startup-10-0-TDQNBDDL.js";
14
+ import { tryExecuteSessionSlashCommand } from "./startup-15-0-E7RYG5YF.js";
15
+ import { SessionManager } from "./startup-10-0-O6DAT7U4.js";
16
16
  import { IsolatedInteractiveRuntime, SessionImportFileNotFoundError, parseSkillBlock, sessionCloseReason } from "./startup-15-1-WQZBOTMZ.js";
17
17
  import { configureHttpDispatcher } from "./http-YFAPTIZD.js";
18
18
  import { AGENT_PANEL_WIDGET_KEY, ANTHROPIC_SUBSCRIPTION_AUTH_WARNING, AgentViewSwitcher, ArminComponent, AssistantMessageComponent, BUILTIN_SLASH_COMMAND_NAMES, BashExecutionComponent, BorderedLoader, BranchSummaryMessageComponent, COMMITTED_WIDGET_PREVIEW_GATE, CONSOLE_CLOSED_EXIT_CODE, CONSOLE_CLOSED_SHUTDOWN_MS, ChatSessionHost, CombinedAutocompleteProvider as CombinedAutocompleteProvider$1, CompactionBoundaryMessageComponent, Container as Container$1, CustomMessageComponent, EarendilAnnouncementComponent, ExpandableText, ExtensionEditorComponent, FooterComponent, InteractiveThemeController, KeybindingsReloadCoordinator, Loader as Loader$1, LoginDialogComponent, Markdown as Markdown$1, ModelSelectorComponent, OAuthSelectorComponent, PromptHistorySelectorComponent, QueuedMessagesView, RemoteCustomMessageComponent, RemoteFrameWidthClamp, RemoteToolExecutionComponent, STARTUP_ASSEMBLY_GAPS, STOP_ALL_STATUS_KEY, SavedRendererInstances, ScopedModelsSelectorComponent, SessionSelectorComponent, SettingsSelectorComponent, SkillInvocationMessageComponent, Spacer as Spacer$1, SteeringQueueController, Text as Text$1, ThinkingSelectorComponent, ToolExecutionComponent, ToolGroupTracker, TranscriptTaskRow, TreeSelectorComponent, TrustSelectorComponent, UsageMeterComponent, UserMessageSelectorComponent, WorkingStatusComponent, addChatTranscriptEntry, agentPanelBoardSource, agentPanelCounts, agentPanelHasRows, applyAssistantMessageDelta, applyToolEntryState, assistantCallBreaks, atomicWordmark, beginStreamingAssistantMessage, bindAgentPanel, blockRows, boundedInteractiveModelRefresh, callsAwaitingLaterResults, canPaintWidgetFrame, chalk, chatEntriesFromAgentMessages, chatRecordsChanged, checkForNewPiVersion, classifyWidgetFrame, clickableBlocksView, combineQueuedMessagesForEditor, compareProviders, composeStartupIdentity, countTasksBy, createChatAutocompleteProvider, createRemoteAgentSteering, createStopAllChord, createStopAllNotices, decisionSettingScopes, declaresHistoryReplayable, discardChatMount, disposeRemoteRenderers, disposeRenderer, endsAwaitedResults, exitWithStatus, formatAuthSelectorProviderType, formatCrashExtensionHint, formatResumeCommand, fs, fuzzyFilter as fuzzyFilter$1, getAutocompleteSourceTag, getCachedChangelog, getCapabilities as getCapabilities$1, getChangelogHighlights, getEntriesForVersion, getModelSearchText, getNewEntries, getSessionSkillCommands, handleTranscriptBlockClick, hasAssistantVisibleContent, hasDefaultModelProvider, hyperlink as hyperlink$1, initialHostEngineViewSyncState, interruptedNotice, isAnthropicSubscriptionAuthKey, isChatSessionWorking, isClickExpandableBlock, isDeadTerminalError, isEngineHintRoute, isExpandable, isResultWithoutCall, isSingleLeftClick, isUnansweredCancelMatch, loadEarendilAnnouncementImage, matchesKey as matchesKey$1, needsChangelogPreload, normalizeChangelogLinks, observeClickExpansion, openExternalEditorForText, openLocalAgentViewPort, openWaitedShellOf, os, panelHintParts, panelHintSegments, parkedRun, parseChangelogAsync, pasteClipboardImageToEditor, path as path$1, pickWhimsicalWorkingMessage, planPreViewCancelAck, prefixAutocompleteDescription, preloadChangelog, promptHistoryEntries, queuedMessageRows, readMountedAnchors, readTaskCompletionHistory, refreshModelCatalogs, remoteAgentCommands, remoteAgentPrompts, renderAtomicAssemblyBanner, renderChatMessageEntry, renderStartupManifesto, restoredQueue, retainChatRecords, retryCancelHint, retryWaitFromEvent, retryWaitMessage, rowsFrom, runHintRoute, sessionChatMount, sessionPromptsFromEntries, setAgentViewBridge, setKeybindings as setKeybindings$1, setRendererClickTarget, settleUnansweredCalls, shouldCancelEngineViewOnArrival, showAgentPanel, showTaskInspector, spawn, stopAllBackgroundWork, supersedeBlockClicks, supportsAtomicBanner, taskNameAndTitle, taskSiblings, themedChatHostStyle, toolResultGroupState, viewedAgentCommand, visibleWidth as visibleWidth$1 } from "./mode-shared-2QJSCUM6.js";
@@ -21,7 +21,7 @@ import { exitOnDecisionConfigError } from "./settings-startup-8-DNZ2RIHM.js";
21
21
  import { dirname } from "node:path";
22
22
  import { setLongTimeout } from "../__atomic_timers/index.js";
23
23
  import { normalizeProviderId } from "@bastani/atomic-ai";
24
- import { Box, CURSOR_MARKER, Container, Editor, Input, Key, Marked, ScrollView, Spacer, Text, TuiAltScreen, VStack, WindowedContainer, bindBundledHintCommands, clickableKeysHint, decodePrintableKey, editorDraftText, emptyEditorDraft, fuzzyFilter, getCapabilities, isHintActivation, isKeyRelease, isViewportTUI, matchesKey, replaceControlCharacters, setCapabilityOverrides, setKeybindings, stripHintMarkers, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
24
+ import { Box, CURSOR_MARKER, Container, Editor, HStack, Input, Key, Marked, ScrollView, Spacer, Text, TuiAltScreen, VStack, WindowedContainer, bindBundledHintCommands, clickableKeysHint, decodePrintableKey, editorDraftText, emptyEditorDraft, fuzzyFilter, getCapabilities, isHintActivation, isKeyRelease, isViewportTUI, matchesKey, replaceControlCharacters, setCapabilityOverrides, setKeybindings, stripHintMarkers, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
25
25
  import { createHash, randomUUID } from "node:crypto";
26
26
  import { setImmediate as setImmediate$1 } from "node:timers/promises";
27
27
  import { clampThinkingLevel, modelsAreEqual } from "@bastani/atomic-ai/compat";
@@ -31,7 +31,8 @@ import { isProxy } from "node:util/types";
31
31
  import { copyScopedModels } from "../core/extensions/runner-context.js";
32
32
  import { ModelRegistry } from "../core/model-registry.js";
33
33
  import "@bastani/atomic-ai/providers/all";
34
- import { LAYOUT_NODE } from "@bastani/atomic-tui/dist/layout-node.js";
34
+ import { LAYOUT_NODE, getLayoutNode } from "@bastani/atomic-tui/dist/layout-node.js";
35
+ import { renderLayoutFrame } from "@bastani/atomic-tui/dist/layout.js";
35
36
  // dist/modes/interactive-engine/engine-dialog-host.js
36
37
  /** Requests that mount a host dialog and therefore need generation ownership. */
37
38
  const MOUNTING_METHODS = /* @__PURE__ */ new Set([
@@ -879,6 +880,11 @@ function awaitsFirstContent(component) {
879
880
  }
880
881
  /** Views that navigate (`/tasks`, the focused agent panel): the footer's hints and the widgets give way to them. */
881
882
  const navigationViews = /* @__PURE__ */ new WeakSet();
883
+ const nativeViews = /* @__PURE__ */ new WeakSet();
884
+ /** When drawn live, let the terminal lay out this view's own scrollable regions. */
885
+ function usePromptSlotLayout(view) {
886
+ nativeViews.add(view);
887
+ }
882
888
  /**
883
889
  * `view` is mounted as a navigation view, until it is unmounted (`navigation` false): while the slot draws it, the
884
890
  * footer's hints and the widgets around the prompt hide.
@@ -933,6 +939,7 @@ var PromptSlot = class extends Container {
933
939
  /** What the last render drew. */
934
940
  drawn;
935
941
  showingHeldRows = false;
942
+ nativeLayout = false;
936
943
  ui;
937
944
  showsRunStatus;
938
945
  screen;
@@ -1042,6 +1049,7 @@ var PromptSlot = class extends Container {
1042
1049
  render(width) {
1043
1050
  const live = super.render(width);
1044
1051
  const held = this.resolve(width);
1052
+ this.nativeLayout = false;
1045
1053
  this.showingHeldRows = held !== void 0;
1046
1054
  this.drawn = {
1047
1055
  width,
@@ -1094,8 +1102,14 @@ var PromptSlot = class extends Container {
1094
1102
  return held;
1095
1103
  }
1096
1104
  /** Held rows are a picture of what was there: a click on them reaches nothing. */
1105
+ [LAYOUT_NODE]() {
1106
+ const view = this.children.length === 1 ? this.children[0] : void 0;
1107
+ const layout = !this.showingHeldRows && view && nativeViews.has(view) ? getLayoutNode(view) : void 0;
1108
+ this.nativeLayout = layout !== void 0;
1109
+ return layout;
1110
+ }
1097
1111
  handleMouse(event) {
1098
- return this.showingHeldRows ? void 0 : super.handleMouse(event);
1112
+ return this.showingHeldRows || this.nativeLayout ? void 0 : super.handleMouse(event);
1099
1113
  }
1100
1114
  showsHeldRows(state, width) {
1101
1115
  if (width !== state.width || this.showsRunStatus()) return false;
@@ -13194,6 +13208,47 @@ var ProgramStatusReporter = class {
13194
13208
  return status;
13195
13209
  }
13196
13210
  };
13211
+ // dist/modes/interactive/session-loading.js
13212
+ /** The newest visible operation takes the row, even if startup or a prior operation is still settling. */
13213
+ var SessionLoadingDock = class extends Container {
13214
+ render(width) {
13215
+ for (let i = this.children.length - 1; i >= 0; i--) {
13216
+ const rows = this.children[i]?.render(width);
13217
+ if (rows?.length) return rows;
13218
+ }
13219
+ return [];
13220
+ }
13221
+ };
13222
+ const docks = /* @__PURE__ */ new WeakMap();
13223
+ function sessionLoadingDock(mode) {
13224
+ let dock = docks.get(mode);
13225
+ if (!dock) {
13226
+ dock = new SessionLoadingDock();
13227
+ docks.set(mode, dock);
13228
+ }
13229
+ return dock;
13230
+ }
13231
+ function withSessionLoading(mode, label, run) {
13232
+ if (!mode.tuiStarted || mode.isShuttingDown) return run();
13233
+ const dock = sessionLoadingDock(mode);
13234
+ const status = new SessionLoadingStatus(() => mode.ui.requestRender(), label);
13235
+ dock.addChild(status);
13236
+ status.begin();
13237
+ return withHistoryLoadObserver((entries) => status.phase(`Reading ${entries.toLocaleString()} history entries`), async () => {
13238
+ try {
13239
+ return await run(status.phase);
13240
+ } finally {
13241
+ status.done();
13242
+ dock.removeChild(status);
13243
+ }
13244
+ });
13245
+ }
13246
+ function stopSessionLoading(mode) {
13247
+ const dock = docks.get(mode);
13248
+ if (!dock) return;
13249
+ for (const child of dock.children) if (child instanceof SessionLoadingStatus) child.done();
13250
+ dock.clear();
13251
+ }
13197
13252
  // dist/modes/interactive/interactive-mode-base.js
13198
13253
  /**
13199
13254
  * Shared state and constructor wiring for interactive mode.
@@ -13599,6 +13654,7 @@ var InteractiveModeBase = class {
13599
13654
  return this.renderer.mode === "fullscreen";
13600
13655
  }
13601
13656
  stopInteractiveTui(fullscreenExitOutput) {
13657
+ stopSessionLoading(this);
13602
13658
  const isFullscreen = this.renderer.mode === "fullscreen";
13603
13659
  if (isFullscreen && fullscreenExitOutput === "transcript") {
13604
13660
  while (this.renderer.hasOverlayEntries) this.renderer.hideOverlay();
@@ -18087,16 +18143,17 @@ function missForOccurrence(notes) {
18087
18143
  function precedingDropCount(mode, notes) {
18088
18144
  if (notes.previousReply) return countDroppedThinkingBlocks(notes.previousReply);
18089
18145
  if (notes.earlier) return notes.earlier.drops;
18090
- let id = notes.summarizedParent;
18091
- if (id === void 0) return 0;
18092
- const seen = /* @__PURE__ */ new Set();
18093
- while (!seen.has(id)) {
18094
- seen.add(id);
18095
- const entry = mode.sessionManager?.getEntry(id);
18096
- if (!entry) return void 0;
18146
+ if (notes.summarizedParent === void 0) return 0;
18147
+ const manager = mode.sessionManager;
18148
+ const getEntry = (id) => manager?.getEntry(id);
18149
+ const positionOf = (id) => manager?.getEntrySeq(id);
18150
+ let entry = getEntry(notes.summarizedParent);
18151
+ while (entry) {
18097
18152
  if (entry.type === "message" && entry.message.role === "assistant") return countDroppedThinkingBlocks(entry.message);
18098
- if (!entry.parentId) return 0;
18099
- id = entry.parentId;
18153
+ if (entry.parentId === null) return 0;
18154
+ const parent = sessionParent(entry, getEntry, positionOf);
18155
+ if (!parent) return positionOf(entry.parentId) === void 0 ? void 0 : 0;
18156
+ entry = parent;
18100
18157
  }
18101
18158
  }
18102
18159
  function paintReplyNotices(mode, notes) {
@@ -18891,7 +18948,7 @@ InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
18891
18948
  newSession: async (options) => {
18892
18949
  InteractiveModeBase.prototype.clearWorkingLoader.call(this);
18893
18950
  try {
18894
- const result = await this.runtimeHost.newSession(options);
18951
+ const result = await withSessionLoading(this, "Starting session", () => this.runtimeHost.newSession(options));
18895
18952
  if (!result.cancelled) {
18896
18953
  this.renderCurrentSessionState();
18897
18954
  this.ui.requestRender();
@@ -18903,7 +18960,7 @@ InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
18903
18960
  },
18904
18961
  fork: async (entryId, options) => {
18905
18962
  try {
18906
- const result = await this.runtimeHost.fork(entryId, options);
18963
+ const result = await withSessionLoading(this, "Forking session", () => this.runtimeHost.fork(entryId, options));
18907
18964
  if (!result.cancelled) {
18908
18965
  this.renderCurrentSessionState();
18909
18966
  this.editor.setText(result.selectedText ?? "");
@@ -19819,7 +19876,7 @@ InteractiveModeBase.prototype.showUserMessageSelector = async function() {
19819
19876
  done();
19820
19877
  try {
19821
19878
  await this.ensureDeferredStartupComplete();
19822
- const result = await this.runtimeHost.fork(entryId);
19879
+ const result = await withSessionLoading(this, "Forking session", () => this.runtimeHost.fork(entryId));
19823
19880
  if (result.cancelled) {
19824
19881
  this.ui.requestRender();
19825
19882
  return;
@@ -22665,12 +22722,18 @@ InteractiveModeBase.prototype.init = async function() {
22665
22722
  scrollbarThumbStyle: (text) => theme.bg("scrollbarThumb", text)
22666
22723
  });
22667
22724
  const pendingMessagesPreview = clickableBlocksView(this.pendingMessagesContainer, () => this.navigationInlineCustomUiDepth > 0);
22725
+ const sessionLoading = sessionLoadingDock(this);
22668
22726
  const dock = new VStack([
22669
22727
  {
22670
22728
  component: pendingMessagesPreview,
22671
22729
  shrink: 1,
22672
22730
  minSize: 0
22673
22731
  },
22732
+ {
22733
+ component: sessionLoading,
22734
+ shrink: 1,
22735
+ minSize: 0
22736
+ },
22674
22737
  {
22675
22738
  component: this.statusContainer,
22676
22739
  shrink: 1,
@@ -22719,6 +22782,7 @@ InteractiveModeBase.prototype.init = async function() {
22719
22782
  this.mountInteractiveTui(this.ui, [
22720
22783
  this.documentContainer,
22721
22784
  pendingMessagesPreview,
22785
+ sessionLoading,
22722
22786
  this.statusContainer,
22723
22787
  this.widgetContainerAbove,
22724
22788
  this.usageMeter,
@@ -22805,12 +22869,14 @@ InteractiveModeBase.prototype.init = async function() {
22805
22869
  eagerChangelogPreload?.catch(() => {});
22806
22870
  let bootstrapPreview;
22807
22871
  try {
22808
- await waitForInteractiveEngineBound(this.runtimeHost, (lines) => {
22872
+ const waitForBinding = () => waitForInteractiveEngineBound(this.runtimeHost, (lines) => {
22809
22873
  if (this.isShuttingDown) return;
22810
22874
  bootstrapPreview = new Text$1(lines.map(replaceControlCharacters).join("\n\n"), 1, 0);
22811
22875
  this.chatContainer.addChild(bootstrapPreview);
22812
22876
  this.ui.requestRender();
22813
22877
  });
22878
+ if ((this.sessionManager?.getEntryCount?.() ?? 0) > 0) await withSessionLoading(this, "Loading session", waitForBinding);
22879
+ else await waitForBinding();
22814
22880
  } finally {
22815
22881
  if (bootstrapPreview) {
22816
22882
  this.chatContainer.removeChild(bootstrapPreview);
@@ -23781,6 +23847,7 @@ InteractiveModeBase.prototype.setupExtensionShortcuts = function(extensionRunner
23781
23847
  this.shutdownRequested = true;
23782
23848
  },
23783
23849
  getContextUsage: () => this.session.getContextUsage(),
23850
+ getSubscriptionUsage: (options) => extensionRunner.createContext().getSubscriptionUsage(options),
23784
23851
  compact: (options) => {
23785
23852
  (async () => {
23786
23853
  try {
@@ -26408,6 +26475,7 @@ InteractiveModeBase.prototype.showPackageUpdateNotification = function(packages,
26408
26475
  // dist/core/subscription-usage.js
26409
26476
  const USAGE_TIMEOUT_MS = 5e3;
26410
26477
  const CACHE_MS = 6e4;
26478
+ const OBSERVATION_WAIT_MS = 1e3;
26411
26479
  const usageProviders = {
26412
26480
  anthropic: "claude",
26413
26481
  openai: "openai-direct",
@@ -26417,53 +26485,73 @@ const usageProviders = {
26417
26485
  "kimi-coding": "kimi",
26418
26486
  openrouter: "openrouter"
26419
26487
  };
26420
- function accountType(runtime, provider, refresh = true) {
26421
- const account = {
26422
- provider,
26423
- name: runtime.getProvider(provider)?.name ?? provider,
26424
- current: false
26488
+ function hasFigures(details) {
26489
+ return Boolean(details.windows.length || details.rateLimits?.length || details.resetCredits !== void 0 || details.credits || details.extraUsage || details.creditCap || details.unlimitedWindows?.length);
26490
+ }
26491
+ function withAvailability(result) {
26492
+ const available = result.status === "ready" ? hasFigures(result) : result.status === "unavailable" && result.reason === "api_key";
26493
+ return {
26494
+ ...result,
26495
+ availability: available ? "available" : "unavailable"
26425
26496
  };
26497
+ }
26498
+ function accountType(runtime, provider, refresh = true) {
26499
+ const registered = runtime.getProvider(provider);
26426
26500
  const status = runtime.getProviderAuthStatus(provider, { refresh });
26427
26501
  const source = runtime.getBuiltinAccountProvider(provider);
26428
26502
  const kind = source ? usageProviders[source] : void 0;
26429
26503
  const credential = runtime.getCredentialSnapshot(provider);
26430
26504
  const claudeToken = kind === "claude" && (status.source === "stored" && credential?.type === "api_key" && credential.key?.startsWith("sk-ant-oat") || status.source === "environment" && status.label === "ANTHROPIC_OAUTH_TOKEN");
26431
- if (status.configured && (status.source === "stored" && (credential?.type ?? runtime.getStoredCredentialType(provider)) === "oauth" || claudeToken)) {
26505
+ const oauth = status.source === "stored" && (credential?.type ?? runtime.getStoredCredentialType(provider)) === "oauth";
26506
+ const account = {
26507
+ provider,
26508
+ name: registered?.name ?? provider,
26509
+ current: false
26510
+ };
26511
+ const subscription = status.configured && (claudeToken || oauth && registered?.auth.oauth?.isSubscription === true);
26512
+ if (status.configured && (oauth || claudeToken)) {
26432
26513
  if (kind) return {
26433
26514
  account,
26515
+ subscription,
26434
26516
  kind
26435
26517
  };
26436
26518
  return {
26437
26519
  account,
26520
+ subscription,
26438
26521
  reason: "unsupported"
26439
26522
  };
26440
26523
  }
26441
26524
  return {
26442
26525
  account,
26526
+ subscription,
26443
26527
  reason: status.configured ? "api_key" : "not_signed_in"
26444
26528
  };
26445
26529
  }
26446
- async function listUsageAccounts(runtime, current, signal) {
26530
+ async function listUsageAccounts(runtime, current, signal, subscriptionsOnly = false) {
26447
26531
  const credentials = await runtime.listCredentials({ signal });
26448
26532
  const catalog = runtime.getProviders();
26449
26533
  if (catalog[0]) runtime.getProviderAuthStatus(catalog[0].id);
26450
- return [.../* @__PURE__ */ new Set([...credentials.map(({ providerId }) => providerId), ...catalog.filter(({ id }) => runtime.getProviderAuthStatus(id, { refresh: false }).configured).map(({ id }) => id)])].map((provider) => {
26451
- const { account, reason } = accountType(runtime, provider, false);
26452
- account.current = provider === current;
26453
- return reason ? {
26534
+ return [.../* @__PURE__ */ new Set([...credentials.map(({ providerId }) => providerId), ...catalog.filter(({ id }) => runtime.getProviderAuthStatus(id, { refresh: false }).configured).map(({ id }) => id)])].flatMap((provider) => {
26535
+ const { account, reason, subscription } = accountType(runtime, provider, false);
26536
+ if (subscriptionsOnly && !subscription) return [];
26537
+ account.current = !subscriptionsOnly && provider === current;
26538
+ return [reason ? withAvailability({
26454
26539
  ...account,
26455
26540
  status: "unavailable",
26456
26541
  reason,
26457
26542
  message: usageReason[reason]
26458
- } : {
26543
+ }) : {
26459
26544
  ...account,
26460
26545
  status: "loading"
26461
- };
26546
+ }];
26462
26547
  }).sort((a, b) => Number(b.current) - Number(a.current) || a.name.localeCompare(b.name) || a.provider.localeCompare(b.provider));
26463
26548
  }
26464
26549
  const cache = /* @__PURE__ */ new Map();
26465
26550
  const RETAIN_CACHE_MS = 9e5;
26466
26551
  async function loadAccountUsage(runtime, provider, current, options = {}) {
26552
+ return withAvailability(await resolveAccountUsage(runtime, provider, current, options));
26553
+ }
26554
+ async function resolveAccountUsage(runtime, provider, current, options) {
26467
26555
  options.signal?.throwIfAborted();
26468
26556
  const { account, kind, reason } = accountType(runtime, provider);
26469
26557
  account.current = provider === current;
@@ -26476,104 +26564,167 @@ async function loadAccountUsage(runtime, provider, current, options = {}) {
26476
26564
  message: usageReason[unavailable]
26477
26565
  };
26478
26566
  }
26479
- const stored = runtime.getCredentialSnapshot(provider);
26480
- if (kind === "openai-direct") try {
26481
- const credential = stored ?? await runtime[readSubscriptionCredential](provider, options.signal ?? AbortSignal.timeout(USAGE_TIMEOUT_MS));
26482
- options.signal?.throwIfAborted();
26483
- const observation = credential?.type === "oauth" ? observedOpenAiDirectUsage(provider, credential.access) : void 0;
26484
- return observation ? {
26485
- ...account,
26486
- status: "ready",
26487
- source: "last_request",
26488
- ...observation
26489
- } : {
26490
- ...account,
26491
- status: "unavailable",
26492
- reason: "not_observed",
26493
- message: usageReason.not_observed
26494
- };
26495
- } catch {
26496
- options.signal?.throwIfAborted();
26497
- return {
26498
- ...account,
26499
- status: "failed",
26500
- reason: "request_failed",
26501
- message: "Could not read local account details."
26502
- };
26567
+ const store = options.store ?? usageObservationStore(runtime);
26568
+ const attempt = (operation) => withProviderTimeout(OBSERVATION_WAIT_MS, options.signal, operation, "Stored subscription usage").catch(() => void 0);
26569
+ const fromStorage = store ? attempt(async (signal) => {
26570
+ const key = await runtime[readUsageAccountKey](provider, kind, signal);
26571
+ return key ? store.read(key) : void 0;
26572
+ }) : void 0;
26573
+ const credential = runtime.getCredentialSnapshot(provider);
26574
+ let token = credential ? usageCredentialToken(credential) : kind === "claude" ? process.env.ANTHROPIC_OAUTH_TOKEN : void 0;
26575
+ if (kind === "openai-direct" && !token) {
26576
+ const direct = await attempt((signal) => runtime[readSubscriptionCredential](provider, signal));
26577
+ if (direct?.type === "oauth") token = direct.access;
26503
26578
  }
26504
- if (isOfflineModeEnabled()) return {
26505
- ...account,
26579
+ const offline = isOfflineModeEnabled();
26580
+ const failure = {
26506
26581
  status: "unavailable",
26507
- reason: "offline",
26508
- message: usageReason.offline
26582
+ reason: "no_subscription"
26509
26583
  };
26510
- let key = stored?.type === "oauth" ? subscriptionCredentialKey(kind, stored.access) : void 0;
26511
- let result;
26512
- try {
26513
- result = await withProviderTimeout(options.timeoutMs ?? USAGE_TIMEOUT_MS, options.signal, async (signal) => {
26514
- let token;
26584
+ let fetched;
26585
+ if (!options.observedOnly && !offline && kind !== "openai-direct") try {
26586
+ fetched = await withProviderTimeout(options.timeoutMs ?? USAGE_TIMEOUT_MS, options.signal, async (signal) => {
26587
+ let identityToken;
26515
26588
  if (kind === "copilot") {
26516
26589
  const github = await runtime[readSubscriptionCredential](provider, signal);
26517
26590
  if (github?.type === "oauth" && github.enterpriseUrl) return {
26518
- status: "unavailable",
26519
- reason: "no_subscription"
26591
+ observedAt: Date.now(),
26592
+ result: failure
26520
26593
  };
26594
+ identityToken = github?.type === "oauth" ? github.access : void 0;
26521
26595
  token = github?.type === "oauth" ? github.refresh : void 0;
26522
26596
  } else {
26523
26597
  const auth = await runtime.getAuth(provider, { signal });
26524
26598
  token = auth && subscriptionBearer(auth.auth);
26599
+ identityToken = token;
26525
26600
  }
26526
26601
  if (!token) return {
26527
- status: "unavailable",
26528
- reason: "sign_in_again"
26602
+ observedAt: Date.now(),
26603
+ result: {
26604
+ status: "unavailable",
26605
+ reason: "sign_in_again"
26606
+ }
26529
26607
  };
26530
26608
  signal.throwIfAborted();
26531
- key = subscriptionCredentialKey(kind, token);
26532
- const cached = cache.get(key);
26533
- const maxAge = Math.min(options.maxAgeMs ?? CACHE_MS, RETAIN_CACHE_MS);
26534
- if (cached && Date.now() - cached.observedAt < maxAge) return cached.result;
26535
- const credential = runtime.getCredentialSnapshot(provider);
26536
- if (kind === "claude" && credential?.type === "oauth" && Array.isArray(credential.scopes) && !credential.scopes.includes("user:profile")) return {
26537
- status: "unavailable",
26538
- reason: "needs_profile_scope"
26609
+ const cacheKey = subscriptionCredentialKey(kind, token);
26610
+ const cached = cache.get(cacheKey);
26611
+ if (cached && Date.now() - cached.observedAt < Math.min(options.maxAgeMs ?? CACHE_MS, RETAIN_CACHE_MS)) return cached;
26612
+ const current = runtime.getCredentialSnapshot(provider);
26613
+ if (kind === "claude" && current?.type === "oauth" && Array.isArray(current.scopes) && !current.scopes.includes("user:profile")) return {
26614
+ observedAt: Date.now(),
26615
+ result: {
26616
+ status: "unavailable",
26617
+ reason: "needs_profile_scope"
26618
+ }
26539
26619
  };
26540
- const accountId = kind === "codex" ? codexAccountId(token) ?? (credential?.type === "oauth" && typeof credential.accountId === "string" ? credential.accountId : void 0) : void 0;
26620
+ const accountId = kind === "codex" ? codexAccountId(token) ?? (current?.type === "oauth" && typeof current.accountId === "string" ? current.accountId : void 0) : void 0;
26541
26621
  const result = await fetchSubscriptionUsage(kind, token, accountId, signal, options.fetch);
26622
+ const observedAt = Date.now();
26542
26623
  if (!signal.aborted) {
26543
- const observedAt = Date.now();
26544
26624
  for (const [id, entry] of cache) if (observedAt - entry.observedAt >= RETAIN_CACHE_MS) cache.delete(id);
26545
- cache.set(key, {
26625
+ cache.set(cacheKey, {
26546
26626
  observedAt,
26547
26627
  result
26548
26628
  });
26629
+ if (store && identityToken && result.status === "ready" && hasFigures(result)) {
26630
+ const { status: _status, ...details } = result;
26631
+ await attempt(async (storeSignal) => {
26632
+ const key = await runtime[readUsageAccountKey](provider, kind, storeSignal, identityToken);
26633
+ if (key) await store.write(key, {
26634
+ observedAt,
26635
+ details
26636
+ });
26637
+ });
26638
+ }
26549
26639
  }
26550
- return result;
26640
+ return {
26641
+ observedAt,
26642
+ result
26643
+ };
26551
26644
  }, "Subscription usage");
26552
26645
  } catch (error) {
26553
26646
  options.signal?.throwIfAborted();
26554
- result = {
26555
- status: "failed",
26556
- reason: error instanceof Error && error.name === "TimeoutError" ? "timeout" : "request_failed"
26647
+ fetched = {
26648
+ observedAt: Date.now(),
26649
+ result: {
26650
+ status: "failed",
26651
+ reason: error instanceof Error && error.name === "TimeoutError" ? "timeout" : "request_failed"
26652
+ }
26557
26653
  };
26558
26654
  }
26559
- if (result.status === "ready") return {
26560
- ...account,
26561
- ...structuredClone(result),
26562
- source: "live"
26655
+ const shared = await fromStorage;
26656
+ options.signal?.throwIfAborted();
26657
+ const local = !token ? void 0 : kind === "openai-direct" ? observedOpenAiDirectUsage(provider, token) : observedSubscriptionUsage(subscriptionCredentialKey(kind, token));
26658
+ const result = fetched?.result ?? {
26659
+ status: "unavailable",
26660
+ reason: kind === "openai-direct" || options.observedOnly ? "not_observed" : "offline"
26563
26661
  };
26564
- const windows = key ? structuredClone(observedSubscriptionUsage(key)) : [];
26565
- const message = usageReason[result.reason];
26566
- return windows.length ? {
26567
- ...account,
26568
- status: "ready",
26569
- source: "recent_response",
26570
- windows,
26571
- reason: result.reason,
26572
- message
26573
- } : {
26662
+ const fresh = result.status === "ready" && fetched && hasFigures(result) ? fetched.observedAt : -1;
26663
+ if (shared && shared.observedAt > fresh && (!local || shared.observedAt > local.observedAt)) {
26664
+ const check = fetched?.result;
26665
+ return {
26666
+ ...account,
26667
+ ...displayObservation(shared),
26668
+ status: "ready",
26669
+ source: "stored",
26670
+ ...check && check.status !== "ready" ? {
26671
+ reason: check.reason,
26672
+ message: usageReason[check.reason]
26673
+ } : {}
26674
+ };
26675
+ }
26676
+ if (local && local.observedAt > fresh) {
26677
+ const details = displayObservation(local);
26678
+ if (kind === "openai-direct") return {
26679
+ ...account,
26680
+ ...details,
26681
+ status: "ready",
26682
+ source: "last_request"
26683
+ };
26684
+ if (result.status !== "ready" && result.reason !== "offline" && result.reason !== "not_observed") return {
26685
+ ...account,
26686
+ ...details,
26687
+ status: "ready",
26688
+ source: "recent_response",
26689
+ reason: result.reason,
26690
+ message: usageReason[result.reason]
26691
+ };
26692
+ return {
26693
+ ...account,
26694
+ ...details,
26695
+ status: "ready",
26696
+ source: "last_request"
26697
+ };
26698
+ }
26699
+ if (result.status === "ready") {
26700
+ const { status, ...details } = result;
26701
+ return {
26702
+ ...account,
26703
+ ...displayObservation({
26704
+ observedAt: fetched.observedAt,
26705
+ details
26706
+ }),
26707
+ status,
26708
+ source: "live"
26709
+ };
26710
+ }
26711
+ return {
26574
26712
  ...account,
26575
26713
  ...result,
26576
- message
26714
+ message: usageReason[result.reason]
26715
+ };
26716
+ }
26717
+ function displayObservation(observation) {
26718
+ const details = structuredClone(observation.details);
26719
+ const now = Date.now();
26720
+ return {
26721
+ ...details,
26722
+ windows: details.windows.map((window) => window.resetsAt && Date.parse(window.resetsAt) <= now ? {
26723
+ ...window,
26724
+ usedPercent: 0,
26725
+ resetsAt: null
26726
+ } : window),
26727
+ observedAt: new Date(observation.observedAt).toISOString()
26577
26728
  };
26578
26729
  }
26579
26730
  async function loadSubscriptionUsage(runtime, current, options = {}) {
@@ -26583,7 +26734,7 @@ async function loadSubscriptionUsage(runtime, current, options = {}) {
26583
26734
  const providers = [...new Set(accounts.map(normalizeProviderId))];
26584
26735
  return { accounts: await Promise.all(providers.map((provider) => loadAccountUsage(runtime, provider, current, options))) };
26585
26736
  }
26586
- const listed = listUsageAccounts(runtime, current, signal);
26737
+ const listed = listUsageAccounts(runtime, current, signal, options.subscriptionsOnly);
26587
26738
  const rows = signal ? await raceWithAbortSignal(listed, signal) : await listed;
26588
26739
  return { accounts: await Promise.all(rows.map((row) => row.status === "loading" ? loadAccountUsage(runtime, row.provider, current, options) : row)) };
26589
26740
  }
@@ -26680,6 +26831,16 @@ function usageExtras(usage, now) {
26680
26831
  return lines;
26681
26832
  }
26682
26833
  // dist/modes/interactive/components/usage-selector.js
26834
+ const OBSERVATION_POLL_MS = 1e3;
26835
+ function fixedLines(lines) {
26836
+ return {
26837
+ render: () => lines,
26838
+ invalidate() {}
26839
+ };
26840
+ }
26841
+ function hasWindows(row) {
26842
+ return row?.status === "ready" && row.windows.length > 0;
26843
+ }
26683
26844
  function safeLabel(text) {
26684
26845
  return replaceControlCharacters(stripTerminalSequences(text)).replace(/\s+/g, " ");
26685
26846
  }
@@ -26698,103 +26859,157 @@ function windowLines(window, width, labelWidth, now) {
26698
26859
  return [...wrapTextWithAnsi(label, width), ...visibleWidth(`${gauge} ${time}`) <= width ? [`${gauge} ${time}`] : [...wrapTextWithAnsi(gauge, width), ...wrapTextWithAnsi(time, width)]];
26699
26860
  }
26700
26861
  var UsageSelector = class {
26701
- rows;
26862
+ rows = /* @__PURE__ */ new Map();
26702
26863
  loading = false;
26703
- listFailed = false;
26864
+ checking = false;
26865
+ poll;
26704
26866
  revision = 0;
26705
- offset = 0;
26706
- maxOffset = 0;
26867
+ viewport;
26868
+ layout;
26707
26869
  border = new DynamicBorder();
26708
26870
  options;
26709
26871
  constructor(options) {
26710
26872
  this.options = options;
26873
+ this.viewport = new ScrollView({
26874
+ render: (width) => this.renderBody(width),
26875
+ invalidate() {}
26876
+ }, {
26877
+ overscroll: "contain",
26878
+ scrollbarThumbStyle: (text) => theme.bg("scrollbarThumb", text)
26879
+ });
26711
26880
  this.reload(false);
26881
+ if (options.observed) this.poll = setInterval(() => this.checkObservations(), OBSERVATION_POLL_MS).unref();
26712
26882
  }
26713
26883
  dispose() {
26884
+ clearInterval(this.poll);
26885
+ this.viewport.setScrollbar("hidden");
26714
26886
  this.revision++;
26715
26887
  }
26716
26888
  invalidate() {}
26717
26889
  async reload(refresh) {
26718
26890
  const revision = ++this.revision;
26719
26891
  this.loading = true;
26720
- this.listFailed = false;
26721
- this.offset = 0;
26722
- this.rows = void 0;
26723
- this.options.requestRender();
26724
26892
  try {
26725
26893
  const rows = await this.options.list();
26726
26894
  if (revision !== this.revision) return;
26727
- this.rows = rows;
26895
+ this.rows.clear();
26896
+ for (const row of rows) this.rows.set(row.provider, row);
26728
26897
  this.options.requestRender();
26729
- await Promise.all(rows.map(async (row, index) => {
26898
+ this.checkObservations();
26899
+ await Promise.all(rows.map(async (row) => {
26730
26900
  if (row.status !== "loading") return;
26731
- const result = await this.options.load(row.provider, refresh).catch(() => ({
26732
- ...row,
26733
- status: "failed",
26734
- reason: "request_failed",
26735
- message: usageReason.request_failed
26736
- }));
26737
- if (revision !== this.revision) return;
26738
- rows[index] = result;
26739
- this.options.requestRender();
26901
+ const result = await this.options.load(row.provider, refresh).catch(() => void 0);
26902
+ if (revision === this.revision && result) this.update(result);
26740
26903
  }));
26741
- } catch {
26742
- if (revision === this.revision) this.listFailed = true;
26743
- } finally {
26904
+ } catch {} finally {
26744
26905
  if (revision === this.revision) {
26745
26906
  this.loading = false;
26746
26907
  this.options.requestRender();
26747
26908
  }
26748
26909
  }
26749
26910
  }
26911
+ update(row) {
26912
+ const current = this.rows.get(row.provider);
26913
+ if (!current || hasWindows(current) && (!hasWindows(row) || (current.observedAt ?? "") > (row.observedAt ?? ""))) return;
26914
+ if (hasWindows(current) && hasWindows(row) && JSON.stringify(current.windows) === JSON.stringify(row.windows)) return;
26915
+ this.rows.set(row.provider, row);
26916
+ this.options.requestRender();
26917
+ }
26918
+ checkObservations() {
26919
+ if (this.checking || !this.options.observed || !this.rows.size) return;
26920
+ this.checking = true;
26921
+ const revision = this.revision;
26922
+ this.options.observed().then((rows) => {
26923
+ if (revision !== this.revision) return;
26924
+ for (const row of rows) if (hasWindows(row)) this.update(row);
26925
+ }, () => {}).finally(() => {
26926
+ this.checking = false;
26927
+ });
26928
+ }
26929
+ handleMouse(event) {
26930
+ if (event.type !== "wheel" || !event.wheelDelta) return void 0;
26931
+ return {
26932
+ handled: true,
26933
+ render: this.viewport.scrollBy(event.wheelDelta) !== event.wheelDelta
26934
+ };
26935
+ }
26750
26936
  handleInput(data) {
26751
26937
  if (matchesKey(data, "escape")) this.options.close();
26752
26938
  else if (matchesKey(data, "r") && !this.loading) this.reload(true);
26753
- else if (matchesKey(data, "up")) this.offset = Math.max(0, this.offset - 1);
26754
- else if (matchesKey(data, "down")) this.offset = Math.min(this.maxOffset, this.offset + 1);
26939
+ else if (matchesKey(data, "up")) this.viewport.scrollBy(-1);
26940
+ else if (matchesKey(data, "down")) this.viewport.scrollBy(1);
26755
26941
  }
26756
- render(width) {
26757
- const pad = width >= 20 ? " " : "";
26758
- const inner = Math.max(1, width - 2 * pad.length);
26942
+ renderBody(inner) {
26759
26943
  const body = [];
26760
26944
  const now = Date.now();
26761
26945
  const add = (value) => body.push(...wrapTextWithAnsi(value, inner));
26762
- if (this.listFailed) add(theme.fg("error", "Could not read signed-in accounts."));
26763
- else if (!this.rows) add(theme.fg("muted", "Reading signed-in accounts…"));
26764
- else if (!this.rows.length) add(theme.fg("muted", "No signed-in accounts. Use /login to connect one."));
26765
- else {
26766
- const labelWidth = Math.min(18, Math.max(0, ...this.rows.flatMap((row) => row.status === "ready" ? row.windows.map((window) => usageWindowLabel(window).length) : [])));
26767
- for (const [index, row] of this.rows.entries()) {
26768
- if (index) body.push("");
26769
- const name = safeLabel(row.name);
26770
- const id = row.provider === row.name ? "" : theme.fg("muted", ` · ${safeLabel(row.provider)}`);
26771
- const current = row.current ? theme.fg("accent", " · Current") : "";
26772
- add(`${theme.bold(name)}${current}${id}`);
26773
- if (row.status === "loading") add(theme.fg("muted", "Loading usage…"));
26774
- else if (row.status === "ready") {
26775
- if (row.source === "recent_response") add(theme.fg("muted", `From a recent response. ${row.message}`));
26776
- if (row.source === "last_request") add(theme.fg("muted", usageObservationLabel(row)));
26777
- for (const window of row.windows) body.push(...windowLines(window, inner, labelWidth, now));
26778
- for (const extra of usageExtras(row, now)) add(theme.fg("muted", extra));
26779
- } else add(theme.fg(row.status === "failed" ? "error" : "muted", row.message));
26780
- }
26781
- }
26946
+ for (const row of this.rows.values()) {
26947
+ if (body.length) body.push("");
26948
+ const id = row.provider === row.name ? "" : theme.fg("muted", ` · ${safeLabel(row.provider)}`);
26949
+ add(`${theme.bold(safeLabel(row.name))}${id}`);
26950
+ if (hasWindows(row)) {
26951
+ const labelWidth = Math.min(18, Math.max(0, ...row.windows.map((window) => usageWindowLabel(window).length)));
26952
+ for (const window of row.windows) body.push(...windowLines(window, inner, labelWidth, now));
26953
+ } else add(theme.fg("muted", "Not available"));
26954
+ }
26955
+ if (!this.rows.size && !this.loading) add(theme.fg("muted", "Not available"));
26956
+ return body;
26957
+ }
26958
+ [LAYOUT_NODE]() {
26959
+ return this.layout?.[LAYOUT_NODE]();
26960
+ }
26961
+ render(width) {
26962
+ const pad = width >= 20 ? " " : "";
26963
+ const inner = Math.max(1, width - 2 * pad.length);
26782
26964
  const capacity = Math.max(1, Math.min(18, this.options.terminalRows() - 9));
26783
- this.maxOffset = Math.max(0, body.length - capacity);
26784
- this.offset = Math.min(this.offset, this.maxOffset);
26785
- const keys = `${theme.bold("Esc")} close ${theme.bold("r")} refresh${this.maxOffset ? ` ${theme.bold("↑ ↓")} scroll` : ""}`;
26786
- const content = [
26787
- theme.bold("Subscription usage"),
26788
- "",
26789
- ...body.slice(this.offset, this.offset + capacity),
26790
- "",
26791
- theme.fg("muted", keys)
26792
- ];
26793
- return [
26965
+ this.viewport.setScrollbar(this.options.scrollbar?.() ?? "hidden");
26966
+ const rowCount = this.viewport.render(inner).length;
26967
+ const bodyHeight = Math.min(rowCount, capacity);
26968
+ const keys = `${theme.bold("Esc")} close ${theme.bold("r")} refresh${rowCount > capacity ? ` ${theme.bold("↑ ↓")} scroll` : ""}`;
26969
+ const head = [
26794
26970
  ...this.border.render(width),
26795
- ...content.map((line) => `${pad}${truncateToWidth(line, inner)}`),
26971
+ `${pad}${truncateToWidth(theme.bold("Subscription usage"), inner)}`,
26972
+ ""
26973
+ ];
26974
+ const foot = [
26975
+ "",
26976
+ `${pad}${truncateToWidth(theme.fg("muted", keys), inner)}`,
26796
26977
  ...this.border.render(width)
26797
26978
  ];
26979
+ const body = pad ? new HStack([
26980
+ {
26981
+ component: fixedLines([pad]),
26982
+ basis: pad.length,
26983
+ shrink: 0
26984
+ },
26985
+ {
26986
+ component: this.viewport,
26987
+ basis: 0,
26988
+ grow: 1
26989
+ },
26990
+ {
26991
+ component: fixedLines([pad]),
26992
+ basis: pad.length,
26993
+ shrink: 0
26994
+ }
26995
+ ]) : this.viewport;
26996
+ this.layout = new VStack([
26997
+ {
26998
+ component: fixedLines(head),
26999
+ basis: head.length,
27000
+ shrink: 0
27001
+ },
27002
+ {
27003
+ component: body,
27004
+ basis: bodyHeight
27005
+ },
27006
+ {
27007
+ component: fixedLines(foot),
27008
+ basis: foot.length,
27009
+ shrink: 0
27010
+ }
27011
+ ]);
27012
+ return renderLayoutFrame(this, width, head.length + foot.length + bodyHeight, this.options.requestRender).lines;
26798
27013
  }
26799
27014
  };
26800
27015
  // dist/modes/interactive/interactive-selectors.js
@@ -26837,16 +27052,22 @@ InteractiveModeBase.prototype.showUsageSelector = function() {
26837
27052
  list: async () => {
26838
27053
  if (runtime instanceof IsolatedInteractiveRuntime) return runtime.listUsageAccounts();
26839
27054
  await this.ensureDeferredStartupComplete();
26840
- return listUsageAccounts(this.session.modelRuntime, this.session.model?.provider);
27055
+ return listUsageAccounts(this.session.modelRuntime, void 0, void 0, true);
26841
27056
  },
26842
- load: (provider, refresh) => runtime instanceof IsolatedInteractiveRuntime ? runtime.loadAccountUsage(provider, refresh) : loadAccountUsage(this.session.modelRuntime, provider, this.session.model?.provider, { maxAgeMs: refresh ? 0 : void 0 }),
27057
+ load: (provider, refresh) => runtime instanceof IsolatedInteractiveRuntime ? runtime.loadAccountUsage(provider, refresh) : loadAccountUsage(this.session.modelRuntime, provider, void 0, { maxAgeMs: refresh ? 0 : void 0 }),
27058
+ observed: async () => runtime instanceof IsolatedInteractiveRuntime ? runtime.observedUsage() : (await loadSubscriptionUsage(this.session.modelRuntime, void 0, {
27059
+ observedOnly: true,
27060
+ subscriptionsOnly: true
27061
+ })).accounts,
26843
27062
  requestRender: () => this.ui.requestRender(),
26844
27063
  close: () => {
26845
27064
  done();
26846
27065
  this.ui.requestRender();
26847
27066
  },
26848
- terminalRows: () => this.ui.terminal.rows
27067
+ terminalRows: () => this.ui.terminal.rows,
27068
+ scrollbar: () => this.settingsManager.getFullscreenScrollbar()
26849
27069
  });
27070
+ usePromptSlotLayout(component);
26850
27071
  return {
26851
27072
  component,
26852
27073
  focus: component,
@@ -27166,7 +27387,7 @@ InteractiveModeBase.prototype.handleCloneCommand = async function() {
27166
27387
  return;
27167
27388
  }
27168
27389
  try {
27169
- if ((await this.runtimeHost.fork(leafId, { position: "at" })).cancelled) {
27390
+ if ((await withSessionLoading(this, "Cloning session", () => this.runtimeHost.fork(leafId, { position: "at" }))).cancelled) {
27170
27391
  this.ui.requestRender();
27171
27392
  return;
27172
27393
  }
@@ -27437,7 +27658,7 @@ InteractiveModeBase.prototype.handleResumeTarget = async function(target) {
27437
27658
  return;
27438
27659
  }
27439
27660
  try {
27440
- const resolution = resolveResumeTarget(target, await SessionManager.listAll(this.sessionManager.getSessionStore()));
27661
+ const resolution = resolveResumeTarget(target, await withSessionLoading(this, "Finding session", () => SessionManager.listAll(this.sessionManager.getSessionStore())));
27441
27662
  if (resolution.kind === "session") await resumeCatalogSelection(this, resolution.session);
27442
27663
  else if (resolution.kind === "ambiguous") this.showError(`Resume id "${target}" is ambiguous: ${resolution.matches.map((entry) => `session ${entry.id}`).join(", ")}. Use /resume to choose an entry, or provide a unique full id.`);
27443
27664
  else this.showError(`No session matches "${target}". Use /resume to choose an entry, or provide a full id or unique 8-character hexadecimal prefix.`);
@@ -27451,12 +27672,13 @@ InteractiveModeBase.prototype.handleResumeSession = async function(sessionId, op
27451
27672
  mountIdleStatus(this.statusContainer, this.settingsManager.getClearOnShrink());
27452
27673
  const resumeStartedAt = (/* @__PURE__ */ new Date()).toISOString();
27453
27674
  try {
27454
- const result = await this.runtimeHost.switchSession(sessionId, {
27675
+ const result = await withSessionLoading(this, "Loading session", (onProgress) => this.runtimeHost.switchSession(sessionId, {
27455
27676
  withSession: options?.withSession,
27456
27677
  sessionDirectory,
27457
27678
  projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),
27458
- history: "tail"
27459
- });
27679
+ history: "tail",
27680
+ onProgress
27681
+ }));
27460
27682
  if (result.cancelled) return result;
27461
27683
  this.renderCurrentSessionState();
27462
27684
  if (this.firstRunNoticeVisible) this.clearFirstRunOnboardingUi();
@@ -27471,13 +27693,14 @@ InteractiveModeBase.prototype.handleResumeSession = async function(sessionId, op
27471
27693
  }
27472
27694
  if (error instanceof MissingSessionCwdError) switch (await this.promptForMissingSessionCwd(error)) {
27473
27695
  case "continue": {
27474
- const result = await this.runtimeHost.switchSession(sessionId, {
27696
+ const result = await withSessionLoading(this, "Loading session", (onProgress) => this.runtimeHost.switchSession(sessionId, {
27475
27697
  cwdOverride: error.issue.fallbackCwd,
27476
27698
  sessionDirectory,
27477
27699
  withSession: options?.withSession,
27478
27700
  projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),
27479
- history: "tail"
27480
- });
27701
+ history: "tail",
27702
+ onProgress
27703
+ }));
27481
27704
  if (!result.cancelled) finishMissingCwdResume(this, `Resumed session in ${error.issue.fallbackCwd}`);
27482
27705
  return result;
27483
27706
  }
@@ -27514,19 +27737,23 @@ async function forkIntoActiveStore(mode, source, cwd) {
27514
27737
  * fork. An extension that cancels the switch leaves no copy behind.
27515
27738
  */
27516
27739
  InteractiveModeBase.prototype.switchToForkedSession = async function(source, cwd, options) {
27517
- const fork = await forkIntoActiveStore(this, source, cwd);
27518
- const forkId = fork.getSessionId();
27519
- const result = await this.runtimeHost.switchSession(forkId, {
27520
- withSession: options?.withSession,
27521
- projectTrustContextFactory: (forkCwd) => this.createProjectTrustContext(forkCwd),
27522
- history: "tail",
27523
- startedSession: fork
27740
+ const { result, forkId } = await withSessionLoading(this, "Forking session", async (onProgress) => {
27741
+ const fork = await forkIntoActiveStore(this, source, cwd);
27742
+ const forkId = fork.getSessionId();
27743
+ const result = await this.runtimeHost.switchSession(forkId, {
27744
+ withSession: options?.withSession,
27745
+ projectTrustContextFactory: (forkCwd) => this.createProjectTrustContext(forkCwd),
27746
+ history: "tail",
27747
+ onProgress,
27748
+ startedSession: fork
27749
+ });
27750
+ if (result.cancelled) await this.sessionManager.deleteSession(forkId);
27751
+ return {
27752
+ result,
27753
+ forkId
27754
+ };
27524
27755
  });
27525
- if (result.cancelled) {
27526
- await this.sessionManager.deleteSession(forkId);
27527
- return result;
27528
- }
27529
- finishMissingCwdResume(this, `Forked into new session ${forkId} in ${cwd}`);
27756
+ if (!result.cancelled) finishMissingCwdResume(this, `Forked into new session ${forkId} in ${cwd}`);
27530
27757
  return result;
27531
27758
  };
27532
27759
  // dist/modes/interactive/interactive-auth-routing.js
@@ -27928,39 +28155,34 @@ InteractiveModeBase.prototype.handleReloadCommand = async function() {
27928
28155
  return;
27929
28156
  }
27930
28157
  this.resetExtensionUI();
27931
- const reloadBox = new Container$1();
27932
- const borderColor = (s) => theme.fg("border", s);
27933
- reloadBox.addChild(new DynamicBorder(borderColor));
27934
- reloadBox.addChild(new Spacer$1(1));
27935
- reloadBox.addChild(new Text$1(theme.fg("muted", "Reloading keybindings, extensions, skills, prompts, themes..."), 1, 0));
27936
- reloadBox.addChild(new Spacer$1(1));
27937
- reloadBox.addChild(new DynamicBorder(borderColor));
27938
28158
  const previousEditor = this.editor;
28159
+ const reloadFocus = new Container$1();
27939
28160
  this.editorContainer.clear();
27940
- this.editorContainer.addChild(reloadBox);
27941
- this.ui.setFocus(reloadBox);
27942
- this.ui.requestRender(true);
27943
- await new Promise((resolve) => process.nextTick(resolve));
27944
- const dismissReloadBox = (editor) => {
28161
+ this.editorContainer.addChild(reloadFocus);
28162
+ this.ui.setFocus(reloadFocus);
28163
+ this.ui.requestRender();
28164
+ const restoreEditor = (editor) => {
27945
28165
  this.editorContainer.clear();
27946
28166
  this.editorContainer.addChild(editor);
27947
28167
  this.ui.setFocus(editor);
27948
28168
  this.ui.requestRender();
27949
28169
  };
27950
28170
  try {
27951
- if (this.runtimeHost instanceof IsolatedInteractiveRuntime) await this.session.reload();
27952
- else await this.reloadCoordinator.reload(this.session);
27953
- const activeHeader = this.customHeader ?? this.builtInHeader;
27954
- if (isExpandable(activeHeader)) activeHeader.setExpanded(this.toolOutputExpanded);
27955
- setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
27956
- this.applyRuntimeSettings();
27957
- await this.themeController.applyFromSettings();
27958
- this.setupAutocompleteProvider();
27959
- const runner = this.session.extensionRunner;
27960
- this.setupExtensionShortcuts(runner);
27961
- watchSessionRenderers(this, this.session, runner);
27962
- this.rebuildChatFromMessages({ resetStartupDisclosure: true });
27963
- dismissReloadBox(this.editor);
28171
+ await withSessionLoading(this, "Reloading session", async () => {
28172
+ if (this.runtimeHost instanceof IsolatedInteractiveRuntime) await this.session.reload();
28173
+ else await this.reloadCoordinator.reload(this.session);
28174
+ const activeHeader = this.customHeader ?? this.builtInHeader;
28175
+ if (isExpandable(activeHeader)) activeHeader.setExpanded(this.toolOutputExpanded);
28176
+ setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
28177
+ this.applyRuntimeSettings();
28178
+ await this.themeController.applyFromSettings();
28179
+ this.setupAutocompleteProvider();
28180
+ const runner = this.session.extensionRunner;
28181
+ this.setupExtensionShortcuts(runner);
28182
+ watchSessionRenderers(this, this.session, runner);
28183
+ this.rebuildChatFromMessages({ resetStartupDisclosure: true });
28184
+ });
28185
+ restoreEditor(this.editor);
27964
28186
  const savedImplicitProjectTrust = await this.maybeSaveImplicitProjectTrustAfterReload();
27965
28187
  this.showLoadedResources({
27966
28188
  force: false,
@@ -27973,7 +28195,7 @@ InteractiveModeBase.prototype.handleReloadCommand = async function() {
27973
28195
  this.showStatus("Reloaded keybindings, extensions, skills, prompts, themes");
27974
28196
  } catch (error) {
27975
28197
  showRestartExtensionErrors(this);
27976
- dismissReloadBox(previousEditor);
28198
+ restoreEditor(previousEditor);
27977
28199
  this.showError(`Reload failed: ${error instanceof Error ? error.message : String(error)}`);
27978
28200
  }
27979
28201
  };
@@ -28041,7 +28263,7 @@ InteractiveModeBase.prototype.handleImportCommand = async function(text) {
28041
28263
  };
28042
28264
  try {
28043
28265
  InteractiveModeBase.prototype.clearWorkingLoader.call(this);
28044
- if ((await this.runtimeHost.importFromJsonl(inputPath)).cancelled) {
28266
+ if ((await withSessionLoading(this, "Importing session", () => this.runtimeHost.importFromJsonl(inputPath))).cancelled) {
28045
28267
  this.showStatus("Import cancelled");
28046
28268
  return;
28047
28269
  }
@@ -28049,7 +28271,7 @@ InteractiveModeBase.prototype.handleImportCommand = async function(text) {
28049
28271
  } catch (error) {
28050
28272
  if (error instanceof MissingSessionCwdError) switch (await this.promptForMissingSessionCwd(error)) {
28051
28273
  case "continue":
28052
- if ((await this.runtimeHost.importFromJsonl(inputPath, error.issue.fallbackCwd)).cancelled) {
28274
+ if ((await withSessionLoading(this, "Importing session", () => this.runtimeHost.importFromJsonl(inputPath, error.issue.fallbackCwd))).cancelled) {
28053
28275
  this.showStatus("Import cancelled");
28054
28276
  return;
28055
28277
  }
@@ -28563,7 +28785,7 @@ InteractiveModeBase.prototype.handleClearCommand = async function() {
28563
28785
  await this.ensureDeferredStartupComplete();
28564
28786
  InteractiveModeBase.prototype.clearWorkingLoader.call(this);
28565
28787
  try {
28566
- if ((await this.runtimeHost.newSession()).cancelled) return;
28788
+ if ((await withSessionLoading(this, "Starting session", () => this.runtimeHost.newSession())).cancelled) return;
28567
28789
  this.renderCurrentSessionState();
28568
28790
  if (this.firstRunNoticeVisible) this.clearFirstRunOnboardingUi();
28569
28791
  this.chatContainer.addChild(new Spacer$1(1));
@@ -28629,7 +28851,7 @@ function __atomicOnDemandFailed(error, feature) {
28629
28851
  return (async () => {
28630
28852
  const root = new URL("../", import.meta.url);
28631
28853
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
28632
- const key = `${root.href}#0.10.19-alpha.1`;
28854
+ const key = `${root.href}#0.10.20-alpha.1`;
28633
28855
  let release = releases.get(key);
28634
28856
  if (release === undefined) {
28635
28857
  const current = (async () => {
@@ -28657,7 +28879,7 @@ function __atomicOnDemandFailed(error, feature) {
28657
28879
  } catch {
28658
28880
  // No installation to read, as in a bundle of the package: the release the process runs decides.
28659
28881
  }
28660
- const updatedTo = typeof installed === "string" && installed !== "0.10.19-alpha.1" ? installed : running !== undefined && running.version !== "0.10.19-alpha.1" ? "0.10.19-alpha.1" : undefined;
28882
+ const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.1" ? installed : running !== undefined && running.version !== "0.10.20-alpha.1" ? "0.10.20-alpha.1" : undefined;
28661
28883
  if (updatedTo === undefined) throw error;
28662
28884
  const application = typeof running?.name === "string" ? running.name : "atomic";
28663
28885
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {