@gloom-sh/terminal 0.20.3 → 0.20.5

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 (348) hide show
  1. package/README.md +2 -0
  2. package/bin/gloom +9 -0
  3. package/bin/without-bun.cjs +98 -0
  4. package/package.json +3 -1
  5. package/src/account/auth-dialog.tsx +17 -0
  6. package/src/api-client/data.ts +144 -35
  7. package/src/api-client/fx-interventions.ts +64 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/release-summaries.ts +21 -0
  10. package/src/api-client/types/econ.ts +12 -0
  11. package/src/api-client/yield-curves.ts +1 -1
  12. package/src/app/global-shortcuts.ts +4 -1
  13. package/src/app/keybindings/actions.ts +8 -2
  14. package/src/app/keybindings/config.ts +2 -1
  15. package/src/app/keybindings/index.ts +1 -0
  16. package/src/app/keybindings/labels.ts +6 -1
  17. package/src/app/keybindings/resolve.ts +23 -4
  18. package/src/app/keybindings/terminal-keys.ts +35 -0
  19. package/src/app/pane-runtime/index.tsx +2 -2
  20. package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
  21. package/src/architecture/ui-literals-allowlist.json +1 -1
  22. package/src/capabilities/chart-series.ts +27 -1
  23. package/src/cli/commands/keybindings.ts +5 -5
  24. package/src/cli/commands/market.ts +154 -21
  25. package/src/cli/commands/news-search.ts +60 -10
  26. package/src/cli/commands/overview.ts +16 -1
  27. package/src/cli/commands/plugins.ts +27 -5
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +20 -4
  30. package/src/cli/commands/ticker.ts +60 -19
  31. package/src/cli/fx-forward.ts +25 -7
  32. package/src/cli/glossary.ts +19 -5
  33. package/src/cli/history-rows.ts +5 -3
  34. package/src/cli/index.ts +8 -8
  35. package/src/cli/known-gaps.ts +27 -1
  36. package/src/cli/listing-arg.ts +11 -1
  37. package/src/cli/name-entries.ts +5 -1
  38. package/src/cli/not-a-ticker.ts +4 -0
  39. package/src/cli/pane-functions/function-help.ts +5 -5
  40. package/src/cli/report-tables.ts +18 -6
  41. package/src/cli/result.ts +15 -7
  42. package/src/cli/types.ts +2 -0
  43. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  44. package/src/components/chart/composite/composite-chart.tsx +54 -13
  45. package/src/components/chart/composite/event-captions.ts +109 -0
  46. package/src/components/chart/composite/event-guides.ts +74 -0
  47. package/src/components/chart/composite/rasterizer.ts +2 -0
  48. package/src/components/chart/composite/text-renderer.ts +2 -0
  49. package/src/components/chart/composite/types.ts +31 -0
  50. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  51. package/src/components/command-bar/pane-settings.ts +2 -2
  52. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  53. package/src/components/command-bar/routes/root/results.ts +6 -2
  54. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  55. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  56. package/src/components/input-search-bar.tsx +9 -2
  57. package/src/components/layout/detached-pane-shell.tsx +1 -1
  58. package/src/components/layout/floating-pane.tsx +5 -1
  59. package/src/components/layout/pane/footer/index.tsx +21 -14
  60. package/src/components/layout/pane/footer/model.ts +6 -0
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  63. package/src/components/layout/shell/active-drag.ts +149 -105
  64. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  65. package/src/components/layout/shell/drag/index.ts +47 -218
  66. package/src/components/layout/shell/drag/live.ts +10 -3
  67. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  68. package/src/components/layout/shell/drag/runtime.ts +29 -6
  69. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  70. package/src/components/layout/shell/index.tsx +11 -6
  71. package/src/components/layout/shell/menu.ts +11 -2
  72. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  73. package/src/components/layout/shell/native/window-state.ts +2 -2
  74. package/src/components/layout/shell/pane/capture.ts +4 -1
  75. package/src/components/layout/shell/pane/layers.tsx +71 -7
  76. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  77. package/src/components/layout/shell/window-mode/index.ts +8 -10
  78. package/src/components/layout/status-bar.tsx +6 -1
  79. package/src/components/layout/window-edit/mode.ts +39 -7
  80. package/src/components/layout/window-edit/presentation.ts +1 -1
  81. package/src/components/onboarding/first-run-workspace.ts +44 -2
  82. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  83. package/src/components/onboarding/onboarding-keyboard.ts +20 -0
  84. package/src/components/onboarding/onboarding-wizard.tsx +16 -11
  85. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  86. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  87. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  88. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  89. package/src/components/pane-settings-dialog/value.ts +6 -0
  90. package/src/components/pane-settings-dialog.tsx +3 -3
  91. package/src/components/reader/detail-reader.tsx +4 -0
  92. package/src/components/ui/button.tsx +2 -0
  93. package/src/components/ui/choice-dialog.tsx +1 -0
  94. package/src/components/ui/data-table/index.tsx +4 -3
  95. package/src/components/ui/index.ts +1 -1
  96. package/src/components/ui/list-view.tsx +7 -12
  97. package/src/components/ui/loading.tsx +10 -3
  98. package/src/components/ui/menu.tsx +6 -2
  99. package/src/components/ui/page-stack-view.tsx +3 -0
  100. package/src/components/ui/pane-link-chip.tsx +269 -54
  101. package/src/components/ui/query-bar.tsx +2 -1
  102. package/src/components/ui/quote.ts +14 -1
  103. package/src/components/ui/tabs.tsx +97 -19
  104. package/src/core/state/app/layout-reducer.ts +7 -0
  105. package/src/core/state/app/layout.ts +44 -7
  106. package/src/core/state/app/state.ts +1 -1
  107. package/src/core/state/app/types.ts +22 -2
  108. package/src/data/config/layout.ts +5 -2
  109. package/src/docs/snapshot.json +54 -13
  110. package/src/i18n/es.ts +9 -8
  111. package/src/i18n/ja.ts +9 -8
  112. package/src/i18n/ko.ts +9 -8
  113. package/src/i18n/zh-cn.ts +9 -8
  114. package/src/i18n/zh-tw.ts +9 -8
  115. package/src/layout/pane-manager/floating-actions.ts +17 -0
  116. package/src/layout/pane-manager/floating-stack.ts +187 -0
  117. package/src/layout/pane-manager/floating.ts +4 -2
  118. package/src/layout/pane-manager/gridlock.ts +5 -1
  119. package/src/layout/pane-manager/index.ts +11 -0
  120. package/src/layout/pane-manager/layout-state.ts +10 -3
  121. package/src/market-data/depositary-pair.ts +5 -3
  122. package/src/market-data/futures-board.ts +46 -1
  123. package/src/market-data/futures-contract.ts +12 -3
  124. package/src/market-data/fx-interventions.ts +270 -0
  125. package/src/market-data/market/dated-previous-close.ts +94 -15
  126. package/src/market-data/market/status.ts +17 -1
  127. package/src/news/news-model.ts +44 -2
  128. package/src/plugins/builtin/alerts/cli.ts +4 -4
  129. package/src/plugins/builtin/alerts/format.ts +1 -2
  130. package/src/plugins/builtin/alerts/headless.ts +1 -2
  131. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  132. package/src/plugins/builtin/alerts/move.ts +30 -9
  133. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  134. package/src/plugins/builtin/alerts/storage.ts +4 -2
  135. package/src/plugins/builtin/alerts/types.ts +12 -0
  136. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  137. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  138. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  139. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  140. package/src/plugins/builtin/awards/index.tsx +1 -1
  141. package/src/plugins/builtin/buildout/index.tsx +1 -0
  142. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  143. package/src/plugins/builtin/cds/headless.ts +4 -0
  144. package/src/plugins/builtin/changelog/index.tsx +292 -101
  145. package/src/plugins/builtin/changelog/versions.ts +293 -0
  146. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  147. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  148. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  149. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  150. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  151. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  152. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  153. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  154. package/src/plugins/builtin/chat/layout.ts +5 -2
  155. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  156. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  157. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  158. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  159. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  160. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  161. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  162. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  163. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  164. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  165. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  166. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  167. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  168. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  169. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  170. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  171. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
  172. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  173. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  174. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  175. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  176. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  177. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  178. package/src/plugins/builtin/cot/headless.ts +14 -2
  179. package/src/plugins/builtin/cot/index.tsx +1 -1
  180. package/src/plugins/builtin/cpi/index.tsx +1 -1
  181. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  182. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  183. package/src/plugins/builtin/doe/index.tsx +1 -1
  184. package/src/plugins/builtin/earnings/index.tsx +2 -2
  185. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  186. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  187. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  188. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  189. package/src/plugins/builtin/econ/index.tsx +1 -0
  190. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  191. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  192. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  193. package/src/plugins/builtin/executives/index.tsx +1 -0
  194. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  195. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  196. package/src/plugins/builtin/futures/index.tsx +25 -4
  197. package/src/plugins/builtin/futures/model.ts +28 -32
  198. package/src/plugins/builtin/futures/series.ts +4 -3
  199. package/src/plugins/builtin/futures/table.tsx +16 -9
  200. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  201. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  202. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  203. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  204. package/src/plugins/builtin/gpu/index.tsx +1 -1
  205. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  206. package/src/plugins/builtin/help/index.tsx +14 -4
  207. package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
  208. package/src/plugins/builtin/holders/index.tsx +1 -0
  209. package/src/plugins/builtin/holders/report-header.ts +2 -2
  210. package/src/plugins/builtin/insider/index.tsx +1 -0
  211. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  212. package/src/plugins/builtin/jobs/index.tsx +1 -0
  213. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  214. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  215. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  216. package/src/plugins/builtin/macro-day/model.ts +19 -3
  217. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  218. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  219. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  220. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  221. package/src/plugins/builtin/members/index.tsx +1 -1
  222. package/src/plugins/builtin/mna/index.tsx +1 -0
  223. package/src/plugins/builtin/news/headless.ts +2 -2
  224. package/src/plugins/builtin/news/index.tsx +4 -3
  225. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  226. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  227. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  228. package/src/plugins/builtin/options/index.tsx +1 -0
  229. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  230. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  231. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  232. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  233. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  234. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  235. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  236. package/src/plugins/builtin/power/index.tsx +1 -1
  237. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  238. package/src/plugins/builtin/research/event-model.ts +9 -1
  239. package/src/plugins/builtin/research/event-sources.ts +22 -0
  240. package/src/plugins/builtin/research/headless.ts +11 -5
  241. package/src/plugins/builtin/research/index.tsx +4 -0
  242. package/src/plugins/builtin/research-search/index.tsx +1 -0
  243. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  244. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  245. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  246. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  247. package/src/plugins/builtin/scanner/headless.ts +52 -13
  248. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  249. package/src/plugins/builtin/sec/index.tsx +1 -0
  250. package/src/plugins/builtin/series-inventory.ts +1 -1
  251. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  252. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  253. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  254. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  255. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  256. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  257. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  258. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  259. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  260. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  261. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  262. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  263. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  264. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  265. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  266. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  267. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  268. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  270. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
  271. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  272. package/src/plugins/builtin/time-sales/client.ts +9 -11
  273. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  274. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  275. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  276. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  277. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  278. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  279. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  280. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  281. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  282. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  283. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  284. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  285. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  286. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  287. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  288. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  289. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  290. package/src/plugins/installer.ts +45 -0
  291. package/src/portfolio/column-values.ts +2 -1
  292. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  293. package/src/public/remote.ts +7 -1
  294. package/src/remote/client.ts +191 -11
  295. package/src/remote/controller-utils.ts +13 -1
  296. package/src/remote/controller.ts +88 -26
  297. package/src/remote/endpoint.ts +24 -0
  298. package/src/remote/form.ts +59 -4
  299. package/src/remote/resources.ts +56 -19
  300. package/src/remote/schema.ts +22 -9
  301. package/src/remote/secrets.ts +12 -0
  302. package/src/remote/semantic-helpers.ts +29 -1
  303. package/src/remote/semantic-tree.tsx +44 -15
  304. package/src/remote/server.ts +2 -1
  305. package/src/remote/surface.tsx +192 -0
  306. package/src/remote/types.ts +5 -0
  307. package/src/renderers/cloudflare/worker.ts +16 -1
  308. package/src/renderers/dom/styles.css +40 -6
  309. package/src/renderers/opentui/host.tsx +6 -0
  310. package/src/renderers/share/layout-view.tsx +1 -1
  311. package/src/series/standalone.ts +2 -2
  312. package/src/shares/api.ts +21 -4
  313. package/src/shares/item.ts +73 -0
  314. package/src/shares/pane-item.ts +205 -0
  315. package/src/shares/pane.ts +4 -0
  316. package/src/shares/payload.ts +9 -5
  317. package/src/sources/gloomberb-cloud/news.ts +37 -12
  318. package/src/state/opening-ticker-panes.ts +47 -0
  319. package/src/test-support/cli-context.ts +2 -0
  320. package/src/test-support/preload.ts +4 -1
  321. package/src/tickers/instrument-kind.ts +23 -3
  322. package/src/tickers/renamed-listings.ts +105 -0
  323. package/src/tickers/search/index.ts +103 -16
  324. package/src/time-series/resolve.ts +2 -2
  325. package/src/types/config.ts +5 -0
  326. package/src/types/context-menu.ts +2 -0
  327. package/src/types/financials.ts +1 -0
  328. package/src/types/plugin-commands.ts +140 -0
  329. package/src/types/plugin-context.ts +125 -0
  330. package/src/types/plugin-contributions.ts +55 -0
  331. package/src/types/plugin-definition.ts +234 -0
  332. package/src/types/plugin-notifications.ts +38 -0
  333. package/src/types/plugin-pane-settings.ts +116 -0
  334. package/src/types/plugin-pane-templates.ts +160 -0
  335. package/src/types/plugin-panes.ts +243 -0
  336. package/src/types/plugin-reports.ts +35 -0
  337. package/src/types/plugin-shared.ts +14 -0
  338. package/src/types/plugin-state.ts +71 -0
  339. package/src/types/plugin.ts +14 -1169
  340. package/src/ui/index.tsx +14 -3
  341. package/src/updater/github-releases.ts +23 -0
  342. package/src/utils/central-banks.ts +86 -1
  343. package/src/utils/cli-output.ts +22 -9
  344. package/src/utils/datetime-format.ts +12 -3
  345. package/src/utils/depositary-receipt.ts +28 -3
  346. package/src/utils/fundamentals.ts +14 -0
  347. package/src/utils/max-drawdown.ts +97 -16
  348. package/src/utils/untrusted-text.ts +29 -0
@@ -22,6 +22,12 @@ import {
22
22
  type ToolResultStatus,
23
23
  } from "./protocol";
24
24
  import { normalizeJson } from "./json";
25
+ import {
26
+ redactRelayResult,
27
+ redactResource,
28
+ storedCredentials,
29
+ withoutStoredCredentials,
30
+ } from "../terminal-relay/redact";
25
31
  import {
26
32
  capToolNote,
27
33
  joinToolNotes,
@@ -33,6 +39,7 @@ import {
33
39
  remoteRequestForTool,
34
40
  resolveRemoteToolBinding,
35
41
  toolExecutionTimeoutMs,
42
+ type RemoteToolBinding,
36
43
  } from "./manifest";
37
44
  import {
38
45
  ASKGUndoManager,
@@ -40,6 +47,7 @@ import {
40
47
  type InProcessRemoteControlHandler,
41
48
  } from "./undo";
42
49
  import { logFailure } from "../../../../utils/log-failure";
50
+ import { describeConfirmedOperation, planUiCall, UiCallRefusal, type UiCallPlan } from "../terminal-relay/policy";
43
51
 
44
52
  interface HeadlessExecution {
45
53
  result: unknown;
@@ -68,11 +76,33 @@ export interface ASKGToolExecutorDependencies {
68
76
 
69
77
  interface ASKGToolExecutionOptions {
70
78
  signal?: AbortSignal;
79
+ /** The person approved this call (or a dry run found nothing to approve). */
71
80
  confirmed?: boolean;
72
81
  /** The confirmKey of the preview the person approved, so the app does not ask again. */
73
82
  confirmedChange?: string;
83
+ /** The gate the call was asked about with, checked again right before it runs. */
84
+ gate?: ASKGToolGate;
85
+ /** One of Ask Gloom's confirmations waits for the person. */
86
+ promptOpen?: () => boolean;
74
87
  }
75
88
 
89
+ /**
90
+ * What the per-operation policy shared with the terminal relay
91
+ * (terminal-relay/policy.ts) says about a call that acts on what is on
92
+ * screen (a press, a submit, a command-bar row), or about a confirmed
93
+ * operation it describes (a layout delete, by the layout's name).
94
+ */
95
+ export type ASKGToolGate =
96
+ /** Refused before anything is asked: it aims at a confirmation, or one is open. */
97
+ | { kind: "refusal"; message: string }
98
+ /** Scroll, select, setValue, focus, a row that opens a ticker or a pane. */
99
+ | { kind: "silent"; recheck: UiCallPlan["recheck"] }
100
+ /** Asks first, naming the control and its pane, the row it opens, or the layout it deletes. */
101
+ | { kind: "ask"; title: string; lines: string[]; recheck: UiCallPlan["recheck"] };
102
+
103
+ /** Why a call that changes the app did not run while one of Ask Gloom's questions waited (controller.ts). */
104
+ export const CONFIRMATION_WAITING_NOTE = "Gloom is waiting for the person to answer a confirmation, and nothing else that changes the app runs until then. This call did not run; retry it after they answer.";
105
+
76
106
  /**
77
107
  * What a call needing approval will change, from the operation's own dry run:
78
108
  * the list and listing it resolved rather than the arguments as sent.
@@ -95,6 +125,11 @@ export interface ASKGToolExecutor {
95
125
  ): Promise<ToolResultPayload>;
96
126
  /** Null when the call has no dry run that says more than its arguments. */
97
127
  preview?(call: ASKGToolCallEvent, signal?: AbortSignal): Promise<ASKGToolPreview | null>;
128
+ /**
129
+ * Null when the policy has nothing to add for the call. Throws when it
130
+ * cannot tell (the screen could not be read): the call does not run.
131
+ */
132
+ gate(call: ASKGToolCallEvent, options: { promptOpen: boolean; signal?: AbortSignal }): Promise<ASKGToolGate | null>;
98
133
  undo(token: string, signal?: AbortSignal): Promise<AppliedUndo>;
99
134
  }
100
135
 
@@ -238,6 +273,15 @@ function inferRemoteRowCount(value: unknown): number | undefined {
238
273
  return 1;
239
274
  }
240
275
 
276
+ /**
277
+ * An app resource or operation result as an assistant may read it, by the
278
+ * same rules as the terminal relay: configuration without its credentials
279
+ * and broker settings, and no secret-named or typed-password value anywhere.
280
+ */
281
+ function redactRemoteData(binding: RemoteToolBinding, args: Record<string, JsonValue>, data: unknown): unknown {
282
+ return redactRelayResult(binding.kind === "resource" ? redactResource(String(args.resource), data) : data);
283
+ }
284
+
241
285
  /**
242
286
  * How much longer the server waits for this call, by its frame: its timeout,
243
287
  * and never past the time it expires.
@@ -342,20 +386,67 @@ export function createASKGToolExecutor(
342
386
  ?? defaultHeadlessExecutor(dependencies.registry, dependencies.context);
343
387
  const undoManager = dependencies.undoManager ?? new ASKGUndoManager(dependencies.remoteHandler);
344
388
 
389
+ const readResource = async (resource: string, signal?: AbortSignal): Promise<unknown> => {
390
+ const response = await runWithDeadline(
391
+ () => dependencies.remoteHandler({ type: "get", resource }),
392
+ PREVIEW_TIMEOUT_MS,
393
+ signal,
394
+ );
395
+ if (!response.ok) throw new Error(response.error.message);
396
+ return response.data;
397
+ };
398
+
399
+ const gate = async (
400
+ call: ASKGToolCallEvent,
401
+ { promptOpen, signal }: { promptOpen: boolean; signal?: AbortSignal },
402
+ ): Promise<ASKGToolGate | null> => {
403
+ if (manifests.get(call.name)?.source !== "remote-op") return null;
404
+ const binding = resolveRemoteToolBinding(call.name);
405
+ if (binding?.kind !== "operation") return null;
406
+ const read = (resource: string) => readResource(resource, signal);
407
+ try {
408
+ const plan = await planUiCall(binding.operation, call.args, { read, promptOpen });
409
+ if (plan) {
410
+ return plan.confirm
411
+ ? {
412
+ kind: "ask",
413
+ title: plan.confirm.title,
414
+ lines: plan.confirm.lines.map(({ label, value }) => `${label}: ${value}`),
415
+ recheck: plan.recheck,
416
+ }
417
+ : { kind: "silent", recheck: plan.recheck };
418
+ }
419
+ const described = await describeConfirmedOperation(binding.operation, call.args, read);
420
+ if (!described) return null;
421
+ const recheck = described.recheck;
422
+ return {
423
+ kind: "ask",
424
+ title: described.confirm.title,
425
+ lines: described.confirm.lines.map(({ label, value }) => `${label}: ${value}`),
426
+ recheck: async () => (recheck ? recheck() : null),
427
+ };
428
+ } catch (error) {
429
+ if (error instanceof UiCallRefusal) return { kind: "refusal", message: error.message };
430
+ throw error;
431
+ }
432
+ };
433
+
345
434
  const execute = async (
346
435
  call: ASKGToolCallEvent,
347
436
  options: ASKGToolExecutionOptions = {},
348
437
  ): Promise<ToolResultPayload> => {
349
438
  const startedAt = now();
439
+ // Whatever leaves the app, a pane function's rows included, without a credential the config stores.
440
+ const credentials = storedCredentials(dependencies.context?.config);
350
441
  const base = (value: ExecutionValue): ToolResultPayload => withBoundedPayload({
351
442
  turnId: call.turnId,
352
443
  toolCallId: call.toolCallId,
353
444
  status: value.status,
354
- ...(value.result !== undefined ? { result: normalizeJson(value.result) } : {}),
445
+ ...(value.result !== undefined ? { result: withoutStoredCredentials(normalizeJson(value.result), credentials) } : {}),
355
446
  ...(value.rowCount !== undefined ? { rowCount: value.rowCount } : {}),
356
447
  truncated: value.truncated ?? false,
357
448
  elapsedMs: Math.max(0, now() - startedAt),
358
- ...(value.note ? { note: capToolNote(value.note) } : {}),
449
+ ...(value.note ? { note: capToolNote(withoutStoredCredentials(value.note, credentials)) } : {}),
359
450
  ...(value.rev ? { rev: value.rev } : {}),
360
451
  ...(value.undoToken ? { undoToken: value.undoToken } : {}),
361
452
  });
@@ -373,6 +464,17 @@ export function createASKGToolExecutor(
373
464
  if ((manifest.confirm === "always" || call.requiresConfirmation) && !options.confirmed) {
374
465
  return base({ status: "denied", note: "This tool call requires local confirmation." });
375
466
  }
467
+ const promptOpen = () => options.promptOpen?.() ?? false;
468
+ let screenGate: ASKGToolGate | null;
469
+ try {
470
+ screenGate = options.gate ?? await gate(call, { promptOpen: promptOpen(), ...(options.signal ? { signal: options.signal } : {}) });
471
+ } catch (error) {
472
+ return base({ status: "error", note: toolErrorNote(error) });
473
+ }
474
+ if (screenGate?.kind === "refusal") return base({ status: "denied", note: screenGate.message });
475
+ if (screenGate?.kind === "ask" && !options.confirmed) {
476
+ return base({ status: "denied", note: "This tool call requires local confirmation." });
477
+ }
376
478
 
377
479
  const timeoutMs = Math.min(toolExecutionTimeoutMs(manifest), toolCallRemainingMs(call, now()));
378
480
  try {
@@ -403,6 +505,12 @@ export function createASKGToolExecutor(
403
505
  }
404
506
  }
405
507
 
508
+ // The last look before it acts: the screen may have changed while the person decided.
509
+ const stale = await screenGate?.recheck(promptOpen());
510
+ if (stale) return { status: "denied", note: stale };
511
+ // Nothing that changes the app runs while one of Ask Gloom's questions waits.
512
+ if (manifest.writeTier !== "read" && promptOpen()) return { status: "denied", note: CONFIRMATION_WAITING_NOTE };
513
+
406
514
  const response = await dependencies.remoteHandler(remoteRequestForTool(binding, call.args), {
407
515
  signal,
408
516
  ...(options.confirmed && options.confirmedChange ? { confirmed: options.confirmedChange } : {}),
@@ -410,7 +518,7 @@ export function createASKGToolExecutor(
410
518
  if (!response.ok) {
411
519
  return {
412
520
  status: "error",
413
- result: { code: response.error.code, ...(response.error.details !== undefined ? { details: response.error.details } : {}) },
521
+ result: redactRemoteData(binding, call.args, { code: response.error.code, ...(response.error.details !== undefined ? { details: response.error.details } : {}) }),
414
522
  note: toolErrorNote(response.error.message),
415
523
  };
416
524
  }
@@ -425,7 +533,7 @@ export function createASKGToolExecutor(
425
533
  }
426
534
  return {
427
535
  status: "ok",
428
- result: response.data,
536
+ result: redactRemoteData(binding, call.args, response.data),
429
537
  rowCount: inferRemoteRowCount(response.data),
430
538
  ...(undoNote ? { note: undoNote } : {}),
431
539
  ...(response.rev ? { rev: response.rev } : response.state?.rev ? { rev: response.state.rev } : {}),
@@ -471,6 +579,7 @@ export function createASKGToolExecutor(
471
579
  return {
472
580
  execute,
473
581
  preview,
582
+ gate,
474
583
  undo: (token, signal) => undoManager.undo(token, signal),
475
584
  };
476
585
  }
@@ -8,6 +8,7 @@ import {
8
8
  remoteOperationToolName,
9
9
  } from "../../../../remote/schema";
10
10
  import type { RemoteControlRequest } from "../../../../remote/types";
11
+ import { operationPolicy } from "../terminal-relay/policy";
11
12
  import type {
12
13
  HeadlessPaneDefinition,
13
14
  PaneDef,
@@ -29,7 +30,8 @@ const REMOTE_TOOL_TIMEOUT_MS = 10_000;
29
30
  /**
30
31
  * A tool that asks first waits for a person to read the prompt and click, so
31
32
  * the server holds the call this long: the minute the terminal relay gives a
32
- * confirmation. A server from before the window holds it 10 s.
33
+ * confirmation. A UI action that may ask declares it too. A server from
34
+ * before the window holds either 10 s.
33
35
  */
34
36
  const CONFIRM_TOOL_TIMEOUT_MS = 60_000;
35
37
  const REMOTE_RESOURCE_TOOL_NAME = "app.get_resource";
@@ -193,7 +195,7 @@ function remoteCandidates(registry: PaneFunctionCatalog): ManifestCandidate[] {
193
195
  description: descriptor.description,
194
196
  writeTier: descriptor.writeTier,
195
197
  inputSchema: descriptor.inputSchema,
196
- ...remoteConfirmation(descriptor.writeTier),
198
+ ...remoteConfirmation(operationsByName.get(descriptor.name)!.id, descriptor.writeTier),
197
199
  },
198
200
  }));
199
201
 
@@ -226,21 +228,34 @@ function remoteCandidates(registry: PaneFunctionCatalog): ManifestCandidate[] {
226
228
  return candidates;
227
229
  }
228
230
 
229
- /** Account and broker writes ask first, and get the minute that takes. */
230
- function remoteConfirmation(writeTier: ClientToolManifest["writeTier"]): Pick<ClientToolManifest, "confirm" | "timeoutMs"> {
231
- return writeTier === "user-data" || writeTier === "broker"
232
- ? { confirm: "always", timeoutMs: CONFIRM_TOOL_TIMEOUT_MS }
233
- : { confirm: "never", timeoutMs: REMOTE_TOOL_TIMEOUT_MS };
231
+ /**
232
+ * Account and broker writes ask first, and so does every operation the
233
+ * per-operation policy confirms each time (terminal-relay/policy.ts); they get
234
+ * the minute that takes. A UI action is asked about call by call instead
235
+ * (executor.ts), since scrolling or selecting asks nothing, so it says
236
+ * `never` and still declares the minute: the server holds it that long, and
237
+ * a scroll answers as soon as it ran.
238
+ */
239
+ function remoteConfirmation(
240
+ operation: string,
241
+ writeTier: ClientToolManifest["writeTier"],
242
+ ): Pick<ClientToolManifest, "confirm" | "timeoutMs"> {
243
+ const { policy } = operationPolicy(operation);
244
+ if (writeTier === "user-data" || writeTier === "broker" || policy === "confirm") {
245
+ return { confirm: "always", timeoutMs: CONFIRM_TOOL_TIMEOUT_MS };
246
+ }
247
+ if (policy === "local-ui" || policy === "navigation") return { confirm: "never", timeoutMs: CONFIRM_TOOL_TIMEOUT_MS };
248
+ return { confirm: "never", timeoutMs: REMOTE_TOOL_TIMEOUT_MS };
234
249
  }
235
250
 
236
251
  /**
237
- * How long a call may run once it starts. A tool that asks first declares the
238
- * window for the person and the write together; the write itself keeps the
239
- * budget of every app action, counted from the approval rather than from the
240
- * call. The server's deadline for the call still bounds it.
252
+ * How long a call may run once it starts. A tool that may ask first declares
253
+ * the window for the person and the action together; an app action itself
254
+ * keeps the budget of every app action, counted from the approval rather
255
+ * than from the call. The server's deadline for the call still bounds it.
241
256
  */
242
- export function toolExecutionTimeoutMs(manifest: Pick<ClientToolManifest, "confirm" | "timeoutMs">): number {
243
- return manifest.confirm === "always"
257
+ export function toolExecutionTimeoutMs(manifest: Pick<ClientToolManifest, "confirm" | "source" | "timeoutMs">): number {
258
+ return manifest.confirm === "always" || manifest.source === "remote-op"
244
259
  ? Math.min(manifest.timeoutMs, REMOTE_TOOL_TIMEOUT_MS)
245
260
  : manifest.timeoutMs;
246
261
  }
@@ -50,6 +50,11 @@ export interface ASKGToolRow {
50
50
  requiresConfirmation: boolean;
51
51
  /** Dry run description shown before a `user-data` or `broker` call runs. */
52
52
  preview?: JsonValue;
53
+ /**
54
+ * What the approval asks, when the call says more than its tool: the
55
+ * control a UI action presses, by label and role.
56
+ */
57
+ confirmTitle?: string;
53
58
  rowCount?: number;
54
59
  elapsedMs?: number;
55
60
  truncated?: boolean;
@@ -152,8 +157,11 @@ export type ASKGAction =
152
157
  | { type: "feedback"; turnId: string; feedback: ASKGTurnFeedback | null }
153
158
  | { type: "feedback-unavailable" }
154
159
  | { type: "event"; event: ASKGSseEvent }
155
- /** `preview` is what the app resolved the call to, in place of the server's account of its arguments. */
156
- | { type: "tool-awaiting-confirmation"; toolCallId: string; preview?: string }
160
+ /**
161
+ * `preview` is what the app resolved the call to, in place of the server's
162
+ * account of its arguments; `title` names what a UI action will press.
163
+ */
164
+ | { type: "tool-awaiting-confirmation"; toolCallId: string; preview?: string; title?: string }
157
165
  | { type: "tool-running"; toolCallId: string }
158
166
  | { type: "tool-result"; payload: ToolResultPayload }
159
167
  | { type: "tool-expanded"; toolCallId: string; expanded: boolean }
@@ -166,8 +174,9 @@ export type ASKGAction =
166
174
  | { type: "reset" };
167
175
 
168
176
  /**
169
- * Tiers that never run without the user saying so. `read` is silent and
170
- * `ui-write` is reversible, so only account and broker writes stop the turn.
177
+ * Tiers that never run without the user saying so. `read` is silent; a
178
+ * `ui-write` call that presses something on screen is asked about call by
179
+ * call (executor.ts gate), the rest of `ui-write` is reversible.
171
180
  */
172
181
  export function requiresLocalConfirmation(call: {
173
182
  writeTier: WriteTier;
@@ -483,6 +492,7 @@ export function askgReducer(
483
492
  ...row,
484
493
  status: "awaiting-confirmation",
485
494
  ...(action.preview !== undefined ? { preview: action.preview } : {}),
495
+ ...(action.title !== undefined ? { confirmTitle: action.title } : {}),
486
496
  }));
487
497
  case "tool-running":
488
498
  return patchToolRow(state, action.toolCallId, (row) => ({ ...row, status: "running" }));
@@ -32,7 +32,6 @@ import {
32
32
  MessageComposer,
33
33
  Prose,
34
34
  shouldShowPaneSidebar,
35
- Spinner,
36
35
  usePaneFooter,
37
36
  type PaneHint,
38
37
  } from "../../../../components";
@@ -46,6 +45,8 @@ import {
46
45
  } from "../../../../state/app/context";
47
46
  import { useInlineTickers } from "../../../../state/hooks/inline-tickers";
48
47
  import { useRemoteControlHandler } from "../../../../remote/app-host";
48
+ import { RemoteUiScope } from "../../../../remote/semantic-tree";
49
+ import { ASKG_PROMPT_SCOPE } from "../terminal-relay/policy";
49
50
  import { useThemeColors } from "../../../../theme/theme-context";
50
51
  import type { PaneProps } from "../../../../types/plugin";
51
52
  import type { ContextMenuItem } from "../../../../types/context-menu";
@@ -139,6 +140,7 @@ import {
139
140
  UNDO_KEY,
140
141
  } from "./tool-timeline";
141
142
  import { ClippedText } from "../../../../components/ui/display";
143
+ import { TurnProgress, TurnQuestion } from "./turn-parts";
142
144
  import { logFailure } from "../../../../utils/log-failure";
143
145
 
144
146
  export const ASKG_PANE_ID = "askg";
@@ -350,51 +352,72 @@ function isSourceLink(href: string): boolean {
350
352
  return href.startsWith(SOURCE_LINK_SCHEME);
351
353
  }
352
354
 
353
- /** Rows the confirmation block reserves for the dry run preview. */
354
- const MAX_PREVIEW_LINES = 4;
355
+ /**
356
+ * Rows the confirmation's preview always gets. It takes every line it has
357
+ * while the conversation keeps its slice, so an order shows its size and
358
+ * price, not only its symbol and side.
359
+ */
360
+ const MIN_PREVIEW_LINES = 4;
361
+
362
+ function confirmationPreviewRows(row: ASKGToolRow, room: number): number {
363
+ return Math.min(previewLines(row.preview).length, Math.max(MIN_PREVIEW_LINES, room));
364
+ }
355
365
 
356
- function confirmationBlockHeight(row: ASKGToolRow): number {
357
- return 3 + Math.min(MAX_PREVIEW_LINES, previewLines(row.preview).length);
366
+ /** The title row, then the preview, then the buttons under a blank row. */
367
+ function confirmationBlockHeight(previewRows: number): number {
368
+ return 3 + previewRows;
358
369
  }
359
370
 
360
371
  function ConfirmationPrompt({
361
372
  row,
373
+ previewRows,
362
374
  width,
363
375
  onApprove,
364
376
  onDecline,
365
377
  }: {
366
378
  row: ASKGToolRow;
379
+ previewRows: number;
367
380
  width: number;
368
381
  onApprove: () => void;
369
382
  onDecline: () => void;
370
383
  }) {
371
384
  const colors = useThemeColors();
372
- const lines = previewLines(row.preview).slice(0, MAX_PREVIEW_LINES);
385
+ const lines = previewLines(row.preview).slice(0, previewRows);
373
386
  return (
374
- <Box
375
- flexDirection="column"
376
- flexShrink={0}
377
- paddingX={1}
378
- height={confirmationBlockHeight(row)}
379
- backgroundColor={colors.panel}
380
- >
381
- <Box flexDirection="row" height={1}>
382
- <Text fg={colors.warning} attributes={TextAttributes.BOLD}>{`Approve ${toolTitle(row.name)}?`}</Text>
383
- <Text fg={colors.textDim}>
384
- {` changes ${tierLabel(row) ?? "data"}${row.argumentSummary ? ` · ${row.argumentSummary}` : ""}`}
385
- </Text>
386
- </Box>
387
- {lines.map((line, index) => (
388
- <Box key={index} height={1}>
389
- <ClippedText fg={colors.text} text={line} width={Math.max(10, width - 2)} cut={truncateWithEllipsis} />
387
+ // Marked so no assistant's UI call can press Approve here (terminal-relay/policy.ts).
388
+ <RemoteUiScope scope={ASKG_PROMPT_SCOPE}>
389
+ <Box
390
+ flexDirection="column"
391
+ flexShrink={0}
392
+ paddingX={1}
393
+ height={confirmationBlockHeight(lines.length)}
394
+ backgroundColor={colors.panel}
395
+ >
396
+ <Box flexDirection="row" height={1}>
397
+ {row.confirmTitle ? (
398
+ // A UI action: the control it presses, by label and role.
399
+ <ClippedText fg={colors.warning} attributes={TextAttributes.BOLD} text={`${row.confirmTitle}?`} width={Math.max(10, width - 2)} cut={truncateWithEllipsis} />
400
+ ) : (
401
+ <>
402
+ <Text fg={colors.warning} attributes={TextAttributes.BOLD}>{`Approve ${toolTitle(row.name)}?`}</Text>
403
+ <Text fg={colors.textDim}>
404
+ {` changes ${tierLabel(row) ?? "data"}${row.argumentSummary ? ` · ${row.argumentSummary}` : ""}`}
405
+ </Text>
406
+ </>
407
+ )}
408
+ </Box>
409
+ {lines.map((line, index) => (
410
+ <Box key={index} height={1}>
411
+ <ClippedText fg={colors.text} text={line} width={Math.max(10, width - 2)} cut={truncateWithEllipsis} />
412
+ </Box>
413
+ ))}
414
+ <Box flexDirection="row" height={2} paddingTop={1}>
415
+ <Button label="Approve" variant="primary" shortcut="y" onPress={onApprove} />
416
+ <Box width={2} />
417
+ <Button label="Decline" shortcut="n" onPress={onDecline} />
390
418
  </Box>
391
- ))}
392
- <Box flexDirection="row" height={2} paddingTop={1}>
393
- <Button label="Approve" variant="primary" shortcut="y" onPress={onApprove} />
394
- <Box width={2} />
395
- <Button label="Decline" shortcut="n" onPress={onDecline} />
396
419
  </Box>
397
- </Box>
420
+ </RemoteUiScope>
398
421
  );
399
422
  }
400
423
 
@@ -486,27 +509,25 @@ function TurnView({
486
509
  onShare: () => void;
487
510
  }) {
488
511
  const colors = useThemeColors();
512
+ // The server holds back the questions to ask next and leaves the blank
513
+ // lines before them, which would open a gap under the answer. A first
514
+ // line keeps its indent: it can start a block of code.
515
+ const answerText = turn.answer.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
489
516
  // A citation opens its source; one that opens nothing stays the text it was.
490
- const answer = useMemo(() => linkCitations(turn.answer, new Set(sources.flatMap((source) => (
517
+ const answer = useMemo(() => linkCitations(answerText, new Set(sources.flatMap((source) => (
491
518
  source.ref !== null && source.target.kind === "pane" ? [source.ref] : []
492
- )))), [sources, turn.answer]);
519
+ )))), [answerText, sources]);
493
520
  const openLink = useCallback((href: string) => {
494
521
  const ref = sourceRefFromHref(href);
495
522
  const source = ref === null ? undefined : sources.find((entry) => entry.ref === ref);
496
523
  if (source) onOpenSource(source);
497
524
  }, [onOpenSource, sources]);
498
- const finished = turn.status === "complete" && turn.answer.trim().length > 0;
525
+ const finished = turn.status === "complete" && answerText.length > 0;
499
526
  return (
500
527
  <Box flexDirection="column" paddingTop={1}>
501
- <Prose
502
- text={turn.prompt}
503
- width={width}
504
- color={colors.textBright}
505
- figures={false}
506
- attributes={TextAttributes.BOLD}
507
- />
528
+ <TurnQuestion text={turn.prompt} width={width} />
508
529
  {tools}
509
- {turn.answer ? (
530
+ {answerText ? (
510
531
  <Box paddingTop={1}>
511
532
  <MarkdownText
512
533
  text={answer}
@@ -519,9 +540,8 @@ function TurnView({
519
540
  linkChips
520
541
  />
521
542
  </Box>
522
- ) : turn.status === "streaming" && turn.tools.length === 0 ? (
523
- <Box paddingTop={1}><Spinner label="Gloom is thinking…" /></Box>
524
543
  ) : null}
544
+ {turn.status === "streaming" ? <TurnProgress turn={turn} /> : null}
525
545
  {finished ? (
526
546
  <AnswerSources
527
547
  sources={sources}
@@ -1384,7 +1404,6 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1384
1404
  // section bar, column header and rows), up to half the pane.
1385
1405
  const expandedNeed = 3 + (expandedTables.length > 1 ? 1 : 0)
1386
1406
  + Math.max(0, ...expandedTables.map((table) => table.rows.length));
1387
- const confirmationHeight = confirmation ? confirmationBlockHeight(confirmation) : 0;
1388
1407
  const attachedHeight = attachedPaneBlockHeight(attached);
1389
1408
  const draftLines = useMemo(() => {
1390
1409
  const textWidth = Math.max(8, width - sidebarWidth - (nativePaneChrome ? 6 : 5));
@@ -1393,6 +1412,10 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1393
1412
  const composerHeight = nativePaneChrome ? draftLines + 2 : draftLines;
1394
1413
  const composerBlockHeight = nativePaneChrome ? composerHeight : composerHeight + 2;
1395
1414
  // The conversation keeps a readable slice no matter what else is open.
1415
+ const confirmationPreview = confirmation
1416
+ ? confirmationPreviewRows(confirmation, height - composerBlockHeight - attachedHeight - confirmationBlockHeight(0) - 6)
1417
+ : 0;
1418
+ const confirmationHeight = confirmation ? confirmationBlockHeight(confirmationPreview) : 0;
1396
1419
  const detailBudget = height - composerBlockHeight - confirmationHeight - attachedHeight - 6;
1397
1420
  const detailHeight = expandedRow && expandedHasRows && detailBudget >= MIN_DETAIL_HEIGHT
1398
1421
  ? Math.min(Math.floor(height / 2), detailBudget, Math.max(MIN_DETAIL_HEIGHT, expandedNeed))
@@ -1661,13 +1684,13 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1661
1684
  if (!planAccess.emailVerified) return list;
1662
1685
  if (confirmation) {
1663
1686
  list.push(
1664
- { id: "approve", key: "y", label: "es approve", title: "Approve", onPress: () => controller.resolveConfirmation(confirmation.toolCallId, true) },
1665
- { id: "decline", key: "n", label: "o decline", title: "Decline", onPress: () => controller.resolveConfirmation(confirmation.toolCallId, false) },
1687
+ { id: "approve", key: "y", label: "es approve", title: "Approve", remoteScope: ASKG_PROMPT_SCOPE, onPress: () => controller.resolveConfirmation(confirmation.toolCallId, true) },
1688
+ { id: "decline", key: "n", label: "o decline", title: "Decline", remoteScope: ASKG_PROMPT_SCOPE, onPress: () => controller.resolveConfirmation(confirmation.toolCallId, false) },
1666
1689
  );
1667
1690
  } else if (paneConsentPending) {
1668
1691
  list.push(
1669
- { id: "attach-pane", key: ATTACH_PANE_KEY, label: " attach", title: "Attach the Pane's Contents", onPress: () => answerPaneConsent(true) },
1670
- { id: "leave-out-pane", key: LEAVE_OUT_PANE_KEY, label: " leave out", title: "Leave Out the Pane's Contents", onPress: () => answerPaneConsent(false) },
1692
+ { id: "attach-pane", key: ATTACH_PANE_KEY, label: " attach", title: "Attach the Pane's Contents", remoteScope: ASKG_PROMPT_SCOPE, onPress: () => answerPaneConsent(true) },
1693
+ { id: "leave-out-pane", key: LEAVE_OUT_PANE_KEY, label: " leave out", title: "Leave Out the Pane's Contents", remoteScope: ASKG_PROMPT_SCOPE, onPress: () => answerPaneConsent(false) },
1671
1694
  );
1672
1695
  }
1673
1696
  if (showSidebar) {
@@ -1966,6 +1989,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
1966
1989
  {confirmation ? (
1967
1990
  <ConfirmationPrompt
1968
1991
  row={confirmation}
1992
+ previewRows={confirmationPreview}
1969
1993
  width={contentWidth}
1970
1994
  onApprove={() => controller.resolveConfirmation(confirmation.toolCallId, true)}
1971
1995
  onDecline={() => controller.resolveConfirmation(confirmation.toolCallId, false)}
@@ -86,6 +86,7 @@ const TOOL_TITLES: Record<string, string> = {
86
86
  const RESOURCE_SUBJECTS: Record<string, string> = {
87
87
  "app://accounts": "broker accounts",
88
88
  "app://snapshot": "your layout",
89
+ "app://snapshot/full": "your layout",
89
90
  "app://panes": "open panes",
90
91
  "app://config": "settings",
91
92
  "app://layout/current": "your layout",
@@ -0,0 +1,70 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Spinner, Prose } from "../../../../components";
3
+ import { quoteBlockStyle, terminalAccentTint } from "../../../../components/ui/quote";
4
+ import { useThemeColors } from "../../../../theme/theme-context";
5
+ import { Box, Text, useUiCapabilities } from "../../../../ui";
6
+ import type { ASKGTurn } from "./model";
7
+
8
+ /**
9
+ * The question as it was asked, set apart from the answer under it as a
10
+ * quote is: a rule down its left edge in the accent and a faint band of it.
11
+ * Gloom's answer is the plain text that follows, so who said what reads at
12
+ * a glance, in a live conversation and in a stored one alike.
13
+ */
14
+ export function TurnQuestion({ text, width }: { text: string; width: number }) {
15
+ const colors = useThemeColors();
16
+ const { nativePaneChrome } = useUiCapabilities();
17
+ if (!text.trim()) return null;
18
+ if (nativePaneChrome) {
19
+ return (
20
+ <Box data-gloom-role="askg-question" data-gloom-selectable="true" style={quoteBlockStyle()}>
21
+ <Prose text={text} width={width} color={colors.textBright} figures={false} />
22
+ </Box>
23
+ );
24
+ }
25
+ // The rule takes the first column and a space keeps the text off it.
26
+ return (
27
+ <Box
28
+ width={width}
29
+ border={["left"]}
30
+ borderStyle="heavy"
31
+ borderColor={colors.borderFocused}
32
+ backgroundColor={terminalAccentTint(colors)}
33
+ paddingLeft={1}
34
+ paddingRight={1}
35
+ >
36
+ <Prose text={text} width={Math.max(10, width - 3)} color={colors.textBright} figures={false} />
37
+ </Box>
38
+ );
39
+ }
40
+
41
+ /** Whole seconds since `since`, counted up once a second while mounted. */
42
+ function useSecondsSince(since: number): number {
43
+ const [now, setNow] = useState(() => Date.now());
44
+ useEffect(() => {
45
+ const timer = setInterval(() => setNow(Date.now()), 1_000);
46
+ return () => clearInterval(timer);
47
+ }, []);
48
+ return Math.max(0, Math.floor((now - since) / 1_000));
49
+ }
50
+
51
+ /**
52
+ * The line under an answer still coming in: the spinner, what Gloom is doing
53
+ * and how long it has been at it. It stays through the whole turn (a server
54
+ * read can take twenty seconds without a row to show for it), so the
55
+ * conversation never sits still while Gloom works, and it goes when the
56
+ * answer is done. A call waiting on the person's approval has its own prompt.
57
+ */
58
+ export function TurnProgress({ turn }: { turn: ASKGTurn }) {
59
+ const colors = useThemeColors();
60
+ const seconds = useSecondsSince(turn.startedAt);
61
+ if (turn.status !== "streaming") return null;
62
+ if (turn.tools.some((row) => row.status === "awaiting-confirmation")) return null;
63
+ const label = turn.answer.trim() ? "Gloom is writing…" : "Gloom is thinking…";
64
+ return (
65
+ <Box flexDirection="row" paddingTop={1} gap={2} data-gloom-role="askg-progress">
66
+ <Spinner label={label} emphasized />
67
+ {seconds > 0 ? <Text fg={colors.textDim}>{`${seconds} s`}</Text> : null}
68
+ </Box>
69
+ );
70
+ }