@gloom-sh/terminal 0.20.18 → 0.20.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/src/api-client/cot.ts +5 -6
  3. package/src/api-client/data.ts +11 -1
  4. package/src/api-client/index.ts +1 -0
  5. package/src/api-client/request.ts +162 -40
  6. package/src/api-client/types/news.ts +45 -0
  7. package/src/api-client/types/world-venues.ts +9 -0
  8. package/src/app.tsx +4 -2
  9. package/src/architecture/floating-promise-allowlist.json +1 -1
  10. package/src/cli/commands/market.ts +53 -17
  11. package/src/cli/commands/ticker.ts +13 -6
  12. package/src/cli/context.ts +8 -0
  13. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  14. package/src/cli/desktop-pane-shot-view.ts +0 -1
  15. package/src/cli/desktop-pane-shot.ts +204 -43
  16. package/src/cli/errors.ts +3 -9
  17. package/src/cli/exit-codes.ts +1 -1
  18. package/src/cli/glossary.ts +1 -1
  19. package/src/cli/help.ts +1 -1
  20. package/src/cli/history-rows.ts +2 -2
  21. package/src/cli/index.ts +1 -1
  22. package/src/cli/listing-arg.ts +87 -23
  23. package/src/cli/pane-functions/catalog-snapshot.json +17 -6
  24. package/src/cli/pane-functions/dom.ts +30 -2
  25. package/src/cli/pane-functions/freshness.ts +23 -4
  26. package/src/cli/pane-functions/function-help.ts +3 -3
  27. package/src/cli/pane-functions/headless.ts +9 -1
  28. package/src/cli/pane-functions/index.ts +77 -10
  29. package/src/cli/pane-functions/report-notices.ts +10 -0
  30. package/src/cli/pane-functions/resolver.ts +3 -2
  31. package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
  32. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  33. package/src/cli/pane-functions/screenshot-payload.ts +24 -10
  34. package/src/cli/pane-functions/screenshot-render.ts +21 -8
  35. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  36. package/src/cli/quote-answer.ts +1 -1
  37. package/src/cli/result.ts +17 -0
  38. package/src/cli/scroll-truncation.ts +7 -2
  39. package/src/cli/ticker-resolution.ts +1 -1
  40. package/src/cli/unreachable.ts +21 -0
  41. package/src/components/chart/composite/drawing-store.ts +11 -7
  42. package/src/components/chart/composite/format.ts +1 -0
  43. package/src/components/chart/composite/legend.tsx +5 -2
  44. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  45. package/src/components/chart/composite/panel-surface.tsx +1 -1
  46. package/src/components/chart/composite/tools.ts +164 -39
  47. package/src/components/chart-table/header.tsx +2 -2
  48. package/src/components/chart-table/layout.ts +5 -6
  49. package/src/components/command-bar/routes/root/runtime.ts +11 -3
  50. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  51. package/src/components/command-bar/selection-runtime.ts +29 -5
  52. package/src/components/command-bar/surface/index.tsx +4 -1
  53. package/src/components/command-bar/workflow/alert.ts +13 -5
  54. package/src/components/layout/pane/footer/model.ts +10 -2
  55. package/src/components/layout/pane/status-footer.ts +24 -0
  56. package/src/components/price-performance.tsx +26 -8
  57. package/src/components/reader/article-reader.tsx +12 -5
  58. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  59. package/src/components/ui/table-layout.ts +32 -1
  60. package/src/market-data/ah-pair.ts +19 -0
  61. package/src/market-data/coordinator/entries.ts +6 -4
  62. package/src/market-data/coordinator/index.ts +14 -3
  63. package/src/market-data/futures-board.ts +36 -29
  64. package/src/market-data/futures-contract.ts +37 -1
  65. package/src/market-data/market/change-basis.ts +9 -0
  66. package/src/market-data/market/status.ts +40 -4
  67. package/src/market-data/performance.ts +127 -32
  68. package/src/market-data/quotes/time.ts +5 -2
  69. package/src/news/types.ts +28 -0
  70. package/src/notifications/app-badge.ts +2 -3
  71. package/src/notifications/app-notifier.ts +5 -0
  72. package/src/plugins/builtin/alerts/cli.ts +65 -18
  73. package/src/plugins/builtin/alerts/command.ts +39 -9
  74. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  75. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  76. package/src/plugins/builtin/alerts/headless.ts +12 -6
  77. package/src/plugins/builtin/alerts/index.tsx +60 -8
  78. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  79. package/src/plugins/builtin/alerts/price.ts +30 -5
  80. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  81. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  82. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  83. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  84. package/src/plugins/builtin/analytics/risk-client.ts +1 -1
  85. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  86. package/src/plugins/builtin/catalysts/model.ts +2 -1
  87. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  88. package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
  89. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  90. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  91. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  92. package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
  93. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  94. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  95. package/src/plugins/builtin/chat/index.tsx +0 -1
  96. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  97. package/src/plugins/builtin/company-kpis/headless.ts +1 -1
  98. package/src/plugins/builtin/company-kpis/model.ts +21 -9
  99. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  100. package/src/plugins/builtin/cot/client.ts +2 -3
  101. package/src/plugins/builtin/cot/headless.ts +16 -16
  102. package/src/plugins/builtin/cot/index.tsx +6 -6
  103. package/src/plugins/builtin/cot/model.ts +25 -5
  104. package/src/plugins/builtin/cot/pane.tsx +11 -6
  105. package/src/plugins/builtin/cot/series.ts +11 -8
  106. package/src/plugins/builtin/cpi/model.ts +15 -4
  107. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  108. package/src/plugins/builtin/doe/model.ts +30 -0
  109. package/src/plugins/builtin/doe/pane.tsx +8 -2
  110. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  111. package/src/plugins/builtin/earnings/headless.ts +10 -3
  112. package/src/plugins/builtin/earnings/history-table.ts +4 -2
  113. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  114. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  115. package/src/plugins/builtin/econ/index.tsx +4 -2
  116. package/src/plugins/builtin/futures/model.ts +14 -1
  117. package/src/plugins/builtin/futures/series.ts +1 -8
  118. package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
  119. package/src/plugins/builtin/insider/detail.tsx +36 -7
  120. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  121. package/src/plugins/builtin/insider/headless.ts +37 -2
  122. package/src/plugins/builtin/insider/index.tsx +79 -10
  123. package/src/plugins/builtin/insider/model.ts +43 -5
  124. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  125. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  126. package/src/plugins/builtin/jobs/headless.ts +2 -1
  127. package/src/plugins/builtin/jobs/model.ts +6 -0
  128. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  129. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  130. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  131. package/src/plugins/builtin/options/analytics.ts +1 -1
  132. package/src/plugins/builtin/options/view.tsx +18 -11
  133. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  134. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  135. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  136. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  137. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  138. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  139. package/src/plugins/builtin/perps/cascade.ts +4 -3
  140. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  141. package/src/plugins/builtin/perps/model.ts +4 -3
  142. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  143. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
  144. package/src/plugins/builtin/research/event-model.ts +12 -6
  145. package/src/plugins/builtin/research-search/index.tsx +3 -1
  146. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  147. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  148. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  149. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  150. package/src/plugins/builtin/sec/headless.ts +42 -4
  151. package/src/plugins/builtin/sec/index.tsx +21 -1
  152. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  153. package/src/plugins/builtin/shared/earnings-report.ts +32 -3
  154. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  155. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  156. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  157. package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
  158. package/src/plugins/builtin/themes/headless.ts +4 -4
  159. package/src/plugins/builtin/themes/model.ts +11 -8
  160. package/src/plugins/builtin/themes/pane.tsx +2 -2
  161. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  162. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  163. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  164. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  165. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  166. package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
  167. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  168. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
  169. package/src/plugins/builtin/volatility/pane.tsx +3 -3
  170. package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
  171. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  172. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  173. package/src/plugins/catalog-browser.ts +10 -1
  174. package/src/renderers/browser/activity.ts +16 -0
  175. package/src/renderers/browser/app-badge-host.ts +14 -0
  176. package/src/renderers/browser/main.tsx +5 -0
  177. package/src/renderers/browser/notifications.ts +103 -0
  178. package/src/renderers/browser/ui-host.tsx +4 -0
  179. package/src/renderers/dom/data-table/index.tsx +27 -4
  180. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  181. package/src/sources/gloomberb-cloud/index.ts +8 -6
  182. package/src/sources/gloomberb-cloud/news.ts +35 -0
  183. package/src/sources/provider-errors.ts +34 -7
  184. package/src/sources/provider-router/history.ts +32 -6
  185. package/src/time-series/base-series.ts +39 -6
  186. package/src/time-series/chart-seed.ts +2 -2
  187. package/src/time-series/history-quality.ts +4 -1
  188. package/src/time-series/hooks.ts +2 -0
  189. package/src/time-series/price-comparison.ts +17 -23
  190. package/src/time-series/reporting.ts +1 -1
  191. package/src/time-series/resolution.ts +13 -0
  192. package/src/time-series/resolve-context.ts +6 -0
  193. package/src/time-series/resolve.ts +39 -2
  194. package/src/time-series/types.ts +2 -1
  195. package/src/types/financials.ts +9 -1
  196. package/src/types/headless.ts +1 -0
  197. package/src/types/issuer-listings.ts +2 -0
  198. package/src/types/plugin-notifications.ts +3 -0
  199. package/src/types/price-history.ts +6 -4
  200. package/src/ui/host.tsx +2 -0
  201. package/src/utils/exchange-announcements.ts +7 -2
  202. package/src/utils/fundamentals.ts +40 -0
  203. package/src/utils/network-failure.ts +2 -0
  204. package/src/utils/price-history-integrity.ts +9 -1
@@ -15,7 +15,8 @@ import { resolvePersistedCloudSessionToken } from "./cloud-session";
15
15
  import type { PaneScreenshotResult } from "./screenshot-types";
16
16
  import { deriveRenderedFreshness, formatFreshnessLine, type ReportFreshness } from "./freshness";
17
17
  import { exportTextTable, reportFooterLines, type CliReportTables } from "../report-tables";
18
- import { declaredReportFreshness, renderedReportFailure, renderedReportFreshness, renderedReportNotices, renderedReportObservations } from "./report-notices";
18
+ import { declaredReportFreshness, renderedLoadError, renderedReportFailure, renderedReportFreshness, renderedReportNotices, renderedReportObservations } from "./report-notices";
19
+ import { DATA_SERVICE_UNREACHABLE_MESSAGE, DataServiceUnreachableError } from "../../utils/network-failure";
19
20
 
20
21
  const DOM_REPORT_WIDTH = 1280;
21
22
  const DOM_REPORT_HEIGHT = 720;
@@ -238,6 +239,9 @@ function renderedFailureReason(
238
239
  result: PaneScreenshotResult,
239
240
  rows: DesktopPaneShotRenderedRow[],
240
241
  ): string | null {
242
+ // Rows the pane kept from an earlier load, which it could not refresh (renderedLoadFailure has the bare pane's).
243
+ const loadError = renderedLoadError(result.render.semanticUi ?? []);
244
+ if (loadError) return `The rendered pane could not refresh: ${loadError}`;
241
245
  if (result.render.loadingStateDetected) return "The rendered pane was still loading.";
242
246
  if (result.render.errorStateDetected) {
243
247
  const marker = result.render.errorStateMarkers[0];
@@ -322,11 +326,15 @@ export async function buildDomPaneReportFromRender(
322
326
  if (failureReason && rows.length > 0) textLines.push("", failureReason);
323
327
  // A pane that knows its feed dates the report; the footer and cell times fill in the rest.
324
328
  const declared = { ...declaredReportFreshness(resolved), ...renderedReportFreshness(result.render.semanticUi ?? []) };
325
- const freshness = deriveRenderedFreshness(declared, {
329
+ const derived = deriveRenderedFreshness(declared, {
326
330
  footerText: result.render.footerText ?? "",
327
331
  cellTimes: rows.flatMap((row) => row.cells.flatMap((cell) => cell.instant ?? [])),
328
332
  observed: renderedReportObservations(result.render.semanticUi ?? []),
329
333
  });
334
+ // Drawn from copies saved earlier, its refresh having failed: dated as saved, never as delayed at the copy's time.
335
+ const freshness = derived && result.savedCopyAt != null && !derived.savedAt
336
+ ? { ...derived, savedAt: new Date(result.savedCopyAt).toISOString() }
337
+ : derived;
330
338
 
331
339
  const complete = failureReason === null && !truncated;
332
340
  // Each table published its rows and nothing else was cut: the report is the whole view.
@@ -446,6 +454,24 @@ class RenderedReportFailure extends Error {
446
454
  }
447
455
  }
448
456
 
457
+ /**
458
+ * The failure a rendered pane with nothing to show stands for: the load its
459
+ * status footer says failed (`pane-load-error`), else the error state its
460
+ * body draws. Such a report has no data, so it is no report: it fails as the
461
+ * plain commands do, a request that never reached the data service in their
462
+ * words ("Gloom couldn't reach its data service", and what to check), never
463
+ * the empty body ("No events") dated as if it had been read. ECO printed "No
464
+ * events" and "retrieved" at the time of the run through a proxy that refused
465
+ * every connection. Null for a pane that drew rows, a wall, or no failure.
466
+ */
467
+ function renderedLoadFailure(render: PaneScreenshotResult["render"]): Error | null {
468
+ if ((render.reportRows ?? render.rows).length > 0 || render.accessGate) return null;
469
+ const message = renderedLoadError(render.semanticUi ?? []) ?? render.stateText?.error?.[0] ?? null;
470
+ if (!message) return null;
471
+ if (message.includes(DATA_SERVICE_UNREACHABLE_MESSAGE)) return new DataServiceUnreachableError(new Error(message));
472
+ return new RenderedReportFailure(message);
473
+ }
474
+
449
475
  /**
450
476
  * The report of a pane the sign-in wall covers whole (`PaneDef.signInWall`)
451
477
  * when there is no session: its lock note, as the rendered wall reports it,
@@ -524,6 +550,8 @@ export async function buildDomFunctionReport(
524
550
  // No header and no partial view: the error alone, and a failed exit, as the plain command gives.
525
551
  const failure = renderedReportFailure(result.render.semanticUi ?? []);
526
552
  if (failure) throw new RenderedReportFailure(failure.message, failure.details);
553
+ const loadFailure = renderedLoadFailure(result.render);
554
+ if (loadFailure) throw loadFailure;
527
555
  // The capture's refusal drawn in the pane's place (chat, a team's) is not its content: say why there is none.
528
556
  if (result.refused && result.unusableReason) throw new RenderedReportFailure(result.unusableReason);
529
557
  try {
@@ -881,7 +881,7 @@ function feedStatusText(freshness: ReportFreshness, short: boolean): string {
881
881
  return `${rest ? `${rest}, ` : ""}${stale}`;
882
882
  }
883
883
  // A line that says how old its oldest observation is does not say it twice.
884
- return freshness.ageMinutes != null && freshness.oldestAgeMinutes == null ? `stale (${ageText(freshness.ageMinutes)} old)` : "stale";
884
+ return freshness.ageMinutes != null && freshness.ageMinutes > 0 && freshness.oldestAgeMinutes == null ? `stale (${ageText(freshness.ageMinutes)} old)` : "stale";
885
885
  }
886
886
  case "not-a-feed":
887
887
  return freshness.basis ? `not a live feed (${freshness.basis})` : "not a live feed";
@@ -1147,6 +1147,8 @@ interface StatusLineDetail {
1147
1147
  basis?: "none";
1148
1148
  /** Leave out how current a feed is (`15 min delayed`, `live`, `not a live feed`), which the pane shows another way; stale stays. */
1149
1149
  feed?: "none";
1150
+ /** Leave out when a list dated by its newest entry was read (`retrieved Wed 18 Nov 2026 00:22 UTC`). */
1151
+ retrieved?: "none";
1150
1152
  }
1151
1153
 
1152
1154
  /**
@@ -1165,7 +1167,7 @@ function statusLineParts(freshness: ReportFreshness, detail: StatusLineDetail =
1165
1167
  : (freshness.unreached || freshness.savedAt) && !freshness.asOf ? []
1166
1168
  : [asOfText(freshness, detail.asOf === "short", local, undated)]),
1167
1169
  // A list dated by its newest filing says when it was read as well.
1168
- ...(freshness.retrievedToo && freshness.asOf && !freshness.savedAt ? [`retrieved ${timeText(freshness.retrievedAt, local)}`] : []),
1170
+ ...(freshness.retrievedToo && freshness.asOf && !freshness.savedAt && detail.retrieved !== "none" ? [`retrieved ${timeText(freshness.retrievedAt, local)}`] : []),
1169
1171
  ...(freshness.schedule && detail.schedule !== "none"
1170
1172
  ? [typeof detail.schedule === "number" ? freshness.scheduleVariants?.[detail.schedule] ?? freshness.schedule : freshness.schedule] : []),
1171
1173
  ...(freshness.oldestAgeMinutes != null ? [`oldest ${ageText(freshness.oldestAgeMinutes)}`] : []),
@@ -1357,12 +1359,17 @@ export function statusLineVariants(freshness: ReportFreshness, { source = false
1357
1359
  ...(freshness.note ? [{ ...shortest, note: "none" as const }] : []),
1358
1360
  ...(freshness.schedule ? [...shorterSchedules(freshness, { ...shortest, note: "none" }), { ...shortest, note: "none" as const, schedule: "none" as const }] : []),
1359
1361
  ];
1362
+ // A list dated by its newest entry and by when it was read gives up the reading first, then what its data is,
1363
+ // and keeps its label to the last: `Newest filing Fri 6 Nov 2026`, never a bare date that reads as now.
1364
+ const unread: StatusLineDetail[] = freshness.retrievedToo
1365
+ ? [{ ...shortest, basis: "none" }, { ...shortest, basis: "none", retrieved: "none" }, { ...shortest, feed: "none", retrieved: "none" }]
1366
+ : [];
1360
1367
  const variants: StatusLineDetail[] = freshness.sources?.length
1361
1368
  ? [{}, ...details.map((detail) => ({ ...detail, date: "none" as const })), { ...shortest, date: "none", note: "none" }]
1362
- : [...details, ...trailing];
1369
+ : [...details, ...trailing, ...unread];
1363
1370
  const lines = [...new Set(variants.map((detail) => capitalize(statusLineParts(freshness, detail).join(" · "))))];
1364
1371
  if (freshness.status === "not-a-feed" && freshness.asOf?.includes("T") && !freshness.sources?.length && !freshness.oldest && !freshness.staleCount) {
1365
- lines.push(formatUtcTime(freshness.asOf));
1372
+ lines.push(narrowestAsOf(freshness, freshness.asOf));
1366
1373
  }
1367
1374
  // A line that dates each source names them already.
1368
1375
  if (!source || freshness.sources?.length) return lines;
@@ -1381,9 +1388,21 @@ export function statusDateEvidence(freshness: ReportFreshness): string[][] {
1381
1388
  [asOfText(freshness, true, false)],
1382
1389
  [asOfText(freshness, true, false, true)],
1383
1390
  [formatUtcTime(freshness.asOf)],
1391
+ [narrowestAsOf(freshness, freshness.asOf)],
1384
1392
  ];
1385
1393
  }
1386
1394
 
1395
+ /**
1396
+ * The narrowest status line of data that is no feed: its as-of in UTC, a day
1397
+ * alone where `asOfAsDay` reads it as one (a filing's date, not its midnight),
1398
+ * named by its label when it has one (`Newest filing 2026-11-06`).
1399
+ */
1400
+ function narrowestAsOf(freshness: ReportFreshness, asOf: string): string {
1401
+ const time = asOfAsDay(freshness, parseReportTime(asOf));
1402
+ const text = formatUtcTime(time ?? asOf);
1403
+ return freshness.asOfLabel ? capitalize(`${freshness.asOfLabel} ${text}`) : text;
1404
+ }
1405
+
1387
1406
  /** A capture's status line: the facts it states (its `freshness` in JSON) and its text, longest first. */
1388
1407
  export interface CaptureStatusLine {
1389
1408
  freshness: ReportFreshness;
@@ -520,11 +520,11 @@ export const FUNCTION_HELP: Readonly<Record<string, FunctionHelp>> = {
520
520
  bloomberg: [],
521
521
  },
522
522
  SRCH: {
523
- summary: "Full-text search across earnings call transcripts, news wires and SEC filings, with the matching passage inline. Save a search to get alerted on new hits.",
523
+ // Searching and reading hits need only a free account; alerts on a saved search are the part the service keeps for Pro.
524
+ summary: "Full-text search across earnings call transcripts, news wires and SEC filings, with the matching passage inline. Free with a Gloom account; alerts on a saved search's new hits are Pro.",
524
525
  usage: ["SRCH data center capex"],
525
526
  keys: [SEARCH, key("Ctrl+S", " save search"), key("a", "lerts")],
526
- data: pro("As calls, stories and filings arrive"),
527
- access: "pro",
527
+ data: same("As calls, stories and filings arrive"),
528
528
  bloomberg: ["NSE"],
529
529
  },
530
530
  COVN: {
@@ -38,6 +38,7 @@ import {
38
38
  } from "../report-tables";
39
39
  import type { ExportIdentity } from "../export-source";
40
40
  import { observationDate } from "../../time-series/price-comparison";
41
+ import { chartBarSizeParts } from "../../time-series/resolution";
41
42
  import type { ResolvedSeries } from "../../time-series/types";
42
43
  import { barLastSession } from "../../market-data/market/bar-period";
43
44
  import type { PaneFunctionReport } from "./report";
@@ -634,7 +635,10 @@ function trailingCells(trailing: HeadlessSeries["trailing"]): Record<string, str
634
635
  }
635
636
 
636
637
  function renderSeries(result: HeadlessSeriesResult): string[] {
637
- const rows = result.series.map((series) => {
638
+ // Series served in different bars (a chart's 5-minute bars beside a series a source answered in daily ones) name theirs.
639
+ const barSizes = result.series.map((series) => (chartBarSizeParts(series.interval?.trim()) ? series.interval!.trim() : null));
640
+ const mixedBars = new Set(barSizes.filter(Boolean)).size > 1;
641
+ const rows = result.series.map((series, index) => {
638
642
  const latest = [...series.points].reverse().find((point) => (
639
643
  point.value != null || point.close != null
640
644
  ));
@@ -645,7 +649,9 @@ function renderSeries(result: HeadlessSeriesResult): string[] {
645
649
  latest: series.notMeaningful ? series.notMeaningful.asOf : latest ? seriesLatestDate(series, latest.date) : MISSING_VALUE,
646
650
  value: series.notMeaningful ? "N/M" : seriesValue(series, latest?.value ?? latest?.close ?? null),
647
651
  unit: series.unit?.trim() ? currencyRateUnitText(series.unit.trim()) : null,
652
+ native: latest?.nativeAmount ? `${seriesValue(series, latest.nativeAmount.value)} ${latest.nativeAmount.currency}` : null,
648
653
  ...trailingCells(series.trailing),
654
+ ...(mixedBars ? { bars: barSizes[index] ?? MISSING_VALUE } : {}),
649
655
  points: observationCount(series),
650
656
  };
651
657
  });
@@ -658,6 +664,8 @@ function renderSeries(result: HeadlessSeriesResult): string[] {
658
664
  { key: "value", header: "Value", align: "right" },
659
665
  ...(trailing ? TRAILING_COLUMNS : []),
660
666
  ...(rows.some((row) => row.unit) ? [{ key: "unit", header: "Unit" }] : []),
667
+ ...(mixedBars ? [{ key: "bars", header: "Bars" }] : []),
668
+ ...(rows.some((row) => row.native) ? [{ key: "native", header: "Native", align: "right" as const }] : []),
661
669
  // Beside the averages, the count of points is the first thing a narrow table drops.
662
670
  { key: "points", header: "Points", align: "right", ...(trailing ? { optional: true } : {}) },
663
671
  ];
@@ -37,6 +37,7 @@ import { expandResolvedArgument } from "./headless";
37
37
  import { defaultScreenshotPath, shotSizeWarnings } from "./screenshot-payload";
38
38
  import { renderDesktopShot } from "./screenshot-render";
39
39
  import { shotCutColumnsWarning, shotStatusIssues } from "./screenshot-assessment";
40
+ import { PANE_SWEEP_EVIDENCE_PATH } from "./screenshot-types";
40
41
  import {
41
42
  buildPaneCatalogEntries,
42
43
  exampleListName,
@@ -51,6 +52,7 @@ import {
51
52
  } from "../listing-arg";
52
53
  import { notATickerStop } from "../company-name-hint";
53
54
  import { CLI_ERROR_CODE, failUnreachable, failWithError, isCliFailure, isSourceUnavailableAnswer, unreachableError } from "../errors";
55
+ import { dataServiceUnreachable, forgetDataServiceReach } from "../../api-client/request";
54
56
  import { DATA_SERVICE_UNREACHABLE_MESSAGE, isNetworkFailure } from "../../utils/network-failure";
55
57
  import { isTickerLinkPeer } from "../../layout/ticker-navigation";
56
58
  import { appCommandPointer, knownGapMessage, commandPointer, commandPointerLeads, topicPointer } from "../known-gaps";
@@ -346,6 +348,41 @@ function tablesHoldValues(tables: CliReportTables): boolean {
346
348
  });
347
349
  }
348
350
 
351
+ /** Whether a report's tables show a figure: a cell outside the label column with a digit in it (not a dash). */
352
+ function tablesHoldFigures(tables: CliReportTables): boolean {
353
+ return tables.tables.some((table) => {
354
+ const skipped = new Set(table.columns.flatMap((header, index) => index === 0 || header === "status" || header === "value_status" ? [index] : []));
355
+ return table.rows.some((row) => row.some((cell, index) => !skipped.has(index) && /\d/.test(String(cell ?? ""))));
356
+ });
357
+ }
358
+
359
+ /**
360
+ * Whether a report holds nothing because its reads failed: empty with a
361
+ * failure said, every row failing to reach the data service (WEI's twenty
362
+ * indices each "couldn't reach"), or every row's listing without data and no
363
+ * figure anywhere (BI's sectors, all dashes). Never one behind a wall, whose
364
+ * note is its answer, one with nothing asked yet ("Select a ticker."), or one
365
+ * with a figure from a read that did answer (VIX's term structure beside
366
+ * quotes it has none of).
367
+ */
368
+ export function reportHasNoData(data: {
369
+ empty: boolean; rowCount: number; unavailableSymbols: readonly string[]; errors?: readonly string[]; locked?: unknown;
370
+ }, tables?: CliReportTables): boolean {
371
+ if (data.locked) return false;
372
+ const errors = data.errors ?? [];
373
+ if (data.unavailableSymbols.length === 0 && errors.length === 0) return false;
374
+ if (data.empty) return true;
375
+ if (data.rowCount === 0) return false;
376
+ const unreached = errors.filter((error) => error.includes(DATA_SERVICE_UNREACHABLE_MESSAGE)).length;
377
+ if (unreached >= data.rowCount) return true;
378
+ return data.unavailableSymbols.length >= data.rowCount && !!tables && !tablesHoldFigures(tables);
379
+ }
380
+
381
+ /** A report with nothing in it because the data service went unanswered: no answer, not "no data" dated now. */
382
+ function reportFailedUnreached(data: Parameters<typeof reportHasNoData>[0], tables: CliReportTables): boolean {
383
+ return reportHasNoData(data, tables) && dataServiceUnreachable();
384
+ }
385
+
349
386
  /**
350
387
  * Why `fn` fails a report it printed, or null when the report has data. It
351
388
  * fails when it is empty (a pane behind a wall reads nothing), when it has no
@@ -449,6 +486,9 @@ export async function runPaneFunction(args: string[], ctx: CliCommandContext) {
449
486
  if (listing) await failUnchosenListing(listing, context, ctx, { ...moved, noun: "data" }, error);
450
487
  throw error;
451
488
  }).finally(progress.stop);
489
+ // A report with nothing in it while the data service went unanswered is no answer, not "No data" dated now:
490
+ // it fails as `search` and `quote` do (G, CMP, WEI and CHOKE printed empty tables and "retrieved" at the run).
491
+ if (reportFailedUnreached(report.data, report.tables)) failUnreachable();
452
492
  // A company's name typed where its ticker goes (`fn RDCF Palantir`) found nothing: the answer is `quote`'s,
453
493
  // "Not a ticker: PALANTIR. Did you mean PLTR (Palantir Technologies Inc.)?", not an empty report. A source that
454
494
  // could not answer for the word (a timeout) says nothing of it, but when search finds the company it is that.
@@ -558,18 +598,37 @@ const SHOT_PROGRESS_AFTER_MS = 3_000;
558
598
  const FN_PROGRESS_AFTER_MS = 5_000;
559
599
 
560
600
  /**
561
- * One line on standard error when a capture or report is slow: "Still loading
562
- * the data for PORT izmir." while its data is read, "Still drawing PORT
563
- * izmir." once a capture's page draws it. Nothing for a quick one, or with --quiet.
601
+ * One line on a terminal's standard error while a capture or report is slow:
602
+ * "Still loading the data for PORT izmir." while its data is read, "Still
603
+ * drawing PORT izmir." once a capture's page draws it. It is progress, not
604
+ * part of the answer: the line is cleared once the work ends, so a finished
605
+ * report never starts with it, and standard error that is not a terminal (a
606
+ * file, a pipe, a script reading it) never gets it. Nothing for a quick one,
607
+ * or with --quiet.
564
608
  */
565
- function progressNotice(ctx: Pick<CliCommandContext, "cliOptions">, label: string, afterMs = SHOT_PROGRESS_AFTER_MS): { drawing(): void; stop(): void } {
566
- if (ctx.cliOptions.quiet) return { drawing: () => {}, stop: () => {} };
609
+ export function progressNotice(
610
+ ctx: Pick<CliCommandContext, "cliOptions">,
611
+ label: string,
612
+ afterMs = SHOT_PROGRESS_AFTER_MS,
613
+ stream: Pick<NodeJS.WriteStream, "isTTY" | "write"> = process.stderr,
614
+ ): { drawing(): void; stop(): void } {
615
+ if (ctx.cliOptions.quiet || !stream.isTTY) return { drawing: () => {}, stop: () => {} };
567
616
  let drawing = false;
617
+ let shown = false;
568
618
  const timer = setTimeout(() => {
569
- console.error(cliStyles.muted(drawing ? `Still drawing ${label}.` : `Still loading the data for ${label}.`));
619
+ // No newline: the line stays the cursor's until it is cleared.
620
+ stream.write(cliStyles.muted(drawing ? `Still drawing ${label}.` : `Still loading the data for ${label}.`));
621
+ shown = true;
570
622
  }, afterMs);
571
623
  (timer as { unref?: () => void }).unref?.();
572
- return { drawing: () => { drawing = true; }, stop: () => clearTimeout(timer) };
624
+ return {
625
+ drawing: () => { drawing = true; },
626
+ stop: () => {
627
+ clearTimeout(timer);
628
+ if (shown) stream.write("\r\x1b[2K");
629
+ shown = false;
630
+ },
631
+ };
573
632
  }
574
633
 
575
634
  export async function runPaneScreenshot(args: string[], ctx: CliCommandContext) {
@@ -608,6 +667,9 @@ async function capturePaneScreenshot(args: string[], ctx: CliCommandContext, onS
608
667
  ? resolve(process.cwd(), ensurePngExtension(parsed.outputPath))
609
668
  : defaultScreenshotPath(resolved, parsed.arg);
610
669
  const progress = progressNotice(ctx, [resolved.token, parsed.arg].filter(Boolean).join(" "));
670
+ const sweepEvidence = parsed.strict === true && ctx.cliOptions.format === "json" && !!parsed.outputPath
671
+ && process.env[PANE_SWEEP_EVIDENCE_PATH] === outputPath;
672
+ const onlyUsable = parsed.requireBotSafe === true || (parsed.strict === true && !sweepEvidence);
611
673
  const result = await renderDesktopShot({
612
674
  resolved,
613
675
  context,
@@ -621,6 +683,7 @@ async function capturePaneScreenshot(args: string[], ctx: CliCommandContext, onS
621
683
  statusLine: parsed.status !== false,
622
684
  fitRows: parsed.heightGiven !== true,
623
685
  options: parsed.options,
686
+ onlyUsable,
624
687
  onStalledReport,
625
688
  onDrawing: progress.drawing,
626
689
  }).finally(progress.stop).catch(async (error: unknown) => {
@@ -662,11 +725,10 @@ async function capturePaneScreenshot(args: string[], ctx: CliCommandContext, onS
662
725
  if (data.blankColumns?.length) stats.push(["Blank columns", cliStyles.warning(data.blankColumns.join(", "))]);
663
726
  if (data.render.emptyStateMarkers.length > 0) stats.push(["Empty states", data.render.emptyStateMarkers.join(", ")]);
664
727
  if (data.render.missingExpectedText.length > 0) stats.push(["Missing text", data.render.missingExpectedText.join(", ")]);
665
- return [`Saved ${displayPath(data.outputPath)}`, renderStats(stats)].join("\n");
728
+ return [data.saved ? `Saved ${displayPath(data.outputPath)}` : "No image saved.", renderStats(stats)].join("\n");
666
729
  },
667
730
  });
668
- // The image is saved and the reason printed; --strict tells a script it should not be used. A pane that drew
669
- // nothing but its empty state ("No ticker selected.") failed either way, as `fn` does for an empty report.
731
+ // A pane that drew nothing but its empty state ("No ticker selected.") fails either way, as `fn` does for an empty report.
670
732
  if (parsed.strict && !result.usable) process.exitCode = CLI_EXIT_CODES.unusableShot;
671
733
  else if (!result.usable && result.render.emptyStateDetected && result.rowCount === 0) process.exitCode = CLI_EXIT_CODES.error;
672
734
  }, { command: "shot" });
@@ -824,6 +886,8 @@ function printCatalog(
824
886
  }
825
887
 
826
888
  async function runPaneCliCommand(ctx: CliCommandContext, run: () => Promise<void>) {
889
+ // Whether the data service answered is this command's to say, never a request made before it.
890
+ forgetDataServiceReach();
827
891
  try {
828
892
  await run();
829
893
  } catch (error) {
@@ -834,6 +898,9 @@ async function runPaneCliCommand(ctx: CliCommandContext, run: () => Promise<void
834
898
  if (isSourceUnavailableAnswer(error)) throw error;
835
899
  // A listing it cannot use says what to type instead; a name that opens nothing, what is close to it.
836
900
  if (error instanceof ListingArgError || error instanceof UnknownPaneFunctionError) ctx.fail(error.message, error.details || undefined);
901
+ // Whatever a pane made of a request that never reached the data service ("News sources unavailable.", "No ticker
902
+ // match found", a bare ECONNREFUSED), nothing answered since: said as every command says it, with what to check.
903
+ if (dataServiceUnreachable()) failUnreachable();
837
904
  const message = error instanceof Error ? error.message : String(error);
838
905
  // Nothing answered: said as every command says it, with what to check.
839
906
  if (message.includes(DATA_SERVICE_UNREACHABLE_MESSAGE)) failUnreachable(message);
@@ -54,6 +54,16 @@ export function renderedReportFailure(semanticUi: readonly RemoteUiNodeSnapshot[
54
54
  return details ? { message, details } : { message };
55
55
  }
56
56
 
57
+ /**
58
+ * The load a rendered pane says failed, from the `pane-load-error` node its
59
+ * status footer publishes (usePaneStatusFooter): the error the footer shows.
60
+ * Null when the pane loaded, or is loading.
61
+ */
62
+ export function renderedLoadError(semanticUi: readonly RemoteUiNodeSnapshot[]): string | null {
63
+ const message = semanticUi.find((node) => node.role === "pane-load-error")?.metadata?.message;
64
+ return typeof message === "string" && message.trim() ? message.trim() : null;
65
+ }
66
+
57
67
  const FRESHNESS_STATUSES: readonly HeadlessFreshnessStatus[] = ["live", "delayed", "stale", "not-a-feed"];
58
68
 
59
69
  /** The `sources` a pane publishes: each a name and a time. */
@@ -273,10 +273,11 @@ export async function applyListingArgument(
273
273
  const aliases = exchange ? [] : entered.map((raw) => headless?.symbolAlias?.(raw) ?? null);
274
274
  const typed = entered.map((raw, index) => aliases[index]?.symbol ?? raw);
275
275
  // RY.TO is the listing its quote names, RY:TSX, as `quote` reads it: a function's data is read by venue.
276
- // A long list is a batch of tickers: its words cost no quote each to be read as companies' names.
276
+ // A long list is a batch of tickers: its words cost no quote each to be read as companies' names, nor its codes
277
+ // no source quotes to be read on their listings abroad.
277
278
  const companyWord = typed.length <= MAX_CHOICE_LOOKUPS;
278
279
  let listings = named ? [named] : await Promise.all(typed.map((raw) => resolveCliListing(raw, exchange, context, {
279
- ownExchangeWins: typed.length > 1, venueSuffix: true, companyWord,
280
+ ownExchangeWins: typed.length > 1, venueSuffix: true, companyWord, listingAbroad: companyWord,
280
281
  })));
281
282
  // A separator stuck to the end of a pasted list (`UPST;`) is not part of a symbol; it is named.
282
283
  const notes: string[] = takesOneTicker ? [] : stripStrayEdges(args.arg).notes;
@@ -61,7 +61,7 @@ export function shotShowsText(visibleText: string, value: string): boolean {
61
61
  export function isPaneScreenshotUsable(signals: PaneScreenshotReadinessSignals): boolean {
62
62
  return !signals.refused
63
63
  && !signals.blankColumns?.length
64
- && (signals.interactive || ((signals.rowCount > 0 || signals.contentShown === true) && !signals.emptyStateDetected))
64
+ && (signals.interactive || signals.confirmedEmpty || ((signals.rowCount > 0 || signals.contentShown === true) && !signals.emptyStateDetected))
65
65
  && !signals.loadingStateDetected
66
66
  && !signals.errorStateDetected
67
67
  && signals.complete
@@ -140,9 +140,12 @@ export function assessPaneScreenshot(
140
140
  ? []
141
141
  : shotUnavailableSymbols(resolved, payload, render.semanticUi);
142
142
  const figureGaps = essentialFigureMismatches(render);
143
- const complete = unavailableSymbols.length === 0 && figureGaps.length === 0 && !render.statusLineClipped;
143
+ const complete = unavailableSymbols.length === 0 && figureGaps.length === 0;
144
144
  const expectedText = shotExpectedText(resolved, symbols, payload);
145
- const normalizedVisibleText = render.visibleText.toLowerCase();
145
+ // A text field's value is on screen too (OVME's Underlying SPY), though not in the page's text. It is read
146
+ // for this check alone: what a reader typed in a field never reaches the result, its JSON or its print.
147
+ const { fieldValues, ...shownRender } = render;
148
+ const normalizedVisibleText = [render.visibleText, ...fieldValues ?? []].join(" ").toLowerCase();
146
149
  const missingExpectedText = expectedText.filter((value) => !shotShowsText(normalizedVisibleText, value));
147
150
  const expectedSelections = shotExpectedSelections(resolved);
148
151
  const missingExpectedSelections = missingActiveTabSelections(
@@ -158,7 +161,6 @@ export function assessPaneScreenshot(
158
161
  ...financialRatioRenderMismatches(resolved, payload, render),
159
162
  ...surfaceNotDrawnMismatches(render),
160
163
  ...figureGaps,
161
- ...(render.statusLineClipped ? ["The as-of status line is clipped."] : []),
162
164
  ];
163
165
  const semanticMismatch = missingExpectedText.length > 0
164
166
  || missingExpectedSelections.length > 0
@@ -186,6 +188,8 @@ export function assessPaneScreenshot(
186
188
  interactive,
187
189
  rowCount,
188
190
  contentShown,
191
+ confirmedEmpty: rowCount === 0 && render.emptyStateDetected && !render.accessGate
192
+ && (render.semanticUi ?? []).some((node) => node.role === "pane-empty-result"),
189
193
  refused,
190
194
  loadingStateDetected: render.loadingStateDetected,
191
195
  errorStateDetected: render.errorStateDetected,
@@ -203,6 +207,7 @@ export function assessPaneScreenshot(
203
207
  const tableRows = shotTableRows(resolved, render);
204
208
  const notices = [
205
209
  ...renderedReportNotices(render.semanticUi ?? []).notices,
210
+ ...(render.statusLineClipped ? ["The as-of status line is clipped."] : []),
206
211
  ...unquotedHoldingsNotice(resolved, payload),
207
212
  ...(render.surfaces?.some((surface) => surface.renderer === "software")
208
213
  ? ["The 3D surface was drawn by the software renderer: this browser has no WebGL."] : []),
@@ -234,7 +239,7 @@ export function assessPaneScreenshot(
234
239
  ...(tableRows ? { tableRows } : {}),
235
240
  outputPath,
236
241
  render: {
237
- ...stripDesktopShotCredentials(render),
242
+ ...stripDesktopShotCredentials(shownRender),
238
243
  expectedText,
239
244
  missingExpectedText,
240
245
  expectedSelections,
@@ -7,10 +7,11 @@ import { graphRowsForFinancials, limitGraphRowsBySymbol, metricDef } from "../..
7
7
  import { getTimeSeriesField } from "../../time-series/field-catalog";
8
8
  import {
9
9
  buildFinancialTableModel,
10
- financialStatementCurrency,
11
- formatFinancialHeader,
10
+ financialColumnPeriod,
11
+ financialFiscalHeader,
12
12
  splitPeriodsNotInYet,
13
13
  } from "../../plugins/builtin/ticker-detail/financials/model";
14
+ import { fiscalYearEndMonth } from "../../utils/fiscal-period";
14
15
  import type { FundamentalPeriod, GraphKind, GraphMetricKey } from "../../time-series/reporting";
15
16
  import type { TimeRange } from "../../time-series/range";
16
17
  import { subtractTimeRange } from "../../time-series/date-window";
@@ -363,19 +364,10 @@ export function shotExpectedText(
363
364
  // A newest period with only some figures is left out of the pane's statement columns (splitPeriodsNotInYet).
364
365
  const latestStatement = table && !ratioTab ? splitPeriodsNotInYet(table.statements, table.subTab).shown[0] : table?.statements[0];
365
366
  const firstMetric = table?.rows[0];
366
- // The pane prints the compact header: date, currency and an S/P source marker.
367
- if (latestStatement) {
368
- const currency = latestStatement.currency ?? financialStatementCurrency(
369
- financials,
370
- [...(financials.annualStatements ?? []), ...(financials.quarterlyStatements ?? [])],
371
- );
372
- expected.push(formatFinancialHeader(
373
- latestStatement.date,
374
- currency,
375
- latestStatement.dateSource,
376
- true,
377
- latestStatement.aggregation?.periodEnd,
378
- ).trim());
367
+ if (table && latestStatement) {
368
+ const annual = financials.annualStatements ?? [];
369
+ const kind = financialColumnPeriod(latestStatement, table.period, new Set(annual.map(({ date }) => date)));
370
+ expected.push(financialFiscalHeader(latestStatement, kind, fiscalYearEndMonth(annual)));
379
371
  }
380
372
  const firstLabel = ratioTab ? ratioTab.ratios[0]?.label : firstMetric?.unitLabel;
381
373
  if (firstLabel) expected.push(firstLabel);
@@ -11,7 +11,7 @@ import type { ChartPaneModel } from "../../plugins/builtin/chart-composer/headle
11
11
  import { buildHeadlessPaneLoadArgs, loadResolvedHeadlessPaneModel, type LoadedHeadlessPaneModel } from "./headless";
12
12
  import { resolve } from "path";
13
13
  import type { PaneRuntimeState } from "../../core/state/app/state";
14
- import { CHART_COMPOSER_PANE_ID, type AppConfig } from "../../types/config";
14
+ import { CHART_COMPOSER_PANE_ID, TICKER_RESEARCH_PANE_ID, type AppConfig } from "../../types/config";
15
15
  import type { OptionsChain, PricePoint, TickerFinancials } from "../../types/financials";
16
16
  import type { InstrumentRef } from "../../market-data/request-types";
17
17
  import { fetchHistoryResult } from "../../sources/history-result";
@@ -37,6 +37,7 @@ import { collectExternalPluginBundles } from "../../renderers/electrobun/bun/ext
37
37
  import { getQuoteMonitorPaneSettings } from "../../plugins/builtin/ticker-detail/settings";
38
38
  import { isNotATickerMessage } from "../not-a-ticker";
39
39
  import { HISTORY_DEFAULT_RANGE } from "../../plugins/builtin/ticker-detail/data-panes/history-bars";
40
+ import { priceReturnDailyWindow } from "../../market-data/performance";
40
41
  import { findCollection } from "../../plugins/builtin/portfolio-list/cli/render";
41
42
  import { peekCachedBrokerAccounts } from "../../plugins/builtin/portfolio-list/cached-account";
42
43
  import { paneScreenshotEvidenceHook } from "./screenshot-evidence";
@@ -171,18 +172,26 @@ interface ShotSymbolCapture {
171
172
 
172
173
  /**
173
174
  * 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.
175
+ * daily closes that price each figure on its day; DES's overview charts the
176
+ * weeks and measures its Price Return strip on five years of daily closes.
177
+ * Captured history answers every request, so the weekly bars would stand in
178
+ * for the daily ones and the capture read the week around each figure's day
179
+ * (or each period's start): each cadence is its own, under the listing the
180
+ * pane asks for. Without daily closes the weekly bars stand alone, as in the app.
179
181
  */
180
- async function peBandHistoryVariants(
182
+ async function weeklyAndDailyHistoryVariants(
181
183
  context: MarketContext, ticker: TickerRecord, exchange: string, weekly: TickerFinancials["priceHistory"],
184
+ /** DES's window (priceReturnDailyWindow), which it asks for by its dates; PEB's is the 5Y range. */
185
+ window?: { start: Date; end: Date },
182
186
  ): Promise<NonNullable<SnapshotMarketData["historyVariants"]>> {
183
187
  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", []));
188
+ const provider = context.dataProvider;
189
+ const read = window
190
+ ? provider.getDetailedPriceHistoryWithMetadata?.(target.symbol, exchange, window.start, window.end, "1d", toMarketDataContext(target))
191
+ .then((result) => result.points)
192
+ ?? provider.getDetailedPriceHistory?.(target.symbol, exchange, window.start, window.end, "1d", toMarketDataContext(target))
193
+ : provider.getPriceHistoryForResolution?.(target.symbol, exchange, "5Y", "1d", toMarketDataContext(target));
194
+ const daily = await (read ?? Promise.resolve([])).catch(logFailure("cli.pane-functions.screenshot-payload", "Read daily closes for a capture failed", []));
186
195
  return [{ target, resolution: "1wk", points: weekly ?? [] }, ...(daily.length ? [{ target, resolution: "1d" as const, points: daily }] : [])];
187
196
  }
188
197
 
@@ -367,7 +376,12 @@ export async function buildDesktopShotPayload(
367
376
  if (resolved.pane.id === "time-sales") {
368
377
  capture.tape = [entry.instrument.symbol, exchange, await fetchTape(entry.instrument.symbol, exchange)];
369
378
  }
370
- if (resolved.pane.id === "pe-band") capture.historyVariants = await peBandHistoryVariants(context, capture.ticker, exchange, data.priceHistory);
379
+ // DES (the research pane's overview, not its financials or the ADR pair) measures returns on daily closes.
380
+ const overview = resolved.pane.id === TICKER_RESEARCH_PANE_ID && resolved.template?.id !== "adr-pair-pane" && !isFinancialAnalysisFunction(resolved);
381
+ if (resolved.pane.id === "pe-band" || overview) {
382
+ capture.historyVariants = await weeklyAndDailyHistoryVariants(context, capture.ticker, exchange, data.priceHistory,
383
+ overview ? priceReturnDailyWindow() : undefined);
384
+ }
371
385
  if (includeOptionsChains && context.dataProvider.getOptionsChain) {
372
386
  // A future with no chain of its own is the pane's to explain (the listed alternative), not a failed shot.
373
387
  const chain = await context.dataProvider.getOptionsChain(entry.instrument.symbol, exchange, undefined,