@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
@@ -13,7 +13,7 @@ import {
13
13
  import { scenarioFreshness } from "./freshness";
14
14
  import { cashSecuredPut, cspReportEntries, loadNextEarningsDate } from "./csp";
15
15
  import { formatSpotTime } from "../options/model-spot";
16
- import { amountUnit, buildScenario, currencyLabel, exportPercent, parseLegs, scenarioValueUnit } from "./model";
16
+ import { amountUnit, buildScenario, currencyLabel, exportPercent, parseLegs, scenarioDateLabels, scenarioValueUnit } from "./model";
17
17
  import { hedgeInputsFromSettings, hedgeReportEntries, scenarioHedgeBudget, seededLegQuotes } from "./hedge";
18
18
  import { collarReportEntries, scenarioCollar } from "./collar";
19
19
  import { modelDividendYieldNote } from "../../../market-data/model-dividend-yield";
@@ -168,7 +168,11 @@ export const optionsScenarioHeadless: HeadlessPaneDefinition<"bundle"> = {
168
168
  formatted: `${money(lastPrint)} ${PRICE_UNIT}${lastSession && lastSession !== "last price" ? ` (${scenarioSpotStamp(lastSession, market.asOf)})` : ""}` }] : []),
169
169
  ...(position!.underlying ? [{ key: "shares", label: "Shares held", value: position!.underlying.quantity, unit: "shares",
170
170
  formatted: `${position!.underlying.quantity.toLocaleString("en-US")} at ${money(position!.underlying.price)} ${PRICE_UNIT}` }] : []),
171
- { key: "asOf", label: "Valued at", value: new Date(position!.asOf).toISOString(), formatted: formatSpotTime(position!.asOf) },
171
+ // The figures are valued at the scenario date; its spot, IVs and rate are as of the position's own time.
172
+ ...(scenario.controls.date !== position!.asOf ? [
173
+ { key: "asOf", label: "As of", value: new Date(position!.asOf).toISOString(), formatted: formatSpotTime(position!.asOf) },
174
+ { key: "valuedAt", label: "Valued at", value: new Date(scenario.controls.date).toISOString(), formatted: formatSpotTime(scenario.controls.date) },
175
+ ] : [{ key: "asOf", label: "Valued at", value: new Date(position!.asOf).toISOString(), formatted: formatSpotTime(position!.asOf) }]),
172
176
  { key: "rate", label: "Rate", value: exportPercent(position!.rate), unit: "%", formatted: percent(position!.rate) },
173
177
  // A yield read as 0 because no dividend was paid, or the dividend stopped, says so; a stated or typed one is the figure alone.
174
178
  { key: "dividendYield", label: "Dividend yield", value: exportPercent(position!.dividendYield), unit: "%", formatted: percent(position!.dividendYield)
@@ -191,7 +195,7 @@ export const optionsScenarioHeadless: HeadlessPaneDefinition<"bundle"> = {
191
195
  { title: `Scenario grid (P&L, ${per})`, columns: [
192
196
  { key: "spot", header: "Spot/share", format: money },
193
197
  { key: "move", header: "Move", format: (value) => typeof value === "number" && Number.isFinite(value) ? `${(value * 100).toFixed(1)}%` : MISSING_VALUE },
194
- ...scenario.dates.map((date, index) => ({ key: `date${index}`, header: new Date(date).toISOString().slice(0, 10), format: money })),
198
+ ...scenarioDateLabels(scenario.dates).map((label, index) => ({ key: `date${index}`, header: label, format: money })),
195
199
  ], rows: scenario.grid.map((row) => ({ spot: row.spot, move: row.move,
196
200
  ...Object.fromEntries(row.values.map((value, index) => [`date${index}`, value])) })) },
197
201
  ] : [],
@@ -357,6 +357,38 @@ export function expiryRisk(position: ScenarioPosition): ScenarioExpiryRisk {
357
357
  maxLoss: unlimitedLoss ? null : Math.max(0, -Math.min(...values)), unlimitedProfit, unlimitedLoss, reason: null };
358
358
  }
359
359
 
360
+ const utcDay = (time: number) => new Date(time).toISOString().slice(0, 10);
361
+
362
+ /**
363
+ * The grid's dates: the origin, the scenario date the valuation is at, the
364
+ * first expiration close, and up to three even steps between the origin and
365
+ * the close, each on a day no other column is on. A three-day position reads
366
+ * the 17th, 18th, 19th and the 20th's close, never two 20ths.
367
+ */
368
+ function scenarioGridDates(asOf: number, expiry: number, selected: number): number[] {
369
+ if (asOf === expiry) return [asOf];
370
+ const fixed = [...new Set([asOf, selected, expiry])];
371
+ const days = new Set(fixed.map(utcDay));
372
+ const steps = [1, 2, 3].map((index) => asOf + (expiry - asOf) * index / 4).filter((date) => {
373
+ const day = utcDay(date);
374
+ if (days.has(day)) return false;
375
+ days.add(day);
376
+ return true;
377
+ });
378
+ return [...fixed, ...steps].sort((a, b) => a - b);
379
+ }
380
+
381
+ /**
382
+ * Each grid date as its column heads it: the UTC day, with the time where
383
+ * another column is on the same day (a position valued on its expiry day:
384
+ * `2026-11-20 14:30` and `2026-11-20 21:00`), so no two columns read alike.
385
+ */
386
+ export function scenarioDateLabels(dates: readonly number[]): string[] {
387
+ const days = dates.map(utcDay);
388
+ return dates.map((date, index) => days.indexOf(days[index]!) !== days.lastIndexOf(days[index]!)
389
+ ? `${days[index]} ${new Date(date).toISOString().slice(11, 16)}` : days[index]!);
390
+ }
391
+
360
392
  export function buildScenario(position: ScenarioPosition, input: Partial<ScenarioControls> = {}): ScenarioModel {
361
393
  const prepared = prepare(position);
362
394
  const date = input.date ?? position.asOf;
@@ -372,8 +404,7 @@ export function buildScenario(position: ScenarioPosition, input: Partial<Scenari
372
404
  const risk = expiryRisk(position);
373
405
  if (risk.reason) warnings.push(risk.reason);
374
406
  if (position.spot === 0) warnings.push("Spot is zero; percentage moves are unavailable.");
375
- const dates = position.asOf === prepared.expiryDate ? [position.asOf]
376
- : Array.from({ length: 5 }, (_, index) => position.asOf + (prepared.expiryDate - position.asOf) * index / 4);
407
+ const dates = scenarioGridDates(position.asOf, prepared.expiryDate, controls.date);
377
408
  const anchor = position.spot || Math.max(...position.legs.map((leg) => leg.strike));
378
409
  const low = Math.max(0, position.spot * (1 - spotRange));
379
410
  const high = anchor * (1 + spotRange);
@@ -35,7 +35,7 @@ import { collarStatItems, scenarioCollar } from "./collar";
35
35
  import { useAssetData } from "../../runtime";
36
36
  import { extendedSession, formatSpotTime } from "../options/model-spot";
37
37
  import { useRemoteUiNode } from "../../../remote/semantic-tree";
38
- import { buildScenario, currencyLabel, scenarioCurrency, scenarioValueUnit, UNKNOWN_CURRENCY, type ScenarioLeg, type ScenarioPosition,
38
+ import { buildScenario, currencyLabel, scenarioCurrency, scenarioDateLabels, scenarioValueUnit, UNKNOWN_CURRENCY, type ScenarioLeg, type ScenarioPosition,
39
39
  type ScenarioControls, validatePosition } from "./model";
40
40
  import { EMPTY_SAVED_STRATEGIES, restoreSavedStrategies, type SavedScenarioStrategy } from "./state";
41
41
  import { useScenarioEvidence } from "./evidence";
@@ -385,7 +385,7 @@ export function OptionsScenarioPane({ width, height, focused }: PaneProps) {
385
385
  emptyStateTitle="No scenario values." getItemKey={(row) => `${row.landmark ?? "step"}:${row.spot}`}
386
386
  columns={[{ id: "spot", label: `Spot ${position?.currency ?? ""}`, width: 14, align: "right" }, { id: "move", label: "Move %", width: 10, align: "right" },
387
387
  { id: "mark", label: "", width: 10, align: "left" },
388
- ...scenario.dates.map((date, i) => ({ id: String(i), label: dateLabel(date).slice(5), width: 13, align: "right" as const }))]}
388
+ ...scenarioDateLabels(scenario.dates).map((label, i) => ({ id: String(i), label: label.slice(5), width: 13, align: "right" as const }))]}
389
389
  renderCell={(row, column) => {
390
390
  const atSpot = row.move != null && Math.abs(row.move) < 1e-9;
391
391
  if (column.id === "spot") return { text: money(row.spot), color: row.landmark ? colors.warning : atSpot ? colors.textBright : colors.text };
@@ -413,8 +413,7 @@ export function OptionsScenarioPane({ width, height, focused }: PaneProps) {
413
413
  width={width}
414
414
  filters={[
415
415
  { id: "date", label: "Scenario date", controlRef: dateControl, value: String(scenario.controls.date),
416
- options: [...new Set([...scenario.dates, scenario.controls.date])].sort((a, b) => a - b)
417
- .map((date) => ({ value: String(date), label: `${dateLabel(date)} +${((date - scenario.position.asOf) / 86_400_000).toFixed(1)}d` })),
416
+ options: scenario.dates.map((date) => ({ value: String(date), label: `${dateLabel(date)} +${((date - scenario.position.asOf) / 86_400_000).toFixed(1)}d` })),
418
417
  onChange: (value: string) => setControls({ ...scenario.controls, date: Number(value) }) },
419
418
  // No shift reads as the "0" placeholder, so the field offers its reset only once there is a shift.
420
419
  { id: "vol", kind: "text", label: "Vol shift (pts)", width: 12, placeholder: "0", debounceMs: 0,
@@ -2,7 +2,7 @@ import { MISSING_VALUE } from "../../../utils/format";
2
2
  import type { PerpDepthPayload, PerpDepthRow, PerpDepthSnapshot, PerpLiquidationMarket, PerpLiquidationPrint, PerpLiquidationsPayload } from "../../../api-client/perps";
3
3
  import type { DataTableCell, DataTableColumn, StatItem } from "../../../components";
4
4
  import { scalarPoint, staticSeries } from "../../../components/chart/static/series";
5
- import { getTableWidth } from "../../../components/ui/table-layout";
5
+ import { getTableWidth, markHiddenTableColumns } from "../../../components/ui/table-layout";
6
6
  import type { HeadlessPaneFreshness } from "../../../types/headless";
7
7
  import type { ThemeColors } from "../../../theme/colors";
8
8
  import { compact, price, venueName } from "./model";
@@ -23,12 +23,13 @@ const usd = (n: number | null | undefined) => n == null ? MISSING_VALUE : compac
23
23
  * shorts) goes together; the venue and the contract stay, since only both tell one venue's contracts apart.
24
24
  */
25
25
  function fit<Id extends string>(columns: Record<Id, DataTableColumn>, ids: readonly Id[], drops: readonly (readonly Id[])[], width: number): DataTableColumn[] {
26
- let kept = ids.map((id) => columns[id]);
26
+ const original = ids.map((id) => columns[id]);
27
+ let kept = original;
27
28
  for (const drop of drops) {
28
29
  if (getTableWidth(kept) <= width) break;
29
30
  kept = kept.filter((column) => !(drop as readonly string[]).includes(column.id));
30
31
  }
31
- return kept;
32
+ return markHiddenTableColumns(original, kept);
32
33
  }
33
34
 
34
35
  // ---- Liquidations ----
@@ -3,6 +3,7 @@ import { isAccessDenied } from "../../../api-client/errors";
3
3
  import { usePlanAccess } from "../../../api-client/plan-access";
4
4
  import type { PerpBoardRow } from "../../../api-client/perps";
5
5
  import { ActionRow, ColumnGrid, SectionHeading, type ColumnGridCell, type ColumnGridColumn } from "../../../components";
6
+ import { hiddenTableColumnText, markHiddenTableColumns } from "../../../components/ui/table-layout";
6
7
  import { t, tf } from "../../../i18n";
7
8
  import { useAsyncResource, useAutoRefresh } from "../../../public/react";
8
9
  import { useThemeColors } from "../../../theme/theme-context";
@@ -61,12 +62,13 @@ const GAP = 2;
61
62
  const span = (columns: readonly Column[]) => columns.reduce((sum, column) => sum + column.width, 0) + GAP * (columns.length - 1);
62
63
 
63
64
  function fitColumns(width: number, venueWidth: number): Column[] {
64
- let columns = COLUMNS.map((column) => column.id === "venue" ? { ...column, width: venueWidth } : column);
65
+ const original = COLUMNS.map((column) => column.id === "venue" ? { ...column, width: venueWidth } : column);
66
+ let columns = original;
65
67
  for (const id of DROP_ORDER) {
66
68
  if (span(columns) <= width) break;
67
69
  columns = columns.filter((column) => column.id !== id);
68
70
  }
69
- return columns;
71
+ return markHiddenTableColumns(original, columns);
70
72
  }
71
73
 
72
74
  /**
@@ -145,6 +147,7 @@ export function PerpMarketsSection({ symbol, exchange, instrumentType, quote, wi
145
147
  return (
146
148
  <Box flexDirection="column" data-gloom-role="perp-markets">
147
149
  <SectionHeading title={t("Perpetuals")} />
150
+ {hiddenTableColumnText(columns) && <Text fg={colors.textDim}>{hiddenTableColumnText(columns)}</Text>}
148
151
  <ColumnGrid columns={gridColumns} rows={[header, ...body]} width={width} role="perp-markets-grid" />
149
152
  {folded.length > 0 && (
150
153
  <ActionRow expanded={expanded} width={width}
@@ -1,7 +1,7 @@
1
1
  import type { PerpBoardRow, PerpHistoryPayload, PerpLongShortRatio, PerpRankingsPayload } from "../../../api-client/perps";
2
2
  import type { DataTableCell, DataTableColumn } from "../../../components";
3
3
  import { scalarPoint, staticSeries } from "../../../components/chart/static/series";
4
- import { getTableWidth } from "../../../components/ui/table-layout";
4
+ import { getTableWidth, markHiddenTableColumns } from "../../../components/ui/table-layout";
5
5
  import { MISSING_VALUE, formatCompact } from "../../../utils/format";
6
6
  import { isUsListingExchange, publicTickerKey } from "../../../utils/exchanges";
7
7
  import { isRecord } from "../../../utils/guards";
@@ -286,7 +286,8 @@ export const RANKING_COLUMNS: PerpColumnId[] = ["market", "venue", "value", "ope
286
286
 
287
287
  /** The columns that fit the pane, the least read going first; before the last of them goes, a long market name gives up its tail. */
288
288
  function fitPerpColumns(ids: readonly PerpColumnId[], drops: readonly PerpColumnId[], width: number): DataTableColumn[] {
289
- let kept = ids.map((id) => PERP_COLUMNS[id]);
289
+ const columns = ids.map((id) => PERP_COLUMNS[id]);
290
+ let kept = columns;
290
291
  const fits = () => getTableWidth(kept) <= width;
291
292
  for (const [index, drop] of drops.entries()) {
292
293
  if (fits()) break;
@@ -296,7 +297,7 @@ function fitPerpColumns(ids: readonly PerpColumnId[], drops: readonly PerpColumn
296
297
  }
297
298
  kept = kept.filter((column) => column.id !== drop);
298
299
  }
299
- return kept;
300
+ return markHiddenTableColumns(columns, kept);
300
301
  }
301
302
  export const boardColumns = (width: number) => fitPerpColumns(BOARD_COLUMNS, BOARD_DROPS, width);
302
303
  export const compareColumns = (width: number) => fitPerpColumns(COMPARE_COLUMNS, COMPARE_DROPS, width);
@@ -22,7 +22,7 @@ import { RANGE_FROM_BARS_NOTE } from "../../../portfolio/column-values";
22
22
  import { periodPnlFigure, tickerDisplayName } from "../../../portfolio/column-values";
23
23
  import { listedSymbol } from "../../../portfolio/listed-symbol";
24
24
  import { displayWidth } from "../../../utils/format";
25
- import { dropColumnsToFit } from "../../../components/ui/table-layout";
25
+ import { dropColumnsToFit, markHiddenTableColumns } from "../../../components/ui/table-layout";
26
26
  import { sinceLastSeenTint, type SinceLastSeenRecap } from "./since-last-seen";
27
27
  import { portfolioPnlLabel } from "../../../portfolio/position-metrics";
28
28
  import { PORTFOLIO_ROW_MENU_KEYS } from "./row-actions";
@@ -363,7 +363,8 @@ export function PortfolioTickerTable({
363
363
  hiddenCompanyRef.current.ids = new Set(hiddenColumnIds.split(",").filter((id) => COMPANY_COLUMN_IDS.has(id)));
364
364
  const displayColumns = useMemo(() => {
365
365
  const hidden = new Set(hiddenColumnIds.split(","));
366
- return hiddenColumnIds ? sizedColumns.filter((column) => !hidden.has(column.id)) : sizedColumns;
366
+ const eligible = sizedColumns.filter((column) => !hiddenCompanyRef.current.ids.has(column.id));
367
+ return hiddenColumnIds ? markHiddenTableColumns(eligible, eligible.filter((column) => !hidden.has(column.id))) : sizedColumns;
367
368
  }, [hiddenColumnIds, sizedColumns]);
368
369
  // Over a period, each currency's part under the rows, so P&L adds up to the header's total as portfolio show --from prints it.
369
370
  const periodLines = columnContext.periodPnl?.lines ?? null;
@@ -51,6 +51,7 @@ import {
51
51
  buildEventRows,
52
52
  eventSourceNotice,
53
53
  formatEventMetric,
54
+ isFundListing,
54
55
  type EventFinancials,
55
56
  type EventRow,
56
57
  type EventStatus,
@@ -156,7 +157,10 @@ function sharedMetricCurrency(rows: readonly EventRow[]): string | undefined {
156
157
  return currencies.size === 1 ? only : undefined;
157
158
  }
158
159
 
159
- export function buildEventColumns(width: number, unit?: string, variant: "corporate-actions" | "earnings-estimates" = "corporate-actions"): EventColumn[] {
160
+ /** The earnings figures a fund's events never have: its rows are distributions and splits. */
161
+ const EARNINGS_COLUMN_IDS: ReadonlySet<EventColumnId> = new Set(["period", "qEps", "qRevenue", "annualEps", "annualRevenue"]);
162
+
163
+ export function buildEventColumns(width: number, unit?: string, variant: "corporate-actions" | "earnings-estimates" = "corporate-actions", fund = false): EventColumn[] {
160
164
  if (variant === "earnings-estimates") {
161
165
  return fitChartTableColumns<EventColumn>([
162
166
  { id: "date", label: "DATE", width: 11, align: "left" },
@@ -180,6 +184,7 @@ export function buildEventColumns(width: number, unit?: string, variant: "corpor
180
184
  { id: "value", label: "VALUE", width: 11, align: "right" },
181
185
  { id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
182
186
  ];
187
+ if (fund) return fitChartTableColumns(columns.filter((column) => !EARNINGS_COLUMN_IDS.has(column.id)), width, ["detail"]);
183
188
  return fitChartTableColumns(columns, width, ["annualRevenue", "annualEps", "qRevenue", "qEps", "detail"]);
184
189
  }
185
190
 
@@ -452,17 +457,23 @@ export function CorporateActionsView({
452
457
  const fundamentalsCurrency = tickerFinancials?.fundamentals?.financialCurrency;
453
458
  const marketCapCurrency = tickerFinancials?.fundamentals?.marketCapCurrency;
454
459
  const quoteCurrency = tickerFinancials?.quote?.currency;
460
+ // The listing's type, as `fn EVT` reads it: a fund's events are its distributions, never a feed's EPS rows.
461
+ const quoteType = tickerFinancials?.quote?.instrumentType;
462
+ const metadataType = tickerFinancials?.quoteMetadata?.instrumentType;
455
463
  const financialsData = useMemo<EventFinancials | null>(
456
- () => (quarterlyStatements || financialCurrency || trailingEps != null ? {
464
+ () => (quarterlyStatements || financialCurrency || trailingEps != null || quoteType || metadataType ? {
457
465
  quarterlyStatements: quarterlyStatements ?? [],
458
466
  // Their last end names the fiscal quarters (Q1 FY2027), as GUIDE and ERN name them.
459
467
  annualStatements: annualStatements ?? [],
460
468
  financialCurrency,
461
469
  fundamentals: { eps: trailingEps, epsCurrency: trailingEpsCurrency, financialCurrency: fundamentalsCurrency, marketCapCurrency, trailingEpsSource },
462
- quote: quoteCurrency ? { currency: quoteCurrency } : null,
470
+ quote: quoteCurrency || quoteType ? { currency: quoteCurrency ?? "", instrumentType: quoteType } : null,
471
+ quoteMetadata: metadataType ? { instrumentType: metadataType } : null,
463
472
  } : null),
464
- [annualStatements, financialCurrency, fundamentalsCurrency, marketCapCurrency, quarterlyStatements, quoteCurrency, trailingEps, trailingEpsCurrency, trailingEpsSource],
473
+ [annualStatements, financialCurrency, fundamentalsCurrency, marketCapCurrency, metadataType, quarterlyStatements, quoteCurrency, quoteType,
474
+ trailingEps, trailingEpsCurrency, trailingEpsSource],
465
475
  );
476
+ const fund = isFundListing(financialsData);
466
477
  const actionsLoader = useCallback((nextSymbol: string, nextExchange: string, forceRefresh: boolean) => {
467
478
  if (!dataProvider?.getCorporateActions) throw new Error("Corporate actions source unavailable");
468
479
  return dataProvider.getCorporateActions(nextSymbol, nextExchange, forceRefresh ? { cacheMode: "refresh" } : undefined);
@@ -481,7 +492,7 @@ export function CorporateActionsView({
481
492
  error: actionsError,
482
493
  reload: reloadActions,
483
494
  } = useTickerRequest<CorporateActionsData>(actionsLoader, symbol, exchange);
484
- const { data: calendarEvent, reload: reloadCalendar } = useTickerRequest(calendarLoader, symbol, exchange);
495
+ const { data: calendarEvent, loading: calendarLoading, error: calendarError, reload: reloadCalendar } = useTickerRequest(calendarLoader, symbol, exchange);
485
496
  // The listing's own day, as `earnings` reads a report date: SIE:XETRA's has passed once Berlin's day has.
486
497
  const today = listingDay(exchange);
487
498
  const actionsData = useMemo(
@@ -512,7 +523,7 @@ export function CorporateActionsView({
512
523
  ((row.qEps != null || row.annualEps != null) && !row.epsCurrency)
513
524
  || ((row.qRevenue != null || row.annualRevenue != null) && !row.revenueCurrency));
514
525
  const currencyMeta = [unit, hasUnstatedCurrency ? "? currency unstated" : null].filter(Boolean).join(" · ");
515
- const columns = useMemo(() => buildEventColumns(width, unit, variant), [width, unit, variant]);
526
+ const columns = useMemo(() => buildEventColumns(width, unit, variant, fund), [width, unit, variant, fund]);
516
527
  const sourceNotice = useMemo(() => (
517
528
  actionsLoading || analystLoading
518
529
  ? null
@@ -521,10 +532,11 @@ export function CorporateActionsView({
521
532
  symbol: symbol ?? "this ticker",
522
533
  actions: actionsData,
523
534
  actionsError,
524
- estimates: analystData,
525
- estimatesError: analystError,
535
+ // A fund has no analyst estimates to miss.
536
+ estimates: fund ? null : analystData,
537
+ estimatesError: fund ? null : analystError,
526
538
  })
527
- ), [actionsData, actionsError, actionsLoading, analystData, analystError, analystLoading, symbol, variant]);
539
+ ), [actionsData, actionsError, actionsLoading, analystData, analystError, analystLoading, fund, symbol, variant]);
528
540
  // Keyed by row id, not by position, so a reload or a shared layout comes
529
541
  // back to the same event.
530
542
  const [selectedKey, setSelectedKey] = usePluginPaneState<string | null>("selectedKey", null);
@@ -545,12 +557,14 @@ export function CorporateActionsView({
545
557
  const rowBackground = useCallback((row: EventRow) => (
546
558
  row.date > today ? futureRowBackground : undefined
547
559
  ), [futureRowBackground, today]);
548
- const loading = actionsLoading || analystLoading;
560
+ const loading = actionsLoading || analystLoading || (calendarLoading && !!recordedActions);
549
561
  const authWall = !loading && !actionsData && !analystData && (isCloudSessionRequired(actionsError) || isCloudSessionRequired(analystError));
550
562
  // Parallel requests fail with the same message ("No ticker selected"), so the
551
563
  // footer must report each distinct reason once.
552
564
  const error = [...new Set([actionsError, analystError].filter((value): value is string => !!value && !isCloudSessionRequired(value)))]
553
565
  .join(" | ") || null;
566
+ const loadError = error ?? (sourceNotice?.failed ? sourceNotice.text : null)
567
+ ?? (recordedActions && !rows.length ? calendarError : null);
554
568
  const reload = useCallback(() => {
555
569
  reloadActions();
556
570
  reloadAnalyst();
@@ -678,7 +692,8 @@ export function CorporateActionsView({
678
692
  usePaneStatusFooter({
679
693
  registrationId: footerPaneId,
680
694
  loading,
681
- error: error ?? (sourceNotice?.failed ? sourceNotice.text : null),
695
+ error: loadError,
696
+ emptyResult: !!actionsData && !rows.length && !sourceNotice,
682
697
  });
683
698
 
684
699
  usePaneNoticeFooter({
@@ -729,9 +744,9 @@ export function CorporateActionsView({
729
744
  ]}
730
745
  selectedTextOverridesCellColor
731
746
  getRowBackgroundColor={rowBackground}
732
- emptyStateTitle={loading
733
- ? (variant === "earnings-estimates" ? "Loading earnings estimates..." : "Loading events...")
734
- : error ?? sourceNotice?.text ?? (variant === "earnings-estimates" ? "No earnings estimates" : "No events")}
747
+ status={{ loading: loading && !rows.length, error: !loading && !rows.length ? loadError : null,
748
+ subject: variant === "earnings-estimates" ? "earnings estimates" : "events" }}
749
+ emptyStateTitle={sourceNotice?.text ?? (variant === "earnings-estimates" ? "No earnings estimates" : "No events")}
735
750
  />
736
751
  );
737
752
  }
@@ -24,6 +24,7 @@ import { isReasonCode, readableStatus } from "../../../utils/reason-codes";
24
24
  import { fundamentalsEpsCurrency, SERVED_TRAILING_EPS } from "../../../utils/fundamentals";
25
25
  import { isNotMeaningful, NOT_MEANINGFUL, NOT_MEANINGFUL_TEXT, NOT_MEANINGFUL_TONE, type Rate } from "../../../utils/growth";
26
26
  import {
27
+ ACTUAL_PENDING,
27
28
  earningsDateStatus,
28
29
  earningsDetail,
29
30
  earningsDetailParts,
@@ -223,8 +224,11 @@ export type EventFinancials = Pick<TickerFinancials, "quarterlyStatements" | "fi
223
224
  quoteMetadata?: Pick<NonNullable<TickerFinancials["quoteMetadata"]>, "instrumentType"> | null;
224
225
  };
225
226
 
226
- /** A fund (an ETF, a closed-end fund) reports no earnings: a feed's EPS rows for one are another company's or noise. */
227
- function isFundListing(financials: EventFinancials | null): boolean {
227
+ /**
228
+ * A fund (an ETF, a closed-end fund) reports no earnings: a feed's EPS rows, estimates and statements for one
229
+ * are another company's or noise, so its events are its distributions and splits alone.
230
+ */
231
+ export function isFundListing(financials: EventFinancials | null): boolean {
228
232
  return [financials?.quote?.instrumentType, financials?.quoteMetadata?.instrumentType].some((type) => classifyInstrumentType(type) === "fund");
229
233
  }
230
234
 
@@ -358,7 +362,8 @@ function upcomingEarningsDetail(earning: CorporateActionsData["earnings"][number
358
362
  if (earning.epsActual != null || !time) return earningsDetail(earning);
359
363
  const parts = earningsDetailParts(earning);
360
364
  if (parts.length === 0) return `Pending, ${time}`;
361
- const at = earningsDateStatus(parts[0]) ? 1 : 0;
365
+ // The time follows whether the date is announced, or that the report is out with its actual pending.
366
+ const at = earningsDateStatus(parts[0]) || parts[0] === ACTUAL_PENDING ? 1 : 0;
362
367
  return [...parts.slice(0, at), time, ...parts.slice(at)].join(", ");
363
368
  }
364
369
 
@@ -369,8 +374,9 @@ export function buildEventRows(
369
374
  currency: string,
370
375
  ): EventRow[] {
371
376
  const rows: EventRow[] = [];
372
- const quarterlyStatements = sortedQuarterlyStatements(financials);
373
- const earnings = isFundListing(financials) ? [] : data?.earnings ?? [];
377
+ const fund = isFundListing(financials);
378
+ const quarterlyStatements = fund ? [] : sortedQuarterlyStatements(financials);
379
+ const earnings = fund ? [] : data?.earnings ?? [];
374
380
  const ttm = ttmRow(quarterlyStatements, earnings, financials);
375
381
  if (ttm) rows.push(ttm);
376
382
 
@@ -432,7 +438,7 @@ export function buildEventRows(
432
438
  }
433
439
 
434
440
  const reportedPeriodEnds = reportedPeriodTimes(earnings, quarterlyStatements);
435
- for (const pair of buildEstimatePairs(estimates)) {
441
+ for (const pair of fund ? [] : buildEstimatePairs(estimates)) {
436
442
  const isFiscal = isFiscalEstimatePeriod(pair.period);
437
443
  if (!isFiscal && isReportedQuarter(pair.date, reportedPeriodEnds)) continue;
438
444
  const growth = estimatePairGrowth(pair);
@@ -9,7 +9,7 @@ import {
9
9
  } from "./model";
10
10
 
11
11
  const description =
12
- "Full-text search across earnings call transcripts, news wires, and SEC filings, with saved searches and keyword alerts.";
12
+ "Full-text search across earnings call transcripts, news wires, and SEC filings, with saved searches; free with a Gloom account, alerts on new hits are Pro.";
13
13
 
14
14
  function queryFromOptions(options?: PaneTemplateCreateOptions): string {
15
15
  return (options?.arg ?? options?.values?.query ?? "").trim();
@@ -37,6 +37,8 @@ export const researchSearchPlugin: GloomPlugin = {
37
37
  {
38
38
  id: RESEARCH_SEARCH_PANE_ID,
39
39
  reportFreshness: { status: "not-a-feed", basis: "search results" },
40
+ // Searching needs an account, not a plan: the catalog marks it Sign-in, not Pro.
41
+ reportRequirements: ["Free Gloom sign-in"],
40
42
  name: "Research Search",
41
43
  icon: "RS",
42
44
  shareItem: { open: true },
@@ -1,12 +1,24 @@
1
1
  import { ProWall, SignInWall } from "../cloud/auth-actions";
2
+ import { FLOW_FREE, FLOW_PRO_NOTE } from "../shared/options-pro-copy";
2
3
 
3
4
  /**
4
5
  * Options flow is the one scanner with no delayed tier to fall back to, so a
5
- * refusal is a call to action. Signed-out users need to sign in, not upgrade.
6
+ * refusal is a call to action. Signed out, FLOW still asks for a sign-in
7
+ * first, but says it is Pro: a free account would not stream it. The highs
8
+ * and lows scanner has a delayed tier, so a sign-in is all it asks.
6
9
  */
7
- export function ScannerDeniedState({ reason, placement, width, height }: { reason: string | null; placement: string; width: number; height: number }) {
10
+ export function ScannerDeniedState({ scanner, reason, placement, width, height }: {
11
+ scanner: "flow" | "hilo";
12
+ reason: string | null;
13
+ placement: string;
14
+ width: number;
15
+ height: number;
16
+ }) {
17
+ const flow = scanner === "flow";
8
18
  if (reason === "auth_required") {
9
- return <SignInWall placement={`${placement.replace(/-wall$/, "")}-signin`} width={width} height={height} action="stream the market scanners" />;
19
+ return <SignInWall placement={`${placement.replace(/-wall$/, "")}-signin`} width={width} height={height}
20
+ action={flow ? "stream options flow with Gloom Cloud Pro" : "stream the market scanners"}
21
+ hint={flow ? FLOW_PRO_NOTE : undefined} />;
10
22
  }
11
23
 
12
24
  return (
@@ -14,7 +26,7 @@ export function ScannerDeniedState({ reason, placement, width, height }: { reaso
14
26
  placement={placement}
15
27
  width={width} height={height}
16
28
  title="Options flow is part of Gloom Cloud Pro."
17
- message="Real-time sweeps, blocks and large premium prints across US options exchanges."
29
+ message={`Real-time sweeps, blocks and large premium prints across US options exchanges.${flow ? ` ${FLOW_FREE}` : ""}`}
18
30
  />
19
31
  );
20
32
  }
@@ -367,7 +367,7 @@ function FlowPane({ focused, width, height }: PaneProps) {
367
367
  }, [setCursorSymbol]);
368
368
 
369
369
  if (feed.denied) {
370
- return <ScannerDeniedState reason={feed.deniedReason} placement="flow-wall" width={width} height={height} />;
370
+ return <ScannerDeniedState scanner="flow" reason={feed.deniedReason} placement="flow-wall" width={width} height={height} />;
371
371
  }
372
372
 
373
373
  const queryBar = (
@@ -151,7 +151,7 @@ function HiloPane({ focused, width, height }: PaneProps) {
151
151
  }, []);
152
152
 
153
153
  if (feed.denied) {
154
- return <ScannerDeniedState reason={feed.deniedReason} placement="hilo-wall" width={width} height={height} />;
154
+ return <ScannerDeniedState scanner="hilo" reason={feed.deniedReason} placement="hilo-wall" width={width} height={height} />;
155
155
  }
156
156
 
157
157
  const renderTable = (side: Side, rows: ScannerHiloExtreme[]) => (
@@ -16,10 +16,22 @@ export function renderFilingNotice(message: string) {
16
16
  return <EmptyState title={message} />;
17
17
  }
18
18
 
19
+ /** The most decimals a filed price is read to: Form 4 prices go to four, a weighted average sometimes further. */
20
+ const FILED_PRICE_DIGITS = 6;
21
+
22
+ /**
23
+ * A price as the form filed it, never fewer than cents: $219.7219 where the
24
+ * filer wrote 219.7219, $212.17, $0.00. Rounded to cents, a weighted average
25
+ * would no longer add up to the form's own total.
26
+ */
27
+ function formatFiledPrice(value: number): string {
28
+ return formatCurrency(value, "USD", FILED_PRICE_DIGITS);
29
+ }
30
+
19
31
  export function buildInsiderTransactionTitle(transaction: InsiderTransaction): string {
20
32
  const type = transactionTypeLabel(transaction.transactionType);
21
33
  const price = transaction.pricePerShare != null
22
- ? ` @ ${formatCurrency(transaction.pricePerShare)}`
34
+ ? ` @ ${formatFiledPrice(transaction.pricePerShare)}`
23
35
  : "";
24
36
  const value = transaction.totalValue != null
25
37
  ? ` | $${formatCompact(transaction.totalValue)}`
@@ -36,7 +48,7 @@ export function buildInsiderTransactionDetailBody(transaction: InsiderTransactio
36
48
  `Security: ${transaction.securityTitle || MISSING_VALUE}${transaction.isDerivative ? " (derivative)" : ""}`,
37
49
  `Acquired/Disposed: ${transaction.acquiredDisposed === "A" ? "Acquired" : transaction.acquiredDisposed === "D" ? "Disposed" : transaction.acquiredDisposed || MISSING_VALUE}`,
38
50
  `Shares: ${transaction.shares != null ? formatNumber(transaction.shares, Number.isInteger(transaction.shares) ? 0 : 4) : MISSING_VALUE}`,
39
- `Price/Share: ${transaction.pricePerShare != null ? formatCurrency(transaction.pricePerShare) : MISSING_VALUE}`,
51
+ `Price/Share: ${transaction.pricePerShare != null ? formatFiledPrice(transaction.pricePerShare) : MISSING_VALUE}`,
40
52
  `Total Value: ${transaction.totalValue != null ? formatCurrency(transaction.totalValue) : MISSING_VALUE}`,
41
53
  `Shares Owned After: ${transaction.sharesOwned != null ? formatNumber(transaction.sharesOwned, Number.isInteger(transaction.sharesOwned) ? 0 : 4) : MISSING_VALUE}`,
42
54
  `Ownership: ${transaction.ownershipType === "D" ? "Direct" : transaction.ownershipType === "I" ? "Indirect" : transaction.ownershipType || MISSING_VALUE}${transaction.ownershipNature ? ` — ${transaction.ownershipNature}` : ""}`,
@@ -12,6 +12,7 @@ import { hasFundFactsAbroad, US_FUND_FACTS_ONLY } from "../../../utils/sec";
12
12
  import type { SecFilingItem } from "../../../types/data-provider";
13
13
  import type { FundFactsPayload } from "../../../api-client/fund-facts";
14
14
  import { errorMessage } from "../../../utils/errors";
15
+ import { filingStoryNote, loadFilingStories, type FilingStory } from "../insider/filing-stories";
15
16
  import { logFailure } from "../../../utils/log-failure";
16
17
  import { loadSecFilings } from "./client";
17
18
  import { ETF_FILING_FORMS, filterFilingsByForms, fundSeriesFilings, loadShownSecFilings, SEC_FILING_FETCH_LIMIT } from "./forms";
@@ -48,9 +49,42 @@ const hasItems = (rows: readonly HeadlessPaneRow[]) => rows.some((row) => typeof
48
49
  /** A current report's press release exhibit, printed only when some row has one; exports keep it with the filing's link. */
49
50
  const PRESS_RELEASE_COLUMN: HeadlessPaneColumn = { key: "pressReleaseUrl", header: "Press release" };
50
51
 
52
+ /** The stories that report a Form 4, under its row, as INS prints them under its lines; JSON has them as `stories`. */
53
+ const STORIES_NOTE_COLUMN: HeadlessPaneColumn = {
54
+ key: "storiesNote", header: "Stories", underRow: true, format: (value) => typeof value === "string" ? value : "",
55
+ };
56
+
51
57
  function secTextColumns(rows: readonly HeadlessPaneRow[]): HeadlessPaneColumn[] {
52
58
  const columns = hasItems(rows) ? SEC_COLUMNS : SEC_COLUMNS.filter((column) => column.key !== "items");
53
- return rows.some((row) => typeof row.pressReleaseUrl === "string" && row.pressReleaseUrl) ? [...columns, PRESS_RELEASE_COLUMN] : columns;
59
+ const withRelease = rows.some((row) => typeof row.pressReleaseUrl === "string" && row.pressReleaseUrl) ? [...columns, PRESS_RELEASE_COLUMN] : columns;
60
+ return rows.some((row) => typeof row.storiesNote === "string" && row.storiesNote) ? [...withRelease, STORIES_NOTE_COLUMN] : withRelease;
61
+ }
62
+
63
+ const INSIDER_FORM = /^4(?:\/A)?$/i;
64
+
65
+ /**
66
+ * The Form 4 rows with the stories that report them: `stories` on the row, and
67
+ * a note under it that names each (`fn story <id>` opens one). The other rows,
68
+ * and a Form 4 Gloom Cloud could not be asked about, stay as they were, and
69
+ * the report says nothing of it: the stories are a lead, not its data.
70
+ */
71
+ async function withFilingStories(
72
+ rows: HeadlessPaneRow[],
73
+ ctx: HeadlessPaneContext,
74
+ dependencies: SecHeadlessDependencies,
75
+ ): Promise<HeadlessPaneRow[]> {
76
+ const accessions = rows
77
+ .filter((row) => typeof row.form === "string" && INSIDER_FORM.test(row.form.trim()))
78
+ .map((row) => row.accessionNumber)
79
+ .filter((value): value is string => typeof value === "string");
80
+ const load = dependencies.loadFilingStories;
81
+ if (!load || accessions.length === 0) return rows;
82
+ const found = await load(accessions, ctx).catch(logFailure("sec.headless", "Read the stories reporting Form 4s failed", new Map<string, FilingStory[]>()));
83
+ return rows.map((row) => {
84
+ const stories = typeof row.accessionNumber === "string" ? found.get(row.accessionNumber) : undefined;
85
+ if (!stories) return row;
86
+ return { ...row, stories: stories.map((story) => ({ ...story })), ...(stories.length ? { storiesNote: stories.map(filingStoryNote).join("\n") } : {}) };
87
+ });
54
88
  }
55
89
 
56
90
  /**
@@ -74,10 +108,13 @@ export interface SecHeadlessDependencies {
74
108
  args: HeadlessPaneLoadArgs,
75
109
  ctx: HeadlessPaneContext,
76
110
  ): Promise<SecFilingItem[]>;
111
+ /** The stories reporting each Form 4, by accession number (Gloom Cloud's match); none asked when absent. */
112
+ loadFilingStories?(accessions: readonly string[], ctx: HeadlessPaneContext): Promise<Map<string, FilingStory[]>>;
77
113
  }
78
114
 
79
115
  const defaultDependencies: SecHeadlessDependencies = {
80
116
  loadFilings: (symbol, limit, _args, ctx) => loadSecFilings(ctx.marketData, symbol, limit),
117
+ loadFilingStories: (accessions, ctx) => loadFilingStories(accessions, ctx.apiClient),
81
118
  };
82
119
 
83
120
  /**
@@ -140,14 +177,15 @@ export function createSecHeadless(dependencies: SecHeadlessDependencies = defaul
140
177
  // A form filter searches every filing listed for the issuer and keeps the supplements it names; without
141
178
  // one, a bank's pricing supplements and a trust's other funds stay out unless --all, as in `filings`.
142
179
  const { filings, hidden } = await loadShownSecFilings(load, limit, { form: form || null, all: args.options.all === true });
143
- const note = hidden && hiddenFilingsNote(hidden);
144
- const rows = buildSecFilingRows(filings);
180
+ const hiddenNote = hidden && hiddenFilingsNote(hidden);
181
+ const rows = await withFilingStories(buildSecFilingRows(filings), ctx, dependencies);
182
+ const notes = hiddenNote ? [hiddenNote] : [];
145
183
  // A listing abroad whose company files nothing with the SEC says where its exchange publishes its announcements.
146
184
  const page = !form && filings.length === 0 ? listingAnnouncementsPage(symbol) : null;
147
185
  return {
148
186
  rows,
149
187
  textColumns: secTextColumns(rows),
150
- ...(note || filings[0]?.companyFrom ? { notes: [...(note ? [note] : []), ...companyDataNotes(filings[0]?.companyFrom)] } : {}),
188
+ ...(notes.length || filings[0]?.companyFrom ? { notes: [...notes, ...companyDataNotes(filings[0]?.companyFrom)] } : {}),
151
189
  ...(form ? { empty: `No ${form} filings found for ${symbol}.` }
152
190
  : page ? { empty: `${symbol} files no SEC reports. ${page.name}: ${page.url}` } : {}),
153
191
  metadata: {