@gloom-sh/terminal 0.20.10 → 0.20.12

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 (324) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
  3. package/src/api-client/awards.ts +16 -0
  4. package/src/api-client/central-bank-rates.ts +5 -0
  5. package/src/api-client/data.ts +55 -2
  6. package/src/api-client/index.ts +18 -1
  7. package/src/api-client/request.ts +86 -3
  8. package/src/api-client/socket-connection.ts +366 -0
  9. package/src/api-client/socket-features.ts +75 -0
  10. package/src/api-client/socket-frames.ts +161 -0
  11. package/src/api-client/socket-listeners.ts +207 -0
  12. package/src/api-client/socket-quotes.ts +332 -0
  13. package/src/api-client/socket.ts +168 -983
  14. package/src/api-client/supply-chain-graph.ts +4 -2
  15. package/src/api-client/supply-chain.ts +8 -0
  16. package/src/api-client/types/econ.ts +10 -7
  17. package/src/api-client/types/filings-and-calls.ts +8 -0
  18. package/src/app/global-shortcuts.ts +2 -1
  19. package/src/app/keybindings/actions.ts +19 -0
  20. package/src/app/pane-runtime/index.tsx +18 -3
  21. package/src/app/pane-runtime/layout-placement.ts +63 -0
  22. package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
  23. package/src/brokers/signed-in/adapter.ts +19 -5
  24. package/src/brokers/signed-in/client.ts +13 -1
  25. package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
  26. package/src/capabilities/chart-series.ts +4 -1
  27. package/src/cli/board-coins.ts +10 -1
  28. package/src/cli/commands/crypto-hints.ts +3 -2
  29. package/src/cli/commands/fred-series.ts +0 -54
  30. package/src/cli/commands/market.ts +209 -31
  31. package/src/cli/commands/overview.ts +47 -14
  32. package/src/cli/commands/search.ts +37 -8
  33. package/src/cli/commands/ticker.ts +15 -4
  34. package/src/cli/desktop-pane-shot.ts +27 -2
  35. package/src/cli/fx-quote-rate.ts +1 -1
  36. package/src/cli/glossary.ts +14 -5
  37. package/src/cli/history-catalog-series.ts +85 -0
  38. package/src/cli/index.ts +1 -1
  39. package/src/cli/list-progress.ts +45 -0
  40. package/src/cli/listing-arg.ts +71 -7
  41. package/src/cli/name-entries.ts +8 -4
  42. package/src/cli/not-a-ticker.ts +2 -2
  43. package/src/cli/pane-functions/freshness.ts +50 -3
  44. package/src/cli/pane-functions/index.ts +7 -4
  45. package/src/cli/pane-functions/market-session.ts +66 -14
  46. package/src/cli/pane-functions/options.ts +5 -0
  47. package/src/cli/pane-functions/resolver.ts +9 -2
  48. package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
  49. package/src/cli/pane-functions/screenshot-types.ts +6 -0
  50. package/src/cli/quote-answer.ts +49 -10
  51. package/src/cli/quote-list-reads.ts +87 -0
  52. package/src/cli/report-tables.ts +70 -13
  53. package/src/cli/result.ts +24 -2
  54. package/src/cli/symbol-list.ts +31 -4
  55. package/src/cli/terminal-code-hints.ts +83 -0
  56. package/src/cli/ticker-resolution.ts +2 -1
  57. package/src/cli/treasury-yields.ts +5 -0
  58. package/src/components/chart/native/kitty/manager.ts +2 -0
  59. package/src/components/chart/native/surface/manager.ts +211 -11
  60. package/src/components/command-bar/action-runtime.ts +2 -0
  61. package/src/components/command-bar/panel/index.tsx +2 -13
  62. package/src/components/command-bar/panel/layout.ts +1 -7
  63. package/src/components/command-bar/panel/runtime.ts +0 -1
  64. package/src/components/command-bar/panel/types.ts +0 -2
  65. package/src/components/command-bar/routing/launch-request.ts +2 -1
  66. package/src/components/command-bar/routing/navigation-state.ts +4 -2
  67. package/src/components/command-bar/workflow/types.ts +6 -0
  68. package/src/components/data-table/column-menu.tsx +89 -0
  69. package/src/components/data-table/sort-menu.tsx +9 -2
  70. package/src/components/data-table/view.tsx +33 -6
  71. package/src/components/form-modal/content.tsx +10 -0
  72. package/src/components/index.ts +1 -1
  73. package/src/components/layout/detached-pane-shell.tsx +3 -0
  74. package/src/components/layout/double-escape-close.ts +34 -3
  75. package/src/components/layout/floating-pane.tsx +10 -4
  76. package/src/components/layout/pane/cycle-order.ts +66 -2
  77. package/src/components/layout/pane/footer/index.tsx +25 -11
  78. package/src/components/layout/pane/footer/model.ts +62 -20
  79. package/src/components/layout/pane/header.tsx +140 -31
  80. package/src/components/layout/pane/sidebar.tsx +138 -20
  81. package/src/components/layout/pane/status-footer.ts +3 -1
  82. package/src/components/layout/shell/active-drag.ts +18 -13
  83. package/src/components/layout/shell/drag/magnets.ts +34 -18
  84. package/src/components/layout/shell/drag/runtime.ts +5 -0
  85. package/src/components/layout/shell/index.tsx +25 -0
  86. package/src/components/layout/shell/menu.ts +9 -0
  87. package/src/components/layout/shell/pane/actions.ts +36 -0
  88. package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
  89. package/src/components/layout/shell/pane-occlusion.ts +40 -0
  90. package/src/components/layout/shell/shortcuts.ts +17 -1
  91. package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
  92. package/src/components/layout/shell/window-mode/index.ts +5 -16
  93. package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
  94. package/src/components/market-board/index.tsx +14 -5
  95. package/src/components/metric-treemap/index.tsx +3 -1
  96. package/src/components/ticker/list-table-view.tsx +5 -0
  97. package/src/components/ui/button.tsx +48 -4
  98. package/src/components/ui/data-table/column-order.ts +180 -0
  99. package/src/components/ui/data-table/index.tsx +12 -1
  100. package/src/components/ui/data-table/opentui/index.tsx +291 -32
  101. package/src/components/ui/data-table/opentui/model.ts +43 -4
  102. package/src/components/ui/data-table/types.ts +56 -0
  103. package/src/components/ui/data-table/use-column-order.ts +135 -0
  104. package/src/components/ui/index.ts +1 -1
  105. package/src/components/ui/inline-quick-add.tsx +19 -3
  106. package/src/components/ui/list-view.tsx +11 -5
  107. package/src/components/ui/query-bar.tsx +16 -1
  108. package/src/components/ui/selection-fill.ts +39 -0
  109. package/src/components/ui/table-layout.ts +120 -0
  110. package/src/core/state/app/layout-reducer.ts +2 -1
  111. package/src/core/state/app/pane-choices.ts +68 -0
  112. package/src/core/state/app/state.ts +14 -6
  113. package/src/core/state/app/types.ts +8 -0
  114. package/src/docs/snapshot.json +3 -2
  115. package/src/i18n/es.ts +2 -0
  116. package/src/i18n/ja.ts +2 -0
  117. package/src/i18n/ko.ts +2 -0
  118. package/src/i18n/zh-cn.ts +2 -0
  119. package/src/i18n/zh-tw.ts +2 -0
  120. package/src/layout/pane-manager/dock-tree.ts +19 -0
  121. package/src/layout/pane-manager/index.ts +3 -0
  122. package/src/market-data/coordinator/index.ts +4 -3
  123. package/src/market-data/coordinator/quotes.ts +12 -4
  124. package/src/market-data/market/freshness.ts +33 -0
  125. package/src/market-data/market/status.ts +5 -1
  126. package/src/market-data/quotes/contributions.ts +10 -0
  127. package/src/market-data/quotes/freshness.ts +31 -0
  128. package/src/market-data/quotes/live-valuation.ts +32 -5
  129. package/src/market-data/quotes/regular-session-valuation.ts +1 -1
  130. package/src/market-data/quotes/resolution.ts +4 -0
  131. package/src/market-data/quotes/time.ts +0 -14
  132. package/src/plugins/builtin/account-management/index.tsx +1 -0
  133. package/src/plugins/builtin/awards/detail.tsx +12 -4
  134. package/src/plugins/builtin/awards/headless.ts +29 -8
  135. package/src/plugins/builtin/awards/model.ts +36 -2
  136. package/src/plugins/builtin/awards/pane.tsx +7 -4
  137. package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
  138. package/src/plugins/builtin/broker-manager/index.tsx +7 -6
  139. package/src/plugins/builtin/broker-manager/model.ts +15 -6
  140. package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
  141. package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
  142. package/src/plugins/builtin/broker-manager/table.ts +10 -4
  143. package/src/plugins/builtin/broker-trading/index.tsx +1 -1
  144. package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
  145. package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
  146. package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
  147. package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
  148. package/src/plugins/builtin/chart-composer/headless.ts +5 -1
  149. package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
  150. package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
  151. package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
  152. package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
  153. package/src/plugins/builtin/chat/sidebar.tsx +35 -19
  154. package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
  155. package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
  156. package/src/plugins/builtin/cloud/plugin.tsx +1 -0
  157. package/src/plugins/builtin/cloud/team/module.tsx +1 -0
  158. package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
  159. package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
  160. package/src/plugins/builtin/company-kpis/model.ts +3 -3
  161. package/src/plugins/builtin/connections/index.ts +1 -0
  162. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
  163. package/src/plugins/builtin/credit-boards/client.ts +5 -0
  164. package/src/plugins/builtin/credit-boards/headless.ts +1 -6
  165. package/src/plugins/builtin/credit-boards/model.ts +0 -6
  166. package/src/plugins/builtin/credit-boards/series.ts +19 -8
  167. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
  168. package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
  169. package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
  170. package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
  171. package/src/plugins/builtin/debt-maturities/model.ts +9 -15
  172. package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
  173. package/src/plugins/builtin/earnings/board-model.ts +33 -4
  174. package/src/plugins/builtin/earnings/board.tsx +15 -3
  175. package/src/plugins/builtin/earnings/calendar.tsx +10 -6
  176. package/src/plugins/builtin/earnings/client.ts +0 -9
  177. package/src/plugins/builtin/earnings/headless.ts +10 -7
  178. package/src/plugins/builtin/earnings/history.tsx +21 -14
  179. package/src/plugins/builtin/earnings-calls/data.ts +24 -4
  180. package/src/plugins/builtin/earnings-calls/format.ts +23 -5
  181. package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
  182. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  183. package/src/plugins/builtin/earnings-calls/model.ts +11 -1
  184. package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
  185. package/src/plugins/builtin/econ/calendar-model.ts +27 -0
  186. package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
  187. package/src/plugins/builtin/econ/index.tsx +9 -2
  188. package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
  189. package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
  190. package/src/plugins/builtin/equity-screener/live.ts +74 -18
  191. package/src/plugins/builtin/equity-screener/model.ts +19 -4
  192. package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
  193. package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
  194. package/src/plugins/builtin/equity-screener/results.ts +22 -2
  195. package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
  196. package/src/plugins/builtin/fear-greed/headless.ts +16 -13
  197. package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
  198. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  199. package/src/plugins/builtin/futures/index.tsx +15 -1
  200. package/src/plugins/builtin/futures/table.tsx +1 -1
  201. package/src/plugins/builtin/fx-matrix/index.tsx +32 -19
  202. package/src/plugins/builtin/holders/pane.tsx +30 -20
  203. package/src/plugins/builtin/insider/table.tsx +10 -7
  204. package/src/plugins/builtin/insider/tickers.tsx +1 -1
  205. package/src/plugins/builtin/iv-history/events.ts +5 -0
  206. package/src/plugins/builtin/iv-history/headless.ts +15 -9
  207. package/src/plugins/builtin/jobs/index.tsx +1 -0
  208. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
  209. package/src/plugins/builtin/macro-day/headless.ts +15 -6
  210. package/src/plugins/builtin/macro-day/model.ts +1 -1
  211. package/src/plugins/builtin/macro-day/releases.ts +25 -16
  212. package/src/plugins/builtin/market-movers/index.tsx +20 -8
  213. package/src/plugins/builtin/market-movers/model.ts +5 -0
  214. package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
  215. package/src/plugins/builtin/money-markets/headless.ts +12 -2
  216. package/src/plugins/builtin/money-markets/pane.tsx +10 -1
  217. package/src/plugins/builtin/options/view.tsx +3 -0
  218. package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
  219. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  220. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  221. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
  222. package/src/plugins/builtin/portfolio-list/pane/index.tsx +19 -1
  223. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
  224. package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
  225. package/src/plugins/builtin/portfolio-list/table.tsx +15 -1
  226. package/src/plugins/builtin/rate-path/pane.tsx +2 -0
  227. package/src/plugins/builtin/realized-vol/headless.ts +28 -2
  228. package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
  229. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
  230. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  231. package/src/plugins/builtin/seasonality/pane.tsx +2 -1
  232. package/src/plugins/builtin/shared/source-footer.ts +70 -0
  233. package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
  234. package/src/plugins/builtin/short-volume/pane.tsx +5 -1
  235. package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
  236. package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
  237. package/src/plugins/builtin/supply-chain/client.ts +3 -1
  238. package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
  239. package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
  240. package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
  241. package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
  242. package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
  243. package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
  244. package/src/plugins/builtin/supply-chain/headless.ts +13 -7
  245. package/src/plugins/builtin/supply-chain/model.ts +68 -11
  246. package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
  247. package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
  248. package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
  249. package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
  250. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
  251. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
  252. package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
  253. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
  254. package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
  255. package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
  256. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
  257. package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
  258. package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
  259. package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
  260. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
  261. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
  262. package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
  263. package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
  264. package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
  265. package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
  266. package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
  267. package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
  268. package/src/plugins/builtin/vol-surface/heat-grid.tsx +6 -3
  269. package/src/plugins/builtin/vol-surface/pane.tsx +7 -3
  270. package/src/plugins/builtin/world-indices/index.tsx +5 -1
  271. package/src/plugins/builtin/yield-curve/index.tsx +2 -1
  272. package/src/plugins/runtime/index.tsx +1 -0
  273. package/src/plugins/runtime/state.ts +20 -0
  274. package/src/portfolio/column-values.ts +8 -2
  275. package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
  276. package/src/public/react.ts +7 -0
  277. package/src/react/auto-refresh.ts +29 -0
  278. package/src/renderers/browser/deeplink-bridge.ts +24 -3
  279. package/src/renderers/dom/data-table/column-drag.ts +147 -0
  280. package/src/renderers/dom/data-table/index.tsx +22 -0
  281. package/src/renderers/dom/data-table/row.tsx +27 -5
  282. package/src/renderers/dom/desktop/query-bar.tsx +229 -60
  283. package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
  284. package/src/renderers/dom/host/overflow-fade.ts +1 -2
  285. package/src/renderers/dom/styles.css +47 -5
  286. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
  287. package/src/renderers/opentui/chart-surface.tsx +1 -0
  288. package/src/renderers/opentui/frame-hits.ts +33 -0
  289. package/src/renderers/opentui/host.tsx +2 -0
  290. package/src/renderers/opentui/native-surface.ts +14 -21
  291. package/src/renderers/opentui/test-utils.tsx +3 -0
  292. package/src/series/types.ts +2 -0
  293. package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
  294. package/src/sources/gloomberb-cloud/index.ts +25 -1
  295. package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
  296. package/src/sources/provider-errors.ts +64 -1
  297. package/src/sources/provider-router/batches.ts +19 -0
  298. package/src/sources/provider-router/index.ts +7 -1
  299. package/src/state/app/context/index.tsx +46 -1
  300. package/src/state/pane-unsent-work.ts +47 -0
  301. package/src/test-support/app-store.ts +24 -1
  302. package/src/test-support/shell-pane-keys.tsx +5 -0
  303. package/src/test-support/telemetry-guard.ts +83 -0
  304. package/src/test-support/test-env.ts +12 -0
  305. package/src/theme/colors.ts +17 -1
  306. package/src/theme/ui-tokens.ts +50 -1
  307. package/src/tickers/listing-venues.ts +11 -1
  308. package/src/tickers/search/japanese-names.json +1 -0
  309. package/src/tickers/search/japanese-names.ts +152 -0
  310. package/src/tickers/terminal-codes.ts +55 -6
  311. package/src/time-series/base-series.ts +3 -0
  312. package/src/time-series/live-quotes.ts +3 -9
  313. package/src/types/data-provider.ts +6 -0
  314. package/src/types/financials.ts +11 -0
  315. package/src/types/plugin-contributions.ts +7 -0
  316. package/src/types/plugin-panes.ts +7 -0
  317. package/src/ui/host.tsx +24 -0
  318. package/src/ui/pointer-drag.ts +11 -2
  319. package/src/utils/double-escape-close.ts +42 -0
  320. package/src/utils/fundamentals.ts +14 -3
  321. package/src/utils/fx-status.ts +30 -7
  322. package/src/utils/network-failure.ts +23 -0
  323. package/src/utils/share-multiples.cases.json +780 -2
  324. package/src/utils/share-multiples.ts +154 -24
@@ -143,7 +143,7 @@ const BLOOMBERG_INDICES: Readonly<Record<string, string>> = {
143
143
  UKX: "^FTSE", DAX: "^GDAXI", CAC: "^FCHI", SX5E: "^STOXX50E", SMI: "^SSMI", AEX: "^AEX", IBEX: "^IBEX",
144
144
  NKY: "^N225", HSI: "^HSI", KOSPI: "^KS11", TWSE: "^TWII", SENSEX: "^BSESN", NIFTY: "^NSEI", FSSTI: "^STI",
145
145
  AS51: "^AXJO", SPTSX: "^GSPTSE", MEXBOL: "^MXX", IBOV: "^BVSP", XU100: "XU100.IS", DXY: "DX-Y.NYB",
146
- USGG5YR: "^FVX", USGG10YR: "^TNX", USGG30YR: "^TYX",
146
+ USGG3M: "^IRX", USGG5YR: "^FVX", USGG10YR: "^TNX", USGG30YR: "^TYX", MOVE: "^MOVE",
147
147
  };
148
148
 
149
149
  /** Index and volatility futures Bloomberg writes with the Index key (ES1 Index, DM1 Index, UX1 Index), by the root quoted here. */
@@ -159,8 +159,13 @@ const BLOOMBERG_FUTURES_ALIASES: ReadonlySet<string> = new Set([
159
159
  /** "EUR Curncy" is the dollar rate in market convention: these as XXXUSD, every other currency as USDXXX. */
160
160
  const DOLLAR_BASE_CURRENCIES: ReadonlySet<string> = new Set(["EUR", "GBP", "AUD", "NZD"]);
161
161
 
162
- /** Bloomberg writes bitcoin as XBT. */
163
- const BLOOMBERG_CRYPTO: Readonly<Record<string, string>> = { XBT: "BTC-USD", XBTUSD: "BTC-USD" };
162
+ /** Bloomberg writes bitcoin as XBT, and keys the dollar index as a currency too (DXY Curncy). */
163
+ const BLOOMBERG_CURRENCY_CODES: Readonly<Record<string, string>> = { XBT: "BTC-USD", XBTUSD: "BTC-USD", DXY: "DX-Y.NYB" };
164
+
165
+ /** Currency futures Bloomberg keys as currencies (JY1 Curncy is the yen future), by the root quoted here. */
166
+ const BLOOMBERG_CURRENCY_FUTURE_ROOTS: Readonly<Record<string, string>> = {
167
+ JY: "6J", EC: "6E", BP: "6B", AD: "6A", CD: "6C", SF: "6S", NV: "6N", PE: "6M",
168
+ };
164
169
 
165
170
  const REUTERS_VENUES: Record<string, string> = { N: "NYSE", O: "NASDAQ", OQ: "NASDAQ" };
166
171
 
@@ -252,10 +257,13 @@ function readBloombergIndex(typed: string, code: string): TerminalListingCode |
252
257
  return root ? genericFuture(typed, root, future![2]!, "Index") : null;
253
258
  }
254
259
 
255
- /** `EURUSD Curncy`, `JPY Curncy` (the dollar rate in market convention: USDJPY), `XBT Curncy`. */
260
+ /** `EURUSD Curncy`, `JPY Curncy` (the dollar rate in market convention: USDJPY), `XBT Curncy`, `DXY Curncy`, `JY1 Curncy`. */
256
261
  function readBloombergCurrency(typed: string, code: string): TerminalListingCode | null {
257
- const crypto = BLOOMBERG_CRYPTO[code];
258
- if (crypto) return { typed, ...keyOf(crypto, ""), terminal: "bloomberg", yellowKey: "Curncy" };
262
+ const named = BLOOMBERG_CURRENCY_CODES[code];
263
+ if (named) return { typed, ...keyOf(named, ""), terminal: "bloomberg", yellowKey: "Curncy" };
264
+ const future = /^([A-Z]{2})(\d{1,2})$/.exec(code);
265
+ const root = future ? BLOOMBERG_CURRENCY_FUTURE_ROOTS[future[1]!] : undefined;
266
+ if (root) return genericFuture(typed, root, future![2]!, "Curncy");
259
267
  const [base, quote] = /^[A-Z]{6}$/.test(code) ? [code.slice(0, 3), code.slice(3)]
260
268
  : /^[A-Z]{3}$/.test(code) && code !== "USD" ? DOLLAR_BASE_CURRENCIES.has(code) ? [code, "USD"] : ["USD", code]
261
269
  : [null, null];
@@ -363,6 +371,47 @@ export function unknownBloombergMarket(raw: string): UnknownBloombergMarket | nu
363
371
  };
364
372
  }
365
373
 
374
+ /** The yellow keys that make a line one code whatever it names: an index, a currency, a commodity, a government bond. */
375
+ const CODE_YELLOW_KEYS: Readonly<Record<string, UnreadBloombergCode["yellowKey"]>> = {
376
+ index: "Index", curncy: "Curncy", comdty: "Comdty", govt: "Govt",
377
+ };
378
+
379
+ /** A word of a code: capitals and digits (MOVE, GTJPY10Y, 1M, 25D), never a word of a name (Hang, Seng). */
380
+ const CODE_WORD = /^[A-Z0-9][A-Z0-9&./-]{0,15}$/;
381
+
382
+ /** A line written as a Bloomberg code that names nothing quoted here (`GTJPY10Y Govt`, `VXJ Index`, `USDJPY BGN Curncy`). */
383
+ export interface UnreadBloombergCode {
384
+ typed: string;
385
+ /** The words before the yellow key, in capitals: `GTJPY10Y`, `USDJPY BGN`. */
386
+ code: string;
387
+ yellowKey: "Index" | "Curncy" | "Comdty" | "Govt";
388
+ }
389
+
390
+ /**
391
+ * A line written as a Bloomberg code with an index, currency, commodity or
392
+ * government bond key that no symbol here is read from: one entry, refused
393
+ * with a hint, never split into words or searched for as a company's name
394
+ * (`MOVE Index` found a Stuttgart product named after the index, and
395
+ * `GTJPY10Y Govt` split into GTJPY10Y and the GOVT fund). An index, a
396
+ * commodity or a bond is one word before its key (`FTSE 100 Index` is a
397
+ * name); a currency's code may carry its pricing source or tenor
398
+ * (`USDJPY BGN Curncy`, `USDJPY 1M 25D RR Curncy`). The first word is in
399
+ * capitals or has a digit, so `Gold Comdty` and `Nasdaq Index` stay names.
400
+ * Null for anything else, and for a code `readTerminalListingCode` reads.
401
+ */
402
+ export function unreadBloombergCode(raw: string): UnreadBloombergCode | null {
403
+ const typed = normalizeTyped(raw);
404
+ const words = typed.split(" ");
405
+ const yellowKey = words.length >= 2 ? CODE_YELLOW_KEYS[words.at(-1)!.toLowerCase()] : undefined;
406
+ if (!yellowKey) return null;
407
+ const parts = words.slice(0, -1);
408
+ if (parts.length > (yellowKey === "Curncy" ? 4 : 1)) return null;
409
+ if (!parts.every((part) => CODE_WORD.test(part.toUpperCase()))) return null;
410
+ if (/\p{Ll}/u.test(parts[0]!) && !/\d/.test(parts[0]!)) return null;
411
+ if (readTerminalListingCode(typed)) return null;
412
+ return { typed, code: parts.join(" ").toUpperCase(), yellowKey };
413
+ }
414
+
366
415
  /** What to type instead where Bloomberg's ticker is not the venue's own code (MK, SP); null elsewhere. */
367
416
  export function bloombergMarketHint(market: string | undefined): string | null {
368
417
  return (market && BLOOMBERG_MARKETS[market]?.hint) || null;
@@ -7,6 +7,7 @@ import type { LiveBarAccumulator } from "./live-bars";
7
7
  import { CHART_RESOLUTION_STEP_MS, type ManualChartResolution } from "./resolution";
8
8
  import type { Quote, QuoteMetadata, TickerFinancials } from "../types/financials";
9
9
  import type { FredSeriesLoadResult } from "../sources/gloomberb-cloud/fred-series";
10
+ import { fredSeriesAttribution } from "../sources/gloomberb-cloud/fred-attribution";
10
11
  import { extractFredSeries } from "./economic";
11
12
  import { isIceSpreadSeries } from "./ice-credit";
12
13
  import { BASIS_POINT_UNIT, BP_PER_PERCENT } from "./studies/units";
@@ -332,6 +333,8 @@ export function baseEconomicSeries(
332
333
  ? points.map((point) => typeof point.value === "number" ? { ...point, value: Number((point.value * BP_PER_PERCENT).toPrecision(12)) } : point)
333
334
  : points,
334
335
  warning: "FRED vintage dates are unavailable; observations use period dates.",
336
+ // Its own publisher and publish date, as `fred` cites them (TurkStat via the CBRT), never Gloom Cloud's name.
337
+ attribution: fredSeriesAttribution(spec.source.seriesId, data),
335
338
  };
336
339
  }
337
340
 
@@ -6,7 +6,7 @@ import type { ChartSeriesSpec, ChartSpec, SecuritySeriesSource } from "./types";
6
6
  import { activeStudyInputSeriesIds } from "./studies/resolve";
7
7
  import { withFormulaNextMonths } from "./formula-months";
8
8
  import { valuationSeriesUsesLiveQuote } from "./fundamentals";
9
- import { hasValidQuoteObservationTime } from "../market-data/quotes/freshness";
9
+ import { hasValidQuoteObservationTime, quoteStampBucket } from "../market-data/quotes/freshness";
10
10
  import type { InstrumentRef } from "../market-data/request-types";
11
11
  import type { QueryEntry } from "../market-data/result-types";
12
12
  import { buildQuoteKey, instrumentFromQuoteTarget, resolveEntryData } from "../market-data/selectors";
@@ -105,19 +105,13 @@ function isNewerQuote(next: Quote, current: Quote | undefined): boolean {
105
105
  && (next.stale === true) !== (current.stale === true));
106
106
  }
107
107
 
108
- /** Every chart bar boundary, intraday or calendar, is a whole minute. */
109
- const QUOTE_TIME_BUCKET_MS = 60_000;
110
-
111
- function quoteTimeBucket(quote: Quote): number {
112
- return Number.isFinite(quote.lastUpdated) ? Math.floor(quote.lastUpdated / QUOTE_TIME_BUCKET_MS) : Number.NaN;
113
- }
114
-
115
108
  function hasResolutionRelevantChange(next: Quote, current: Quote | undefined): boolean {
116
109
  if (!current) return true;
117
110
  // Bid/ask updates restamp a quote many times a second without moving its
118
111
  // price or volume. The stamp alone matters only when it crosses into
119
112
  // another minute, where it can open a bar at the same price.
120
- return !Object.is(quoteTimeBucket(next), quoteTimeBucket(current))
113
+ // Every chart bar boundary, intraday or calendar, is a whole minute (quoteStampBucket).
114
+ return !Object.is(quoteStampBucket(next), quoteStampBucket(current))
121
115
  || next.price !== current.price
122
116
  || next.volume !== current.volume
123
117
  || next.stale !== current.stale
@@ -265,6 +265,12 @@ export interface QuoteBatchResult {
265
265
  * stale, or none.
266
266
  */
267
267
  followUp?: "default" | "refresh";
268
+ /**
269
+ * The error is a source failing (a timeout, the request limit, an
270
+ * unreachable service), not an answer about the listing: asked again
271
+ * shortly it may be quoted. Kept where `error` crosses a bridge as text.
272
+ */
273
+ transient?: boolean;
268
274
  }
269
275
 
270
276
  export interface QuoteBatchOptions {
@@ -205,6 +205,17 @@ export interface Quote extends DepositaryReceiptFacts {
205
205
  changeSessionDate?: string;
206
206
  high52w?: number;
207
207
  low52w?: number;
208
+ /**
209
+ * The 52-week range is the high and low of the stored daily bars over 52
210
+ * weeks, the source's own having been unusable (an index's that only
211
+ * repeated the day's range, or reached zero): said beside it.
212
+ */
213
+ yearRangeBasis?: "daily-bars";
214
+ /**
215
+ * No live quote: the price is the close of the latest stored daily bar of
216
+ * `session` (an exchange-local date), said beside the price.
217
+ */
218
+ dailyClose?: { session: string };
208
219
  marketCap?: number;
209
220
  volume?: number;
210
221
  name?: string;
@@ -37,6 +37,13 @@ export interface TickerResearchTabDef {
37
37
  instruments?: readonly TickerInstrumentKind[];
38
38
  /** Narrower checks than `instruments`: a US listing, an options chain, a connected broker. */
39
39
  isVisible?: (context: TickerResearchTabVisibilityContext) => boolean;
40
+ /**
41
+ * Opens only with Gloom Cloud Pro: an account without it sees the tab's
42
+ * wall. A ticker pane restored on this tab for such an account opens on
43
+ * Overview, and the wall shows once someone picks the tab; the tab stays
44
+ * saved for when the plan has Pro.
45
+ */
46
+ proOnly?: boolean;
40
47
  }
41
48
 
42
49
  export interface TickerAction {
@@ -47,6 +47,13 @@ export interface PaneDef {
47
47
  defaultWidth?: string;
48
48
  defaultFloatingSize?: { width: number; height: number };
49
49
  defaultMode?: "docked" | "floating";
50
+ /**
51
+ * A window for the account or the app rather than data (account, brokers,
52
+ * orders, connections, team, Ask Gloom): it opens floating even in a layout
53
+ * being built as a grid, and is not one of the layout's panes when deciding
54
+ * whether a new one docks.
55
+ */
56
+ utilityWindow?: true;
50
57
  /** Pane publishes its selected symbol as pane-state `cursorSymbol`, so ticker panes can follow it. */
51
58
  tickerSource?: boolean;
52
59
  /**
package/src/ui/host.tsx CHANGED
@@ -167,6 +167,8 @@ interface ScrollBarRenderable {
167
167
  visible: boolean;
168
168
  /** Terminal only: whether a click on the bar moves the keyboard focus to it. */
169
169
  focusable?: boolean;
170
+ /** Terminal only: shows the bar again while the content overflows, after `visible` was set. */
171
+ resetVisibilityControl?(): void;
170
172
  on?(event: "change", handler: () => void): void;
171
173
  off?(event: "change", handler: () => void): void;
172
174
  }
@@ -267,6 +269,20 @@ export interface NativePaneImage {
267
269
  cells?: { cols: number; rows: number; cells: NativeFrameCell[] };
268
270
  }
269
271
 
272
+ /**
273
+ * What the frame on screen drew on top, cell by cell: kitty images are drawn
274
+ * out of band, so the terminal image layer reads this to keep each image under
275
+ * whatever covers it.
276
+ */
277
+ export interface NativeFrameHits {
278
+ /** The renderable drawn last at a cell of the frame on screen, or null. */
279
+ at(x: number, y: number): unknown;
280
+ /** Whether a renderable fills its cells (a background), rather than only grouping or writing over others. */
281
+ paints(renderable: unknown): boolean;
282
+ /** Whether a renderable is still in the tree the terminal draws. */
283
+ attached(renderable: unknown): boolean;
284
+ }
285
+
270
286
  /** The last frame the terminal renderer drew, as styled rows. */
271
287
  export interface NativeFrameCapture {
272
288
  cols: number;
@@ -304,6 +320,8 @@ export interface NativeRendererHost {
304
320
  removePostProcessFn?(processFn: NativePostProcessFn): void;
305
321
  /** Terminal renderers only. Kitty graphics are drawn out of band and come back as blank cells. */
306
322
  captureFrame?(): NativeFrameCapture | null;
323
+ /** Terminal renderers only: what each cell of the frame on screen drew on top. */
324
+ frameHits?: NativeFrameHits;
307
325
  /**
308
326
  * Terminal renderers only: a PNG of a rectangle of the frame shown now, in
309
327
  * cells, its characters drawn in a bundled font and its kitty images put back.
@@ -545,6 +563,10 @@ export interface HostQueryBarItem {
545
563
  narrowing: boolean;
546
564
  /** Short exclusive choice drawn as inline segments instead of a menu. */
547
565
  inline?: boolean;
566
+ /** Inline: a long list that runs past the bar's edge, drawn as a strip that scrolls by itself rather than folding into its menu. */
567
+ scrolls?: boolean;
568
+ /** Toggles: a shorter label for a bar short of room. */
569
+ short?: string;
548
570
  /** Text filters: the live input, rendered by the kit, and its field state. */
549
571
  node?: ReactNode;
550
572
  active?: boolean;
@@ -576,6 +598,8 @@ export interface HostQueryBarProps {
576
598
  onChange(value: string): void;
577
599
  /** Drawn first, where a tab row starts: a nested tab strip. */
578
600
  start?: boolean;
601
+ /** What the choice is ("Interval"), for a screen reader and its folded menu; "View" when unnamed. */
602
+ label?: string;
579
603
  };
580
604
  onClearAll?: () => void;
581
605
  /** Muted context at the right edge, e.g. the selected row's date. Gives way first. */
@@ -1,5 +1,4 @@
1
- export function capturePointerDrag(renderer: unknown, renderable: unknown): void {
2
- if (!renderable) return;
1
+ function setCapture(renderer: unknown, renderable: unknown): void {
3
2
  const hostCapture = (renderer as { captureMouseRenderable?: (target: unknown) => void }).captureMouseRenderable;
4
3
  if (typeof hostCapture === "function") {
5
4
  hostCapture.call(renderer, renderable);
@@ -10,3 +9,13 @@ export function capturePointerDrag(renderer: unknown, renderable: unknown): void
10
9
  capture.call(renderer, renderable);
11
10
  }
12
11
  }
12
+
13
+ export function capturePointerDrag(renderer: unknown, renderable: unknown): void {
14
+ if (!renderable) return;
15
+ setCapture(renderer, renderable);
16
+ }
17
+
18
+ /** Ends a capture whose release never came (the button let go outside the window), so the next press goes where it lands. */
19
+ export function releasePointerDrag(renderer: unknown): void {
20
+ setCapture(renderer, undefined);
21
+ }
@@ -31,6 +31,8 @@ export interface DoubleEscapeCloseState {
31
31
  streamAt: number;
32
32
  /** The last Esc that armed, closed or looked like a repeat. */
33
33
  pressAt: number;
34
+ /** The last Esc that closed a window on its own (`takeSingleEscapeClose`), until the Esc after it. */
35
+ singleClosedAt: number;
34
36
  }
35
37
 
36
38
  export function createDoubleEscapeCloseState(): DoubleEscapeCloseState {
@@ -39,12 +41,14 @@ export function createDoubleEscapeCloseState(): DoubleEscapeCloseState {
39
41
  targetId: null,
40
42
  streamAt: Number.NEGATIVE_INFINITY,
41
43
  pressAt: Number.NEGATIVE_INFINITY,
44
+ singleClosedAt: Number.NEGATIVE_INFINITY,
42
45
  };
43
46
  }
44
47
 
45
48
  export function resetDoubleEscapeClose(state: DoubleEscapeCloseState) {
46
49
  state.lastAt = 0;
47
50
  state.targetId = null;
51
+ state.singleClosedAt = Number.NEGATIVE_INFINITY;
48
52
  }
49
53
 
50
54
  /**
@@ -81,6 +85,44 @@ function isHeldEscape(state: DoubleEscapeCloseState, now: number, repeat: boolea
81
85
  && now - state.streamAt < HELD_ESCAPE_STALL_MS;
82
86
  }
83
87
 
88
+ /**
89
+ * Whether an Esc is a held key rather than a press: the host's repeat, or one
90
+ * that comes as fast as a held key's while a stream is live. Read before the
91
+ * Esc arms anything, since arming moves the last press to it.
92
+ */
93
+ export function isHeldEscapePress(state: DoubleEscapeCloseState, now: number, repeat?: boolean): boolean {
94
+ return repeat === true || isHeldEscape(state, now, repeat);
95
+ }
96
+
97
+ /**
98
+ * One Esc nothing else took closes a floating window on its own. Call it once
99
+ * the window closed, for a press that was not held (`isHeldEscapePress`): the
100
+ * Esc a double press sends after it closes nothing more
101
+ * (`swallowEscapeAfterSingleClose`), so Esc Esc still closes one window, and
102
+ * a held key, as after a double close, goes on closing nothing.
103
+ */
104
+ export function takeSingleEscapeClose(state: DoubleEscapeCloseState, now: number) {
105
+ resetDoubleEscapeClose(state);
106
+ state.streamAt = now;
107
+ state.pressAt = now;
108
+ state.singleClosedAt = now;
109
+ }
110
+
111
+ /**
112
+ * The Esc right after one that closed a window on its own, at a double
113
+ * press's pace: the second half of a pair whose first half already closed.
114
+ * It is taken, and reaches nothing. A host's repeat is left to the held-key
115
+ * rules.
116
+ */
117
+ export function swallowEscapeAfterSingleClose(state: DoubleEscapeCloseState, now: number, repeat?: boolean): boolean {
118
+ if (repeat === true || now - state.singleClosedAt > DOUBLE_ESCAPE_CLOSE_MS) return false;
119
+ state.singleClosedAt = Number.NEGATIVE_INFINITY;
120
+ resetDoubleEscapeClose(state);
121
+ state.streamAt = now;
122
+ state.pressAt = now;
123
+ return true;
124
+ }
125
+
84
126
  interface EscapeOffer {
85
127
  count(): void;
86
128
  keep(): void;
@@ -572,11 +572,22 @@ export function trailingEpsSourceNote(
572
572
 
573
573
  type PriceEarningsBasis = Pick<Fundamentals, "financialCurrency" | "ttmConversion" | "epsCurrency" | "trailingPEConversion">;
574
574
 
575
- /** The trailing EPS in the price's currency: converted at the rate the served P/E used when it says so. */
576
- export function priceEarningsEps(fundamentals: Pick<Fundamentals, "eps" | "trailingPEConversion"> | undefined): number | undefined {
575
+ /** The minor units a quote can be priced in, as Gloom Cloud reads them: pence, South African cents and agorot. */
576
+ const MINOR_QUOTE_UNITS = new Set(["GBp", "GBX", "ZAc", "ZAC", "ILA"]);
577
+
578
+ /**
579
+ * The trailing EPS in the price's currency and unit: converted at the rate the served P/E used when it says so, a
580
+ * rate into the major unit, so a price in pence, South African cents or agorot takes it a hundredfold (30,000 ILA
581
+ * over 2.50 USD at 3.7037 ILS is 32.4, not 3,240).
582
+ */
583
+ export function priceEarningsEps(
584
+ fundamentals: Pick<Fundamentals, "eps" | "trailingPEConversion"> | undefined,
585
+ quoteCurrency?: string | null,
586
+ ): number | undefined {
577
587
  const eps = fundamentals?.eps;
578
588
  const rate = fundamentals?.trailingPEConversion?.rate;
579
- return typeof eps === "number" && typeof rate === "number" && Number.isFinite(rate) && rate > 0 ? eps * rate : eps;
589
+ if (typeof eps !== "number" || typeof rate !== "number" || !Number.isFinite(rate) || !(rate > 0)) return eps;
590
+ return eps * rate * (MINOR_QUOTE_UNITS.has(quoteCurrency?.trim() ?? "") ? 100 : 1);
580
591
  }
581
592
 
582
593
  /**
@@ -7,8 +7,19 @@ export interface FxRateStatus {
7
7
  unknownTime: number;
8
8
  oldestAsOf: number | null;
9
9
  latestFetchedAt: number | null;
10
+ /** The pairs counted as unavailable and as stale (`TRY/USD`), so a label names them. */
11
+ unavailablePairs?: string[];
12
+ stalePairs?: string[];
13
+ /** The pair whose rate is the oldest (`oldestAsOf`). */
14
+ oldestPair?: string | null;
10
15
  }
11
16
 
17
+ /** A currency's rate as the pair it is read as: every rate is against the US dollar. */
18
+ const usdPair = (currency: string) => `${currency}/USD`;
19
+
20
+ /** Up to this many pairs are named; more are counted. */
21
+ const NAMED_PAIRS = 3;
22
+
12
23
  /** A rate whose last load failed, or whose observation is past its stale time. */
13
24
  export function isFxRateStale(entry: QueryEntry<number> | null | undefined, now = Date.now()): boolean {
14
25
  return Boolean(entry?.error || (entry?.staleAt != null && entry.staleAt <= now));
@@ -21,27 +32,39 @@ export function summarizeFxRates(
21
32
  read: (currency: string) => QueryEntry<number> | null | undefined,
22
33
  now = Date.now(),
23
34
  ): FxRateStatus {
24
- const status: FxRateStatus = { loading: 0, unavailable: 0, stale: 0, unknownTime: 0, oldestAsOf: null, latestFetchedAt: null };
35
+ const status: FxRateStatus = { loading: 0, unavailable: 0, stale: 0, unknownTime: 0, oldestAsOf: null, latestFetchedAt: null,
36
+ unavailablePairs: [], stalePairs: [], oldestPair: null };
25
37
  for (const currency of new Set(currencies.map((value) => value.trim().toUpperCase()))) {
26
38
  if (currency === "USD") continue;
27
39
  const entry = read(currency);
28
40
  if (entry?.phase === "loading" || entry?.phase === "refreshing") status.loading++;
29
41
  const rate = rates.get(currency);
30
- if (rate == null || !Number.isFinite(rate) || rate <= 0) { status.unavailable++; continue; }
42
+ if (rate == null || !Number.isFinite(rate) || rate <= 0) { status.unavailable++; status.unavailablePairs!.push(usdPair(currency)); continue; }
31
43
  // A legacy persisted numeric rate may be present without a dated query.
32
44
  if (!entry || entry.asOf == null || !Number.isFinite(entry.asOf)) status.unknownTime++;
33
- else status.oldestAsOf = Math.min(status.oldestAsOf ?? Infinity, entry.asOf);
34
- if (isFxRateStale(entry, now)) status.stale++;
45
+ else if (status.oldestAsOf == null || entry.asOf < status.oldestAsOf) {
46
+ status.oldestAsOf = entry.asOf;
47
+ status.oldestPair = usdPair(currency);
48
+ }
49
+ if (isFxRateStale(entry, now)) { status.stale++; status.stalePairs!.push(usdPair(currency)); }
35
50
  if (entry?.fetchedAt != null) status.latestFetchedAt = Math.max(status.latestFetchedAt ?? 0, entry.fetchedAt);
36
51
  }
37
52
  return status;
38
53
  }
39
54
 
55
+ /** `TRY/USD` or `TRY/USD, EGP/USD` when few enough are named, else their count. */
56
+ function pairsText(count: number, pairs: readonly string[] | undefined): string {
57
+ return pairs && pairs.length === count && count <= NAMED_PAIRS ? pairs.join(", ") : String(count);
58
+ }
59
+
60
+ /** `TRY/USD stale · oldest rate TRY/USD 2026-11-12 03:49 UTC`: each pair named, as a footer has room for, else counted. */
40
61
  export function fxStatusLabel(status: FxRateStatus): string {
41
62
  const parts: string[] = [];
42
- if (status.unavailable) parts.push(`${status.unavailable} unavailable`);
43
- if (status.stale) parts.push(`${status.stale} stale`);
63
+ if (status.unavailable) parts.push(`${pairsText(status.unavailable, status.unavailablePairs)} unavailable`);
64
+ if (status.stale) parts.push(`${pairsText(status.stale, status.stalePairs)} stale`);
44
65
  if (status.unknownTime) parts.push(`${status.unknownTime} rate ${status.unknownTime === 1 ? "time" : "times"} unknown`);
45
- if (status.oldestAsOf != null) parts.push(`oldest rate ${new Date(status.oldestAsOf).toISOString().slice(0, 16).replace("T", " ")} UTC`);
66
+ if (status.oldestAsOf != null) {
67
+ parts.push(`oldest rate ${status.oldestPair ? `${status.oldestPair} ` : ""}${new Date(status.oldestAsOf).toISOString().slice(0, 16).replace("T", " ")} UTC`);
68
+ }
46
69
  return parts.join(" · ");
47
70
  }
@@ -78,6 +78,29 @@ export function isNetworkFailure(error: unknown): boolean {
78
78
  return false;
79
79
  }
80
80
 
81
+ /** Codes of a connection that closed under a request: Node's and the system's, then Bun's. */
82
+ const DROPPED_CODES = new Set(["ECONNRESET", "ECONNABORTED", "EPIPE", "ConnectionClosed"]);
83
+
84
+ /**
85
+ * Whether a request failed because its connection closed under it (Bun's "The
86
+ * socket connection was closed unexpectedly"): what a server restarting, or a
87
+ * proxy moving to new servers, does to the requests caught on it, and asking
88
+ * again moments later reaches a server that answers. A refused connection, a
89
+ * timeout or an abort is not one: those say the service, or the network, is
90
+ * not there, and asking again at once would not change that.
91
+ */
92
+ export function isDroppedConnection(error: unknown): boolean {
93
+ if (error instanceof DataServiceUnreachableError) return false;
94
+ for (let current = error, depth = 0; current && typeof current === "object" && depth < 4; depth += 1) {
95
+ if (cameFromServer(current)) return false;
96
+ const { name, code } = current as { name?: unknown; code?: unknown };
97
+ if (name === "AbortError" || name === "TimeoutError") return false;
98
+ if (typeof code === "string" && DROPPED_CODES.has(code)) return true;
99
+ current = (current as { cause?: unknown }).cause;
100
+ }
101
+ return false;
102
+ }
103
+
81
104
  /** A network failure as `DataServiceUnreachableError`; anything else as it was. */
82
105
  export function asDataServiceFailure(error: unknown): unknown {
83
106
  return isNetworkFailure(error) && !(error instanceof DataServiceUnreachableError)