@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
@@ -0,0 +1,156 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { apiClient, type CloudAccountPlan } from "../../api-client";
3
+ import { usePlanAccess } from "../../api-client/plan-access";
4
+ import { getPaneTemplateDisplayLabel } from "../../components/command-bar/pane-templates/items";
5
+ import type { AppPluginStateStorePort } from "../../core/app-service-ports";
6
+ import type { PluginRegistry } from "../../plugins/registry";
7
+ import { useAppDispatch, useAppSelector } from "../../state/app/context";
8
+ import { recordFunctionOpen } from "../../telemetry/usage-counts";
9
+ import { logFailure } from "../../utils/log-failure";
10
+ import {
11
+ openedFunctions,
12
+ ownTickers,
13
+ pickProWelcomeChips,
14
+ proWelcomeEligible,
15
+ type ProWelcomeChip,
16
+ } from "./model";
17
+
18
+ /**
19
+ * Whether the row was dismissed lives in the app's local state store (SQLite
20
+ * in the terminal and the desktop app, browser storage on the web), for this
21
+ * machine, never in config.json, cloud sync or anything sent anywhere.
22
+ */
23
+ const STATE_OWNER = "core.pro-welcome";
24
+ const DISMISSED_KEY = "dismissed";
25
+
26
+ export interface ProWelcome {
27
+ /** The functions the row names while it shows; null otherwise. */
28
+ chips: ProWelcomeChip[] | null;
29
+ /** Opens a function on its ticker, as the command bar would run it. */
30
+ open(chip: ProWelcomeChip): void;
31
+ /** Puts the row away for good on this machine. */
32
+ dismiss(): void;
33
+ }
34
+
35
+ interface UseProWelcomeOptions {
36
+ /** This window shows the row: the main window, with no setup or sign-in in front of the workspace. */
37
+ active: boolean;
38
+ pluginState: Pick<AppPluginStateStorePort, "get" | "set">;
39
+ pluginRegistry: Pick<PluginRegistry, "paneTemplates" | "createPaneFromTemplateAsync">;
40
+ /** Settles once every plugin has registered: the functions and the account are known by then. */
41
+ pluginsReady?: Promise<unknown>;
42
+ /** Defaults to the Cloud API client's `/account/cloud`. */
43
+ loadPlan?: () => Promise<CloudAccountPlan>;
44
+ }
45
+
46
+ function readDismissed(pluginState: Pick<AppPluginStateStorePort, "get">): boolean {
47
+ try {
48
+ return pluginState.get<boolean>(STATE_OWNER, DISMISSED_KEY)?.value === true;
49
+ } catch (error) {
50
+ logFailure("pro-welcome", "Reading whether the Pro row was dismissed failed")(error);
51
+ return false;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * The first-weeks Pro row's session (see `./model.ts` for who sees it and
57
+ * what it names). The account's plan is asked for once a session, and only
58
+ * for a paying Pro account that has not dismissed the row.
59
+ */
60
+ export function useProWelcome({
61
+ active,
62
+ pluginState,
63
+ pluginRegistry,
64
+ pluginsReady,
65
+ loadPlan = () => apiClient.getCloudAccountPlan(),
66
+ }: UseProWelcomeOptions): ProWelcome {
67
+ const dispatch = useAppDispatch();
68
+ const initialized = useAppSelector((state) => state.initialized);
69
+ const layout = useAppSelector((state) => state.config.layout);
70
+ const layouts = useAppSelector((state) => state.config.layouts);
71
+ const recentCommands = useAppSelector((state) => state.config.recentCommands);
72
+ const portfolios = useAppSelector((state) => state.config.portfolios);
73
+ const watchlists = useAppSelector((state) => state.config.watchlists);
74
+ const disabledPlugins = useAppSelector((state) => state.config.disabledPlugins);
75
+ const tickers = useAppSelector((state) => state.tickers);
76
+ const recentTickers = useAppSelector((state) => state.recentTickers);
77
+ const access = usePlanAccess();
78
+ const accountId = access.signedIn ? apiClient.getCurrentUser()?.id ?? null : null;
79
+
80
+ const [ready, setReady] = useState(!pluginsReady);
81
+ useEffect(() => {
82
+ if (!pluginsReady) return;
83
+ let live = true;
84
+ const done = () => {
85
+ if (live) setReady(true);
86
+ };
87
+ pluginsReady.then(done, done);
88
+ return () => {
89
+ live = false;
90
+ };
91
+ }, [pluginsReady]);
92
+
93
+ const [dismissed, setDismissed] = useState(() => readDismissed(pluginState));
94
+ const [plan, setPlan] = useState<{ accountId: string; plan: CloudAccountPlan } | null>(null);
95
+ const asked = useRef(new Set<string>());
96
+ const loadPlanRef = useRef(loadPlan);
97
+ loadPlanRef.current = loadPlan;
98
+ const wanted = active && initialized && ready && !dismissed && access.isPayingPro && !!accountId;
99
+
100
+ useEffect(() => {
101
+ if (!wanted || !accountId || asked.current.has(accountId)) return;
102
+ asked.current.add(accountId);
103
+ // Kept under the account it is for: one that signed in since never reads it.
104
+ loadPlanRef.current().then(
105
+ (next) => setPlan({ accountId, plan: next }),
106
+ // The row is a nicety: without an answer it stays away until the next launch.
107
+ logFailure("pro-welcome", "Loading the account's plan failed"),
108
+ );
109
+ }, [accountId, wanted]);
110
+
111
+ const eligible = wanted && plan?.accountId === accountId && proWelcomeEligible({
112
+ access,
113
+ plan: plan.plan,
114
+ dismissed,
115
+ now: Date.now(),
116
+ });
117
+
118
+ const chips = useMemo(() => {
119
+ if (!eligible) return null;
120
+ const paneIdOf = (templateId: string) => pluginRegistry.paneTemplates.get(templateId)?.paneId ?? null;
121
+ const opened = openedFunctions({ layout, layouts, recentCommands }, paneIdOf);
122
+ const own = ownTickers({ portfolios, watchlists }, tickers, recentTickers);
123
+ const picked = pickProWelcomeChips(own, opened, (templateId) => pluginRegistry.paneTemplates.has(templateId));
124
+ return picked.length > 0 ? picked : null;
125
+ // The templates follow the plugins turned on and off.
126
+ }, [disabledPlugins, eligible, layout, layouts, pluginRegistry, portfolios, recentCommands, recentTickers, tickers, watchlists]);
127
+
128
+ const open = useCallback((chip: ProWelcomeChip) => {
129
+ const template = pluginRegistry.paneTemplates.get(chip.fn.templateId);
130
+ if (!template) return;
131
+ // Kept as the command bar keeps its runs, so the row stops naming it.
132
+ dispatch({
133
+ type: "RECORD_COMMAND",
134
+ id: `pane-template:${template.id}`,
135
+ label: getPaneTemplateDisplayLabel(template),
136
+ arg: chip.symbol,
137
+ });
138
+ recordFunctionOpen({ shortcut: chip.fn.shortcut, externalPluginId: null });
139
+ pluginRegistry.createPaneFromTemplateAsync(template.id, {
140
+ arg: chip.symbol,
141
+ symbol: chip.symbol,
142
+ ...(chip.ticker ? { ticker: chip.ticker } : {}),
143
+ }).catch(logFailure("pro-welcome", "Opening a Pro function from the row failed"));
144
+ }, [dispatch, pluginRegistry]);
145
+
146
+ const dismiss = useCallback(() => {
147
+ setDismissed(true);
148
+ try {
149
+ pluginState.set(STATE_OWNER, DISMISSED_KEY, true);
150
+ } catch (error) {
151
+ logFailure("pro-welcome", "Saving the Pro row's dismissal failed")(error);
152
+ }
153
+ }, [pluginState]);
154
+
155
+ return useMemo(() => ({ chips, open, dismiss }), [chips, dismiss, open]);
156
+ }
@@ -0,0 +1,135 @@
1
+ import { useEffect, type Dispatch } from "react";
2
+ import { watchExternalConfigChanges } from "../../data/config/store";
3
+ import { serializeJson } from "../../data/sqlite/json";
4
+ import { hasPendingTickerWrite, hasPendingTickerWrites } from "../../data/ticker-writes";
5
+ import type { AppTickerRepositoryPort } from "../../core/app-service-ports";
6
+ import type { PluginRegistry } from "../../plugins/registry";
7
+ import type { AppAction, AppState } from "../../state/app/context";
8
+ import type { TickerRecord } from "../../types/ticker";
9
+ import { logFailure } from "../../utils/log-failure";
10
+
11
+ /** How often the ticker rows are looked at for another program's write: a cheap question to SQLite. */
12
+ const TICKER_ROWS_LOOK_MS = 2_000;
13
+
14
+ type TickerRowsPort = AppTickerRepositoryPort & {
15
+ /**
16
+ * Changes when another program commits to the database; absent where no
17
+ * one can say. The desktop app's windows ask the process that holds it.
18
+ */
19
+ changesElsewhere?(): number | null | Promise<number | null>;
20
+ /**
21
+ * The rows the repository held a copy of that a read found deleted by
22
+ * another program (`TickerRepository.takeRowsDeletedElsewhere`), whoever
23
+ * wrote them last: rows the app added itself since its last look included.
24
+ */
25
+ takeRowsDeletedElsewhere?(): string[] | Promise<string[]>;
26
+ };
27
+
28
+ /**
29
+ * Takes in what a `gloom` command run beside the app writes to the profile:
30
+ * config.json (alerts, settings, watchlists and portfolios, layouts) as soon
31
+ * as the file changes, and ticker rows (watchlist members, positions) within
32
+ * a couple of seconds. The app shows them, an alert added from the terminal
33
+ * is checked, and no later save of the app's own copy writes over them.
34
+ */
35
+ export function useExternalProfileChanges({
36
+ enabled,
37
+ dataDir,
38
+ dispatch,
39
+ stateRef,
40
+ pluginRegistry,
41
+ tickerRepository,
42
+ lookEveryMs = TICKER_ROWS_LOOK_MS,
43
+ }: {
44
+ enabled: boolean;
45
+ dataDir: string;
46
+ dispatch: Dispatch<AppAction>;
47
+ stateRef: { current: AppState };
48
+ pluginRegistry: Pick<PluginRegistry, "events">;
49
+ tickerRepository: TickerRowsPort;
50
+ /** How often the ticker rows are looked at; tests look sooner. */
51
+ lookEveryMs?: number;
52
+ }): void {
53
+ useEffect(() => {
54
+ if (!enabled) return;
55
+ return watchExternalConfigChanges(dataDir, (change) => {
56
+ const current = stateRef.current.config;
57
+ const next = change.apply(current);
58
+ if (next === current) return;
59
+ dispatch({ type: "SET_CONFIG", config: next });
60
+ pluginRegistry.events.emit("config:changed", { config: next });
61
+ });
62
+ }, [dataDir, dispatch, enabled, pluginRegistry, stateRef]);
63
+
64
+ useEffect(() => {
65
+ const changesElsewhere = tickerRepository.changesElsewhere?.bind(tickerRepository);
66
+ const takeDeleted = tickerRepository.takeRowsDeletedElsewhere?.bind(tickerRepository);
67
+ if (!enabled || !changesElsewhere) return;
68
+ let stopped = false;
69
+ // The database's version and its rows as last read. Without the repository's own account of the rows deleted
70
+ // elsewhere, a row gone from the last read's is one; the app's own commits move no version, so that misses a
71
+ // row the app added since.
72
+ let taken: number | null = null;
73
+ let stored: Set<string> | null = null;
74
+ let reading = false;
75
+ const look = async () => {
76
+ reading = true;
77
+ try {
78
+ const version = await changesElsewhere();
79
+ // The app's own writes still on their way would read as someone else's: wait for them.
80
+ if (stopped || version === null || (stored && version === taken) || hasPendingTickerWrites(tickerRepository)) return;
81
+ const rows = await tickerRepository.loadAllTickers();
82
+ const present = new Set(rows.map((row) => row.metadata.ticker));
83
+ const deleted = takeDeleted ? await takeDeleted() : [...stored ?? []].filter((symbol) => !present.has(symbol));
84
+ if (stopped) return;
85
+ // The first look is the rows as the app starts with them; only rows deleted since are taken in then.
86
+ takeStoredTickerRows(stored ? rows : [], deleted, tickerRepository, stateRef, dispatch);
87
+ stored = present;
88
+ taken = version;
89
+ } finally {
90
+ reading = false;
91
+ }
92
+ };
93
+ const lookNow = () => {
94
+ if (!reading) look().catch(logFailure("app.external-profile-changes", "Reading ticker rows another program wrote failed"));
95
+ };
96
+ lookNow();
97
+ const timer = setInterval(lookNow, lookEveryMs);
98
+ (timer as { unref?: () => void }).unref?.();
99
+ return () => {
100
+ stopped = true;
101
+ clearInterval(timer);
102
+ };
103
+ }, [dispatch, enabled, lookEveryMs, stateRef, tickerRepository]);
104
+ }
105
+
106
+ /**
107
+ * Replaces the app's copy of each row the database holds differently, and
108
+ * drops each row another program deleted (`deleted`), so no later save of
109
+ * the app's copy brings it back. Rows only the app holds stay, and so does
110
+ * one the app is saving: its save folds the other program's change in.
111
+ */
112
+ function takeStoredTickerRows(
113
+ rows: readonly TickerRecord[],
114
+ deleted: readonly string[],
115
+ tickerRepository: AppTickerRepositoryPort,
116
+ stateRef: { current: AppState },
117
+ dispatch: Dispatch<AppAction>,
118
+ ): void {
119
+ const current = stateRef.current.tickers;
120
+ let next: Map<string, TickerRecord> | null = null;
121
+ for (const row of rows) {
122
+ const symbol = row.metadata.ticker;
123
+ if (hasPendingTickerWrite(tickerRepository, symbol)) continue;
124
+ const held = current.get(symbol);
125
+ if (held && serializeJson(held.metadata) === serializeJson(row.metadata)) continue;
126
+ next ??= new Map(current);
127
+ next.set(symbol, row);
128
+ }
129
+ for (const symbol of deleted) {
130
+ if (!current.has(symbol)) continue;
131
+ next ??= new Map(current);
132
+ next.delete(symbol);
133
+ }
134
+ if (next) dispatch({ type: "SET_TICKERS", tickers: next });
135
+ }
package/src/app.tsx CHANGED
@@ -20,6 +20,8 @@ import { DetachedPaneShell } from "./components/layout/detached-pane-shell";
20
20
  import { TransientLayoutProvider } from "./components/layout/transient-layout";
21
21
  import { CommandBar } from "./components/command-bar/surface";
22
22
  import { OnboardingWizard } from "./components/onboarding/onboarding-wizard";
23
+ import { getOnboardingProgress } from "./components/onboarding/wizard-model";
24
+ import { HeardFromQuestionHost } from "./account/heard-from-question";
23
25
  import { useRunSetupAgain } from "./components/onboarding/run-setup-again";
24
26
  import { CompanyPickerHost } from "./plugins/builtin/cloud/company-picker";
25
27
  import { TerminalRelayHost } from "./plugins/builtin/cloud/terminal-relay/host";
@@ -50,6 +52,7 @@ import { AppDialogBridge } from "./app/dialog-bridge";
50
52
  import { KeybindingsProvider, useResolvedKeybindings } from "./app/keybindings";
51
53
  import { useAppPaneRuntime } from "./app/pane-runtime";
52
54
  import { bindPluginRegistryRuntimeAccess } from "./app/runtime/plugin-bindings";
55
+ import { useExternalProfileChanges } from "./app/runtime/external-profile-changes";
53
56
  import { useAppStartupRuntime } from "./app/runtime/startup";
54
57
  import { useTickerRefreshRuntime } from "./app/runtime/ticker-refresh";
55
58
  import { useAppUpdateRuntime } from "./app/runtime/update";
@@ -79,6 +82,8 @@ import { reportTelemetryConfig } from "./telemetry/live-config";
79
82
  import { AttentionCountsNotice } from "./app/attention-notice";
80
83
  import { useSinceLastVisit } from "./app/since-last-visit/use-since-last-visit";
81
84
  import { SinceLastVisitStrip } from "./app/since-last-visit/strip";
85
+ import { useProWelcome } from "./app/pro-welcome/use-pro-welcome";
86
+ import { ProWelcomeRow } from "./app/pro-welcome/row";
82
87
  import { recordFunctionOpen } from "./telemetry/usage-counts";
83
88
  import { logFailure } from "./utils/log-failure";
84
89
 
@@ -228,6 +233,10 @@ function AppInner({
228
233
  const appWideWorkElsewhere = isDetachedWindow || desktopWindowBridge?.primary === false;
229
234
  // Not while setup is already showing.
230
235
  const runSetupAgain = useRunSetupAgain(onboardingActive ? undefined : onRunSetupAgain);
236
+ // A setup card holds the keyboard over the whole window; the workspace coach
237
+ // after the cards floats over a live workspace, whose "Ctrl+P adds more"
238
+ // needs the command bar's prompt (and Help) where they always are.
239
+ const setupCardShown = onboardingActive && getOnboardingProgress(config).stage !== "research";
231
240
  const detachedPaneId = isDetachedWindow ? desktopWindowBridge.paneId ?? null : null;
232
241
  const focusDetachedPane = useMemo(() => {
233
242
  const focus = desktopWindowBridge?.kind === "main" ? desktopWindowBridge.focusDetachedPane : undefined;
@@ -423,6 +432,16 @@ function AppInner({
423
432
  scheduleConfigSave(nextConfig);
424
433
  }, []);
425
434
  useTeamCollectionsSync({ persistConfig, tickerRepository });
435
+ // A `gloom` command run beside the app writes the same profile: take its
436
+ // changes in, so none is written over. A popped-out window leaves that to the main one.
437
+ useExternalProfileChanges({
438
+ enabled: !appWideWorkElsewhere,
439
+ dataDir: config.dataDir,
440
+ dispatch,
441
+ stateRef,
442
+ pluginRegistry,
443
+ tickerRepository,
444
+ });
426
445
 
427
446
  useAppPaneRuntime({
428
447
  dataProvider,
@@ -498,6 +517,15 @@ function AppInner({
498
517
  notify: notifyRequest,
499
518
  });
500
519
  const showSinceLastVisit = !!sinceLastVisit.recap && state.config.presentationMode !== true;
520
+ // A new Pro payer's first two weeks: Pro functions they have not opened, on
521
+ // their own tickers. Its own row under the strip, never part of it.
522
+ const proWelcome = useProWelcome({
523
+ active: !appWideWorkElsewhere && !onboardingActive && !signInGateActive,
524
+ pluginState: pluginRegistry.persistence.pluginState,
525
+ pluginRegistry,
526
+ pluginsReady,
527
+ });
528
+ const showProWelcome = !!proWelcome.chips && state.config.presentationMode !== true;
501
529
 
502
530
  const chrome = useAppChromeShown();
503
531
  const keybindingHost = useUiHost().kind === "opentui" ? "terminal" : "desktop";
@@ -553,7 +581,8 @@ function AppInner({
553
581
  <ThemedAppRoot>
554
582
  {chrome.header && (
555
583
  <Header
556
- onOpenHelp={() => {
584
+ commandInputAvailable={!setupCardShown}
585
+ onOpenHelp={setupCardShown ? undefined : () => {
557
586
  recordFunctionOpen({ shortcut: "HELP", externalPluginId: null });
558
587
  pluginRegistry.showPane("help");
559
588
  }}
@@ -561,6 +590,7 @@ function AppInner({
561
590
  />
562
591
  )}
563
592
  {showSinceLastVisit ? <SinceLastVisitStrip strip={sinceLastVisit} /> : null}
593
+ {showProWelcome ? <ProWelcomeRow welcome={proWelcome} /> : null}
564
594
  <TransientLayoutProvider>
565
595
  <Shell
566
596
  pluginRegistry={pluginRegistry}
@@ -569,12 +599,13 @@ function AppInner({
569
599
  desktopWindowBridge={desktopWindowBridge}
570
600
  desktopDockPreview={desktopDockPreview}
571
601
  commandBarNativeOccluder={commandBarNativeOccluder}
572
- topBandRows={showSinceLastVisit ? 1 : 0}
602
+ topBandRows={(showSinceLastVisit ? 1 : 0) + (showProWelcome ? 1 : 0)}
573
603
  />
574
604
  <StatusBar />
575
605
  </TransientLayoutProvider>
576
606
  {!onboardingActive ? <CompanyPickerHost pluginRegistry={pluginRegistry} /> : null}
577
607
  {initialized && !onboardingActive && !signInGateActive ? <AttentionCountsNotice notify={notifyRequest} /> : null}
608
+ {initialized && !onboardingActive && !signInGateActive ? <HeardFromQuestionHost /> : null}
578
609
  <TerminalRelayHost device={remoteControlAdapter?.terminalDevice} />
579
610
  {onboardingActive && onOnboardingComplete ? (
580
611
  <OnboardingWizard
@@ -29,7 +29,7 @@
29
29
  "src/layout/desks.ts": ["chart-composer"],
30
30
  "src/plugins/catalog-browser.ts": ["alerts","analytics","attention","awards","backtest","bond-calculator","catalysts","cds","central-bank-rates","changelog","chart-composer","clinical-trials","cloud","comment-letters","commodities-energy","commodity-balances","company-attention","company-kpis","connections","correlation","cot","cpi","credit-boards","credit-conditions","credit-documents","crypto-board","crypto-etf-flows","debt-maturities","dividend-yield","docs","doe","earnings","earnings-calls","earnings-ripple","econ","econ-statistics","equity-screener","estimate-revisions","executives","exposure","fear-greed","filing-events","fixed-income","futures","futures-curve","fx-matrix","gpu","help","holders","insider","ipo-calendar","iv-history","jobs","jodi","kelly-sizer","layout-manager","macro-day","market-halts","market-heatmap","market-valuation","members","mna","money-markets","news","openfda","options","options-calculator","options-positioning","options-scenario","pe-band","perps","portfolio-list","power","primary-dealers","rate-path","realized-vol","relative-rotation","research","research-search","revenue-breakdown","reverse-dcf","risk-factors","roadmap","scanner","seasonality","sec","sectors","short-interest","short-volume","social-mentions","supply-chain","thirteenf","ticker-detail","time-sales","trace-bonds","treasury-auctions","treasury-daily","vol-surface","volatility","world-indices","world-venue-map","yield-curve"],
31
31
  "src/plugins/catalog-cli.ts": ["alerts","fear-greed","news","notes","portfolio-list"],
32
- "src/plugins/catalog-ui.ts": ["alerts","clinical-trials","cloud","comment-letters","custom-view","fear-greed","ipo-calendar","market-halts","market-heatmap","members","news","notes","openfda","research-search"],
32
+ "src/plugins/catalog-ui.ts": ["alerts","clinical-trials","cloud","comment-letters","composite","custom-view","fear-greed","ipo-calendar","market-halts","market-heatmap","members","news","notes","openfda","research-search"],
33
33
  "src/plugins/catalog.ts": ["debug"],
34
34
  "src/remote/controller.ts": ["custom-view"],
35
35
  "src/renderers/electrobun/bun/core-capabilities.ts": ["notes"],
@@ -64,7 +64,6 @@
64
64
  "src/components/ui/multi-select/dialog.tsx": ["void:toggleOption()"],
65
65
  "src/components/ui/query-bar-keys.tsx": ["void:choose()","void:choose()","void:dialog.alert()"],
66
66
  "src/components/use-external-link-footer.ts": ["void:rendererHost.openExternal()"],
67
- "src/data/config/store/node.ts": ["void:settled.then()"],
68
67
  "src/data/ticker-writes.ts": ["void:Promise.allSettled().then()"],
69
68
  "src/layout-marketplace/linked-sync.ts": ["void:check()","void:check()","void:check()"],
70
69
  "src/market-data/coordinator/index.ts": ["void:this.reloadTogether()","void:this.reloadTogether()"],
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "src/cli/commands/keybindings.ts": "CLI errors for `config set keybindings`: example chords in the config grammar the user types.",
3
3
  "src/cli/commands/system.ts": "CLI help: example `config set keybindings` commands, written in the config grammar.",
4
+ "src/cli/known-gaps.ts": "What `gloom catalog FB` prints for the app's Send Feedback: it sends the reader to the terminal app (`gloom`), where Ctrl+P opens the command bar.",
4
5
  "src/cli/pane-functions/dom.ts": "What `gloom fn` prints for a pane behind the sign-in wall: it sends the reader to the terminal app (`gloom`), where Ctrl+P opens the command bar.",
5
6
  "src/plugins/builtin/alerts/cli.ts": "`gloom alerts` output, which sends the reader to the terminal app (`gloom`), where Ctrl+P opens the command bar.",
6
7
  "src/plugins/builtin/alerts/event-rows.ts": "needsSignInNote is printed by `gloom alerts` and the headless read only: it names the terminal app's Ctrl+P.",
@@ -0,0 +1,98 @@
1
+ import { liveCompanyQuestion } from "./company-name-hint";
2
+ import { movedSymbolLine, parseListingArg, type ListingDeps } from "./listing-arg";
3
+ import { requireQuotedListing, type QuotedListing } from "./quote-answer";
4
+ import {
5
+ bareListingNote,
6
+ describeListingFate,
7
+ listingChangeLine,
8
+ loadListingFate,
9
+ noLongerTradingNote,
10
+ SUCCESSOR_CHANGE_WAIT_MS,
11
+ } from "../tickers/listing-fate";
12
+ import { startTickerChangeLookup } from "../tickers/ticker-changes";
13
+ import { logFailure } from "../utils/log-failure";
14
+
15
+ /**
16
+ * Why an alert was refused for what was typed, with what to type instead as
17
+ * `details`. `reason` says it without the refusal, for a form that checks
18
+ * the symbol before anything is added.
19
+ */
20
+ export class AlertListingRefusal extends Error {
21
+ readonly reason: string;
22
+
23
+ constructor(message: string, readonly details?: string, reason?: string) {
24
+ super(message);
25
+ this.name = "AlertListingRefusal";
26
+ this.reason = reason ?? message;
27
+ }
28
+ }
29
+
30
+ export interface AlertListingOptions {
31
+ /** The command that adds the alert on another symbol (`gloom alerts add XYZ above 80`); none in the app. */
32
+ retry?: (symbol: string) => string | null;
33
+ now?: number;
34
+ }
35
+
36
+ /**
37
+ * The listing an alert follows, read as `quote` reads the symbol: the same
38
+ * resolver (a company's name such as "Singtel" is Z74:SGX), and what `quote`
39
+ * says of what became of it. Every place an alert is added goes through here:
40
+ * `gloom alerts add`, ALRT's Add Alert and SA.
41
+ *
42
+ * - A listing that no longer trades is refused, since nothing would ever
43
+ * check it: DBS, the silver fund delisted in 2023, asks after D05:SGX (DBS
44
+ * Group Holdings); SQ, which last traded before Block became XYZ, names XYZ.
45
+ * - A symbol its company left for another that something new trades under is
46
+ * kept, saying so: FB is a fund now, and Meta trades as META.
47
+ *
48
+ * Throws `AlertListingRefusal` with why.
49
+ */
50
+ export interface AlertListing extends QuotedListing {
51
+ /** What became of the symbol, also among `notes`: FB's line, saying Meta trades as META. */
52
+ fate: string[];
53
+ }
54
+
55
+ export async function resolveAlertListing(
56
+ typed: string,
57
+ exchange: string | null | undefined,
58
+ deps: ListingDeps,
59
+ options: AlertListingOptions = {},
60
+ ): Promise<AlertListing> {
61
+ const fail = (message: string, details?: string): never => {
62
+ throw new AlertListingRefusal(message, details);
63
+ };
64
+ const quoted = await requireQuotedListing(typed, exchange, deps, { fail }, "alerts add");
65
+ // What became of the symbol is a note beside the alert; a lookup that fails leaves the alert as `quote` reads it.
66
+ const fate = await alertListingNotes(quoted, typed, exchange, deps, options).catch((error: unknown) => {
67
+ if (error instanceof AlertListingRefusal) throw error;
68
+ return logFailure("cli.alert-listing", "Read what became of an alert's symbol failed", [] as string[])(error);
69
+ });
70
+ return { ...quoted, notes: [...quoted.notes, ...fate], fate };
71
+ }
72
+
73
+ async function alertListingNotes(
74
+ { listing, quote }: QuotedListing,
75
+ typed: string,
76
+ exchange: string | null | undefined,
77
+ deps: ListingDeps,
78
+ { retry, now = Date.now() }: AlertListingOptions,
79
+ ): Promise<string[]> {
80
+ // A bare symbol read on a listing abroad (Z74 -> SGX) is not the US symbol the changes are of.
81
+ const fate = bareListingNote(listing, quote)
82
+ ? describeListingFate(listing, quote, null, now)
83
+ : await loadListingFate(listing, deps.dataProvider, {
84
+ quote,
85
+ changes: startTickerChangeLookup(deps.dataProvider, listing.symbol, listing.exchange),
86
+ graceMs: SUCCESSOR_CHANGE_WAIT_MS,
87
+ });
88
+ const stopped = noLongerTradingNote(`${listing.symbol}${quote.name ? ` (${quote.name})` : ""}`, quote, now);
89
+ if (stopped) {
90
+ const named = !!parseListingArg(typed, exchange).exchange;
91
+ const pointer = fate.moved
92
+ ? movedSymbolLine(fate.moved, retry?.(fate.moved.tradesAs) ?? null)
93
+ : named ? null : await liveCompanyQuestion(typed, deps, now);
94
+ throw new AlertListingRefusal(`${stopped}, so no alert was added.`, pointer ?? undefined, `${stopped}.`);
95
+ }
96
+ const changed = listingChangeLine(fate);
97
+ return changed ? [changed] : [];
98
+ }
@@ -119,9 +119,11 @@ export function basisPointsCell(value: unknown): string {
119
119
  * reading the source has put out.
120
120
  */
121
121
  const LAGGING_SERIES: Readonly<Record<string, string>> = {
122
- UMCSENT: "FRED publishes the University of Michigan survey with a lag; latest preliminary reading: fn ECO",
122
+ UMCSENT: "University of Michigan sentiment is delayed one month on FRED at the publisher's request; newer preliminary readings are in fn ECO.",
123
123
  };
124
124
 
125
+ export const FRED_VINTAGE_NOTE = "Release dates are the first numeric ALFRED vintage available; archive coverage can begin after an older figure's original publication. Missing release provenance stays blank. The as_of field dates the current value's revision when available, not its first release.";
126
+
125
127
  export function laggingSeriesNote(seriesId: string): string | null {
126
128
  return LAGGING_SERIES[seriesId.toUpperCase()] ?? null;
127
129
  }