@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
@@ -41,6 +41,7 @@ import {
41
41
  buildValuationChartPreset,
42
42
  } from "./presets";
43
43
  import { buildChartComposerPaneSettingsDef } from "./settings";
44
+ import { rebindResearchChartSpec } from "./chart-spec-edit";
44
45
  import type { PluginModule } from "../plugin-module";
45
46
  import {
46
47
  LIVE_STREAMING_QUICK_SETTING,
@@ -499,6 +500,17 @@ function chartShowsOneSecurity(pane: PaneInstanceConfig): boolean {
499
500
  return symbols.size === 1;
500
501
  }
501
502
 
503
+ /**
504
+ * Ticker search moves a chart of one security to another ticker: its series of that ticker move
505
+ * and keep their fields, as the research tab's chart does when its ticker changes.
506
+ */
507
+ function retargetChartTicker(pane: PaneInstanceConfig, symbol: string, previous: string | null): PaneInstanceConfig {
508
+ const spec = parseChartSpec(pane.settings?.[CHART_SPEC_SETTING_KEY]);
509
+ if (!spec) return pane;
510
+ const rebound = rebindResearchChartSpec(spec, previous, symbol);
511
+ return rebound === spec ? pane : { ...pane, settings: { ...pane.settings, [CHART_SPEC_SETTING_KEY]: rebound } };
512
+ }
513
+
502
514
  export const chartComposerModule: PluginModule = {
503
515
  // Every ticker field, asking for the ticker when charted.
504
516
  series: listFieldSeries(),
@@ -509,6 +521,7 @@ export const chartComposerModule: PluginModule = {
509
521
  component: ChartComposerPane,
510
522
  defaultPosition: "right",
511
523
  tickerFollower: chartShowsOneSecurity,
524
+ retargetTicker: retargetChartTicker,
512
525
  defaultMode: "floating",
513
526
  defaultFloatingSize: { width: 100, height: 32 },
514
527
  portableShare: { prepare: prepareChartPaneForShare },
@@ -353,12 +353,18 @@ export class ChatController {
353
353
  }
354
354
 
355
355
  /** Single-flight: every open chat pane calls this on mount. */
356
- async refreshSession(): Promise<void> {
356
+ /**
357
+ * Reads the signed-in user again. `reuseCheckWithinMs` accepts a session
358
+ * check the app made that recently instead: the web app checks its session
359
+ * before the first paint, and the status bar opening right after has
360
+ * nothing new to learn from a second request.
361
+ */
362
+ async refreshSession(options: { reuseCheckWithinMs?: number } = {}): Promise<void> {
357
363
  if (this.sessionRefreshPromise) return this.sessionRefreshPromise;
358
364
  this.realtime.stopSessionRetry();
359
365
  const generation = this.sessionRefreshGeneration;
360
366
  const isCurrent = () => generation === this.sessionRefreshGeneration;
361
- const request = this.runSessionRefresh(isCurrent)
367
+ const request = this.runSessionRefresh(isCurrent, options.reuseCheckWithinMs)
362
368
  .catch((error) => {
363
369
  if (isCurrent()) this.realtime.scheduleSessionRetry();
364
370
  throw error;
@@ -379,9 +385,10 @@ export class ChatController {
379
385
  this.sessionRefreshPromise = null;
380
386
  }
381
387
 
382
- private async runSessionRefresh(isCurrent: () => boolean): Promise<void> {
388
+ private async runSessionRefresh(isCurrent: () => boolean, reuseCheckWithinMs?: number): Promise<void> {
383
389
  return refreshChatControllerSession({
384
390
  isCurrent,
391
+ reuseCheckWithinMs,
385
392
  applySignedOut: () => this.applySignedOutSession(),
386
393
  channelStates: this.storage.channelStates,
387
394
  emit: () => this.emit(),
@@ -49,7 +49,10 @@ export function hydrateChatControllerSession({
49
49
  const storedSession = storage.readSessionState();
50
50
  const restoredUser = apiClient.getCurrentUser() ?? storedSession?.user ?? null;
51
51
  session.sessionToken = storedSession?.sessionToken ?? null;
52
- apiClient.setSessionToken(session.sessionToken);
52
+ // Installing the credential already in place would discard its session
53
+ // check: the web app, which signs in with a cookie and stores no token,
54
+ // asked the server for its session a second time on every open.
55
+ if (apiClient.getSessionToken() !== session.sessionToken) apiClient.setSessionToken(session.sessionToken);
53
56
  // WebSocket tokens are short-lived connection credentials. Reusing a persisted
54
57
  // one can trap reconnects on an expired token even while the session cookie is valid.
55
58
  apiClient.setWebSocketToken(null);
@@ -88,6 +91,8 @@ export function applySignedOutChatControllerSession({
88
91
 
89
92
  interface RefreshChatControllerSessionOptions {
90
93
  isCurrent: () => boolean;
94
+ /** Use a session check the app made within this many milliseconds instead of asking again. */
95
+ reuseCheckWithinMs?: number;
91
96
  applySignedOut: () => void;
92
97
  channelStates: Map<string, ChannelRuntimeState>;
93
98
  emit: () => void;
@@ -106,6 +111,7 @@ interface RefreshChatControllerSessionOptions {
106
111
 
107
112
  export async function refreshChatControllerSession({
108
113
  isCurrent,
114
+ reuseCheckWithinMs,
109
115
  applySignedOut,
110
116
  channelStates,
111
117
  emit,
@@ -122,7 +128,8 @@ export async function refreshChatControllerSession({
122
128
  syncVerificationPolling,
123
129
  }: RefreshChatControllerSessionOptions): Promise<void> {
124
130
  const cachedToken = session.sessionToken;
125
- const apiSession = await apiClient.getSession(isCurrent);
131
+ const recent = reuseCheckWithinMs === undefined ? undefined : apiClient.recentSession(reuseCheckWithinMs);
132
+ const apiSession = recent ? recent.user : await apiClient.getSession(isCurrent);
126
133
  if (!isCurrent()) return;
127
134
  if (!apiSession) {
128
135
  const persistedToken = apiClient.getSessionToken();
@@ -34,6 +34,8 @@ const CHIP_NAME_COLUMNS = 12;
34
34
  /** The message on arrival never takes more columns than this, and does not show in fewer than the least. */
35
35
  const PREVIEW_MOST_COLUMNS = 48;
36
36
  const PREVIEW_LEAST_COLUMNS = 12;
37
+ /** A session the app checked this recently (the web app does before its first paint) is not asked for again on mount. */
38
+ const RECENT_SESSION_CHECK_MS = 30_000;
37
39
 
38
40
  /** Who the chip names: the sender of the newest message for you, and whether it came in a DM or group chat. */
39
41
  interface ChipWho {
@@ -183,7 +185,7 @@ export function ChatStatusWidget({ controller = chatController }: ChatStatusWidg
183
185
  setUsername(nextSnapshot.user?.username ?? null);
184
186
  setHasSavedSession(nextSnapshot.hasSavedSession);
185
187
  });
186
- void controller.refreshSession().catch(() => {});
188
+ void controller.refreshSession({ reuseCheckWithinMs: RECENT_SESSION_CHECK_MS }).catch(() => {});
187
189
  return unsubscribe;
188
190
  }, [controller]);
189
191
 
@@ -49,6 +49,7 @@ import {
49
49
  } from "./model";
50
50
  import { useAutoRefresh } from "../../../react/auto-refresh";
51
51
  import { usePaneStatusLinkFooter } from "../../../components/layout/pane/status-footer";
52
+ import { logFailure } from "../../../utils/log-failure";
52
53
 
53
54
  function isAuthError(error: string | null): boolean {
54
55
  return !!error && /unauthorized|verification/i.test(error);
@@ -301,7 +302,7 @@ function useTweetSearchData(
301
302
  });
302
303
  })
303
304
  // The tweets on screen are still the answer; the next cycle tries again.
304
- .catch(() => {});
305
+ .catch(logFailure("cloud-tweets.table", "Refresh latest tweets failed"));
305
306
  }, [enabled, load, requestKey]);
306
307
  const fetchedAt = state.data ? cachedTweetResult(requestKey)?.fetchedAt ?? null : null;
307
308
  useAutoRefresh(fetchedAt, refreshLatest, { intervalMs: TWEET_REFRESH_MS });
@@ -378,7 +379,7 @@ export function TweetSearchTable({
378
379
  content: (ctx: PromptContext<string>) => (
379
380
  <ChoiceDialog {...ctx} title="Open from this tweet" choices={selectedLinks.map(tweetLinkChoice)} />
380
381
  ),
381
- }).catch(() => undefined);
382
+ }).catch(logFailure("cloud-tweets.table", "Open tweet links prompt failed"));
382
383
  const link = choice === undefined ? undefined : selectedLinks[Number(choice)];
383
384
  if (!link) return;
384
385
  if (link.kind === "ticker") openTicker(link.symbol);
@@ -9,6 +9,7 @@ import type {
9
9
  CommentLetterIssuer,
10
10
  CommentLetterPage,
11
11
  } from "./types";
12
+ import { logFailure } from "../../../utils/log-failure";
12
13
 
13
14
  const EFTS_URL = "https://efts.sec.gov/LATEST/search-index";
14
15
  const FETCH_TIMEOUT_MS = 15_000;
@@ -324,7 +325,7 @@ export function createCommentLettersLoader(
324
325
  }
325
326
  const company = issuer ? await issuer : null;
326
327
  if (company && offset === 0) {
327
- const listed = await loadIssuerFilings(company.ticker, force).catch(() => null);
328
+ const listed = await loadIssuerFilings(company.ticker, force).catch(logFailure("comment-letters.client", "Load issuer filings for comment letters failed", null));
328
329
  issuerFromCloud = !!listed?.complete;
329
330
  if (listed?.complete) {
330
331
  const rows = listed.filings
@@ -31,7 +31,7 @@ function validPeriod(period: KpiPeriod): boolean {
31
31
  }
32
32
  function validEvidence(evidence: KpiEvidence): boolean {
33
33
  let safeUrl = false;
34
- try { safeUrl = ["https:", "http:"].includes(new URL(evidence.url).protocol); } catch { /* Invalid evidence cannot be opened. */ }
34
+ try { safeUrl = ["https:", "http:"].includes(new URL(evidence.url).protocol); } catch { /* Intentional ignore: evidence without a web link cannot be opened, so it fails validation. */ }
35
35
  return !!evidence && text(evidence.id) && text(evidence.documentId) && text(evidence.sourceId)
36
36
  && sourceKinds.includes(evidence.sourceKind) && safeUrl && text(evidence.title) && instant(evidence.publishedAt)
37
37
  && text(evidence.country) && text(evidence.language) && text(evidence.quote) && evidence.quote.trim().length > 0
@@ -27,6 +27,7 @@ import { allGuidance, allObservations, basisLabel, changeText, changeTone, compa
27
27
  import { PriceSparkline } from "../../../components/price-sparkline/view";
28
28
  import type { PricePoint } from "../../../types/financials";
29
29
  import { toneColor, withoutQuietColumns } from "../shared/research-cells";
30
+ import { logFailure } from "../../../utils/log-failure";
30
31
 
31
32
  /** A locked placeholder, or with `note` the line above them saying what free shows and what Pro adds. */
32
33
  type Item = { id: string; row: CompanyRow } | { id: string; row: null; note?: string };
@@ -92,7 +93,7 @@ function CompanyView({ symbol, exchange, name, mode, width, height, focused }: P
92
93
  const accessKey = `${session.requestKey}:${access.hasProAccess ? "full" : "preview"}`;
93
94
  const openUpgrade = useCloudUpgradeAction(mode === "kpis" ? "kpis" : "guide");
94
95
  const [snapshotSetting] = usePaneSettingValue<CompanyDataset | null>("companySnapshot", null);
95
- const snapshot = useMemo(() => { try { return snapshotSetting ? validateCompanyData(snapshotSetting) : null; } catch { return null; } }, [snapshotSetting]);
96
+ const snapshot = useMemo(() => { try { return snapshotSetting ? validateCompanyData(snapshotSetting) : null; } catch (error) { return logFailure("company-kpis.pane", "Validate company disclosures snapshot failed", null)(error); } }, [snapshotSetting]);
96
97
  const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null })
97
98
  : loadCompanyData(mode, symbol!, accessKey, force, { exchange, name }), [mode, symbol, exchange, name, accessKey, snapshot]);
98
99
  const resource = useAsyncResource(symbol ? loader : null, { initialData: () => symbol ? cachedCompanyData(mode, symbol, accessKey, { exchange, name }) : null, clearOnError: isAccessDenied });
@@ -6,6 +6,7 @@ import { isRecord } from "../../../utils/guards";
6
6
  import { resolveIssuerListing } from "../shared/headless-market-data";
7
7
  import { companyQuery, fetchCompanyData, validateCompanyData, type CompanyDataset, type CompanyMode } from "./client";
8
8
  import { allGuidance, allObservations } from "./model";
9
+ import { logFailure } from "../../../utils/log-failure";
9
10
 
10
11
  interface Evidence { kind: "company-disclosures"; version: 1; complete: boolean; plottedValueCount: number; payload: CompanyDataset; mode: CompanyMode; tab: string; rowIds: string[]; }
11
12
  export function useCompanyEvidence(payload: CompanyDataset | null, mode: CompanyMode, tab: string, rowIds: string[]) {
@@ -20,7 +21,7 @@ function screenshotEvidence(mode: CompanyMode): PaneScreenshotEvidenceHook<Evide
20
21
  const symbol = resolved.createOptions?.symbol ?? resolved.createOptions?.arg;
21
22
  if (!symbol) throw new Error("A company disclosure screenshot requires a ticker");
22
23
  // A bare symbol takes the saved listing's venue, as the pane does.
23
- const saved = parsePublicTickerKey(symbol).exchange ? null : await context.store.loadTicker(symbol).catch(() => null);
24
+ const saved = parsePublicTickerKey(symbol).exchange ? null : await context.store.loadTicker(symbol).catch(logFailure("company-kpis.screenshot-evidence", "Load saved ticker for disclosure capture failed", null));
24
25
  const listing = await resolveIssuerListing(symbol, saved?.metadata.exchange, context.dataProvider);
25
26
  const payload = await fetchCompanyData(mode, symbol, companyQuery(resolved.options), apiClient, listing);
26
27
  // Keyed by the requested ticker: a listing abroad is answered under its bare symbol.
@@ -34,7 +35,7 @@ function screenshotEvidence(mode: CompanyMode): PaneScreenshotEvidenceHook<Evide
34
35
  const rows = "series" in payload ? allObservations(payload) : allGuidance(payload);
35
36
  if (value.plottedValueCount !== value.rowIds.length || value.rowIds.some((id) => !rows.some((row) => row.id === id))) return null;
36
37
  return value as unknown as Evidence;
37
- } catch { return null; }
38
+ } catch { /* Intentional ignore: invalid captured observations are rejected as evidence by returning null. */ return null; }
38
39
  },
39
40
  mismatches(evidence, { resolved, payload }) {
40
41
  const snapshot = payload.config.layout.instances.find((entry) => entry.instanceId === payload.paneId)?.settings?.companySnapshot;
@@ -1,7 +1,7 @@
1
1
  import type { CotClass, CotClassSummary, CotContractPayload, CotHistoryPoint } from "../../../api-client/cot";
2
2
  import type { HeadlessPaneColumn, HeadlessPaneDefinition } from "../../../types/plugin";
3
3
  import { fetchCotBoard, fetchCotContract } from "./client";
4
- import { COT_CLASSES, COT_FAMILIES, COT_MAJOR_CODES, COT_POSITIONS, COT_SCOPES, cotClass, cotContractCode, cotContractUnitText, cotFamily, cotInteger, cotMarketName, cotPositions, cotPositionsText, cotProxyFor, cotProxyNote, cotScope, cotUnknownMarketMessage } from "./model";
4
+ import { COT_CLASSES, COT_FAMILIES, COT_MAJOR_CODES, COT_POSITIONS, COT_SCOPES, cotClass, cotContractCode, cotContractUnitText, cotFamily, cotInteger, cotMarketName, cotPositions, cotPositionsText, cotProxyFor, cotProxyNote, cotReleaseTime, cotScope, cotUnknownMarketMessage } from "./model";
5
5
  import { COMMODITIES_VIEW_STATE } from "../commodities-energy/view-state";
6
6
  import { REPORT_ROWS } from "../shared/headless-options";
7
7
 
@@ -12,6 +12,12 @@ const signed = (value: unknown) => cotInteger(typeof value === "number" ? value
12
12
  const percent = (value: unknown) => typeof value === "number" ? `${value > 0 ? "+" : ""}${value.toFixed(1)}%` : "--";
13
13
  const rank = (value: unknown) => typeof value === "number" ? value.toFixed(0) : "--";
14
14
 
15
+ /** The report's release, by the CFTC's schedule, for an export's publication time; nothing outside the schedule. */
16
+ function cotReleased(asOf: string | null) {
17
+ const publishedAt = cotReleaseTime(asOf);
18
+ return publishedAt ? { freshness: { publishedAt } } : {};
19
+ }
20
+
15
21
  /** The pane's columns: percentiles as their rank value, net share of open interest to one decimal. */
16
22
  function cotPositionRow(row: CotClassSummary) {
17
23
  return { long: row.long, short: row.short, spreading: row.spreading, net: row.net,
@@ -83,7 +89,7 @@ export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
83
89
  ...Object.fromEntries(row.positions.map((position) => [`${camelClass(position.id)}Net`, position.net])) })) }],
84
90
  // "jet fuel" reads heating oil's positions, and says so.
85
91
  ...(proxy ? { notes: [cotProxyNote(proxy)] } : {}),
86
- errors: data.gaps, metadata: { ...data, complete: data.status === "available" } };
92
+ errors: data.gaps, metadata: { ...data, complete: data.status === "available" }, ...cotReleased(data.asOf) };
87
93
  }
88
94
  const traderClass = cotClass(family, args.options.traderClass);
89
95
  if (args.options.traderClass && traderClass !== args.options.traderClass) throw new Error("Trader class does not belong to this report family");
@@ -94,6 +100,6 @@ export const cotHeadless: HeadlessPaneDefinition<"bundle"> = {
94
100
  columns: [{ key: "marketName", header: "Market" }, { key: "contractCode", header: "Code" }, ...POSITION_COLUMNS,
95
101
  { key: "openInterest", header: "Open interest", align: "right", format: count }, { key: "reportDate", header: "As of" }],
96
102
  rows: rows.map((row) => ({ contractCode: row.contractCode, marketName: cotMarketName(row.marketName), reportDate: row.reportDate, openInterest: row.openInterest, ...cotPositionRow(row.position) })) }],
97
- errors: data.gaps, metadata: { ...data, scope, complete: data.status === "available" } };
103
+ errors: data.gaps, metadata: { ...data, scope, complete: data.status === "available" }, ...cotReleased(data.asOf) };
98
104
  },
99
105
  };
@@ -6,6 +6,7 @@ import { formatMarketPriceWithCurrency, formatPriceObservation } from "../../../
6
6
  import { futuresPricePer } from "../../../market-data/futures-contract";
7
7
  import { unitCurrencyToken } from "../../../time-series/price-units";
8
8
  import { cleanFloat32Price } from "../../../cli/history-rows";
9
+ import { zonedWallClockToUtcMs } from "../../../utils/zoned-date-time";
9
10
  import { cryptoPairCoin, isFuturesSymbol } from "../shared/crypto-pair";
10
11
  import {
11
12
  bestNameMatch, FUTURES_CONTRACTS, futuresBoardContract, futuresBoardContractForTicker, futuresContractByCode, futuresContractByName, type FuturesContract,
@@ -139,6 +140,14 @@ export type CotScope = typeof COT_SCOPES[number]["value"];
139
140
  export function cotScope(value: unknown): CotScope { return value === "all" ? "all" : "major"; }
140
141
 
141
142
  const rootAlias = (input: string) => ROOTS[input === "VIX" ? "VX" : input]?.code ?? null;
143
+ /** The CME currency futures by their currency's ISO code, as a reader of FX types them: JPY is 6J, the yen. */
144
+ const CURRENCY_FUTURES: Readonly<Record<string, string>> = {
145
+ EUR: "6E=F", JPY: "6J=F", GBP: "6B=F", CAD: "6C=F", AUD: "6A=F", CHF: "6S=F", MXN: "6M=F",
146
+ };
147
+ const currencyFuture = (input: string) => {
148
+ const symbol = CURRENCY_FUTURES[input];
149
+ return symbol ? Object.entries(PRICE_OVERLAYS).find(([, row]) => row.priceSymbol === symbol)?.[0] ?? null : null;
150
+ };
142
151
  const marketCode = (input: string) => /^[0-9A-Z]{5}[0-9A-Z+]$/.test(input) ? input : null;
143
152
  /**
144
153
  * The FUT board row a typed argument names, by code, symbol or commodity name
@@ -154,7 +163,8 @@ function typedMarket(value: string): { board: FuturesContract } | { root: string
154
163
  /**
155
164
  * A CFTC code, root or commodity name typed as an argument or stored in a
156
165
  * pane: every alias, crypto included, every FUT board root the CFTC reports,
157
- * and the names FUT finds them by (cocoa, coffee, sugar, gold, crude). A typed
166
+ * the names FUT finds them by (cocoa, coffee, sugar, gold, crude), and a
167
+ * currency's ISO code for its CME future (JPY, CHF, EUR). A typed
158
168
  * root is always the future, so ZM here is soybean meal, never Zoom. A CFTC
159
169
  * code is tried after the names, as one could be spelled with six letters
160
170
  * (COFFEE, COPPER).
@@ -162,7 +172,7 @@ function typedMarket(value: string): { board: FuturesContract } | { root: string
162
172
  export function cotContractCode(value: unknown): string | null {
163
173
  if (typeof value !== "string") return null;
164
174
  const input = value.trim().toUpperCase().replace(/=F$/, "");
165
- const alias = rootAlias(input);
175
+ const alias = rootAlias(input) ?? currencyFuture(input);
166
176
  if (alias) return alias;
167
177
  const market = typedMarket(value);
168
178
  if (market && "root" in market) return ROOTS[market.root]!.code;
@@ -199,7 +209,7 @@ export function cotProxyNote(proxy: { subject: string; root: string }): string {
199
209
  /** The markets the unknown-market hint names, by the code and the word a newcomer knows them by. */
200
210
  const SUGGESTED_MARKETS: ReadonlyArray<readonly [string, string]> = [
201
211
  ["ES", "S&P 500"], ["CL", "crude oil"], ["NG", "natural gas"], ["GC", "gold"], ["HG", "copper"],
202
- ["ZC", "corn"], ["CC", "cocoa"], ["KC", "coffee"], ["SB", "sugar"], ["ZN", "10-year note"],
212
+ ["ZC", "corn"], ["CC", "cocoa"], ["KC", "coffee"], ["SB", "sugar"], ["ZN", "10-year note"], ["JPY", "yen"],
203
213
  ];
204
214
  /**
205
215
  * What a market `cotContractCode` does not know is told: a FUT board row the
@@ -230,6 +240,37 @@ export function cotContractCodeForTicker(ticker: unknown): string | null {
230
240
  const board = futuresBoardContractForTicker(ticker);
231
241
  return rootAlias(input) ?? (board ? boardMarketCode(board) : null) ?? marketCode(input);
232
242
  }
243
+ /**
244
+ * The CFTC's published release schedule (cftc.gov, Commitments of Traders,
245
+ * Release Schedule, read 2026-11-01): 3:30 p.m. Eastern on the Friday after
246
+ * the Tuesday the positions are as of, or the day a federal holiday moved that
247
+ * Friday's release to. Years it has not published, and 2027 with its move to
248
+ * two releases a week, are left out rather than guessed.
249
+ */
250
+ const COT_SCHEDULED_YEARS: ReadonlySet<number> = new Set([2026]);
251
+ const COT_DELAYED_RELEASES: Readonly<Record<string, string>> = {
252
+ "2026-01-02": "2026-01-05", "2026-06-19": "2026-06-22", "2026-07-03": "2026-07-06",
253
+ "2026-11-13": "2026-11-16", "2026-11-27": "2026-11-30", "2026-12-25": "2026-12-28",
254
+ };
255
+ const DAY_MS = 86_400_000;
256
+ /**
257
+ * When the CFTC released the report of positions as of `reportDate`, an ISO
258
+ * instant, by its schedule (`COT_SCHEDULED_YEARS`). Null for a date that is
259
+ * no Tuesday or a release outside the schedule, which an export then says was
260
+ * not published.
261
+ */
262
+ export function cotReleaseTime(reportDate: string | null | undefined): string | null {
263
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(reportDate ?? "");
264
+ if (!match) return null;
265
+ const tuesday = Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
266
+ if (new Date(tuesday).getUTCDay() !== 2) return null;
267
+ const friday = new Date(tuesday + 3 * DAY_MS).toISOString().slice(0, 10);
268
+ const day = COT_DELAYED_RELEASES[friday] ?? friday;
269
+ const [year, month, date] = day.split("-").map(Number) as [number, number, number];
270
+ if (!COT_SCHEDULED_YEARS.has(year)) return null;
271
+ return new Date(zonedWallClockToUtcMs("America/New_York", year, month, date, 15, 30, 0)).toISOString();
272
+ }
273
+
233
274
  /** The futures root a CFTC code belongs to, for titles readers recognize: a verified alias, else its FUT board root. */
234
275
  export function cotRoot(code: string): string | null {
235
276
  return Object.entries(ROOTS).find(([, row]) => row.code === code)?.[0]
@@ -22,7 +22,7 @@ const currency = (value: unknown) => value === null || (text(value) && /^[A-Z]{3
22
22
  const day = (value: unknown): value is string => text(value) && /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
23
23
  const nullableDay = (value: unknown) => value === null || day(value);
24
24
  const strings = (value: unknown): value is string[] => Array.isArray(value) && value.every(text);
25
- const url = (value: unknown) => { try { return text(value) && ["https:", "http:"].includes(new URL(value).protocol); } catch { return false; } };
25
+ const url = (value: unknown) => { try { return text(value) && ["https:", "http:"].includes(new URL(value).protocol); } catch { /* Intentional ignore: malformed URLs fail this web link field validator. */ return false; } };
26
26
  const unique = (rows: readonly { id: string }[]) => new Set(rows.map((row) => row.id)).size === rows.length;
27
27
  function fact(row: CreditFact): boolean {
28
28
  return !!row && [row.id, row.instrumentId, row.documentId, row.field, row.instrumentName, row.factKey, row.form, row.language].every(text)
@@ -45,7 +45,7 @@ export const creditScreenshotEvidence: PaneScreenshotEvidenceHook<CreditEvidence
45
45
  const eligible = new Set(value.tab === "capital" ? payload.instruments.map((row) => row.id) : value.tab === "covenants" ? payload.covenants.map((row) => row.id) : value.tab === "screen" ? (screen?.rows ?? []).map(screenRowId) : payload.maturities.flatMap((row) => row.instruments.map((instrument) => `${row.year}:${instrument.id}`)));
46
46
  if (new Set(value.rowIds).size !== value.rowIds.length || value.rowIds.some((id) => !eligible.has(id as string))) return null;
47
47
  return value as unknown as CreditEvidence;
48
- } catch { return null; }
48
+ } catch { /* Intentional ignore: invalid captured observations are rejected as evidence by returning null. */ return null; }
49
49
  },
50
50
  mismatches(evidence, { resolved, payload }) {
51
51
  const settings = payload.config.layout.instances.find((entry) => entry.instanceId === payload.paneId)?.settings;
@@ -20,6 +20,7 @@ import { CreditInstrumentDetail } from "./detail";
20
20
  import { useCreditEvidence } from "./evidence";
21
21
  import { HeadroomGauge } from "./gauge";
22
22
  import { capitalCell, capitalColumns, capitalFigures, comparatorSymbol, covenantColumns, covenantFact, covenantReason, covenantUsage, CREDIT_EMPTY_TITLE, creditEmptyCause, CREDIT_TABS, creditAmount, covenantNumber, creditCurrencies, creditMaturityRows, creditPercent, creditTab, fieldLabel, headroomTone, instrumentOutstanding, isClosed, maturityAxis, maturityColumns, maturitySeries, maturityShares, NO_VALUE, screenColumns, screenRowId, screenSignal, sentence } from "./model";
23
+ import { logFailure } from "../../../utils/log-failure";
23
24
 
24
25
  type Row = { numbers?: Record<string, number | null>; id: string; values: Record<string, string>; instrumentId?: string; covenant?: CreditHeadroom; screen?: CreditScreenRow; year?: number; locked?: boolean; closed?: boolean };
25
26
  const rowId = (row: Row) => row.id;
@@ -54,7 +55,7 @@ function CreditView({ symbol, width, height, focused, accessKey, needsVerificati
54
55
  const [snapshotSetting] = usePaneSettingValue<CreditDocumentsPayload | null>("creditSnapshot", null);
55
56
  const [screenSnapshot] = usePaneSettingValue<CreditScreenPayload | null>("creditScreenSnapshot", null);
56
57
  const [instrumentSnapshot] = usePaneSettingValue<CreditInstrument | null>("creditInstrumentSnapshot", null);
57
- const snapshot = useMemo(() => { try { return snapshotSetting ? validateCreditDocuments(snapshotSetting, symbol ? creditIssuerSymbol(symbol) : undefined) : null; } catch { return null; } }, [snapshotSetting, symbol]);
58
+ const snapshot = useMemo(() => { try { return snapshotSetting ? validateCreditDocuments(snapshotSetting, symbol ? creditIssuerSymbol(symbol) : undefined) : null; } catch (error) { return logFailure("credit-documents.pane", "Validate credit documents snapshot failed", null)(error); } }, [snapshotSetting, symbol]);
58
59
  const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadCredit(symbol!, accessKey, force), [symbol, accessKey, snapshot]);
59
60
  const resource = useAsyncResource(symbol ? loader : null, { initialData: () => symbol ? cachedCredit(symbol, accessKey) : null, clearOnError: isAccessDenied });
60
61
  const data = resource.data?.payload ?? null;
@@ -647,7 +647,7 @@ function CallsListView({
647
647
  // which is a deliberate act reserved for Enter.
648
648
  const prefetchTranscript = useCallback((call: CloudEarningsCallPayload) => {
649
649
  if (!call.hasTranscript || !access.emailVerified || !access.hasProAccess) return;
650
- void loadTranscript(call.id).catch(() => {});
650
+ void loadTranscript(call.id).catch(() => { /* Intentional ignore: a warm-up that fails is loaded again, and its failure shown, when the call opens. */ });
651
651
  }, [access.emailVerified, access.hasProAccess]);
652
652
 
653
653
  // A published transcript is immutable, so it loads once per call. Opening
@@ -2,8 +2,13 @@ import type { PluginModule } from "../plugin-module";
2
2
  import { formatTickerListInput, parseTickerListInput } from "../../../tickers/list";
3
3
  import { earningsRippleHeadless } from "./headless";
4
4
 
5
+ /**
6
+ * The tickers a typed argument names. A list the command bar refuses (more than
7
+ * ten) throws its message rather than opening the pane on the person's holdings.
8
+ * `fn` and `shot` pass their own list as `symbols` and never get here.
9
+ */
5
10
  function namedSymbols(arg: string | undefined): string[] {
6
- try { return arg?.trim() ? parseTickerListInput(arg) : []; } catch { return []; }
11
+ return arg?.trim() ? parseTickerListInput(arg) : [];
7
12
  }
8
13
 
9
14
  export const earningsRippleModule: PluginModule = {
@@ -320,6 +320,7 @@ function isCountryCode(code: string): boolean {
320
320
  try {
321
321
  regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
322
322
  } catch {
323
+ // Intentional ignore: a runtime without region names accepts any two-letter code instead.
323
324
  regionNames = null;
324
325
  }
325
326
  }
@@ -328,6 +329,7 @@ function isCountryCode(code: string): boolean {
328
329
  // ZZ is CLDR's "Unknown Region".
329
330
  return code !== "ZZ" && regionNames.of(code) !== undefined;
330
331
  } catch {
332
+ // Intentional ignore: a code the runtime's region names reject is no country code.
331
333
  return false;
332
334
  }
333
335
  }
@@ -141,18 +141,18 @@ const GROUPS: ReadonlyArray<{ group: string; rows: readonly FredRow[] }> = [
141
141
  {
142
142
  group: "FX",
143
143
  rows: [
144
- ["DEXUSEU", "Euro (USD per EUR)", "USD", "daily", ["EURUSD", "EUR"]],
145
- ["DEXUSUK", "British pound (USD per GBP)", "USD", "daily", ["GBPUSD", "GBP", "sterling"]],
144
+ ["DEXUSEU", "Euro (USD per EUR)", "USD", "daily", ["EURUSD", "EUR", "euro"]],
145
+ ["DEXUSUK", "British pound (USD per GBP)", "USD", "daily", ["GBPUSD", "GBP", "sterling", "pound"]],
146
146
  ["DEXUSAL", "Australian dollar (USD per AUD)", "USD", "daily", ["AUDUSD", "AUD"]],
147
147
  ["DEXUSNZ", "New Zealand dollar (USD per NZD)", "USD", "daily", ["NZDUSD", "NZD"]],
148
- ["DEXJPUS", "Japanese yen (JPY per USD)", "JPY", "daily", ["USDJPY", "JPY"]],
149
- ["DEXCHUS", "Chinese yuan (CNY per USD)", "CNY", "daily", ["USDCNY", "CNY", "renminbi"]],
148
+ ["DEXJPUS", "Japanese yen (JPY per USD)", "JPY", "daily", ["USDJPY", "JPY", "yen"]],
149
+ ["DEXCHUS", "Chinese yuan (CNY per USD)", "CNY", "daily", ["USDCNY", "CNY", "renminbi", "yuan"]],
150
150
  ["DEXINUS", "Indian rupee (INR per USD)", "INR", "daily", ["USDINR", "INR"]],
151
151
  ["DEXBZUS", "Brazilian real (BRL per USD)", "BRL", "daily", ["USDBRL", "BRL"]],
152
152
  ["DEXMXUS", "Mexican peso (MXN per USD)", "MXN", "daily", ["USDMXN", "MXN"]],
153
153
  ["DEXKOUS", "South Korean won (KRW per USD)", "KRW", "daily", ["USDKRW", "KRW"]],
154
154
  ["DEXCAUS", "Canadian dollar (CAD per USD)", "CAD", "daily", ["USDCAD", "CAD"]],
155
- ["DEXSZUS", "Swiss franc (CHF per USD)", "CHF", "daily", ["USDCHF", "CHF"]],
155
+ ["DEXSZUS", "Swiss franc (CHF per USD)", "CHF", "daily", ["USDCHF", "CHF", "franc", "swiss franc"]],
156
156
  ["DEXTAUS", "Taiwan dollar (TWD per USD)", "TWD", "daily", ["USDTWD", "TWD"]],
157
157
  ["DEXHKUS", "Hong Kong dollar (HKD per USD)", "HKD", "daily", ["USDHKD", "HKD"]],
158
158
  ["DEXSIUS", "Singapore dollar (SGD per USD)", "SGD", "daily", ["USDSGD", "SGD"]],
@@ -11,6 +11,7 @@ import {
11
11
  type EconCalendarCacheEntry,
12
12
  } from "./calendar-model";
13
13
  import type { EconEvent } from "./types";
14
+ import { logFailure } from "../../../utils/log-failure";
14
15
 
15
16
  /** The ECO setting that turns the print toast on. Off until the user turns it on, as breaking news is. */
16
17
  export const ECON_PRINT_NOTIFICATIONS_ENABLED_KEY = "econPrintNotificationsEnabled";
@@ -172,8 +173,9 @@ export function startHighImpactPrintWatch(
172
173
  try {
173
174
  // A due print is asked for past the cache; otherwise a fresh cache answers without a request.
174
175
  observe(await deps.load(due), before);
175
- } catch {
176
+ } catch (error) {
176
177
  // The next ask follows the same schedule.
178
+ logFailure("econ.print-watch", "Load calendar for print watch failed")(error);
177
179
  } finally {
178
180
  running = false;
179
181
  }
@@ -22,6 +22,21 @@ function futuresSeriesUnit(contract: FuturesContract): string {
22
22
  return "USD";
23
23
  }
24
24
 
25
+ /**
26
+ * Words a contract is looked for by that its name does not hold: a currency
27
+ * future by its currency's code and name (`yen`, `JPY` for 6J), and the safe
28
+ * havens, gold, the yen and the franc.
29
+ */
30
+ const CONTRACT_TAGS: Readonly<Record<string, readonly string[]>> = {
31
+ GC: ["safe haven"],
32
+ "6E": ["EUR", "euro"],
33
+ "6J": ["JPY", "yen", "safe haven"],
34
+ "6B": ["GBP", "pound", "sterling"],
35
+ "6A": ["AUD", "aussie"],
36
+ "6C": ["CAD", "loonie"],
37
+ "6S": ["CHF", "franc", "swiss franc", "safe haven"],
38
+ };
39
+
25
40
  /** Each continuous front-month contract on the futures board, as `FUT:ES`. */
26
41
  const FRONT_MONTH_SERIES: readonly SeriesDefinition[] = FUTURES_CONTRACTS.map((contract) => ({
27
42
  id: `fut:${contract.code}`,
@@ -29,7 +44,7 @@ const FRONT_MONTH_SERIES: readonly SeriesDefinition[] = FUTURES_CONTRACTS.map((c
29
44
  unit: futuresSeriesUnit(contract),
30
45
  frequency: "daily",
31
46
  group: "Futures",
32
- tags: [contract.code, FUTURES_SECTOR_LABELS[contract.sector], "futures", "front month"],
47
+ tags: [contract.code, FUTURES_SECTOR_LABELS[contract.sector], "futures", "front month", ...CONTRACT_TAGS[contract.code] ?? []],
33
48
  expression: `FUT:${contract.code}`,
34
49
  }));
35
50
 
@@ -7,7 +7,7 @@ import { servedFromSavedCopy } from "../../../data/saved-copies";
7
7
  import { fxPairObservation, fxRateObservations } from "../shared/fx-rate-freshness";
8
8
  import { loadFxBoard, type FxLegReading } from "./client";
9
9
  import { crossMovePercent } from "./direction";
10
- import { formatRate, resolveCurrencies, type FxCurrency } from "./pairs";
10
+ import { FX_CURRENCY_KEYWORDS, formatRate, resolveCurrencies, type FxCurrency } from "./pairs";
11
11
  import { FX_MATRIX_REPORT_OPTIONS, fxMatrixReportNotices } from "./settings";
12
12
 
13
13
  const iso = (time: number | null | undefined) => time != null && Number.isFinite(time) ? new Date(time).toISOString() : null;
@@ -143,7 +143,9 @@ export const fxMatrixHeadless: HeadlessPaneDefinition<"rows"> = {
143
143
  freshness: { source: "Gloom Cloud" },
144
144
  describe: (args) => `FX Cross Rates | ${resolveCurrencies(args.options.currencies).join(" ")}`,
145
145
  discovery: {
146
- intents: ["fx", "forex", "currency", "cross rates", "exchange rates"],
146
+ // A currency's code or name finds the board (`catalog yen`, `catalog chf`), and so do the safe havens it
147
+ // carries, the yen and the franc. Searched, never listed: the catalog's Keywords line stays short.
148
+ intents: ["fx", "forex", "currency", "cross rates", "exchange rates", "safe haven", ...FX_CURRENCY_KEYWORDS],
147
149
  limitations: ["Indicative crosses through USD legs, whose observation times can differ."],
148
150
  screenshotReadiness: "live-dom",
149
151
  },
@@ -9,6 +9,8 @@ import {
9
9
  type PaneFooterSegment,
10
10
  } from "../../../components";
11
11
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
12
+ import { createDataTableCsv } from "../../../components/data-table/export";
13
+ import { dropColumnsToFit } from "../../../components/ui/table-layout";
12
14
  import { ageFooterSegment, savedCopyFooterSegment } from "../../../components/layout/pane/footer";
13
15
  import { CountryFlag } from "../../../components/ui/country-flag";
14
16
  import { getSharedMarketDataCoordinator } from "../../../market-data/coordinator";
@@ -46,6 +48,31 @@ const RATE_COLUMN_WIDTH = 10;
46
48
  /** Snapshot rates reload at this pace while the feed is not carrying every leg. */
47
49
  const FX_FALLBACK_REFRESH_MS = 60_000;
48
50
 
51
+ /**
52
+ * The board's columns for a pane `width` cells wide: whole currency columns
53
+ * give way from the right until the rest fit (`dropColumnsToFit`), the first
54
+ * currency always kept. A board with more rows than `height` holds keeps a
55
+ * cell for its scrollbar.
56
+ */
57
+ function fxMatrixColumnsToFit<C extends DataTableColumn>(
58
+ columns: readonly C[], currencies: readonly string[], width: number, height: number,
59
+ ): C[] {
60
+ const scrollbar = currencies.length + 1 > height ? 1 : 0;
61
+ return dropColumnsToFit(columns, Math.floor(width) - scrollbar, currencies.slice(1).reverse());
62
+ }
63
+
64
+ /** "1 column hidden" in the footer, the codes in its title, for a pane too narrow for every currency. */
65
+ export function fxHiddenColumnsSegment(hidden: readonly string[]): PaneFooterSegment {
66
+ const count = hidden.length;
67
+ return {
68
+ id: "hidden-columns",
69
+ // A capture keeps it, as a picture cannot scroll to the columns it left out.
70
+ capture: true,
71
+ title: `${hidden.join(", ")} ${count === 1 ? "is" : "are"} not shown as ${count === 1 ? "a column" : "columns"}: widen the pane`,
72
+ parts: [{ text: `${count} ${count === 1 ? "column" : "columns"} hidden`, tone: "muted" }],
73
+ };
74
+ }
75
+
49
76
  function FxMatrixPane({ focused, width, height }: PaneProps) {
50
77
  const dataProvider = useAssetData();
51
78
  const flagged = useUiCapabilities().nativePaneChrome === true;
@@ -181,7 +208,7 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
181
208
  intervalMs: allLegsLive ? null : FX_FALLBACK_REFRESH_MS,
182
209
  });
183
210
 
184
- const columns = useMemo<DataTableColumn[]>(() => [
211
+ const allColumns = useMemo<DataTableColumn[]>(() => [
185
212
  { id: "base", label: "", width: flagged ? FLAGGED_BASE_COLUMN_WIDTH : BASE_COLUMN_WIDTH, align: "left" },
186
213
  ...currencies.map((currency) => ({
187
214
  id: currency,
@@ -191,6 +218,10 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
191
218
  headerLeading: flagged ? CURRENCY_FLAGS.get(currency) : undefined,
192
219
  })),
193
220
  ], [currencies, flagged]);
221
+ // A pane too narrow for every currency drops whole columns from the right, never cutting a rate at its edge, and
222
+ // the footer says how many (a capture keeps it): each one's rates still read along its row. The first stays.
223
+ const columns = useMemo(() => fxMatrixColumnsToFit(allColumns, currencies, width, height), [allColumns, currencies, height, width]);
224
+ const hiddenCurrencies = currencies.length - (columns.length - 1);
194
225
 
195
226
  const renderCell = useCallback((
196
227
  row: FxCurrency,
@@ -240,13 +271,13 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
240
271
  const updatedAgo = useUpdatedAgo(status.latestFetchedAt || null);
241
272
 
242
273
  usePaneFooter(FX_MATRIX_PANE_ID, () => {
243
- const info: PaneFooterSegment[] = [];
274
+ const info: PaneFooterSegment[] = hiddenCurrencies > 0 ? [fxHiddenColumnsSegment(currencies.slice(columns.length - 1))] : [];
244
275
  if (status.loading > 0) info.push({ id: "loading", parts: [{ text: "loading", tone: "muted" }] });
245
276
  if (statusText) info.push({ id: "rates", parts: [{ text: statusText, tone: status.stale || status.unknownTime || status.unavailable ? "warning" : "muted" }] });
246
277
  if (savedAt != null) info.push(savedCopyFooterSegment("updated", savedAt));
247
278
  else if (updatedAgo) info.push(ageFooterSegment(updatedAgo, { verb: "fetched" }));
248
279
  return { info };
249
- }, [savedAt, status.loading, statusText, updatedAgo]);
280
+ }, [columns.length, currencies, hiddenCurrencies, savedAt, status.loading, statusText, updatedAgo]);
250
281
 
251
282
  return (
252
283
  <DataTableView<FxCurrency>
@@ -263,6 +294,9 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
263
294
  freezeFirstColumn
264
295
  getExportMetadata={() => createFxExportMetadata(currencies, rates,
265
296
  (currency) => rateEntries.get(currency))}
297
+ // An export carries every currency, the columns a narrow pane leaves out too.
298
+ exportCsv={() => createDataTableCsv({ columns: allColumns, items: dataProvider ? currencies : [], renderCell,
299
+ getExportMetadata: () => createFxExportMetadata(currencies, rates, (currency) => rateEntries.get(currency)) })}
266
300
  items={dataProvider ? currencies : []}
267
301
  sortColumnId={null}
268
302
  sortDirection="asc"