gloomberb 0.20.4 → 0.20.6

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 (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. package/src/utils/untrusted-text.ts +29 -0
@@ -7,14 +7,15 @@ import { setPaneSettings } from "../pane-settings";
7
7
  import { findPaneInstance, type LayoutConfig } from "../types/config";
8
8
  import { getBasePaneDisplayTitle } from "../components/layout/pane/title";
9
9
  import { commandBarResultsFromNodes, commandBarSnapshot } from "./command-bar";
10
- import { formSnapshot } from "./form";
10
+ import { formNodes, formSnapshot } from "./form";
11
11
  import type { RemoteUiRegistry } from "./semantic-tree";
12
12
  import { REMOTE_AGENT_HELP, remoteControlSchema } from "./schema";
13
- import type { RemoteIncludedState, RemoteStateInclude } from "./types";
13
+ import type { RemoteIncludedState, RemoteStateInclude, RemoteUiNodeSnapshot } from "./types";
14
14
  import {
15
15
  activeLayoutRev,
16
16
  normalizeIncludes,
17
17
  paneSnapshot,
18
+ paneSummary,
18
19
  type PatchTarget,
19
20
  } from "./controller-utils";
20
21
  import { finiteOrNull } from "../utils/guards";
@@ -66,6 +67,28 @@ function brokerAccountsResource(state: AppState) {
66
67
  }));
67
68
  }
68
69
 
70
+ /**
71
+ * What the default snapshot leaves out for its size, and where to read it:
72
+ * an agent reads the schema and the guide once, not with every look.
73
+ */
74
+ const SNAPSHOT_REFERENCES = {
75
+ schema: "Every resource and operation with its input: { type: 'schema' } (gloom remote schema). Read it once.",
76
+ help: "Recipes and caveats: app://remote/help (gloom remote help).",
77
+ ui: "ui lists the labelled controls; ui://tree lists every node, unlabelled click areas too.",
78
+ paneState: "What a pane loaded and where it is (panes[].runtimeState, config.layouts[].paneState): app://pane-state/{paneId}, app://panes, app://config.",
79
+ full: "app://snapshot/full has all of it inline.",
80
+ };
81
+
82
+ /** The config without what each saved layout's panes loaded: app://config keeps it. */
83
+ function configSummary(config: AppState["config"]): AppState["config"] {
84
+ return { ...config, layouts: config.layouts.map(({ paneState: _paneState, ...layout }) => layout) };
85
+ }
86
+
87
+ /** A clickable box with no label: it says nothing an agent can act on by name. */
88
+ function isBareBox(node: { role: string; label?: string }): boolean {
89
+ return node.role === "box" && !node.label;
90
+ }
91
+
69
92
  export function createRemoteResources({
70
93
  dispatch,
71
94
  getState,
@@ -75,8 +98,9 @@ export function createRemoteResources({
75
98
  }: RemoteResourceContext) {
76
99
  const getResource = (resource: string): unknown => {
77
100
  const state = getState();
78
- const uiNodes = uiRegistry?.snapshot() ?? [];
79
- if (resource === "app://snapshot") {
101
+ if (resource === "app://snapshot" || resource === "app://snapshot/full") {
102
+ const uiNodes = uiRegistry?.snapshot() ?? [];
103
+ const full = resource === "app://snapshot/full";
80
104
  return {
81
105
  rev: activeLayoutRev(state),
82
106
  app: {
@@ -88,13 +112,13 @@ export function createRemoteResources({
88
112
  commandBarQuery: state.commandBarQuery,
89
113
  initialized: state.initialized,
90
114
  },
91
- config: state.config,
92
- panes: state.config.layout.instances.map((pane) => paneSnapshot(state, pane)),
115
+ config: full ? state.config : configSummary(state.config),
116
+ panes: state.config.layout.instances.map((pane) => (full ? paneSnapshot : paneSummary)(state, pane)),
93
117
  commandBar: commandBarSnapshot(state, uiNodes),
94
118
  form: formSnapshot(uiNodes, isDialogOpen()),
95
- ui: uiNodes,
96
- schema: remoteControlSchema(),
97
- help: REMOTE_AGENT_HELP,
119
+ ...full
120
+ ? { ui: uiNodes, schema: remoteControlSchema(), help: REMOTE_AGENT_HELP }
121
+ : { ui: uiNodes.filter((node) => !isBareBox(node)), references: SNAPSHOT_REFERENCES },
98
122
  };
99
123
  }
100
124
  if (resource === "app://config") return state.config;
@@ -143,14 +167,14 @@ export function createRemoteResources({
143
167
  hasWizard: !!command.wizard?.length,
144
168
  }));
145
169
  }
146
- if (resource === "app://command-bar") return commandBarSnapshot(state, uiNodes);
147
- if (resource === "app://command-bar/results") return commandBarResultsFromNodes(uiNodes);
148
- if (resource === "app://form") return formSnapshot(uiNodes, isDialogOpen());
170
+ if (resource === "app://command-bar") return commandBarSnapshot(state, uiRegistry?.snapshot() ?? []);
171
+ if (resource === "app://command-bar/results") return commandBarResultsFromNodes(uiRegistry?.snapshot() ?? []);
172
+ if (resource === "app://form") return formSnapshot(formNodes(uiRegistry), isDialogOpen());
149
173
  if (resource === "app://capabilities") return pluginRegistry.capabilities.manifests();
150
174
  if (resource === "app://auth") return apiClient.describeAuthState();
151
175
  if (resource === "app://accounts") return brokerAccountsResource(state);
152
176
  if (resource === "app://remote/help") return REMOTE_AGENT_HELP;
153
- if (resource === "ui://tree") return uiNodes;
177
+ if (resource === "ui://tree") return uiRegistry?.snapshot() ?? [];
154
178
  if (resource.startsWith("ui://node/")) {
155
179
  const nodeId = decodeURIComponent(resource.slice("ui://node/".length));
156
180
  const node = uiRegistry?.detail(nodeId);
@@ -168,7 +192,9 @@ export function createRemoteResources({
168
192
  const included = normalizeIncludes(include, defaults);
169
193
  if (included.length === 0) return undefined;
170
194
  const state = getState();
171
- const uiNodes = uiRegistry?.snapshot() ?? [];
195
+ // The whole tree only for what lists from it; the form is read on its own.
196
+ let tree: RemoteUiNodeSnapshot[] | undefined;
197
+ const uiNodes = () => (tree ??= uiRegistry?.snapshot() ?? []);
172
198
  const result: RemoteIncludedState = {
173
199
  rev: activeLayoutRev(state),
174
200
  included,
@@ -188,16 +214,16 @@ export function createRemoteResources({
188
214
  }
189
215
  if (included.includes("layout")) result.layout = state.config.layout;
190
216
  if (included.includes("panes")) {
191
- result.panes = state.config.layout.instances.map((pane) => paneSnapshot(state, pane));
217
+ result.panes = state.config.layout.instances.map((pane) => paneSummary(state, pane));
192
218
  }
193
219
  if (included.includes("commandBar") || included.includes("commandBar.results")) {
194
- const commandBar = commandBarSnapshot(state, uiNodes);
220
+ const commandBar = commandBarSnapshot(state, uiNodes());
195
221
  result.commandBar = included.includes("commandBar")
196
222
  ? commandBar
197
223
  : { results: commandBar.results };
198
224
  }
199
- if (included.includes("form")) result.form = formSnapshot(uiNodes, isDialogOpen());
200
- if (included.includes("ui")) result.ui = uiNodes;
225
+ if (included.includes("form")) result.form = formSnapshot(formNodes(uiRegistry), isDialogOpen());
226
+ if (included.includes("ui")) result.ui = uiNodes();
201
227
  if (included.includes("schema")) result.schema = remoteControlSchema();
202
228
  if (included.includes("help")) result.help = REMOTE_AGENT_HELP;
203
229
  return result;
@@ -14,7 +14,8 @@ import {
14
14
  } from "./pane-screenshot";
15
15
 
16
16
  export const REMOTE_RESOURCES: RemoteResourceSchema[] = [
17
- { uri: "app://snapshot", description: "Current app snapshot including layout, focus, panes, command bar, and plugin/capability catalogs. app.activePanel is deprecated and always \"left\"; read app.focusedPaneId." },
17
+ { uri: "app://snapshot", description: "What is on screen, in one read: focus, config with the layouts, panes, the command bar, the open form or setup dialog (form), and the labelled UI nodes (ui). Left out for size, and named in references: the schema and this guide, what each pane loaded (runtime state), and unlabelled UI nodes. app.activePanel is deprecated and always \"left\"; read app.focusedPaneId." },
18
+ { uri: "app://snapshot/full", description: "app://snapshot with everything it leaves out inline: the schema and guide, pane runtime state and every UI node. Often several times the size." },
18
19
  { uri: "app://config", description: "Current app config.", patchable: true },
19
20
  { uri: "app://layout/current", description: "Current active layout.", patchable: true },
20
21
  { uri: "app://layouts", description: "Saved layouts." },
@@ -26,7 +27,7 @@ export const REMOTE_RESOURCES: RemoteResourceSchema[] = [
26
27
  { uri: "app://commands", description: "Registered command-bar commands." },
27
28
  { uri: "app://command-bar", description: "Current command-bar state and semantic result rows." },
28
29
  { uri: "app://command-bar/results", description: "Current semantic command-bar result rows." },
29
- { uri: "app://form", description: "The open form or confirm: kind, title, fields with values and options, error, pending state, and submit label, with covered: true while another dialog sits over it; { open: false } when none is open, with otherDialogOpen: true while another dialog (pane settings) is." },
30
+ { uri: "app://form", description: "The open form or confirm: kind, title, fields with values and options, error, pending state, and submit label, with covered: true while another dialog sits over it; { open: false } when none is open, with otherDialogOpen: true while another dialog (pane settings) is. The first-run setup dialog reads as kind 'setup', with its step, title, fields and buttons by node id." },
30
31
  { uri: "app://capabilities", description: "Registered plugin capability manifests." },
31
32
  { uri: "app://accounts", description: "Broker profiles and their accounts: net liquidation, cash by currency, margin requirements, margin loan, leverage, day and unrealized P&L, with source and as-of times." },
32
33
  { uri: "app://auth", description: "What the client believes about its cloud session: credential present, checked, cached user plan and verification. No secrets." },
@@ -74,7 +75,7 @@ const watchlistChangeInput = objectSchema({
74
75
  export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
75
76
  op(
76
77
  "app.openCommandBar",
77
- "Open the command bar with an optional query and optional mode. Fails while a dialog (a form, a confirm, pane settings) is open.",
78
+ "Open the command bar with an optional query and optional mode. Fails while a dialog (a form, a confirm, pane settings) or the setup dialog is open.",
78
79
  "{ query?: string, mode?: 'command' | 'ticker' | 'default' }",
79
80
  "local-write",
80
81
  objectSchema({
@@ -85,7 +86,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
85
86
  op("app.closeCommandBar", "Close the command bar.", "{}", "local-write", objectSchema()),
86
87
  op(
87
88
  "app.closeDialog",
88
- "Close the dialog on top, as Esc would: a form, a confirm, pane settings, or a picker opened over a form. Fails when no dialog is open.",
89
+ "Close the dialog on top, as Esc would: a form, a confirm, pane settings, or a picker opened over a form. Fails when no dialog is open; the setup dialog is left with its own buttons (app://form).",
89
90
  "{}",
90
91
  "local-write",
91
92
  objectSchema(),
@@ -99,7 +100,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
99
100
  ),
100
101
  op(
101
102
  "app.search",
102
- "Open command-bar search without requiring UI prefix syntax. Fails while a dialog is open.",
103
+ "Open command-bar search without requiring UI prefix syntax. Fails while a dialog or the setup dialog is open.",
103
104
  "{ mode?: 'command' | 'ticker' | 'default', query?: string }",
104
105
  "local-write",
105
106
  objectSchema({
@@ -361,7 +362,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
361
362
  ),
362
363
  op(
363
364
  "ui.invokeMatching",
364
- "Invoke an action on the first semantic UI node matching role, label, index, or metadata. While a form or confirm is open, its own nodes (metadata.scope 'form') match first; while another dialog covers it, they do not match.",
365
+ "Invoke an action on the first semantic UI node matching role, label, index, or metadata. While a form, confirm or the setup dialog is open, its own nodes (metadata.scope 'form') match first; while another dialog covers it, they do not match.",
365
366
  "{ role?: string, label?: string, contains?: string, index?: number, action?: string, input?: any, metadata?: object }",
366
367
  "local-write",
367
368
  objectSchema({
@@ -379,7 +380,8 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
379
380
  export const REMOTE_AGENT_HELP = {
380
381
  title: "Gloom remote control guide",
381
382
  quickStart: [
382
- "Read app://snapshot once to orient; it includes schema, current layout, panes, command bar state, and semantic UI nodes.",
383
+ "Read app://snapshot once to orient: focus, layout, panes, command bar, the open form or setup dialog (form), and the labelled UI nodes. Read the schema ({ type: 'schema' }, gloom remote schema) once for every operation and its input.",
384
+ "When form.open is true, a form or the setup dialog covers the app: deal with it first. A change made behind it answers with a warning that says so.",
383
385
  "Prefer app-level operations such as app.search, layout.setGrid, layout.closeFloating, and ticker.pin before falling back to ui.invoke.",
384
386
  "Use commandBar.activateResult with label, itemId, or index after app.search; avoid raw node ids unless there is no stable semantic selector.",
385
387
  "For list-like surfaces, prefer semantic list activation through commandBar.activateResult or ui.invokeMatching.",
@@ -388,8 +390,8 @@ export const REMOTE_AGENT_HELP = {
388
390
  resources: [
389
391
  { uri: "app://command-bar", use: "Current command-bar query, open state, selected row, and semantic result rows." },
390
392
  { uri: "app://command-bar/results", use: "Just the visible command-bar result/list rows." },
391
- { uri: "app://form", use: "The open form or confirm, with field ids, values, options, error and pending state, or whether another dialog is open. Every call includes it as `form`." },
392
- { uri: "ui://tree", use: "Low-level live semantic controls; use when no app-level operation exists." },
393
+ { uri: "app://form", use: "The open form, confirm or setup dialog, with field ids, values, options, error and pending state, or whether another dialog is open. Every call includes it as `form`." },
394
+ { uri: "ui://tree", use: "Every live semantic control, unlabelled click areas too (app://snapshot lists the labelled ones); use when no app-level operation exists." },
393
395
  { uri: "app://panes", use: "Pane instances, placement, focus, and runtime state." },
394
396
  ],
395
397
  recipes: [
@@ -424,6 +426,14 @@ export const REMOTE_AGENT_HELP = {
424
426
  { type: "call", operation: "ui.invokeMatching", input: { role: "form", action: "submit" } },
425
427
  ],
426
428
  },
429
+ {
430
+ goal: "Get past the first-run setup dialog (form.kind 'setup')",
431
+ requests: [
432
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form-field", metadata: { fieldId: "ticker" }, action: "setValue", input: "NVDA" } },
433
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form-field", metadata: { fieldId: "ticker" }, action: "submit" } },
434
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form", action: "submit" } },
435
+ ],
436
+ },
427
437
  {
428
438
  goal: "Activate a visible semantic control without knowing its node id",
429
439
  request: { type: "call", operation: "ui.invokeMatching", input: { role: "button", label: "Done", action: "press" } },
@@ -448,10 +458,12 @@ export const REMOTE_AGENT_HELP = {
448
458
  caveats: [
449
459
  "Capability manifests are for plugin services; UI control should rely on app-level operations and shared semantic UI nodes so plugins remain remote-agnostic.",
450
460
  "If an operation changes UI, request include: ['commandBar'] or use batch include to avoid a follow-up get.",
461
+ "Panes in app://snapshot and in call answers leave out runtimeState, which can hold everything a pane loaded; read app://pane-state/{paneId} for one pane, or app://panes.",
451
462
  "For charts, use visible semantic chart nodes with actions such as moveCursor, press, drag, release, and scroll.",
452
463
  "A command with hasWizard in app://commands opens a form in a centered dialog when activated, and the command bar closes. Read `form` in the response, set fields with ui.invokeMatching { role: 'form-field', metadata: { fieldId }, action: 'setValue' }, then send with { role: 'form', action: 'submit' } or close with action 'cancel'. Selects take an option value, toggles a boolean; neither needs to be opened.",
453
464
  "While a dialog is open (form.open or form.otherDialogOpen), app.openCommandBar and app.search fail; close a form or confirm with { role: 'form', action: 'cancel' }, and any dialog on top with app.closeDialog.",
454
465
  "A form with covered: true has another dialog over it, such as a listing picker or a sign-in; its controls wait until that one is answered or closed with app.closeDialog.",
466
+ "On a new profile the setup dialog covers the app: form.kind is 'setup', with its step, title, fields and buttons by node id. Fill a field with ui.invokeMatching { role: 'form-field', metadata: { fieldId }, action: 'setValue' } (submit on the Ticker field adds the position), press a button with { role: 'button', label }, go on with { role: 'form', action: 'submit' } (the button Enter presses), and skip the whole setup with { role: 'form', action: 'cancel' } where a step offers it. Skip leaves one step without filling it. app.closeDialog does not close it.",
455
467
  "Pane settings open in their own dialog, not as command-bar rows; change one with pane.setSetting, read them from app://pane-settings/{paneId}, and close the dialog with app.closeDialog.",
456
468
  "watchlist.add and watchlist.remove wait while the person answers a confirmation in the app and return what changed; with dryRun they return what would change without asking.",
457
469
  "pane.screenshot returns the pane's PNG as base64 in image.data, with its pixel size; the terminal (TUI) app answers that it needs the desktop app.",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Words that name a credential: a password or passphrase, a secret, a token,
3
+ * an API or private key, a cookie. Matched against the keys of free-form maps
4
+ * and against a form field's id, label and placeholder, so what such a field
5
+ * holds is withheld wherever remote control lists it.
6
+ */
7
+ export const SECRET_NAME = /(pass(word|phrase)?|secret|token|api[-_ ]?key|private[-_ ]?key|credential|cookie)/i;
8
+
9
+ /** Whether any of these texts names a credential. */
10
+ export function namesSecret(...texts: unknown[]): boolean {
11
+ return texts.some((text) => typeof text === "string" && SECRET_NAME.test(text));
12
+ }
@@ -35,6 +35,11 @@ export interface RemoteUiRegistry {
35
35
  register(id: string, registration: RemoteUiNodeRegistration): void;
36
36
  unregister(id: string): void;
37
37
  snapshot(): RemoteUiNodeSnapshot[];
38
+ /**
39
+ * The nodes of one role, without projecting the rest (a table's rows, a
40
+ * chart's data): the open form is read this way on every change.
41
+ */
42
+ snapshotRole?(role: string): RemoteUiNodeSnapshot[];
38
43
  /** One node as the tree has it, with its detail; null when it is not on screen. */
39
44
  detail(nodeId: string): RemoteUiNodeSnapshot | null;
40
45
  invoke(nodeId: string, action: string, input?: unknown): Promise<unknown>;
@@ -43,9 +48,13 @@ export interface RemoteUiRegistry {
43
48
  const RemoteUiRegistryContext = createContext<RemoteUiRegistry | null>(null);
44
49
 
45
50
  function nodeSnapshot(node: RegisteredRemoteUiNode): RemoteUiNodeSnapshot {
46
- const registration = node.registration;
51
+ return remoteUiNodeSnapshot(node.id, node.registration);
52
+ }
53
+
54
+ /** A registered node as `ui://tree` lists it. */
55
+ export function remoteUiNodeSnapshot(id: string, registration: RemoteUiNodeRegistration): RemoteUiNodeSnapshot {
47
56
  return {
48
- id: node.id,
57
+ id,
49
58
  role: registration.role,
50
59
  label: registration.label,
51
60
  disabled: registration.disabled,
@@ -71,6 +80,9 @@ export function createRemoteUiRegistry(): RemoteUiRegistry {
71
80
  snapshot() {
72
81
  return [...nodes.values()].map(nodeSnapshot);
73
82
  },
83
+ snapshotRole(role) {
84
+ return [...nodes.values()].filter((node) => node.registration.role === role).map(nodeSnapshot);
85
+ },
74
86
  detail(nodeId) {
75
87
  const node = nodes.get(nodeId);
76
88
  if (!node) return null;
@@ -2,7 +2,7 @@ import { randomUUID } from "crypto";
2
2
  import { createServer, type IncomingMessage, type ServerResponse } from "http";
3
3
  import type { RemoteAppKind, RemoteControlRequest, RemoteControlResponse, RemoteEndpoint } from "./types";
4
4
  import { REMOTE_CONTROL_PROTOCOL_VERSION } from "./types";
5
- import { removeRemoteEndpointFiles, writeRemoteEndpointFiles } from "./endpoint";
5
+ import { currentPidNamespace, removeRemoteEndpointFiles, writeRemoteEndpointFiles } from "./endpoint";
6
6
 
7
7
  export interface RemoteControlServerOptions {
8
8
  dataDir: string;
@@ -44,6 +44,7 @@ export async function startRemoteControlServer(options: RemoteControlServerOptio
44
44
  port: address.port,
45
45
  token,
46
46
  startedAt: new Date().toISOString(),
47
+ pidNamespace: currentPidNamespace(),
47
48
  };
48
49
  try {
49
50
  await writeRemoteEndpointFiles(options.dataDir, endpoint);
@@ -0,0 +1,192 @@
1
+ import { createContext, useContext, useRef, type ReactNode } from "react";
2
+ import { isDialogOpen } from "../ui/dialog-stack";
3
+ import {
4
+ RemoteUiRegistryProvider,
5
+ remoteUiNodeSnapshot,
6
+ useRemoteUiNode,
7
+ useRemoteUiRegistry,
8
+ type RemoteUiNodeRegistration,
9
+ type RemoteUiRegistry,
10
+ } from "./semantic-tree";
11
+ import { namesSecret } from "./secrets";
12
+ import type { RemoteUiNodeSnapshot } from "./types";
13
+
14
+ /** What the surface's own title and header say about it, set by the components that draw them. */
15
+ interface SurfaceDetails {
16
+ step?: string;
17
+ section?: string;
18
+ title?: string;
19
+ description?: string;
20
+ /** Closes or skips the whole surface, when it offers that. */
21
+ cancel?: () => void;
22
+ }
23
+
24
+ const RemoteSurfaceContext = createContext<{ current: SurfaceDetails } | null>(null);
25
+
26
+ /** Roles of the controls a person fills in: listed as the surface's fields. */
27
+ const FIELD_ROLES = new Set(["form-field", "text-field", "textarea", "select", "checkbox", "list"]);
28
+ /** The kit's own editors, left out when the surface names its fields as form-field nodes. */
29
+ const EDITOR_ROLES = new Set(["text-field", "textarea"]);
30
+ /** The button Enter presses on the surface is the one it sends with. */
31
+ const SUBMIT_SHORTCUT = "Enter";
32
+
33
+ /**
34
+ * Registers its subtree's nodes in the app's registry, and keeps them, so the
35
+ * surface can list its own controls. Every node drawn inside is the open
36
+ * form's (`metadata.scope` "form"), so `ui.invokeMatching` tries them first,
37
+ * as it does a form modal's.
38
+ */
39
+ function surfaceRegistry(parent: RemoteUiRegistry, own: Map<string, RemoteUiNodeRegistration>): RemoteUiRegistry {
40
+ return {
41
+ register(id, registration) {
42
+ own.set(id, registration);
43
+ parent.register(id, inForm(registration));
44
+ },
45
+ unregister(id) {
46
+ own.delete(id);
47
+ parent.unregister(id);
48
+ },
49
+ snapshot: () => parent.snapshot(),
50
+ snapshotRole: (role) => parent.snapshotRole?.(role) ?? parent.snapshot().filter((node) => node.role === role),
51
+ detail: (nodeId) => parent.detail(nodeId),
52
+ invoke: (nodeId, action, input) => parent.invoke(nodeId, action, input),
53
+ };
54
+ }
55
+
56
+ function inForm(registration: RemoteUiNodeRegistration): RemoteUiNodeRegistration {
57
+ return {
58
+ get role() { return registration.role; },
59
+ get paneId() { return registration.paneId; },
60
+ get label() { return registration.label; },
61
+ get disabled() { return registration.disabled; },
62
+ get actions() { return registration.actions; },
63
+ getMetadata: () => {
64
+ const metadata = registration.getMetadata?.() ?? registration.metadata ?? {};
65
+ return { ...metadata, scope: metadata.scope ?? "form" };
66
+ },
67
+ get getDetail() { return registration.getDetail; },
68
+ };
69
+ }
70
+
71
+ function isPassword(metadata: Record<string, unknown>): boolean {
72
+ return metadata.type === "password" || metadata.inputType === "password" || metadata.fieldType === "password";
73
+ }
74
+
75
+ const FIELD_KEYS = ["placeholder", "active", "focused", "required", "error", "options", "items", "selectedIndex", "checked"] as const;
76
+
77
+ /**
78
+ * A field as the surface lists it. A password, or a field whose id, label or
79
+ * placeholder names a credential (an API key typed in the clear), says
80
+ * whether it is filled, never what.
81
+ */
82
+ function surfaceField(node: RemoteUiNodeSnapshot) {
83
+ const metadata = node.metadata ?? {};
84
+ const value = metadata.value;
85
+ const password = isPassword(metadata);
86
+ const secret = password || namesSecret(metadata.fieldId, node.label, metadata.placeholder);
87
+ const kept = Object.fromEntries(FIELD_KEYS.filter((key) => metadata[key] != null).map((key) => [key, metadata[key]]));
88
+ return {
89
+ nodeId: node.id,
90
+ ...(typeof metadata.fieldId === "string" ? { id: metadata.fieldId } : {}),
91
+ role: node.role,
92
+ label: node.label ?? null,
93
+ ...(secret
94
+ ? { ...(password ? { type: "password" } : {}), secret: true, filled: typeof value === "string" && value.length > 0 }
95
+ : node.role === "list" || node.role === "checkbox" ? {} : { value: value ?? null }),
96
+ ...kept,
97
+ ...(node.disabled ? { disabled: true } : {}),
98
+ actions: node.actions,
99
+ };
100
+ }
101
+
102
+ function surfaceButton(node: RemoteUiNodeSnapshot) {
103
+ const shortcut = node.metadata?.shortcut;
104
+ return {
105
+ nodeId: node.id,
106
+ label: node.label ?? null,
107
+ ...(node.disabled ? { disabled: true } : {}),
108
+ ...(typeof shortcut === "string" && shortcut ? { shortcut } : {}),
109
+ };
110
+ }
111
+
112
+ /** The controls drawn inside the surface, in the order they registered. */
113
+ function surfaceControls(own: Map<string, RemoteUiNodeRegistration>) {
114
+ const nodes = [...own].map(([id, registration]) => remoteUiNodeSnapshot(id, registration));
115
+ // A step that names its fields as form-field nodes drives its editors through them.
116
+ const named = nodes.some((node) => node.role === "form-field");
117
+ const fields = nodes.filter((node) => FIELD_ROLES.has(node.role) && !(named && EDITOR_ROLES.has(node.role)));
118
+ const buttons = nodes.filter((node) => node.role === "button" && node.label);
119
+ const submit = buttons.find((node) => node.metadata?.shortcut === SUBMIT_SHORTCUT);
120
+ return { fields, buttons, submit };
121
+ }
122
+
123
+ /**
124
+ * A full-window card that is not a dialog of the dialog stack, such as the
125
+ * first-run setup: remote control reads it as the open form (`app://form`),
126
+ * with its title, the fields and buttons drawn in it, `submit` for the button
127
+ * Enter presses and `cancel` when it can be skipped. `covered` while a dialog
128
+ * sits over it.
129
+ */
130
+ export function RemoteSurface({ kind, children }: { kind: string; children: ReactNode }) {
131
+ const parent = useRemoteUiRegistry();
132
+ const detailsRef = useRef<SurfaceDetails>({});
133
+ const ownRef = useRef<Map<string, RemoteUiNodeRegistration>>(new Map());
134
+ const registryRef = useRef<RemoteUiRegistry | null>(null);
135
+ if (parent && !registryRef.current) registryRef.current = surfaceRegistry(parent, ownRef.current);
136
+
137
+ const press = async (node: RemoteUiNodeSnapshot | undefined) => {
138
+ if (!node) throw new Error("This step has no button that sends it; press one of its buttons instead.");
139
+ if (node.disabled) throw new Error(`"${node.label}" is disabled.`);
140
+ await ownRef.current.get(node.id)?.actions?.press?.();
141
+ };
142
+
143
+ useRemoteUiNode({
144
+ role: "form",
145
+ get label() { return detailsRef.current.title; },
146
+ get actions() {
147
+ const cancel = detailsRef.current.cancel;
148
+ const { submit } = surfaceControls(ownRef.current);
149
+ return {
150
+ cancel: cancel ? () => cancel() : undefined,
151
+ submit: submit ? () => press(surfaceControls(ownRef.current).submit) : undefined,
152
+ };
153
+ },
154
+ getMetadata: () => {
155
+ const details = detailsRef.current;
156
+ const { fields, buttons, submit } = surfaceControls(ownRef.current);
157
+ return {
158
+ scope: "form",
159
+ kind,
160
+ step: details.step ?? details.section ?? null,
161
+ title: details.title ?? null,
162
+ ...(details.description ? { description: details.description } : {}),
163
+ fields: fields.map(surfaceField),
164
+ buttons: buttons.map(surfaceButton),
165
+ submitLabel: submit?.label ?? null,
166
+ covered: isDialogOpen(),
167
+ };
168
+ },
169
+ } satisfies RemoteUiNodeRegistration);
170
+
171
+ const content = <RemoteSurfaceContext value={detailsRef}>{children}</RemoteSurfaceContext>;
172
+ return registryRef.current
173
+ ? <RemoteUiRegistryProvider registry={registryRef.current}>{content}</RemoteUiRegistryProvider>
174
+ : content;
175
+ }
176
+
177
+ /** Names the surface this is drawn in: its step, title and description. */
178
+ export function useRemoteSurfaceHeading(heading: Pick<SurfaceDetails, "step" | "title" | "description">): void {
179
+ const surface = useContext(RemoteSurfaceContext);
180
+ if (!surface) return;
181
+ surface.current.step = heading.step;
182
+ surface.current.title = heading.title;
183
+ surface.current.description = heading.description;
184
+ }
185
+
186
+ /** The surface's section (shown as its step when the title names none) and how it is skipped, if it can be. */
187
+ export function useRemoteSurfaceHeader(header: Pick<SurfaceDetails, "section" | "cancel">): void {
188
+ const surface = useContext(RemoteSurfaceContext);
189
+ if (!surface) return;
190
+ surface.current.section = header.section;
191
+ surface.current.cancel = header.cancel;
192
+ }
@@ -9,6 +9,11 @@ export interface RemoteEndpoint {
9
9
  port: number;
10
10
  token: string;
11
11
  startedAt: string;
12
+ /**
13
+ * The process-id namespace `pid` belongs to, on Linux. A client in another
14
+ * one (a sandbox, a container) cannot tell from `pid` whether the app runs.
15
+ */
16
+ pidNamespace?: string;
12
17
  }
13
18
 
14
19
  export interface RemoteJsonPatchOperation {
@@ -1,9 +1,11 @@
1
1
  import { useLayoutEffect, useRef, useState } from "react";
2
2
 
3
3
  /** Fit partially covered cells into their remaining area, retaining text ellipses. */
4
- export function useFrozenColumnInsets(enabled: boolean, scrollLeft: number, viewportWidth: number, columns: unknown, gap: number) {
4
+ export function useFrozenColumnInsets(frozen: boolean, scrollLeft: number, viewportWidth: number, columns: unknown, gap: number) {
5
5
  const ref = useRef<HTMLDivElement>(null);
6
6
  const [insets, setInsets] = useState<number[]>([]);
7
+ // Unscrolled, no column is under the frozen one and every inset is 0: a resize measures nothing.
8
+ const enabled = frozen && scrollLeft > 0;
7
9
  useLayoutEffect(() => {
8
10
  const cells = ref.current?.children;
9
11
  if (!enabled || !cells?.length) {
@@ -11,6 +11,7 @@ import {
11
11
  type ReactNode,
12
12
  type RefObject,
13
13
  } from "react";
14
+ import { flushSync } from "react-dom";
14
15
  import { EmptyState } from "../../../components/ui/status";
15
16
  import { usePaneInstance } from "../../../state/app/context";
16
17
  import { useRegisterPaneScrollBox } from "../../../state/pane-scroll-registry";
@@ -26,6 +27,7 @@ import {
26
27
  buildTableGridTemplateColumns,
27
28
  getTableWidth,
28
29
  hasMeaningfulTableHorizontalOverflow,
30
+ tableFreezesFirstColumn,
29
31
  } from "../../../components/ui/table-layout";
30
32
  import { WEB_CELL_HEIGHT, WEB_CELL_WIDTH } from "../../../theme/font-scale";
31
33
  import { isLiveResizing, onLiveResizeEnd } from "../../../ui/live-resize";
@@ -113,7 +115,7 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
113
115
  horizontalPadding = 1,
114
116
  fillAvailableWidth = true,
115
117
  showHorizontalScrollbar = true,
116
- freezeFirstColumn = false,
118
+ freezeFirstColumn: freezeFirstColumnProp,
117
119
  scrollToIndex,
118
120
  scrollToIndexAlign = "nearest",
119
121
  scrollToIndexVersion = 0,
@@ -202,6 +204,17 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
202
204
  const bodyAfterHeight = bodyAfter ? WEB_CELL_HEIGHT * 6 : 0;
203
205
  const horizontalScrollEnabled = showHorizontalScrollbar
204
206
  && hasMeaningfulTableHorizontalOverflow(tableWidth, viewportWidth, columnGap);
207
+ const freezeFirstColumn = tableFreezesFirstColumn({
208
+ freezeFirstColumn: freezeFirstColumnProp, columns, columnGap, horizontalPadding, viewportWidth,
209
+ overflows: horizontalScrollEnabled,
210
+ });
211
+ // A table that pins by default pins once scrolled: unscrolled nothing is under
212
+ // its first column, so a pane dragged or resized at rest draws no sticky cells.
213
+ const pinned = freezeFirstColumn && (freezeFirstColumnProp === true || frozenScrollLeft > 0);
214
+ // Pinned from a scroll that came before it, it starts where the body is.
215
+ useLayoutEffect(() => {
216
+ if (freezeFirstColumn) setFrozenScrollLeft(bodyElementRef.current?.scrollLeft ?? 0);
217
+ }, [freezeFirstColumn]);
205
218
  const scrollContentWidth = horizontalScrollEnabled
206
219
  || !fillAvailableWidth
207
220
  ? Math.max(1, tableWidth * WEB_CELL_WIDTH)
@@ -325,7 +338,7 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
325
338
  const [frozenEdgePx, setFrozenEdgePx] = useState(0);
326
339
  useLayoutEffect(() => {
327
340
  const body = bodyElementRef.current;
328
- const frozenCell = freezeFirstColumn && overflowEdges.start
341
+ const frozenCell = pinned && overflowEdges.start
329
342
  ? body?.querySelector<HTMLElement>('[data-gloom-role="data-table-header-cell"]')
330
343
  : null;
331
344
  // The gap after it is the next column's margin, as laid out.
@@ -336,7 +349,7 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
336
349
  : 0;
337
350
  // Set only on a change: a state update from a layout effect costs the render a second commit.
338
351
  if (next !== frozenEdgePx) setFrozenEdgePx(next);
339
- }, [columnGap, columns, freezeFirstColumn, frozenEdgePx, overflowEdges.start, viewportWidth]);
352
+ }, [columnGap, columns, pinned, frozenEdgePx, overflowEdges.start, viewportWidth]);
340
353
 
341
354
  const rootStyle: CSSProperties = {
342
355
  position: "relative",
@@ -390,7 +403,12 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
390
403
  }}
391
404
  onScroll={(event) => {
392
405
  markScrollbarActive();
393
- if (freezeFirstColumn) setFrozenScrollLeft(event.currentTarget.scrollLeft);
406
+ if (freezeFirstColumn) {
407
+ const left = event.currentTarget.scrollLeft;
408
+ // Pinning on the first scroll away draws before that frame shows the column leaving.
409
+ if (!pinned && left > 0) flushSync(() => setFrozenScrollLeft(left));
410
+ else setFrozenScrollLeft(left);
411
+ }
394
412
  const controlledOffset = controlledScrollOffsetRef.current;
395
413
  controlledScrollOffsetRef.current = null;
396
414
  if (controlledOffset
@@ -418,9 +436,9 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
418
436
  >
419
437
  <WebDataTableHeader
420
438
  columns={columns}
421
- freezeFirstColumn={freezeFirstColumn}
439
+ freezeFirstColumn={pinned}
422
440
  scrollLeft={frozenScrollLeft}
423
- viewportWidth={freezeFirstColumn ? viewportWidth : 0}
441
+ viewportWidth={pinned && frozenScrollLeft > 0 ? viewportWidth : 0}
424
442
  columnGap={columnGap}
425
443
  horizontalPadding={horizontalPadding}
426
444
  focusPane={focusPane}
@@ -453,11 +471,11 @@ export function WebDataTable<T, C extends DataTableColumn = DataTableColumn>({
453
471
  item={item}
454
472
  itemKey={itemKey}
455
473
  columns={columns}
456
- freezeFirstColumn={freezeFirstColumn}
474
+ freezeFirstColumn={pinned}
457
475
  scrollLeft={frozenScrollLeft}
458
- // Only a frozen first column places itself by it: every
476
+ // Only a frozen first column scrolled past places itself by it: every
459
477
  // other row stays memoized when the viewport changes width.
460
- viewportWidth={freezeFirstColumn ? viewportWidth : 0}
478
+ viewportWidth={pinned && frozenScrollLeft > 0 ? viewportWidth : 0}
461
479
  columnGap={columnGap}
462
480
  horizontalPadding={horizontalPadding}
463
481
  focusPane={focusPane}
@@ -297,6 +297,8 @@ function WebDataTableRowInner<
297
297
  sectionHeader.attributes ?? TextAttributes.BOLD,
298
298
  ),
299
299
  gridColumn: "1 / -1",
300
+ // Beside a pinned first column the heading stays in view too, not cut to its last letters.
301
+ ...(freezeFirstColumn ? { position: "sticky", left: inlinePaddingPx(horizontalPadding), justifySelf: "start" } : {}),
300
302
  overflow: "hidden",
301
303
  textOverflow: "ellipsis",
302
304
  display: "flex",