@gloom-sh/terminal 0.20.9 → 0.20.11

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 (212) hide show
  1. package/package.json +1 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
  3. package/src/api-client/auth.ts +6 -0
  4. package/src/api-client/data.ts +1 -0
  5. package/src/api-client/earnings.ts +15 -0
  6. package/src/api-client/index.ts +14 -3
  7. package/src/api-client/socket-connection.ts +355 -0
  8. package/src/api-client/socket-features.ts +75 -0
  9. package/src/api-client/socket-frames.ts +161 -0
  10. package/src/api-client/socket-listeners.ts +207 -0
  11. package/src/api-client/socket-quotes.ts +332 -0
  12. package/src/api-client/socket.ts +150 -983
  13. package/src/api-client/types/account.ts +10 -0
  14. package/src/api-client/types/billing.ts +10 -0
  15. package/src/api-client/types/econ.ts +19 -7
  16. package/src/api-client/types/market.ts +7 -0
  17. package/src/api-client/types/screener.ts +2 -0
  18. package/src/brokers/signed-in/adapter.ts +19 -5
  19. package/src/brokers/signed-in/client.ts +13 -1
  20. package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
  21. package/src/cli/commands/market.ts +18 -8
  22. package/src/cli/commands/overview.ts +26 -7
  23. package/src/cli/commands/ticker.ts +40 -15
  24. package/src/cli/desktop-pane-shot.ts +39 -0
  25. package/src/cli/errors.ts +20 -3
  26. package/src/cli/fx-pair.ts +11 -2
  27. package/src/cli/history-rows.ts +34 -3
  28. package/src/cli/index.ts +1 -1
  29. package/src/cli/listing-arg.ts +51 -13
  30. package/src/cli/pane-functions/headless.ts +4 -2
  31. package/src/cli/pane-functions/index.ts +1 -0
  32. package/src/cli/pane-functions/resolver.ts +2 -1
  33. package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
  34. package/src/cli/pane-functions/screenshot-types.ts +4 -0
  35. package/src/components/chart/composite/chart-layout.ts +7 -4
  36. package/src/components/chart/composite/composite-chart.tsx +6 -16
  37. package/src/components/chart/composite/toolbar.tsx +258 -82
  38. package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
  39. package/src/components/chart/native/kitty/manager.ts +2 -0
  40. package/src/components/chart/native/surface/manager.ts +211 -11
  41. package/src/components/command-bar/list/model.ts +13 -0
  42. package/src/components/command-bar/panel/index.tsx +2 -13
  43. package/src/components/command-bar/panel/layout.ts +1 -7
  44. package/src/components/command-bar/panel/runtime.ts +0 -1
  45. package/src/components/command-bar/panel/types.ts +0 -2
  46. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
  47. package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
  48. package/src/components/command-bar/surface/index.tsx +10 -5
  49. package/src/components/command-bar/workflow/alert.ts +21 -7
  50. package/src/components/data-table/column-menu.tsx +89 -0
  51. package/src/components/data-table/sort-menu.tsx +9 -2
  52. package/src/components/data-table/table-pane.ts +3 -1
  53. package/src/components/data-table/view.tsx +33 -6
  54. package/src/components/form-modal/content.tsx +10 -0
  55. package/src/components/index.ts +1 -1
  56. package/src/components/layout/pane/footer/index.tsx +25 -11
  57. package/src/components/layout/pane/footer/model.ts +88 -21
  58. package/src/components/layout/pane/sidebar.tsx +125 -15
  59. package/src/components/layout/shell/active-drag.ts +18 -13
  60. package/src/components/layout/shell/drag/magnets.ts +34 -18
  61. package/src/components/metric-treemap/heat-surface.tsx +2 -1
  62. package/src/components/metric-treemap/index.tsx +3 -2
  63. package/src/components/ticker/list-table-view.tsx +5 -0
  64. package/src/components/ui/confirm-dialog.tsx +253 -7
  65. package/src/components/ui/data-table/column-order.ts +180 -0
  66. package/src/components/ui/data-table/index.tsx +13 -2
  67. package/src/components/ui/data-table/opentui/index.tsx +267 -23
  68. package/src/components/ui/data-table/opentui/model.ts +43 -4
  69. package/src/components/ui/data-table/types.ts +56 -0
  70. package/src/components/ui/data-table/use-column-order.ts +135 -0
  71. package/src/components/ui/index.ts +1 -1
  72. package/src/components/ui/list-view.tsx +4 -3
  73. package/src/components/ui/status.tsx +9 -6
  74. package/src/components/ui/table-layout.ts +120 -0
  75. package/src/docs/snapshot.json +39 -2
  76. package/src/i18n/es.ts +14 -0
  77. package/src/i18n/ja.ts +14 -0
  78. package/src/i18n/ko.ts +14 -0
  79. package/src/i18n/zh-cn.ts +14 -0
  80. package/src/i18n/zh-tw.ts +14 -0
  81. package/src/market-data/coordinator/index.ts +4 -3
  82. package/src/market-data/coordinator/quotes.ts +12 -4
  83. package/src/market-data/fx-closes.ts +14 -2
  84. package/src/market-data/market/change-basis.ts +35 -1
  85. package/src/market-data/market/status.ts +37 -0
  86. package/src/market-data/performance.ts +4 -1
  87. package/src/market-data/quotes/freshness.ts +12 -0
  88. package/src/market-data/quotes/live-valuation.ts +26 -3
  89. package/src/market-data/quotes/regular-session-valuation.ts +1 -1
  90. package/src/market-data/realized-volatility.ts +3 -0
  91. package/src/market-data/us-bond-market.ts +115 -0
  92. package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
  93. package/src/plugins/builtin/account-management/keyboard.ts +3 -0
  94. package/src/plugins/builtin/account-management/model.ts +1 -0
  95. package/src/plugins/builtin/account-management/pane.tsx +51 -5
  96. package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
  97. package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
  98. package/src/plugins/builtin/broker-manager/index.tsx +6 -6
  99. package/src/plugins/builtin/broker-manager/model.ts +15 -6
  100. package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
  101. package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
  102. package/src/plugins/builtin/broker-manager/table.ts +10 -4
  103. package/src/plugins/builtin/chat/sidebar.tsx +33 -16
  104. package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
  105. package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
  106. package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
  107. package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
  108. package/src/plugins/builtin/correlation/compute.ts +4 -3
  109. package/src/plugins/builtin/earnings/board-model.ts +33 -0
  110. package/src/plugins/builtin/earnings/board-table.ts +50 -11
  111. package/src/plugins/builtin/earnings/board.tsx +29 -13
  112. package/src/plugins/builtin/earnings/calendar.tsx +15 -3
  113. package/src/plugins/builtin/earnings/client.ts +4 -1
  114. package/src/plugins/builtin/earnings/headless.ts +27 -14
  115. package/src/plugins/builtin/econ/calendar-source.ts +3 -0
  116. package/src/plugins/builtin/equity-screener/live.ts +74 -18
  117. package/src/plugins/builtin/equity-screener/model.ts +19 -4
  118. package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
  119. package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
  120. package/src/plugins/builtin/equity-screener/results.ts +22 -2
  121. package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
  122. package/src/plugins/builtin/futures/index.tsx +15 -1
  123. package/src/plugins/builtin/futures/table.tsx +1 -1
  124. package/src/plugins/builtin/fx-matrix/index.tsx +2 -0
  125. package/src/plugins/builtin/help/index.tsx +1 -1
  126. package/src/plugins/builtin/holders/pane.tsx +30 -20
  127. package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
  128. package/src/plugins/builtin/iv-history/events.ts +5 -0
  129. package/src/plugins/builtin/iv-history/headless.ts +19 -12
  130. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
  131. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  132. package/src/plugins/builtin/macro-day/model.ts +17 -4
  133. package/src/plugins/builtin/macro-day/releases.ts +36 -15
  134. package/src/plugins/builtin/market-halts/model.ts +3 -2
  135. package/src/plugins/builtin/market-movers/headless.ts +2 -1
  136. package/src/plugins/builtin/market-movers/index.tsx +3 -2
  137. package/src/plugins/builtin/market-movers/model.ts +75 -22
  138. package/src/plugins/builtin/market-movers/screener.ts +2 -1
  139. package/src/plugins/builtin/market-movers/table.ts +7 -5
  140. package/src/plugins/builtin/options/view.tsx +2 -0
  141. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  142. package/src/plugins/builtin/pe-band/model.ts +4 -0
  143. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  144. package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
  145. package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
  146. package/src/plugins/builtin/portfolio-list/pane/index.tsx +15 -1
  147. package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
  148. package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
  149. package/src/plugins/builtin/portfolio-list/table.tsx +18 -1
  150. package/src/plugins/builtin/rate-path/pane.tsx +2 -0
  151. package/src/plugins/builtin/research/analyst-headless.ts +9 -1
  152. package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
  153. package/src/plugins/builtin/research/client.ts +25 -1
  154. package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
  155. package/src/plugins/builtin/research/event-model.ts +3 -13
  156. package/src/plugins/builtin/research/event-sources.ts +3 -1
  157. package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
  158. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
  159. package/src/plugins/builtin/seasonality/pane.tsx +2 -1
  160. package/src/plugins/builtin/short-interest/headless.ts +2 -0
  161. package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
  162. package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
  163. package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
  164. package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
  165. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
  166. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
  167. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  168. package/src/plugins/builtin/vol-surface/pane.tsx +2 -1
  169. package/src/plugins/builtin/world-indices/index.tsx +5 -1
  170. package/src/plugins/builtin/yield-curve/headless.ts +5 -1
  171. package/src/plugins/builtin/yield-curve/index.tsx +7 -1
  172. package/src/portfolio/column-values.ts +47 -14
  173. package/src/portfolio/return-metrics.ts +4 -2
  174. package/src/renderers/dom/data-table/column-drag.ts +147 -0
  175. package/src/renderers/dom/data-table/index.tsx +22 -0
  176. package/src/renderers/dom/data-table/row.tsx +27 -5
  177. package/src/renderers/dom/host/image-surface.tsx +19 -9
  178. package/src/renderers/dom/host/input.tsx +4 -0
  179. package/src/renderers/dom/styles.css +22 -0
  180. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
  181. package/src/renderers/opentui/chart-surface.tsx +1 -0
  182. package/src/renderers/opentui/frame-hits.ts +33 -0
  183. package/src/renderers/opentui/host.tsx +2 -0
  184. package/src/renderers/opentui/native-surface.ts +14 -21
  185. package/src/renderers/opentui/test-utils.tsx +3 -0
  186. package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
  187. package/src/sources/provider-errors.ts +12 -0
  188. package/src/sources/provider-router/index.ts +12 -4
  189. package/src/state/app/context/index.tsx +22 -0
  190. package/src/state/pane-session.ts +145 -0
  191. package/src/test-support/app-store.ts +24 -1
  192. package/src/tickers/search/home-listing.ts +44 -1
  193. package/src/tickers/search/index.ts +5 -2
  194. package/src/tickers/search/ranking.ts +7 -7
  195. package/src/tickers/us-listing.ts +11 -5
  196. package/src/time-series/base-series.ts +7 -1
  197. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  198. package/src/time-series/fundamentals/series.ts +6 -0
  199. package/src/time-series/live-quotes.ts +3 -9
  200. package/src/time-series/resolve.ts +1 -0
  201. package/src/types/financials.ts +20 -0
  202. package/src/types/headless.ts +9 -0
  203. package/src/ui/host.tsx +20 -0
  204. package/src/ui/pointer-drag.ts +11 -2
  205. package/src/utils/exchanges.ts +13 -8
  206. package/src/utils/fundamentals.ts +14 -3
  207. package/src/utils/price-earnings.ts +17 -10
  208. package/src/utils/price-history-integrity.ts +15 -0
  209. package/src/utils/reason-codes.ts +79 -0
  210. package/src/utils/share-multiples.cases.json +1667 -0
  211. package/src/utils/share-multiples.ts +384 -0
  212. package/src/utils/untrusted-text.ts +11 -0
@@ -1,9 +1,9 @@
1
1
  import type { TickerFinancials } from "../../../../types/financials";
2
2
  import type { TickerRecord } from "../../../../types/ticker";
3
- import { convertCurrency, formatCompactAmount } from "../../../../utils/format";
4
- import { getCurrencySymbol } from "../../../../market-data/market/format";
5
- import { getActiveQuoteDisplay } from "../../../../market-data/market/status";
6
- import { combinedChangeBasisLabel, futuresQuoteFromSettle, quoteChangeBasis, type QuoteChangeBasis } from "../../../../market-data/market/change-basis";
3
+ import { convertCurrency, formatCompactAmount, formatNumber } from "../../../../utils/format";
4
+ import { currencyMinorDigits, getCurrencySymbol } from "../../../../market-data/market/format";
5
+ import { extendedPrintSession, getActiveQuoteDisplay, type ExtendedSession } from "../../../../market-data/market/status";
6
+ import { dayMoveBasisLabel, futuresQuoteFromSettle, quoteChangeBasis, type QuoteChangeBasis } from "../../../../market-data/market/change-basis";
7
7
  import { isQuoteStaleForCurrentSession } from "../../../../market-data/quotes/freshness";
8
8
  import { headlineQuoteDisplay } from "../../../../portfolio/column-values";
9
9
  import type { AllocationHolding } from "../../../../portfolio/allocation";
@@ -48,10 +48,13 @@ export interface PortfolioSummaryTotals {
48
48
  /**
49
49
  * What Day (or a watchlist's Avg Day) is measured from, as each holding's
50
50
  * change line says it: "vs Fri 16 Oct close" when they agree, "vs mixed
51
- * closes" when they do not (an HKEX listing beside a US one). Absent
52
- * without a move.
51
+ * closes" when they do not (an HKEX listing beside a US one), after the
52
+ * session of the extended-hours prints it is valued at, as the rows mark
53
+ * them ("AH vs Tue 10 Nov close"). Absent without a move.
53
54
  */
54
55
  dayChangeBasis?: string;
56
+ /** Some holding's day is valued at an extended-hours print, which dayChangeBasis names. */
57
+ dayAtExtendedPrint?: boolean;
55
58
  totalCostBasis: number;
56
59
  hasPositions: boolean;
57
60
  unrealizedPnl: number;
@@ -77,17 +80,39 @@ function currencyCode(value: string | undefined): string | null {
77
80
 
78
81
  export { resolvePortfolioTotalsCurrency } from "../../../../portfolio/totals-currency";
79
82
 
83
+ /** From here a book's totals read in whole units (1,588), as `portfolio show` prints market values; below it, to the minor unit (101.10). */
84
+ const WHOLE_AMOUNT_FROM = 1_000;
85
+ /** From here they read compact (1.23B), so a header row keeps its other figures. */
86
+ const COMPACT_AMOUNT_FROM = 1_000_000_000;
87
+
88
+ /**
89
+ * An amount with thousands separators: to the currency's minor unit below a
90
+ * thousand (101.10, ¥950), in whole units from there (1,588, -40,000) and
91
+ * compact from a billion (1.23B). A signed amount carries + or -, except one
92
+ * that rounds to zero.
93
+ */
94
+ function bookAmountText(value: number | undefined, currency: string, signed: boolean): string {
95
+ if (value == null || !Number.isFinite(value)) return formatCompactAmount(value);
96
+ const abs = Math.abs(value);
97
+ if (abs >= COMPACT_AMOUNT_FROM) return formatCompactAmount(value, { signed });
98
+ const minor = currencyMinorDigits(currency);
99
+ const body = formatNumber(abs, Number(abs.toFixed(minor)) >= WHOLE_AMOUNT_FROM ? 0 : minor);
100
+ if (!/[1-9]/.test(body)) return body;
101
+ return `${value < 0 ? "-" : signed ? "+" : ""}${body}`;
102
+ }
103
+
80
104
  /**
81
- * A compact total in the portfolio's currency. Bare when both it and the app's
82
- * base currency are USD, as the pane has always shown it; otherwise it leads
83
- * with the currency symbol, as prices do: A$108.6k, +$600.12.
105
+ * A total in the portfolio's currency (bookAmountText): never rounded to a
106
+ * hundred, as a compact 1.6k for $1,587.80 was. Bare when both it and the
107
+ * app's base currency are USD, as the pane has always shown it; otherwise it
108
+ * leads with the currency symbol, as prices do: A$108,612, +$600.12.
84
109
  */
85
110
  export function formatPortfolioAmount(
86
111
  value: number | undefined,
87
112
  currency: string,
88
113
  { signed = false, baseCurrency = "USD" }: { signed?: boolean; baseCurrency?: string } = {},
89
114
  ): string {
90
- const text = formatCompactAmount(value, { signed });
115
+ const text = bookAmountText(value, currency, signed);
91
116
  const bare = currency === "USD" && (currencyCode(baseCurrency) ?? "USD") === "USD";
92
117
  if (bare || value == null || !Number.isFinite(value)) return text;
93
118
  const sign = text.startsWith("+") || text.startsWith("-") ? text.charAt(0) : "";
@@ -135,6 +160,8 @@ export function calculatePortfolioSummaryTotals(
135
160
  let watchlistChangeSum = 0;
136
161
  let watchlistCount = 0;
137
162
  const dayBases: Array<QuoteChangeBasis | null> = [];
163
+ // The extended session of each price the day is valued at, null for a regular one.
164
+ const dayPrints: Array<ExtendedSession | null> = [];
138
165
  const unavailableConversions = new Set<string>();
139
166
  let livePriced = true;
140
167
  const pricedLots: PricedPortfolioLot[] = [];
@@ -249,6 +276,7 @@ export function calculatePortfolioSummaryTotals(
249
276
  session: valuationBasis === "regular-close" ? "regular" : "active",
250
277
  terms,
251
278
  }));
279
+ dayPrints.push(valuationBasis === "latest-print" ? extendedPrintSession(quote, activeQuote.price) : null);
252
280
  }
253
281
  } else {
254
282
  // A broker mark is not evidence of an unchanged day.
@@ -269,7 +297,7 @@ export function calculatePortfolioSummaryTotals(
269
297
  const unrealizedPnl = signedUnrealizedPnl;
270
298
  const unrealizedPnlPct = portfolioPnlPercent(unrealizedPnl, totalCostBasis) ?? Number.NaN;
271
299
  const avgWatchlistChange = watchlistCount > 0 ? watchlistChangeSum / watchlistCount : 0;
272
- const dayChangeBasis = combinedChangeBasisLabel(dayBases, now);
300
+ const dayChangeBasis = dayMoveBasisLabel(dayBases, dayPrints, { marks: true, now });
273
301
 
274
302
  return {
275
303
  totalMktValue,
@@ -287,6 +315,7 @@ export function calculatePortfolioSummaryTotals(
287
315
  dailyPnl,
288
316
  dailyPnlPct,
289
317
  ...(dayChangeBasis ? { dayChangeBasis } : {}),
318
+ ...(dayChangeBasis && dayPrints.some((print) => print != null) ? { dayAtExtendedPrint: true } : {}),
290
319
  totalCostBasis,
291
320
  hasPositions,
292
321
  unrealizedPnl,
@@ -10,6 +10,7 @@ import { PRICE_SPARKLINE_COLUMN_ID } from "../../../components/price-sparkline/v
10
10
  import type { QuoteFlashDirection } from "../../../components/quote-flash";
11
11
  import type { TickerTableCell, TickerTableSummaryRow } from "../../../components/ticker/list-table-view";
12
12
  import { createRowValueCache } from "../../../components/ui/row-value-cache";
13
+ import type { DataTableColumnReorder } from "../../../components/ui";
13
14
  import type { ColumnConfig } from "../../../types/config";
14
15
  import type { PricePoint, TickerFinancials } from "../../../types/financials";
15
16
  import type { TickerRecord } from "../../../types/ticker";
@@ -52,6 +53,9 @@ const GROSS_WEIGHT_LABEL = "GROSS WT";
52
53
  /** P&L%'s header over a period: each position's P&L as a share of the book at the start. */
53
54
  const CONTRIBUTION_LABEL = "CONTRIB";
54
55
 
56
+ /** What an extended-hours print's session mark adds to LAST: `AH `, `PM ` or `ON `. */
57
+ const SESSION_MARK_WIDTH = 3;
58
+
55
59
  /** The widest a futures quantity grows the QTY column: `-12,000 × 5,000 bushels` fits. */
56
60
  const MAX_QUANTITY_COLUMN_WIDTH = 24;
57
61
 
@@ -201,6 +205,7 @@ export function PortfolioTickerTable({
201
205
  answeredSnapshots,
202
206
  exportName,
203
207
  allocationRows,
208
+ columnReorder,
204
209
  }: {
205
210
  columns: ColumnConfig[];
206
211
  focused?: boolean;
@@ -237,6 +242,8 @@ export function PortfolioTickerTable({
237
242
  exportName?: string;
238
243
  /** The book's CASH and TOTAL rows under its holdings (`allocationSummaryRows`). */
239
244
  allocationRows?: readonly TickerTableSummaryRow[];
245
+ /** Header drags rewrite the pane's Columns setting (`DataTableProps.columnReorder`). */
246
+ columnReorder?: DataTableColumnReorder;
240
247
  }) {
241
248
  const cellCacheRef = useRef(createRowValueCache<string, ReturnType<typeof getColumnValue> & TickerTableCell>(5000));
242
249
  const openPerpetualRef = useRef(onOpenPerpetual);
@@ -282,6 +289,14 @@ export function PortfolioTickerTable({
282
289
  (widest, ticker) => Math.max(widest, displayWidth(resolveCell(sharesColumn, ticker, tableFinancialsMap.get(ticker.metadata.ticker)).text)),
283
290
  sharesColumn.width,
284
291
  )) : 0;
292
+ // A book at the latest print marks an extended-hours print in LAST (AH 158.78), so the column grows to fit the mark.
293
+ const priceColumn = columns.find((column) => column.id === "price");
294
+ const priceWidth = useMemo(() => priceColumn && columnContext.valuationBasis === "latest-print"
295
+ ? Math.min(priceColumn.width + SESSION_MARK_WIDTH, sortedTickers.reduce(
296
+ (widest, ticker) => Math.max(widest, displayWidth(resolveCell(priceColumn, ticker, tableFinancialsMap.get(ticker.metadata.ticker)).text)),
297
+ priceColumn.width,
298
+ ))
299
+ : 0, [columnContext.valuationBasis, priceColumn, resolveCell, sortedTickers, tableFinancialsMap]);
285
300
  // The Ticker column grows to its longest symbol, so ETH-USD and BA:LSE show whole beside their market-state dot.
286
301
  const tickerWidth = useMemo(() => Math.min(MAX_TICKER_COLUMN_WIDTH, sortedTickers.reduce(
287
302
  (widest, ticker) => Math.max(widest, TICKER_DOT_WIDTH + displayWidth(listedSymbol(ticker, tickerDisplayName(ticker), columnContext.homeMarket))),
@@ -295,13 +310,14 @@ export function PortfolioTickerTable({
295
310
  ? { ...column, label: "QTY", ...(sharesWidth > column.width ? { width: sharesWidth } : {}) }
296
311
  : column.id === "weight" && grossWeights ? { ...column, label: GROSS_WEIGHT_LABEL }
297
312
  : column.id === "ticker" && tickerWidth > column.width ? { ...column, width: tickerWidth }
313
+ : column.id === "price" && priceWidth > column.width ? { ...column, width: priceWidth }
298
314
  : column.id === "pnl_pct" && period ? { ...column, label: CONTRIBUTION_LABEL }
299
315
  : pnlLabel !== "P&L" && (column.id === "pnl" || column.id === "pnl_pct") ? {
300
316
  ...column,
301
317
  label: column.id === "pnl_pct" ? pnlLabel.replace("P&L", "%") : pnlLabel,
302
318
  } : column).map((column) => BOOK_CURRENCY_COLUMN_IDS.has(column.id) ? bookCurrencyColumn(column, capCurrency) : column)
303
319
  .map((column) => hasFrontReference && column.id === noteColumnId ? { ...column, flexGrow: 1 } : column),
304
- [capCurrency, columns, grossWeights, hasFrontReference, hasNonShareQuantity, noteColumnId, period, pnlLabel, sharesWidth, tickerWidth]);
320
+ [capCurrency, columns, grossWeights, hasFrontReference, hasNonShareQuantity, noteColumnId, period, pnlLabel, priceWidth, sharesWidth, tickerWidth]);
305
321
  // Read again as the rows' data moves, from the cells the rows show; the columns change only when what is hidden does.
306
322
  // The company columns hidden last time, per list, stay hidden while a row added since settles.
307
323
  const hiddenCompanyRef = useRef<{ list: string | undefined; ids: ReadonlySet<string> }>({ list: undefined, ids: new Set() });
@@ -377,6 +393,7 @@ export function PortfolioTickerTable({
377
393
  summaryRows={summaryRows}
378
394
  rootHeight={rootHeight}
379
395
  exportName={exportName}
396
+ columnReorder={columnReorder}
380
397
  />
381
398
  );
382
399
  }
@@ -194,6 +194,8 @@ export function RatePathPane({ width, height, focused }: PaneProps) {
194
194
  rootBefore={header(meetingColumns, meetings.length, pathChart)} />
195
195
  : tab === "probabilities" ? <DataTableView
196
196
  columns={probabilityColumns}
197
+ // Target ranges in rate order.
198
+ columnReorder={false}
197
199
  items={data.meetings} selection={selection} focused={focused} sortColumnId={null} sortDirection="asc"
198
200
  getItemKey={meetingKey} rootWidth={width} rootHeight={bodyHeight} emptyStateTitle="Meeting probabilities unavailable"
199
201
  rootBefore={header(probabilityColumns, data.meetings.length)}
@@ -9,7 +9,7 @@ import type {
9
9
  import type { AnalystResearchData, Quote } from "../../../types/financials";
10
10
  import { logFailure } from "../../../utils/log-failure";
11
11
  import { formatPercent } from "../../../utils/format";
12
- import { loadAnalystResearch } from "./client";
12
+ import { hasAnalystCoverage, loadAnalystResearch, noAnalystCoverageText } from "./client";
13
13
  import {
14
14
  analystReferenceMetadata,
15
15
  analystTargetCurrency,
@@ -185,6 +185,14 @@ export function createAnalystResearchHeadless(
185
185
  dependencies.loadData(symbol, args, ctx),
186
186
  dependencies.loadQuote?.(symbol, ctx) ?? Promise.resolve(null),
187
187
  ]);
188
+ // A listing no analyst covers has nothing to sum up or list: the report says so once.
189
+ if (!hasAnalystCoverage(data)) {
190
+ return {
191
+ sections: [{ title: "Recent analyst actions", columns: RATING_COLUMNS, rows: [] }],
192
+ empty: noAnalystCoverageText(data.symbol || symbol),
193
+ metadata: { symbol: data.symbol || symbol, name: data.name ?? null },
194
+ };
195
+ }
188
196
  const { upside, reference } = analystUpside(data, quote);
189
197
  const currency = analystTargetCurrency(data);
190
198
  const ratings = sortRatingRows(data.ratings, {
@@ -27,7 +27,7 @@ import { handleRefreshKey, useClampSelectedIndex } from "../../../components/dat
27
27
  import { SignInWall } from "../cloud/auth-actions";
28
28
  import { isCloudSessionRequired, useResearchCloudSession } from "../shared/research-cloud-session";
29
29
  import { useBoundTicker as useSymbolBinding, useTickerRequest } from "../shared/ticker-request";
30
- import { loadAnalystResearch } from "./client";
30
+ import { hasAnalystCoverage, loadAnalystResearch, noAnalystCoverageText } from "./client";
31
31
  import {
32
32
  DEFAULT_RATING_SORT,
33
33
  analystReferencePrice,
@@ -109,7 +109,7 @@ function AnalystHeader({ data, history, series, currency, width, height, tableRo
109
109
  const consensusLabel = !nativePaneChrome && width < 44 ? "Cons." : "Consensus";
110
110
  const split = ratingSplit(data);
111
111
  // The table body already reports loading, error, and empty states.
112
- const figures: StatItem[] = data ? [
112
+ const figures: StatItem[] = hasAnalystCoverage(data) ? [
113
113
  { id: "target", label: consensusLabel, value: formatAnalystPrice(target?.average, currency) },
114
114
  {
115
115
  id: "upside",
@@ -194,6 +194,10 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
194
194
  }, [dataProvider, cloudSession.requestKey]);
195
195
  const { data, loading, error, reload } = useTickerRequest<AnalystResearchData>(loader, symbol, exchange);
196
196
  const authWall = !data && isCloudSessionRequired(error);
197
+ // A listing no analyst covers loads as research with nothing in it: the body says so, the footer has nothing to add.
198
+ const noCoverage = !!data && !hasAnalystCoverage(data);
199
+ // A failure with nothing loaded is the body's to say; one behind data on screen (a refresh), the footer's.
200
+ const failedEmpty = !!symbol && !data && !loading && !!error && !authWall;
197
201
  const rows = useMemo(() => sortRatingRows(data?.ratings ?? [], sortPreference), [data?.ratings, sortPreference]);
198
202
  const ratingCurrency = analystTargetCurrency(data);
199
203
  const columns = useMemo(
@@ -278,9 +282,9 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
278
282
  const selectedRow = rows.length > 0 ? rows[selectedIdx] : undefined;
279
283
  const footer = (
280
284
  <AnalystFooter
281
- data={authWall ? null : data}
285
+ data={authWall || noCoverage ? null : data}
282
286
  loading={loading}
283
- error={authWall ? null : error}
287
+ error={authWall || failedEmpty ? null : error}
284
288
  width={width}
285
289
  binding={binding}
286
290
  focused={focused}
@@ -332,6 +336,8 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
332
336
  getItemKey={(row, index) => `${row.date}:${row.firm}:${index}`}
333
337
  renderCell={renderCell}
334
338
  selectedTextOverridesCellColor
339
+ status={noCoverage ? { empty: true, emptyTitle: noAnalystCoverageText(symbol ?? data?.symbol ?? "") }
340
+ : failedEmpty && error ? { error, subject: "Analyst research" } : undefined}
335
341
  emptyStateTitle={loading ? "Loading analyst data..." : error ?? "No analyst data"}
336
342
  />
337
343
  </>
@@ -1,6 +1,15 @@
1
+ import { isNoDataAnswer } from "../../../sources/provider-errors";
2
+ import { hasAnalystResearchValue } from "../../../sources/provider-router/financials";
1
3
  import type { DataProvider, MarketDataRequestContext } from "../../../types/data-provider";
2
4
  import type { AnalystResearchData } from "../../../types/financials";
3
5
 
6
+ /**
7
+ * The listing's analyst research. A listing no analyst covers (CENN) is
8
+ * answered with research that holds nothing, which `hasAnalystCoverage`
9
+ * reads, not with a failure: the service answered it has nothing for a
10
+ * symbol it knows. A symbol it does not know, and a source that did not
11
+ * answer, still fail.
12
+ */
4
13
  export async function loadAnalystResearch(
5
14
  provider: DataProvider,
6
15
  symbol: string,
@@ -8,5 +17,20 @@ export async function loadAnalystResearch(
8
17
  context?: MarketDataRequestContext,
9
18
  ): Promise<AnalystResearchData> {
10
19
  if (!provider.getAnalystResearch) throw new Error("Analyst data unavailable");
11
- return provider.getAnalystResearch(symbol, exchange, context);
20
+ try {
21
+ return await provider.getAnalystResearch(symbol, exchange, context);
22
+ } catch (error) {
23
+ if (!isNoDataAnswer(error)) throw error;
24
+ return { symbol, recommendations: [], ratings: [], earningsEstimates: [], revenueEstimates: [] };
25
+ }
26
+ }
27
+
28
+ /** Whether any analyst covers the listing: a target, a rating mix, an action or an estimate. */
29
+ export function hasAnalystCoverage(data: AnalystResearchData | null | undefined): boolean {
30
+ return !!data && hasAnalystResearchValue(data);
31
+ }
32
+
33
+ /** What a pane or a report says for a listing no analyst covers. */
34
+ export function noAnalystCoverageText(symbol: string): string {
35
+ return `No analyst coverage for ${symbol}.`;
12
36
  }
@@ -27,6 +27,7 @@ import { useResolvedEntryValue, useSecFilingDocuments, useSecFilingsQuery } from
27
27
  import { instrumentFromTicker } from "../../../market-data/request-types";
28
28
  import { usePaneTicker } from "../../../state/app/context";
29
29
  import { mayBeUsEquityTicker } from "../../../utils/sec";
30
+ import { loadAnalystResearch } from "./client";
30
31
  import { useAssetData, usePluginPaneState } from "../../runtime";
31
32
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
32
33
  import { SignInWall } from "../cloud/auth-actions";
@@ -469,7 +470,7 @@ export function CorporateActionsView({
469
470
  }, [dataProvider, cloudSession.requestKey]);
470
471
  const analystLoader = useCallback(async (nextSymbol: string, nextExchange: string, forceRefresh: boolean) => {
471
472
  if (!dataProvider?.getAnalystResearch) return null;
472
- return dataProvider.getAnalystResearch(nextSymbol, nextExchange, forceRefresh ? { cacheMode: "refresh" } : undefined);
473
+ return loadAnalystResearch(dataProvider, nextSymbol, nextExchange, forceRefresh ? { cacheMode: "refresh" } : undefined);
473
474
  }, [dataProvider, cloudSession.requestKey]);
474
475
  // The earnings calendar's next report, which the rows are resolved against as `earnings` and ERN read it.
475
476
  const calendarLoader = useCallback((nextSymbol: string, _exchange: string, forceRefresh: boolean) => (
@@ -16,6 +16,7 @@ import {
16
16
  import { computeTTM } from "../ticker-detail/financials/aggregation";
17
17
  import { classifyInstrumentType } from "../../../tickers/instrument-kind";
18
18
  import { declaredDividends } from "../../../utils/declared-dividends";
19
+ import { isReasonCode, readableStatus } from "../../../utils/reason-codes";
19
20
  import { fundamentalsEpsCurrency, SERVED_TRAILING_EPS } from "../../../utils/fundamentals";
20
21
  import {
21
22
  earningsDateStatus,
@@ -497,7 +498,7 @@ export function eventSourceNotice(state: EventSourceState): EventSourceNotice |
497
498
  .filter(([section, status]) => status === "unavailable" && (state.variant !== "earnings-estimates" || section === "earnings"))
498
499
  .map(([section]) => section);
499
500
  // Sections and estimates that a source failed to give share one line: "Unavailable: earnings, analyst estimates (the source did not answer)".
500
- const estimatesCode = !!state.estimatesError && REASON_CODE.test(state.estimatesError.trim());
501
+ const estimatesCode = isReasonCode(state.estimatesError);
501
502
  const sharedLine = !state.actionsError && unavailableSections.length > 0 && estimatesCode;
502
503
 
503
504
  if (state.actionsError) {
@@ -530,23 +531,12 @@ export function eventSourceNotice(state: EventSourceState): EventSourceNotice |
530
531
  };
531
532
  }
532
533
 
533
- /** A data service's reason code (UPSTREAM_ERROR) rather than words. */
534
- const REASON_CODE = /^[A-Z][A-Z0-9_]+$/;
535
-
536
534
  /**
537
535
  * A source's failure in words: a reason code reads as what happened
538
536
  * ("UPSTREAM_ERROR" is "the source did not answer"); a sentence stands.
539
537
  */
540
538
  export function sourceErrorText(error: string): string {
541
- const text = error.trim();
542
- if (!REASON_CODE.test(text)) return text;
543
- switch (text) {
544
- case "TIMEOUT": return "the source timed out";
545
- case "NOT_FOUND":
546
- case "NO_DATA": return "the source has none for this symbol";
547
- case "RATE_LIMITED": return "the source is busy, try again shortly";
548
- default: return "the source did not answer";
549
- }
539
+ return readableStatus(error.trim());
550
540
  }
551
541
 
552
542
  function hasCorporateActionRows(data: CorporateActionsData): boolean {
@@ -5,6 +5,7 @@ import type {
5
5
  TickerFinancials,
6
6
  } from "../../../types/financials";
7
7
  import { formatEventMetric } from "./event-model";
8
+ import { loadAnalystResearch } from "./client";
8
9
  import { formatPercent, formatPercentRaw } from "../../../utils/format";
9
10
  import { loadEarningsCalendar } from "../earnings/data/cache";
10
11
  import { calendarEventOf, newYorkDay, withResolvedEarnings } from "../shared/earnings-calendar";
@@ -74,7 +75,8 @@ function settledError(result: PromiseSettledResult<unknown>): string | null {
74
75
  export async function loadEventSources(provider: DataProvider, symbol: string, today = newYorkDay()): Promise<EventSources> {
75
76
  const [actions, estimates, financials, calendar] = await Promise.allSettled([
76
77
  provider.getCorporateActions?.(symbol, "") ?? null,
77
- provider.getAnalystResearch?.(symbol, "") ?? null,
78
+ // A listing no analyst covers answers with no estimates, not a failure.
79
+ provider.getAnalystResearch ? loadAnalystResearch(provider, symbol, "") : null,
78
80
  provider.getTickerFinancials(symbol, ""),
79
81
  loadEarningsCalendar(provider, [symbol]),
80
82
  ]);
@@ -214,6 +214,8 @@ function RevenueBreakdownView({ width, height, focused }: { width: number; heigh
214
214
  {payload ? (
215
215
  <DataTableView<Item>
216
216
  columns={columns}
217
+ // Reporting quarters in time order, then the latest and TTM.
218
+ columnReorder={false}
217
219
  items={items}
218
220
  focused={focused}
219
221
  rootWidth={width}
@@ -145,7 +145,8 @@ export function ReverseDcfPane({ width, height, focused }: PaneProps) {
145
145
  <Box paddingX={1}><Notice variant="callout" tone="muted">{missingInputsText(model.missing)}</Notice></Box>
146
146
  </> : model && !model.error ? <>
147
147
  <StatGrid items={stats} width={width} maxLines={statMaxLines} />
148
- <DataTableView<Row> focused={focused} columns={COLUMNS} items={model.sensitivity} rootWidth={width} rootHeight={contentHeight}
148
+ {/* Terminal growth rates in order: a sensitivity grid's axis. */}
149
+ <DataTableView<Row> focused={focused} columns={COLUMNS} columnReorder={false} items={model.sensitivity} rootWidth={width} rootHeight={contentHeight}
149
150
  getItemKey={(row) => String(row.discountRate)} emptyStateTitle="No implied growth." sortColumnId={null} sortDirection="desc"
150
151
  selection={{ kind: "id", selectedId, getId: (row) => String(row.discountRate),
151
152
  onChange: (id) => { if (id) setDiscount(String(Math.round(Number(id) * 100))); } }}
@@ -220,7 +220,8 @@ export function SeasonalityPane({ width, height, focused }: PaneProps) {
220
220
  formatCursor: (ratio) => new Date(Date.UTC(OVERLAY_YEAR, 0, 1) + ratio * 365 * 86_400_000).toISOString().slice(5, 10) }}
221
221
  colors={{ background: palette.bgColor, grid: palette.gridColor, crosshair: palette.crosshairColor, text: colors.text,
222
222
  textDim: palette.axisColor, negative: colors.negative }} />
223
- : <DataTableView<Row> focused={focused} columns={COLUMNS} items={rows} rootWidth={width} rootHeight={contentHeight}
223
+ // January to December: the grid is a calendar.
224
+ : <DataTableView<Row> focused={focused} columns={COLUMNS} columnReorder={false} items={rows} rootWidth={width} rootHeight={contentHeight}
224
225
  getItemKey={(row) => row.id} emptyStateTitle="No monthly returns." sortColumnId={null} sortDirection="desc"
225
226
  selection={{ kind: "id", selectedId: selectedRow, getId: (row) => row.id, onChange: (id) => setSelectedRow(id) }}
226
227
  getExportMetadata={() => [["symbol", model.symbol], ["as of", model.asOf?.toISOString()], ["units", "percent, local-price close to close"]]}
@@ -84,6 +84,8 @@ export function createShortInterestHeadless(
84
84
  ],
85
85
  },
86
86
  usListingsOnly: "FINRA short interest",
87
+ // FINRA's settlements count OTC securities' shares short too: 0700.HK is offered TCEHY.
88
+ usListingsOtc: true,
87
89
  options: [
88
90
  {
89
91
  key: "order",
@@ -9,6 +9,8 @@ export function publicationHeadless(kind: PublicationKind): HeadlessPaneDefiniti
9
9
  shape: "bundle", options: [],
10
10
  argument: { kind: "ticker", description: "US equity ticker.", placeholder: "ticker" },
11
11
  usListingsOnly: fails ? "SEC fails to deliver" : "FINRA weekly off-exchange volume",
12
+ // Both report OTC securities: a receipt over the counter (TCEHY) has its fails and its weekly volume.
13
+ usListingsOtc: true,
12
14
  freshness: { source: fails ? "SEC" : "FINRA", status: "not-a-feed", basis: fails ? "settlement-date outstanding fails" : "published off-exchange volume",
13
15
  schedule: fails ? "published twice monthly" : "published weekly with a delay", observedKey: "date", oldest: null },
14
16
  discovery: {
@@ -14,6 +14,7 @@ export const shortWatchHeadless: HeadlessPaneDefinition<"rows"> = {
14
14
  freshness: { source: "FINRA", status: "not-a-feed", basis: "twice-monthly settlement", observedKey: "settlementDate", maxAgeMinutes: 30 * 24 * 60 },
15
15
  argument: { kind: "symbol-list", maximum: SHORT_WATCH_LIMIT, description: "US tickers; the pane defaults to your portfolios and watchlists." },
16
16
  usListingsOnly: "FINRA short interest",
17
+ usListingsOtc: true,
17
18
  failsWithoutData: true,
18
19
  options: [],
19
20
  describe: "Short squeeze watch",
@@ -313,6 +313,8 @@ function ThirteenFBrowserPane({ focused, width, height, onDetailChange }: PanePr
313
313
  onBodyScrollActivity={loadMoreFromScroll}
314
314
  resetScrollKey={`${browserMode}:${query}`}
315
315
  columns={columns}
316
+ // Performance adds the quarters' returns in time order after the fund's columns.
317
+ columnReorder={browserMode === "performance" ? false : undefined}
316
318
  items={sortedRows}
317
319
  sortColumnId={browserSort.columnId}
318
320
  sortDirection={browserSort.direction}
@@ -5,6 +5,7 @@ import { areNearbyFinancialPeriodEnds, fillDate, fillDateText, statementPeriodMo
5
5
  import { formatPerShareNumber } from "../../../../utils/reported-money";
6
6
  import { hasNonIncomeStatementGap } from "../../../../utils/statement-gaps";
7
7
  import {
8
+ displayWidth,
8
9
  formatGrowthShort,
9
10
  formatNumber,
10
11
  formatWithDivisor,
@@ -32,7 +33,7 @@ export function hasStatementFinancials(financials: TickerFinancials | null | und
32
33
  type FinancialMetricFormat = "compact" | "eps" | "percent";
33
34
  export type FinancialGrowthDirection = "higher" | "lower" | "neutral";
34
35
 
35
- export type MetricDef = {
36
+ type MetricDef = {
36
37
  label: string;
37
38
  key?: keyof FinancialStatement;
38
39
  id?: string;
@@ -92,7 +93,7 @@ export type FinancialTableRow =
92
93
  toggleable: boolean;
93
94
  };
94
95
 
95
- export function statementMetricValue(
96
+ function statementMetricValue(
96
97
  def: Pick<MetricDef, "key" | "compute">,
97
98
  statement: FinancialStatement,
98
99
  ): number | undefined {
@@ -100,6 +101,12 @@ export function statementMetricValue(
100
101
  return typeof value === "number" && Number.isFinite(value) ? value : undefined;
101
102
  }
102
103
 
104
+ /** The figure a row shows for a period: a group's summary line, or the row's own. */
105
+ export function financialCellValue(row: FinancialTableRow, statement: FinancialStatement): number | undefined {
106
+ if (row.kind === "group") return row.summaryKey ? statement[row.summaryKey] as number | undefined : undefined;
107
+ return statementMetricValue(row, statement);
108
+ }
109
+
103
110
  export const FINANCIAL_COL_W = 18;
104
111
  export const FINANCIAL_LABEL_W = 28;
105
112
  const FINANCIAL_LABEL_MIN_W = 12;
@@ -114,8 +121,22 @@ const FINANCIAL_LABEL_MIN_W = 12;
114
121
  export function financialLabelWidth(width: number): number {
115
122
  return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width - FINANCIAL_COL_W - 6));
116
123
  }
124
+ /** The growth after a period's value: a blank and up to six characters (`+466%`, `<-99T%`). */
117
125
  const FINANCIAL_GROWTH_W = 7;
118
- const FINANCIAL_VALUE_W = FINANCIAL_COL_W - FINANCIAL_GROWTH_W;
126
+
127
+ /**
128
+ * A terminal period column as wide as the widest value it shows and the growth
129
+ * after it, or its header where that is wider. A fixed 18 left a short value
130
+ * further from its own column's edge than from its growth, so each pair read
131
+ * tight and the next period far off, and fewer periods fit.
132
+ */
133
+ export function financialPeriodWidth(values: Iterable<string>, headers: Iterable<string>): number {
134
+ let value = 0;
135
+ for (const text of values) value = Math.max(value, displayWidth(text));
136
+ let header = 0;
137
+ for (const text of headers) header = Math.max(header, displayWidth(text));
138
+ return Math.max(value + FINANCIAL_GROWTH_W, header);
139
+ }
119
140
 
120
141
  export function computeGrowth(current: number | undefined, previous: number | undefined): number | undefined {
121
142
  if (current == null || previous == null || !Number.isFinite(current) || !Number.isFinite(previous) || previous === 0) return undefined;
@@ -182,10 +203,11 @@ export function semanticGrowthValue(
182
203
  return growth;
183
204
  }
184
205
 
185
- export function formatFinancialCell(value: string, growth: number | undefined) {
206
+ /** A period's value and its growth laid out in a column `width` cells wide, the growth against its right edge. */
207
+ export function formatFinancialCell(value: string, growth: number | undefined, width = FINANCIAL_COL_W) {
186
208
  const growthText = growth != null && Number.isFinite(growth) ? formatFinancialGrowth(growth) : "";
187
209
  return {
188
- valueText: padTo(value, FINANCIAL_VALUE_W, "right"),
210
+ valueText: padTo(value, Math.max(0, width - FINANCIAL_GROWTH_W), "right"),
189
211
  growthText: padTo(growthText ? ` ${growthText}` : "", FINANCIAL_GROWTH_W, "right"),
190
212
  };
191
213
  }
@@ -461,7 +483,7 @@ export function shareFinancialUnit<T extends { unitLabel: string; label: string;
461
483
  export function buildFinancialRows(
462
484
  defs: FinancialRowDef[],
463
485
  statements: FinancialStatement[],
464
- collapsedGroups: Set<string>,
486
+ collapsedGroups: ReadonlySet<string>,
465
487
  depth = 0,
466
488
  ): FinancialTableRow[] {
467
489
  const rows: FinancialTableRow[] = [];
@@ -9,7 +9,7 @@ import {
9
9
  import { useAssetData } from "../../../runtime";
10
10
  import { colors, priceColor } from "../../../../theme/colors";
11
11
  import type { PricePoint } from "../../../../types/financials";
12
- import { padTo } from "../../../../utils/format";
12
+ import { displayWidth, padTo } from "../../../../utils/format";
13
13
  import { useBoundTicker, useTickerRequest } from "../../shared/ticker-request";
14
14
  import type { FinancialTableStatement } from "./aggregation";
15
15
  import { FINANCIAL_COL_W, financialLabelWidth } from "./model";
@@ -29,6 +29,28 @@ export type RatioTableColumn = DataTableColumn & (
29
29
 
30
30
  const ratioRowKey = (row: RatioTableRow) => row.id;
31
31
 
32
+ /**
33
+ * A ratio's name in the metric column, after its disclosure, a cell apart: as wide as it says
34
+ * (`contentWidth`), so the table fits the column to it whole. The desktop draws the disclosure as a
35
+ * path, not a glyph.
36
+ */
37
+ export function ratioNameCell(
38
+ row: Extract<RatioTableRow, { kind: "ratio" }>,
39
+ color: string,
40
+ ): Pick<DataTableCell, "text" | "contentWidth" | "content"> {
41
+ const text = `${row.expanded ? "▾" : "▸"} ${row.label}`;
42
+ return {
43
+ text,
44
+ contentWidth: displayWidth(text),
45
+ content: (
46
+ <Box flexDirection="row" alignItems="center" gap={1}>
47
+ <DisclosureMarker expanded={row.expanded} color={color} />
48
+ <Text fg={color}>{row.label}</Text>
49
+ </Box>
50
+ ),
51
+ };
52
+ }
53
+
32
54
  export interface PeriodEndHistoryState {
33
55
  data: PricePoint[] | undefined;
34
56
  loading: boolean;
@@ -102,15 +124,8 @@ export function RatioTable({
102
124
  return { text: ` ${row.unitLabel}`, color: colors.textDim };
103
125
  }
104
126
  return {
105
- text: `${row.expanded ? "▾" : "▸"} ${row.label}`,
127
+ ...ratioNameCell(row, colors.text),
106
128
  color: colors.text,
107
- // The desktop draws the disclosure as a path, not a glyph.
108
- content: (
109
- <Box flexDirection="row" alignItems="center" gap={1}>
110
- <DisclosureMarker expanded={row.expanded} color={colors.text} />
111
- <Text fg={colors.text}>{row.label}</Text>
112
- </Box>
113
- ),
114
129
  onMouseDown: (event) => {
115
130
  event.preventDefault?.();
116
131
  event.stopPropagation?.();
@@ -146,6 +161,8 @@ export function RatioTable({
146
161
  headerScrollId={headerScrollId}
147
162
  bodyScrollId={bodyScrollId}
148
163
  columns={columns}
164
+ // The statements' fiscal periods: an axis, not columns to arrange.
165
+ columnReorder={false}
149
166
  items={rows}
150
167
  selection={{
151
168
  kind: "id",