@gloom-sh/terminal 0.20.22 → 0.20.23

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 (195) hide show
  1. package/package.json +1 -1
  2. package/src/account/heard-from-question.tsx +6 -4
  3. package/src/account/heard-from.ts +3 -4
  4. package/src/api-client/exchange-announcements.ts +2 -2
  5. package/src/api-client/heard-from.ts +5 -7
  6. package/src/api-client/ownership-disclosures.ts +38 -5
  7. package/src/api-client/types/ticker-data.ts +3 -1
  8. package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
  9. package/src/cli/commands/market.ts +5 -3
  10. package/src/cli/commands/overview.ts +7 -9
  11. package/src/cli/listing-arg.ts +45 -18
  12. package/src/cli/pane-functions/catalog-snapshot.json +2 -2
  13. package/src/cli/pane-functions/data.ts +3 -1
  14. package/src/cli/pane-functions/freshness.ts +6 -1
  15. package/src/cli/pane-functions/function-help.ts +0 -2
  16. package/src/cli/pane-functions/market-session.ts +12 -2
  17. package/src/cli/pane-functions/screenshot-payload.ts +3 -1
  18. package/src/cli/symbol-list.ts +52 -14
  19. package/src/cli/ticker-resolution.ts +133 -38
  20. package/src/components/chart/composite/composite-chart.tsx +12 -0
  21. package/src/components/chart/composite/types.ts +18 -0
  22. package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
  23. package/src/components/chart-table/header.tsx +11 -5
  24. package/src/components/chart-table/selection.ts +20 -1
  25. package/src/components/data-table/view.tsx +2 -0
  26. package/src/components/feed-data-table/stack-view.tsx +85 -5
  27. package/src/components/layout/pane/header.tsx +12 -30
  28. package/src/components/ticker/badge/index.tsx +9 -4
  29. package/src/components/ticker/badge/list.tsx +3 -1
  30. package/src/components/ui/data-table/index.tsx +7 -1
  31. package/src/components/ui/data-table/muted-row.tsx +47 -0
  32. package/src/components/ui/data-table/opentui/index.tsx +42 -11
  33. package/src/components/ui/data-table/spill.ts +36 -0
  34. package/src/components/ui/data-table/types.ts +17 -1
  35. package/src/components/ui/data-table/use-column-order.ts +11 -0
  36. package/src/components/ui/icon.tsx +50 -3
  37. package/src/components/ui/list-view.tsx +2 -2
  38. package/src/components/ui/table-layout.ts +32 -0
  39. package/src/components/ui/terminal-hover-label.tsx +49 -0
  40. package/src/components/use-pinned-moment.ts +222 -13
  41. package/src/core/state/app/state.ts +11 -2
  42. package/src/core/state/app/types.ts +2 -1
  43. package/src/data/sqlite/access.ts +14 -1
  44. package/src/data/sqlite/checkpointer.ts +2 -2
  45. package/src/data/sqlite/database.ts +4 -0
  46. package/src/docs/snapshot.json +180 -26
  47. package/src/i18n/es.ts +1 -0
  48. package/src/i18n/ja.ts +1 -0
  49. package/src/i18n/ko.ts +1 -0
  50. package/src/i18n/zh-cn.ts +1 -0
  51. package/src/i18n/zh-tw.ts +1 -0
  52. package/src/market-data/market/freshness.ts +2 -2
  53. package/src/market-data/market/globex-day.ts +14 -0
  54. package/src/market-data/published-us-sessions.ts +3 -2
  55. package/src/market-data/quotes/live-valuation.ts +4 -2
  56. package/src/market-data/quotes/metadata.ts +48 -5
  57. package/src/market-data/quotes/regular-session-valuation.ts +12 -1
  58. package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
  59. package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
  60. package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
  61. package/src/plugins/builtin/chat/channels.ts +5 -2
  62. package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
  63. package/src/plugins/builtin/chat/content/footer.tsx +17 -7
  64. package/src/plugins/builtin/chat/content/index.tsx +108 -36
  65. package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
  66. package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
  68. package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
  69. package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
  70. package/src/plugins/builtin/chat/content/types.ts +2 -0
  71. package/src/plugins/builtin/chat/controller/channels.ts +15 -15
  72. package/src/plugins/builtin/chat/controller/index.ts +140 -34
  73. package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
  74. package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
  75. package/src/plugins/builtin/chat/controller/send.ts +41 -17
  76. package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
  77. package/src/plugins/builtin/chat/controller/state.ts +17 -8
  78. package/src/plugins/builtin/chat/controller/storage.ts +41 -4
  79. package/src/plugins/builtin/chat/controller/view.ts +6 -3
  80. package/src/plugins/builtin/chat/index.tsx +1 -1
  81. package/src/plugins/builtin/chat/layout.ts +8 -1
  82. package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
  83. package/src/plugins/builtin/chat/message/header.tsx +112 -30
  84. package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
  85. package/src/plugins/builtin/chat/message/render-state.ts +4 -2
  86. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  87. package/src/plugins/builtin/chat/message/types.ts +5 -0
  88. package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
  89. package/src/plugins/builtin/company-kpis/model.ts +11 -3
  90. package/src/plugins/builtin/correlation/compute.ts +6 -1
  91. package/src/plugins/builtin/custom-view/loader.ts +95 -34
  92. package/src/plugins/builtin/custom-view/pane.tsx +31 -41
  93. package/src/plugins/builtin/custom-view/table.ts +201 -0
  94. package/src/plugins/builtin/dividend-yield/client.ts +14 -17
  95. package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
  96. package/src/plugins/builtin/dividend-yield/model.ts +45 -6
  97. package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
  98. package/src/plugins/builtin/dividend-yield/types.ts +2 -3
  99. package/src/plugins/builtin/dividend-yield/view.ts +22 -2
  100. package/src/plugins/builtin/econ/calendar-model.ts +135 -0
  101. package/src/plugins/builtin/econ/columns.ts +132 -0
  102. package/src/plugins/builtin/econ/index.tsx +25 -65
  103. package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
  104. package/src/plugins/builtin/holders/disclosures.ts +20 -6
  105. package/src/plugins/builtin/holders/headless.ts +2 -2
  106. package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
  107. package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
  108. package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
  109. package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
  110. package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
  111. package/src/plugins/builtin/market-halts/pane.tsx +14 -2
  112. package/src/plugins/builtin/news/wire/news/row.ts +5 -12
  113. package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
  114. package/src/plugins/builtin/pe-band/headless.ts +1 -1
  115. package/src/plugins/builtin/pe-band/model.ts +41 -18
  116. package/src/plugins/builtin/pe-band/pane.tsx +6 -5
  117. package/src/plugins/builtin/perps/equity-row.tsx +4 -6
  118. package/src/plugins/builtin/perps/markets-section.tsx +19 -15
  119. package/src/plugins/builtin/perps/model.ts +10 -2
  120. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
  121. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
  122. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
  123. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
  124. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
  125. package/src/plugins/builtin/research/event-data.ts +3 -1
  126. package/src/plugins/builtin/research/event-model.ts +17 -15
  127. package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
  128. package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
  129. package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
  130. package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
  131. package/src/plugins/builtin/sec/headless.ts +8 -8
  132. package/src/plugins/builtin/sec/index.tsx +69 -29
  133. package/src/plugins/builtin/shared/report-freshness.ts +4 -1
  134. package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
  135. package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
  136. package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
  137. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
  138. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
  139. package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
  140. package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
  141. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
  142. package/src/plugins/builtin/time-sales/model.ts +16 -9
  143. package/src/plugins/builtin/time-sales/pane.tsx +27 -24
  144. package/src/plugins/builtin/treasury-daily/client.ts +43 -9
  145. package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
  146. package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
  147. package/src/portfolio/positions-import/parse.ts +14 -6
  148. package/src/portfolio/positions-import/plan.ts +3 -2
  149. package/src/react/async-resource.ts +3 -1
  150. package/src/renderers/dom/data-table/index.tsx +40 -0
  151. package/src/renderers/dom/data-table/row.tsx +39 -3
  152. package/src/renderers/dom/desktop/icons.tsx +147 -3
  153. package/src/renderers/dom/desktop/popover.tsx +2 -2
  154. package/src/renderers/dom/host/media-surface.tsx +204 -45
  155. package/src/renderers/dom/host/tabs.tsx +1 -0
  156. package/src/renderers/dom/styles.css +14 -2
  157. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  158. package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
  159. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  160. package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
  161. package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
  162. package/src/sources/gloomberb-cloud/index.ts +8 -7
  163. package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
  164. package/src/sources/listing-symbols.ts +7 -1
  165. package/src/sources/provider-router/cache.ts +5 -4
  166. package/src/sources/provider-router/financials.ts +40 -18
  167. package/src/state/app/tab-cursor.ts +47 -6
  168. package/src/telemetry/stall-clocks.ts +3 -0
  169. package/src/telemetry/stall-reports.ts +12 -3
  170. package/src/telemetry/windows-process-activity.ts +41 -0
  171. package/src/telemetry/windows-time.ts +32 -0
  172. package/src/test-support/scoped-earnings.ts +24 -0
  173. package/src/tickers/terminal-codes.ts +1 -6
  174. package/src/time-series/daily-valuation.ts +13 -6
  175. package/src/time-series/filed-trailing-eps.ts +16 -3
  176. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  177. package/src/time-series/fundamentals/historical-valuation.ts +20 -0
  178. package/src/time-series/fundamentals/series.ts +13 -1
  179. package/src/time-series/valuation-currency.ts +2 -0
  180. package/src/types/financials.ts +46 -10
  181. package/src/ui/dialog-context.ts +8 -0
  182. package/src/utils/datetime-format.ts +23 -1
  183. package/src/utils/declared-dividends.ts +12 -2
  184. package/src/utils/exchange-announcements.ts +4 -1
  185. package/src/utils/exchange-notation.generated.ts +3 -1
  186. package/src/utils/exchanges.ts +2 -1
  187. package/src/utils/fundamentals.ts +1 -0
  188. package/src/utils/main-thread-stall.ts +9 -1
  189. package/src/utils/rpc-timeout-error.ts +36 -11
  190. package/src/utils/sec.ts +3 -1
  191. package/src/utils/share-multiples.ts +1 -1
  192. package/src/utils/stall-process-activity.ts +70 -0
  193. package/src/utils/statement-scope.ts +103 -0
  194. package/src/utils/trailing-eps.ts +1 -1
  195. package/src/utils/zoned-date-time.ts +1 -0
@@ -3,7 +3,7 @@ import type { PluginModule } from "../plugin-module";
3
3
  import type { SecFilingDocument, SecFilingItem } from "../../../types/data-provider";
4
4
  import { apiClient } from "../../../api-client";
5
5
  import { useAsyncResource } from "../../../public/react";
6
- import { EXCHANGE_FILING_HISTORY_LIMIT, exchangeFilingForm, localFilingListing, localFilingRows, PRESENTATIONS_FORM } from "./exchange-filings";
6
+ import { emptyOwnershipArchive, exchangeFilingForms, exchangeFilingHistoryLimit, localFilingListing, localFilingRows, PRESENTATIONS_FORM, RECENT_EXCHANGE_FILING_LIMIT } from "./exchange-filings";
7
7
  import { useResolvedEntryValue, useSecFilingDocuments, useSecFilingsQuery, useTickerFinancials } from "../../../market-data/hooks";
8
8
  import { getSharedMarketDataCoordinator } from "../../../market-data/coordinator";
9
9
  import { useShortcut } from "../../../react/input";
@@ -353,9 +353,11 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
353
353
  const local = ticker && !forms && eligibleTicker ? localFilingListing(ticker.metadata.ticker, ticker.metadata.exchange) : null;
354
354
  const localSymbol = local?.symbol;
355
355
  const localVenue = local?.exchange;
356
- const localForm = exchangeFilingForm(localVenue);
356
+ const localForms = exchangeFilingForms(localVenue);
357
+ const hasLocalForms = localForms.length > 0;
357
358
  const [storedGroup, setFormGroup] = usePluginPaneState<string>(forms ? "fundFormGroup" : "formGroup", ALL_FORMS);
358
- const localKind = localForm && localForm.value === storedGroup ? localForm.kind : undefined;
359
+ const localForm = localForms.find(form => form.value === storedGroup);
360
+ const localKind = localForm?.kind;
359
361
  const presentations = localKind === PRESENTATIONS_FORM;
360
362
  const formGroup = localKind || groups.some((group) => group.value === storedGroup) ? storedGroup : ALL_FORMS;
361
363
  // A ticker can map to more than one filer (CIK); each can be listed alone.
@@ -381,12 +383,40 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
381
383
  const readLocal = useCallback(() => apiClient.getCloudExchangeAnnouncements({
382
384
  symbol: localSymbol!,
383
385
  exchange: localVenue!,
384
- limit: localKind || localVenue === "JPX" ? EXCHANGE_FILING_HISTORY_LIMIT : 50,
386
+ limit: localVenue === "HOSE" && !localKind
387
+ ? RECENT_EXCHANGE_FILING_LIMIT : exchangeFilingHistoryLimit(localVenue, localKind),
385
388
  ...(localKind ? { kind: localKind } : {}),
386
389
  }), [localSymbol, localVenue, localKind]);
387
390
  const localFeed = useAsyncResource(localSymbol && localVenue ? readLocal : null);
388
- const localRows = useMemo(() => localFeed.data && localVenue && (localKind || (formGroup === ALL_FORMS && issuerCik === ALL_FORMS))
389
- ? localFilingRows(localFeed.data, showSupplements) : [], [localFeed.data, localVenue, formGroup, issuerCik, localKind, showSupplements]);
391
+ const [archiveSymbol, setArchiveSymbol] = useState<string | undefined>();
392
+ const showLocalFilings = !!localKind || (formGroup === ALL_FORMS && issuerCik === ALL_FORMS);
393
+ const hasOlderLocalFilings = showLocalFilings && localVenue === "HOSE" && localFeed.data !== null
394
+ && (localFeed.data.total ?? 0) > localFeed.data.announcements.length;
395
+ // HOSE's longer read can be slow. Keep the recent notices while it loads,
396
+ // including when opening a saved link to an older filing.
397
+ const openOlderFiling = openItemId?.startsWith("exchange:") &&
398
+ !localFeed.data?.announcements.some(item => `exchange:${item.url}` === openItemId);
399
+ const readOlderFilings = hasOlderLocalFilings && (archiveSymbol === localSymbol || openOlderFiling);
400
+ useEffect(() => {
401
+ if (hasOlderLocalFilings && openOlderFiling) setArchiveSymbol(localSymbol);
402
+ }, [hasOlderLocalFilings, openOlderFiling, localSymbol]);
403
+ const readArchive = useCallback(() => apiClient.getCloudExchangeAnnouncements({
404
+ symbol: localSymbol!,
405
+ exchange: localVenue!,
406
+ limit: exchangeFilingHistoryLimit(localVenue),
407
+ }), [localSymbol, localVenue]);
408
+ const archiveFeed = useAsyncResource(readOlderFilings ? readArchive : null);
409
+ const localData = archiveFeed.data ?? localFeed.data;
410
+ const localLoading = localFeed.loading || archiveFeed.loading;
411
+ const localError = archiveFeed.error ?? localFeed.error;
412
+ const localRows = useMemo(() => {
413
+ if (!localData || !showLocalFilings) return [];
414
+ const rows = localFilingRows(localData, showSupplements);
415
+ if (!archiveFeed.data?.stale || !localFeed.data) return rows;
416
+ const recent = localFilingRows(localFeed.data, showSupplements);
417
+ const known = new Set(recent.map(row => row.documentKey));
418
+ return [...recent, ...rows.filter(row => !known.has(row.documentKey))];
419
+ }, [localData, localFeed.data, archiveFeed.data, showLocalFilings, showSupplements]);
390
420
 
391
421
  const openLocal = localRows.find(row => `exchange:${row.url}` === openItemId);
392
422
  const timeline = useMemo(() => {
@@ -402,8 +432,15 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
402
432
  const scrollRef = useRef<ScrollBoxRenderable | null>(null);
403
433
  const loadMore = useTableLoadMore(
404
434
  scrollRef,
405
- visibleCount < timeline.length,
406
- () => setVisibleCount((current) => Math.min(timeline.length, current + SEC_FILING_PAGE_SIZE)),
435
+ visibleCount < timeline.length || (hasOlderLocalFilings && !readOlderFilings),
436
+ () => {
437
+ if (visibleCount < timeline.length) {
438
+ setVisibleCount((current) => Math.min(timeline.length, current + SEC_FILING_PAGE_SIZE));
439
+ } else {
440
+ setArchiveSymbol(localSymbol);
441
+ setVisibleCount((current) => current + SEC_FILING_PAGE_SIZE);
442
+ }
443
+ },
407
444
  );
408
445
  useEffect(() => {
409
446
  setVisibleCount(SEC_FILING_PAGE_SIZE);
@@ -418,17 +455,17 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
418
455
  // A pricing supplement opened from the command bar shows the supplements rather than closing.
419
456
  const supplement = !showSupplements && scopedFilings.some((filing) => filing.accessionNumber === openItemId && isSupplement(filing));
420
457
  if (supplement) setShowSupplements(true);
421
- else if (!loading && !localFeed.loading) setOpenItemId(null);
458
+ else if (!loading && !localLoading && !archiveFeed.error) setOpenItemId(null);
422
459
  return;
423
460
  }
424
461
  if (index >= visibleCount) {
425
462
  setVisibleCount(Math.ceil((index + 1) / SEC_FILING_PAGE_SIZE) * SEC_FILING_PAGE_SIZE);
426
463
  }
427
- }, [timeline, isSupplement, loading, localFeed.loading, openItemId, scopedFilings, setOpenItemId, setShowSupplements, showSupplements, visibleCount]);
464
+ }, [timeline, isSupplement, loading, localLoading, archiveFeed.error, openItemId, scopedFilings, setOpenItemId, setShowSupplements, showSupplements, visibleCount]);
428
465
  const error = !localKind && filingsEntry?.error && filingsEntry.error.reasonCode !== "NO_DATA" ? filingsEntry.error.message : null;
429
466
  // Hosted, the only filings source is Gloom Cloud, which needs an account.
430
467
  const cloudSession = useResearchCloudSession();
431
- const authWall = !localFeed.loading && !localRows.length && (!!localKind || formFilings.length === 0) && (isCloudSessionRequired(error) || isCloudSessionRequired(localFeed.error));
468
+ const authWall = !localLoading && !localRows.length && (!!localKind || formFilings.length === 0) && (isCloudSessionRequired(error) || isCloudSessionRequired(localError));
432
469
 
433
470
  const openFiling = openItemId
434
471
  ? filings.find((filing) => filing.accessionNumber === openItemId) ?? null
@@ -514,7 +551,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
514
551
  useShortcut((event) => {
515
552
  if (!isPlainKey(event, "r")) return;
516
553
  refresh();
517
- if (localVenue) localFeed.reload();
554
+ if (localVenue) (readOlderFilings ? archiveFeed : localFeed).reload();
518
555
  if (forms && eligibleTicker) reloadFacts();
519
556
  }, { enabled: focused, scope: "sec" });
520
557
  // Signing in must retry the request the wall was shown for.
@@ -546,14 +583,14 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
546
583
  focused,
547
584
  // A current report links its press release, where its figures are, when its index names one.
548
585
  url: openLocal ? openLocal.url : openFiling ? openFiling.pressReleaseUrl ?? openFiling.filingUrl
549
- : factsUrl ?? abroadPage ?? (localKind ? localFeed.data?.page : null) ?? announcements?.url,
586
+ : factsUrl ?? abroadPage ?? (localKind ? localData?.page : null) ?? announcements?.url,
550
587
  source: openLocal ? openLocal.source : openFiling ? openFiling.form : facts?.covered ? listNames(fundFactPublishers(facts)) : facts?.note ? facts.note.filing.form : announcements?.name ?? null,
551
588
  label: openLocal ? "filing" : openFiling ? openFiling.pressReleaseUrl ? "press release" : "filing"
552
589
  : factsUrl ? "source" : abroadPage ? "issuer page" : announcements ? "announcements" : "filing",
553
590
  // Rows read in the background for their insiders do not hold up the pane.
554
- loading: loading || localFeed.loading || loadingDocuments || (!!loadingKey && viewedTargets.some((target) => target.accessionNumber === loadingKey)),
555
- error: authWall ? null : error ?? detailError ?? localFeed.error,
556
- stale: !!localKind && localFeed.data?.stale === true,
591
+ loading: loading || localLoading || loadingDocuments || (!!loadingKey && viewedTargets.some((target) => target.accessionNumber === loadingKey)),
592
+ error: authWall ? null : error ?? detailError ?? localError,
593
+ stale: (!!localKind || !!archiveFeed.data) && localData?.stale === true,
557
594
  hints,
558
595
  showOpenHint: !!openLocal || !!(openFiling ? openFiling.filingUrl : factsUrl ?? abroadPage ?? announcements),
559
596
  });
@@ -562,7 +599,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
562
599
  useCompanyDataFooter(issuerFilings[0]?.companyFrom, !openFiling);
563
600
  usePaneNoticeFooter({
564
601
  registrationId: "sec:form-filter",
565
- notices: (localRows.length || localKind) && localFeed.data?.coverage ? [localFeed.data.coverage] : filterHistoryCapped
602
+ notices: (localRows.length || localKind) && localData?.coverage ? [localData.coverage] : filterHistoryCapped
566
603
  ? [`Only the ${SEC_FILING_FETCH_LIMIT.toLocaleString("en-US")} most recent filings of this issuer were searched; older fund filings are not listed.`]
567
604
  : [],
568
605
  focused,
@@ -578,7 +615,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
578
615
  defaultValue: ALL_FORMS,
579
616
  options: [
580
617
  { value: ALL_FORMS, label: forms ? "All fund forms" : "All forms" },
581
- ...(localForm ? [{ value: localForm.value, label: localForm.label }] : []),
618
+ ...localForms.map(({ value, label }) => ({ value, label })),
582
619
  ...groups.map((group) => ({ value: group.value, label: group.label })),
583
620
  ],
584
621
  onChange: (value: string) => { setFormGroup(value); setSelectedIdx(0, { immediate: true }); setOpenItemId(null); },
@@ -600,7 +637,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
600
637
  defaultValue: false,
601
638
  onChange: (value: boolean) => { setShowSupplements(value); setSelectedIdx(0, { immediate: true }); setOpenItemId(null); },
602
639
  }] : []),
603
- ], [formGroup, forms, groups, issuerCik, issuers, localForm, localKind, setFormGroup, setIssuer, setOpenItemId, setSelectedIdx, setShowSupplements, showSupplements, supplementCount]);
640
+ ], [formGroup, forms, groups, issuerCik, issuers, localForms, localKind, setFormGroup, setIssuer, setOpenItemId, setSelectedIdx, setShowSupplements, showSupplements, supplementCount]);
604
641
  // The ticker and the filer once, beside the filters: every row is their filing.
605
642
  const issuerMeta = !localKind && issuers.length === 1 ? secIssuerLabel(issuers[0]!).replace(/CIK 0+/, "CIK ") : undefined;
606
643
  const queryBar = (
@@ -650,11 +687,11 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
650
687
  )
651
688
  : body;
652
689
  if (authWall) return withFacts(<SignInWall placement="sec-signin" action="view SEC filings" needsVerification={cloudSession.needsVerification} />);
653
- if (!localForm && (loading || localFeed.loading) && filings.length === 0 && !localRows.length) return withFacts(<Spinner label="Loading SEC filings..." />);
690
+ if (!hasLocalForms && (loading || localLoading) && filings.length === 0 && !localRows.length) return withFacts(<Spinner label="Loading SEC filings..." />);
654
691
  // The fund view keeps its facts and query bar over an empty or failed filings list, which says why in the table.
655
- const feedError = localFeed.error ?? error;
656
- if (!forms && !localForm && feedError && formFilings.length === 0 && !localRows.length) return <EmptyState title="Filings unavailable." message={feedError} />;
657
- if (!forms && !localForm && formFilings.length === 0 && !localRows.length) {
692
+ const feedError = localError ?? error;
693
+ if (!forms && !hasLocalForms && feedError && formFilings.length === 0 && !localRows.length) return <EmptyState title="Filings unavailable." message={feedError} />;
694
+ if (!forms && !hasLocalForms && formFilings.length === 0 && !localRows.length) {
658
695
  // A company from abroad that files nothing with the SEC says so and links its exchange's announcements, as `filings` does.
659
696
  if (equityAbroad) {
660
697
  const listing = { symbol: parsePublicTickerKey(ticker.metadata.ticker).symbol, exchange: equityAbroad, name: ticker.metadata.name ?? null };
@@ -722,16 +759,19 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
722
759
  titleLabel="Filing"
723
760
  timeColumn={localRows.some(row => row.dateBasis === "catalogue") ? { ...FILED_COLUMN, label: "Date" } : FILED_COLUMN}
724
761
  emptyStateTitle={presentations
725
- ? localFeed.loading ? "Loading presentations..."
726
- : localFeed.error || localFeed.data?.stale ? "Presentation archive unavailable or incomplete."
762
+ ? localLoading ? "Loading presentations..."
763
+ : localError || localData?.stale ? "Presentation archive unavailable or incomplete."
727
764
  : "No investor conference presentations in the past year."
728
- : localForm && (loading || localFeed.loading) ? "Loading filings..."
729
- : localForm && feedError ? "Filings unavailable."
730
- : localKind === "results" ? "No SGX results or presentations."
765
+ : hasLocalForms && (loading || localLoading) ? "Loading filings..."
766
+ : hasLocalForms && feedError ? "Filings unavailable."
767
+ : localKind === "ownership" ? emptyOwnershipArchive(localData?.stale)
768
+ : localKind === "results" ? localFeed.data?.stale
769
+ ? "Results archive unavailable or incomplete."
770
+ : "No results or presentations in the exchange archive."
731
771
  : forms && formFilings.length === 0 ? fundEmptyTitle
732
772
  : supplementCount > 0 && !showSupplements ? "Only pricing supplements."
733
773
  : formGroup === ALL_FORMS ? "No SEC filings." : "No filings of these forms."}
734
- emptyStateHint={localForm && feedError ? feedError
774
+ emptyStateHint={hasLocalForms && feedError ? feedError
735
775
  : forms && formFilings.length === 0 ? fundEmptyHint
736
776
  : supplementCount > 0 && !showSupplements ? "Turn on Pricing supplements to list them." : undefined}
737
777
  scrollRef={scrollRef}
@@ -148,11 +148,14 @@ export function quoteFreshnessFields(
148
148
  * for (`asOfDate`), not by the older last trade. A board publishes one per
149
149
  * quote it shows, so `fn` and `shot` date it as `quote` dates the same quotes.
150
150
  */
151
- export function quoteObservation(quote: Quote, now = Date.now()): QuoteFreshnessFields & { quoteSymbol: string; updatedAt: number; asOfDate?: string } {
151
+ export function quoteObservation(quote: Quote, now = Date.now()): QuoteFreshnessFields & {
152
+ quoteSymbol: string; updatedAt: number; asOfDate?: string; futuresPriceKind?: Quote["futuresPriceKind"];
153
+ } {
152
154
  return {
153
155
  ...quoteFreshnessFields(quote, now),
154
156
  quoteSymbol: quote.symbol,
155
157
  updatedAt: quoteHeadlineTime(quote),
158
+ ...(quote.futuresPriceKind ? { futuresPriceKind: quote.futuresPriceKind } : {}),
156
159
  ...(quote.nominalPrice ? { asOfDate: quote.nominalPrice.session } : {}),
157
160
  };
158
161
  }
@@ -179,8 +179,7 @@ function aggregateQuarterlyStatements(
179
179
  // statements provider used a different definition for that line.
180
180
  const mixed = statements.some(({ filledFrom }) =>
181
181
  filledFrom?.source === "results"
182
- && filledFrom.documents.some((document) => document.source === "mops")
183
- && filledFrom.definitions?.some(({ field }) => statements.some((statement) =>
182
+ && filledFrom.definitions?.some(({ field }) => filledFrom.fields.includes(field) && statements.some((statement) =>
184
183
  statement.filledFrom?.source !== "results" || !statement.filledFrom.fields.includes(field),
185
184
  )),
186
185
  );
@@ -0,0 +1,61 @@
1
+ import type { ReactNode } from "react";
2
+ import { DataTableView, ExternalLinkText, PaneLinkMenu, type DataTableColumn } from "../../../../components";
3
+ import { colors } from "../../../../theme/colors";
4
+ import type { TaiwanExchangeStatement } from "../../../../types/financials";
5
+ import { Box, Text, useUiCapabilities } from "../../../../ui";
6
+ import { formatDay } from "../../../../utils/day-format";
7
+
8
+ const formatAmount = new Intl.NumberFormat("en-US", { maximumFractionDigits: 8 });
9
+
10
+ export function ExchangeStatementTable({
11
+ focused, statement, width, queryBar,
12
+ }: {
13
+ focused: boolean;
14
+ statement: TaiwanExchangeStatement;
15
+ width: number;
16
+ queryBar: ReactNode;
17
+ }) {
18
+ const { nativePaneChrome } = useUiCapabilities();
19
+ const { currency, source } = statement;
20
+ const period = statement.kind === "income"
21
+ ? `${statement.months} months ended ${formatDay(statement.periodEnd)}`
22
+ : `As of ${formatDay(statement.periodEnd)}`;
23
+ const publisher = source.venue === "TPEX" ? "TPEx" : "TWSE";
24
+ const columns: DataTableColumn[] = [
25
+ { id: "metric", label: "Metric", width: Math.max(18, Math.min(42, width - 23)), align: "left" },
26
+ { id: "value", label: currency, width: 21, align: "right" },
27
+ ];
28
+ return (
29
+ <PaneLinkMenu>
30
+ <DataTableView
31
+ focused={focused}
32
+ items={statement.figures}
33
+ columns={columns}
34
+ selection={{ kind: "none" }}
35
+ sortColumnId={null}
36
+ sortDirection="desc"
37
+ emptyStateTitle="No exchange figures"
38
+ getItemKey={(row) => row.sourceLabel}
39
+ columnReorder={false}
40
+ renderCell={(row, column) => column.id === "metric"
41
+ ? { text: row.perShare ? `${row.label} (per share)` : row.label }
42
+ : { text: formatAmount.format(row.value), value: row.value }}
43
+ getExportMetadata={() => [
44
+ ["Period", period],
45
+ ["Currency", currency],
46
+ ["Exchange export date", source.snapshotDate],
47
+ ["Source", source.url],
48
+ ]}
49
+ resetScrollKey={`${statement.kind}:${statement.periodEnd}`}
50
+ showHorizontalScrollbar
51
+ rootBefore={<>
52
+ {queryBar}
53
+ <Box flexDirection="row" flexWrap="wrap" gap={1} paddingX={nativePaneChrome ? 0 : 1}>
54
+ <Text fg={colors.textDim}>{period}</Text>
55
+ <ExternalLinkText url={source.url} label={`${publisher} export ${formatDay(source.snapshotDate)}`} />
56
+ </Box>
57
+ </>}
58
+ />
59
+ </PaneLinkMenu>
60
+ );
61
+ }
@@ -1,5 +1,6 @@
1
- import type { FinancialStatement, TickerFinancials } from "../../../../types/financials";
1
+ import type { FinancialStatement, StatementPeriodFiling, TickerFinancials } from "../../../../types/financials";
2
2
  import { ebitdaLacksDepreciation } from "../../../../utils/ebitda";
3
+ import { safeExternalUrl } from "../../../../utils/external-url";
3
4
  import { longerPeriodLabel, statementPeriodLabel, ttmPeriodLabel } from "../../../../utils/fiscal-period";
4
5
  import { areNearbyFinancialPeriodEnds, fillDate, fillDateText, statementPeriodMonths } from "../../../../utils/financial-statements";
5
6
  import { formatPerShareNumber } from "../../../../utils/reported-money";
@@ -265,6 +266,7 @@ function filledLine(statement: FinancialStatement, key: keyof FinancialStatement
265
266
  function comparableLine(current: FinancialStatement, previous: FinancialStatement, key: keyof FinancialStatement): boolean {
266
267
  const fill = current.filledFrom;
267
268
  if (fill?.source !== "results" || filledLine(previous, key)) return false;
269
+ if (fill.definitions?.some(({ field }) => field === key)) return false;
268
270
  if (fill.comparable) return fill.comparable.some((field) => field === key);
269
271
  const days = (Date.parse(current.date) - Date.parse(previous.date)) / 86_400_000;
270
272
  return !fill.periodMonths && days >= 300 && days <= 430;
@@ -411,6 +413,18 @@ export function financialColumnPeriod(statement: FinancialTableStatement, period
411
413
  return period === "annual" && (statement.date === "TTM" || annualDates.has(statement.date)) ? "annual" : "quarterly";
412
414
  }
413
415
 
416
+ /** An issuer's report for the displayed period, even when the figures come from a provider. */
417
+ export function financialPeriodFiling(
418
+ filings: readonly StatementPeriodFiling[] | undefined,
419
+ statement: FinancialTableStatement,
420
+ period: FinancialPeriod,
421
+ ): StatementPeriodFiling | undefined {
422
+ if (statement.date === "TTM") return undefined;
423
+ const end = financialPeriodEnd(statement);
424
+ return filings?.find((filing) => filing.periodEnd === end
425
+ && (filing.periodMonths === 12) === (period === "annual") && !!safeExternalUrl(filing.url));
426
+ }
427
+
414
428
  export function latestFinancialPeriodEnd(statements: readonly FinancialTableStatement[]): string | undefined {
415
429
  return statements
416
430
  .map(financialPeriodEnd)
@@ -452,6 +466,20 @@ export function financialStatementLimitations(financials: TickerFinancials | nul
452
466
  return limitations;
453
467
  }
454
468
 
469
+ /**
470
+ * What a scoped statement series is filed as, such as a spun-off listing's history in its predecessor's consolidated
471
+ * accounts, and a newer filing still under review for it. It is said in full above the table, where no pane width
472
+ * cuts it, so the figures are never read as the listing's own; the CSV says it as its "Statement basis". Null for
473
+ * statements with no scope, which are the listing's own.
474
+ */
475
+ export function financialStatementBasisNote(
476
+ financials: Pick<TickerFinancials, "statementScope" | "statementReview"> | null | undefined,
477
+ ): string | null {
478
+ const scope = financials?.statementScope;
479
+ if (!scope) return null;
480
+ return `Statement basis: ${scope.label}.${financials.statementReview?.status === "pending" ? " New filing under review." : ""}`;
481
+ }
482
+
455
483
  /** "Ordinary Shares (bn ADRs)": a share-count line whose counts are depositary receipts. */
456
484
  export function receiptShareCountLabel(row: Pick<FinancialTableModelRow, "key" | "label" | "unitLabel">): string {
457
485
  if (!row.key || !SHARE_COUNT_FIELDS.has(row.key)) return row.unitLabel;
@@ -942,14 +970,20 @@ export function financialStatementPeriods(
942
970
  }
943
971
 
944
972
  /**
945
- * Whether a column has its lead line, or Gloom Cloud left it blank on purpose: the company's announcements
946
- * count it otherwise than the statements source (HSBC's revenue, `filledFrom.omitted`), so the period is in.
973
+ * A period is ready when its lead line is present, intentionally omitted, or accompanied by a filed
974
+ * income or cash flow figure. Banks' filings can report net income under a separate revenue convention.
947
975
  */
948
976
  function hasLeadLine(lead: FinancialRowDef, statement: FinancialStatement): boolean {
949
977
  if (hasFinancialRowValue(lead, [statement])) return true;
950
978
  const key = isFinancialGroup(lead) ? lead.summaryKey : lead.key;
951
979
  const fill = statement.filledFrom;
952
- return !!key && fill?.source === "results" && (fill.omitted ?? []).some((field) => field === key);
980
+ if (!key || fill?.source !== "results") return false;
981
+ if (fill.omitted?.some((field) => field === key)) return true;
982
+ const filedLine = key === "totalRevenue" ? "netIncome" : key === "freeCashFlow" ? "operatingCashFlow" : undefined;
983
+ if (!filedLine || !fill.fields.includes(filedLine) || !Number.isFinite(statement[filedLine])) return false;
984
+ const document = fill.lines[filedLine]?.document;
985
+ const url = document === undefined ? undefined : fill.documents[document]?.url;
986
+ return typeof url === "string" && !!safeExternalUrl(url);
953
987
  }
954
988
 
955
989
  /**
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState, type ReactNode, type RefObje
4
4
  import {
5
5
  DataTableView,
6
6
  DisclosureMarker,
7
+ ExternalLinkText,
7
8
  type DataTableCell,
8
9
  type DataTableColumn,
9
10
  } from "../../../../components";
@@ -54,10 +55,12 @@ export const PERIOD_END_NAME_CELL: DataTableCell = { text: "Period end", color:
54
55
  * edge on the desktop and the web and in the last column (`flush`), and a
55
56
  * cell short of it elsewhere, so the day is drawn the same way.
56
57
  */
57
- export function periodEndCell(end: string | undefined, width: number, flush: boolean): DataTableCell {
58
+ export function periodEndCell(end: string | undefined, width: number, flush: boolean, filingUrl?: string): DataTableCell {
58
59
  if (!end) return { text: "" };
59
60
  const shown = formatDay(end);
60
61
  const day = financialPeriodHeaderLabel(shown, width);
62
+ const padded = flush ? day : `${day} `;
63
+ const start = day.indexOf(shown);
61
64
  return {
62
65
  // A day, not a figure: written day first, exported as its ISO date.
63
66
  text: shown,
@@ -65,7 +68,11 @@ export function periodEndCell(end: string | undefined, width: number, flush: boo
65
68
  color: colors.textMuted,
66
69
  content: (
67
70
  <Box flexDirection="row" width={width} justifyContent="flex-end">
68
- <Text fg={colors.textMuted}>{flush ? day : `${day} `}</Text>
71
+ {filingUrl ? <>
72
+ <Text>{padded.slice(0, start)}</Text>
73
+ <ExternalLinkText url={filingUrl} label={shown} />
74
+ <Text>{padded.slice(start + shown.length)}</Text>
75
+ </> : <Text fg={colors.textMuted}>{padded}</Text>}
69
76
  </Box>
70
77
  ),
71
78
  };