@gloom-sh/terminal 0.19.3 → 0.19.5

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 (226) hide show
  1. package/package.json +4 -2
  2. package/src/api-client/errors.ts +8 -0
  3. package/src/api-client/index.ts +18 -0
  4. package/src/api-client/request.ts +295 -42
  5. package/src/api-client/socket.ts +95 -0
  6. package/src/app/keybindings/actions.ts +1 -1
  7. package/src/app/pane-runtime/index.tsx +1 -1
  8. package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
  9. package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
  10. package/src/app/pane-runtime/ticker-open-target.ts +12 -2
  11. package/src/cli/commands/command-utils.ts +4 -0
  12. package/src/cli/commands/market.ts +119 -27
  13. package/src/cli/commands/search.ts +1 -1
  14. package/src/cli/commands/ticker.ts +10 -6
  15. package/src/cli/currency-name-hint.ts +60 -0
  16. package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
  17. package/src/cli/desktop-pane-shot.ts +2 -1
  18. package/src/cli/history-rows.ts +18 -1
  19. package/src/cli/known-gaps.ts +17 -2
  20. package/src/cli/not-a-ticker.ts +5 -3
  21. package/src/cli/pane-functions/catalog.ts +9 -1
  22. package/src/cli/pane-functions/headless.ts +7 -3
  23. package/src/cli/pane-functions/market-session.ts +6 -7
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  26. package/src/components/chart/composite/time-axis.ts +17 -2
  27. package/src/components/command-bar/action-runtime.ts +2 -0
  28. package/src/components/command-bar/commands/direct/runtime.ts +3 -3
  29. package/src/components/command-bar/helpers.ts +2 -0
  30. package/src/components/command-bar/list/model.ts +9 -0
  31. package/src/components/command-bar/pane-actions.ts +46 -35
  32. package/src/components/command-bar/pane-templates/workflow.ts +6 -0
  33. package/src/components/command-bar/panel/index.tsx +30 -3
  34. package/src/components/command-bar/panel/types.ts +7 -0
  35. package/src/components/command-bar/routes/root/results.ts +4 -4
  36. package/src/components/command-bar/routes/root/selection.ts +3 -2
  37. package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
  38. package/src/components/command-bar/routing/launch-request.ts +3 -2
  39. package/src/components/command-bar/routing/list-state.ts +4 -1
  40. package/src/components/command-bar/surface/index.tsx +15 -1
  41. package/src/components/layout/floating-pane.tsx +10 -0
  42. package/src/components/layout/pane/frame.tsx +6 -0
  43. package/src/components/layout/pane/header.tsx +244 -42
  44. package/src/components/layout/pane/index.tsx +20 -2
  45. package/src/components/layout/shell/active-drag.ts +160 -28
  46. package/src/components/layout/shell/drag/index.ts +99 -96
  47. package/src/components/layout/shell/drag/live.ts +3 -17
  48. package/src/components/layout/shell/drag/magnets.ts +304 -0
  49. package/src/components/layout/shell/drag/overlays.tsx +77 -75
  50. package/src/components/layout/shell/drag/runtime.ts +12 -7
  51. package/src/components/layout/shell/index.tsx +66 -32
  52. package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
  53. package/src/components/layout/shell/native/surfaces.ts +1 -9
  54. package/src/components/layout/shell/native/window-state.ts +21 -25
  55. package/src/components/layout/shell/pane/layers.tsx +153 -24
  56. package/src/components/layout/shell/shortcuts.ts +4 -1
  57. package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
  58. package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
  59. package/src/components/layout/status-bar.tsx +75 -6
  60. package/src/components/layout/window-controls.tsx +96 -35
  61. package/src/components/layout/window-fullscreen.ts +20 -0
  62. package/src/components/quote-flash.ts +36 -32
  63. package/src/core/app-runtime.ts +4 -1
  64. package/src/core/connection-health.ts +76 -1
  65. package/src/core/state/app/command-bar-launch.ts +12 -0
  66. package/src/core/state/app/layout.ts +4 -3
  67. package/src/core/state/app/types.ts +4 -1
  68. package/src/data/config/layout.ts +2 -2
  69. package/src/data/config/store/fold-panes.ts +6 -1
  70. package/src/i18n/es.ts +8 -1
  71. package/src/i18n/ja.ts +8 -1
  72. package/src/i18n/ko.ts +8 -1
  73. package/src/i18n/zh-cn.ts +8 -1
  74. package/src/i18n/zh-tw.ts +8 -1
  75. package/src/layout/pane-follow.ts +3 -2
  76. package/src/layout/pane-layout-move.ts +2 -1
  77. package/src/layout/pane-manager/dock-stack.ts +38 -0
  78. package/src/layout/pane-manager/dock-tree.ts +76 -15
  79. package/src/layout/pane-manager/docking.ts +48 -6
  80. package/src/layout/pane-manager/floating-actions.ts +12 -3
  81. package/src/layout/pane-manager/floating-placement.ts +189 -0
  82. package/src/layout/pane-manager/floating.ts +23 -4
  83. package/src/layout/pane-manager/gridlock.ts +16 -4
  84. package/src/layout/pane-manager/hidden-panes.ts +30 -1
  85. package/src/layout/pane-manager/index.ts +2 -0
  86. package/src/layout/pane-manager/layout-state.ts +17 -0
  87. package/src/layout/pane-manager/types.ts +4 -1
  88. package/src/layout/ticker-retarget.ts +88 -0
  89. package/src/layout-marketplace/cloud.ts +9 -1
  90. package/src/market-data/connection-follow.ts +68 -0
  91. package/src/market-data/coordinator/entries.ts +15 -3
  92. package/src/market-data/coordinator/events.ts +17 -1
  93. package/src/market-data/coordinator/financials.ts +20 -7
  94. package/src/market-data/coordinator/index.ts +217 -4
  95. package/src/market-data/coordinator/quotes.ts +10 -0
  96. package/src/market-data/frame-scheduler.ts +47 -10
  97. package/src/market-data/frame-wake.ts +74 -0
  98. package/src/market-data/futures-board.ts +7 -6
  99. package/src/market-data/hooks.tsx +43 -3
  100. package/src/market-data/performance.ts +78 -9
  101. package/src/market-data/request-types.ts +6 -3
  102. package/src/news/aggregator.ts +12 -1
  103. package/src/plugins/builtin/alerts/cli.ts +2 -1
  104. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  105. package/src/plugins/builtin/attention/evidence.ts +1 -1
  106. package/src/plugins/builtin/awards/client.ts +1 -1
  107. package/src/plugins/builtin/awards/evidence.ts +1 -1
  108. package/src/plugins/builtin/awards/pane.tsx +2 -1
  109. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  110. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  111. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  112. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  113. package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
  114. package/src/plugins/builtin/buildout/model/index.ts +6 -0
  115. package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
  116. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  117. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  118. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  119. package/src/plugins/builtin/chart-composer/index.tsx +13 -0
  120. package/src/plugins/builtin/chat/controller/index.ts +10 -3
  121. package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
  122. package/src/plugins/builtin/chat/status-widget.tsx +3 -1
  123. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  124. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  125. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  126. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  127. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  128. package/src/plugins/builtin/cot/headless.ts +9 -3
  129. package/src/plugins/builtin/cot/model.ts +44 -3
  130. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  131. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  132. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  133. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  134. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  135. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  136. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  137. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  138. package/src/plugins/builtin/futures/series.ts +16 -1
  139. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  140. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  141. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  142. package/src/plugins/builtin/gpu/headless.ts +2 -1
  143. package/src/plugins/builtin/help/function-card.tsx +2 -1
  144. package/src/plugins/builtin/help/index.tsx +3 -2
  145. package/src/plugins/builtin/insider/display.ts +45 -6
  146. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  147. package/src/plugins/builtin/iv-history/client.ts +2 -1
  148. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  149. package/src/plugins/builtin/jobs/pages.ts +4 -4
  150. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  151. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  152. package/src/plugins/builtin/members/client.ts +1 -1
  153. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  154. package/src/plugins/builtin/mna/pane.tsx +4 -1
  155. package/src/plugins/builtin/options/market-reference.ts +1 -1
  156. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  157. package/src/plugins/builtin/options/view.tsx +2 -1
  158. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  159. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  160. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  161. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  162. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  163. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  164. package/src/plugins/builtin/perps/client.ts +1 -1
  165. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  166. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  167. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  168. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  169. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  170. package/src/plugins/builtin/research/index.tsx +1 -0
  171. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  172. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  173. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  174. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  175. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  176. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  177. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  178. package/src/plugins/builtin/sec/index.tsx +7 -4
  179. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  180. package/src/plugins/builtin/sectors/client.ts +18 -8
  181. package/src/plugins/builtin/sectors/index.tsx +19 -5
  182. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  183. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  184. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  185. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  186. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  187. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  188. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  189. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  190. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  191. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
  192. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
  193. package/src/plugins/builtin/time-sales/client.ts +1 -0
  194. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  195. package/src/plugins/builtin/yield-curve/headless.ts +3 -1
  196. package/src/portfolio/column-values.ts +76 -10
  197. package/src/react/async-resource.ts +12 -0
  198. package/src/remote/controller.ts +3 -1
  199. package/src/renderers/browser/app-services.ts +8 -1
  200. package/src/renderers/browser/cloud-transport.ts +6 -1
  201. package/src/renderers/cloudflare/worker.ts +24 -2
  202. package/src/renderers/dom/host/box.tsx +204 -176
  203. package/src/renderers/dom/host/style.ts +49 -20
  204. package/src/renderers/dom/host/text.tsx +3 -2
  205. package/src/renderers/dom/styles.css +32 -0
  206. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  207. package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
  208. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  209. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  210. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  211. package/src/renderers/electrobun/shared/protocol.ts +6 -0
  212. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  213. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  214. package/src/shares/portable-layout.ts +99 -2
  215. package/src/sources/provider-router/index.ts +9 -3
  216. package/src/sources/provider-router/sources.ts +26 -1
  217. package/src/sync/core-contributors.ts +18 -4
  218. package/src/time-series/price-units.ts +11 -0
  219. package/src/time-series/resolve.ts +12 -0
  220. package/src/types/config.ts +17 -1
  221. package/src/types/plugin.ts +6 -0
  222. package/src/ui/host.tsx +2 -0
  223. package/src/utils/currency-names.ts +20 -0
  224. package/src/utils/currency-pair.ts +6 -0
  225. package/src/utils/exchange-rate-snapshot.ts +20 -2
  226. package/src/utils/fx-market-hours.ts +43 -0
@@ -78,7 +78,7 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
78
78
  return { sections: [], empty: `No price for ${missing}, so the pair cannot be compared.`, unavailableSymbols: [missing], errors };
79
79
  }
80
80
  const figures = adrPairFigures(comparison);
81
- const rows = adrPairInputRows(comparison);
81
+ const rows = adrPairInputRows(comparison, quotes);
82
82
  const kind = spotRateKind(homeCurrency);
83
83
  return {
84
84
  sections: [
@@ -2,7 +2,8 @@ import type { DepositaryPair, Quote, TickerFinancials } from "../../../../types/
2
2
  import type { TickerRecord } from "../../../../types/ticker";
3
3
  import { canonicalExchange, parsePublicTickerKey, publicTickerKey } from "../../../../utils/exchanges";
4
4
  import { listingSuffixCandidate, listingSuffixVenue } from "../../../../sources/listing-symbols";
5
- import { formatMarketPriceWithCurrency } from "../../../../market-data/market/format";
5
+ import { formatMarketPriceWithCurrency, liveQuoteFormatOptions, type MarketFormatOptions } from "../../../../market-data/market/format";
6
+ import { heldCurrencyUnit } from "../../../../utils/currency-units";
6
7
  import { adrRatioText } from "../../../../utils/depositary-receipt";
7
8
  import {
8
9
  compareDepositaryPair, dollarPairLabel, formatPairRate, isReceiptSide, listingDepositaryPair, pairPriceInput, pairTimeText,
@@ -108,20 +109,39 @@ function sessionText(input: PairPriceInput): string {
108
109
  return input.open ? "Open" : "Closed";
109
110
  }
110
111
 
112
+ /**
113
+ * A leg's price written as the quote monitor writes the listing's: its
114
+ * instrument's own decimals (cents on a dollar price, $419.50 and never
115
+ * $419.5). The comparison reads a minor unit (GBp) in its currency, so the
116
+ * session prices the decimals come from are read in it too.
117
+ */
118
+ function legPriceOptions(input: PairPriceInput, quote: Quote | null | undefined): MarketFormatOptions {
119
+ const divisor = quote?.currency ? heldCurrencyUnit(quote.currency).divisor : 1;
120
+ const inCurrency = (value: number | undefined) => value == null ? value : value / divisor;
121
+ return liveQuoteFormatOptions(
122
+ quote ? { ...quote, previousClose: inCurrency(quote.previousClose), regularClose: inCurrency(quote.regularClose), open: inCurrency(quote.open) } : null,
123
+ input.currency,
124
+ );
125
+ }
126
+
111
127
  /** The inputs the figures come from, each with when it was set. */
112
- export function adrPairInputRows(comparison: DepositaryPairComparison, now = Date.now()): AdrPairInputRow[] {
128
+ export function adrPairInputRows(
129
+ comparison: DepositaryPairComparison,
130
+ quotes: { receipt: Quote | null | undefined; home: Quote | null | undefined },
131
+ now = Date.now(),
132
+ ): AdrPairInputRow[] {
113
133
  const { home, receipt, spot, ratio } = comparison;
114
134
  const time = (value: number | null) => value == null ? "—" : pairTimeText(value, now).replace(/ UTC$/, "");
115
135
  const kind = spotRateKind(home.currency);
116
136
  return [
117
137
  {
118
138
  id: "home", listing: home.symbol, role: `Home, ${ratioCount(ratio)} per ADR`,
119
- price: formatMarketPriceWithCurrency(home.price, home.currency, { currencyCode: true }),
139
+ price: formatMarketPriceWithCurrency(home.price, home.currency, { ...legPriceOptions(home, quotes.home), currencyCode: true }),
120
140
  asOf: time(home.observedAt), session: sessionText(home), opens: home.symbol,
121
141
  },
122
142
  {
123
143
  id: "receipt", listing: receipt.symbol, role: "ADR",
124
- price: formatMarketPriceWithCurrency(receipt.price, receipt.currency), asOf: time(receipt.observedAt),
144
+ price: formatMarketPriceWithCurrency(receipt.price, receipt.currency, legPriceOptions(receipt, quotes.receipt)), asOf: time(receipt.observedAt),
125
145
  session: sessionText(receipt), opens: receipt.symbol,
126
146
  },
127
147
  ...spot ? [{
@@ -49,7 +49,7 @@ export function AdrPairResearchTab({ width, height, focused }: TickerResearchTab
49
49
  const [selectedIndex, setSelectedIndex] = useState(0);
50
50
 
51
51
  const stats: StatItem[] = comparison ? adrPairFigures(comparison) : [];
52
- const rows = comparison ? adrPairInputRows(comparison) : [];
52
+ const rows = comparison ? adrPairInputRows(comparison, { receipt: receiptQuote, home: homeQuote }) : [];
53
53
 
54
54
  if (!legs) return <EmptyState title="No ADR pair for this listing." />;
55
55
  const pending = (entry: typeof receiptEntry) => !entry || entry.phase === "loading" || entry.phase === "idle";
@@ -15,12 +15,14 @@ import { OverviewTab } from "../overview-tab";
15
15
  import { useOpenResearchTab } from "../research-tab-navigation";
16
16
  import type { OverviewFunctionLink } from "./types";
17
17
  import { useOverviewDividend } from "./dividend";
18
+ import { useTickerSnapshotState } from "../../../../market-data/hooks";
18
19
 
19
20
  /** Registered by the chart composer, in the same plugin as this tab. */
20
21
  const CHART_TAB_ID = "chart";
21
22
 
22
23
  export function OverviewResearchTab({ width, height, focused }: TickerResearchTabProps) {
23
- const { ticker, financials } = usePaneTicker();
24
+ const { symbol, ticker, financials } = usePaneTicker();
25
+ const snapshot = useTickerSnapshotState(symbol, ticker);
24
26
  const dispatch = useAppDispatch();
25
27
  const paneId = useOptionalPaneInstanceId();
26
28
  const paneInstance = usePaneInstance();
@@ -48,6 +50,7 @@ export function OverviewResearchTab({ width, height, focused }: TickerResearchTa
48
50
  onOpenChart={paneId && !lockedToOneTab ? openChart : undefined}
49
51
  onOpenFunction={openFunction}
50
52
  dividend={dividend}
53
+ snapshot={snapshot}
51
54
  perpetuals={ticker ? (contentWidth: number) => {
52
55
  const instrumentType = financials?.quote?.instrumentType ?? ticker.metadata.assetCategory;
53
56
  // A contract's own DES shows its funding and premium; a stock or a coin lists its markets across venues.
@@ -6,13 +6,13 @@ import { mayBeUsEquityOrFundTicker } from "../../../utils/sec";
6
6
  import { ResearchTradeActions, researchTradeMatches, useResearchTrading } from "../shared/research-trading";
7
7
  import { instrumentFromTicker } from "../../../market-data/request-types";
8
8
  import { useMemo, type ReactNode } from "react";
9
- import { EmptyState, ExternalLinkText, PaneLinkMenu, SectionHeading, usePaneNoticeFooter } from "../../../components";
9
+ import { EmptyState, ExternalLinkText, PaneLinkMenu, PaneStatusBody, SectionHeading, unavailableText, usePaneNoticeFooter } from "../../../components";
10
10
  import { CompositeChart, pricePointsToResolvedSeries } from "../../../components/chart/composite";
11
11
  import { CompanyLogo, resolveCompanyLogoSrc } from "../../../components/company-logo";
12
12
  import { bodyLineInk, FigureText, figureLineInk, useFigureCells } from "../../../components/ui/figure";
13
13
  import { PriceReturnStrip } from "../../../components/price-performance";
14
14
  import { t } from "../../../i18n";
15
- import { useFxRateObservations } from "../../../market-data/hooks";
15
+ import { useFxRateObservations, type TickerSnapshotState } from "../../../market-data/hooks";
16
16
  import { formatMarketPriceWithCurrency, formatSignedMarketPrice, liveQuoteFormatOptions } from "../../../market-data/market/format";
17
17
  import { priceSeriesUnit } from "../../../market-data/market/index-level";
18
18
  import {
@@ -103,10 +103,33 @@ interface OverviewTabProps {
103
103
  onOpenFunction?: (link: OverviewFunctionLink) => void;
104
104
  /** The history the dividend yield reads (useOverviewDividend): a trailing one's cash, a forward one's lapse; without it the yield stands. */
105
105
  dividend?: OverviewDividendState;
106
+ /** Where the ticker's snapshot load stands (useTickerSnapshotState), for the state shown before anything of it is in. */
107
+ snapshot?: TickerSnapshotState;
108
+ }
109
+
110
+ /** Nothing of the ticker is in yet: no quote, profile, figures or history. */
111
+ function hasNothingToShow(financials: TickerFinancials | null): boolean {
112
+ if (!financials) return true;
113
+ return !financials.quote && !financials.profile && (financials.priceHistory?.length ?? 0) === 0
114
+ && Object.keys(financials.fundamentals ?? {}).length === 0
115
+ && financials.annualStatements.length === 0 && financials.quarterlyStatements.length === 0;
106
116
  }
107
117
 
108
118
  export function OverviewTab(props: OverviewTabProps) {
109
119
  if (!props.ticker) return <EmptyState title={t("No ticker selected.")} />;
120
+ // Before anything of the ticker is in, the tab says it is loading, or why it could not, rather than standing empty.
121
+ const { snapshot } = props;
122
+ if (snapshot && (snapshot.loading || snapshot.error) && hasNothingToShow(props.financials)) {
123
+ return (
124
+ <PaneStatusBody
125
+ loading={snapshot.loading}
126
+ error={snapshot.loading ? null : snapshot.error}
127
+ subject="overview"
128
+ errorTitle={unavailableText(t("Overview"))}
129
+ retry={{ onRetry: snapshot.retry }}
130
+ />
131
+ );
132
+ }
110
133
  return <ResolvedOverviewTab {...props} ticker={props.ticker} />;
111
134
  }
112
135
 
@@ -79,6 +79,7 @@ export function tapeRejection(body: string): string | null {
79
79
  const value = JSON.parse(body) as { gaps?: unknown };
80
80
  return Array.isArray(value?.gaps) && typeof value.gaps[0] === "string" ? value.gaps[0] : null;
81
81
  } catch {
82
+ // Intentional ignore: an error body that is not JSON names no gap, so the request's own error stands.
82
83
  return null;
83
84
  }
84
85
  }
@@ -15,6 +15,7 @@ import { abortable, abortError } from "../../../utils/async-deadline";
15
15
  import { errorMessage } from "../../../utils/errors";
16
16
  import { expiredExpiryText, findListedExpiry, isLiveOptionExpiry, liveOptionExpiries, optionExpiryVenue, unlistedExpiryText } from "../../../utils/option-expiry";
17
17
  import { optionModelSpot } from "../options/model-spot";
18
+ import { logFailure } from "../../../utils/log-failure";
18
19
 
19
20
  const DEFAULT_SURFACE_EXPIRY_LIMIT = 18;
20
21
  /** Expiries read at a time from a source that takes them one by one. */
@@ -190,7 +191,7 @@ export async function loadVolatilitySurface(
190
191
  checkAbort();
191
192
  publish();
192
193
  // Asked while the catalogue loads, so it costs the expiries no wait.
193
- const batched = Promise.resolve().then(() => dependencies.batchesExpiries?.()).then((answer) => answer === true, () => false);
194
+ const batched = Promise.resolve().then(() => dependencies.batchesExpiries?.()).then((answer) => answer === true, logFailure("vol-surface.client", "Read expiry batching support failed", false));
194
195
  const treasury = Promise.resolve().then(() => dependencies.loadYieldCurve()).then((value) => {
195
196
  if (request.signal?.aborted) return;
196
197
  curve = value;
@@ -16,6 +16,7 @@ import { SWAP_TENORS, type SwapCurvePayload, type SwapTenor } from "../../../api
16
16
  import { fetchSwapCurve, loadSavedCurve, loadSavedWorldRows } from "./client";
17
17
  import { savedCopyMark } from "../../../data/saved-copies";
18
18
  import { formatSwapBp, selectedSwapTenor } from "./swaps-model";
19
+ import { logFailure } from "../../../utils/log-failure";
19
20
 
20
21
  const percent = (value: unknown) => value == null ? "-" : `${Number(value).toFixed(2)}%`;
21
22
  /** A move already in basis points: `+3bp`, `-1bp`, `0bp`. */
@@ -164,6 +165,7 @@ export function createYieldCurveHeadless(
164
165
  const curve = curveIdOf(args.options.curve) ?? parseCurveArgument(args.argument).curve ?? "us";
165
166
  return `Yield Curves | ${curveOption(curve).label}`;
166
167
  } catch {
168
+ // Intentional ignore: the load reports a curve it cannot read, so the title stays generic.
167
169
  return "Yield Curves";
168
170
  }
169
171
  },
@@ -206,7 +208,7 @@ export function createYieldCurveHeadless(
206
208
  const compareAsOf = comparePoints ? curveAsOf(comparePoints) : null;
207
209
  const compareAt = (maturity: string) => comparePoints?.find((point) => point.maturity === maturity)?.yield ?? null;
208
210
  // The stored curve brings its look-backs; the FRED fallback's load after it, and a failure leaves the move blank.
209
- const lookbacks: YieldLookbackCurves = data.lookbacks ?? (session ? await loadLookbacks(session, context).catch(() => ({})) : {});
211
+ const lookbacks: YieldLookbackCurves = data.lookbacks ?? (session ? await loadLookbacks(session, context).catch(logFailure("yield-curve.headless", "Load yield curve lookbacks failed", {})) : {});
210
212
  const tenorRows = new Map(yieldTenorRows(points, lookbacks).map((row) => [row.id, row]));
211
213
  const rows = [...points].sort((a, b) => a.maturityYears - b.maturityYears);
212
214
  const missing = points.filter((point) => point.yield == null);
@@ -397,6 +397,80 @@ function futuresContractSizeLabel(
397
397
  return !metrics.unknownContractSize && multiplier > 1 ? { size: formatMarketQuantity(multiplier) } : null;
398
398
  }
399
399
 
400
+ interface RowPositionMetrics {
401
+ quoteCurrency: string;
402
+ quote: Quote | undefined;
403
+ /** What the figures were worked out for: a context that disagrees works them out again. */
404
+ activeTab: string | undefined;
405
+ baseCurrency: string;
406
+ exchangeRates: Map<string, number>;
407
+ /** In the position's own currency. */
408
+ position: PortfolioPositionMetrics;
409
+ /** Converted into the pane's currency (`ctx.baseCurrency`). */
410
+ base: PortfolioPositionMetrics;
411
+ }
412
+
413
+ /** Each shared context's row figures, by record. */
414
+ const sharedRowMetrics = new WeakMap<ColumnContext, WeakMap<TickerRecord, RowPositionMetrics>>();
415
+ const rowMetricsByOwner = new WeakMap<object, WeakMap<TickerRecord, RowPositionMetrics>>();
416
+
417
+ /**
418
+ * Lets the cells and sort keys read with `ctx` work out each row's position
419
+ * figures once per quote, rather than twice a cell: a pane's rows recompute
420
+ * every visible cell when a quote ticks. Contexts given the same `owner` share
421
+ * the figures while they agree on the tab, currency and rates (a context that
422
+ * disagrees works them out again). Only for records that are replaced when
423
+ * they change, never edited in place.
424
+ */
425
+ export function sharePositionMetrics<T extends ColumnContext>(ctx: T, owner: object = ctx): T {
426
+ let rows = rowMetricsByOwner.get(owner);
427
+ if (!rows) {
428
+ rows = new WeakMap();
429
+ rowMetricsByOwner.set(owner, rows);
430
+ }
431
+ sharedRowMetrics.set(ctx, rows);
432
+ return ctx;
433
+ }
434
+
435
+ function computeRowPositionMetrics(ticker: TickerRecord, ctx: ColumnContext, quoteCurrency: string, quote: Quote | undefined): RowPositionMetrics {
436
+ const { activeTab, baseCurrency, exchangeRates } = ctx;
437
+ return {
438
+ quoteCurrency,
439
+ quote,
440
+ activeTab,
441
+ baseCurrency,
442
+ exchangeRates,
443
+ position: getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, undefined, quote),
444
+ base: getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, {
445
+ currency: baseCurrency,
446
+ convert: (value, currency) => convertCurrency(value, currency, baseCurrency, exchangeRates),
447
+ }, quote),
448
+ };
449
+ }
450
+
451
+ /** A row's position figures, in its own currency and in the pane's (sharePositionMetrics). */
452
+ function rowPositionMetrics(
453
+ ticker: TickerRecord,
454
+ ctx: ColumnContext,
455
+ quoteCurrency: string,
456
+ quote: Quote | undefined,
457
+ ): RowPositionMetrics {
458
+ const rows = sharedRowMetrics.get(ctx);
459
+ if (!rows) return computeRowPositionMetrics(ticker, ctx, quoteCurrency, quote);
460
+ const cached = rows.get(ticker);
461
+ if (
462
+ cached
463
+ && cached.quote === quote
464
+ && cached.quoteCurrency === quoteCurrency
465
+ && cached.activeTab === ctx.activeTab
466
+ && cached.baseCurrency === ctx.baseCurrency
467
+ && cached.exchangeRates === ctx.exchangeRates
468
+ ) return cached;
469
+ const entry = computeRowPositionMetrics(ticker, ctx, quoteCurrency, quote);
470
+ rows.set(ticker, entry);
471
+ return entry;
472
+ }
473
+
400
474
  export function getColumnValue(
401
475
  col: ColumnConfig,
402
476
  ticker: TickerRecord,
@@ -408,7 +482,7 @@ export function getColumnValue(
408
482
  const fundamentals = financials?.fundamentals;
409
483
  const quoteCurrency = quote?.currency || ticker.metadata.currency || "USD";
410
484
 
411
- const positionMetrics = getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, undefined, quote);
485
+ const { position: positionMetrics, base: baseMetrics } = rowPositionMetrics(ticker, ctx, quoteCurrency, quote);
412
486
  const futures = positionMetrics.isFuture ? ctx.futuresTerms?.get(ticker.metadata.ticker) : undefined;
413
487
  // The latest print, which the quote columns read, and the price the position is valued at.
414
488
  const liveQuote = getPortfolioQuoteDisplay(positionMetrics, quote);
@@ -416,10 +490,6 @@ export function getColumnValue(
416
490
  const displayQuote = tradedQuoteDisplay(positionMetrics, liveQuote, quote);
417
491
  const headlineQuote = settledHeadline(positionMetrics, ctx, futures) ?? headlineQuoteDisplay(displayQuote, quote);
418
492
  const { positionCurrency, totalShares, totalCost, totalCostUnits, totalPriceUnits, multiplierHint, brokerMarkPrice } = positionMetrics;
419
- const baseMetrics = getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, {
420
- currency: ctx.baseCurrency,
421
- convert: (value, currency) => convertCurrency(value, currency, ctx.baseCurrency, ctx.exchangeRates),
422
- }, quote);
423
493
 
424
494
  const toBaseQuote = (value: number) =>
425
495
  convertCurrency(value, quoteCurrency, ctx.baseCurrency, ctx.exchangeRates);
@@ -685,17 +755,13 @@ export function getSortValue(
685
755
  const fundamentals = financials?.fundamentals;
686
756
  const quoteCurrency = quote?.currency || ticker.metadata.currency || "USD";
687
757
 
688
- const positionMetrics = getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, undefined, quote);
758
+ const { position: positionMetrics, base: baseMetrics } = rowPositionMetrics(ticker, ctx, quoteCurrency, quote);
689
759
  const futures = positionMetrics.isFuture ? ctx.futuresTerms?.get(ticker.metadata.ticker) : undefined;
690
760
  const liveQuote = getPortfolioQuoteDisplay(positionMetrics, quote);
691
761
  const activeQuote = getPortfolioValuationDisplay(positionMetrics, quote, ctx.valuationBasis, futures?.settlement);
692
762
  const displayQuote = tradedQuoteDisplay(positionMetrics, liveQuote, quote);
693
763
  const headlineQuote = settledHeadline(positionMetrics, ctx, futures) ?? headlineQuoteDisplay(displayQuote, quote);
694
764
  const { positionCurrency, totalShares, totalCost, totalCostUnits, totalPriceUnits, brokerMarkPrice } = positionMetrics;
695
- const baseMetrics = getPortfolioPositionMetrics(ticker, ctx.activeTab, quoteCurrency, {
696
- currency: ctx.baseCurrency,
697
- convert: (value, currency) => convertCurrency(value, currency, ctx.baseCurrency, ctx.exchangeRates),
698
- }, quote);
699
765
 
700
766
  const toBaseQuote = (value: number) =>
701
767
  convertCurrency(value, quoteCurrency, ctx.baseCurrency, ctx.exchangeRates);
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { connectionHealth, GLOOM_CLOUD_HTTP_CONNECTION_ID } from "../core/connection-health";
2
3
 
3
4
  interface ResourceState<T> {
4
5
  data: T | null;
@@ -74,6 +75,17 @@ export function useAsyncResource<T>(
74
75
  const { data, loading, error, updatedAt } = state.owner === loader ? state
75
76
  : keepPreviousData && loader ? { ...state, loading: true, error: null }
76
77
  : { data: null, loading: !!loader, error: null, updatedAt: null };
78
+
79
+ // A load that failed is asked again once the data service answers after an
80
+ // outage, so a pane recovers by itself instead of keeping the failure.
81
+ const failedRef = useRef(false);
82
+ failedRef.current = !!loader && error !== null && !loading;
83
+ useEffect(() => {
84
+ if (!loader) return;
85
+ return connectionHealth.subscribeRecovery((sourceId) => {
86
+ if (sourceId === GLOOM_CLOUD_HTTP_CONNECTION_ID && failedRef.current) void load();
87
+ });
88
+ }, [load, loader]);
77
89
  const status = error !== null ? "error" : data !== null ? "loaded" : loading ? "loading" : "idle";
78
90
  return { data, loading, error, updatedAt, status, load, reload };
79
91
  }
@@ -64,6 +64,7 @@ import {
64
64
  import { createRemoteResources } from "./resources";
65
65
  import { dismissTopmostDialog, isDialogOpen as isAnyDialogOpen } from "../ui/dialog-stack";
66
66
  import { asRecord } from "../utils/guards";
67
+ import { SECURITY_DESCRIPTION_SEARCH } from "../core/state/app/command-bar-launch";
67
68
  import { runAutomated } from "../telemetry/usage-counts";
68
69
  import {
69
70
  applyWatchlistChange,
@@ -277,7 +278,8 @@ export function createAppRemoteController({
277
278
  await afterMutation();
278
279
  }
279
280
  if (mode === "ticker") {
280
- dispatch({ type: "SET_COMMAND_BAR", open: true, launch: { kind: "ticker-search", query } });
281
+ // DES's search: a remote pick opens the ticker, it does not change the focused pane's.
282
+ dispatch({ type: "SET_COMMAND_BAR", open: true, launch: { kind: "ticker-search", query, payload: SECURITY_DESCRIPTION_SEARCH } });
281
283
  await afterMutation();
282
284
  return mutationSummary(getState(), { commandBar: getResource("app://command-bar") });
283
285
  }
@@ -7,6 +7,7 @@ import { AssetDataRouter } from "../../sources/provider-router";
7
7
  import { JsonPersistence } from "../../data/json-persistence";
8
8
  import { isBrokerAccountSnapshotKey } from "../../brokers/account-cache";
9
9
  import { JsonTickerRepository } from "../../data/json-ticker-repository";
10
+ import { registerGloomCloudConnectionSources } from "../../core/connection-health";
10
11
 
11
12
  export function createBrowserAppServices({ config, plugins, externalPlugins }: AppServicesFactoryOptions) {
12
13
  const cloudProvider = createGloomberbCloudProvider();
@@ -27,7 +28,13 @@ export function createBrowserAppServices({ config, plugins, externalPlugins }: A
27
28
  priority: 0,
28
29
  provider: { fetchNews: (query) => cloudNews?.provider.fetchNews(query) ?? Promise.resolve([]) },
29
30
  }));
30
- return pluginRegistry.events.on("host:portfolio-ticker-saved", () => recordResearchActivity("ticker_saved"));
31
+ // The page sends its own Gloom Cloud requests and holds its own stream: their health is this registry's to keep.
32
+ const disposeCloudSources = registerGloomCloudConnectionSources(pluginRegistry.connectionHealth);
33
+ const stopRecording = pluginRegistry.events.on("host:portfolio-ticker-saved", () => recordResearchActivity("ticker_saved"));
34
+ return () => {
35
+ stopRecording();
36
+ disposeCloudSources();
37
+ };
31
38
  },
32
39
  });
33
40
  }
@@ -28,7 +28,12 @@ export function browserCredentialedFetch(url: string, init: RequestInit = {}): P
28
28
  // carrying them into fetch would either fail or misrepresent the web origin.
29
29
  headers.delete("Cookie");
30
30
  headers.delete("Origin");
31
- return fetch(url, { ...init, headers, credentials: "include" });
31
+ // Reads skip the HTTP cache. Chromium lets only one request per URL use the
32
+ // cache at a time, so the same read from a second tab, or a second pane,
33
+ // waits for the first to finish and then goes to the network anyway: three
34
+ // tabs opened together waited seconds per request that way.
35
+ const read = (init.method ?? "GET").toUpperCase() === "GET" && init.cache === undefined;
36
+ return fetch(url, { ...init, headers, credentials: "include", ...(read ? { cache: "no-store" as const } : {}) });
32
37
  }
33
38
 
34
39
  function parseResponseHeaders(raw: string): Headers {
@@ -15,6 +15,23 @@ const LAYOUT_SHARE_PATH = /^\/l\/[a-f0-9]{32}\/?$/;
15
15
  const API_PATH = /^\/api(?:\/|$)/;
16
16
  const APPLE_APP_SITE_ASSOCIATION_PATH = "/.well-known/apple-app-site-association";
17
17
  const ROBOTS_PATH = "/robots.txt";
18
+ /**
19
+ * Files the web build names after their contents (`main-<hash>.js`, the launch
20
+ * frame, the bundled plugins: `withContentHash` in scripts/build-web.ts, the
21
+ * first 16 hex digits of a SHA-256). A name never serves other bytes, so a
22
+ * browser keeps them for a year without asking again; the bundle audit checks
23
+ * each such name against its file. Lazy chunks keep plain names and are
24
+ * revalidated as before.
25
+ */
26
+ export const IMMUTABLE_ASSET_PATH = /^\/assets\/.+-[a-f0-9]{16}\.(?:js|css)$/;
27
+ const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
28
+ /**
29
+ * The icons and the install manifest keep their names from build to build.
30
+ * The browser asked whether each had changed before the first paint of every
31
+ * open; a copy up to a day old does no harm.
32
+ */
33
+ const DAILY_ASSET_PATH = /^\/(?:favicon\.(?:ico|svg)|manifest\.webmanifest|app-icon-\d+\.png)$/;
34
+ const DAILY_CACHE_CONTROL = "public, max-age=86400";
18
35
 
19
36
  /**
20
37
  * Crawling stays allowed on purpose. Deep links are kept out of the index by
@@ -64,13 +81,17 @@ export const SECURITY_HEADERS = {
64
81
  "x-frame-options": "DENY",
65
82
  } as const;
66
83
 
67
- export function withSecurityHeaders(response: Response, options: { share?: boolean; noindex?: boolean } = {}): Response {
84
+ export function withSecurityHeaders(response: Response, options: { share?: boolean; noindex?: boolean; keep?: "immutable" | "daily" } = {}): Response {
68
85
  const headers = new Headers(response.headers);
69
86
  for (const [name, value] of Object.entries(SECURITY_HEADERS)) headers.set(name, value);
70
87
  const html = (headers.get("content-type") ?? "").includes("text/html");
71
88
  if (options.share) headers.set("x-robots-tag", "noindex, nofollow, noarchive");
72
89
  else if (options.noindex && html) headers.set("x-robots-tag", "noindex");
73
90
  if (html) headers.set("cache-control", "no-store");
91
+ // Only the file itself: a name the build no longer has falls back to the app's HTML, which stays no-store.
92
+ else if (options.keep && (response.ok || response.status === 304)) {
93
+ headers.set("cache-control", options.keep === "immutable" ? IMMUTABLE_CACHE_CONTROL : DAILY_CACHE_CONTROL);
94
+ }
74
95
  return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
75
96
  }
76
97
 
@@ -135,7 +156,8 @@ export async function handleRequest(request: Request, env: WorkerEnv, fetchApi:
135
156
  // `/?ticker=GPC&tab=executives` would be indexed as thin duplicates. Only the
136
157
  // bare root stays indexable.
137
158
  const deepLink = url.pathname !== "/" || url.search !== "";
138
- return withSecurityHeaders(await env.ASSETS.fetch(request), { noindex: deepLink });
159
+ const keep = IMMUTABLE_ASSET_PATH.test(url.pathname) ? "immutable" : DAILY_ASSET_PATH.test(url.pathname) ? "daily" : undefined;
160
+ return withSecurityHeaders(await env.ASSETS.fetch(request), { noindex: deepLink, keep });
139
161
  }
140
162
 
141
163
  export default {