@gloom-sh/terminal 0.20.5 → 0.20.7

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 (185) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/package.json +2 -1
  4. package/src/api-client/data.ts +10 -2
  5. package/src/api-client/fund-facts.ts +20 -4
  6. package/src/api-client/hk-tenders.ts +59 -0
  7. package/src/api-client/index.ts +1 -0
  8. package/src/api-client/socket.ts +4 -4
  9. package/src/api-client/types/econ.ts +20 -2
  10. package/src/app.tsx +18 -13
  11. package/src/architecture/floating-promise-allowlist.json +313 -0
  12. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  13. package/src/cli/commands/market.ts +197 -57
  14. package/src/cli/commands/news-search.ts +22 -7
  15. package/src/cli/commands/overview.ts +12 -6
  16. package/src/cli/commands/search.ts +19 -3
  17. package/src/cli/commands/ticker.ts +3 -1
  18. package/src/cli/desktop-pane-shot.ts +61 -0
  19. package/src/cli/early-command.ts +2 -0
  20. package/src/cli/errors.ts +10 -1
  21. package/src/cli/fx-forward.ts +76 -12
  22. package/src/cli/fx-pair.ts +1 -1
  23. package/src/cli/fx-quote-rate.ts +23 -0
  24. package/src/cli/help.ts +1 -0
  25. package/src/cli/index-roots.ts +5 -4
  26. package/src/cli/index.ts +40 -3
  27. package/src/cli/known-gaps.ts +11 -8
  28. package/src/cli/listing-arg.ts +6 -4
  29. package/src/cli/options.ts +52 -3
  30. package/src/cli/output-file.ts +5 -3
  31. package/src/cli/pane-functions/catalog.ts +15 -0
  32. package/src/cli/pane-functions/dom.ts +4 -4
  33. package/src/cli/pane-functions/freshness.ts +38 -5
  34. package/src/cli/pane-functions/function-help.ts +4 -4
  35. package/src/cli/pane-functions/headless.ts +9 -4
  36. package/src/cli/pane-functions/index.ts +6 -4
  37. package/src/cli/pane-functions/resolver.ts +2 -2
  38. package/src/cli/pane-functions/screenshot-assessment.ts +16 -4
  39. package/src/cli/quote-answer.ts +57 -1
  40. package/src/cli/result.ts +38 -2
  41. package/src/cli/spreadsheet-hint.ts +7 -3
  42. package/src/cli/treasury-yields.ts +5 -3
  43. package/src/components/chart/composite/legend.tsx +40 -2
  44. package/src/components/command-bar/workflow/tickers.ts +2 -2
  45. package/src/components/data-table/view.tsx +9 -2
  46. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  47. package/src/components/ui/data-table/opentui/model.ts +8 -6
  48. package/src/components/ui/data-table/types.ts +6 -1
  49. package/src/components/ui/table-layout.ts +38 -1
  50. package/src/docs/snapshot.json +58 -19
  51. package/src/i18n/es.ts +2 -0
  52. package/src/i18n/ja.ts +2 -0
  53. package/src/i18n/ko.ts +2 -0
  54. package/src/i18n/zh-cn.ts +2 -0
  55. package/src/i18n/zh-tw.ts +2 -0
  56. package/src/market-data/market/change-basis.ts +57 -12
  57. package/src/market-data/market/dated-previous-close.ts +184 -10
  58. package/src/market-data/market/freshness.ts +18 -6
  59. package/src/market-data/market/status.ts +9 -1
  60. package/src/market-data/published-nse-sessions.ts +16 -1
  61. package/src/market-data/quotes/contributions.ts +2 -0
  62. package/src/market-data/quotes/freshness.ts +15 -0
  63. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  64. package/src/plugins/builtin/alerts/alert-engine.ts +15 -0
  65. package/src/plugins/builtin/alerts/cli.ts +22 -9
  66. package/src/plugins/builtin/alerts/headless.ts +1 -1
  67. package/src/plugins/builtin/alerts/index.tsx +5 -1
  68. package/src/plugins/builtin/alerts/metric-command.ts +1 -1
  69. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  70. package/src/plugins/builtin/backtest/headless.ts +1 -1
  71. package/src/plugins/builtin/cds/model.ts +0 -6
  72. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  73. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  74. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  75. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  76. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  77. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  78. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  79. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  80. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  81. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  82. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  83. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  84. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  85. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  86. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  87. package/src/plugins/builtin/econ/calendar-model.ts +41 -7
  88. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  89. package/src/plugins/builtin/econ/index.tsx +41 -8
  90. package/src/plugins/builtin/econ/types.ts +3 -0
  91. package/src/plugins/builtin/fixed-income/index.tsx +2 -0
  92. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  93. package/src/plugins/builtin/help/keybindings-editor.tsx +6 -2
  94. package/src/plugins/builtin/holders/fund-holders.ts +22 -1
  95. package/src/plugins/builtin/holders/headless.ts +5 -4
  96. package/src/plugins/builtin/holders/pane.tsx +7 -3
  97. package/src/plugins/builtin/holders/report-header.ts +23 -0
  98. package/src/plugins/builtin/members/client.ts +1 -1
  99. package/src/plugins/builtin/members/headless.ts +2 -0
  100. package/src/plugins/builtin/members/model.ts +10 -8
  101. package/src/plugins/builtin/members/pane.tsx +4 -1
  102. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +5 -2
  103. package/src/plugins/builtin/portfolio-list/cli/render.ts +86 -26
  104. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  105. package/src/plugins/builtin/portfolio-list/headless.ts +2 -1
  106. package/src/plugins/builtin/portfolio-list/income.ts +46 -22
  107. package/src/plugins/builtin/portfolio-list/pane/data.ts +16 -6
  108. package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -4
  109. package/src/plugins/builtin/portfolio-list/use-throttled-ticker-order.ts +40 -3
  110. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  111. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  112. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  113. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  114. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  115. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  116. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  117. package/src/plugins/builtin/sec/fund-facts.ts +25 -5
  118. package/src/plugins/builtin/shared/report-freshness.ts +15 -6
  119. package/src/plugins/builtin/supply-chain/model.ts +18 -6
  120. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  121. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  122. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  123. package/src/plugins/builtin/ticker-detail/financials/model.ts +6 -2
  124. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +1 -1
  125. package/src/plugins/builtin/ticker-detail/headless.ts +6 -4
  126. package/src/plugins/builtin/treasury-auctions/cache.ts +36 -2
  127. package/src/plugins/builtin/treasury-auctions/headless.ts +42 -4
  128. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  129. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  130. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  131. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -1
  132. package/src/plugins/builtin/treasury-auctions/model.ts +16 -8
  133. package/src/plugins/builtin/treasury-auctions/pane.tsx +45 -21
  134. package/src/portfolio/collection-name.ts +22 -0
  135. package/src/portfolio/column-values.ts +3 -0
  136. package/src/portfolio/valuation-basis.ts +23 -1
  137. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  138. package/src/renderers/dom/data-table/index.tsx +27 -9
  139. package/src/renderers/dom/data-table/row.tsx +2 -0
  140. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  141. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  142. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  143. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  144. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  145. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  146. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  147. package/src/sources/provider-router/cache.ts +3 -1
  148. package/src/state/hooks/quote-streaming.ts +14 -6
  149. package/src/sync/controller.ts +17 -2
  150. package/src/sync/other-window-tabs.ts +32 -1
  151. package/src/sync/react.ts +4 -4
  152. package/src/tickers/instrument-kind.ts +22 -1
  153. package/src/tickers/search/index.ts +5 -0
  154. package/src/tickers/terminal-codes.ts +17 -5
  155. package/src/time-series/bar-spacing.ts +33 -0
  156. package/src/time-series/base-series.ts +21 -3
  157. package/src/time-series/chart-bounds.ts +31 -0
  158. package/src/time-series/field-catalog.ts +17 -0
  159. package/src/time-series/fundamentals/current-valuation.ts +244 -0
  160. package/src/time-series/fundamentals/historical-valuation.ts +99 -0
  161. package/src/time-series/fundamentals/metric-ids.ts +61 -0
  162. package/src/time-series/fundamentals/period-points.ts +104 -0
  163. package/src/time-series/fundamentals/quarterly-ttm.ts +220 -0
  164. package/src/time-series/fundamentals/series.ts +164 -0
  165. package/src/time-series/fundamentals/source-statements.ts +177 -0
  166. package/src/time-series/fundamentals/statement-fields.ts +154 -0
  167. package/src/time-series/fundamentals/statement-merge.ts +124 -0
  168. package/src/time-series/fundamentals/statement.ts +114 -0
  169. package/src/time-series/fundamentals/valuation-multiples.ts +50 -0
  170. package/src/time-series/fundamentals.ts +18 -1275
  171. package/src/time-series/ice-credit.ts +32 -6
  172. package/src/time-series/resolve.ts +9 -5
  173. package/src/time-series/session-bar.ts +78 -9
  174. package/src/time-series/studies/formula.ts +53 -10
  175. package/src/time-series/studies/pair.ts +18 -7
  176. package/src/time-series/studies/units.ts +49 -2
  177. package/src/time-series/types.ts +12 -0
  178. package/src/types/desktop-window.ts +2 -0
  179. package/src/types/financials.ts +15 -0
  180. package/src/types/headless.ts +8 -0
  181. package/src/utils/cli-output.ts +6 -3
  182. package/src/utils/debug-log.ts +29 -0
  183. package/src/utils/ebitda.ts +128 -0
  184. package/src/utils/format.ts +1 -1
  185. package/src/utils/shell-word.ts +13 -0
@@ -11,6 +11,7 @@ import {
11
11
  type PaneFooterSegment,
12
12
  } from "../../../components";
13
13
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
14
+ import { getTableWidth } from "../../../components/ui/table-layout";
14
15
  import { createDataTableCsv } from "../../../components/data-table/export";
15
16
  import { ageFooterSegment, savedCopyFooterSegment } from "../../../components/layout/pane/footer";
16
17
  import { CountryFlag } from "../../../components/ui/country-flag";
@@ -19,7 +20,8 @@ import { useFxRatesMap } from "../../../market-data/hooks";
19
20
  import { resolveEntryData } from "../../../market-data/selectors";
20
21
  import { useRemoteUiNode } from "../../../remote/semantic-tree";
21
22
  import { usePaneSettingValue, useUpdatePaneSettings } from "../../../state/app/context";
22
- import { colors } from "../../../theme/colors";
23
+ import { colors, shownPriceColor } from "../../../theme/colors";
24
+ import { formatPercentRaw, MISSING_VALUE } from "../../../utils/format";
23
25
  import type {
24
26
  CommandBarResultDef, CommandBarSearchProvider, GloomPluginContext, PaneProps, PaneTemplateContext, PaneTemplateCreateOptions,
25
27
  PaneTemplateInstanceConfig,
@@ -55,6 +57,10 @@ const CURRENCY_FLAGS = new Map<string, ReactNode>(
55
57
  FX_CURRENCIES.map((currency) => [currency, <CountryFlag region={CURRENCY_FLAG_REGIONS[currency]} />]),
56
58
  );
57
59
  const RATE_COLUMN_WIDTH = 10;
60
+ /** Room for `-12.34%`; the header takes what it needs. */
61
+ const MOVE_COLUMN_WIDTH = 9;
62
+ /** The currencies the day's move must fit beside: the eight majors the board opens with. */
63
+ const MOVE_FITS_BESIDE = 8;
58
64
  /** Snapshot rates reload at this pace while the feed is not carrying every leg. */
59
65
  const FX_FALLBACK_REFRESH_MS = 60_000;
60
66
 
@@ -252,17 +258,34 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
252
258
  const value = convertedAmount(currency);
253
259
  return value == null ? 1 : formatAmountFigure(value, currency).length;
254
260
  })) : 0;
255
- const allColumns = useMemo<DataTableColumn[]>(() => [
256
- { id: "base", label: "", width: flagged ? FLAGGED_BASE_COLUMN_WIDTH : BASE_COLUMN_WIDTH, align: "left" },
257
- ...amount ? [{ id: "amount", label: "Amount", width: amountWidth, align: "right" as const }] : [],
258
- ...currencies.map((currency) => ({
259
- id: currency,
260
- label: currency,
261
- width: RATE_COLUMN_WIDTH,
262
- align: "right" as const,
263
- headerLeading: flagged ? CURRENCY_FLAGS.get(currency) : undefined,
264
- })),
265
- ], [amount != null, amountWidth, currencies, flagged]);
261
+ // Each currency's value in dollars, its move on the day: the row currency against the dollar, so JPY -0.51% is the
262
+ // yen 0.51% weaker (USD/JPY up), read from its dollar pair against that pair's previous daily close (the references
263
+ // the cells' tints read). The dollar is the reference, so it has none.
264
+ const moveVsUsd = useCallback((row: string): number | null => {
265
+ if (row === "USD") return null;
266
+ const rate = rates.get(row);
267
+ const reference = directionReferences.get(row);
268
+ return rate == null || reference == null || !Number.isFinite(rate) || rate <= 0 ? null : crossMovePercent(rate, reference, 1, 1);
269
+ }, [directionReferences, rates]);
270
+ // The move is shown where it fits beside the first eight currencies; a pane with no room for both (a board saved
271
+ // at its old width) shows the currencies as it did, and one too narrow for them scrolls to the rest.
272
+ const allColumns = useMemo<DataTableColumn[]>(() => {
273
+ const columns: DataTableColumn[] = [
274
+ { id: "base", label: "", width: flagged ? FLAGGED_BASE_COLUMN_WIDTH : BASE_COLUMN_WIDTH, align: "left" },
275
+ ...amount ? [{ id: "amount", label: "Amount", width: amountWidth, align: "right" as const }] : [],
276
+ { id: "move", label: "1D in USD", width: MOVE_COLUMN_WIDTH, align: "right",
277
+ title: "Each currency's value in US dollars, its move since its dollar pair's previous daily close: JPY -0.51% is the yen 0.51% weaker against the dollar" },
278
+ ...currencies.map((currency) => ({
279
+ id: currency,
280
+ label: currency,
281
+ width: RATE_COLUMN_WIDTH,
282
+ align: "right" as const,
283
+ headerLeading: flagged ? CURRENCY_FLAGS.get(currency) : undefined,
284
+ })),
285
+ ];
286
+ const throughEighth = columns.slice(0, columns.length - Math.max(0, currencies.length - MOVE_FITS_BESIDE));
287
+ return getTableWidth(throughEighth) <= width - 1 ? columns : columns.filter((column) => column.id !== "move");
288
+ }, [amount != null, amountWidth, currencies, flagged, width]);
266
289
 
267
290
  const renderCell = useCallback((
268
291
  row: FxCurrency,
@@ -279,6 +302,12 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
279
302
  };
280
303
  }
281
304
 
305
+ if (column.id === "move") {
306
+ const move = moveVsUsd(row);
307
+ if (move == null) return { text: row !== "USD" && status.loading > 0 ? "…" : MISSING_VALUE, color: colors.textDim };
308
+ return { text: formatPercentRaw(move), value: move, color: shownPriceColor(move, 2) };
309
+ }
310
+
282
311
  if (column.id === "amount") {
283
312
  const value = convertedAmount(row);
284
313
  if (value == null) return { text: status.loading > 0 ? "…" : "—", color: colors.textDim };
@@ -311,7 +340,7 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
311
340
  ? directionTint(level, { background: colors.selected, text: colors.selectedText })
312
341
  : directionTint(level, { background: colors.bg, text: colors.text });
313
342
  return { text: formatRate(base / quote, quoteCurrency, reference), color: colors.text, backgroundColor };
314
- }, [amount?.currency, convertedAmount, directionReferences, flagged, rates, referenceRates, status.loading]);
343
+ }, [amount?.currency, convertedAmount, directionReferences, flagged, moveVsUsd, rates, referenceRates, status.loading]);
315
344
 
316
345
  const handleKeyDown = useCallback((event: DataTableKeyEvent) => handleRefreshKey(event, refresh), [refresh]);
317
346
 
@@ -469,7 +498,8 @@ export const fxMatrixModule: PluginModule = {
469
498
  component: FxMatrixPane,
470
499
  defaultPosition: "right",
471
500
  defaultMode: "floating",
472
- defaultFloatingSize: { width: 105, height: 14 },
501
+ // Room for the eight majors after the codes and the day's move in dollars; narrower, the move gives way.
502
+ defaultFloatingSize: { width: 115, height: 14 },
473
503
  tableExport: true,
474
504
  settings: fxMatrixSettings,
475
505
  },
@@ -53,6 +53,7 @@ import type { KeybindingsConfig } from "../../../types/config";
53
53
  import type { KeyboardShortcut } from "../../../types/plugin";
54
54
  import { useUiHost } from "../../../ui";
55
55
  import { isPlainKey } from "../../../utils/keyboard";
56
+ import { logFailure } from "../../../utils/log-failure";
56
57
  import { detectShortcutPlatform, getShortcutDisplayMode } from "../../../utils/shortcut-labels";
57
58
  import { getSharedRegistry } from "../../registry";
58
59
  import { usePluginAppActions } from "../../runtime";
@@ -218,8 +219,11 @@ export function KeybindingsEditor({
218
219
 
219
220
  const writeKeybindings = useCallback((next: KeybindingsConfig | undefined) => {
220
221
  dispatch({ type: "SET_KEYBINDINGS", keybindings: next });
221
- void saveConfigImmediately(updateKeybindingsConfig(stateRef.current.config, next));
222
- }, [dispatch, stateRef]);
222
+ saveConfigImmediately(updateKeybindingsConfig(stateRef.current.config, next)).catch((error: unknown) => {
223
+ logFailure("help.keybindings", "Saving keybindings failed")(error);
224
+ notify({ type: "error", body: t("Could not save your keybindings.") });
225
+ });
226
+ }, [dispatch, notify, stateRef]);
223
227
 
224
228
  const startCapture = useCallback((target: CaptureTarget) => {
225
229
  setFeedback(null);
@@ -6,6 +6,7 @@ import { isNoSourceAnswer } from "../../../sources/provider-errors";
6
6
  import { logFailure } from "../../../utils/log-failure";
7
7
  import { fetchFunds } from "../members/client";
8
8
  import { coveredFund } from "../members/model";
9
+ import { isNoHoldersAnswer, noHoldersText } from "./report-header";
9
10
 
10
11
  type FundQuote = Pick<Quote, "instrumentType" | "tradingExchangeName" | "listingExchangeName" | "exchangeName">;
11
12
 
@@ -24,7 +25,7 @@ export interface FundHoldersAnswer {
24
25
  * holds where `fn MEMB` covers it, and its fund facts (`fn ETF`). Null for a
25
26
  * listing that is not a fund, or a failure that is no answer (a timeout).
26
27
  */
27
- export async function fundHoldersAnswer(
28
+ async function fundHoldersAnswer(
28
29
  symbol: string,
29
30
  error: unknown,
30
31
  quote: FundQuote | null | undefined,
@@ -49,3 +50,23 @@ export async function fundHoldersAnswer(
49
50
  ],
50
51
  };
51
52
  }
53
+
54
+ /**
55
+ * What `holders`, `13f` and `fn HDS` say for a listing no holder source has
56
+ * holders of, in place of the source's bare NO_DATA: a fund's answer
57
+ * (`fundHoldersAnswer`), else that none are on record and, abroad, which
58
+ * filings were read (`noHoldersText`). Its venue is the quote's, else the one
59
+ * the request named. Null for a failure that is no answer (a timeout).
60
+ */
61
+ export async function noHoldersAnswer(
62
+ symbol: string,
63
+ exchange: string | undefined,
64
+ error: unknown,
65
+ quote: (FundQuote & Pick<Quote, "currency">) | null | undefined,
66
+ client: NonNullable<Parameters<typeof fetchFunds>[0]>,
67
+ ): Promise<FundHoldersAnswer | null> {
68
+ const fund = await fundHoldersAnswer(symbol, error, quote, client);
69
+ if (fund || !isNoHoldersAnswer(error)) return fund;
70
+ const venue = (quote ? quoteTradingExchange(quote) : "") || exchange || symbol.split(":")[1] || "";
71
+ return { message: noHoldersText(symbol, venue, quote?.currency), details: [] };
72
+ }
@@ -33,7 +33,7 @@ import {
33
33
  holderReportUnits,
34
34
  } from "./report-rows";
35
35
  import { REPORT_ROWS } from "../shared/headless-options";
36
- import { fundHoldersAnswer } from "./fund-holders";
36
+ import { noHoldersAnswer } from "./fund-holders";
37
37
  import { companyDataNotes } from "../../../types/company-from";
38
38
  import {
39
39
  HOLDER_ROWS_MAX,
@@ -230,15 +230,16 @@ export function createHoldersHeadless(
230
230
  dependencies.loadSnapshot(symbol, args, ctx).catch(async (error: unknown) => {
231
231
  const quote = await ctx.marketData.getQuote(symbol)
232
232
  .catch(logFailure("holders.headless", "Read the quote of a listing with no holders failed", null));
233
- const fund = await fundHoldersAnswer(symbol, error, quote, ctx.apiClient);
234
- if (fund) return fund;
233
+ const none = await noHoldersAnswer(symbol, exchange, error, quote, ctx.apiClient);
234
+ if (none) return none;
235
235
  throw error;
236
236
  }),
237
237
  indexTicker
238
238
  ? dependencies.loadIndexedHolders(indexTicker, limit, ctx).catch(logFailure("holders.headless", "Load 13F holder index failed", null))
239
239
  : null,
240
240
  ]);
241
- // A fund has no ownership breakdown: the report says so in place of rows, with what reads it, and fails as no data.
241
+ // A fund has no ownership breakdown, and a listing may have no holders on record: the report says so
242
+ // in place of rows (with what reads a fund), and fails as no data.
242
243
  if ("message" in snapshot) {
243
244
  return {
244
245
  columns: HOLDER_REPORT_COLUMNS,
@@ -35,7 +35,7 @@ import {
35
35
  holderValueCurrency,
36
36
  resolveHolderOwnershipPercent,
37
37
  } from "./format";
38
- import { holderPeriodsDiffer, holderShareBasisMarker, nonUsHolderCaveat } from "./report-header";
38
+ import { holderPeriodsDiffer, holderShareBasisMarker, isNoHoldersAnswer, nonUsHolderCaveat, noHoldersText } from "./report-header";
39
39
  import {
40
40
  buildColumns,
41
41
  hasHolderChanges,
@@ -80,11 +80,15 @@ export function HoldersView({ focused, width, height }: { focused: boolean; widt
80
80
  const tableScrollRef = useRef<ScrollBoxRenderable | null>(null);
81
81
 
82
82
  const exchange = ticker?.metadata.exchange ?? "";
83
+ const savedCurrency = ticker?.metadata.currency ?? "";
83
84
  const issuerListing = useIssuerListing(ticker);
84
85
  const loadHolders = useMemo(() => symbol ? async (forceRefresh: boolean) => {
85
86
  if (!dataProvider) throw new Error("Holder data unavailable");
86
- return loadHolderData(dataProvider, symbol, exchange, forceRefresh ? { cacheMode: "refresh" } : undefined);
87
- } : null, [dataProvider, exchange, symbol]);
87
+ return loadHolderData(dataProvider, symbol, exchange, forceRefresh ? { cacheMode: "refresh" } : undefined).catch((error: unknown) => {
88
+ // The source has none: the pane says so, and abroad which filings were read, not the source's NO_DATA.
89
+ throw isNoHoldersAnswer(error) ? new Error(noHoldersText(symbol, exchange, savedCurrency)) : error;
90
+ });
91
+ } : null, [dataProvider, exchange, savedCurrency, symbol]);
88
92
  // Another ticker's holders stay up until its own answer, and a failed
89
93
  // refresh keeps the last holders; the failure goes to the footer.
90
94
  const { data, loading, error, reload } = useAsyncResource<HolderData>(loadHolders, {
@@ -2,6 +2,7 @@ import type { HolderData } from "../../../types/financials";
2
2
  import { currencyUnitLabel, resolveCurrencyUnit } from "../../../utils/currency-units";
3
3
  import { adrRatioText } from "../../../utils/depositary-receipt";
4
4
  import { canonicalExchange, isUsListingExchange, resolveExchangeTimeZone } from "../../../utils/exchanges";
5
+ import { isNoSourceAnswer } from "../../../sources/provider-errors";
5
6
 
6
7
  /**
7
8
  * The lines above a holder table in text reports (`holders`, `insider`,
@@ -170,3 +171,25 @@ export function nonUsHolderCaveat(exchange?: string | null, currency?: string |
170
171
  // Few filers report a line abroad, so a small position can lead the list.
171
172
  return `SEC 13F filings only, not the ${venue} share register: the line's largest holders may be missing.`;
172
173
  }
174
+
175
+ /**
176
+ * What a listing no holder source has rows for reads, in place of the
177
+ * source's bare NO_DATA. Abroad it says which filings were read, in the
178
+ * caveat's words: a Shanghai or Shenzhen line no 13F filer reports holding
179
+ * is not one with no shareholders.
180
+ */
181
+ export function noHoldersText(symbol: string, exchange?: string | null, currency?: string | null): string {
182
+ if (!isNonUsHolderListing(exchange, currency)) return `No holders on record for ${symbol}.`;
183
+ const canonical = canonicalExchange(exchange ?? "");
184
+ const venue = resolveExchangeTimeZone(canonical) ? canonical : "local";
185
+ return `No holders on record for ${symbol}: no SEC 13F filing reports it, and the ${venue} share register is not read.`;
186
+ }
187
+
188
+ /**
189
+ * A holder read the source answered with nothing: a miss, or one that
190
+ * crossed the desktop or screenshot bridge, which carries only its message,
191
+ * the source's bare NO_DATA.
192
+ */
193
+ export function isNoHoldersAnswer(error: unknown): boolean {
194
+ return isNoSourceAnswer(error) || (error instanceof Error && error.message.trim() === "NO_DATA");
195
+ }
@@ -40,7 +40,7 @@ async function fetchFundPayload<T>(fund: string, fetcher: () => Promise<T>, vali
40
40
  try { return validate(await fetcher()); } catch (error) {
41
41
  if (error instanceof ApiRequestError && error.status === 404) {
42
42
  const funds = await fetchFunds(client).then((payload) => payload.funds, () => { /* Intentional ignore: an unreadable covered list leaves the server's own message. */ return []; });
43
- if (funds.length && !coveredFund(funds, fund)) throw new Error(notCoveredMessage(fund, funds));
43
+ if (funds.length && !coveredFund(funds, fund)) { const text = notCoveredMessage(fund); throw new Error(`${text.title} ${text.message}`); }
44
44
  }
45
45
  throw unavailableOnServer(error, unavailable);
46
46
  }
@@ -27,7 +27,9 @@ export const membersHeadless: HeadlessPaneDefinition<"rows"> = {
27
27
  }
28
28
  if (args.options.tab === "changes") {
29
29
  const data = await fetchChanges(fund, context.apiClient);
30
+ // An empty table says why: the fund's index changes are not followed, or none is stored, as the pane says.
30
31
  return { freshness: { status: "not-a-feed", basis: "index changes" }, rows: data.changes.map((row) => ({ ...row, reason: changeReason(row) })), columns: [{ key: "effectiveDate", header: "Effective" }, { key: "added", header: "Added" }, { key: "removed", header: "Removed" }, { key: "daysToGo", header: "In days", align: "right" }, { key: "reason", header: "Reason" }],
32
+ empty: data.available ? "No stored index changes." : `Index changes are not covered for ${data.fund.ticker}.`,
31
33
  complete: data.available && !data.stale, metadata: { ...data, changes: undefined } };
32
34
  }
33
35
  const data = await fetchMembers(fund, context.apiClient);
@@ -18,14 +18,16 @@ export function coveredFund(funds: MemberFundsPayload["funds"], input: string) {
18
18
  const symbol = canonicalFund(input);
19
19
  return funds.find((fund) => fund.ticker === symbol || fund.aliases.some((alias) => alias.toUpperCase() === symbol));
20
20
  }
21
- /** Every symbol that opens this fund: the server's aliases and the app's own. */
22
- function fundAliases(fund: MemberFundsPayload["funds"][number]) {
23
- const local = Object.entries(LOCAL_ALIASES).flatMap(([alias, ticker]) => ticker === fund.ticker ? [alias] : []);
24
- return [...new Set([...fund.aliases.map((alias) => alias.toUpperCase()), ...local])].filter((alias) => alias !== fund.ticker);
25
- }
26
- export function notCoveredMessage(input: string, funds: MemberFundsPayload["funds"]) {
27
- const covered = funds.map((fund) => { const aliases = fundAliases(fund); return aliases.length ? `${fund.ticker} (${aliases.join(", ")})` : fund.ticker; });
28
- return `${requestedSymbol(input)} is not a covered fund. Covered: ${covered.join(", ")}.`;
21
+ /**
22
+ * What a fund MEMB does not cover reads: that it is not covered, and where its fund facts and the covered list are,
23
+ * as a command (`gloom fn ETF SMH`) for the report and as a function for the pane. Never the whole covered list.
24
+ */
25
+ export function notCoveredMessage(input: string, surface: "report" | "pane" = "report") {
26
+ const symbol = requestedSymbol(input);
27
+ const title = `${symbol} is not a covered fund.`;
28
+ const message = surface === "pane" ? `Its fund facts are in ETF ${symbol}. MEMB with no fund lists the funds it covers.`
29
+ : `Its fund facts: gloom fn ETF ${symbol}. The covered funds: gloom fn MEMB.`;
30
+ return { title, message };
29
31
  }
30
32
  /** "Partial 1D 334/504 · 91.5% wt": how many holdings have a fresh 1D return, and their share of the fund. */
31
33
  export function coverageText(aggregate: FundMembersPayload["aggregate"], short = false) {
@@ -191,7 +191,10 @@ type FundPaneProps = Pick<PaneProps, "width" | "height" | "focused"> & { fund: s
191
191
  function CoveredFund({ fund, requested, ...props }: FundPaneProps) {
192
192
  const resource = useAsyncResource(loadFunds, { initialData: cachedFunds });
193
193
  const funds = resource.data?.payload.funds;
194
- if (funds?.length && !coveredFund(funds, fund)) return <PaneStatusBody empty emptyTitle={notCoveredMessage(requested, funds)} />;
194
+ if (funds?.length && !coveredFund(funds, fund)) {
195
+ const text = notCoveredMessage(requested, "pane");
196
+ return <PaneStatusBody empty emptyTitle={text.title} emptyMessage={text.message} />;
197
+ }
195
198
  return <FundView key={fund} fund={fund} {...props} />;
196
199
  }
197
200
  export function MembersPane(props: PaneProps) {
@@ -2,6 +2,7 @@ import { saveConfig } from "../../../../data/config/store";
2
2
  import { withConfigData } from "../../../../cli/scoped-context";
3
3
  import { withCollectionConfigData, withCollectionMarketData } from "../../../../cli/suffixed-listing-rows";
4
4
  import { countCollectionTickers } from "../../../../cli/helpers";
5
+ import { exitLeavingReadsBehind } from "../../../../cli/result";
5
6
  import { resolveCliTicker, resolveTickerForCli } from "../../../../cli/ticker-resolution";
6
7
  import { takeFlag, takeOption } from "../../../../cli/commands/command-utils";
7
8
  import { EXCHANGE_OPTION, listingKeys, loadSavedListing, parseListingArg, requireSavedListing, savedListingCandidates, savedListingName, type ListingArg } from "../../../../cli/listing-arg";
@@ -1150,7 +1151,8 @@ export const portfolioCliCommand: CliCommandDef = {
1150
1151
  if (action === "show") {
1151
1152
  const name = args.slice(1).join(" ");
1152
1153
  if (!name) ctx.fail("Usage: gloom portfolio show <name> [--close] [--explain] [--drip] [--from <date> [--to <date>]]");
1153
- await showCollection(name, ctx, { explain, basis, drip, ...(period ? { period } : {}), ...(real ? { real } : {}) });
1154
+ const shown = await showCollection(name, ctx, { explain, basis, drip, ...(period ? { period } : {}), ...(real ? { real } : {}) });
1155
+ if (shown.readsLeftBehind) exitLeavingReadsBehind();
1154
1156
  return;
1155
1157
  }
1156
1158
 
@@ -1218,6 +1220,7 @@ export const portfolioCliCommand: CliCommandDef = {
1218
1220
  ctx.fail(TARGET_USAGE);
1219
1221
  }
1220
1222
 
1221
- await showCollection(args.join(" "), ctx, { explain, basis, drip, ...(period ? { period } : {}) });
1223
+ const shown = await showCollection(args.join(" "), ctx, { explain, basis, drip, ...(period ? { period } : {}) });
1224
+ if (shown.readsLeftBehind) exitLeavingReadsBehind();
1222
1225
  },
1223
1226
  };