@gloom-sh/terminal 0.20.17 → 0.20.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +3 -2
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/app/global-shortcuts.ts +5 -3
  13. package/src/app/pro-welcome/keys.ts +27 -0
  14. package/src/app/pro-welcome/model.ts +158 -0
  15. package/src/app/pro-welcome/row.tsx +176 -0
  16. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  17. package/src/app/runtime/external-profile-changes.ts +135 -0
  18. package/src/app.tsx +33 -2
  19. package/src/architecture/core-builtin-allowlist.json +1 -1
  20. package/src/architecture/floating-promise-allowlist.json +0 -1
  21. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  22. package/src/cli/alert-listing.ts +98 -0
  23. package/src/cli/commands/market.ts +138 -22
  24. package/src/cli/commands/overview.ts +7 -1
  25. package/src/cli/commands/plugins.ts +3 -2
  26. package/src/cli/commands/search.ts +30 -6
  27. package/src/cli/context.ts +16 -5
  28. package/src/cli/csv-export.ts +2 -1
  29. package/src/cli/desktop-pane-shot.ts +72 -9
  30. package/src/cli/glossary.ts +64 -10
  31. package/src/cli/history-demergers.ts +117 -0
  32. package/src/cli/history-rows.ts +6 -2
  33. package/src/cli/index.ts +1 -0
  34. package/src/cli/known-gaps.ts +16 -0
  35. package/src/cli/known-us-stocks.ts +18 -0
  36. package/src/cli/listing-arg.ts +105 -15
  37. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  38. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  39. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  40. package/src/cli/pane-functions/catalog.ts +50 -16
  41. package/src/cli/pane-functions/data.ts +16 -4
  42. package/src/cli/pane-functions/dom.ts +24 -6
  43. package/src/cli/pane-functions/freshness.ts +17 -1
  44. package/src/cli/pane-functions/index.ts +100 -42
  45. package/src/cli/pane-functions/resolver.ts +8 -5
  46. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  47. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  48. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  49. package/src/cli/quote-answer.ts +32 -16
  50. package/src/cli/registry.ts +22 -2
  51. package/src/cli/result.ts +5 -4
  52. package/src/cli/series-search.ts +45 -6
  53. package/src/cli/shot-temp-dir.ts +4 -9
  54. package/src/components/chart/composite/legend.tsx +43 -18
  55. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  56. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  57. package/src/components/chart-table/header.tsx +9 -0
  58. package/src/components/chart-table/layout.ts +11 -11
  59. package/src/components/command-bar/pane-templates/items.ts +17 -1
  60. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  61. package/src/components/command-bar/routes/root/results.ts +34 -2
  62. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  63. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  64. package/src/components/command-bar/workflow/alert.ts +19 -8
  65. package/src/components/data-table/view.tsx +15 -2
  66. package/src/components/form-modal/content.tsx +9 -4
  67. package/src/components/index.ts +1 -1
  68. package/src/components/layout/header.tsx +9 -5
  69. package/src/components/layout/pane/capture-status.ts +6 -0
  70. package/src/components/layout/pane/footer/index.tsx +2 -0
  71. package/src/components/layout/pane/footer/model.ts +113 -15
  72. package/src/components/layout/pane/header.tsx +16 -2
  73. package/src/components/market-board/index.tsx +4 -2
  74. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  75. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  76. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  77. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  78. package/src/components/onboarding/setup-cards.ts +36 -0
  79. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  80. package/src/components/onboarding/wizard-account.ts +6 -1
  81. package/src/components/onboarding/wizard-model.ts +32 -6
  82. package/src/components/onboarding/wizard-positions.ts +1 -1
  83. package/src/components/sign-in-gate.tsx +3 -1
  84. package/src/components/toggle-list.tsx +6 -8
  85. package/src/components/ui/confirm-dialog.tsx +47 -7
  86. package/src/components/ui/data-table/types.ts +8 -0
  87. package/src/components/ui/display.tsx +17 -2
  88. package/src/components/ui/index.ts +1 -1
  89. package/src/components/ui/stat-grid.tsx +4 -0
  90. package/src/components/ui/status.tsx +13 -1
  91. package/src/components/ui/table-layout.ts +2 -1
  92. package/src/components/use-pane-notice-footer.tsx +16 -3
  93. package/src/data/config/store/index.ts +31 -0
  94. package/src/data/config/store/node.ts +61 -11
  95. package/src/data/config/store/normalize.ts +4 -6
  96. package/src/data/config/store/shared-file.ts +309 -0
  97. package/src/data/profile-merge.ts +299 -0
  98. package/src/data/sqlite/checkpointer.ts +11 -1
  99. package/src/data/sqlite/database.ts +1 -1
  100. package/src/data/ticker-repository.ts +134 -10
  101. package/src/data/ticker-store.ts +67 -0
  102. package/src/data/ticker-writes.ts +5 -0
  103. package/src/i18n/es.ts +27 -0
  104. package/src/i18n/ja.ts +27 -0
  105. package/src/i18n/ko.ts +27 -0
  106. package/src/i18n/zh-cn.ts +27 -0
  107. package/src/i18n/zh-tw.ts +27 -0
  108. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  109. package/src/market-data/ah-pair.ts +103 -0
  110. package/src/market-data/depositary-pair.ts +6 -2
  111. package/src/market-data/hooks.tsx +33 -2
  112. package/src/market-data/market/change-basis.ts +2 -1
  113. package/src/market-data/market/header-market.ts +11 -0
  114. package/src/market-data/split-terms.ts +28 -0
  115. package/src/plugins/builtin/account-management/footer.ts +1 -1
  116. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  117. package/src/plugins/builtin/account-management/model.ts +1 -0
  118. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  119. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  120. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  121. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  122. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  123. package/src/plugins/builtin/alerts/cli.ts +36 -30
  124. package/src/plugins/builtin/alerts/constants.ts +10 -0
  125. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  126. package/src/plugins/builtin/alerts/format.ts +24 -8
  127. package/src/plugins/builtin/alerts/index.tsx +38 -9
  128. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  129. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  130. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  131. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  132. package/src/plugins/builtin/alerts/types.ts +7 -0
  133. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  134. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  135. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  136. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  137. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  139. package/src/plugins/builtin/awards/pane.tsx +1 -1
  140. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  141. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  142. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  143. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  144. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  145. package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
  146. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  147. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  148. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  149. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  150. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  151. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  152. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  153. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  154. package/src/plugins/builtin/composite/application.ts +14 -0
  155. package/src/plugins/builtin/composite/broker.ts +12 -0
  156. package/src/plugins/builtin/composite/credit.ts +33 -0
  157. package/src/plugins/builtin/composite/crypto.ts +10 -0
  158. package/src/plugins/builtin/composite/earnings.ts +12 -0
  159. package/src/plugins/builtin/composite/filings.ts +13 -0
  160. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  161. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  162. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  163. package/src/plugins/builtin/composite/ownership.ts +23 -0
  164. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  165. package/src/plugins/builtin/composite/quant.ts +15 -0
  166. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  167. package/src/plugins/builtin/composite/screeners.ts +11 -0
  168. package/src/plugins/builtin/composite/shared.ts +11 -0
  169. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  170. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  171. package/src/plugins/builtin/correlation/index.tsx +13 -17
  172. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  173. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  174. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  175. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  176. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  177. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  178. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  179. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  180. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  181. package/src/plugins/builtin/earnings/headless.ts +7 -4
  182. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  183. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  184. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  185. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  186. package/src/plugins/builtin/econ/index.tsx +3 -0
  187. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  188. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  189. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  190. package/src/plugins/builtin/exposure/model.ts +10 -0
  191. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  192. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  193. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  194. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  195. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  196. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  197. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  198. package/src/plugins/builtin/mna/detail.tsx +67 -6
  199. package/src/plugins/builtin/mna/headless.ts +128 -13
  200. package/src/plugins/builtin/mna/model.ts +219 -16
  201. package/src/plugins/builtin/mna/pane.tsx +34 -6
  202. package/src/plugins/builtin/money-markets/model.ts +14 -5
  203. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  204. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  205. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  206. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  207. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  208. package/src/plugins/builtin/pe-band/client.ts +13 -1
  209. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  210. package/src/plugins/builtin/pe-band/model.ts +63 -10
  211. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  212. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  213. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  214. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  215. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  216. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  217. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  218. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  219. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  220. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  221. package/src/plugins/builtin/research/event-model.ts +31 -13
  222. package/src/plugins/builtin/research/headless.ts +8 -1
  223. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  224. package/src/plugins/builtin/sectors/index.tsx +6 -9
  225. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  226. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  227. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  228. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  229. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  230. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  231. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  232. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  233. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  234. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  235. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  236. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  237. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  238. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  239. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  240. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  241. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  242. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  243. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  244. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  245. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  246. package/src/plugins/builtin/volatility/model.ts +17 -0
  247. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  248. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  249. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  250. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  251. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  252. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  253. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  254. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  255. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  256. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  257. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  258. package/src/plugins/catalog-data.ts +20 -0
  259. package/src/plugins/catalog-lazy.ts +51 -0
  260. package/src/plugins/catalog-ui.ts +16 -18
  261. package/src/plugins/host-smoke.ts +5 -2
  262. package/src/portfolio/allocation.ts +79 -19
  263. package/src/portfolio/cash-balances.ts +76 -0
  264. package/src/portfolio/mutations.ts +43 -8
  265. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  266. package/src/renderers/desktop/window-layouts.ts +14 -0
  267. package/src/renderers/dom/data-table/row.tsx +2 -0
  268. package/src/renderers/dom/host/tabs.tsx +57 -8
  269. package/src/renderers/dom/styles.css +13 -5
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  272. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  273. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  274. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  275. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  276. package/src/series/standalone-catalog.ts +5 -4
  277. package/src/series/standalone.ts +13 -7
  278. package/src/sources/gloomberb-cloud/index.ts +14 -3
  279. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  280. package/src/sources/provider-router/financials.ts +20 -13
  281. package/src/sources/provider-router/index.ts +4 -0
  282. package/src/sources/provider-router/search.ts +1 -0
  283. package/src/sync/collections-contributor.ts +3 -1
  284. package/src/sync/config-merge.ts +10 -1
  285. package/src/sync/sanitize.ts +26 -2
  286. package/src/tickers/company-name-listing.ts +16 -2
  287. package/src/tickers/listing-fate.ts +12 -8
  288. package/src/tickers/renamed-listings.ts +43 -10
  289. package/src/tickers/search/home-listing.ts +28 -0
  290. package/src/tickers/search/index.ts +19 -7
  291. package/src/tickers/terminal-codes.ts +11 -1
  292. package/src/time-series/resolve.ts +3 -1
  293. package/src/time-series/spec.ts +2 -2
  294. package/src/time-series/types.ts +1 -1
  295. package/src/types/data-provider.ts +11 -0
  296. package/src/types/financials.ts +39 -3
  297. package/src/types/ticker.ts +10 -2
  298. package/src/utils/cli-output.ts +1 -1
  299. package/src/utils/declared-dividends.ts +13 -1
  300. package/src/utils/dividend-cash.ts +5 -1
  301. package/src/utils/forward-dividend.ts +4 -3
  302. package/src/utils/remove-folder.ts +37 -0
  303. package/src/utils/trailing-dividend.ts +1 -1
  304. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -139,7 +139,8 @@ export function assessPaneScreenshot(
139
139
  const unavailableSymbols = usesLiveDomEvidence
140
140
  ? []
141
141
  : shotUnavailableSymbols(resolved, payload, render.semanticUi);
142
- const complete = unavailableSymbols.length === 0;
142
+ const figureGaps = essentialFigureMismatches(render);
143
+ const complete = unavailableSymbols.length === 0 && figureGaps.length === 0 && !render.statusLineClipped;
143
144
  const expectedText = shotExpectedText(resolved, symbols, payload);
144
145
  const normalizedVisibleText = render.visibleText.toLowerCase();
145
146
  const missingExpectedText = expectedText.filter((value) => !shotShowsText(normalizedVisibleText, value));
@@ -156,6 +157,8 @@ export function assessPaneScreenshot(
156
157
  ...paneEvidenceMismatches(resolved, payload, render),
157
158
  ...financialRatioRenderMismatches(resolved, payload, render),
158
159
  ...surfaceNotDrawnMismatches(render),
160
+ ...figureGaps,
161
+ ...(render.statusLineClipped ? ["The as-of status line is clipped."] : []),
159
162
  ];
160
163
  const semanticMismatch = missingExpectedText.length > 0
161
164
  || missingExpectedSelections.length > 0
@@ -309,7 +312,10 @@ const BLANK_COLUMN_MIN_ROWS = 3;
309
312
  * and V/AVG did before the open. A column some rows leave empty is a sparse
310
313
  * marker (an event column), not a blank one, and neither is a column the pane
311
314
  * says can be blank (`mayBeBlank`: a value that comes after an event, such as
312
- * an upcoming report's move); section headers and tables of fewer than
315
+ * an upcoming report's move). A row the pane says is still waiting on the
316
+ * value (a cell's `mayBeBlank`: ECO's ACTUAL before the release) is left out:
317
+ * the column is blank when every other row is, and there are at least
318
+ * BLANK_COLUMN_MIN_ROWS of them. Section headers and tables of fewer than
313
319
  * BLANK_COLUMN_MIN_ROWS rows are not read.
314
320
  */
315
321
  function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "tableIndex" | "cells" | "section">[]): string[] {
@@ -322,18 +328,22 @@ function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "table
322
328
  const blank: string[] = [];
323
329
  for (const tableRows of tables.values()) {
324
330
  if (tableRows.length < BLANK_COLUMN_MIN_ROWS) continue;
325
- const columns = new Map<string, { label: string; placeholders: number; filled: boolean }>();
331
+ const columns = new Map<string, { label: string; placeholders: number; waiting: number; filled: boolean }>();
326
332
  for (const row of tableRows) {
327
333
  for (const cell of row.cells) {
328
334
  const key = cell.columnId ?? cell.columnLabel;
329
- const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, filled: false };
330
- if (PLACEHOLDER_VALUE.test(cell.text.trim()) && !cell.mayBeBlank) column.placeholders += 1;
335
+ const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, waiting: 0, filled: false };
336
+ // A row still waiting on the value (an upcoming release's ACTUAL) is neither a gap nor a value.
337
+ if (cell.mayBeBlank && PLACEHOLDER_VALUE.test(cell.text.trim())) column.waiting += 1;
338
+ else if (PLACEHOLDER_VALUE.test(cell.text.trim())) column.placeholders += 1;
331
339
  else column.filled = true;
332
340
  columns.set(key, column);
333
341
  }
334
342
  }
335
- for (const { label, placeholders, filled } of columns.values()) {
336
- if (!filled && placeholders === tableRows.length && !blank.includes(label)) blank.push(label);
343
+ for (const { label, placeholders, waiting, filled } of columns.values()) {
344
+ // Blank in every row that should have the value, and in enough of them to be no short list's gaps.
345
+ const owed = tableRows.length - waiting;
346
+ if (!filled && owed >= BLANK_COLUMN_MIN_ROWS && placeholders === owed && !blank.includes(label)) blank.push(label);
337
347
  }
338
348
  }
339
349
  return blank;
@@ -434,6 +444,19 @@ function plotsData(node: RemoteUiNodeSnapshot): boolean {
434
444
  return lists.some((list) => list.some((series) => isRecord(series) && typeof series.pointCount === "number" && series.pointCount > 0));
435
445
  }
436
446
 
447
+ export function essentialFigureMismatches(render: Pick<DesktopPaneShotRenderResult, "semanticUi" | "visibleText">): string[] {
448
+ return render.semanticUi.filter((node) => node.role === "figure-layout").flatMap((node) => {
449
+ const metadata = node.metadata;
450
+ if (!isRecord(metadata) || !Array.isArray(metadata.figures) || !Array.isArray(metadata.omitted)) return ["Essential figure evidence is unavailable."];
451
+ const omitted = metadata.omitted;
452
+ return metadata.figures.flatMap((figure) => {
453
+ if (!isRecord(figure) || typeof figure.label !== "string" || typeof figure.value !== "string") return ["Essential figure evidence is invalid."];
454
+ return omitted.includes(figure.label) || !shotShowsText(render.visibleText, figure.label) || !shotShowsText(render.visibleText, figure.value)
455
+ ? [`Essential figure is missing or clipped: ${figure.label}.`] : [];
456
+ });
457
+ });
458
+ }
459
+
437
460
  /**
438
461
  * A 3D surface that is not the real drawing: the frame has no mesh, or the 2D
439
462
  * grid stands in for it. Both are fine for a person using the pane and wrong
@@ -165,6 +165,25 @@ interface ShotSymbolCapture {
165
165
  unread?: { symbol: string; reason: string };
166
166
  tape?: TapeCapture;
167
167
  chain?: [string, OptionsChain];
168
+ /** More than one cadence the pane reads for the row, each answering only its own requests. */
169
+ historyVariants?: NonNullable<SnapshotMarketData["historyVariants"]>;
170
+ }
171
+
172
+ /**
173
+ * PEB reads every week on record and, for the years they are served, the
174
+ * daily closes that price each figure on its day. Captured history answers
175
+ * every request, so the weekly bars would stand in for the daily ones and
176
+ * the capture read the week around each figure's day: each cadence is its
177
+ * own, under the listing the pane asks for. Without daily closes the weekly
178
+ * bars stand alone, as in the app.
179
+ */
180
+ async function peBandHistoryVariants(
181
+ context: MarketContext, ticker: TickerRecord, exchange: string, weekly: TickerFinancials["priceHistory"],
182
+ ): Promise<NonNullable<SnapshotMarketData["historyVariants"]>> {
183
+ const target = { symbol: ticker.metadata.ticker, exchange: ticker.metadata.exchange ?? "" };
184
+ const daily = await (context.dataProvider.getPriceHistoryForResolution?.(target.symbol, exchange, "5Y", "1d", toMarketDataContext(target))
185
+ ?? Promise.resolve([])).catch(logFailure("cli.pane-functions.screenshot-payload", "Read PEB daily closes for a capture failed", []));
186
+ return [{ target, resolution: "1wk", points: weekly ?? [] }, ...(daily.length ? [{ target, resolution: "1d" as const, points: daily }] : [])];
168
187
  }
169
188
 
170
189
  export async function buildDesktopShotPayload(
@@ -348,6 +367,7 @@ export async function buildDesktopShotPayload(
348
367
  if (resolved.pane.id === "time-sales") {
349
368
  capture.tape = [entry.instrument.symbol, exchange, await fetchTape(entry.instrument.symbol, exchange)];
350
369
  }
370
+ if (resolved.pane.id === "pe-band") capture.historyVariants = await peBandHistoryVariants(context, capture.ticker, exchange, data.priceHistory);
351
371
  if (includeOptionsChains && context.dataProvider.getOptionsChain) {
352
372
  // A future with no chain of its own is the pane's to explain (the listed alternative), not a failed shot.
353
373
  const chain = await context.dataProvider.getOptionsChain(entry.instrument.symbol, exchange, undefined,
@@ -425,6 +445,7 @@ export async function buildDesktopShotPayload(
425
445
  }
426
446
  if (capture.tape) tapeSnapshots.push(capture.tape);
427
447
  if (capture.chain) optionsChains.push(capture.chain);
448
+ if (capture.historyVariants?.length) historyVariants = [...historyVariants ?? [], ...capture.historyVariants];
428
449
  }
429
450
  }
430
451
  // PF over a period draws the report's P&L between the two closes: the page reads no history of its own.
@@ -20,6 +20,7 @@ import {
20
20
  deriveCaptureReport,
21
21
  deriveHeadlessFreshness,
22
22
  deriveRenderedFreshness,
23
+ statusDateEvidence,
23
24
  type CaptureReport,
24
25
  type CaptureStatusLine,
25
26
  type ReportFreshness,
@@ -323,7 +324,8 @@ export async function renderDesktopShot({
323
324
  freshness = line.freshness;
324
325
  // A row whose read failed is marked on the picture, where its figures are missing.
325
326
  const unread = unreadRowsNote(shotPayload.unreadRows);
326
- return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates };
327
+ return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates,
328
+ dateEvidence: statusDateEvidence(line.freshness) };
327
329
  },
328
330
  });
329
331
  covered = coverage && await settledWithin(coverage, SHOT_REPORT_WAIT_MS);
@@ -1,4 +1,4 @@
1
- import type { QuoteBatchResult } from "../types/data-provider";
1
+ import type { QuoteBatchOptions, QuoteBatchResult } from "../types/data-provider";
2
2
  import type { Quote } from "../types/financials";
3
3
  import { bareListingNote } from "../tickers/listing-fate";
4
4
  import { isRateLimited, isTransientServiceFailure, notATickerSymbol, rateLimitedError } from "../sources/provider-errors";
@@ -35,13 +35,13 @@ import {
35
35
  tradingBoardNote,
36
36
  type CliListing,
37
37
  type ListingDataRequest,
38
+ type ListingDeps,
38
39
  type ListingVenue,
39
40
  } from "./listing-arg";
40
41
  import { isNotATickerMessage, withListingSuggestion } from "./not-a-ticker";
41
42
  import { notATickerWords } from "./company-name-hint";
42
43
  import { isNetworkFailure } from "../utils/network-failure";
43
44
  import { logFailure } from "../utils/log-failure";
44
- import type { MarketContext } from "./types";
45
45
 
46
46
  /** The text of an error, or null for none. */
47
47
  export function errorMessage(error: unknown): string | null {
@@ -96,7 +96,7 @@ export interface QuoteAnswer {
96
96
  export async function answerQuote(
97
97
  result: QuoteBatchResult,
98
98
  listing: CliListing,
99
- market: MarketContext,
99
+ market: ListingDeps,
100
100
  request: ListingDataRequest,
101
101
  refresh: boolean,
102
102
  venues: Promise<ListingVenue[]> | null,
@@ -209,7 +209,7 @@ export async function answerQuote(
209
209
  * (`.IS`, `.JO`): another one-letter suffix is as likely a US share class
210
210
  * (MKC.V, BRK.B) and keeps its own answer. Null otherwise.
211
211
  */
212
- async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext): Promise<string | null> {
212
+ async function notTradedOnSuffixVenue(listing: CliListing, market: ListingDeps): Promise<string | null> {
213
213
  if (listing.exchange) return null;
214
214
  const suffix = listing.symbol.slice(listing.symbol.lastIndexOf(".") + 1);
215
215
  if (!listing.symbol.includes(".") || (suffix.length < 2 && suffix.toUpperCase() !== "L")) return null;
@@ -231,7 +231,7 @@ async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext
231
231
  async function answerCompanyName(
232
232
  result: QuoteBatchResult,
233
233
  listing: CliListing,
234
- market: MarketContext,
234
+ market: ListingDeps,
235
235
  request: ListingDataRequest,
236
236
  refresh: boolean,
237
237
  datesChangeBasis: boolean,
@@ -261,7 +261,7 @@ async function answerCompanyName(
261
261
  export async function withJoinedCompanyNames(
262
262
  answers: readonly QuoteAnswer[],
263
263
  asked: readonly CliListing[],
264
- market: MarketContext,
264
+ market: ListingDeps,
265
265
  request: ListingDataRequest,
266
266
  refresh: boolean,
267
267
  datesChangeBasis: boolean,
@@ -281,7 +281,7 @@ export async function withJoinedCompanyNames(
281
281
  async function abroadShareClass(
282
282
  listing: CliListing,
283
283
  quote: Quote,
284
- market: MarketContext,
284
+ market: ListingDeps,
285
285
  request: ListingDataRequest,
286
286
  refresh: boolean,
287
287
  datesChangeBasis: boolean,
@@ -297,7 +297,7 @@ async function abroadShareClass(
297
297
  */
298
298
  async function answerNamedListing(
299
299
  named: ListingArg,
300
- market: MarketContext,
300
+ market: ListingDeps,
301
301
  request: ListingDataRequest,
302
302
  refresh: boolean,
303
303
  datesChangeBasis: boolean,
@@ -309,12 +309,28 @@ async function answerNamedListing(
309
309
  });
310
310
  const found = resolved ? { ...resolved, readAs: named.readAs, ...named.meant ? { meant: named.meant } : {}, ...named.readFromName ? { readFromName: named.readFromName } : {},
311
311
  ...named.wordAsName ? { wordAsName: named.wordAsName } : {} } : null;
312
- const [quoted] = found ? await market.dataProvider.getQuotesBatch([found.request], { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : [];
312
+ const quoted = found ? await quoteOne(market, found.request, { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : null;
313
313
  return found && quoted?.quote ? answerQuote(quoted, found, market, request, refresh, null, { datesChangeBasis }) : null;
314
314
  }
315
315
 
316
+ /**
317
+ * One listing's quote as `quote` asks for it: the service's quote of the
318
+ * moment, through the batch request where the provider has one (the app's
319
+ * own provider may not), with why there is none.
320
+ */
321
+ async function quoteOne(deps: ListingDeps, target: { symbol: string; exchange: string }, options: QuoteBatchOptions): Promise<QuoteBatchResult> {
322
+ if (deps.dataProvider.getQuotesBatch) {
323
+ const [result] = await deps.dataProvider.getQuotesBatch([target], options);
324
+ return result ?? { target, quote: null };
325
+ }
326
+ return deps.dataProvider.getQuote(target.symbol, target.exchange, {
327
+ cacheMode: options.forceRefresh ? "refresh" : "default",
328
+ ...(options.datesChangeBasis ? { datesChangeBasis: true } : {}),
329
+ }).then((quote) => ({ target, quote }), (error: unknown) => ({ target, quote: null, error }));
330
+ }
331
+
316
332
  /** A listing a command found a quote for, with what `quote` says beside it. */
317
- interface QuotedListing {
333
+ export interface QuotedListing {
318
334
  /** The listing the quote is of: the one typed, or the venue a bare symbol was quoted on. */
319
335
  listing: CliListing;
320
336
  quote: Quote;
@@ -334,15 +350,15 @@ interface QuotedListing {
334
350
  export async function requireQuotedListing(
335
351
  raw: string,
336
352
  exchange: string | null | undefined,
337
- market: MarketContext,
353
+ market: ListingDeps,
338
354
  ctx: Pick<Parameters<CliCommandDef["execute"]>[1], "fail">,
339
355
  command: string,
340
356
  ): Promise<QuotedListing> {
341
357
  // A word that names a company is read after the quote, as `quote` reads it.
342
358
  const listing = await requireCliListing(raw, exchange, market, ctx, { companyWord: false });
343
359
  const venues = loadBareVenues(listing, market);
344
- const [result] = await market.dataProvider.getQuotesBatch([listing.request], { revalidate: true });
345
- const answer = await answerQuote(result ?? { target: listing.request, quote: null }, listing, market, { command, noun: "quote" }, false, venues);
360
+ const result = await quoteOne(market, listing.request, { revalidate: true });
361
+ const answer = await answerQuote(result, listing, market, { command, noun: "quote" }, false, venues);
346
362
  const quote = answer.result.quote;
347
363
  if (!quote) {
348
364
  if (answer.failure) ctx.fail(answer.failure.message, answer.failure.details);
@@ -375,7 +391,7 @@ export type IndexFormRead = () => Promise<Quote | null>;
375
391
  * goes beside the quote the service has not answered yet instead of after it. A symbol some venue lists asks only
376
392
  * when its answer needs it.
377
393
  */
378
- export function indexFormRead(listing: CliListing, market: MarketContext, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
394
+ export function indexFormRead(listing: CliListing, market: ListingDeps, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
379
395
  if (listing.exchange || listing.saved || !CARETLESS_INDEX.test(listing.symbol) || indexRootFor(listing.symbol)) return null;
380
396
  let read: Promise<Quote | null> | null = null;
381
397
  const start: IndexFormRead = () => read ??= Promise.resolve().then(() => market.dataProvider.getQuote(`^${listing.symbol}`, ""))
@@ -412,7 +428,7 @@ const FIVE_DIGIT_CODE = /^0\d{4}$/;
412
428
  * (Tencent Holdings Limited)". Null for any other symbol, a named or saved
413
429
  * listing, and a code HKEX does not list.
414
430
  */
415
- async function hongKongCodeNote(listing: CliListing, quote: Quote, market: MarketContext): Promise<string | null> {
431
+ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: ListingDeps): Promise<string | null> {
416
432
  if (listing.exchange || listing.saved || !FIVE_DIGIT_CODE.test(listing.symbol)) return null;
417
433
  if (canonicalExchange(quote.listingExchangeName || quote.exchangeName) === "HKEX") return null;
418
434
  const code = String(Number(listing.symbol));
@@ -429,7 +445,7 @@ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: Marke
429
445
  * Naira)?". When search finds nothing near, the row keeps its own error and its
430
446
  * search hint.
431
447
  */
432
- async function withCurrencyPairHint(result: QuoteBatchResult, market: MarketContext): Promise<QuoteBatchResult> {
448
+ async function withCurrencyPairHint(result: QuoteBatchResult, market: ListingDeps): Promise<QuoteBatchResult> {
433
449
  const message = errorMessage(result.error);
434
450
  const symbol = message ? notATickerSymbol(message) : null;
435
451
  if (!message || !symbol || !looksLikeCurrencyPair(symbol)) return result;
@@ -52,6 +52,8 @@ export interface CliCommandRegistry {
52
52
  config: AppConfig | null;
53
53
  /** The plugins that run here: loaded, switched on, and declaring the command line among their targets. */
54
54
  plugins: GloomPlugin[];
55
+ /** The ones of those that contribute data capabilities, which a command reading market data needs without the rest. */
56
+ readonly dataPlugins: GloomPlugin[];
55
57
  readonly idlePlugins: IdleCliPlugin[];
56
58
  externalPlugins: LoadedExternalPlugin[];
57
59
  /** Loads installed contributions when dispatch or application services need them. */
@@ -170,6 +172,10 @@ export function buildCliCommandRegistry({
170
172
  .filter((entry) => !entry.error && !entry.unsupportedTarget && !disabledPlugins.has(entry.plugin.id))
171
173
  .map((entry) => entry.plugin);
172
174
  },
175
+ get dataPlugins() {
176
+ const { getLoadableDataPlugins } = require("../plugins/catalog-data") as typeof import("../plugins/catalog-data");
177
+ return getLoadableDataPlugins(registry.externalPlugins).filter((plugin) => !disabledPlugins.has(plugin.id));
178
+ },
173
179
  get idlePlugins() {
174
180
  const { getPluginCatalog } = require("../plugins/catalog") as typeof import("../plugins/catalog");
175
181
  return getPluginCatalog(registry.externalPlugins).flatMap((entry): IdleCliPlugin[] => {
@@ -196,13 +202,23 @@ export function buildCliCommandRegistry({
196
202
 
197
203
  /** The idle plugins of each command's context, kept off the plugin API's context type. */
198
204
  const idlePluginsByContext = new WeakMap<CliCommandContext, () => IdleCliPlugin[]>();
205
+ /** How many installed plugins a command's context found, loading them first, kept off the plugin API's context type too. */
206
+ const installedPluginCountByContext = new WeakMap<CliCommandContext, () => Promise<number>>();
207
+
208
+ /**
209
+ * How many installed plugins (loaded, failed or switched to other targets) a command has beside the built-in ones.
210
+ * A command that answers from what the built-in plugins declare may do so only when this is none.
211
+ */
212
+ export async function installedPluginCount(ctx: CliCommandContext): Promise<number> {
213
+ return (await installedPluginCountByContext.get(ctx)?.()) ?? 0;
214
+ }
199
215
 
200
216
  /** The installed plugins a command's context does not run (`IdleCliPlugin`); none for a context built without a registry. */
201
217
  export function idleCliPlugins(ctx: CliCommandContext): IdleCliPlugin[] {
202
218
  return idlePluginsByContext.get(ctx)?.() ?? [];
203
219
  }
204
220
 
205
- type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins">>;
221
+ type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins" | "dataPlugins">>;
206
222
 
207
223
  export function createCliCommandContext(
208
224
  ownerId: string,
@@ -217,7 +233,7 @@ export function createCliCommandContext(
217
233
  initConfigData,
218
234
  initMarketData: async () => {
219
235
  await registry.ensureExternalPlugins?.();
220
- return initMarketData({ plugins: registry.plugins });
236
+ return initMarketData({ plugins: () => registry.plugins, ...registry.dataPlugins ? { dataPlugins: registry.dataPlugins } : {} });
221
237
  },
222
238
  initServices: async () => {
223
239
  await registry.ensureExternalPlugins?.();
@@ -240,5 +256,9 @@ export function createCliCommandContext(
240
256
  log: debugLog.createLogger(ownerId === "core" ? "cli" : ownerId),
241
257
  };
242
258
  idlePluginsByContext.set(ctx, () => registry.idlePlugins ?? []);
259
+ installedPluginCountByContext.set(ctx, async () => {
260
+ await registry.ensureExternalPlugins?.();
261
+ return registry.externalPlugins.length;
262
+ });
243
263
  return ctx;
244
264
  }
package/src/cli/result.ts CHANGED
@@ -3,6 +3,7 @@ import type { CliGlobalOptions } from "./options";
3
3
  import {
4
4
  cliPlainEnabled,
5
5
  cliStyles,
6
+ cliText,
6
7
  cliTerminalWidth,
7
8
  renderForFile,
8
9
  renderStats,
@@ -624,7 +625,7 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
624
625
  return withCsvFooter(csv, [...exportSourceLines(cited), ...cutNote, ...(renderOptions.exportNotes ?? []).map((note) => `note: ${note}`)]);
625
626
  }
626
627
  if (renderOptions.text) {
627
- return renderOptions.text(result.data);
628
+ return cliText(renderOptions.text(result.data));
628
629
  }
629
630
  // The heading's lines, the summary and the notes are prose: each wraps to a narrow --width, as the source line does.
630
631
  const summary = wrapToTerminal(renderOptions.summary?.(result.data) ?? "");
@@ -745,12 +746,12 @@ export function printCliResult<T, Row extends Record<string, unknown> = Record<s
745
746
  if (options.format !== "json" && !options.quiet) {
746
747
  // Each wraps to a narrow --width, as a note does.
747
748
  for (const warning of result.warnings ?? []) {
748
- console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(warning)}`));
749
+ console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(cliText(warning))}`));
749
750
  }
750
751
  }
751
- if (!options.quiet) for (const line of footer) console.error(line);
752
+ if (!options.quiet) for (const line of footer) console.error(cliText(line));
752
753
  if (options.format === "ndjson" && !options.quiet) {
753
- for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(`note: ${note}`);
754
+ for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(cliText(`note: ${note}`));
754
755
  }
755
756
  }
756
757
 
@@ -41,11 +41,43 @@ const isWord = (text: string, word: string) => new RegExp(`(^|[^a-z0-9])${escape
41
41
  /** A series whose name, tags and group have every word whole outranks any that has one only as the start of a longer word. */
42
42
  const WHOLE_WORDS_SCORE = 10;
43
43
 
44
+ /** What a catalog search reads of a series: enough to rank and list it, none of the code that loads it. */
45
+ export interface CatalogSeriesFact {
46
+ id: string;
47
+ name: string;
48
+ unit: string;
49
+ frequency: string;
50
+ publisher?: string;
51
+ tags?: readonly string[];
52
+ group?: string;
53
+ description?: string;
54
+ /** What `fn G` charts. */
55
+ expression: string;
56
+ }
57
+
58
+ /**
59
+ * The catalog series the plugins declare, as a search reads them. Series that ask for a ticker are left out; a
60
+ * search names data, not a field of every stock. A formula priced in one delivery month (a crack) charts by its
61
+ * id: its expression alone would mix months.
62
+ */
63
+ export function catalogSeriesFacts(plugins: readonly SeriesSource[]): CatalogSeriesFact[] {
64
+ return plugins.flatMap((plugin) => plugin.series ?? []).flatMap((definition) => definition.input ? [] : [{
65
+ id: definition.id,
66
+ name: definition.name,
67
+ unit: definition.unit,
68
+ frequency: definition.frequency,
69
+ ...definition.publisher ? { publisher: definition.publisher } : {},
70
+ ...definition.tags ? { tags: definition.tags } : {},
71
+ ...definition.group ? { group: definition.group } : {},
72
+ ...definition.description ? { description: definition.description } : {},
73
+ expression: "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition),
74
+ }]);
75
+ }
76
+
44
77
  /**
45
78
  * The plugins' catalog series whose words cover every word of the query: in
46
79
  * the name and tags only for `search`, also the description and publisher for
47
- * `catalog`. Series that ask for a ticker are left out; a search names data,
48
- * not a field of every stock. A query that is a series' id (`policy-rate:ch`),
80
+ * `catalog`. A query that is a series' id (`policy-rate:ch`),
49
81
  * what `fn G` charts (`CAP:policy-rate:ch`, `FRED:DFEDTARU`) or a FRED series
50
82
  * id (`DFEDTARU`) ranks it first, then one whose name, tags and group have
51
83
  * each word whole (`defi` is Total DeFi TVL's tag, before the "deficit" of the
@@ -57,15 +89,22 @@ export function findCatalogSeries(
57
89
  plugins: readonly SeriesSource[],
58
90
  query: string,
59
91
  scope: "names" | "all" = "all",
92
+ ): SeriesMatch[] {
93
+ return findSeriesFacts(catalogSeriesFacts(plugins), query, scope);
94
+ }
95
+
96
+ /** `findCatalogSeries` over series already read as facts. */
97
+ export function findSeriesFacts(
98
+ facts: readonly CatalogSeriesFact[],
99
+ query: string,
100
+ scope: "names" | "all" = "all",
60
101
  ): SeriesMatch[] {
61
102
  const words = query.toLowerCase().replace(/["']/g, "").split(/\s+/).filter(Boolean);
62
103
  if (words.length === 0 || words.join("").length < 3) return [];
63
104
  const phrase = words.join(" ");
64
105
  const ranked: Array<{ match: SeriesMatch; score: number; order: number }> = [];
65
- for (const definition of plugins.flatMap((plugin) => plugin.series ?? [])) {
66
- if (definition.input) continue;
67
- // A formula priced in one delivery month (a crack) charts by its id: its expression alone would mix months.
68
- const expression = "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition);
106
+ for (const definition of facts) {
107
+ const expression = definition.expression;
69
108
  const byId = words.length === 1
70
109
  && [definition.id, expression, fredSeriesIdOf(expression) ?? ""].some((id) => id.toLowerCase() === phrase);
71
110
  const name = definition.name.toLowerCase();
@@ -1,12 +1,8 @@
1
- import { mkdtemp, rm } from "fs/promises";
1
+ import { mkdtemp } from "fs/promises";
2
2
  import { tmpdir } from "os";
3
3
  import { join } from "path";
4
4
  import { logFailure } from "../utils/log-failure";
5
-
6
- type RemoveFolder = (
7
- path: string,
8
- options: { recursive: true; force: true; maxRetries: number; retryDelay: number },
9
- ) => Promise<void>;
5
+ import { removeFolder, type RemoveFolderOptions } from "../utils/remove-folder";
10
6
 
11
7
  /**
12
8
  * Hands `use` a fresh folder under the system temp folder and removes it
@@ -18,13 +14,12 @@ type RemoveFolder = (
18
14
  export async function withShotTempDir<T>(
19
15
  prefix: string,
20
16
  use: (dir: string) => Promise<T>,
21
- remove: RemoveFolder = rm,
17
+ removal: RemoveFolderOptions = {},
22
18
  ): Promise<T> {
23
19
  const dir = await mkdtemp(join(tmpdir(), prefix));
24
20
  try {
25
21
  return await use(dir);
26
22
  } finally {
27
- await remove(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
28
- .catch(logFailure("cli.screenshot", "Could not remove a capture's temporary folder"));
23
+ if (await removeFolder(dir, removal) !== null) logFailure("cli.screenshot", "Could not remove a capture's temporary folder")(null);
29
24
  }
30
25
  }
@@ -15,6 +15,7 @@ import {
15
15
  import type { CompositeChartProps, CompositeChartScene } from "./types";
16
16
  import { DIRECTION_MARKER, seriesColorsDirection, seriesCueCssBackground, type SeriesLineCue } from "./series-cues";
17
17
  import { DisclosureMarker as KitDisclosureMarker } from "../../ui/disclosure-marker";
18
+ import { usePaneCapture } from "../../layout/pane/capture-status";
18
19
 
19
20
  const LEGEND_WHEEL_DELTA_PER_CELL = 8;
20
21
  const NO_LINE_CUES: ReadonlyMap<string, SeriesLineCue> = new Map();
@@ -253,7 +254,7 @@ export function CompositeLegend({
253
254
  cellPlot = false,
254
255
  directionDownColor = null,
255
256
  width,
256
- accessory,
257
+ accessory: liveAccessory,
257
258
  accessoryWidth,
258
259
  formatValue,
259
260
  showLatestChangePercent,
@@ -297,6 +298,7 @@ export function CompositeLegend({
297
298
  /** Folds or opens the legend: a chevron in its inset, shown under the pointer while it is open. */
298
299
  onToggleCollapsed?: () => void;
299
300
  }) {
301
+ const accessory = usePaneCapture() ? null : liveAccessory;
300
302
  const isDesktopWeb = useUiCapabilities().nativePaneChrome === true;
301
303
  const foldKey = useShortcutLabel()("Shift+L");
302
304
  // Folded, the legend keeps its first series; the rest wait behind a count.
@@ -458,6 +460,17 @@ export function CompositeLegend({
458
460
  if (entries.some(({ axisNote }) => axisNote) && minimumWidthOf(entries) > widthBeforeAccessory) {
459
461
  entries = buildEntries(entries.some(({ fiscalPeriod }) => fiscalPeriod), false);
460
462
  }
463
+ if (entries.some((entry) => entry.entry.compactLabel) && measureSeriesWidth() > widthBeforeAccessory) {
464
+ for (const entry of entries) setEntryLabel(entry, entry.compactLabel, displayWidth(entry.compactLabel));
465
+ if (measureSeriesWidth() > widthBeforeAccessory) {
466
+ for (const entry of entries) {
467
+ if (!entry.entry.compactLabel) continue;
468
+ const { name, suffix } = labelParts(entry, entry.compactLabel);
469
+ entry.compactLabel = (nameWords(name)[0] ?? name) + suffix;
470
+ setEntryLabel(entry, entry.compactLabel, displayWidth(entry.compactLabel));
471
+ }
472
+ }
473
+ }
461
474
  const fitsOneLine = minimumWidthOf(entries, true) <= widthBeforeAccessory;
462
475
  // Entries that cannot share a line even with names cut to fragments wrap onto
463
476
  // more lines when the chart gives them room, each whole, its name only cut
@@ -659,24 +672,36 @@ export function CompositeLegend({
659
672
  </Box>
660
673
  );
661
674
  };
662
- const scrollLine = (line: number[] | null, key: string | number, ref: typeof scrollRef | undefined) => (
663
- <ScrollBox
664
- key={key}
665
- ref={ref}
666
- width={seriesWidth}
667
- height={1}
668
- flexShrink={0}
669
- scrollX
670
- focusable={false}
671
- horizontalScrollbarOptions={{ visible: false }}
672
- onMouseScroll={ref ? handleMouseScroll : undefined}
673
- data-gloom-role="composite-chart-legend-scroll"
674
- >
675
- <Box flexDirection="row" width={line ? lineWidth(line) : desiredSeriesWidth} height={1} gap={1}>
676
- {line ? line.map((index) => renderEntry(entries[index]!, index)) : entries.map(renderEntry)}
675
+ const scrollLine = (line: number[] | null, key: string | number, ref: typeof scrollRef | undefined) => {
676
+ const contentWidth = line ? lineWidth(line) : desiredSeriesWidth;
677
+ const count = ref && !collapsed && series.length > 1 && contentWidth > seriesWidth ? `${series.length} series` : "";
678
+ const countWidth = count ? Math.min(seriesWidth, displayWidth(count) + 1) : 0;
679
+ return (
680
+ <Box key={key} flexDirection="row" width={seriesWidth} height={1} flexShrink={0}>
681
+ <ScrollBox
682
+ ref={ref}
683
+ width={Math.max(0, seriesWidth - countWidth)}
684
+ height={1}
685
+ flexShrink={0}
686
+ scrollX
687
+ focusable={false}
688
+ horizontalScrollbarOptions={{ visible: false }}
689
+ onMouseScroll={ref ? handleMouseScroll : undefined}
690
+ data-gloom-role="composite-chart-legend-scroll"
691
+ >
692
+ <Box flexDirection="row" width={contentWidth} height={1} gap={1}>
693
+ {line ? line.map((index) => renderEntry(entries[index]!, index)) : entries.map(renderEntry)}
694
+ </Box>
695
+ </ScrollBox>
696
+ {count ? (
697
+ <Box width={countWidth} height={1} flexShrink={0} paddingLeft={countWidth > displayWidth(count) ? 1 : 0}
698
+ data-gloom-role="composite-chart-legend-count" title={series.map((entry) => entry.label).join(" · ")}>
699
+ <Text fg={themeColors.textDim}>{countWidth < displayWidth(count) ? String(series.length) : count}</Text>
700
+ </Box>
701
+ ) : null}
677
702
  </Box>
678
- </ScrollBox>
679
- );
703
+ );
704
+ };
680
705
  const lineCount = lines?.length ?? 1;
681
706
  const foldLabel = foldedCount > 0
682
707
  ? `Show ${foldedCount} more series (${foldKey})`
@@ -104,7 +104,7 @@ export function PanelPlotSurface({
104
104
  );
105
105
  }
106
106
 
107
- /** A value axis, with the cursor's value on it and, on the desktop, each series' value at the cursor. */
107
+ /** A value axis, with the cursor's value and each series' observation at that time. */
108
108
  export function PanelValueAxis({
109
109
  view,
110
110
  formatAxisValue,
@@ -122,8 +122,8 @@ export function PanelValueAxis({
122
122
  // The pointer's value on the axes follows the level line it belongs to.
123
123
  const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
124
124
  const seriesTags = useMemo(
125
- () => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side) : undefined,
126
- [formatAxisValue, isDesktopWeb, panel, scene, side],
125
+ () => resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side),
126
+ [formatAxisValue, panel, scene, side],
127
127
  );
128
128
  return (
129
129
  <PriceAxisLabels
@@ -37,7 +37,7 @@ interface PriceAxisLabelsProps {
37
37
  axisColor?: string;
38
38
  /** Anchors that stay put while the cursor moves, such as a measure start. */
39
39
  extraMarkers?: readonly PriceAxisMarker[];
40
- /** Desktop/web observations, separate from a drawing tool's endpoint. */
40
+ /** Series observations, separate from a drawing tool's endpoint. */
41
41
  seriesTags?: readonly SeriesAxisTag[];
42
42
  measuredPixelHeight?: number;
43
43
  /** A value axis the pointer stretches and squeezes: a drag or the wheel on it, a double click back. */
@@ -218,18 +218,20 @@ export function PriceAxisLabels({
218
218
  data-gloom-side={side}
219
219
  >
220
220
  {Array.from({ length: height }, (_, row) => {
221
+ const seriesTag = fractionalViewport ? undefined : placedSeriesTags.find((tag) =>
222
+ Math.min(height - 1, Math.floor(tag.centerY / pixelHeight * height)) === row);
221
223
  const isCursorRow = !usePixelOverlay && cursorLabel !== null && cursorRow === row;
222
224
  const marker = usePixelOverlay || usePixelTicks
223
225
  ? undefined
224
226
  : extraMarkers?.find((entry) => entry.row === row);
225
- const label = isCursorRow
227
+ const label = seriesTag?.label ?? (isCursorRow
226
228
  ? cursorLabel
227
- : marker?.label ?? (usePixelTicks || (footButton && row === height - 1) ? null : axisLabels.get(row) ?? null);
229
+ : marker?.label ?? (usePixelTicks || (footButton && row === height - 1) ? null : axisLabels.get(row) ?? null));
228
230
  return (
229
231
  <AxisRow
230
232
  key={row}
231
233
  label={label}
232
- fg={isCursorRow ? cursorColor : marker ? marker.color : axisColor}
234
+ fg={seriesTag?.color ?? (isCursorRow ? cursorColor : marker ? marker.color : axisColor)}
233
235
  side={side}
234
236
  axisWidth={axisWidth}
235
237
  axisSectionWidth={axisSectionWidth}
@@ -271,7 +273,7 @@ export function PriceAxisLabels({
271
273
  {axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
272
274
  </Box>
273
275
  )) : null}
274
- {seriesTags ? <SeriesAxisTags placed={placedSeriesTags} pixelHeight={pixelHeight} lanes={lanes} background={cursorBackgroundColor} /> : null}
276
+ {seriesTags && fractionalViewport ? <SeriesAxisTags placed={placedSeriesTags} pixelHeight={pixelHeight} lanes={lanes} background={cursorBackgroundColor} /> : null}
275
277
  {usePixelOverlay ? (
276
278
  <Box
277
279
  width={axisSectionWidth}