@gloom-sh/terminal 0.20.17 → 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 (304) 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 +3 -2
  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/app/global-shortcuts.ts +5 -3
  13. package/src/app/pro-welcome/keys.ts +27 -0
  14. package/src/app/pro-welcome/model.ts +158 -0
  15. package/src/app/pro-welcome/row.tsx +176 -0
  16. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  17. package/src/app/runtime/external-profile-changes.ts +135 -0
  18. package/src/app.tsx +33 -2
  19. package/src/architecture/core-builtin-allowlist.json +1 -1
  20. package/src/architecture/floating-promise-allowlist.json +0 -1
  21. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  22. package/src/cli/alert-listing.ts +98 -0
  23. package/src/cli/commands/market.ts +138 -22
  24. package/src/cli/commands/overview.ts +7 -1
  25. package/src/cli/commands/plugins.ts +3 -2
  26. package/src/cli/commands/search.ts +30 -6
  27. package/src/cli/context.ts +16 -5
  28. package/src/cli/csv-export.ts +2 -1
  29. package/src/cli/desktop-pane-shot.ts +72 -9
  30. package/src/cli/glossary.ts +64 -10
  31. package/src/cli/history-demergers.ts +117 -0
  32. package/src/cli/history-rows.ts +6 -2
  33. package/src/cli/index.ts +1 -0
  34. package/src/cli/known-gaps.ts +16 -0
  35. package/src/cli/known-us-stocks.ts +18 -0
  36. package/src/cli/listing-arg.ts +105 -15
  37. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  38. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  39. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  40. package/src/cli/pane-functions/catalog.ts +50 -16
  41. package/src/cli/pane-functions/data.ts +16 -4
  42. package/src/cli/pane-functions/dom.ts +24 -6
  43. package/src/cli/pane-functions/freshness.ts +17 -1
  44. package/src/cli/pane-functions/index.ts +100 -42
  45. package/src/cli/pane-functions/resolver.ts +8 -5
  46. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  47. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  48. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  49. package/src/cli/quote-answer.ts +32 -16
  50. package/src/cli/registry.ts +22 -2
  51. package/src/cli/result.ts +5 -4
  52. package/src/cli/series-search.ts +45 -6
  53. package/src/cli/shot-temp-dir.ts +4 -9
  54. package/src/components/chart/composite/legend.tsx +43 -18
  55. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  56. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  57. package/src/components/chart-table/header.tsx +9 -0
  58. package/src/components/chart-table/layout.ts +11 -11
  59. package/src/components/command-bar/pane-templates/items.ts +17 -1
  60. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  61. package/src/components/command-bar/routes/root/results.ts +34 -2
  62. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  63. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  64. package/src/components/command-bar/workflow/alert.ts +19 -8
  65. package/src/components/data-table/view.tsx +15 -2
  66. package/src/components/form-modal/content.tsx +9 -4
  67. package/src/components/index.ts +1 -1
  68. package/src/components/layout/header.tsx +9 -5
  69. package/src/components/layout/pane/capture-status.ts +6 -0
  70. package/src/components/layout/pane/footer/index.tsx +2 -0
  71. package/src/components/layout/pane/footer/model.ts +113 -15
  72. package/src/components/layout/pane/header.tsx +16 -2
  73. package/src/components/market-board/index.tsx +4 -2
  74. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  75. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  76. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  77. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  78. package/src/components/onboarding/setup-cards.ts +36 -0
  79. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  80. package/src/components/onboarding/wizard-account.ts +6 -1
  81. package/src/components/onboarding/wizard-model.ts +32 -6
  82. package/src/components/onboarding/wizard-positions.ts +1 -1
  83. package/src/components/sign-in-gate.tsx +3 -1
  84. package/src/components/toggle-list.tsx +6 -8
  85. package/src/components/ui/confirm-dialog.tsx +47 -7
  86. package/src/components/ui/data-table/types.ts +8 -0
  87. package/src/components/ui/display.tsx +17 -2
  88. package/src/components/ui/index.ts +1 -1
  89. package/src/components/ui/stat-grid.tsx +4 -0
  90. package/src/components/ui/status.tsx +13 -1
  91. package/src/components/ui/table-layout.ts +2 -1
  92. package/src/components/use-pane-notice-footer.tsx +16 -3
  93. package/src/data/config/store/index.ts +31 -0
  94. package/src/data/config/store/node.ts +61 -11
  95. package/src/data/config/store/normalize.ts +4 -6
  96. package/src/data/config/store/shared-file.ts +309 -0
  97. package/src/data/profile-merge.ts +299 -0
  98. package/src/data/sqlite/checkpointer.ts +11 -1
  99. package/src/data/sqlite/database.ts +1 -1
  100. package/src/data/ticker-repository.ts +134 -10
  101. package/src/data/ticker-store.ts +67 -0
  102. package/src/data/ticker-writes.ts +5 -0
  103. package/src/i18n/es.ts +27 -0
  104. package/src/i18n/ja.ts +27 -0
  105. package/src/i18n/ko.ts +27 -0
  106. package/src/i18n/zh-cn.ts +27 -0
  107. package/src/i18n/zh-tw.ts +27 -0
  108. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  109. package/src/market-data/ah-pair.ts +103 -0
  110. package/src/market-data/depositary-pair.ts +6 -2
  111. package/src/market-data/hooks.tsx +33 -2
  112. package/src/market-data/market/change-basis.ts +2 -1
  113. package/src/market-data/market/header-market.ts +11 -0
  114. package/src/market-data/split-terms.ts +28 -0
  115. package/src/plugins/builtin/account-management/footer.ts +1 -1
  116. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  117. package/src/plugins/builtin/account-management/model.ts +1 -0
  118. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  119. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  120. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  121. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  122. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  123. package/src/plugins/builtin/alerts/cli.ts +36 -30
  124. package/src/plugins/builtin/alerts/constants.ts +10 -0
  125. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  126. package/src/plugins/builtin/alerts/format.ts +24 -8
  127. package/src/plugins/builtin/alerts/index.tsx +38 -9
  128. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  129. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  130. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  131. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  132. package/src/plugins/builtin/alerts/types.ts +7 -0
  133. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  134. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  135. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  136. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  137. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  139. package/src/plugins/builtin/awards/pane.tsx +1 -1
  140. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  141. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  142. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  143. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  144. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  145. package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
  146. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  147. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  148. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  149. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  150. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  151. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  152. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  153. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  154. package/src/plugins/builtin/composite/application.ts +14 -0
  155. package/src/plugins/builtin/composite/broker.ts +12 -0
  156. package/src/plugins/builtin/composite/credit.ts +33 -0
  157. package/src/plugins/builtin/composite/crypto.ts +10 -0
  158. package/src/plugins/builtin/composite/earnings.ts +12 -0
  159. package/src/plugins/builtin/composite/filings.ts +13 -0
  160. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  161. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  162. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  163. package/src/plugins/builtin/composite/ownership.ts +23 -0
  164. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  165. package/src/plugins/builtin/composite/quant.ts +15 -0
  166. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  167. package/src/plugins/builtin/composite/screeners.ts +11 -0
  168. package/src/plugins/builtin/composite/shared.ts +11 -0
  169. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  170. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  171. package/src/plugins/builtin/correlation/index.tsx +13 -17
  172. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  173. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  174. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  175. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  176. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  177. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  178. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  179. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  180. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  181. package/src/plugins/builtin/earnings/headless.ts +7 -4
  182. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  183. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  184. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  185. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  186. package/src/plugins/builtin/econ/index.tsx +3 -0
  187. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  188. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  189. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  190. package/src/plugins/builtin/exposure/model.ts +10 -0
  191. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  192. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  193. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  194. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  195. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  196. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  197. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  198. package/src/plugins/builtin/mna/detail.tsx +67 -6
  199. package/src/plugins/builtin/mna/headless.ts +128 -13
  200. package/src/plugins/builtin/mna/model.ts +219 -16
  201. package/src/plugins/builtin/mna/pane.tsx +34 -6
  202. package/src/plugins/builtin/money-markets/model.ts +14 -5
  203. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  204. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  205. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  206. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  207. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  208. package/src/plugins/builtin/pe-band/client.ts +13 -1
  209. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  210. package/src/plugins/builtin/pe-band/model.ts +63 -10
  211. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  212. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  213. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  214. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  215. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  216. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  217. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  218. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  219. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  220. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  221. package/src/plugins/builtin/research/event-model.ts +31 -13
  222. package/src/plugins/builtin/research/headless.ts +8 -1
  223. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  224. package/src/plugins/builtin/sectors/index.tsx +6 -9
  225. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  226. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  227. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  228. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  229. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  230. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  231. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  232. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  233. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  234. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  235. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  236. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  237. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  238. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  239. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  240. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  241. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  242. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  243. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  244. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  245. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  246. package/src/plugins/builtin/volatility/model.ts +17 -0
  247. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  248. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  249. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  250. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  251. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  252. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  253. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  254. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  255. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  256. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  257. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  258. package/src/plugins/catalog-data.ts +20 -0
  259. package/src/plugins/catalog-lazy.ts +51 -0
  260. package/src/plugins/catalog-ui.ts +16 -18
  261. package/src/plugins/host-smoke.ts +5 -2
  262. package/src/portfolio/allocation.ts +79 -19
  263. package/src/portfolio/cash-balances.ts +76 -0
  264. package/src/portfolio/mutations.ts +43 -8
  265. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  266. package/src/renderers/desktop/window-layouts.ts +14 -0
  267. package/src/renderers/dom/data-table/row.tsx +2 -0
  268. package/src/renderers/dom/host/tabs.tsx +57 -8
  269. package/src/renderers/dom/styles.css +13 -5
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  272. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  273. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  274. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  275. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  276. package/src/series/standalone-catalog.ts +5 -4
  277. package/src/series/standalone.ts +13 -7
  278. package/src/sources/gloomberb-cloud/index.ts +14 -3
  279. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  280. package/src/sources/provider-router/financials.ts +20 -13
  281. package/src/sources/provider-router/index.ts +4 -0
  282. package/src/sources/provider-router/search.ts +1 -0
  283. package/src/sync/collections-contributor.ts +3 -1
  284. package/src/sync/config-merge.ts +10 -1
  285. package/src/sync/sanitize.ts +26 -2
  286. package/src/tickers/company-name-listing.ts +16 -2
  287. package/src/tickers/listing-fate.ts +12 -8
  288. package/src/tickers/renamed-listings.ts +43 -10
  289. package/src/tickers/search/home-listing.ts +28 -0
  290. package/src/tickers/search/index.ts +19 -7
  291. package/src/tickers/terminal-codes.ts +11 -1
  292. package/src/time-series/resolve.ts +3 -1
  293. package/src/time-series/spec.ts +2 -2
  294. package/src/time-series/types.ts +1 -1
  295. package/src/types/data-provider.ts +11 -0
  296. package/src/types/financials.ts +39 -3
  297. package/src/types/ticker.ts +10 -2
  298. package/src/utils/cli-output.ts +1 -1
  299. package/src/utils/declared-dividends.ts +13 -1
  300. package/src/utils/dividend-cash.ts +5 -1
  301. package/src/utils/forward-dividend.ts +4 -3
  302. package/src/utils/remove-folder.ts +37 -0
  303. package/src/utils/trailing-dividend.ts +1 -1
  304. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -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
+ }