@gloom-sh/terminal 0.20.16 → 0.20.18

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 (345) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +16 -5
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/api-client/types/econ.ts +3 -0
  13. package/src/app/global-shortcuts.ts +5 -3
  14. package/src/app/pro-welcome/keys.ts +27 -0
  15. package/src/app/pro-welcome/model.ts +158 -0
  16. package/src/app/pro-welcome/row.tsx +176 -0
  17. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  18. package/src/app/runtime/external-profile-changes.ts +135 -0
  19. package/src/app.tsx +33 -2
  20. package/src/architecture/core-builtin-allowlist.json +1 -1
  21. package/src/architecture/floating-promise-allowlist.json +0 -1
  22. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  23. package/src/cli/alert-listing.ts +98 -0
  24. package/src/cli/commands/fred-series.ts +3 -1
  25. package/src/cli/commands/market.ts +138 -22
  26. package/src/cli/commands/overview.ts +72 -14
  27. package/src/cli/commands/plugins.ts +3 -2
  28. package/src/cli/commands/search.ts +30 -6
  29. package/src/cli/context.ts +16 -5
  30. package/src/cli/csv-export.ts +74 -0
  31. package/src/cli/desktop-pane-shot.ts +75 -11
  32. package/src/cli/glossary.ts +64 -10
  33. package/src/cli/help.ts +4 -2
  34. package/src/cli/history-demergers.ts +117 -0
  35. package/src/cli/history-rows.ts +6 -2
  36. package/src/cli/index.ts +1 -0
  37. package/src/cli/known-gaps.ts +16 -0
  38. package/src/cli/known-us-stocks.ts +18 -0
  39. package/src/cli/listing-arg.ts +105 -15
  40. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  41. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  42. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  43. package/src/cli/pane-functions/catalog.ts +50 -16
  44. package/src/cli/pane-functions/data.ts +16 -4
  45. package/src/cli/pane-functions/dom.ts +24 -6
  46. package/src/cli/pane-functions/freshness.ts +17 -1
  47. package/src/cli/pane-functions/headless.ts +7 -2
  48. package/src/cli/pane-functions/index.ts +102 -44
  49. package/src/cli/pane-functions/resolver.ts +8 -5
  50. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  51. package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
  52. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  53. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  54. package/src/cli/quote-answer.ts +32 -16
  55. package/src/cli/registry.ts +22 -2
  56. package/src/cli/report-tables.ts +17 -3
  57. package/src/cli/result.ts +8 -10
  58. package/src/cli/series-search.ts +45 -6
  59. package/src/cli/shot-temp-dir.ts +4 -9
  60. package/src/components/chart/composite/legend.tsx +80 -25
  61. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  62. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  63. package/src/components/chart-table/header.tsx +9 -0
  64. package/src/components/chart-table/layout.ts +11 -11
  65. package/src/components/command-bar/pane-templates/items.ts +17 -1
  66. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  67. package/src/components/command-bar/routes/root/results.ts +34 -2
  68. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  69. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  70. package/src/components/command-bar/workflow/alert.ts +19 -8
  71. package/src/components/data-table/view.tsx +15 -2
  72. package/src/components/form-modal/content.tsx +9 -4
  73. package/src/components/index.ts +1 -1
  74. package/src/components/layout/header.tsx +9 -5
  75. package/src/components/layout/pane/capture-status.ts +6 -0
  76. package/src/components/layout/pane/footer/index.tsx +2 -0
  77. package/src/components/layout/pane/footer/model.ts +113 -15
  78. package/src/components/layout/pane/header.tsx +16 -2
  79. package/src/components/market-board/index.tsx +4 -2
  80. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  81. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  82. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  83. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  84. package/src/components/onboarding/setup-cards.ts +36 -0
  85. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  86. package/src/components/onboarding/wizard-account.ts +6 -1
  87. package/src/components/onboarding/wizard-model.ts +32 -6
  88. package/src/components/onboarding/wizard-positions.ts +1 -1
  89. package/src/components/sign-in-gate.tsx +3 -1
  90. package/src/components/toggle-list.tsx +6 -8
  91. package/src/components/ui/confirm-dialog.tsx +47 -7
  92. package/src/components/ui/data-table/display-columns.ts +4 -1
  93. package/src/components/ui/data-table/hooks.ts +2 -3
  94. package/src/components/ui/data-table/index.tsx +4 -1
  95. package/src/components/ui/data-table/types.ts +19 -4
  96. package/src/components/ui/data-table/visible-range.ts +11 -1
  97. package/src/components/ui/display.tsx +17 -2
  98. package/src/components/ui/index.ts +1 -1
  99. package/src/components/ui/stat-grid.tsx +4 -0
  100. package/src/components/ui/status.tsx +13 -1
  101. package/src/components/ui/table-layout.ts +2 -1
  102. package/src/components/use-pane-notice-footer.tsx +16 -3
  103. package/src/data/config/store/index.ts +31 -0
  104. package/src/data/config/store/node.ts +61 -11
  105. package/src/data/config/store/normalize.ts +4 -6
  106. package/src/data/config/store/shared-file.ts +309 -0
  107. package/src/data/profile-merge.ts +299 -0
  108. package/src/data/sqlite/checkpointer.ts +11 -1
  109. package/src/data/sqlite/database.ts +1 -1
  110. package/src/data/ticker-repository.ts +134 -10
  111. package/src/data/ticker-store.ts +67 -0
  112. package/src/data/ticker-writes.ts +5 -0
  113. package/src/i18n/es.ts +27 -0
  114. package/src/i18n/ja.ts +27 -0
  115. package/src/i18n/ko.ts +27 -0
  116. package/src/i18n/zh-cn.ts +27 -0
  117. package/src/i18n/zh-tw.ts +27 -0
  118. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  119. package/src/market-data/ah-pair.ts +103 -0
  120. package/src/market-data/depositary-pair.ts +6 -2
  121. package/src/market-data/hooks.tsx +33 -2
  122. package/src/market-data/market/change-basis.ts +2 -1
  123. package/src/market-data/market/header-market.ts +11 -0
  124. package/src/market-data/split-terms.ts +28 -0
  125. package/src/plugins/builtin/account-management/footer.ts +1 -1
  126. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  127. package/src/plugins/builtin/account-management/model.ts +1 -0
  128. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  129. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  130. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  131. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  132. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  133. package/src/plugins/builtin/alerts/cli.ts +36 -30
  134. package/src/plugins/builtin/alerts/constants.ts +10 -0
  135. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  136. package/src/plugins/builtin/alerts/format.ts +24 -8
  137. package/src/plugins/builtin/alerts/index.tsx +38 -9
  138. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  139. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  140. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  141. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  142. package/src/plugins/builtin/alerts/types.ts +7 -0
  143. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  144. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  145. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  146. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  147. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  148. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  149. package/src/plugins/builtin/awards/pane.tsx +7 -3
  150. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  151. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  152. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  153. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  154. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  155. package/src/plugins/builtin/chart-composer/pane.tsx +9 -3
  156. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  157. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  158. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  159. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  160. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  161. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  162. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  163. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  164. package/src/plugins/builtin/composite/application.ts +14 -0
  165. package/src/plugins/builtin/composite/broker.ts +12 -0
  166. package/src/plugins/builtin/composite/credit.ts +33 -0
  167. package/src/plugins/builtin/composite/crypto.ts +10 -0
  168. package/src/plugins/builtin/composite/earnings.ts +12 -0
  169. package/src/plugins/builtin/composite/filings.ts +13 -0
  170. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  171. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  172. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  173. package/src/plugins/builtin/composite/ownership.ts +23 -0
  174. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  175. package/src/plugins/builtin/composite/quant.ts +15 -0
  176. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  177. package/src/plugins/builtin/composite/screeners.ts +11 -0
  178. package/src/plugins/builtin/composite/shared.ts +11 -0
  179. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  180. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  181. package/src/plugins/builtin/correlation/index.tsx +13 -17
  182. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  183. package/src/plugins/builtin/credit-conditions/series.ts +2 -2
  184. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  185. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  186. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  187. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  188. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  189. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  190. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  191. package/src/plugins/builtin/earnings/board-model.ts +12 -0
  192. package/src/plugins/builtin/earnings/board-table.ts +7 -4
  193. package/src/plugins/builtin/earnings/board.tsx +2 -2
  194. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  195. package/src/plugins/builtin/earnings/headless.ts +7 -4
  196. package/src/plugins/builtin/earnings/highlight.ts +1 -1
  197. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  198. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  199. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  200. package/src/plugins/builtin/econ/calendar-model.ts +18 -0
  201. package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
  202. package/src/plugins/builtin/econ/index.tsx +3 -0
  203. package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
  204. package/src/plugins/builtin/econ-statistics/client.ts +11 -10
  205. package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
  206. package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
  207. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  208. package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
  209. package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
  210. package/src/plugins/builtin/econ-statistics/view.ts +9 -3
  211. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  212. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  213. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  214. package/src/plugins/builtin/exposure/model.ts +10 -0
  215. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  216. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  217. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  218. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  219. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  220. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  221. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  222. package/src/plugins/builtin/mna/detail.tsx +67 -6
  223. package/src/plugins/builtin/mna/headless.ts +128 -13
  224. package/src/plugins/builtin/mna/model.ts +219 -16
  225. package/src/plugins/builtin/mna/pane.tsx +34 -6
  226. package/src/plugins/builtin/money-markets/model.ts +14 -5
  227. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  228. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  229. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  230. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  231. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  232. package/src/plugins/builtin/pe-band/client.ts +13 -1
  233. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  234. package/src/plugins/builtin/pe-band/model.ts +63 -10
  235. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  236. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  237. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  238. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  239. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  240. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  241. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  242. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  243. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  244. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  245. package/src/plugins/builtin/research/event-model.ts +31 -13
  246. package/src/plugins/builtin/research/headless.ts +8 -1
  247. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  248. package/src/plugins/builtin/sectors/index.tsx +6 -9
  249. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  250. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  251. package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
  252. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  253. package/src/plugins/builtin/shared/series-cache.ts +3 -0
  254. package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
  255. package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
  256. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  257. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  258. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  259. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  260. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  261. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  262. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  263. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  264. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  265. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  266. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  267. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +67 -1
  268. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  270. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  271. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  272. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  273. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  274. package/src/plugins/builtin/time-sales/headless.ts +4 -1
  275. package/src/plugins/builtin/time-sales/pane.tsx +2 -0
  276. package/src/plugins/builtin/time-sales/window.ts +12 -0
  277. package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
  278. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
  279. package/src/plugins/builtin/treasury-daily/client.ts +23 -11
  280. package/src/plugins/builtin/volatility/model.ts +17 -0
  281. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  282. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  283. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  284. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  285. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  286. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  287. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  288. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  289. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  290. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  291. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  292. package/src/plugins/catalog-data.ts +20 -0
  293. package/src/plugins/catalog-lazy.ts +51 -0
  294. package/src/plugins/catalog-ui.ts +16 -18
  295. package/src/plugins/host-smoke.ts +5 -2
  296. package/src/portfolio/allocation.ts +79 -19
  297. package/src/portfolio/cash-balances.ts +76 -0
  298. package/src/portfolio/mutations.ts +43 -8
  299. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  300. package/src/renderers/desktop/window-layouts.ts +14 -0
  301. package/src/renderers/dom/data-table/row.tsx +2 -0
  302. package/src/renderers/dom/host/tabs.tsx +57 -8
  303. package/src/renderers/dom/styles.css +13 -5
  304. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  305. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  306. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  307. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  308. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
  309. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  310. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  311. package/src/series/standalone-catalog.ts +5 -4
  312. package/src/series/standalone.ts +13 -7
  313. package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
  314. package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
  315. package/src/sources/gloomberb-cloud/index.ts +14 -3
  316. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  317. package/src/sources/provider-router/financials.ts +20 -13
  318. package/src/sources/provider-router/index.ts +4 -0
  319. package/src/sources/provider-router/search.ts +1 -0
  320. package/src/sync/collections-contributor.ts +3 -1
  321. package/src/sync/config-merge.ts +10 -1
  322. package/src/sync/sanitize.ts +26 -2
  323. package/src/tickers/company-name-listing.ts +16 -2
  324. package/src/tickers/listing-fate.ts +12 -8
  325. package/src/tickers/renamed-listings.ts +43 -10
  326. package/src/tickers/search/home-listing.ts +28 -0
  327. package/src/tickers/search/index.ts +19 -7
  328. package/src/tickers/terminal-codes.ts +11 -1
  329. package/src/time-series/base-series.ts +3 -0
  330. package/src/time-series/ice-credit.ts +1 -0
  331. package/src/time-series/resolve.ts +3 -1
  332. package/src/time-series/spec.ts +2 -2
  333. package/src/time-series/types.ts +2 -1
  334. package/src/types/data-provider.ts +11 -0
  335. package/src/types/financials.ts +39 -3
  336. package/src/types/headless.ts +4 -2
  337. package/src/types/ticker.ts +10 -2
  338. package/src/utils/cli-output.ts +1 -1
  339. package/src/utils/declared-dividends.ts +13 -1
  340. package/src/utils/dividend-cash.ts +5 -1
  341. package/src/utils/forward-dividend.ts +4 -3
  342. package/src/utils/remove-folder.ts +37 -0
  343. package/src/utils/throttled-fetch.ts +15 -1
  344. package/src/utils/trailing-dividend.ts +1 -1
  345. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -15,6 +15,7 @@ import {
15
15
  import type { CompositeChartProps, CompositeChartScene } from "./types";
16
16
  import { DIRECTION_MARKER, seriesColorsDirection, seriesCueCssBackground, type SeriesLineCue } from "./series-cues";
17
17
  import { DisclosureMarker as KitDisclosureMarker } from "../../ui/disclosure-marker";
18
+ import { usePaneCapture } from "../../layout/pane/capture-status";
18
19
 
19
20
  const LEGEND_WHEEL_DELTA_PER_CELL = 8;
20
21
  const NO_LINE_CUES: ReadonlyMap<string, SeriesLineCue> = new Map();
@@ -106,6 +107,12 @@ function nameWords(label: string): string[] {
106
107
  return label.split(" ").filter(Boolean);
107
108
  }
108
109
 
110
+ function sharedLegendContext(series: readonly ResolvedSeries[]): string | null {
111
+ const context = series[0]?.legendContext;
112
+ return context && series.length > 1 && series.every((entry) => entry.legendContext === context
113
+ && entry.label.split(" · ")[0]!.endsWith(` ${context}`)) ? context : null;
114
+ }
115
+
109
116
  /** The shortest a legend name reads on one line: its first word whole, with one `…` for the rest ("Bab…"). */
110
117
  export function shortestLegendName(label: string): string {
111
118
  const words = nameWords(label);
@@ -247,7 +254,7 @@ export function CompositeLegend({
247
254
  cellPlot = false,
248
255
  directionDownColor = null,
249
256
  width,
250
- accessory,
257
+ accessory: liveAccessory,
251
258
  accessoryWidth,
252
259
  formatValue,
253
260
  showLatestChangePercent,
@@ -291,6 +298,7 @@ export function CompositeLegend({
291
298
  /** Folds or opens the legend: a chevron in its inset, shown under the pointer while it is open. */
292
299
  onToggleCollapsed?: () => void;
293
300
  }) {
301
+ const accessory = usePaneCapture() ? null : liveAccessory;
294
302
  const isDesktopWeb = useUiCapabilities().nativePaneChrome === true;
295
303
  const foldKey = useShortcutLabel()("Shift+L");
296
304
  // Folded, the legend keeps its first series; the rest wait behind a count.
@@ -303,6 +311,7 @@ export function CompositeLegend({
303
311
  const valueDates = legendValueDates(series, scene, cursorValueById);
304
312
  // A series read against the right axis while others in its panel read against the left says which is its scale.
305
313
  const leftPanels = new Set(allSeries.filter((entry) => entry.axis === "left" && !entry.hidden).map((entry) => entry.panelId));
314
+ let context: string | null = null;
306
315
  const buildEntries = (withFiscalPeriods: boolean, withAxisNotes = true) => series.map((entry) => {
307
316
  const cue = lineCues.get(entry.id) ?? null;
308
317
  const downColor = !cue && directionDownColor && seriesColorsDirection(entry) ? directionDownColor : null;
@@ -342,8 +351,11 @@ export function CompositeLegend({
342
351
  && cursorValue?.value != null && Number.isFinite(cursorValue.value)
343
352
  ? `Value ${cursorValue.value} ${entry.unit}` : "";
344
353
  const tooltip = [fullText, exactTotal, details].filter(Boolean).join(" · ");
345
- const label = entry.label;
346
- const compactLabel = withoutListingExchange(entry.compactLabel ?? label);
354
+ const metric = entry.legendContext && entry.label.split(" · ")[0]!.endsWith(` ${entry.legendContext}`) ? entry.legendContext : null;
355
+ const shortLabel = withoutListingExchange(entry.compactLabel ?? entry.label);
356
+ const compact = !context && metric && !shortLabel.endsWith(` ${metric}`) ? `${shortLabel} ${metric}` : shortLabel;
357
+ const compactLabel = context && compact.endsWith(` ${context}`) ? compact.slice(0, -context.length - 1) : compact;
358
+ const label = context ? compactLabel : entry.label;
347
359
  const labelWidth = displayWidth(label);
348
360
  const text = [label, valueText].filter(Boolean).join(" ");
349
361
  return {
@@ -354,6 +366,7 @@ export function CompositeLegend({
354
366
  markerWidth,
355
367
  label,
356
368
  compactLabel,
369
+ metric,
357
370
  text,
358
371
  width: Math.max(1, displayWidth(text)) + markerWidth,
359
372
  labelWidth,
@@ -370,9 +383,17 @@ export function CompositeLegend({
370
383
  let entries = buildEntries(true);
371
384
  type LegendEntry = (typeof entries)[number];
372
385
  const otherNames = (target: LegendEntry) => entries.filter((other) => other !== target).map((other) => other.compactLabel);
386
+ const labelParts = (target: LegendEntry, label: string) => {
387
+ const suffix = !context && target.metric && label.endsWith(` ${target.metric}`) ? ` ${target.metric}` : "";
388
+ return { name: suffix ? label.slice(0, -suffix.length) : label, suffix };
389
+ };
390
+ const cutEntryLabel = (target: LegendEntry, label: string, budget: number) => {
391
+ const { name, suffix } = labelParts(target, label);
392
+ return wholeWordsCut(name, budget - displayWidth(suffix), otherNames(target)) + suffix;
393
+ };
373
394
  const setEntryLabel = (target: LegendEntry, label: string, labelWidth: number) => {
374
395
  target.label = label;
375
- const shown = wholeWordsCut(label, labelWidth, otherNames(target));
396
+ const shown = cutEntryLabel(target, label, labelWidth);
376
397
  target.labelWidth = displayWidth(shown);
377
398
  target.text = [shown, target.valueText].filter(Boolean).join(" ");
378
399
  target.width = Math.max(1, displayWidth(target.text)) + target.markerWidth;
@@ -385,7 +406,12 @@ export function CompositeLegend({
385
406
  // line up with the query bar and tables above and below the chart.
386
407
  const inset = width > 1 ? 1 : 0;
387
408
  const leadWidth = valueDates.lead ? displayWidth(valueDates.lead) + 1 : 0;
388
- const innerWidth = Math.max(0, width - inset - leadWidth);
409
+ if (measureSeriesWidth() > width - inset - leadWidth - (accessory ? accessoryWidth ?? 14 : 0)) {
410
+ context = sharedLegendContext(series);
411
+ if (context) entries = buildEntries(true);
412
+ }
413
+ const contextWidth = context ? displayWidth(context) + 1 : 0;
414
+ const innerWidth = Math.max(0, width - inset - leadWidth - contextWidth);
389
415
  const resolvedAccessoryWidth = accessory
390
416
  ? Math.max(1, Math.min(innerWidth, Math.floor(accessoryWidth ?? 14)))
391
417
  : 0;
@@ -412,7 +438,8 @@ export function CompositeLegend({
412
438
  const key = `${apart ? "apart" : "first"}:${label}`;
413
439
  let name = known.get(key);
414
440
  if (name === undefined) {
415
- name = apart ? shortestLegendNameAmong(label, otherNames(entry)) : shortestLegendName(label);
441
+ const parts = labelParts(entry, label);
442
+ name = (apart ? shortestLegendNameAmong(parts.name, otherNames(entry)) : shortestLegendName(parts.name)) + parts.suffix;
416
443
  known.set(key, name);
417
444
  }
418
445
  return name;
@@ -433,6 +460,17 @@ export function CompositeLegend({
433
460
  if (entries.some(({ axisNote }) => axisNote) && minimumWidthOf(entries) > widthBeforeAccessory) {
434
461
  entries = buildEntries(entries.some(({ fiscalPeriod }) => fiscalPeriod), false);
435
462
  }
463
+ if (entries.some((entry) => entry.entry.compactLabel) && measureSeriesWidth() > widthBeforeAccessory) {
464
+ for (const entry of entries) setEntryLabel(entry, entry.compactLabel, displayWidth(entry.compactLabel));
465
+ if (measureSeriesWidth() > widthBeforeAccessory) {
466
+ for (const entry of entries) {
467
+ if (!entry.entry.compactLabel) continue;
468
+ const { name, suffix } = labelParts(entry, entry.compactLabel);
469
+ entry.compactLabel = (nameWords(name)[0] ?? name) + suffix;
470
+ setEntryLabel(entry, entry.compactLabel, displayWidth(entry.compactLabel));
471
+ }
472
+ }
473
+ }
436
474
  const fitsOneLine = minimumWidthOf(entries, true) <= widthBeforeAccessory;
437
475
  // Entries that cannot share a line even with names cut to fragments wrap onto
438
476
  // more lines when the chart gives them room, each whole, its name only cut
@@ -446,7 +484,7 @@ export function CompositeLegend({
446
484
  Math.max(1, widthBeforeAccessory - entry.markerWidth - (entry.valueText ? displayWidth(entry.valueText) + 1 : 0)),
447
485
  );
448
486
  const wrappedWidths = entries.map((entry) => entry.markerWidth + Math.max(1, displayWidth(
449
- [wholeWordsCut(entry.compactLabel, wrappedLabelWidth(entry), otherNames(entry)), entry.valueText].filter(Boolean).join(" "),
487
+ [cutEntryLabel(entry, entry.compactLabel, wrappedLabelWidth(entry)), entry.valueText].filter(Boolean).join(" "),
450
488
  )));
451
489
  wantedRows = packLegendLines(wrappedWidths, widthBeforeAccessory).length;
452
490
  if (rows > 1) {
@@ -460,7 +498,7 @@ export function CompositeLegend({
460
498
  const widest = Math.max(...entries.map((entry) => entry.labelWidth));
461
499
  for (let cap = widest - 1; cap >= 1; cap -= 1) {
462
500
  const packed = packLegendLines(entries.map((entry) => entry.markerWidth + Math.max(1, displayWidth(
463
- [wholeWordsCut(entry.compactLabel, Math.min(cap, wrappedLabelWidth(entry)), otherNames(entry)), entry.valueText].filter(Boolean).join(" "),
501
+ [cutEntryLabel(entry, entry.compactLabel, Math.min(cap, wrappedLabelWidth(entry))), entry.valueText].filter(Boolean).join(" "),
464
502
  ))), widthBeforeAccessory);
465
503
  if (packed.length <= rows) {
466
504
  lines = packed;
@@ -634,24 +672,36 @@ export function CompositeLegend({
634
672
  </Box>
635
673
  );
636
674
  };
637
- const scrollLine = (line: number[] | null, key: string | number, ref: typeof scrollRef | undefined) => (
638
- <ScrollBox
639
- key={key}
640
- ref={ref}
641
- width={seriesWidth}
642
- height={1}
643
- flexShrink={0}
644
- scrollX
645
- focusable={false}
646
- horizontalScrollbarOptions={{ visible: false }}
647
- onMouseScroll={ref ? handleMouseScroll : undefined}
648
- data-gloom-role="composite-chart-legend-scroll"
649
- >
650
- <Box flexDirection="row" width={line ? lineWidth(line) : desiredSeriesWidth} height={1} gap={1}>
651
- {line ? line.map((index) => renderEntry(entries[index]!, index)) : entries.map(renderEntry)}
675
+ const scrollLine = (line: number[] | null, key: string | number, ref: typeof scrollRef | undefined) => {
676
+ const contentWidth = line ? lineWidth(line) : desiredSeriesWidth;
677
+ const count = ref && !collapsed && series.length > 1 && contentWidth > seriesWidth ? `${series.length} series` : "";
678
+ const countWidth = count ? Math.min(seriesWidth, displayWidth(count) + 1) : 0;
679
+ return (
680
+ <Box key={key} flexDirection="row" width={seriesWidth} height={1} flexShrink={0}>
681
+ <ScrollBox
682
+ ref={ref}
683
+ width={Math.max(0, seriesWidth - countWidth)}
684
+ height={1}
685
+ flexShrink={0}
686
+ scrollX
687
+ focusable={false}
688
+ horizontalScrollbarOptions={{ visible: false }}
689
+ onMouseScroll={ref ? handleMouseScroll : undefined}
690
+ data-gloom-role="composite-chart-legend-scroll"
691
+ >
692
+ <Box flexDirection="row" width={contentWidth} height={1} gap={1}>
693
+ {line ? line.map((index) => renderEntry(entries[index]!, index)) : entries.map(renderEntry)}
694
+ </Box>
695
+ </ScrollBox>
696
+ {count ? (
697
+ <Box width={countWidth} height={1} flexShrink={0} paddingLeft={countWidth > displayWidth(count) ? 1 : 0}
698
+ data-gloom-role="composite-chart-legend-count" title={series.map((entry) => entry.label).join(" · ")}>
699
+ <Text fg={themeColors.textDim}>{countWidth < displayWidth(count) ? String(series.length) : count}</Text>
700
+ </Box>
701
+ ) : null}
652
702
  </Box>
653
- </ScrollBox>
654
- );
703
+ );
704
+ };
655
705
  const lineCount = lines?.length ?? 1;
656
706
  const foldLabel = foldedCount > 0
657
707
  ? `Show ${foldedCount} more series (${foldKey})`
@@ -707,6 +757,11 @@ export function CompositeLegend({
707
757
  <Text fg={themeColors.textMuted}>{valueDates.lead}</Text>
708
758
  </Box>
709
759
  ) : null}
760
+ {context ? (
761
+ <Box width={contextWidth} height={1} flexShrink={0} data-gloom-role="composite-chart-legend-context">
762
+ <Text fg={themeColors.textMuted}>{context}</Text>
763
+ </Box>
764
+ ) : null}
710
765
  {seriesWidth > 0 && lines ? (
711
766
  <Box flexDirection="column" width={seriesWidth} height={lineCount} flexShrink={0}>
712
767
  {lines.map((line, index) => scrollLine(line, index, index === lines!.length - 1 ? scrollRef : undefined))}
@@ -104,7 +104,7 @@ export function PanelPlotSurface({
104
104
  );
105
105
  }
106
106
 
107
- /** A value axis, with the cursor's value on it and, on the desktop, each series' value at the cursor. */
107
+ /** A value axis, with the cursor's value and each series' observation at that time. */
108
108
  export function PanelValueAxis({
109
109
  view,
110
110
  formatAxisValue,
@@ -122,8 +122,8 @@ export function PanelValueAxis({
122
122
  // The pointer's value on the axes follows the level line it belongs to.
123
123
  const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
124
124
  const seriesTags = useMemo(
125
- () => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side) : undefined,
126
- [formatAxisValue, isDesktopWeb, panel, scene, side],
125
+ () => resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side),
126
+ [formatAxisValue, panel, scene, side],
127
127
  );
128
128
  return (
129
129
  <PriceAxisLabels
@@ -37,7 +37,7 @@ interface PriceAxisLabelsProps {
37
37
  axisColor?: string;
38
38
  /** Anchors that stay put while the cursor moves, such as a measure start. */
39
39
  extraMarkers?: readonly PriceAxisMarker[];
40
- /** Desktop/web observations, separate from a drawing tool's endpoint. */
40
+ /** Series observations, separate from a drawing tool's endpoint. */
41
41
  seriesTags?: readonly SeriesAxisTag[];
42
42
  measuredPixelHeight?: number;
43
43
  /** A value axis the pointer stretches and squeezes: a drag or the wheel on it, a double click back. */
@@ -218,18 +218,20 @@ export function PriceAxisLabels({
218
218
  data-gloom-side={side}
219
219
  >
220
220
  {Array.from({ length: height }, (_, row) => {
221
+ const seriesTag = fractionalViewport ? undefined : placedSeriesTags.find((tag) =>
222
+ Math.min(height - 1, Math.floor(tag.centerY / pixelHeight * height)) === row);
221
223
  const isCursorRow = !usePixelOverlay && cursorLabel !== null && cursorRow === row;
222
224
  const marker = usePixelOverlay || usePixelTicks
223
225
  ? undefined
224
226
  : extraMarkers?.find((entry) => entry.row === row);
225
- const label = isCursorRow
227
+ const label = seriesTag?.label ?? (isCursorRow
226
228
  ? cursorLabel
227
- : marker?.label ?? (usePixelTicks || (footButton && row === height - 1) ? null : axisLabels.get(row) ?? null);
229
+ : marker?.label ?? (usePixelTicks || (footButton && row === height - 1) ? null : axisLabels.get(row) ?? null));
228
230
  return (
229
231
  <AxisRow
230
232
  key={row}
231
233
  label={label}
232
- fg={isCursorRow ? cursorColor : marker ? marker.color : axisColor}
234
+ fg={seriesTag?.color ?? (isCursorRow ? cursorColor : marker ? marker.color : axisColor)}
233
235
  side={side}
234
236
  axisWidth={axisWidth}
235
237
  axisSectionWidth={axisSectionWidth}
@@ -271,7 +273,7 @@ export function PriceAxisLabels({
271
273
  {axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
272
274
  </Box>
273
275
  )) : null}
274
- {seriesTags ? <SeriesAxisTags placed={placedSeriesTags} pixelHeight={pixelHeight} lanes={lanes} background={cursorBackgroundColor} /> : null}
276
+ {seriesTags && fractionalViewport ? <SeriesAxisTags placed={placedSeriesTags} pixelHeight={pixelHeight} lanes={lanes} background={cursorBackgroundColor} /> : null}
275
277
  {usePixelOverlay ? (
276
278
  <Box
277
279
  width={axisSectionWidth}
@@ -10,6 +10,7 @@ import { PriceSparkline } from "../price-sparkline/view";
10
10
  import { StatGrid, type StatItem } from "../ui/stat-grid";
11
11
  import type { TableWidthColumn } from "../ui/table-layout";
12
12
  import { CHART_COMPACT_ROWS, chartTableChromeRows, chartTableLayout, type ChartTableLayout } from "./layout";
13
+ import { useRemoteUiNode } from "../../remote/semantic-tree";
13
14
 
14
15
  const DAY_MS = 86_400_000;
15
16
  /** Daily series shorter than this still span two weeks, so the axis reads days, not hours. */
@@ -205,6 +206,14 @@ export function ChartTableHeader(props: ChartTableHeaderProps) {
205
206
  const { width, query, chart } = props;
206
207
  const colors = useThemeColors();
207
208
  const layout = useChartTableLayout(props);
209
+ const essential = props.figures?.filter((item) => item.essential === true) ?? [];
210
+ useRemoteUiNode(essential.length ? {
211
+ role: "figure-layout", label: "Essential figures",
212
+ metadata: {
213
+ figures: essential.map(({ label, value }) => ({ label, value })),
214
+ omitted: essential.filter((item) => !layout.figures.includes(item)).map((item) => item.label),
215
+ },
216
+ } : null);
208
217
  const series = chart?.series;
209
218
  const viewport = useMemo(() => {
210
219
  if (chart?.viewport || !series?.length) return chart?.viewport;
@@ -29,7 +29,6 @@ const TABLE_MIN_BODY_ROWS = 4;
29
29
  const CHART_SHARE = 0.4;
30
30
  /** Below this many body rows the figures keep a single row. */
31
31
  const SHORT_BODY_ROWS = 12;
32
- /** The figures never take more than this share of the body. */
33
32
  const FIGURE_SHARE = 0.25;
34
33
  /** The share of the body figures that wrap rather than cut a date may take, beyond FIGURE_SHARE. */
35
34
  const WRAPPED_FIGURE_SHARE = 1 / 3;
@@ -96,7 +95,10 @@ function figureRows(figures: readonly StatItem[], width: number, maxLines: numbe
96
95
  */
97
96
  function fitFigures(figures: readonly StatItem[], width: number, maxRows: number, body: number): { figures: StatItem[]; maxLines: number } {
98
97
  const kept = [...figures];
99
- while (kept.length > 0 && figureRows(kept, width, maxRows) > maxRows) kept.pop();
98
+ while (kept.length > 0 && figureRows(kept, width, maxRows) > maxRows) {
99
+ const optional = kept.findLastIndex((item) => item.essential !== true);
100
+ kept.splice(optional >= 0 ? optional : kept.length - 1, 1);
101
+ }
100
102
  return { figures: kept, maxLines: maxRows > 1 ? Math.max(maxRows, Math.floor(body * WRAPPED_FIGURE_SHARE)) : maxRows };
101
103
  }
102
104
 
@@ -106,23 +108,19 @@ function fitFigures(figures: readonly StatItem[], width: number, maxRows: number
106
108
  *
107
109
  * - The table always keeps its header and a few rows (all of them when it has
108
110
  * fewer), so the rows the pane is about never vanish.
109
- * - The figures take at most a quarter of the body, one row when it is short
110
- * or when a second row would cost the chart its place, and lose items from
111
- * the end rather than spill; a whole-row figure wraps onto a second line
112
- * rather than cut its detail, in rows up to a third of the body, never
113
- * at the cost of a figure that fits a line.
114
111
  * - The chart takes 40% of what is left, or everything the table does not
115
112
  * need when all its rows fit, so no blank band opens under a short table.
116
113
  * - Below a readable chart the band becomes a one-row strip, then nothing.
117
114
  */
118
115
  export function chartTableLayout(input: ChartTableLayoutInput): ChartTableLayout {
119
116
  const body = Math.max(0, Math.floor(input.height) - (input.queryRows ?? 0));
120
- const figureCap = body < SHORT_BODY_ROWS ? 1 : Math.max(1, Math.floor(body * FIGURE_SHARE));
117
+ const essential = (input.figures ?? []).filter((item) => item.essential === true);
118
+ const essentialRows = figureRows(essential, input.width, body);
119
+ const figureCap = Math.max(essentialRows, body < SHORT_BODY_ROWS ? 1 : Math.max(1, Math.floor(body * FIGURE_SHARE)));
121
120
  const layout = layoutWithFigureRows(input, body, figureCap);
122
- // A readable chart is worth more than a second row of figures.
123
121
  if (layout.mode !== "full" && layout.figureRows > 1) {
124
122
  const tighter = layoutWithFigureRows(input, body, 1);
125
- if (tighter.mode === "full") return tighter;
123
+ if (tighter.mode === "full" && essential.every((item) => tighter.figures.includes(item))) return tighter;
126
124
  }
127
125
  // Without a full chart, rows a short table leaves go back to figures that
128
126
  // were dropped, rather than to a blank band under the table.
@@ -145,7 +143,9 @@ function layoutWithFigureRows(input: ChartTableLayoutInput, body: number, figure
145
143
  const tableFit = chrome + tableRows;
146
144
 
147
145
  // A table with no room for a single row after the figures gets the body back.
148
- const figureBudget = Math.min(figureCap, Math.max(0, body - chrome - Math.min(tableRows, 1)));
146
+ const essentialRows = figureRows((input.figures ?? []).filter((item) => item.essential === true), width, body);
147
+ const figureBudget = Math.min(figureCap, Math.max(0, body - tableMin,
148
+ Math.min(Math.max(1, essentialRows), body - chrome - Math.min(tableRows, 1))));
149
149
  const { figures, maxLines: figureMaxLines } = figureBudget > 0 ? fitFigures(input.figures ?? [], width, figureBudget, body) : { figures: [], maxLines: 0 };
150
150
  const shownRows = figures.length ? figureRows(figures, width, figureMaxLines) : 0;
151
151
 
@@ -5,6 +5,7 @@ import type {
5
5
  PaneTemplateDef,
6
6
  ShortcutArgError,
7
7
  } from "../../../types/plugin";
8
+ import { glossaryNamesFunction } from "../../../cli/glossary";
8
9
  import { fuzzyFilter } from "../../../utils/fuzzy-search";
9
10
  import { discoveryOpening } from "../../../utils/lookup-token";
10
11
  import { summarizeError } from "../helpers";
@@ -295,6 +296,20 @@ function paneTemplateDiscovery(template: PaneTemplateDef, registry: Pick<PluginR
295
296
  return (template.headless ?? registry.panes?.get(template.paneId)?.headless)?.discovery;
296
297
  }
297
298
 
299
+ /**
300
+ * A row found by a query that is, whole, a term its function shows (`var`,
301
+ * `value at risk` for MARS and PORT), as `catalog` finds it, where the row's
302
+ * own words do not carry the query already; those rank as they did. A word of
303
+ * a longer query, or a loose alias, finds nothing.
304
+ */
305
+ function withShownTerm(item: ResultItem, template: PaneTemplateDef, query: string): ResultItem {
306
+ const codes = [template.shortcut?.prefix, ...template.shortcut?.aliases ?? []];
307
+ if (!codes.some((code) => !!code && glossaryNamesFunction(code, query))) return item;
308
+ const own = `${item.label} ${item.searchText ?? ""} ${item.detail} ${item.right ?? ""}`.toLowerCase();
309
+ if (query.toLowerCase().split(/\s+/).every((word) => own.includes(word))) return item;
310
+ return { ...item, searchText: `${query} ${item.searchText ?? ""}` };
311
+ }
312
+
298
313
  export function buildPaneShortcutItems(options: {
299
314
  templates: readonly PaneTemplateDef[];
300
315
  filterQuery?: string;
@@ -328,7 +343,8 @@ export function buildPaneShortcutItems(options: {
328
343
  : options.createOptions,
329
344
  showShortcut: true,
330
345
  });
331
- return opening && opening.argument && !item.disabled ? { ...item, name: opening.argument } : item;
346
+ const named = opening && opening.argument && !item.disabled ? { ...item, name: opening.argument } : item;
347
+ return query ? withShownTerm(named, template, query) : named;
332
348
  });
333
349
 
334
350
  return options.filterQuery
@@ -77,8 +77,9 @@ function buildInstantAnswer(options: {
77
77
  savedSymbolKeys: ReadonlySet<string>;
78
78
  buildTickerSearchResultItems: (candidates: TickerSearchCandidate[], query: string) => ResultItem[];
79
79
  localTickerSearchResultItems: (query?: string, options?: { category?: string; limit?: number }) => ResultItem[];
80
+ homeVenue?: string | null;
80
81
  }): InstantAnswer | null {
81
- const { query, fromIndex, cached, tickers, savedSymbolKeys, buildTickerSearchResultItems, localTickerSearchResultItems } = options;
82
+ const { query, fromIndex, cached, tickers, savedSymbolKeys, buildTickerSearchResultItems, localTickerSearchResultItems, homeVenue } = options;
82
83
  const localItems = () => localTickerSearchResultItems(query, { limit: 6 });
83
84
  if (cached) {
84
85
  return { query, items: mergeTickerSearchResultItems(query, buildTickerSearchResultItems(withMajorCoinCandidate(query, cached, tickers), query), localItems()), fromIndex: false };
@@ -92,6 +93,7 @@ function buildInstantAnswer(options: {
92
93
  tickers,
93
94
  providerResults: known,
94
95
  totalLimit: LISTING_SEARCH_LIMIT,
96
+ homeVenue,
95
97
  ...QUICK_LOOK_TICKER_SEARCH_OPTIONS,
96
98
  }), tickers);
97
99
  if (candidates.length === 0) return null;
@@ -133,6 +135,8 @@ export function useRootProviderSearch(options: {
133
135
  categoryPriorities?: CommandBarCategoryPriorities;
134
136
  currentRoute: CommandBarRoute | null;
135
137
  dataProvider: DataProvider;
138
+ /** The venue of the user's own market, whose lines of the company a word names lead (`withHomeVenueLead`). */
139
+ homeVenue?: string | null;
136
140
  localTickerSearchResultItems: (query?: string, options?: { category?: string; limit?: number }) => ResultItem[];
137
141
  portfolios: AppState["config"]["portfolios"];
138
142
  readTickerSearchCache: (
@@ -177,6 +181,7 @@ export function useRootProviderSearch(options: {
177
181
  categoryPriorities,
178
182
  currentRoute,
179
183
  dataProvider,
184
+ homeVenue = null,
180
185
  localTickerSearchResultItems,
181
186
  portfolios,
182
187
  readTickerSearchCache,
@@ -218,11 +223,13 @@ export function useRootProviderSearch(options: {
218
223
  savedSymbolKeys,
219
224
  buildTickerSearchResultItems,
220
225
  localTickerSearchResultItems,
226
+ homeVenue,
221
227
  });
222
228
  // The index is read inside; its version says when what it knows changed.
223
229
  }, [
224
230
  buildTickerSearchResultItems,
225
231
  currentRoute,
232
+ homeVenue,
226
233
  listingIndexVersion,
227
234
  listingSuffix,
228
235
  localTickerSearchResultItems,
@@ -311,6 +318,7 @@ export function useRootProviderSearch(options: {
311
318
  },
312
319
  // The rows the CLI reads a symbol's listings from, so `CAR:` offers CAR Group on ASX (its eleventh).
313
320
  totalLimit: LISTING_SEARCH_LIMIT,
321
+ homeVenue,
314
322
  ...QUICK_LOOK_TICKER_SEARCH_OPTIONS,
315
323
  }));
316
324
  if (requestId !== rootSearchRequestIdRef.current) return;
@@ -339,6 +347,7 @@ export function useRootProviderSearch(options: {
339
347
  buildTickerSearchResultItems,
340
348
  currentRoute,
341
349
  dataProvider,
350
+ homeVenue,
342
351
  localTickerSearchResultItems,
343
352
  rootTickerSearchArg,
344
353
  searchBrokerId,
@@ -15,6 +15,9 @@ import {
15
15
  import { matchPrefix, type Command } from "../../commands/registry";
16
16
  import { pastedRootList } from "../../commands/collection-list";
17
17
  import { isCollectionCommand, SECURITY_DESCRIPTION_SEARCH } from "../../helpers";
18
+
19
+ /** A command's code that is a ticker's shape too: letters, as a US listing's symbol is written. */
20
+ const TICKER_SHAPED_CODE = /^[A-Z]{1,5}$/;
18
21
  import { recentPaneTemplateArg } from "../../pane-templates/items";
19
22
  import { dedupeById, PASTED_LIST_CATEGORY } from "../../view-model";
20
23
  import type { ResultItem } from "../../list/model";
@@ -109,6 +112,27 @@ export interface RootResultModelOptions {
109
112
  tickerActionItems: () => ResultItem[];
110
113
  }
111
114
 
115
+ /**
116
+ * The row that opens a function's code as a ticker instead (`FB as a ticker`,
117
+ * `CATL as a ticker`): the security search for the code. Null for a code no
118
+ * ticker is written like, or with no security search to open.
119
+ */
120
+ function tickerCodeItem(
121
+ code: string,
122
+ availableCommands: Command[],
123
+ openModeRoute: RootResultModelOptions["openModeRoute"],
124
+ ): ResultItem | null {
125
+ if (!TICKER_SHAPED_CODE.test(code) || !availableCommands.some((command) => command.id === "security-description")) return null;
126
+ return {
127
+ id: `ticker-code:${code}`,
128
+ label: `${code} as a ticker`,
129
+ detail: "Open security details after resolving a ticker",
130
+ category: "Search",
131
+ kind: "command",
132
+ action: () => openModeRoute("ticker-search", code, SECURITY_DESCRIPTION_SEARCH),
133
+ };
134
+ }
135
+
112
136
  /** An in-flight or answered request keeps its rows even if the heuristic lapses. */
113
137
  function isAssistSectionVisible(
114
138
  assist: AssistRowHandlers,
@@ -340,13 +364,17 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
340
364
  }))
341
365
  : [shortcutItem];
342
366
  shortcutRuns = templateItems.some((item) => !item.disabled);
343
- const relatedTemplateItems = rootQuery.trim().toUpperCase() === rootShortcutIntent.prefix
367
+ const codeAlone = rootQuery.trim().toUpperCase() === rootShortcutIntent.prefix;
368
+ const relatedTemplateItems = codeAlone
344
369
  ? paneShortcutItems({
345
370
  filterQuery: rootQuery,
346
371
  includePromptableTickerTemplates: true,
347
372
  })
348
373
  : [];
349
- items.push(...templateItems, ...relatedTemplateItems);
374
+ // CATL is Catalysts and CATL's own name for itself, as FB is Send Feedback and a ticker: the listing is the
375
+ // row under the function, which Enter still opens.
376
+ const tickerItem = codeAlone ? tickerCodeItem(rootShortcutIntent.prefix, availableCommands, openModeRoute) : null;
377
+ items.push(...templateItems, ...(tickerItem ? [tickerItem] : []), ...relatedTemplateItems);
350
378
  } else if (
351
379
  rootShortcutIntent.kind !== "none"
352
380
  && rootShortcutIntent.source === "plugin-command"
@@ -392,6 +420,10 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
392
420
  } else if (match && !match.command.hasArg) {
393
421
  const item = commandToItem(match.command);
394
422
  if (item) items.push(item);
423
+ // FB is Send Feedback and a ticker too (VF, SB and CR are companies): the ticker is the row under the command,
424
+ // which Enter still runs, for someone who typed the code meaning the listing.
425
+ const tickerItem = match.arg ? null : tickerCodeItem(rootQuery.trim().toUpperCase(), availableCommands, openModeRoute);
426
+ if (tickerItem) items.push(tickerItem);
395
427
  } else if (!rootQuery) {
396
428
  // One row per function: a code a group above already runs as it is (a
397
429
  // recent CHAT, Start Here's PF) is not listed again in the groups below.
@@ -19,6 +19,7 @@ import { isProviderResultItem } from "./search-providers";
19
19
  import { buildRootShortcutFeedback } from "./shortcut-feedback";
20
20
  import { commandShortcutQuery, type ShortcutIntent } from "./shortcuts";
21
21
  import { clampIndex } from "../../../../utils/math";
22
+ import { homeMarketVenue, systemTimeZone } from "../../../../market-data/market/header-market";
22
23
 
23
24
  /** Written the way a symbol is: up to five letters and a share class (AAPL, nvda, BRK.B). */
24
25
  const SYMBOL_SHAPED_QUERY = /^[A-Za-z]{1,5}(?:[.\-/][A-Za-z]{1,2})?$/;
@@ -190,6 +191,9 @@ export function useCommandBarRootRuntime({
190
191
  const tickerSearchRouteQuery = currentRoute?.kind === "mode" && currentRoute.screen === "ticker-search"
191
192
  ? currentRoute.query
192
193
  : null;
194
+ // The market the header shows is the desk's own: search leads with its lines of the company a word names.
195
+ const headerMarket = state.config.headerMarket;
196
+ const homeVenue = useMemo(() => homeMarketVenue(headerMarket, systemTimeZone()), [headerMarket]);
193
197
 
194
198
  const {
195
199
  tickerSearchPending,
@@ -200,6 +204,7 @@ export function useCommandBarRootRuntime({
200
204
  buildTickerSearchResultItems,
201
205
  dataProvider,
202
206
  getTickers,
207
+ homeVenue,
203
208
  localTickerSearchResultItems,
204
209
  readTickerSearchCache,
205
210
  routeQuery: tickerSearchRouteQuery,
@@ -300,7 +305,8 @@ export function useCommandBarRootRuntime({
300
305
  if (rootTickerReading) return rootTickerReading.search;
301
306
  const trimmed = rootQuery.trim();
302
307
  const symbolQuery = symbolSearchQuery(trimmed);
303
- if (symbolQuery.length < 2) return null;
308
+ // One letter is too little to be worth a search; one digit is a Hong Kong code as people type it (5 is HSBC's 0005).
309
+ if (symbolQuery.length < 2 && !/^\d$/.test(symbolQuery)) return null;
304
310
  const normalizedQuery = normalizeCommandTickerSearchText(symbolQuery);
305
311
  // The install row for "TV" is labelled TV, but it leads on purpose and
306
312
  // must not keep Grupo Televisa out of the list.
@@ -331,6 +337,7 @@ export function useCommandBarRootRuntime({
331
337
  categoryPriorities: providerCategoryPriorities,
332
338
  currentRoute,
333
339
  dataProvider,
340
+ homeVenue,
334
341
  localTickerSearchResultItems,
335
342
  portfolios: state.config.portfolios,
336
343
  readTickerSearchCache,
@@ -17,6 +17,8 @@ export function useTickerSearchRouteResults(options: {
17
17
  buildTickerSearchResultItems: (candidates: TickerSearchCandidate[], query: string) => ResultItem[];
18
18
  dataProvider: DataProvider;
19
19
  getTickers: () => AppState["tickers"];
20
+ /** The venue of the user's own market, whose lines of the company a word names lead. */
21
+ homeVenue?: string | null;
20
22
  localTickerSearchResultItems: (query?: string, options?: { category?: string; limit?: number }) => ResultItem[];
21
23
  readTickerSearchCache: (
22
24
  query: string,
@@ -41,6 +43,7 @@ export function useTickerSearchRouteResults(options: {
41
43
  buildTickerSearchResultItems,
42
44
  dataProvider,
43
45
  getTickers,
46
+ homeVenue,
44
47
  localTickerSearchResultItems,
45
48
  readTickerSearchCache,
46
49
  routeQuery,
@@ -104,6 +107,7 @@ export function useTickerSearchRouteResults(options: {
104
107
  },
105
108
  // The rows the CLI's search reads, so CAR Group on ASX (CAR's eleventh row) is offered too.
106
109
  totalLimit: LISTING_SEARCH_LIMIT,
110
+ homeVenue,
107
111
  ...QUICK_LOOK_TICKER_SEARCH_OPTIONS,
108
112
  });
109
113
  if (requestId !== searchRequestIdRef.current) return;
@@ -137,6 +141,7 @@ export function useTickerSearchRouteResults(options: {
137
141
  buildTickerSearchResultItems,
138
142
  dataProvider,
139
143
  getTickers,
144
+ homeVenue,
140
145
  localTickerSearchResultItems,
141
146
  readTickerSearchCache,
142
147
  resetTickerSearchRoute,