@gloom-sh/terminal 0.20.12 → 0.20.14

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 (616) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
  3. package/src/account/auth-dialog.tsx +22 -4
  4. package/src/account/auth-form.tsx +6 -1
  5. package/src/account/billing.ts +3 -2
  6. package/src/account/checkout-handoff.tsx +7 -14
  7. package/src/account/device-signin-dialog.tsx +35 -24
  8. package/src/account/upgrade-dialog.tsx +8 -8
  9. package/src/api-client/crypto-markets.ts +10 -0
  10. package/src/api-client/errors.ts +3 -1
  11. package/src/api-client/index.ts +10 -2
  12. package/src/api-client/install-experiments.ts +146 -0
  13. package/src/api-client/money-markets.ts +7 -0
  14. package/src/api-client/request.ts +12 -2
  15. package/src/api-client/telemetry.ts +47 -0
  16. package/src/api-client/types/market.ts +4 -0
  17. package/src/api-client/types/news.ts +16 -0
  18. package/src/architecture/floating-promise-allowlist.json +17 -34
  19. package/src/brokers/signed-in/adapter.ts +2 -2
  20. package/src/brokers/signed-in/catalog.ts +13 -4
  21. package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
  22. package/src/cli/commands/market.ts +146 -55
  23. package/src/cli/commands/overview.ts +21 -7
  24. package/src/cli/commands/search.ts +103 -9
  25. package/src/cli/commands/ticker.ts +22 -13
  26. package/src/cli/earnings-calendar.ts +33 -53
  27. package/src/cli/errors.ts +3 -1
  28. package/src/cli/freshness.ts +7 -2
  29. package/src/cli/glossary.ts +10 -5
  30. package/src/cli/helpers.ts +8 -16
  31. package/src/cli/history-export.ts +4 -0
  32. package/src/cli/history-rows.ts +18 -1
  33. package/src/cli/known-gaps.ts +11 -2
  34. package/src/cli/listing-arg.ts +183 -28
  35. package/src/cli/not-a-ticker.ts +4 -0
  36. package/src/cli/pane-functions/catalog.ts +81 -12
  37. package/src/cli/pane-functions/dom.ts +8 -1
  38. package/src/cli/pane-functions/freshness.ts +2 -2
  39. package/src/cli/pane-functions/headless.ts +13 -10
  40. package/src/cli/pane-functions/index.ts +1 -1
  41. package/src/cli/pane-functions/options.ts +7 -0
  42. package/src/cli/pane-functions/report.ts +4 -1
  43. package/src/cli/pane-functions/resolver.ts +61 -15
  44. package/src/cli/perpetual-contract.ts +4 -4
  45. package/src/cli/quote-answer.ts +6 -2
  46. package/src/cli/result.ts +24 -5
  47. package/src/cli/symbol-args.ts +5 -3
  48. package/src/cli/symbol-list.ts +23 -10
  49. package/src/cli/symbol-rows.ts +135 -3
  50. package/src/cli/treasury-yields.ts +15 -1
  51. package/src/components/chart/composite/axis-overlays.tsx +5 -2
  52. package/src/components/chart/composite/composite-chart.tsx +1 -0
  53. package/src/components/chart/composite/format.ts +103 -16
  54. package/src/components/chart/composite/legend.tsx +60 -25
  55. package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
  56. package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
  57. package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
  58. package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
  59. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
  60. package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
  61. package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
  62. package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
  63. package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
  64. package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
  65. package/src/components/chart/composite/panel-surface/props.ts +79 -0
  66. package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
  67. package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
  68. package/src/components/chart/composite/panel-surface.tsx +81 -1177
  69. package/src/components/chart/composite/time-axis.ts +51 -29
  70. package/src/components/chart/composite/toolbar.tsx +42 -6
  71. package/src/components/chart/curve/curve-surface.tsx +5 -5
  72. package/src/components/command-bar/commands/collection-list.ts +1 -0
  73. package/src/components/command-bar/list/badge.ts +8 -5
  74. package/src/components/command-bar/list/model.ts +0 -5
  75. package/src/components/command-bar/list/view.tsx +39 -2
  76. package/src/components/command-bar/routes/root/plugin-install.ts +4 -2
  77. package/src/components/command-bar/routes/root/provider-search.ts +23 -3
  78. package/src/components/command-bar/routes/root/results.ts +23 -11
  79. package/src/components/command-bar/routes/root/runtime.ts +3 -2
  80. package/src/components/command-bar/routes/root/selection.ts +3 -2
  81. package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
  82. package/src/components/command-bar/routes/root/start-here.ts +1 -2
  83. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -3
  84. package/src/components/command-bar/routes/ticker-search/results.ts +23 -4
  85. package/src/components/data-table/view.tsx +29 -6
  86. package/src/components/form-modal/host.tsx +1 -1
  87. package/src/components/layout/header.tsx +3 -2
  88. package/src/components/layout/market-summary.ts +3 -3
  89. package/src/components/layout/pane/error-boundary.tsx +2 -1
  90. package/src/components/layout/pane/title.ts +10 -4
  91. package/src/components/markdown-text.tsx +36 -0
  92. package/src/components/market-board/index.tsx +4 -3
  93. package/src/components/onboarding/first-run-workspace.ts +46 -11
  94. package/src/components/onboarding/onboarding-keyboard.ts +57 -5
  95. package/src/components/onboarding/onboarding-wizard.tsx +91 -24
  96. package/src/components/onboarding/portfolio-step/index.tsx +1 -0
  97. package/src/components/onboarding/portfolio-step/positions-panel.tsx +36 -9
  98. package/src/components/onboarding/portfolio-step/types.ts +2 -0
  99. package/src/components/onboarding/tickers-step-model.ts +140 -0
  100. package/src/components/onboarding/tickers-step.tsx +116 -0
  101. package/src/components/onboarding/use-onboarding-broker-form.ts +1 -1
  102. package/src/components/onboarding/use-onboarding-progress.ts +100 -11
  103. package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
  104. package/src/components/onboarding/wizard-model.ts +3 -1
  105. package/src/components/onboarding/wizard-tickers.ts +139 -0
  106. package/src/components/pane-settings-dialog/tui.tsx +6 -3
  107. package/src/components/pane-settings-dialog.tsx +2 -1
  108. package/src/components/pane-template-wizard.tsx +2 -0
  109. package/src/components/price-performance.tsx +2 -2
  110. package/src/components/speedometer-gauge/model.ts +2 -1
  111. package/src/components/speedometer-gauge/terminal.tsx +13 -8
  112. package/src/components/ui/choice-dialog.tsx +102 -33
  113. package/src/components/ui/confirm-dialog.tsx +3 -2
  114. package/src/components/ui/frame.tsx +7 -3
  115. package/src/components/ui/icon.tsx +4 -2
  116. package/src/components/ui/list-view.tsx +8 -0
  117. package/src/components/ui/multi-select/dialog.tsx +1 -7
  118. package/src/components/ui/not-meaningful.ts +16 -0
  119. package/src/components/ui/number-prompt-dialog.tsx +2 -1
  120. package/src/components/ui/query-bar.tsx +16 -4
  121. package/src/components/ui/stat-grid.tsx +27 -6
  122. package/src/components/use-pane-notice-footer.tsx +3 -1
  123. package/src/data/config/store/normalize.ts +2 -0
  124. package/src/docs/snapshot.json +3 -3
  125. package/src/i18n/es.ts +6 -2
  126. package/src/i18n/ja.ts +6 -2
  127. package/src/i18n/ko.ts +6 -2
  128. package/src/i18n/zh-cn.ts +6 -2
  129. package/src/i18n/zh-tw.ts +6 -2
  130. package/src/layout-marketplace/model.ts +2 -1
  131. package/src/market-data/futures-contract.ts +2 -1
  132. package/src/market-data/hooks.tsx +1 -1
  133. package/src/market-data/market/change-basis.ts +27 -5
  134. package/src/market-data/market/format.ts +48 -14
  135. package/src/market-data/quotes/contributions.ts +13 -0
  136. package/src/market-data/quotes/export-identity.ts +36 -1
  137. package/src/market-data/quotes/listing-enterprise-value.ts +3 -3
  138. package/src/market-data/quotes/resolution.ts +16 -0
  139. package/src/market-data/quotes/time.ts +17 -10
  140. package/src/market-data/tax-equivalent.ts +3 -2
  141. package/src/news/aggregator.ts +19 -8
  142. package/src/news/hooks.ts +1 -1
  143. package/src/news/news-model.ts +49 -0
  144. package/src/news/types.ts +9 -0
  145. package/src/plugins/builtin/account-management/calendar-tab.tsx +8 -3
  146. package/src/plugins/builtin/account-management/pane.tsx +9 -8
  147. package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
  148. package/src/plugins/builtin/alerts/calendar-events.ts +4 -5
  149. package/src/plugins/builtin/alerts/format.ts +6 -5
  150. package/src/plugins/builtin/alerts/headless.ts +3 -2
  151. package/src/plugins/builtin/alerts/history.ts +2 -1
  152. package/src/plugins/builtin/alerts/pane.tsx +2 -1
  153. package/src/plugins/builtin/alerts/price-text.ts +2 -1
  154. package/src/plugins/builtin/alerts/scheduled.ts +6 -5
  155. package/src/plugins/builtin/analytics/account-returns.ts +6 -7
  156. package/src/plugins/builtin/analytics/display.ts +2 -1
  157. package/src/plugins/builtin/analytics/pane-model.ts +5 -9
  158. package/src/plugins/builtin/analytics/risk-client.ts +12 -2
  159. package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
  160. package/src/plugins/builtin/analytics/risk-math.ts +23 -6
  161. package/src/plugins/builtin/analytics/risk-model.ts +26 -15
  162. package/src/plugins/builtin/analytics/risk-pane.tsx +8 -7
  163. package/src/plugins/builtin/analytics/view.tsx +5 -5
  164. package/src/plugins/builtin/attention/model.ts +6 -5
  165. package/src/plugins/builtin/attention/pane.tsx +5 -4
  166. package/src/plugins/builtin/awards/detail.tsx +5 -4
  167. package/src/plugins/builtin/awards/headless.ts +8 -7
  168. package/src/plugins/builtin/awards/model.ts +4 -3
  169. package/src/plugins/builtin/awards/pane.tsx +4 -4
  170. package/src/plugins/builtin/backtest/format.ts +3 -2
  171. package/src/plugins/builtin/backtest/report.ts +3 -2
  172. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  173. package/src/plugins/builtin/bond-calculator/pane.tsx +2 -1
  174. package/src/plugins/builtin/broker-manager/add-flow.tsx +1 -1
  175. package/src/plugins/builtin/broker-trading/orders-data.ts +3 -3
  176. package/src/plugins/builtin/broker-trading/orders.tsx +3 -2
  177. package/src/plugins/builtin/broker-trading/ticket.tsx +2 -2
  178. package/src/plugins/builtin/buildout/cells.tsx +2 -1
  179. package/src/plugins/builtin/buildout/company/pane.tsx +4 -3
  180. package/src/plugins/builtin/buildout/data-runtime.ts +21 -23
  181. package/src/plugins/builtin/buildout/detail/values.ts +2 -1
  182. package/src/plugins/builtin/buildout/format.ts +4 -3
  183. package/src/plugins/builtin/buildout/pane/index.tsx +3 -3
  184. package/src/plugins/builtin/catalysts/detail.tsx +2 -1
  185. package/src/plugins/builtin/catalysts/model.ts +6 -5
  186. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  187. package/src/plugins/builtin/cds/headless.ts +3 -2
  188. package/src/plugins/builtin/cds/model.ts +8 -8
  189. package/src/plugins/builtin/cds/pane.tsx +3 -2
  190. package/src/plugins/builtin/central-bank-rates/headless.ts +2 -1
  191. package/src/plugins/builtin/central-bank-rates/model.ts +3 -2
  192. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -5
  193. package/src/plugins/builtin/changelog/index.tsx +2 -2
  194. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
  195. package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
  196. package/src/plugins/builtin/chart-composer/index.tsx +4 -2
  197. package/src/plugins/builtin/chart-composer/pane.tsx +8 -4
  198. package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
  199. package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
  200. package/src/plugins/builtin/chart-composer/use-series-catalog.ts +3 -1
  201. package/src/plugins/builtin/chart-composer/user-series.ts +3 -1
  202. package/src/plugins/builtin/chat/attachments/desktop.tsx +2 -1
  203. package/src/plugins/builtin/chat/controller/utils.ts +2 -1
  204. package/src/plugins/builtin/clinical-trials/model.ts +4 -3
  205. package/src/plugins/builtin/clinical-trials/sponsor-tickers.ts +4 -2
  206. package/src/plugins/builtin/cloud/askg/lock-note.ts +16 -4
  207. package/src/plugins/builtin/cloud/askg/model.ts +2 -1
  208. package/src/plugins/builtin/cloud/askg/pane.tsx +35 -1
  209. package/src/plugins/builtin/cloud/company-picker.tsx +1 -3
  210. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  211. package/src/plugins/builtin/cloud/team/pane.tsx +12 -12
  212. package/src/plugins/builtin/cloud/thesis/detail.tsx +13 -8
  213. package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
  214. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
  215. package/src/plugins/builtin/cloud-tweets/model.ts +2 -2
  216. package/src/plugins/builtin/comment-letters/pane.tsx +2 -1
  217. package/src/plugins/builtin/commodity-balances/headless.ts +3 -2
  218. package/src/plugins/builtin/company-attention/app-rank.tsx +5 -4
  219. package/src/plugins/builtin/company-attention/building-model.ts +7 -7
  220. package/src/plugins/builtin/company-attention/headless.ts +6 -5
  221. package/src/plugins/builtin/company-attention/model.ts +4 -4
  222. package/src/plugins/builtin/company-attention/moves-model.ts +9 -9
  223. package/src/plugins/builtin/company-attention/signals-model.ts +9 -9
  224. package/src/plugins/builtin/company-kpis/headless.ts +2 -1
  225. package/src/plugins/builtin/company-kpis/model.ts +15 -10
  226. package/src/plugins/builtin/company-kpis/pane.tsx +2 -2
  227. package/src/plugins/builtin/congress-trades/detail.tsx +6 -5
  228. package/src/plugins/builtin/congress-trades/headless.ts +2 -1
  229. package/src/plugins/builtin/congress-trades/model.ts +6 -6
  230. package/src/plugins/builtin/congress-trades/table.tsx +7 -6
  231. package/src/plugins/builtin/connections/pane.tsx +5 -5
  232. package/src/plugins/builtin/correlation/headless.ts +2 -2
  233. package/src/plugins/builtin/correlation/index.tsx +4 -1
  234. package/src/plugins/builtin/correlation/matrix/selection.ts +2 -1
  235. package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -3
  236. package/src/plugins/builtin/cot/headless.ts +3 -2
  237. package/src/plugins/builtin/cot/model.ts +2 -1
  238. package/src/plugins/builtin/cot/pane.tsx +4 -3
  239. package/src/plugins/builtin/cpi/headless.ts +10 -4
  240. package/src/plugins/builtin/cpi/model.ts +25 -7
  241. package/src/plugins/builtin/cpi/pane.tsx +3 -1
  242. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +5 -4
  243. package/src/plugins/builtin/credit-boards/headless.ts +2 -1
  244. package/src/plugins/builtin/credit-boards/model.ts +5 -5
  245. package/src/plugins/builtin/credit-conditions/headless.ts +2 -1
  246. package/src/plugins/builtin/credit-conditions/index.tsx +2 -2
  247. package/src/plugins/builtin/credit-documents/model.ts +2 -2
  248. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  249. package/src/plugins/builtin/crypto-board/defi-view.tsx +7 -7
  250. package/src/plugins/builtin/crypto-board/defi.ts +2 -2
  251. package/src/plugins/builtin/crypto-board/headless.ts +10 -2
  252. package/src/plugins/builtin/crypto-board/model.ts +93 -14
  253. package/src/plugins/builtin/crypto-board/pane.tsx +28 -13
  254. package/src/plugins/builtin/crypto-board/supply.ts +2 -2
  255. package/src/plugins/builtin/crypto-etf-flows/model.ts +4 -4
  256. package/src/plugins/builtin/custom-view/index.tsx +3 -1
  257. package/src/plugins/builtin/custom-view/pane.tsx +5 -1
  258. package/src/plugins/builtin/custom-view/view-spec.ts +11 -0
  259. package/src/plugins/builtin/debt-maturities/model.ts +3 -3
  260. package/src/plugins/builtin/debt-maturities/pane.tsx +2 -2
  261. package/src/plugins/builtin/dividend-yield/client.ts +31 -5
  262. package/src/plugins/builtin/dividend-yield/headless.ts +20 -13
  263. package/src/plugins/builtin/dividend-yield/pane.tsx +12 -10
  264. package/src/plugins/builtin/dividend-yield/ranking-view.tsx +4 -1
  265. package/src/plugins/builtin/dividend-yield/ranking.ts +21 -12
  266. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  267. package/src/plugins/builtin/dividend-yield/view.ts +8 -4
  268. package/src/plugins/builtin/docs/use-docs.ts +4 -2
  269. package/src/plugins/builtin/doe/headless.ts +2 -1
  270. package/src/plugins/builtin/doe/model.ts +12 -11
  271. package/src/plugins/builtin/earnings/board-model.ts +14 -8
  272. package/src/plugins/builtin/earnings/board-table.ts +13 -8
  273. package/src/plugins/builtin/earnings/calendar-model.ts +5 -5
  274. package/src/plugins/builtin/earnings/calendar.tsx +2 -1
  275. package/src/plugins/builtin/earnings/format.ts +16 -14
  276. package/src/plugins/builtin/earnings/headless.ts +57 -19
  277. package/src/plugins/builtin/earnings/history-model.ts +11 -7
  278. package/src/plugins/builtin/earnings/history-table.ts +22 -9
  279. package/src/plugins/builtin/earnings/history.tsx +4 -3
  280. package/src/plugins/builtin/earnings-calls/calendar.tsx +2 -1
  281. package/src/plugins/builtin/earnings-calls/format.ts +6 -5
  282. package/src/plugins/builtin/earnings-calls/upcoming.ts +5 -5
  283. package/src/plugins/builtin/earnings-ripple/headless.ts +2 -1
  284. package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
  285. package/src/plugins/builtin/earnings-ripple/model.ts +3 -2
  286. package/src/plugins/builtin/earnings-ripple/pane.tsx +6 -6
  287. package/src/plugins/builtin/econ/calendar-model.ts +19 -3
  288. package/src/plugins/builtin/econ/detail-view.tsx +2 -2
  289. package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
  290. package/src/plugins/builtin/econ/index.tsx +7 -6
  291. package/src/plugins/builtin/econ-statistics/detail.tsx +2 -1
  292. package/src/plugins/builtin/econ-statistics/headless.ts +25 -4
  293. package/src/plugins/builtin/econ-statistics/pane.tsx +2 -2
  294. package/src/plugins/builtin/equity-screener/headless.ts +5 -5
  295. package/src/plugins/builtin/equity-screener/model.ts +6 -4
  296. package/src/plugins/builtin/equity-screener/pane.tsx +7 -7
  297. package/src/plugins/builtin/equity-screener/screen-check.ts +2 -1
  298. package/src/plugins/builtin/equity-screener/ticker-check.tsx +2 -1
  299. package/src/plugins/builtin/estimate-revisions/model.ts +3 -2
  300. package/src/plugins/builtin/estimate-revisions/pane.tsx +8 -8
  301. package/src/plugins/builtin/executives/format.ts +4 -4
  302. package/src/plugins/builtin/exposure/headless.ts +8 -8
  303. package/src/plugins/builtin/exposure/model.ts +4 -3
  304. package/src/plugins/builtin/exposure/pane.tsx +6 -5
  305. package/src/plugins/builtin/fear-greed/format.ts +7 -7
  306. package/src/plugins/builtin/fear-greed/headless.ts +2 -1
  307. package/src/plugins/builtin/filing-events/feed.ts +2 -1
  308. package/src/plugins/builtin/futures/table.tsx +8 -8
  309. package/src/plugins/builtin/futures-curve/headless.ts +18 -18
  310. package/src/plugins/builtin/futures-curve/model.ts +5 -5
  311. package/src/plugins/builtin/futures-curve/pane.tsx +8 -8
  312. package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
  313. package/src/plugins/builtin/fx-matrix/pairs.ts +2 -1
  314. package/src/plugins/builtin/gpu/board.tsx +6 -5
  315. package/src/plugins/builtin/gpu/changes.tsx +2 -1
  316. package/src/plugins/builtin/gpu/equities.tsx +2 -2
  317. package/src/plugins/builtin/gpu/headless.ts +4 -3
  318. package/src/plugins/builtin/gpu/model.ts +8 -7
  319. package/src/plugins/builtin/help/functions-table.tsx +41 -9
  320. package/src/plugins/builtin/help/index.tsx +6 -3
  321. package/src/plugins/builtin/help/keybindings-editor.tsx +35 -7
  322. package/src/plugins/builtin/help/shortcut-table.tsx +19 -7
  323. package/src/plugins/builtin/help/table-cells.tsx +51 -0
  324. package/src/plugins/builtin/holders/pane.tsx +4 -1
  325. package/src/plugins/builtin/insider/base-values.ts +2 -2
  326. package/src/plugins/builtin/insider/display.ts +2 -1
  327. package/src/plugins/builtin/insider/headless.ts +16 -16
  328. package/src/plugins/builtin/insider/insider-data.ts +2 -1
  329. package/src/plugins/builtin/insider/signals-model.ts +3 -3
  330. package/src/plugins/builtin/insider/table-model.ts +27 -13
  331. package/src/plugins/builtin/insider/table.tsx +1 -1
  332. package/src/plugins/builtin/ipo-calendar/model.ts +4 -4
  333. package/src/plugins/builtin/iv-history/format.ts +8 -7
  334. package/src/plugins/builtin/iv-history/headless.ts +9 -8
  335. package/src/plugins/builtin/iv-history/pane.tsx +3 -2
  336. package/src/plugins/builtin/iv-history/screen-pane.tsx +5 -4
  337. package/src/plugins/builtin/jobs/headless.ts +11 -11
  338. package/src/plugins/builtin/jobs/model.ts +2 -2
  339. package/src/plugins/builtin/jobs/pane.tsx +5 -5
  340. package/src/plugins/builtin/jodi/model.ts +2 -2
  341. package/src/plugins/builtin/jodi/pane.tsx +2 -1
  342. package/src/plugins/builtin/kelly-sizer/headless.ts +4 -4
  343. package/src/plugins/builtin/kelly-sizer/model.ts +2 -1
  344. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -2
  345. package/src/plugins/builtin/macro-day/headless.ts +27 -15
  346. package/src/plugins/builtin/macro-day/model.ts +42 -4
  347. package/src/plugins/builtin/macro-day/pane.tsx +30 -12
  348. package/src/plugins/builtin/macro-day/releases.ts +24 -1
  349. package/src/plugins/builtin/market-halts/model.ts +11 -10
  350. package/src/plugins/builtin/market-halts/pane.tsx +2 -1
  351. package/src/plugins/builtin/market-heatmap/index.tsx +4 -4
  352. package/src/plugins/builtin/market-movers/session-table.ts +3 -3
  353. package/src/plugins/builtin/market-movers/session.ts +2 -1
  354. package/src/plugins/builtin/market-movers/table.ts +5 -5
  355. package/src/plugins/builtin/market-valuation/detail.tsx +2 -2
  356. package/src/plugins/builtin/market-valuation/headless.ts +7 -7
  357. package/src/plugins/builtin/market-valuation/pane.tsx +7 -7
  358. package/src/plugins/builtin/members/breadth-pane.tsx +5 -4
  359. package/src/plugins/builtin/members/headless.ts +2 -1
  360. package/src/plugins/builtin/members/model.ts +3 -2
  361. package/src/plugins/builtin/members/pane.tsx +10 -9
  362. package/src/plugins/builtin/mna/distress/model.ts +2 -1
  363. package/src/plugins/builtin/mna/model.ts +5 -5
  364. package/src/plugins/builtin/money-markets/client.ts +4 -1
  365. package/src/plugins/builtin/money-markets/headless.ts +17 -5
  366. package/src/plugins/builtin/money-markets/index.tsx +1 -1
  367. package/src/plugins/builtin/money-markets/model.ts +3 -2
  368. package/src/plugins/builtin/money-markets/pane.tsx +11 -5
  369. package/src/plugins/builtin/news/headless.ts +5 -2
  370. package/src/plugins/builtin/news/wire/breaking/notifications.ts +21 -19
  371. package/src/plugins/builtin/news/wire/news/row.ts +3 -1
  372. package/src/plugins/builtin/news/wire/news/table.tsx +3 -2
  373. package/src/plugins/builtin/news/wire/persisted-articles.ts +28 -3
  374. package/src/plugins/builtin/notes/headless.ts +2 -1
  375. package/src/plugins/builtin/notes/model.ts +2 -1
  376. package/src/plugins/builtin/openfda/pane.tsx +4 -3
  377. package/src/plugins/builtin/options/carry.ts +3 -2
  378. package/src/plugins/builtin/options/market-reference.ts +2 -1
  379. package/src/plugins/builtin/options/table.ts +48 -9
  380. package/src/plugins/builtin/options/view.tsx +47 -17
  381. package/src/plugins/builtin/options-calculator/headless.ts +3 -2
  382. package/src/plugins/builtin/options-calculator/pane.tsx +7 -7
  383. package/src/plugins/builtin/options-positioning/headless.ts +8 -7
  384. package/src/plugins/builtin/options-positioning/model.ts +10 -10
  385. package/src/plugins/builtin/options-positioning/pane.tsx +5 -5
  386. package/src/plugins/builtin/options-scenario/collar.ts +5 -4
  387. package/src/plugins/builtin/options-scenario/csp-screen-headless.ts +11 -10
  388. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +15 -14
  389. package/src/plugins/builtin/options-scenario/csp-screen.ts +2 -1
  390. package/src/plugins/builtin/options-scenario/csp.ts +6 -5
  391. package/src/plugins/builtin/options-scenario/headless.ts +6 -5
  392. package/src/plugins/builtin/options-scenario/hedge.ts +3 -3
  393. package/src/plugins/builtin/options-scenario/pane.tsx +7 -6
  394. package/src/plugins/builtin/options-scenario/strategy-screen.ts +1 -1
  395. package/src/plugins/builtin/pe-band/headless.ts +9 -8
  396. package/src/plugins/builtin/pe-band/pane.tsx +7 -7
  397. package/src/plugins/builtin/perps/cascade.ts +3 -2
  398. package/src/plugins/builtin/perps/headless.ts +10 -9
  399. package/src/plugins/builtin/perps/model.ts +14 -14
  400. package/src/plugins/builtin/perps/pane.tsx +3 -2
  401. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
  402. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
  403. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
  404. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -0
  405. package/src/plugins/builtin/portfolio-list/header.tsx +2 -2
  406. package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
  407. package/src/plugins/builtin/portfolio-list/index.tsx +3 -2
  408. package/src/plugins/builtin/portfolio-list/pane/futures-terms.ts +4 -2
  409. package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -3
  410. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +26 -7
  411. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +4 -2
  412. package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
  413. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -2
  414. package/src/plugins/builtin/portfolio-list/settings.ts +4 -1
  415. package/src/plugins/builtin/portfolio-list/summary/index.tsx +8 -5
  416. package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
  417. package/src/plugins/builtin/portfolio-list/table.tsx +25 -15
  418. package/src/plugins/builtin/power/detail.tsx +6 -5
  419. package/src/plugins/builtin/power/gas-model.ts +8 -7
  420. package/src/plugins/builtin/power/gas.tsx +2 -1
  421. package/src/plugins/builtin/power/headless.ts +7 -6
  422. package/src/plugins/builtin/power/model.ts +3 -2
  423. package/src/plugins/builtin/power/prices-headless.ts +10 -9
  424. package/src/plugins/builtin/power/prices-model.ts +3 -2
  425. package/src/plugins/builtin/power/prices.tsx +2 -1
  426. package/src/plugins/builtin/primary-dealers/model.ts +3 -3
  427. package/src/plugins/builtin/primary-dealers/pane.tsx +2 -2
  428. package/src/plugins/builtin/rate-path/headless.ts +8 -7
  429. package/src/plugins/builtin/rate-path/model.ts +6 -5
  430. package/src/plugins/builtin/rate-path/pane.tsx +6 -5
  431. package/src/plugins/builtin/realized-vol/fx-proxy.ts +2 -1
  432. package/src/plugins/builtin/realized-vol/headless.ts +11 -10
  433. package/src/plugins/builtin/realized-vol/pane.tsx +5 -4
  434. package/src/plugins/builtin/relative-rotation/headless.ts +2 -1
  435. package/src/plugins/builtin/relative-rotation/pane.tsx +6 -6
  436. package/src/plugins/builtin/research/analyst-headless.ts +5 -5
  437. package/src/plugins/builtin/research/analyst-model.ts +7 -7
  438. package/src/plugins/builtin/research/analyst-pane.tsx +7 -7
  439. package/src/plugins/builtin/research/client.ts +14 -0
  440. package/src/plugins/builtin/research/corporate-actions-pane.tsx +40 -30
  441. package/src/plugins/builtin/research/event-model.ts +55 -22
  442. package/src/plugins/builtin/research/event-sources.ts +26 -8
  443. package/src/plugins/builtin/research/relative-valuation-columns.ts +20 -12
  444. package/src/plugins/builtin/research/relative-valuation-currency.ts +16 -0
  445. package/src/plugins/builtin/research/relative-valuation-headless.ts +33 -21
  446. package/src/plugins/builtin/research/relative-valuation-model.ts +31 -17
  447. package/src/plugins/builtin/research/relative-valuation-pane.tsx +29 -14
  448. package/src/plugins/builtin/research-search/model.ts +2 -1
  449. package/src/plugins/builtin/research-search/saved-view.tsx +4 -3
  450. package/src/plugins/builtin/revenue-breakdown/model.ts +4 -4
  451. package/src/plugins/builtin/reverse-dcf/headless.ts +7 -7
  452. package/src/plugins/builtin/reverse-dcf/model.ts +4 -4
  453. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -2
  454. package/src/plugins/builtin/scanner/flow-model.ts +7 -4
  455. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  456. package/src/plugins/builtin/scanner/headless.ts +3 -2
  457. package/src/plugins/builtin/scanner/hilo-model.ts +2 -1
  458. package/src/plugins/builtin/scanner/live-headless.ts +2 -2
  459. package/src/plugins/builtin/scanner/live-model.ts +3 -2
  460. package/src/plugins/builtin/scanner/live-pane.tsx +5 -5
  461. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  462. package/src/plugins/builtin/seasonality/pane.tsx +4 -3
  463. package/src/plugins/builtin/sec/filing-display.tsx +12 -15
  464. package/src/plugins/builtin/sec/fund-facts.ts +2 -2
  465. package/src/plugins/builtin/sec/headless.ts +2 -1
  466. package/src/plugins/builtin/sec/index.tsx +6 -2
  467. package/src/plugins/builtin/sectors/headless.ts +4 -4
  468. package/src/plugins/builtin/sectors/index.tsx +7 -7
  469. package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
  470. package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
  471. package/src/plugins/builtin/shared/earnings-calendar.ts +90 -6
  472. package/src/plugins/builtin/shared/earnings-report.ts +13 -6
  473. package/src/plugins/builtin/shared/research-cells.tsx +2 -2
  474. package/src/plugins/builtin/shared/source-footer.ts +2 -1
  475. package/src/plugins/builtin/shared/trend.ts +2 -2
  476. package/src/plugins/builtin/shared/use-quote-board.ts +9 -8
  477. package/src/plugins/builtin/short-interest/headless.ts +6 -6
  478. package/src/plugins/builtin/short-interest/model.ts +9 -9
  479. package/src/plugins/builtin/short-interest/publications-model.ts +5 -5
  480. package/src/plugins/builtin/short-interest/publications-pane.tsx +3 -2
  481. package/src/plugins/builtin/short-interest/watch-headless.ts +5 -5
  482. package/src/plugins/builtin/short-interest/watch-pane.tsx +6 -6
  483. package/src/plugins/builtin/short-volume/model.ts +5 -5
  484. package/src/plugins/builtin/short-volume/pane.tsx +4 -4
  485. package/src/plugins/builtin/social-mentions/headless.ts +2 -1
  486. package/src/plugins/builtin/social-mentions/model.ts +4 -4
  487. package/src/plugins/builtin/supply-chain/graph-model.ts +2 -1
  488. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -2
  489. package/src/plugins/builtin/supply-chain/headless.ts +3 -2
  490. package/src/plugins/builtin/supply-chain/model.ts +4 -4
  491. package/src/plugins/builtin/supply-chain/pane.tsx +2 -2
  492. package/src/plugins/builtin/supply-chain/row-evidence.tsx +2 -1
  493. package/src/plugins/builtin/themes/headless.ts +2 -1
  494. package/src/plugins/builtin/themes/model.ts +3 -2
  495. package/src/plugins/builtin/themes/pane.tsx +3 -2
  496. package/src/plugins/builtin/thirteenf/format.ts +9 -9
  497. package/src/plugins/builtin/thirteenf/headless.ts +3 -2
  498. package/src/plugins/builtin/thirteenf/model.ts +2 -1
  499. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +2 -1
  500. package/src/plugins/builtin/thirteenf/pane.tsx +5 -4
  501. package/src/plugins/builtin/thirteenf/report-notes.ts +2 -1
  502. package/src/plugins/builtin/thirteenf/signals-pane.tsx +3 -2
  503. package/src/plugins/builtin/thirteenf/table.ts +6 -5
  504. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
  505. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -3
  506. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +4 -4
  507. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +3 -3
  508. package/src/plugins/builtin/ticker-detail/financials/model.ts +83 -35
  509. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -1
  510. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +2 -2
  511. package/src/plugins/builtin/ticker-detail/financials/schema.ts +14 -18
  512. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +8 -13
  513. package/src/plugins/builtin/ticker-detail/headless.ts +33 -6
  514. package/src/plugins/builtin/ticker-detail/overview/chart-scale.ts +52 -0
  515. package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -9
  516. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -14
  517. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +6 -0
  518. package/src/plugins/builtin/ticker-detail/overview/tax-equivalent.ts +2 -1
  519. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +43 -9
  520. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +7 -5
  521. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +4 -4
  522. package/src/plugins/builtin/ticker-detail/settings.ts +17 -0
  523. package/src/plugins/builtin/time-sales/headless.ts +3 -2
  524. package/src/plugins/builtin/time-sales/model.ts +7 -5
  525. package/src/plugins/builtin/time-sales/pane.tsx +7 -6
  526. package/src/plugins/builtin/trace-bonds/model.ts +3 -2
  527. package/src/plugins/builtin/trace-bonds/pane.tsx +3 -2
  528. package/src/plugins/builtin/treasury-auctions/client.ts +2 -1
  529. package/src/plugins/builtin/treasury-auctions/headless.ts +6 -6
  530. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +3 -2
  531. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +10 -9
  532. package/src/plugins/builtin/treasury-auctions/hk.ts +5 -5
  533. package/src/plugins/builtin/treasury-auctions/model.ts +4 -4
  534. package/src/plugins/builtin/treasury-auctions/pane.tsx +18 -18
  535. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -1
  536. package/src/plugins/builtin/treasury-daily/model.ts +2 -2
  537. package/src/plugins/builtin/vol-surface/events.ts +5 -4
  538. package/src/plugins/builtin/vol-surface/headless.ts +19 -18
  539. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  540. package/src/plugins/builtin/vol-surface/pane.tsx +8 -7
  541. package/src/plugins/builtin/vol-surface/stored.ts +2 -1
  542. package/src/plugins/builtin/vol-surface/tables.ts +4 -3
  543. package/src/plugins/builtin/volatility/headless.ts +5 -4
  544. package/src/plugins/builtin/volatility/pane.tsx +6 -6
  545. package/src/plugins/builtin/world-indices/headless.ts +7 -7
  546. package/src/plugins/builtin/world-indices/index.tsx +3 -1
  547. package/src/plugins/builtin/world-venue-map/headless.ts +2 -1
  548. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +2 -1
  549. package/src/plugins/builtin/world-venue-map/layers.ts +3 -2
  550. package/src/plugins/builtin/world-venue-map/use-geo.ts +4 -2
  551. package/src/plugins/builtin/yield-curve/curves.ts +3 -3
  552. package/src/plugins/builtin/yield-curve/headless.ts +7 -6
  553. package/src/plugins/builtin/yield-curve/index.tsx +5 -4
  554. package/src/plugins/builtin/yield-curve/swaps.tsx +2 -1
  555. package/src/portfolio/allocation.ts +5 -5
  556. package/src/portfolio/collection-name.ts +2 -1
  557. package/src/portfolio/column-values.ts +61 -45
  558. package/src/portfolio/futures-positions.ts +2 -1
  559. package/src/portfolio/listed-symbol.ts +4 -2
  560. package/src/portfolio/period-pnl.ts +51 -1
  561. package/src/renderers/dom/dialog-host.tsx +5 -5
  562. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +7 -1
  563. package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
  564. package/src/renderers/opentui/dialog-host.tsx +3 -4
  565. package/src/renderers/opentui/ui-host.tsx +32 -2
  566. package/src/renderers/share/layout-view.tsx +2 -1
  567. package/src/sources/gloomberb-cloud/news.ts +9 -0
  568. package/src/sources/gloomberb-cloud/normalizers.ts +7 -0
  569. package/src/sources/provider-router/history.ts +5 -2
  570. package/src/sources/provider-router/search.ts +15 -10
  571. package/src/state/hooks/inline-tickers.ts +3 -2
  572. package/src/state/hooks/quote-streaming.ts +9 -10
  573. package/src/team/collections-sync.ts +8 -3
  574. package/src/telemetry/usage-counts.ts +26 -0
  575. package/src/test-support/plugin-persistence.ts +12 -0
  576. package/src/tickers/company-name-listing.ts +6 -5
  577. package/src/tickers/company-name.ts +36 -2
  578. package/src/tickers/instrument-coverage.ts +27 -0
  579. package/src/tickers/listing-venues.ts +26 -1
  580. package/src/tickers/renamed-listings.ts +2 -1
  581. package/src/tickers/search/home-listing.ts +38 -1
  582. package/src/tickers/search/index.ts +22 -2
  583. package/src/tickers/search/ranking.ts +21 -2
  584. package/src/tickers/starter-symbols.ts +7 -0
  585. package/src/time-series/base-series.ts +4 -0
  586. package/src/time-series/fundamentals/statement-fields.ts +11 -14
  587. package/src/time-series/history-acquisition.ts +1 -1
  588. package/src/time-series/log-scale.ts +9 -0
  589. package/src/time-series/reporting.ts +3 -3
  590. package/src/time-series/resolve.ts +6 -4
  591. package/src/time-series/transforms.ts +10 -5
  592. package/src/time-series/types.ts +5 -2
  593. package/src/types/config.ts +9 -0
  594. package/src/types/data-provider.ts +3 -2
  595. package/src/types/financials.ts +28 -0
  596. package/src/types/headless.ts +2 -0
  597. package/src/types/instrument.ts +6 -0
  598. package/src/types/plugin-panes.ts +1 -1
  599. package/src/types/plugin-reports.ts +8 -0
  600. package/src/ui/dialog-stack.ts +17 -0
  601. package/src/ui/dialog.tsx +6 -2
  602. package/src/utils/crypto-pair.ts +9 -0
  603. package/src/utils/datetime-format.ts +74 -33
  604. package/src/utils/exchanges.ts +13 -0
  605. package/src/utils/financial-statements.ts +98 -17
  606. package/src/utils/format.ts +4 -9
  607. package/src/utils/fundamentals.ts +38 -16
  608. package/src/utils/futures-generic.ts +14 -0
  609. package/src/utils/growth.ts +67 -0
  610. package/src/utils/keyboard.ts +6 -0
  611. package/src/utils/options.ts +1 -1
  612. package/src/utils/report-timing.ts +2 -2
  613. package/src/utils/served-rates.ts +45 -0
  614. package/src/utils/text-wrap.ts +84 -3
  615. package/src/utils/trailing-dividend.ts +13 -3
  616. package/src/utils/zoned-date-time.ts +47 -22
@@ -58,6 +58,34 @@ export interface PeriodPnlRow {
58
58
  contribution: number | null;
59
59
  }
60
60
 
61
+ /**
62
+ * One currency's part of the book over the period: its holdings' price P&L
63
+ * (local), its move on their start value (FX), the two together, and the
64
+ * total's share of the book. Over the holdings that have both closes, as the
65
+ * book's total is; `unpriced` names the ones it leaves out.
66
+ */
67
+ export interface PeriodCurrencyPnl {
68
+ /** The major currency its holdings are priced in: GBP for a price in pence. */
69
+ currency: string;
70
+ /** The book's own currency, which has no FX line. */
71
+ own: boolean;
72
+ /**
73
+ * The holdings' price P&L, in the book's currency at the end's rate. Each
74
+ * figure is null when every holding in the currency is left out: there is
75
+ * nothing to add up, which is not a P&L of 0.
76
+ */
77
+ local: number | null;
78
+ /** The currency's move on the holdings' start value; 0 in the book's currency. */
79
+ fx: number | null;
80
+ total: number | null;
81
+ /** Each over the book's contribution base, in percent. */
82
+ localContribution: number | null;
83
+ fxContribution: number | null;
84
+ contribution: number | null;
85
+ /** Its holdings without a close at one end of the window or a rate: left out of the figures. */
86
+ unpriced: string[];
87
+ }
88
+
61
89
  export interface PeriodPnl {
62
90
  rows: PeriodPnlRow[];
63
91
  /** The FX line: every holding's currency move, together. */
@@ -75,6 +103,8 @@ export interface PeriodPnl {
75
103
  contributionBasis: "net" | "gross";
76
104
  /** Holdings without a close at one end of the window, or without a rate for their currency. */
77
105
  unpriced: string[];
106
+ /** The book by the currency its holdings are priced in: the book's own first, then the others by code. */
107
+ currencies: PeriodCurrencyPnl[];
78
108
  }
79
109
 
80
110
  const finite = (value: number | null | undefined): value is number => value != null && Number.isFinite(value);
@@ -117,5 +147,25 @@ export function periodPnl(holdings: readonly PeriodPnlHolding[], bookCurrency: s
117
147
  const fx = rows.reduce((sum, row) => sum + (finite(row.fx) ? row.fx : 0), 0);
118
148
  const total = rows.reduce((sum, row) => sum + (finite(row.pnl) && finite(row.fx) ? row.pnl + row.fx : 0), 0);
119
149
  const share = (value: number) => contributionBase ? (value / contributionBase) * 100 : null;
120
- return { rows, fx, fxContribution: share(fx), total, totalContribution: share(total), contributionBase, contributionBasis: shorts ? "gross" : "net", unpriced };
150
+ // Each holding counts under the major currency it converts through, priced or not, so a part that leaves one out says so.
151
+ const groups = new Map<string, { currency: string; own: boolean; counted: number; local: number; fx: number; unpriced: string[] }>();
152
+ for (const row of rows) {
153
+ const { currency, own } = periodCurrency(row.currency, bookCurrency);
154
+ const key = own ? heldCurrencyUnit(bookCurrency).currency || bookCurrency : currency;
155
+ const group = groups.get(key) ?? { currency: key, own, counted: 0, local: 0, fx: 0, unpriced: [] };
156
+ groups.set(key, group);
157
+ if (finite(row.pnl) && finite(row.fx)) {
158
+ group.counted += 1;
159
+ group.local += row.pnl;
160
+ group.fx += row.fx;
161
+ } else {
162
+ group.unpriced.push(row.symbol);
163
+ }
164
+ }
165
+ const currencies = [...groups.values()]
166
+ .map(({ currency, own, counted, local, fx, unpriced }): PeriodCurrencyPnl => counted === 0
167
+ ? { currency, own, local: null, fx: null, total: null, localContribution: null, fxContribution: null, contribution: null, unpriced }
168
+ : { currency, own, local, fx, total: local + fx, localContribution: share(local), fxContribution: share(fx), contribution: share(local + fx), unpriced })
169
+ .sort((a, b) => Number(b.own) - Number(a.own) || a.currency.localeCompare(b.currency));
170
+ return { rows, fx, fxContribution: share(fx), total, totalContribution: share(total), contributionBase, contributionBasis: shorts ? "gross" : "net", unpriced, currencies };
121
171
  }
@@ -1,12 +1,12 @@
1
1
  /** @jsxImportSource react */
2
2
  import { useEffect, useRef, type ReactNode } from "react";
3
- import { DialogHostProvider } from "../../ui/dialog";
3
+ import { DialogHostProvider, type DialogOptions } from "../../ui/dialog";
4
4
  import {
5
5
  bridgeDialogContent,
6
6
  DialogBridgeRegistrationProvider,
7
7
  useDialogBridgeSlot,
8
8
  } from "../../ui/dialog-bridge";
9
- import { useDialogStack } from "../../ui/dialog-stack";
9
+ import { closesOnClickOutside, useDialogStack } from "../../ui/dialog-stack";
10
10
  import { blendHex } from "../../theme/colors";
11
11
  import { useThemeColors } from "../../theme/theme-context";
12
12
  import { isEditableTarget, isInsideDialogSurface } from "./host/focus-scope";
@@ -14,7 +14,7 @@ import { isEditableTarget, isInsideDialogSurface } from "./host/focus-scope";
14
14
  interface DialogState {
15
15
  id: string;
16
16
  content: ReactNode | ((context: { dialogId: string; dismiss(): void; resolve(value: unknown): void }) => ReactNode);
17
- closeOnClickOutside: boolean;
17
+ closeOnClickOutside: DialogOptions["closeOnClickOutside"];
18
18
  returnFocus: HTMLElement | null;
19
19
  }
20
20
 
@@ -42,7 +42,7 @@ export function WebDialogHostProvider({ children }: { children: ReactNode }) {
42
42
  return {
43
43
  id,
44
44
  content: options.content as DialogState["content"],
45
- closeOnClickOutside: options.closeOnClickOutside === true,
45
+ closeOnClickOutside: options.closeOnClickOutside,
46
46
  returnFocus,
47
47
  };
48
48
  },
@@ -99,7 +99,7 @@ export function WebDialogHostProvider({ children }: { children: ReactNode }) {
99
99
  data-topmost={isTopmost ? "true" : "false"}
100
100
  onMouseDown={(event) => {
101
101
  if (event.target !== event.currentTarget) return;
102
- if (isTopmost && dialogState.closeOnClickOutside) {
102
+ if (isTopmost && closesOnClickOutside(dialogState.closeOnClickOutside)) {
103
103
  close(dialogState.id, undefined);
104
104
  return;
105
105
  }
@@ -12,6 +12,7 @@ import type {
12
12
  DesktopCoreRequest,
13
13
  } from "../../shared/protocol";
14
14
  import { encodeRpcValue } from "../../shared/rpc-codec";
15
+ import { logFailure } from "../../../../utils/log-failure";
15
16
  import { desktopBootFramePath, removeDesktopBootFrame } from "../window/boot-frame";
16
17
  import { MAIN_WINDOW_RPC_KEY, paneIdFromDetachedRpcKey } from "../window/focus";
17
18
  import type { DesktopBackend, DesktopRpc } from "./backend";
@@ -52,7 +53,12 @@ export async function handleDesktopBackendRequest(
52
53
  request.payload.channel === "nightly" ? "nightly" : "stable",
53
54
  );
54
55
  case "update.start":
55
- void desktopUpdater.download(request.payload.release, (progress) => sendUpdateProgress(rpc, progress));
56
+ // The download reports its failures as progress. One that escapes it ends
57
+ // the same way, so the window does not wait on a download that stopped.
58
+ desktopUpdater.download(request.payload.release, (progress) => sendUpdateProgress(rpc, progress)).catch((error: unknown) => {
59
+ logFailure("desktop-update", "Desktop update download failed")(error);
60
+ sendUpdateProgress(rpc, { phase: "error", error: "Desktop update failed" });
61
+ });
56
62
  return null;
57
63
  case "update.apply":
58
64
  // Only the main window offers Restart; a popped-out window never relaunches the app.
@@ -42,7 +42,7 @@ export function createCapabilityInvoker(options: {
42
42
  ? withDeadline(
43
43
  request,
44
44
  options.timeoutMs,
45
- `Asset data request timed out after ${options.timeoutMs}ms: ${operationId}`,
45
+ `Asset data request timed out after ${options.timeoutMs}ms`,
46
46
  )
47
47
  : request;
48
48
  if (!invokeOptions.signal) {
@@ -17,7 +17,7 @@ import {
17
17
  useDialogBridgeSlot,
18
18
  type DialogContentBridge,
19
19
  } from "../../ui/dialog-bridge";
20
- import { useDialogStack, type DialogKind } from "../../ui/dialog-stack";
20
+ import { closesOnClickOutside, useDialogStack, type DialogKind } from "../../ui/dialog-stack";
21
21
 
22
22
  interface DialogRecord {
23
23
  id: string;
@@ -26,7 +26,7 @@ interface DialogRecord {
26
26
  size?: DialogOptions["size"];
27
27
  style?: DialogStyle;
28
28
  closeOnEscape?: boolean;
29
- closeOnClickOutside?: boolean;
29
+ closeOnClickOutside?: DialogOptions["closeOnClickOutside"];
30
30
  }
31
31
 
32
32
  function renderDialogContent(content: unknown, context: AlertContext | PromptContext<unknown>): ReactNode {
@@ -82,7 +82,6 @@ function DialogLayer({
82
82
  ? Math.max(1, Math.min(style.maxHeight, viewportHeight))
83
83
  : viewportHeight;
84
84
  const closeOnEscape = dialog.closeOnEscape ?? true;
85
- const closeOnClickOutside = dialog.closeOnClickOutside ?? false;
86
85
  const zIndex = 9_998 + index * 2;
87
86
 
88
87
  useKeyboard((event) => {
@@ -124,7 +123,7 @@ function DialogLayer({
124
123
  alignItems="center"
125
124
  justifyContent="center"
126
125
  onMouseDown={() => {
127
- if (isTopmost && closeOnClickOutside) close(dialog.id);
126
+ if (isTopmost && closesOnClickOutside(dialog.closeOnClickOutside)) close(dialog.id);
128
127
  }}
129
128
  >
130
129
  <box
@@ -175,6 +175,33 @@ const OpenTuiScrollBox = forwardRef<unknown, OpenTuiPrimitiveProps>(function Ope
175
175
  });
176
176
  const OpenTuiInputPrimitive = createOpenTuiPrimitive("input");
177
177
 
178
+ /**
179
+ * A field's placeholder in the terminal's dim role: faint as well as in the
180
+ * placeholder colour, so an example value (`10`, `USD`) does not read as one
181
+ * typed, nor as the hint under the field in the same muted colour (review,
182
+ * 12 Nov 2026: AP's placeholders and hints were one grey). The desktop draws
183
+ * its placeholder inside a sunken field and keeps the colour alone.
184
+ */
185
+ function dimPlaceholder(props: OpenTuiPrimitiveProps): OpenTuiPrimitiveProps {
186
+ const { placeholder, placeholderColor } = props as { placeholder?: unknown; placeholderColor?: unknown };
187
+ if (typeof placeholder !== "string" || placeholder.length === 0) return props;
188
+ // One styled text per placeholder and colour, so a re-render does not hand the field a new one to apply.
189
+ const key = `${typeof placeholderColor === "string" ? placeholderColor : ""}\u0000${placeholder}`;
190
+ let styled = dimPlaceholders.get(key);
191
+ if (!styled) {
192
+ if (dimPlaceholders.size >= 256) dimPlaceholders.clear();
193
+ styled = new OpenTuiStyledText([{
194
+ __isChunk: true,
195
+ text: withoutControlCharacters(placeholder),
196
+ fg: typeof placeholderColor === "string" ? RGBA.fromHex(placeholderColor) : undefined,
197
+ attributes: OpenTuiTextAttributes.DIM,
198
+ }] as any);
199
+ dimPlaceholders.set(key, styled);
200
+ }
201
+ return { ...props, placeholder: styled };
202
+ }
203
+ const dimPlaceholders = new Map<string, OpenTuiStyledText>();
204
+
178
205
  interface PasteEventLike {
179
206
  bytes: Uint8Array;
180
207
  }
@@ -188,7 +215,7 @@ interface PasteEventLike {
188
215
  const OpenTuiInput = forwardRef<unknown, OpenTuiPrimitiveProps>(function OpenTuiInput({ joinPastedLines: join, onPaste, ...props }, ref) {
189
216
  const handlePaste = typeof onPaste === "function" ? onPaste as (event: PasteEventLike) => void : null;
190
217
  return createElement(OpenTuiInputPrimitive, {
191
- ...props,
218
+ ...dimPlaceholder(props),
192
219
  ref,
193
220
  onPaste: join === true || join === "list" || handlePaste
194
221
  ? (event: PasteEventLike) => {
@@ -198,7 +225,10 @@ const OpenTuiInput = forwardRef<unknown, OpenTuiPrimitiveProps>(function OpenTui
198
225
  : undefined,
199
226
  });
200
227
  });
201
- const OpenTuiTextarea = createOpenTuiPrimitive("textarea");
228
+ const OpenTuiTextareaPrimitive = createOpenTuiPrimitive("textarea");
229
+ const OpenTuiTextarea = forwardRef<unknown, OpenTuiPrimitiveProps>(function OpenTuiTextarea(props, ref) {
230
+ return createElement(OpenTuiTextareaPrimitive, { ...dimPlaceholder(props), ref });
231
+ });
202
232
  const OpenTuiMediaSurface = createOpenTuiPrimitive("box");
203
233
 
204
234
  const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
@@ -1,4 +1,5 @@
1
1
  /** @jsxImportSource react */
2
+ import { formatShortDate } from "../../utils/datetime-format";
2
3
  import type { CSSProperties } from "react";
3
4
  import type { DockLayoutNode, PaneInstanceConfig } from "../../types/config";
4
5
  import type { LayoutMarketplaceEntry } from "../../shares/portable-layout";
@@ -79,7 +80,7 @@ function formatDate(value: string): string {
79
80
  const date = new Date(value);
80
81
  return Number.isNaN(date.getTime())
81
82
  ? ""
82
- : date.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
83
+ : formatShortDate(date);
83
84
  }
84
85
 
85
86
  export function LayoutShareView({
@@ -82,6 +82,14 @@ function mapCloudNewsStoryItem(
82
82
  };
83
83
  }
84
84
 
85
+ /** A folded row's notices, when the service says how many (two or more) and since when. */
86
+ function routineNotices(payload: CloudNewsPayload["routine"]): NewsArticle["routine"] | null {
87
+ if (!payload || !Number.isInteger(payload.notices) || payload.notices < 2) return null;
88
+ const since = new Date(payload.since);
89
+ if (Number.isNaN(since.getTime())) return null;
90
+ return { kind: payload.kind, notices: payload.notices, since, programme: payload.programme ?? null };
91
+ }
92
+
85
93
  export function mapCloudNewsArticle(
86
94
  item: CloudNewsPayload,
87
95
  fallbackTicker?: string,
@@ -124,6 +132,7 @@ export function mapCloudNewsArticle(
124
132
  isDeveloping: !!item.flags?.developing,
125
133
  sourceCount: item.sourceCount,
126
134
  items: item.items?.map(mapCloudNewsStoryItem) ?? [],
135
+ ...(routineNotices(item.routine) ? { routine: routineNotices(item.routine)! } : {}),
127
136
  };
128
137
  }
129
138
 
@@ -124,6 +124,8 @@ export function mapQuote(
124
124
  delisting: parseListingDelisting(quote.delisting),
125
125
  intradayBar: readIntradayBar(quote.intradayBar),
126
126
  staleReason: readStaleReason(quote.staleReason),
127
+ // An exchange's name, shown as the quote's source: nothing longer or stranger is.
128
+ priceVenue: typeof quote.priceVenue === "string" && /^[A-Za-z][A-Za-z0-9 .-]{0,23}$/.test(quote.priceVenue) ? quote.priceVenue : undefined,
127
129
  priceBasis,
128
130
  priceObservation,
129
131
  currency: currency || quote.currency,
@@ -143,6 +145,9 @@ export function mapQuote(
143
145
  low52w: normalizePriceValueByDivisor(quote.low52w, divisor),
144
146
  // The service read the 52-week range from its stored daily bars, its source's being unusable.
145
147
  yearRangeBasis: quote.yearRangeBasis === "daily-bars" ? "daily-bars" : undefined,
148
+ // What a coin's day range and volume measure: the composite's, or one exchange's own day.
149
+ statsBasis: quote.statsBasis === "composite" || quote.statsBasis === "exchange" ? quote.statsBasis : undefined,
150
+ rangeWidened: quote.rangeWidened === true ? true : undefined,
146
151
  // No live quote: the close of the latest daily bar of this session.
147
152
  dailyClose: readDailyClose(quote.dailyClose),
148
153
  bid: normalizePriceValueByDivisor(quote.bid, divisor),
@@ -300,6 +305,8 @@ export function mapPricePoint(
300
305
  ...(point.partial === true ? { partial: true } : {}),
301
306
  ...(point.filled === true ? { filled: true } : {}),
302
307
  ...(point.unsettled === true ? { unsettled: true } : {}),
308
+ ...(point.sessionClose === true ? { sessionClose: true } : {}),
309
+ ...(point.beforeClose === true ? { beforeClose: true } : {}),
303
310
  ...(typeof point.rescaled === "number" && Number.isFinite(point.rescaled) && point.rescaled > 0 && point.rescaled !== 1
304
311
  ? { rescaled: point.rescaled } : {}),
305
312
  ...(typeof point.contract === "string" && FUTURES_CONTRACT_CODE.test(point.contract) ? { contract: point.contract } : {}),
@@ -779,8 +779,11 @@ export class ProviderRouterHistoryRoutes {
779
779
  if (behind) throw new Error(`Latest history for ${target.symbol} is behind`);
780
780
  // A reason the service gave ("ADX listings have daily bars only.") says why; one that has no
781
781
  // listing for the symbol says it is not a ticker; otherwise no source answered. A coin trades
782
- // around the clock and its sources are there: they could not answer just now.
783
- throw noProviderError(coin ? `No source could load history for ${request.target.symbol} just now` : request.missingProviderError,
782
+ // around the clock and its sources are there: they could not answer just now. So could a
783
+ // source that failed (a timeout, a 5xx) rather than had nothing: that is no listing without
784
+ // history, and never reads as one ("No history provider available").
785
+ const failed = coin || attempts.misses.failure !== undefined;
786
+ throw noProviderError(failed ? `No source could load history for ${request.target.symbol} just now` : request.missingProviderError,
784
787
  attempts.misses, request.target.symbol);
785
788
  }
786
789
  // A window of dates no source could answer, because one failed rather than had nothing, is that failure:
@@ -12,11 +12,16 @@ const SEARCH_CACHE_MAX_ENTRIES = 100;
12
12
 
13
13
  const SEARCH_PROVIDER_TIMEOUT_MS = 5_000;
14
14
  /**
15
- * A keystroke path cannot wait the batch budget on a source that is failing
15
+ * A keystroke path cannot wait the batch budget on a broker that is failing
16
16
  * slowly. A broker whose gateway is down is the common case, and five seconds
17
- * of it is indistinguishable from the feature being broken.
17
+ * of it is indistinguishable from the feature being broken. A data provider
18
+ * keeps the batch budget: its answer is the search's, and one that takes a
19
+ * second (a name it has not searched lately, a client far from it) given up
20
+ * leaves the person with no rows, or with only another spelling's (HSB-C for
21
+ * "hsbc", which it reads as a ticker and answers without HSBC's Hong Kong
22
+ * 0005).
18
23
  */
19
- const INTERACTIVE_SEARCH_TIMEOUT_MS = 800;
24
+ const INTERACTIVE_BROKER_SEARCH_TIMEOUT_MS = 800;
20
25
 
21
26
  interface BrokerSearchCandidate {
22
27
  brokerId: string;
@@ -154,8 +159,8 @@ export class ProviderRouterSearchRoutes {
154
159
  ): { first: Promise<InstrumentSearchResult[]>; settled: Promise<void> } {
155
160
  const results: InstrumentSearchResult[] = [];
156
161
  const resultIndexByKey = new Map<string, number>();
157
- const timeoutMs = context?.interactive
158
- ? INTERACTIVE_SEARCH_TIMEOUT_MS
162
+ const brokerTimeoutMs = context?.interactive
163
+ ? INTERACTIVE_BROKER_SEARCH_TIMEOUT_MS
159
164
  : SEARCH_PROVIDER_TIMEOUT_MS;
160
165
 
161
166
  const cacheResults = (ttl = SEARCH_CACHE_TTL_MS) => {
@@ -196,7 +201,7 @@ export class ProviderRouterSearchRoutes {
196
201
  try {
197
202
  const items = await settleWithin(
198
203
  candidate.broker.searchInstruments!(query, candidate.instance),
199
- timeoutMs,
204
+ brokerTimeoutMs,
200
205
  );
201
206
  record(items && annotateBrokerSearchResults(items, candidate));
202
207
  } catch (error) {
@@ -206,15 +211,15 @@ export class ProviderRouterSearchRoutes {
206
211
 
207
212
  const searchProvider = (provider: DataProvider) => (async () => {
208
213
  try {
209
- record(await withDeadline(provider.search(query, context), timeoutMs, `${provider.id} search timed out`));
214
+ record(await withDeadline(provider.search(query, context), SEARCH_PROVIDER_TIMEOUT_MS, `${provider.id} search timed out`));
210
215
  } catch (error) {
211
216
  const timedOut = error instanceof OperationTimeoutError;
212
217
  if (isNetworkFailure(error)) {
213
218
  unreachable ??= error;
214
- } else if (isProviderBusy(error) || (timedOut && !context?.interactive)) {
215
- // A keystroke gives up on a slow source by design and asks again on the next one; only a full wait is busy.
219
+ } else if (isProviderBusy(error) || timedOut) {
220
+ // Its full budget waited out: no answer, which is not one that found nothing.
216
221
  busy = true;
217
- } else if (!timedOut && shouldLogProviderError(error)) {
222
+ } else if (shouldLogProviderError(error)) {
218
223
  this.deps.logProviderError(`${provider.id} failed: ${error}`);
219
224
  }
220
225
  }
@@ -133,10 +133,11 @@ let pendingQuoteBatch: { requests: Map<string, QuoteRequest>; promise: Promise<v
133
133
  function queueQuoteLoad(symbol: string, request: QuoteRequest): Promise<void> {
134
134
  if (!pendingQuoteBatch) {
135
135
  const requests = new Map<string, QuoteRequest>();
136
- const promise = new Promise<void>((resolve) => {
136
+ // A batch that fails rejects for every badge in it, which records the failure.
137
+ const promise = new Promise<void>((resolve, reject) => {
137
138
  setTimeout(() => {
138
139
  pendingQuoteBatch = null;
139
- void loadInlineQuotes(requests).finally(resolve);
140
+ loadInlineQuotes(requests).then(resolve, reject);
140
141
  }, 0);
141
142
  });
142
143
  pendingQuoteBatch = { requests, promise };
@@ -250,26 +250,25 @@ export function useQuoteUpdates(
250
250
  const schedule = (delayMs: number) => {
251
251
  timer = setTimeout(() => {
252
252
  timer = null;
253
- void refresh();
253
+ refresh();
254
254
  }, Math.max(0, delayMs));
255
255
  };
256
- const refresh = async () => {
256
+ // A poll nobody waits on: a failed one is logged and the next comes on schedule.
257
+ const refresh = () => {
257
258
  if (cancelled) return;
258
259
  schedule(pollIntervalMs);
259
260
  if (inFlight) return;
260
261
  inFlight = true;
261
262
  lastPollRef.current = { key: instrumentKey, at: Date.now() };
262
- try {
263
- await coordinator.loadQuotesBatch(instruments, { forceRefresh: true });
264
- } catch (error) {
265
- logFailure("state.hooks.quote-streaming", "Polling broker quotes failed")(error);
266
- } finally {
267
- inFlight = false;
268
- }
263
+ coordinator.loadQuotesBatch(instruments, { forceRefresh: true })
264
+ .catch(logFailure("state.hooks.quote-streaming", "Polling broker quotes failed"))
265
+ .finally(() => {
266
+ inFlight = false;
267
+ });
269
268
  };
270
269
  const last = lastPollRef.current;
271
270
  const dueIn = last?.key === instrumentKey ? last.at + pollIntervalMs - Date.now() : 0;
272
- if (dueIn <= 0) void refresh();
271
+ if (dueIn <= 0) refresh();
273
272
  else schedule(dueIn);
274
273
  return () => {
275
274
  cancelled = true;
@@ -107,7 +107,7 @@ export function useTeamCollectionsSync(host: Omit<TeamCollectionsHost, "dispatch
107
107
  }
108
108
  };
109
109
 
110
- const refresh = async () => {
110
+ const pullCollections = async () => {
111
111
  if (!apiClient.isVerified()) return;
112
112
  const currentTeams = teamStore.getSnapshot().teams;
113
113
  const lists = await Promise.all(currentTeams.map((team) => apiClient.listTeamCollections(team.id).catch(logFailure("team.collections-sync", "Listing team collections failed", null))));
@@ -123,6 +123,11 @@ export function useTeamCollectionsSync(host: Omit<TeamCollectionsHost, "dispatch
123
123
  });
124
124
  await applyCollections(teamIds, collections);
125
125
  };
126
+ // Nothing waits on a refresh: one that fails (a ticker that cannot be saved)
127
+ // is logged, and the next sign-in or team change pulls again.
128
+ const refresh = () => {
129
+ pullCollections().catch(logFailure("team.collections-sync", "Refreshing team collections failed"));
130
+ };
126
131
 
127
132
  const applyEvent = async (event: TeamCollectionEvent) => {
128
133
  if (event.change === "created" || event.change === "updated") {
@@ -206,9 +211,9 @@ export function useTeamCollectionsSync(host: Omit<TeamCollectionsHost, "dispatch
206
211
 
207
212
  const teamKey = teams.map((team) => team.id).join(",");
208
213
  useEffect(() => {
209
- void refresh();
214
+ refresh();
210
215
  const unsubscribeUser = apiClient.subscribeCurrentUser(() => {
211
- void refresh();
216
+ refresh();
212
217
  });
213
218
  const unsubscribeEvents = apiClient.subscribeCloudEvent("collection.updated", (data) => {
214
219
  void applyEvent(data as TeamCollectionEvent);
@@ -241,6 +241,32 @@ export function recordRestoredFunctions(fns: readonly UsageFunction[]): void {
241
241
  }
242
242
  }
243
243
 
244
+ /** The install as its usage counts name it: the random install id, the surface and the OS. */
245
+ export interface UsageInstall {
246
+ installId: string;
247
+ surface: UsageCountsSurface;
248
+ os?: string;
249
+ }
250
+
251
+ /**
252
+ * The install as usage counts report it, for what else the Usage setting
253
+ * covers that is filed under the install id (an install experiment, see
254
+ * api-client/install-experiments.ts). Null while nothing can be sent: no
255
+ * host yet, Usage counts off, or no install id. Never throws.
256
+ */
257
+ export async function usageInstall(): Promise<UsageInstall | null> {
258
+ try {
259
+ const current = host;
260
+ if (!current || !current.isEnabled()) return null;
261
+ const installId = await current.getInstallId();
262
+ if (!installId) return null;
263
+ return { installId, surface: current.surface, ...(current.os ? { os: current.os } : {}) };
264
+ } catch (error) {
265
+ logFailure("telemetry-usage-counts", "Could not read the install id")(error);
266
+ return null;
267
+ }
268
+ }
269
+
244
270
  /** Installs the surface's host and schedules what was counted before it. */
245
271
  export function installUsageCounter(next: UsageCounterHost): () => void {
246
272
  host = next;
@@ -1,6 +1,17 @@
1
1
  import type { PersistedResourceValue } from "../types/persistence";
2
2
  import type { PluginPersistence } from "../types/plugin";
3
3
 
4
+ /**
5
+ * A mid-morning UTC moment for a test to hold the clock at (`setSystemTime`),
6
+ * when it reads the time of day off a copy `seedResource` saved: that copy is
7
+ * dated a minute before the clock, so in the first minute of a day it is from
8
+ * the day before and reads with its date ("saved copy from 13 Nov 23:59")
9
+ * instead of "saved copy from 23:59". Its minutes and seconds are ones no time
10
+ * zone's midnight falls on, so the minute before it is never another day's
11
+ * wherever the test runs.
12
+ */
13
+ export const SAVED_COPY_TEST_NOW = Date.parse("2026-11-13T10:17:42Z");
14
+
4
15
  export class MemoryPluginPersistence implements PluginPersistence {
5
16
  private readonly state = new Map<string, { schemaVersion: number; value: unknown }>();
6
17
  private readonly resources = new Map<string, PersistedResourceValue<unknown>>();
@@ -83,6 +94,7 @@ export class MemoryPluginPersistence implements PluginPersistence {
83
94
  provenance?: unknown;
84
95
  } = {},
85
96
  ): void {
97
+ // A minute back: see SAVED_COPY_TEST_NOW for what a test that reads this copy's time of day holds the clock for.
86
98
  const now = Date.now();
87
99
  this.resources.set(this.resourceKey(kind, key, options.sourceKey), {
88
100
  value,
@@ -5,7 +5,7 @@ import type { InstrumentSearchResult } from "../types/instrument";
5
5
  import { canonicalExchange, isUsEquityExchange, isUsListingExchange, parsePublicTickerKey } from "../utils/exchanges";
6
6
  import { companyLines, companyNameExtraWords, companyNameMatch, foldNameLetters, namedByService, runTogether, sameCompany, shortCompanyName } from "./company-name";
7
7
  import { LISTING_SEARCH_LIMIT } from "./search";
8
- import { lineDistance, primaryCompanyLine } from "./search/home-listing";
8
+ import { isFundReceipt, lineDistance, primaryCompanyLine } from "./search/home-listing";
9
9
  import { classifyInstrumentKind, isCryptoInstrumentType } from "./search/ranking";
10
10
  import { isProviderBusy, type ProviderBusyError } from "../sources/provider-errors";
11
11
  import { readTerminalListingCode, type TerminalListing, type TerminalListingCode } from "./terminal-codes";
@@ -64,8 +64,8 @@ const NOT_COMMON = /preferred|warrant|right|unit|note|bond|debenture/i;
64
64
  */
65
65
  const DEBT_NAME = /\d(?:[.,]\d+)?\s?%|\bsubordinated\b|\b(?:notes?|bonds?|debentures?)\s+due\b|\bdue\s+(?:\d{1,2}\s+\p{L}+\s+)?(?:19|20)\d{2}\b/iu;
66
66
 
67
- /** Whether a search row is a bond, by its type or by its name. */
68
- function isDebtLine(type: string, name: string | null | undefined): boolean {
67
+ /** Whether a search row is a bond or another line that is not the common share, by its type or by its name. */
68
+ export function isDebtLine(type: string, name: string | null | undefined): boolean {
69
69
  return NOT_COMMON.test(type) || DEBT_NAME.test(name ?? "");
70
70
  }
71
71
 
@@ -178,8 +178,9 @@ function rankCompanyLines(name: string, results: readonly InstrumentSearchResult
178
178
  || parsePublicTickerKey(result.symbol).exchange) return [];
179
179
  // A word alone names a company by these lines only; the company's other lines are still its lines.
180
180
  const namesCompany = !(options.oneWord && (match.abbreviated > 0 || isCryptoInstrumentType(type) || !(order === 0 || named || match.extra === 0)));
181
- // A receipt is a company's shares too, however search types it ("Depositary Receipt" or "American Depositary Receipt").
182
- const stock = classifyInstrumentKind(type) === "equity" || RECEIPT.test(type) ? 0 : 1;
181
+ // A receipt is a company's shares too, however search types it ("Depositary Receipt" or "American Depositary Receipt"),
182
+ // unless it is one on a fund search lists under its name: the Tracker Fund's Thai receipt is the fund's line.
183
+ const stock = RECEIPT.test(type) ? (isFundReceipt(result, results) ? 1 : 0) : classifyInstrumentKind(type) === "equity" ? 0 : 1;
183
184
  const home = result.homeListing === true;
184
185
  const line = home ? 0 : 1 + lineDistance(type, exchange, result.symbol);
185
186
  return [{
@@ -31,9 +31,14 @@ const NAME_NOISE = new Set([
31
31
  "anonim", "sirketi", "ortakligi",
32
32
  ]);
33
33
  // Turkish legal forms short enough to open another company's name (AO Smith, AO World): a legal form only as its last word.
34
- const LAST_WORD_NOISE = new Set(["ao", "tas"]);
34
+ // So is a partnership limited by shares (Hermès International SCA), whatever a venue spells out.
35
+ const LAST_WORD_NOISE = new Set(["ao", "tas", "sca"]);
36
+ // A legal form a venue spells out in words that are no legal form alone: Hermès International Société en commandite par actions.
37
+ const SPELLED_SCA = /\bsociete en commandite par actions\b/g;
35
38
  // Words a venue adds to the share it lists ("Microsoft Corporation Common Stock"), never part of whose it is.
36
- const SHARE_NOISE = new Set(["common", "ordinary", "stock", "shares"]);
39
+ const SHARE_NOISE = new Set(["common", "ordinary", "stock", "shares", "share"]);
40
+ // A venue's short form of a share class word, read as the word: "Volkswagen AG Pref. Share" in Zurich is its "Preferred Stock".
41
+ const SHARE_WORD_FORMS: Readonly<Record<string, string>> = { pref: "preferred", pfd: "preferred" };
37
42
 
38
43
  /** A company's name for comparing its listings: "Kotobuki Spirits Co., Ltd." is "kotobuki spirits". */
39
44
  function companyKey(name: string): string {
@@ -41,7 +46,9 @@ function companyKey(name: string): string {
41
46
  .replace(/\([^)]*\)/g, " ")
42
47
  .replace(/\b(?:(?:american|global) )?depositary (?:shares?|receipts?)\b/g, " ")
43
48
  .replace(/\./g, "")
49
+ .replace(SPELLED_SCA, "sca")
44
50
  .split(/[^\p{L}\p{N}]+/u)
51
+ .map((word) => SHARE_WORD_FORMS[word] ?? word)
45
52
  .filter((word) => word && !NAME_NOISE.has(word));
46
53
  // The last word before any share wording, never a name's only one.
47
54
  let last = words.length - 1;
@@ -77,6 +84,19 @@ export function sameCompany(left: string | null | undefined, right: string | nul
77
84
  return [...fewer].every((word) => more.has(word));
78
85
  }
79
86
 
87
+ /**
88
+ * Whether two names are one company's name however each venue writes the legal
89
+ * form and the share wording: "Deutsche Post AG" and "Deutsche Post" are, "DHL
90
+ * Express" and "DHL" are not (`sameCompany` would read them as one, since one
91
+ * name's words are all in the other's). For a name the data service gives a
92
+ * company besides its own (a former name, a trade name), which a line is told
93
+ * by only when it is exactly that name. An empty name matches none.
94
+ */
95
+ export function sameCompanyName(left: string | null | undefined, right: string | null | undefined): boolean {
96
+ const a = companyKey(left ?? "");
97
+ return a !== "" && a === companyKey(right ?? "");
98
+ }
99
+
80
100
  // Words that tell one class of a company's shares from another ("Berkshire Hathaway Inc. Class B"), never its business.
81
101
  const SHARE_CLASS_WORD = /^(?:class|series|[a-z]|\d+)$/;
82
102
 
@@ -317,6 +337,20 @@ function nameWord(word: string, opening: boolean, domain: boolean): string {
317
337
  return `${word.charAt(0)}${word.slice(1).toLowerCase()}`;
318
338
  }
319
339
 
340
+ /**
341
+ * The name a company is introduced by beside its lines on other venues
342
+ * ("Prudential plc trades on HKEX as 2378:HKEX", "HSBC Holdings plc also
343
+ * lists 0005:HKEX"): the name its home line is listed under, which tells
344
+ * Prudential plc from Prudential Financial, else its issuer's, cased. Without
345
+ * the comma or the full stop a listing's name can carry beside its legal form:
346
+ * "HSBC Holdings, plc." is HSBC Holdings plc.
347
+ */
348
+ export function companyLinesName(listedName: string | null | undefined, issuerName: string): string {
349
+ return (listedName?.trim() || companyNameCase(issuerName))
350
+ .replace(/,\s*(?=(?:plc|inc|ltd|limited|corp|sa|ag|nv|se)\b)/i, " ")
351
+ .replace(/\.$/, "");
352
+ }
353
+
320
354
  /**
321
355
  * A company name a source writes in capitals (an ETF's holdings file: "APPLE INC", "MERCK & CO INC") as it is
322
356
  * normally written: "Apple Inc", "Merck & Co Inc". Legal forms and short words take their usual case, initials