@gloom-sh/terminal 0.20.17 → 0.20.19

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 (453) 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/cot.ts +5 -6
  7. package/src/api-client/data.ts +14 -3
  8. package/src/api-client/heard-from.ts +72 -0
  9. package/src/api-client/index.ts +64 -6
  10. package/src/api-client/mna.ts +18 -0
  11. package/src/api-client/request.ts +162 -40
  12. package/src/api-client/supply-chain.ts +9 -0
  13. package/src/api-client/types/billing.ts +35 -1
  14. package/src/api-client/types/news.ts +45 -0
  15. package/src/api-client/types/world-venues.ts +9 -0
  16. package/src/app/global-shortcuts.ts +5 -3
  17. package/src/app/pro-welcome/keys.ts +27 -0
  18. package/src/app/pro-welcome/model.ts +158 -0
  19. package/src/app/pro-welcome/row.tsx +176 -0
  20. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  21. package/src/app/runtime/external-profile-changes.ts +135 -0
  22. package/src/app.tsx +37 -4
  23. package/src/architecture/core-builtin-allowlist.json +1 -1
  24. package/src/architecture/floating-promise-allowlist.json +1 -2
  25. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  26. package/src/cli/alert-listing.ts +98 -0
  27. package/src/cli/commands/market.ts +191 -39
  28. package/src/cli/commands/overview.ts +7 -1
  29. package/src/cli/commands/plugins.ts +3 -2
  30. package/src/cli/commands/search.ts +30 -6
  31. package/src/cli/commands/ticker.ts +13 -6
  32. package/src/cli/context.ts +24 -5
  33. package/src/cli/csv-export.ts +2 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  35. package/src/cli/desktop-pane-shot-view.ts +0 -1
  36. package/src/cli/desktop-pane-shot.ts +276 -52
  37. package/src/cli/errors.ts +3 -9
  38. package/src/cli/exit-codes.ts +1 -1
  39. package/src/cli/glossary.ts +65 -11
  40. package/src/cli/help.ts +1 -1
  41. package/src/cli/history-demergers.ts +117 -0
  42. package/src/cli/history-rows.ts +8 -4
  43. package/src/cli/index.ts +2 -1
  44. package/src/cli/known-gaps.ts +16 -0
  45. package/src/cli/known-us-stocks.ts +18 -0
  46. package/src/cli/listing-arg.ts +192 -38
  47. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  48. package/src/cli/pane-functions/catalog-snapshot.json +877 -0
  49. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  50. package/src/cli/pane-functions/catalog.ts +50 -16
  51. package/src/cli/pane-functions/data.ts +16 -4
  52. package/src/cli/pane-functions/dom.ts +54 -8
  53. package/src/cli/pane-functions/freshness.ts +39 -4
  54. package/src/cli/pane-functions/function-help.ts +3 -3
  55. package/src/cli/pane-functions/headless.ts +9 -1
  56. package/src/cli/pane-functions/index.ts +175 -50
  57. package/src/cli/pane-functions/report-notices.ts +10 -0
  58. package/src/cli/pane-functions/resolver.ts +11 -7
  59. package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
  60. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  61. package/src/cli/pane-functions/screenshot-payload.ts +36 -1
  62. package/src/cli/pane-functions/screenshot-render.ts +24 -9
  63. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  64. package/src/cli/quote-answer.ts +33 -17
  65. package/src/cli/registry.ts +22 -2
  66. package/src/cli/result.ts +22 -4
  67. package/src/cli/scroll-truncation.ts +7 -2
  68. package/src/cli/series-search.ts +45 -6
  69. package/src/cli/shot-temp-dir.ts +4 -9
  70. package/src/cli/ticker-resolution.ts +1 -1
  71. package/src/cli/unreachable.ts +21 -0
  72. package/src/components/chart/composite/drawing-store.ts +11 -7
  73. package/src/components/chart/composite/format.ts +1 -0
  74. package/src/components/chart/composite/legend.tsx +48 -20
  75. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  76. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  77. package/src/components/chart/composite/panel-surface.tsx +1 -1
  78. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  79. package/src/components/chart/composite/tools.ts +164 -39
  80. package/src/components/chart-table/header.tsx +11 -2
  81. package/src/components/chart-table/layout.ts +16 -17
  82. package/src/components/command-bar/pane-templates/items.ts +17 -1
  83. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  84. package/src/components/command-bar/routes/root/results.ts +34 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +19 -4
  86. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  87. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  88. package/src/components/command-bar/selection-runtime.ts +29 -5
  89. package/src/components/command-bar/surface/index.tsx +4 -1
  90. package/src/components/command-bar/workflow/alert.ts +32 -13
  91. package/src/components/data-table/view.tsx +15 -2
  92. package/src/components/form-modal/content.tsx +9 -4
  93. package/src/components/index.ts +1 -1
  94. package/src/components/layout/header.tsx +9 -5
  95. package/src/components/layout/pane/capture-status.ts +6 -0
  96. package/src/components/layout/pane/footer/index.tsx +2 -0
  97. package/src/components/layout/pane/footer/model.ts +123 -17
  98. package/src/components/layout/pane/header.tsx +16 -2
  99. package/src/components/layout/pane/status-footer.ts +24 -0
  100. package/src/components/market-board/index.tsx +4 -2
  101. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  102. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  103. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  104. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  105. package/src/components/onboarding/setup-cards.ts +36 -0
  106. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  107. package/src/components/onboarding/wizard-account.ts +6 -1
  108. package/src/components/onboarding/wizard-model.ts +32 -6
  109. package/src/components/onboarding/wizard-positions.ts +1 -1
  110. package/src/components/price-performance.tsx +26 -8
  111. package/src/components/reader/article-reader.tsx +12 -5
  112. package/src/components/sign-in-gate.tsx +3 -1
  113. package/src/components/toggle-list.tsx +6 -8
  114. package/src/components/ui/confirm-dialog.tsx +47 -7
  115. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  116. package/src/components/ui/data-table/types.ts +8 -0
  117. package/src/components/ui/display.tsx +17 -2
  118. package/src/components/ui/index.ts +1 -1
  119. package/src/components/ui/stat-grid.tsx +4 -0
  120. package/src/components/ui/status.tsx +13 -1
  121. package/src/components/ui/table-layout.ts +34 -2
  122. package/src/components/use-pane-notice-footer.tsx +16 -3
  123. package/src/data/config/store/index.ts +31 -0
  124. package/src/data/config/store/node.ts +61 -11
  125. package/src/data/config/store/normalize.ts +4 -6
  126. package/src/data/config/store/shared-file.ts +309 -0
  127. package/src/data/profile-merge.ts +299 -0
  128. package/src/data/sqlite/checkpointer.ts +11 -1
  129. package/src/data/sqlite/database.ts +1 -1
  130. package/src/data/ticker-repository.ts +134 -10
  131. package/src/data/ticker-store.ts +67 -0
  132. package/src/data/ticker-writes.ts +5 -0
  133. package/src/i18n/es.ts +27 -0
  134. package/src/i18n/ja.ts +27 -0
  135. package/src/i18n/ko.ts +27 -0
  136. package/src/i18n/zh-cn.ts +27 -0
  137. package/src/i18n/zh-tw.ts +27 -0
  138. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  139. package/src/market-data/ah-pair.ts +122 -0
  140. package/src/market-data/coordinator/entries.ts +6 -4
  141. package/src/market-data/coordinator/index.ts +14 -3
  142. package/src/market-data/depositary-pair.ts +6 -2
  143. package/src/market-data/futures-board.ts +36 -29
  144. package/src/market-data/futures-contract.ts +37 -1
  145. package/src/market-data/hooks.tsx +33 -2
  146. package/src/market-data/market/change-basis.ts +11 -1
  147. package/src/market-data/market/header-market.ts +11 -0
  148. package/src/market-data/market/status.ts +40 -4
  149. package/src/market-data/performance.ts +127 -32
  150. package/src/market-data/quotes/time.ts +5 -2
  151. package/src/market-data/split-terms.ts +28 -0
  152. package/src/news/types.ts +28 -0
  153. package/src/notifications/app-badge.ts +2 -3
  154. package/src/notifications/app-notifier.ts +5 -0
  155. package/src/plugins/builtin/account-management/footer.ts +1 -1
  156. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  157. package/src/plugins/builtin/account-management/model.ts +1 -0
  158. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  159. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  160. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  161. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  162. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  163. package/src/plugins/builtin/alerts/cli.ts +101 -48
  164. package/src/plugins/builtin/alerts/command.ts +39 -9
  165. package/src/plugins/builtin/alerts/constants.ts +10 -0
  166. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  167. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  168. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  169. package/src/plugins/builtin/alerts/format.ts +24 -8
  170. package/src/plugins/builtin/alerts/headless.ts +12 -6
  171. package/src/plugins/builtin/alerts/index.tsx +97 -16
  172. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  173. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  174. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  175. package/src/plugins/builtin/alerts/price.ts +30 -5
  176. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  177. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  178. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  179. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  180. package/src/plugins/builtin/alerts/types.ts +7 -0
  181. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  182. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  183. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  184. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  185. package/src/plugins/builtin/analytics/risk-client.ts +27 -14
  186. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  187. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  188. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  189. package/src/plugins/builtin/awards/pane.tsx +1 -1
  190. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  191. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  192. package/src/plugins/builtin/catalysts/model.ts +2 -1
  193. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  194. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  195. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  196. package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
  197. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  198. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  199. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  200. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  201. package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
  202. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  203. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  204. package/src/plugins/builtin/chat/index.tsx +0 -1
  205. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  206. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  207. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  208. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  209. package/src/plugins/builtin/company-kpis/headless.ts +10 -5
  210. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  211. package/src/plugins/builtin/company-kpis/model.ts +57 -15
  212. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  213. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  214. package/src/plugins/builtin/composite/application.ts +14 -0
  215. package/src/plugins/builtin/composite/broker.ts +12 -0
  216. package/src/plugins/builtin/composite/credit.ts +33 -0
  217. package/src/plugins/builtin/composite/crypto.ts +10 -0
  218. package/src/plugins/builtin/composite/earnings.ts +12 -0
  219. package/src/plugins/builtin/composite/filings.ts +13 -0
  220. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  221. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  222. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  223. package/src/plugins/builtin/composite/ownership.ts +23 -0
  224. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  225. package/src/plugins/builtin/composite/quant.ts +15 -0
  226. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  227. package/src/plugins/builtin/composite/screeners.ts +11 -0
  228. package/src/plugins/builtin/composite/shared.ts +11 -0
  229. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  230. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  231. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  232. package/src/plugins/builtin/correlation/index.tsx +13 -17
  233. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  234. package/src/plugins/builtin/cot/client.ts +2 -3
  235. package/src/plugins/builtin/cot/headless.ts +16 -16
  236. package/src/plugins/builtin/cot/index.tsx +6 -6
  237. package/src/plugins/builtin/cot/model.ts +25 -5
  238. package/src/plugins/builtin/cot/pane.tsx +11 -6
  239. package/src/plugins/builtin/cot/series.ts +11 -8
  240. package/src/plugins/builtin/cpi/model.ts +15 -4
  241. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  242. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  243. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  244. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  245. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  246. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  247. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  248. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  249. package/src/plugins/builtin/doe/model.ts +30 -0
  250. package/src/plugins/builtin/doe/pane.tsx +8 -2
  251. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  252. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  253. package/src/plugins/builtin/earnings/headless.ts +16 -6
  254. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  255. package/src/plugins/builtin/earnings/history-table.ts +7 -4
  256. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  257. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  258. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  259. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  260. package/src/plugins/builtin/econ/index.tsx +7 -2
  261. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  262. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  263. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  264. package/src/plugins/builtin/exposure/model.ts +10 -0
  265. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  266. package/src/plugins/builtin/futures/model.ts +14 -1
  267. package/src/plugins/builtin/futures/series.ts +1 -8
  268. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  269. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  270. package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
  271. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  272. package/src/plugins/builtin/insider/detail.tsx +36 -7
  273. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  274. package/src/plugins/builtin/insider/headless.ts +37 -2
  275. package/src/plugins/builtin/insider/index.tsx +79 -10
  276. package/src/plugins/builtin/insider/model.ts +43 -5
  277. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  278. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  279. package/src/plugins/builtin/jobs/headless.ts +2 -1
  280. package/src/plugins/builtin/jobs/model.ts +6 -0
  281. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  282. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  283. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  284. package/src/plugins/builtin/mna/detail.tsx +67 -6
  285. package/src/plugins/builtin/mna/headless.ts +128 -13
  286. package/src/plugins/builtin/mna/model.ts +219 -16
  287. package/src/plugins/builtin/mna/pane.tsx +34 -6
  288. package/src/plugins/builtin/money-markets/model.ts +14 -5
  289. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  290. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  291. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  292. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  293. package/src/plugins/builtin/options/analytics.ts +1 -1
  294. package/src/plugins/builtin/options/view.tsx +18 -11
  295. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  296. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  297. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  298. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  299. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  300. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  301. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  302. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  303. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  304. package/src/plugins/builtin/pe-band/client.ts +13 -1
  305. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  306. package/src/plugins/builtin/pe-band/model.ts +63 -10
  307. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  308. package/src/plugins/builtin/perps/cascade.ts +4 -3
  309. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  310. package/src/plugins/builtin/perps/model.ts +4 -3
  311. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  312. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  313. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  314. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  315. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  316. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  317. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  318. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  319. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  320. package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
  321. package/src/plugins/builtin/research/event-model.ts +43 -19
  322. package/src/plugins/builtin/research/headless.ts +8 -1
  323. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  324. package/src/plugins/builtin/research-search/index.tsx +3 -1
  325. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  326. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  327. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  328. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  329. package/src/plugins/builtin/sec/headless.ts +42 -4
  330. package/src/plugins/builtin/sec/index.tsx +21 -1
  331. package/src/plugins/builtin/sectors/index.tsx +6 -9
  332. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  333. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  334. package/src/plugins/builtin/shared/earnings-report.ts +49 -5
  335. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  336. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  337. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  338. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  339. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  340. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  341. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  342. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  343. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  344. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  345. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  346. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  347. package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
  348. package/src/plugins/builtin/themes/headless.ts +4 -4
  349. package/src/plugins/builtin/themes/model.ts +11 -8
  350. package/src/plugins/builtin/themes/pane.tsx +2 -2
  351. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  352. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  353. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  354. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  355. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  356. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  357. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  358. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  359. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  360. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
  361. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
  362. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
  363. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  364. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  365. package/src/plugins/builtin/volatility/model.ts +17 -0
  366. package/src/plugins/builtin/volatility/pane.tsx +16 -7
  367. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  368. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  369. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  370. package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
  371. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  372. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  373. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  374. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  375. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  376. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  377. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  378. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  379. package/src/plugins/catalog-browser.ts +10 -1
  380. package/src/plugins/catalog-data.ts +20 -0
  381. package/src/plugins/catalog-lazy.ts +51 -0
  382. package/src/plugins/catalog-ui.ts +16 -18
  383. package/src/plugins/host-smoke.ts +5 -2
  384. package/src/portfolio/allocation.ts +79 -19
  385. package/src/portfolio/cash-balances.ts +76 -0
  386. package/src/portfolio/mutations.ts +43 -8
  387. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  388. package/src/renderers/browser/activity.ts +16 -0
  389. package/src/renderers/browser/app-badge-host.ts +14 -0
  390. package/src/renderers/browser/main.tsx +5 -0
  391. package/src/renderers/browser/notifications.ts +103 -0
  392. package/src/renderers/browser/ui-host.tsx +4 -0
  393. package/src/renderers/desktop/window-layouts.ts +14 -0
  394. package/src/renderers/dom/data-table/index.tsx +27 -4
  395. package/src/renderers/dom/data-table/row.tsx +2 -0
  396. package/src/renderers/dom/host/tabs.tsx +57 -8
  397. package/src/renderers/dom/styles.css +13 -5
  398. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  399. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  400. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  401. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  402. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  403. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  404. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  405. package/src/series/standalone-catalog.ts +5 -4
  406. package/src/series/standalone.ts +13 -7
  407. package/src/sources/gloomberb-cloud/index.ts +22 -9
  408. package/src/sources/gloomberb-cloud/news.ts +35 -0
  409. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  410. package/src/sources/provider-errors.ts +34 -7
  411. package/src/sources/provider-router/financials.ts +20 -13
  412. package/src/sources/provider-router/history.ts +32 -6
  413. package/src/sources/provider-router/index.ts +4 -0
  414. package/src/sources/provider-router/search.ts +1 -0
  415. package/src/sync/collections-contributor.ts +3 -1
  416. package/src/sync/config-merge.ts +10 -1
  417. package/src/sync/sanitize.ts +26 -2
  418. package/src/tickers/company-name-listing.ts +16 -2
  419. package/src/tickers/listing-fate.ts +12 -8
  420. package/src/tickers/renamed-listings.ts +43 -10
  421. package/src/tickers/search/home-listing.ts +28 -0
  422. package/src/tickers/search/index.ts +19 -7
  423. package/src/tickers/terminal-codes.ts +11 -1
  424. package/src/time-series/base-series.ts +39 -6
  425. package/src/time-series/chart-seed.ts +2 -2
  426. package/src/time-series/history-quality.ts +4 -1
  427. package/src/time-series/hooks.ts +2 -0
  428. package/src/time-series/price-comparison.ts +17 -23
  429. package/src/time-series/reporting.ts +1 -1
  430. package/src/time-series/resolution.ts +13 -0
  431. package/src/time-series/resolve-context.ts +6 -0
  432. package/src/time-series/resolve.ts +42 -3
  433. package/src/time-series/spec.ts +2 -2
  434. package/src/time-series/types.ts +3 -2
  435. package/src/types/data-provider.ts +11 -0
  436. package/src/types/financials.ts +48 -4
  437. package/src/types/headless.ts +1 -0
  438. package/src/types/issuer-listings.ts +2 -0
  439. package/src/types/plugin-notifications.ts +3 -0
  440. package/src/types/price-history.ts +6 -4
  441. package/src/types/ticker.ts +10 -2
  442. package/src/ui/host.tsx +2 -0
  443. package/src/utils/cli-output.ts +1 -1
  444. package/src/utils/declared-dividends.ts +13 -1
  445. package/src/utils/dividend-cash.ts +5 -1
  446. package/src/utils/exchange-announcements.ts +7 -2
  447. package/src/utils/forward-dividend.ts +4 -3
  448. package/src/utils/fundamentals.ts +40 -0
  449. package/src/utils/network-failure.ts +2 -0
  450. package/src/utils/price-history-integrity.ts +9 -1
  451. package/src/utils/remove-folder.ts +37 -0
  452. package/src/utils/trailing-dividend.ts +1 -1
  453. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -487,12 +487,23 @@ function preMarketCloseAwaitingPrint(quote: Quote | null | undefined): { date: s
487
487
 
488
488
  /**
489
489
  * When the price a quote's headline shows was observed: the regular close a
490
- * pre-market with no trade yet still stands at (preMarketCloseAwaitingPrint),
491
- * otherwise the quote's last update. What an Updated cell and a report's
492
- * as-of date the quote by.
490
+ * pre-market with no trade yet still stands at (preMarketCloseAwaitingPrint);
491
+ * a completed session's close stamped after the venue closed, with no
492
+ * extended print beside it, at that close (regularSessionCloseOn), as `fn
493
+ * ADR` and `fx` date it (GGAL.BA's 4,857.50 read 20:59 UTC in `quote` and
494
+ * 20:10 in `fn ADR`, its close on BYMA's calendar); otherwise the quote's last
495
+ * update. What an Updated cell and a report's as-of date the quote by.
493
496
  */
494
497
  export function quoteHeadlineTime(quote: Quote): number {
495
- return preMarketCloseAwaitingPrint(quote)?.closedAt ?? quote.lastUpdated;
498
+ const awaiting = preMarketCloseAwaitingPrint(quote);
499
+ if (awaiting) return awaiting.closedAt;
500
+ // A closed market's quote only: in a pre-market or after-hours session the last update can be a print.
501
+ const date = quote.marketState === "CLOSED" && !quote.delisting ? regularSessionDisplayDate(quote) : null;
502
+ if (date && Number.isFinite(quote.lastUpdated) && !getExtendedSessionDisplay(quote)) {
503
+ const closedAt = regularSessionCloseOn(quote.listingExchangeName || quote.exchangeName, date);
504
+ if (closedAt != null && quote.lastUpdated > closedAt) return closedAt;
505
+ }
506
+ return quote.lastUpdated;
496
507
  }
497
508
 
498
509
  /**
@@ -532,6 +543,31 @@ export function regularSessionDisplayDate(quote: Quote | null | undefined): stri
532
543
  return completedRegularSession(quote)?.date ?? quote.changeSessionDate ?? null;
533
544
  }
534
545
 
546
+ /**
547
+ * The exchange-local day of the close a quote's headline holds at once its
548
+ * regular session is over (and in the pre-market while it still shows the last
549
+ * close), so a report that prints an extended print beside it dates each: the
550
+ * close by its day, the print by its time (extendedPrintTime). Null while the
551
+ * session trades, for a listing that no longer trades, and when the quote does
552
+ * not say which day the close is.
553
+ */
554
+ export function headlineCloseDate(quote: Quote | null | undefined): string | null {
555
+ if (!quote || quote.delisting || completedRegularClose(quote) == null) return null;
556
+ const date = regularSessionDisplayDate(quote);
557
+ return date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : null;
558
+ }
559
+
560
+ /**
561
+ * When the pre-market, after-hours or overnight print getExtendedSessionDisplay
562
+ * shows was observed: the quote's last update, which that print is (the close
563
+ * beside it holds at its own day, headlineCloseDate). Null without an extended
564
+ * print or a time.
565
+ */
566
+ export function extendedPrintTime(quote: Quote | null | undefined): number | null {
567
+ if (!quote || !getExtendedSessionDisplay(quote)) return null;
568
+ return Number.isFinite(quote.lastUpdated) && quote.lastUpdated > 0 ? quote.lastUpdated : null;
569
+ }
570
+
535
571
  /**
536
572
  * getRegularSessionDisplay once the regular session is over (and in the
537
573
  * pre-market, while the quote carries the last session's close and move), null
@@ -1,7 +1,9 @@
1
1
  import type { PricePoint, Quote } from "../types/financials";
2
- import { pricePointCloseCopied, pricePointIntegrity } from "../utils/price-history-integrity";
2
+ import { CONTRADICTORY_PRICES, pricePointCloseCopied, pricePointIntegrity } from "../utils/price-history-integrity";
3
3
  import { calendarMonthsBefore } from "../utils/calendar-date";
4
- import { barSessionDay, isReturnPeriod, periodBaseDay, periodBaseIndex } from "./market/period-return";
4
+ import { formatShortDate } from "../utils/datetime-format";
5
+ import { barCloseDay, barSessionDay, isReturnPeriod, periodBaseDay, periodBaseIndex } from "./market/period-return";
6
+ import { getRegularSessionDisplay, headlineCloseDate } from "./market/status";
5
7
 
6
8
  export interface PriceReturnHorizon {
7
9
  id: string;
@@ -15,6 +17,30 @@ export interface PriceReturnField {
15
17
  label: string;
16
18
  value: number | null;
17
19
  unavailableReason?: "inconsistent-ohlc";
20
+ /** With `inconsistent-ohlc`: the session day of the end bar (the base or the latest) whose prices contradict each other. */
21
+ inconsistentDay?: string;
22
+ /** The day of the close the return is measured from, `YYYY-MM-DD`: the last close on or before the period's start date. */
23
+ baseDay?: string;
24
+ }
25
+
26
+ const DAILY_WINDOW_LEAD_DAYS = 21;
27
+
28
+ /**
29
+ * The daily closes a Price Return strip is measured on: five years and the
30
+ * three weeks before them, so 5Y has the close on its start date (a "5Y"
31
+ * range starts the day after it), to the end of today in UTC, so a day keeps
32
+ * one request.
33
+ */
34
+ export function priceReturnDailyWindow(now = Date.now()): { start: Date; end: Date } {
35
+ const today = new Date(Math.floor(now / 86_400_000) * 86_400_000);
36
+ const start = new Date(Date.UTC(today.getUTCFullYear() - 5, today.getUTCMonth(), today.getUTCDate() - DAILY_WINDOW_LEAD_DAYS));
37
+ return { start, end: new Date(today.getTime() + 86_400_000) };
38
+ }
39
+
40
+ /** The price a strip's returns run to, and the session day it is from. */
41
+ export interface PriceReturnEnd {
42
+ day: string;
43
+ close: number;
18
44
  }
19
45
 
20
46
  export const PRICE_RETURN_HORIZONS: PriceReturnHorizon[] = [
@@ -100,14 +126,32 @@ function isInconsistent(point: PricePoint): boolean {
100
126
  return inconsistent;
101
127
  }
102
128
 
129
+ /**
130
+ * The price a quote's returns run to: its headline, the regular session's
131
+ * price, which stops at the close, never an after-hours or pre-market print
132
+ * (GGAL's 1Y ran to the 29.08 after-hours print beside its 28.53 close). Dated
133
+ * by the session that close is from, or while it trades by the quote's time
134
+ * on the venue's clock. Null without a price.
135
+ */
136
+ export function headlinePriceReturnEnd(quote: Quote | null | undefined, venue?: string): PriceReturnEnd | null {
137
+ const close = getRegularSessionDisplay(quote)?.price;
138
+ if (!quote || close == null || !Number.isFinite(close)) return null;
139
+ // A time that is no date (a source's unknown timestamp) dates nothing.
140
+ const timed = Number.isFinite(new Date(quote.lastUpdated).getTime());
141
+ const day = headlineCloseDate(quote) ?? (timed ? barSessionDay(quote.lastUpdated, venue) : null);
142
+ return day ? { day, close } : null;
143
+ }
144
+
103
145
  export function appendQuoteToPriceReturnHistory(
104
146
  points: readonly PricePoint[],
105
- quote: Pick<Quote, "price" | "lastUpdated"> | null | undefined,
147
+ quote: Quote | null | undefined,
106
148
  ): readonly PricePoint[] {
107
149
  const history = normalizePriceReturnHistory(points);
108
150
  if (!quote || !Number.isFinite(quote.price) || !Number.isFinite(quote.lastUpdated)) {
109
151
  return history;
110
152
  }
153
+ // The headline price, never an extended-hours print.
154
+ const price = getRegularSessionDisplay(quote)?.price ?? quote.price;
111
155
 
112
156
  const quoteDate = new Date(quote.lastUpdated);
113
157
  if (!Number.isFinite(quoteDate.getTime())) return history;
@@ -119,7 +163,7 @@ export function appendQuoteToPriceReturnHistory(
119
163
  ...history,
120
164
  {
121
165
  date: quoteDate,
122
- close: quote.price,
166
+ close: price,
123
167
  },
124
168
  ];
125
169
  normalizedArrays.add(withQuote);
@@ -139,59 +183,110 @@ export function computePriceReturnForHorizon(
139
183
  horizon: PriceReturnHorizon,
140
184
  venue?: string,
141
185
  ): number | null {
142
- return priceReturnForHorizon(points, horizon, venue).value;
186
+ return buildPriceReturnFields(points, venue, [horizon])[0]?.value ?? null;
143
187
  }
144
188
 
145
- function priceReturnForHorizon(
146
- points: readonly PricePoint[],
147
- horizon: PriceReturnHorizon,
148
- venue: string | undefined,
149
- ): Pick<PriceReturnField, "value" | "unavailableReason"> {
150
- const history = normalizePriceReturnHistory(points);
151
- return priceReturnFromHistory(history, sessionDays(history, venue), horizon);
189
+ const DAY_MS = 86_400_000;
190
+
191
+ /**
192
+ * The bar size of a history read as returns: weekly or monthly bars close on
193
+ * the last day of their period (barCloseDay), which a period's base is held
194
+ * against, not the Monday they are dated by. Undefined for daily bars, and for
195
+ * a short or irregular history, which is read by its dates.
196
+ */
197
+ function barInterval(history: readonly PricePoint[]): "1wk" | "1mo" | undefined {
198
+ if (history.length < 4) return undefined;
199
+ const gaps = history.slice(1).map((point, index) => (point.date.getTime() - history[index]!.date.getTime()) / DAY_MS);
200
+ // Most bars a week or a month apart, a holiday's week or a quote appended to them aside; a sparse history is read as dated.
201
+ const share = (low: number, high: number) => gaps.filter((gap) => gap >= low && gap <= high).length / gaps.length;
202
+ return share(5, 9) >= 0.8 ? "1wk" : share(26, 33) >= 0.8 ? "1mo" : undefined;
152
203
  }
153
204
 
154
- /** `history` normalized, `days` its bars' session days. */
205
+ /**
206
+ * `history` normalized, `days` the day each bar's close is from. A period
207
+ * runs from the last close on or before its start date (periodBaseDay of the
208
+ * end's day, as every period return is measured) to `end`, the headline's
209
+ * price when given, else the newest close. No gap limit: the overview's
210
+ * history can be sparse, and its base is whatever close it holds on or
211
+ * before then.
212
+ */
155
213
  function priceReturnFromHistory(
156
214
  history: readonly PricePoint[],
157
215
  days: readonly string[],
158
216
  horizon: PriceReturnHorizon,
159
- ): Pick<PriceReturnField, "value" | "unavailableReason"> {
160
- if (history.length < 2) return {
161
- value: null,
162
- ...(history.some(isInconsistent) ? { unavailableReason: "inconsistent-ohlc" as const } : {}),
163
- };
164
-
165
- const latest = history.at(-1)!;
217
+ end: PriceReturnEnd | null,
218
+ ): Pick<PriceReturnField, "value" | "unavailableReason" | "inconsistentDay" | "baseDay"> {
219
+ const inconsistentAt = (index: number) => ({ value: null, unavailableReason: "inconsistent-ohlc" as const, inconsistentDay: days[index]! });
220
+ const last = history.at(-1);
221
+ const final = end ?? (last ? { day: days.at(-1)!, close: last.close } : null);
222
+ if (!final || history.length < (end ? 1 : 2)) {
223
+ const index = history.findIndex(isInconsistent);
224
+ return index < 0 ? { value: null } : inconsistentAt(index);
225
+ }
166
226
  // The close on or before the same date a horizon earlier, as every period return is measured. No gap
167
227
  // limit: the overview's history can be sparse, and its base is whatever close it holds on or before then.
168
228
  // Each bar and the quote by its session day: a JPX bar stamped 00:00 JST, or a quote after a New York close, is not the UTC date's.
169
- const baseDay = horizonBaseDay(days.at(-1)!, horizon);
170
- const baseIndex = periodBaseIndex(days, baseDay, Number.POSITIVE_INFINITY);
229
+ const baseDay = horizonBaseDay(final.day, horizon);
230
+ // The end's own close is never its base.
231
+ const before = end ? days.length : days.length - 1;
232
+ const baseIndex = periodBaseIndex(days.slice(0, before), baseDay, Number.POSITIVE_INFINITY);
171
233
  const baseline = baseIndex < 0 ? null : history[baseIndex]!;
172
- const cutoff = new Date(`${baseDay}T00:00:00Z`);
173
234
 
174
- // The bars from the baseline (or the cutoff) on: the history is in time order, one bar a timestamp.
175
- const since = (baseline?.date ?? cutoff).getTime();
176
- for (let index = history.length - 1; index >= 0 && history[index]!.date.getTime() >= since; index -= 1) {
177
- if (isInconsistent(history[index]!)) return { value: null, unavailableReason: "inconsistent-ohlc" };
178
- }
235
+ // A price return reads two closes, the base's and the end's. A bar between them whose prices contradict each
236
+ // other changes neither, so only an end bar's contradiction leaves the return blank (as the sector board reads its
237
+ // returns): 3698:HKEX's 3Y and 5Y read blank for one bad bar inside the five years before. A headline price given
238
+ // as the end is no bar.
239
+ if (!end && isInconsistent(last!)) return inconsistentAt(history.length - 1);
240
+ if (baseline && isInconsistent(baseline)) return inconsistentAt(baseIndex);
179
241
  if (!baseline || !Number.isFinite(baseline.close) || baseline.close === 0) return { value: null };
180
- if (!Number.isFinite(latest.close)) return { value: null };
181
- return { value: (latest.close - baseline.close) / baseline.close };
242
+ if (!Number.isFinite(final.close)) return { value: null };
243
+ return { value: (final.close - baseline.close) / baseline.close, baseDay: days[baseIndex]! };
182
244
  }
183
245
 
246
+ /** "1M", "1M and 3M", "1M, 3M and 1Y". */
247
+ function listed(items: readonly string[]): string {
248
+ return items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
249
+ }
250
+
251
+ /**
252
+ * "3Y and 5Y returns left blank: contradictory prices on 16 Jan 2025.": the returns shown blank because the bar one is
253
+ * measured from or to has contradictory prices, with those bars' days; undefined when none is. A bad bar no shown
254
+ * return reads is not mentioned: it changes no figure the overview shows.
255
+ */
256
+ export function priceReturnIntegrityNotice(fields: readonly PriceReturnField[]): string | undefined {
257
+ const blank = fields.filter((field) => field.unavailableReason === "inconsistent-ohlc");
258
+ if (blank.length === 0) return undefined;
259
+ const days = [...new Set(blank.flatMap((field) => field.inconsistentDay ? [field.inconsistentDay] : []))].sort();
260
+ const on = days.length > 0 ? ` on ${listed(days.map((day) => formatShortDate(`${day}T00:00:00Z`, { utc: true })))}` : "";
261
+ return `${listed(blank.map((field) => field.label))} ${blank.length === 1 ? "return" : "returns"} left blank: ${CONTRADICTORY_PRICES}${on}.`;
262
+ }
263
+
264
+ /**
265
+ * Each horizon's return over `points`, from the close on or before its start
266
+ * date to `end` (headlinePriceReturnEnd), else to the newest close. Daily
267
+ * bars give each base the close of that day; weekly or monthly ones the last
268
+ * close of a period ending on or before it. Each field names its base close's
269
+ * day.
270
+ */
184
271
  export function buildPriceReturnFields(
185
272
  points: readonly PricePoint[],
186
273
  venue?: string,
187
274
  horizons: readonly PriceReturnHorizon[] = PRICE_RETURN_HORIZONS,
275
+ end?: PriceReturnEnd | null,
188
276
  ): PriceReturnField[] {
189
277
  // Normalized and dated once for every horizon.
190
278
  const history = normalizePriceReturnHistory(points);
191
- const days = sessionDays(history, venue);
279
+ const sessions = sessionDays(history, venue);
280
+ const interval = barInterval(history);
281
+ const days = interval ? sessions.map((day) => barCloseDay(day, interval, venue)) : sessions;
282
+ // A headline older than the bars (a quote that stopped while history went on) is not the end: the newest close is.
283
+ // Held against the newest bar's session, not the day its period closes: a weekly bar dated Monday 9 Nov closes on
284
+ // Friday 13 Nov, after Wednesday's headline, which is still newer than the bar's Monday.
285
+ const lastSession = sessions.at(-1);
286
+ const final = end && (lastSession === undefined || end.day >= lastSession) ? end : null;
192
287
  return horizons.map((horizon) => ({
193
288
  id: horizon.id,
194
289
  label: horizon.label,
195
- ...priceReturnFromHistory(history, days, horizon),
290
+ ...priceReturnFromHistory(history, days, horizon, final),
196
291
  }));
197
292
  }
@@ -40,8 +40,11 @@ function quoteFeedWord(quote: Quote): string | null {
40
40
  return `${Math.round(delayedFeedLagMs(exchange) / 60_000)} min delayed`;
41
41
  }
42
42
 
43
- /** `08:09 UTC` on today's UTC date, `Thu 08:09 UTC` within the week, `Thu 29 Oct 08:09 UTC` before it. */
44
- function asOfClock(time: number, now: number): string {
43
+ /**
44
+ * `08:09 UTC` on today's UTC date, `Thu 08:09 UTC` within the week, `Thu 29 Oct
45
+ * 08:09 UTC` before it: when a card's price, or an extended print, was observed.
46
+ */
47
+ export function asOfClock(time: number, now = Date.now()): string {
45
48
  const iso = new Date(time).toISOString();
46
49
  if (iso.slice(0, 10) === new Date(now).toISOString().slice(0, 10)) return `${iso.slice(11, 16)} UTC`;
47
50
  return `${now - time < WEEK_MS ? formatUtcWeekdayTime(time) : formatUtcDayTime({ time, dateOnly: false }, now)} UTC`;
@@ -0,0 +1,28 @@
1
+ import type { SplitAction } from "../types/financials";
2
+
3
+ /** A factor with more shares than this on either side is no share count a split states: GE's 1253:1000 spinoff adjustment. */
4
+ const MAX_SPLIT_SHARES = 100;
5
+
6
+ function greatestCommonDivisor(a: number, b: number): number {
7
+ return b === 0 ? a : greatestCommonDivisor(b, a % b);
8
+ }
9
+
10
+ /**
11
+ * A split's share terms, from its adjustment factor when that is a ratio of
12
+ * whole share counts: "10-for-1", "1-for-10 reverse", and, for one that adds
13
+ * a share for every few held as a bonus issue does (DBS's 1-for-10 in 2024),
14
+ * "11-for-10, 1 new share for every 10 held". Null for a factor no share count
15
+ * states, which may be a spinoff's price adjustment rather than a split.
16
+ */
17
+ export function splitShareTerms(split: Pick<SplitAction, "fromFactor" | "toFactor">): string | null {
18
+ const { fromFactor: from, toFactor: to } = split;
19
+ if (!Number.isInteger(from) || !Number.isInteger(to) || from! <= 0 || to! <= 0 || from === to) return null;
20
+ const divisor = greatestCommonDivisor(to!, from!);
21
+ const after = to! / divisor;
22
+ const before = from! / divisor;
23
+ if (Math.max(after, before) > MAX_SPLIT_SHARES) return null;
24
+ if (after < before) return `${after}-for-${before} reverse`;
25
+ if (before === 1) return `${after}-for-1`;
26
+ const added = after - before;
27
+ return `${after}-for-${before}, ${added} new share${added === 1 ? "" : "s"} for every ${before} held`;
28
+ }
package/src/news/types.ts CHANGED
@@ -23,6 +23,32 @@ export interface NewsStoryItem {
23
23
  hasArticleText?: boolean;
24
24
  }
25
25
 
26
+ /**
27
+ * A Form 4 a story about insiders trading reports: one filing's lines of the
28
+ * side the story reports, by an insider it names, dated in the period it names,
29
+ * summed as filed.
30
+ */
31
+ export interface NewsInsiderFiling {
32
+ accession: string;
33
+ form: string;
34
+ /** YYYY-MM-DD. */
35
+ filedOn: string;
36
+ issuerName: string | null;
37
+ ticker: string | null;
38
+ /** The reporting owner as filed: "STEVENS MARK A". */
39
+ insider: string;
40
+ title: string | null;
41
+ side: "sale" | "purchase";
42
+ firstTradeDate: string;
43
+ lastTradeDate: string;
44
+ lines: number;
45
+ shares: number;
46
+ value: number;
47
+ weightedPrice: number;
48
+ rule10b51: boolean | null;
49
+ url: string;
50
+ }
51
+
26
52
  export interface NewsArticle {
27
53
  id: string;
28
54
  title: string;
@@ -44,6 +70,8 @@ export interface NewsArticle {
44
70
  items?: NewsStoryItem[];
45
71
  /** The routine notices the story stands for in a company's feed (a buy-back's daily notices), its own included. */
46
72
  routine?: NewsRoutineNotices;
73
+ /** A story about insiders trading: the Form 4s it reports, as Gloom Cloud matched them. */
74
+ insiderFilings?: NewsInsiderFiling[];
47
75
  /**
48
76
  * The text this story was found by, when it stands in for a coin pair's feed
49
77
  * no story is filed under: the stories that mention "bitcoin" for BTC-USD.
@@ -1,7 +1,6 @@
1
1
  /**
2
- * The badge on the app's icon: the Dock icon on macOS. Only a host that can
3
- * show one installs a sink, which is the desktop app's main window; the
4
- * terminal and the web app have none, so nothing is set up for them.
2
+ * The unread badge on the macOS Dock icon or the browser tab. Hosts that
3
+ * cannot show one do not install a sink.
5
4
  */
6
5
  export interface AppBadgeHost {
7
6
  /** `""` clears the badge; otherwise the label from {@link appBadgeLabel}. */
@@ -41,6 +41,7 @@ interface CreateAppNotifierOptions {
41
41
  isAppActive: () => boolean;
42
42
  renderToast: (notification: AppNotificationRequest) => void;
43
43
  desktop?: DesktopNotificationSink | null;
44
+ notifyInBackground?: (notification: AppNotificationRequest) => boolean;
44
45
  }
45
46
 
46
47
  function escapeAppleScriptString(value: string): string {
@@ -263,6 +264,7 @@ export function createAppNotifier({
263
264
  isAppActive,
264
265
  renderToast,
265
266
  desktop = typeof Bun !== "undefined" ? createDesktopNotifier() : null,
267
+ notifyInBackground,
266
268
  }: CreateAppNotifierOptions): AppNotifier {
267
269
  return {
268
270
  notify(request) {
@@ -298,6 +300,9 @@ export function createAppNotifier({
298
300
  ) {
299
301
  desktopRequested = desktop ? desktop.notify(notification) !== false : false;
300
302
  }
303
+ if (!appActive && notifyInBackground && (notification.browser || logged)) {
304
+ desktopRequested = notifyInBackground(notification) || desktopRequested;
305
+ }
301
306
 
302
307
  return {
303
308
  toastVisible: appActive && toastRendered,
@@ -15,7 +15,7 @@ export function useAccountManagementFooter({
15
15
  message,
16
16
  saveProfile,
17
17
  }: {
18
- busy: "profile" | "password" | "alerts" | "billing" | "trial" | "delete" | null;
18
+ busy: "profile" | "password" | "alerts" | "billing" | "trial" | "cancel" | "delete" | null;
19
19
  /** Off while a tab that owns its footer is showing. */
20
20
  enabled: boolean;
21
21
  hasSession: boolean;
@@ -3,6 +3,7 @@ import { useFieldRing, type FieldRing } from "../../../components";
3
3
  import { useShortcut } from "../../../react/input";
4
4
  import type { ScrollBoxRenderable } from "../../../ui";
5
5
  import { isPlainKey } from "../../../utils/keyboard";
6
+ import { logFailure } from "../../../utils/log-failure";
6
7
  import type { AccountDraft, AccountFieldKey } from "./model";
7
8
 
8
9
  const SCOPE = "account-management:fields";
@@ -35,6 +36,7 @@ export function useAccountManagementKeyboard({
35
36
  setDraftValue,
36
37
  deleteAccount,
37
38
  endTrial,
39
+ cancelPro,
38
40
  copyInvite,
39
41
  turnOffEmailAlerts,
40
42
  yearlyPlanAction,
@@ -57,6 +59,7 @@ export function useAccountManagementKeyboard({
57
59
  setDraftValue: <K extends keyof AccountDraft>(key: K, value: AccountDraft[K]) => void;
58
60
  deleteAccount: () => Promise<void>;
59
61
  endTrial: () => Promise<void>;
62
+ cancelPro: () => Promise<void>;
60
63
  copyInvite: () => void;
61
64
  turnOffEmailAlerts: () => Promise<void>;
62
65
  /** The yearly row's action: review, pay or open the invoice. */
@@ -70,6 +73,7 @@ export function useAccountManagementKeyboard({
70
73
  passwordAction: openPasswordDialog,
71
74
  upgradeAction: openUpgrade,
72
75
  cancelTrialAction: () => { void endTrial(); },
76
+ cancelProAction: () => { cancelPro().catch(logFailure("account-management.keyboard", "Cancel Pro failed")); },
73
77
  inviteCopyAction: copyInvite,
74
78
  assistantsAction: openAssistants,
75
79
  deleteAccountAction: () => { void deleteAccount(); },
@@ -27,6 +27,7 @@ export type AccountFieldKey =
27
27
  | "yearlyPlanAction"
28
28
  | "yearlyPlanDismissAction"
29
29
  | "cancelTrialAction"
30
+ | "cancelProAction"
30
31
  | "inviteCopyAction"
31
32
  | "assistantsAction"
32
33
  | "passwordAction"
@@ -16,6 +16,7 @@ import {
16
16
  import { useAppSelector, usePaneAppConfig } from "../../../state/app/context";
17
17
  import { useViewport } from "../../../react/input";
18
18
  import { displayWidth } from "../../../utils/format";
19
+ import { formatShortDate } from "../../../utils/datetime-format";
19
20
  import { useChartQueries, useFxRatesMap } from "../../../market-data/hooks";
20
21
  import { buildPortfolioFinancialsMap } from "../../../market-data/portfolio-financials";
21
22
  import { useLiveTickerFinancialsMap, useSampledValue } from "../../../state/hooks/live-ticker-financials";
@@ -72,6 +73,7 @@ import {
72
73
  import { DeleteAccountPasswordDialog, PasswordChangeDialog } from "./password-dialog";
73
74
  import { deleteAccountConfirmingSession } from "./delete-account";
74
75
  import { endTrialAfterWarning } from "./trial-cancel";
76
+ import { cancelProAfterSteps } from "./pro-cancel";
75
77
  import { CalendarAccountTab } from "./calendar-tab";
76
78
  import { InviteRow } from "./invite-row";
77
79
  import { PaymentRecoveryRow, usePaymentRecovery } from "./payment-recovery-row";
@@ -97,7 +99,7 @@ import { useCloudUpgradeAction } from "../shared/cloud-upgrade";
97
99
  import { resolvePlanAccess } from "../../../api-client/plan-access";
98
100
  import { usePluginPaneState } from "../../runtime";
99
101
 
100
- type AccountBusy = "profile" | "password" | "alerts" | "billing" | "trial" | "delete" | null;
102
+ type AccountBusy = "profile" | "password" | "alerts" | "billing" | "trial" | "cancel" | "delete" | null;
101
103
  const ACCOUNT_TAB_DEFS: Array<{ label: string; value: AccountManagementTab }> = [
102
104
  { label: "Profile", value: "profile" },
103
105
  { label: "Emails", value: "emails" },
@@ -132,9 +134,10 @@ const ACCOUNT_TAB_FIELD_ORDER: Record<AccountManagementTab, AccountFieldKey[]> =
132
134
  ],
133
135
  // Its actions are footer hints; the tab owns its footer.
134
136
  calendar: [],
135
- // Cancel Trial shows only while a trial runs, the yearly row while it has
136
- // an action, Not Now while its review is open, the invite once it loaded.
137
- pro: ["upgradeAction", "cancelTrialAction", "yearlyPlanAction", "yearlyPlanDismissAction", "inviteCopyAction"],
137
+ // Cancel Trial shows only while a trial runs, Cancel Pro while a paid plan
138
+ // renews, the yearly row while it has an action, Not Now while its review
139
+ // is open, the invite once it loaded.
140
+ pro: ["upgradeAction", "cancelTrialAction", "cancelProAction", "yearlyPlanAction", "yearlyPlanDismissAction", "inviteCopyAction"],
138
141
  // The Teams tab owns its own keyboard handling (a list, not form fields).
139
142
  teams: [],
140
143
  // Remote assistants allowed to drive this terminal; a list with its own footer.
@@ -290,23 +293,39 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
290
293
  refreshAfterYearlySwitch,
291
294
  focusYearlyDismiss,
292
295
  );
296
+ // The account's own paid plan, renewing: gloom.sh's cancel window shows then
297
+ // too. A trial has Cancel Trial, Pro through a team is the team's to cancel,
298
+ // and a failed payment shows Pay Invoice in this place.
299
+ const ownSubscription = paymentRecovery.plan?.subscription;
300
+ const canCancelPro = planAccess.isPayingPro
301
+ && ownSubscription?.active === true
302
+ && ownSubscription.status !== "trialing"
303
+ && ownSubscription.cancelAtPeriodEnd !== true
304
+ && !paymentRecovery.visible;
293
305
  const fieldOrder = useMemo(() => ACCOUNT_TAB_FIELD_ORDER[activeTab].filter((field) => {
294
306
  if (field === "showLocalTime" || field === "showDesks") return chatCardSupported;
295
307
  if (field === "desks") return chatCardSupported && draft.showDesks;
296
308
  if (field === "cancelTrialAction") return planAccess.isTrialActive;
309
+ if (field === "cancelProAction") return canCancelPro;
297
310
  if (field === "yearlyPlanAction") return yearlyPlan.primary !== null;
298
311
  if (field === "yearlyPlanDismissAction") return yearlyPlan.reviewing;
299
312
  if (field === "inviteCopyAction") return invite !== null;
300
313
  return true;
301
- }), [activeTab, chatCardSupported, draft.showDesks, invite, planAccess.isTrialActive, yearlyPlan.primary, yearlyPlan.reviewing]);
314
+ }), [activeTab, canCancelPro, chatCardSupported, draft.showDesks, invite, planAccess.isTrialActive, yearlyPlan.primary, yearlyPlan.reviewing]);
302
315
  const accountTabs = ACCOUNT_TAB_DEFS.map((tab) => ({ ...tab, label: t(tab.label) }));
303
316
 
304
317
  const planPrice = useMemo(() => formatCloudMonthlyPrice(pricing), [language, pricing]);
305
318
  const trialOffer = useMemo(() => formatTrialOffer(pricing), [language, pricing]);
319
+ const cancelsOn = ownSubscription?.cancelAtPeriodEnd === true && ownSubscription.currentPeriodEnd
320
+ ? formatShortDate(ownSubscription.currentPeriodEnd, { fallback: "" })
321
+ : "";
306
322
  const planStatusLabel = useMemo(() => {
307
323
  const trialEnd = planAccess.isTrialActive ? formatTrialEnd(planAccess.trialEndsAt) : null;
308
- return trialEnd ? tf("Pro trial — ends {date}", { date: trialEnd }) : formatPlan(profile?.plan);
309
- }, [language, planAccess.isTrialActive, planAccess.trialEndsAt, profile?.plan]);
324
+ if (trialEnd) return tf("Pro trial — ends {date}", { date: trialEnd });
325
+ // A cancelled paid plan says when Pro stops, where Cancel Pro was.
326
+ if (planAccess.isPayingPro && cancelsOn) return tf("Pro until {date}", { date: cancelsOn });
327
+ return formatPlan(profile?.plan);
328
+ }, [cancelsOn, language, planAccess.isPayingPro, planAccess.isTrialActive, planAccess.trialEndsAt, profile?.plan]);
310
329
 
311
330
  const planStats = useMemo<StatItem[]>(() => {
312
331
  return [
@@ -837,6 +856,43 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
837
856
  }
838
857
  }, [busy, dialog, planAccess]);
839
858
 
859
+ // gloom.sh's cancel window, step for step (pro-cancel.tsx): why, the offer
860
+ // the server has, then the confirmation with the date Pro stays on to.
861
+ const cancelPro = useCallback(async () => {
862
+ setActiveField("cancelProAction");
863
+ if (busy || !canCancelPro) return;
864
+ try {
865
+ const outcome = await cancelProAfterSteps(
866
+ dialog,
867
+ { currentPeriodEnd: ownSubscription?.currentPeriodEnd },
868
+ {
869
+ retentionOffer: (signal) => apiClient.getCloudRetentionOffer({ signal }),
870
+ acceptOffer: (feedback) => apiClient.acceptCloudRetentionOffer(feedback),
871
+ cancel: (feedback) => apiClient.cancelCloudSubscription(feedback),
872
+ },
873
+ {
874
+ onWorking: (text) => {
875
+ setBusy("cancel");
876
+ setMessage({ tone: "info", text });
877
+ },
878
+ },
879
+ );
880
+ if (!outcome) return;
881
+ setMessage({ tone: "success", text: outcome.message });
882
+ // The plan changed on the server: Cancel Pro and the plan line follow it.
883
+ await paymentRecovery.reload();
884
+ const nextProfile = await apiClient.getAccountProfile().catch(logFailure("account-management.pane", "Refresh cancelled account profile failed", null));
885
+ if (nextProfile) setProfile(nextProfile);
886
+ } catch (error) {
887
+ setMessage({
888
+ tone: "error",
889
+ text: error instanceof Error ? error.message : t("Cancel failed."),
890
+ });
891
+ } finally {
892
+ setBusy(null);
893
+ }
894
+ }, [busy, canCancelPro, dialog, ownSubscription?.currentPeriodEnd, paymentRecovery.reload]);
895
+
840
896
  const renderer = useRendererHost();
841
897
  const copyInvite = useCallback(() => {
842
898
  setActiveField("inviteCopyAction");
@@ -863,6 +919,7 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
863
919
  deleteAccount,
864
920
  draftRef,
865
921
  endTrial,
922
+ cancelPro,
866
923
  copyInvite,
867
924
  fieldOrder,
868
925
  // Behind the sign-in wall the fields are not there, and Enter is the wall's.
@@ -1137,6 +1194,17 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
1137
1194
  />
1138
1195
  </Box>
1139
1196
  ) : null}
1197
+ {canCancelPro || busy === "cancel" ? (
1198
+ <Box ref={fieldNodeRef("cancelProAction")} flexDirection="row">
1199
+ <Button
1200
+ label={busy === "cancel" ? t("Cancelling...") : t("Cancel Pro")}
1201
+ variant="danger"
1202
+ active={activeField === "cancelProAction"}
1203
+ onPress={() => { cancelPro().catch(logFailure("account-management.pane", "Cancel Pro failed")); }}
1204
+ disabled={!!busy}
1205
+ />
1206
+ </Box>
1207
+ ) : null}
1140
1208
  </Box>}
1141
1209
  {paymentRecovery.visible ? null : (
1142
1210
  <YearlyPlanRow