@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
@@ -27,7 +27,9 @@ import { isPlainArrowUp, stopSearchFocusNavigation } from "../../../utils/search
27
27
  import { cycleSortPreference, nextHeaderSort } from "../../../utils/sort-values";
28
28
  import { usePluginPaneState } from "../../runtime";
29
29
  import { useAsyncResource } from "../../../react/async-resource";
30
- import { useAutoRefresh } from "../../../react/auto-refresh";
30
+ import { useAutoRefresh, useUtcDay } from "../../../react/auto-refresh";
31
+ import { reportFooterSegment } from "../shared/source-footer";
32
+ import { treasuryAuctionsHeadless } from "./headless";
31
33
  import { useCommandValue } from "../shared/command-tab";
32
34
  import { FIXED_INCOME_PANE_ID } from "../fixed-income/model";
33
35
  import {
@@ -46,8 +48,8 @@ import {
46
48
  auctionHistoryPhrase,
47
49
  auctionHistoryWindow,
48
50
  auctionSize,
49
- auctionSortColumn,
50
51
  buildAuctionColumns,
52
+ compactTerm,
51
53
  dealerPct,
52
54
  directPct,
53
55
  firstAuctionSortDirection,
@@ -58,6 +60,7 @@ import {
58
60
  isPendingAuction,
59
61
  nextAuctionHistoryWindow,
60
62
  nextFilter,
63
+ parseAuctionSort,
61
64
  rateLabel,
62
65
  rateValue,
63
66
  middleRateLabel,
@@ -76,6 +79,7 @@ import {
76
79
  } from "./types";
77
80
  import { AUCTION_MARKETS, isAuctionMarket, type AuctionMarket } from "./hk";
78
81
  import { HkTendersView } from "./hk-view";
82
+ import { auctionViewHints } from "./keys";
79
83
 
80
84
  function formatRate(value: number | null): string {
81
85
  return value == null ? "—" : `${value.toFixed(3)}%`;
@@ -132,6 +136,10 @@ function secTypeColor(secType: string, selected: boolean): string {
132
136
  /** An announced auction's Rate in the table, the word other panes use for a figure not out yet (KPI's Later actual). */
133
137
  const RESULTS_PENDING = "Pending";
134
138
 
139
+ const PERCENTILE_KEYS = {
140
+ stopOutPctl: "stopOutPercentile", btcPctl: "btcPercentile", indirectPctl: "indirectPercentile", dealerPctl: "dealerPercentile",
141
+ } as const;
142
+
135
143
  // Stable table adapter so memoized rows survive pane re-renders.
136
144
  const auctionKey = (auction: TreasuryAuction) => auction.id;
137
145
 
@@ -160,7 +168,7 @@ function renderAuctionCell(
160
168
  attributes: TextAttributes.BOLD,
161
169
  };
162
170
  case "term":
163
- return { text: auction.securityTerm, color: selected ?? colors.text };
171
+ return { text: column.compact ? compactTerm(auction.securityTerm) : auction.securityTerm, color: selected ?? colors.text };
164
172
  case "rate":
165
173
  // An announced auction says its results are pending, as its detail does; other metric cells stay "—".
166
174
  return isPendingAuction(auction)
@@ -180,10 +188,11 @@ function renderAuctionCell(
180
188
  return { text: formatMoney(auctionSize(auction)), color: dimmed };
181
189
  case "cusip":
182
190
  return { text: auction.cusip ?? "", color: dimmed };
191
+ case "stopOutPctl":
183
192
  case "btcPctl":
184
193
  case "indirectPctl":
185
194
  case "dealerPctl": {
186
- const key = column.id === "btcPctl" ? "btcPercentile" : column.id === "indirectPctl" ? "indirectPercentile" : "dealerPercentile";
195
+ const key = PERCENTILE_KEYS[column.id];
187
196
  const value = after?.[key] ?? null;
188
197
  return { text: value == null ? "" : String(value), value, color: selected ?? colors.text };
189
198
  }
@@ -238,6 +247,10 @@ function TreasuryAuctionDetail({ auction, width, after }: { auction: TreasuryAuc
238
247
  <KeyValueRow labelWidth={22} width={Math.max(1, width - 2)} emphasis={false} label="Primary dealer" value={share(auction.primaryDealerAccepted, auction.competitiveAccepted)} />
239
248
  {after && <>
240
249
  <Box height={1} />
250
+ {stopOutVsAvgBp(auction) != null && (
251
+ <KeyValueRow labelWidth={22} width={Math.max(1, width - 2)} emphasis={false} label={`${stopOutLabel(auction)} pctl`}
252
+ value={after.stopOutPercentile == null ? "—" : String(after.stopOutPercentile)} />
253
+ )}
241
254
  <KeyValueRow labelWidth={22} width={Math.max(1, width - 2)} emphasis={false} label="B/C percentile" value={after.btcPercentile == null ? "—" : String(after.btcPercentile)} />
242
255
  <KeyValueRow labelWidth={22} width={Math.max(1, width - 2)} emphasis={false} label="Indirect percentile" value={after.indirectPercentile == null ? "—" : String(after.indirectPercentile)} />
243
256
  <KeyValueRow labelWidth={22} width={Math.max(1, width - 2)} emphasis={false} label="Dealer percentile" value={after.dealerPercentile == null ? "—" : String(after.dealerPercentile)} />
@@ -253,13 +266,17 @@ function TreasuryAuctionDetail({ auction, width, after }: { auction: TreasuryAuc
253
266
 
254
267
  const NO_AUCTIONS: TreasuryAuction[] = [];
255
268
 
256
- /** A sort as kept in pane state and typed after --sort: the column's name, and `:asc` or `:desc` once the pane flips it. */
269
+ /**
270
+ * A sort as kept in pane state and typed after --sort: the column's name, `-`
271
+ * first for the other way round (`-indirect-pctl`, lowest first), and `:asc`
272
+ * or `:desc` once the pane flips it.
273
+ */
257
274
  function readSort(value: string | null): AuctionSortPreference | null {
258
275
  if (!value) return null;
259
276
  const [name, direction] = value.split(":");
260
- const columnId = auctionSortColumn(name ?? "");
261
- if (!columnId) return null;
262
- return { columnId, direction: direction === "asc" || direction === "desc" ? direction : firstAuctionSortDirection(columnId) };
277
+ const sort = parseAuctionSort(name ?? "");
278
+ if (!sort) return null;
279
+ return direction === "asc" || direction === "desc" ? { columnId: sort.columnId, direction } : sort;
263
280
  }
264
281
 
265
282
  function writeSort(sort: AuctionSortPreference): string | null {
@@ -393,6 +410,8 @@ function UsAuctionsView({
393
410
  const columns = next === "after" ? AUCTION_AFTER_SORT_COLUMN_IDS : AUCTION_SORT_COLUMN_IDS;
394
411
  if (!columns.includes(sortPreference.columnId)) setSortValue(null);
395
412
  }, [setSortValue, setView, sortPreference.columnId]);
413
+ const toggleView = useCallback(() => selectView(view === "after" ? "results" : "after"), [selectView, view]);
414
+ const toggleMarket = useCallback(() => marketFilter.onChange("hk"), [marketFilter]);
396
415
 
397
416
  usePaneRefreshKey(() => resource.reload(), { focused, enabled: !searchFocused });
398
417
 
@@ -422,7 +441,7 @@ function UsAuctionsView({
422
441
  return handlePaneKey(event);
423
442
  }, [focusSearch, handlePaneKey]);
424
443
 
425
- const showYear = auctionDatesShowYear(historyDays);
444
+ const showYear = useMemo(() => auctionDatesShowYear(rows.map((auction) => auction.auctionDate)), [rows]);
426
445
  // A table that scrolls down keeps a cell for its scrollbar.
427
446
  const columns = useMemo(() => buildAuctionColumns({ showYear, view, rows, width: width - 1 }), [rows, showYear, view, width]);
428
447
  const renderAuctionRow = useCallback((
@@ -432,12 +451,15 @@ function UsAuctionsView({
432
451
  rowState: { selected: boolean },
433
452
  ) => renderAuctionCell(auction, column, rowState, showYear, after?.get(auction.id)), [after, showYear]);
434
453
 
454
+ const utcDay = useUtcDay();
435
455
  usePaneFooter(TREASURY_AUCTIONS_PANE_ID, () => {
436
456
  const info = loadingErrorFooterInfo(loading, error);
437
457
  if (yieldsError) info.push({ id: "yields", parts: [{ text: "Treasury yields unavailable", tone: "warning" as const }] });
438
458
  if (savedAt != null) info.push(...savedCopyFooterInfo([savedAt]));
439
459
  else if (stale) info.push(STALE_SEGMENT);
440
460
  if (fetchedAt && savedAt == null) {
461
+ // Its source and the newest auction listed, as `fn AUCT` ends; how long ago it loaded goes first on a narrow row.
462
+ if (rows.length) info.push(reportFooterSegment(treasuryAuctionsHeadless, { rows: rows.map((auction) => ({ auctionDate: auction.auctionDate })) }));
441
463
  info.push(ageFooterSegment(formatRelativeAge(fetchedAt)));
442
464
  }
443
465
  return {
@@ -447,24 +469,30 @@ function UsAuctionsView({
447
469
  : [
448
470
  { id: "search", key: "/", label: "search", onPress: focusSearch },
449
471
  { id: "filter", key: "f", label: "ilter", onPress: cycleFilter },
472
+ ...auctionViewHints({ view, toggleView, market: "us", toggleMarket, cycleSort }),
450
473
  ],
451
474
  };
452
475
  }, [
453
476
  auctions.length,
454
477
  cycleFilter,
478
+ cycleSort,
479
+ toggleMarket,
480
+ toggleView,
481
+ view,
455
482
  detailOpen,
456
483
  error,
457
484
  yieldsError,
458
485
  fetchedAt,
459
486
  focusSearch,
460
487
  loading,
488
+ rows,
461
489
  savedAt,
462
490
  stale,
491
+ utcDay,
463
492
  ]);
464
493
 
465
- // The pane menu names the sort keys; "Sort by…" there picks a column directly.
494
+ // The footer's [] steps to the next sort column; the pane menu names the way back. "Sort by…" there picks a column directly.
466
495
  usePaneMenuItems("treasury-auctions:sort-keys", () => detailOpen || auctions.length === 0 ? null : [
467
- { id: "sort-next", label: "Next Sort Column", accelerator: "]", onSelect: () => cycleSort(1) },
468
496
  { id: "sort-previous", label: "Previous Sort Column", accelerator: "[", onSelect: () => cycleSort(-1) },
469
497
  ], [auctions.length, cycleSort, detailOpen]);
470
498
 
@@ -1,6 +1,7 @@
1
1
  import { DataTableView, Notice, type DataTableColumn } from "../../../components";
2
2
  import { turbo } from "../../../components/chart/surface3d/model";
3
3
  import { useThemeColors } from "../../../theme/theme-context";
4
+ import { useSelectionFill } from "../../../components/ui/selection-fill";
4
5
  import { Box, Text } from "../../../ui";
5
6
  import { deltaLabel, tenorLabel, type SurfaceCell, type VolatilitySurfaceGrid } from "./raster";
6
7
 
@@ -74,6 +75,7 @@ export interface SurfaceHeatGridProps {
74
75
  */
75
76
  export function SurfaceHeatGrid({ grid, range, ticks, selected, onSelect, width, height, notice }: SurfaceHeatGridProps) {
76
77
  const colors = useThemeColors();
78
+ const selectionFill = useSelectionFill();
77
79
  const shown = heatGridColumns(grid.moneyness, width);
78
80
  const columns: DataTableColumn[] = [{ id: "tenor", label: "Expiry", width: LABEL_WIDTH, align: "left" },
79
81
  ...shown.map((column) => ({ id: String(column), label: grid.axis === "delta" ? deltaLabel(grid.moneyness[column]!) : `${Math.round(grid.moneyness[column]! * 100)}%`,
@@ -84,7 +86,8 @@ export function SurfaceHeatGrid({ grid, range, ticks, selected, onSelect, width,
84
86
  const first = ticks[0], last = ticks.at(-1);
85
87
  return <Box flexDirection="column" width={width} height={height} data-gloom-role="surface-grid" data-gloom-surface-renderer="grid">
86
88
  {notice ? <Box paddingX={1}><Notice tone="muted">{notice}</Notice></Box> : null}
87
- <DataTableView<HeatRow> rootWidth={width} rootHeight={Math.max(2, height - 1 - noticeRows)} columns={columns} items={rows}
89
+ {/* Moneyness or delta in order across the tenors: the surface's axis. */}
90
+ <DataTableView<HeatRow> rootWidth={width} rootHeight={Math.max(2, height - 1 - noticeRows)} columns={columns} columnReorder={false} items={rows}
88
91
  getItemKey={(row) => String(row.index)}
89
92
  selection={{ kind: "id", selectedId: selected ? String(selected.tenorIndex) : null, getId: (row) => String(row.index),
90
93
  onChange: (_id, row) => onSelect({ tenorIndex: row.index, moneynessIndex: selected?.moneynessIndex ?? 0 }) }}
@@ -97,8 +100,8 @@ export function SurfaceHeatGrid({ grid, range, ticks, selected, onSelect, width,
97
100
  const onMouseDown = () => onSelect({ tenorIndex: row.index, moneynessIndex: index });
98
101
  if (value == null || !Number.isFinite(value)) return { text: "--", color: colors.textMuted, onMouseDown };
99
102
  const fill = surfaceColorHex(value, range);
100
- return { text: (value * 100).toFixed(1), color: chosen ? colors.selectedText : surfaceTextColor(fill),
101
- backgroundColor: chosen ? colors.selected : fill, onMouseDown };
103
+ return { text: (value * 100).toFixed(1), color: chosen ? (selectionFill.lit ? colors.selectedText : selectionFill.ink(colors.textBright)) : surfaceTextColor(fill),
104
+ backgroundColor: chosen ? selectionFill.bg : fill, onMouseDown };
102
105
  }} emptyStateTitle="No volatility observations." />
103
106
  <Box flexDirection="row" height={1} gap={1} paddingX={1} flexShrink={0} data-gloom-role="surface-legend">
104
107
  <Box flexShrink={0}><Text fg={colors.textDim}>{first?.label ?? ""}</Text></Box>
@@ -12,6 +12,7 @@ import { useShortcut } from "../../../react/input";
12
12
  import { usePaneSettingValue, usePluginAppActions, usePluginPaneState } from "../../../public/react";
13
13
  import { blendHex } from "../../../theme/color-utils";
14
14
  import { useThemeColors } from "../../../theme/theme-context";
15
+ import { useSelectionFill } from "../../../components/ui/selection-fill";
15
16
  import type { PaneProps } from "../../../types/plugin";
16
17
  import { Box, useUiCapabilities, type ScrollBoxRenderable } from "../../../ui";
17
18
  import { FILL_REST } from "../../../components/ui/fill";
@@ -84,6 +85,8 @@ type Axis = "spot" | "forward" | "delta" | "strike";
84
85
 
85
86
  export function VolSurfacePane({ focused, width, height }: PaneProps) {
86
87
  const colors = useThemeColors();
88
+ // The chosen cell is the table's cursor: quieter while the pane does not have the keys.
89
+ const selectionFill = useSelectionFill();
87
90
  const { symbol, ticker, financials } = usePaneTicker();
88
91
  const { createPaneFromTemplate } = usePluginAppActions();
89
92
  const target = resolveOptionsTarget(ticker);
@@ -500,7 +503,8 @@ export function VolSurfacePane({ focused, width, height }: PaneProps) {
500
503
  return sort.direction === "asc" ? delta : -delta;
501
504
  });
502
505
  const table = <DataTableView<SurfaceGridRow> focused={focused} rootWidth={width} rootHeight={tableHeight}
503
- columns={columns} items={sortedRows} getItemKey={(row) => row.label} scrollRef={scrollRef} onBodyScrollActivity={onScroll}
506
+ // Moneyness or delta in order across the tenors: the surface's axis.
507
+ columns={columns} columnReorder={false} items={sortedRows} getItemKey={(row) => row.label} scrollRef={scrollRef} onBodyScrollActivity={onScroll}
504
508
  sortColumnId={sort.columnId} sortDirection={sort.direction} onHeaderClick={(id) => setSort((current) => nextHeaderSort(current, id))}
505
509
  selection={{ kind: "id", selectedId: tableSelectedRow?.label ?? null, getId: (row) => row.label, onChange: (_id, row) => onSelectRow(row) }}
506
510
  onActivate={onSelectRow} onRootKeyDown={handleKey} getExportMetadata={exportMetadata} freezeFirstColumn
@@ -510,8 +514,8 @@ export function VolSurfacePane({ focused, width, height }: PaneProps) {
510
514
  if (column.id === "tenor") return { text: tenorLabel(row), color: colors.textDim };
511
515
  const index = Number(column.id), cell = row.cells[index]!;
512
516
  const chosen = row.label === tableSelectedRow?.label && index === tableCellIndex;
513
- return { text: formatIv(cell.volatility), color: chosen ? colors.selectedText : colors.textBright,
514
- backgroundColor: chosen ? colors.selected : cell.volatility == null ? colors.bg : blendHex(colors.bg, cell.volatility > 0.5 ? colors.warning : colors.positive, Math.min(0.48, 0.08 + cell.volatility * 0.5)),
517
+ return { text: formatIv(cell.volatility), color: chosen ? (selectionFill.lit ? colors.selectedText : selectionFill.ink(colors.textBright)) : colors.textBright,
518
+ backgroundColor: chosen ? selectionFill.bg : cell.volatility == null ? colors.bg : blendHex(colors.bg, cell.volatility > 0.5 ? colors.warning : colors.positive, Math.min(0.48, 0.08 + cell.volatility * 0.5)),
515
519
  onMouseDown: () => { onSelectRow(row); setCoordinate(cell.coordinate); } };
516
520
  }} emptyStateTitle="No volatility observations." />;
517
521
  const reopen = !shownDate && closedUnfitted ? usOptionsReopen(Date.now()) : null;
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useState } from "react";
2
- import { DataTableView, type DataTableVisibleRange } from "../../../components";
2
+ import { DataTableView, type DataTableColumnReorder, type DataTableVisibleRange } from "../../../components";
3
3
  import type { PaneProps } from "../../../types/plugin";
4
4
  import type { PluginModule } from "../plugin-module";
5
5
  import { TICKER_RESEARCH_PANE_ID } from "../../../types/config";
@@ -39,6 +39,8 @@ function renderRegionHeader(row: WorldIndexTableRow) {
39
39
  return row.type === "header" ? { text: REGION_LABELS[row.region] } : null;
40
40
  }
41
41
 
42
+ const WORLD_INDEX_COLUMN_REORDER: DataTableColumnReorder = { anchored: 2 };
43
+
42
44
  function WorldIndicesPane({ focused, width, height }: PaneProps) {
43
45
  const { pinTicker } = usePluginTickerActions();
44
46
  const dataProvider = useAssetData();
@@ -124,6 +126,8 @@ function WorldIndicesPane({ focused, width, height }: PaneProps) {
124
126
  rootWidth={width}
125
127
  rootHeight={height}
126
128
  columns={columns}
129
+ // The session mark and the index name the row, whether or not the mark has a heading at this width.
130
+ columnReorder={WORLD_INDEX_COLUMN_REORDER}
127
131
  items={dataProvider ? flatRows : []}
128
132
  sortable
129
133
  sortColumnId={sortPreference.columnId}
@@ -471,7 +471,8 @@ function WorldTab({ onOpen, focused, width, height }: {
471
471
  <PaneStatusBody loading={loading && !data} error={!data ? error : null} loadingLabel="Loading world curves..." subject="world curves">
472
472
  <DataTableView<WorldRow>
473
473
  focused={focused} rootWidth={width} rootHeight={height}
474
- columns={WORLD_COLUMNS} items={rows} getItemKey={worldKey} renderCell={renderCell}
474
+ // Maturities in order, each beside its own change.
475
+ columns={WORLD_COLUMNS} columnReorder={false} items={rows} getItemKey={worldKey} renderCell={renderCell}
475
476
  selection={{ kind: "id", selectedId, getId: worldKey, onChange: (id) => setSelected(id) }}
476
477
  onActivate={(row) => onOpen(row.id)} sortColumnId={null} sortDirection="asc"
477
478
  emptyStateTitle="No curves yet."
@@ -15,6 +15,7 @@ export {
15
15
  setPluginPaneStateValue,
16
16
  useDebouncedPluginPaneState,
17
17
  usePluginConfigState,
18
+ usePluginPaneChoice,
18
19
  usePluginPaneState,
19
20
  usePluginState,
20
21
  usePrunePluginPaneState,
@@ -17,6 +17,7 @@ import { usePluginRenderContext } from "./context";
17
17
  const DEFAULT_PLUGIN_PANE_STATE_COMMIT_DELAY_MS = 300;
18
18
 
19
19
  import { deletePluginPaneStateValue, getPluginPaneStateValue } from "../../layout/pane-state";
20
+ import { isPaneChoice, pluginChoiceKey } from "../../core/state/app/pane-choices";
20
21
  export { deletePluginPaneStateValue, getPluginPaneStateValue, setPluginPaneStateValue } from "../../layout/pane-state";
21
22
 
22
23
  /**
@@ -84,6 +85,25 @@ export function usePluginPaneState<T>(key: string, fallback: T, paneId?: string)
84
85
  return [value, setValue];
85
86
  }
86
87
 
88
+ /**
89
+ * Whether this plugin's pane-state `key` was chosen in this session rather
90
+ * than restored with the workspace, and the call for a pick that may leave the
91
+ * value as it is (see `pane-choices.ts`). Any write of the key already counts.
92
+ */
93
+ export function usePluginPaneChoice(key: string, paneId?: string): [chosen: boolean, choose: () => void] {
94
+ const { pluginId } = usePluginRenderContext();
95
+ const contextPaneId = useOptionalPaneInstanceId();
96
+ const scopedPaneId = paneId ?? contextPaneId;
97
+ if (!scopedPaneId) throw new Error("usePluginPaneChoice requires a pane id or PaneInstanceProvider");
98
+ const dispatch = useAppDispatch();
99
+ const choiceKey = pluginChoiceKey(pluginId, key);
100
+ const chosen = useAppSelector((state) => isPaneChoice(state, scopedPaneId, choiceKey));
101
+ const choose = useCallback(() => {
102
+ dispatch({ type: "CHOOSE_PANE_STATE", paneId: scopedPaneId, key: choiceKey });
103
+ }, [choiceKey, dispatch, scopedPaneId]);
104
+ return [chosen, choose];
105
+ }
106
+
87
107
  export function useDebouncedPluginPaneState<T>(
88
108
  key: string,
89
109
  fallback: T,
@@ -398,6 +398,9 @@ function headlineChangePercent(
398
398
  return quote ? (getCompletedRegularSessionDisplay(quote) ?? quote).changePercent : undefined;
399
399
  }
400
400
 
401
+ /** The 52W% cell's muted mark for a range read from the stored daily bars (Quote.yearRangeBasis). */
402
+ export const RANGE_FROM_BARS_NOTE = "bars";
403
+
401
404
  function fiftyTwoWeekPosition(displayQuote: ActiveQuoteDisplay | null, quote: TickerFinancials["quote"]): number | null {
402
405
  const range = displayQuote ? liveFiftyTwoWeekRange(quote, displayQuote.price) : null;
403
406
  return displayQuote && range ? ((displayQuote.price - range.low) / (range.high - range.low)) * 100 : null;
@@ -560,7 +563,7 @@ export function getColumnValue(
560
563
  ticker: TickerRecord,
561
564
  financials: TickerFinancials | undefined,
562
565
  ctx: ColumnContext,
563
- ): { text: string; color?: string; value?: number | string | null; valueUnit?: string; pnlBasis?: PortfolioPositionPnl["basis"] } {
566
+ ): { text: string; note?: string; color?: string; value?: number | string | null; valueUnit?: string; pnlBasis?: PortfolioPositionPnl["basis"] } {
564
567
  const sent = financials?.quote;
565
568
 
566
569
  const fundamentals = financials?.fundamentals;
@@ -679,7 +682,10 @@ export function getColumnValue(
679
682
  }
680
683
  case "range_52w": {
681
684
  const position = fiftyTwoWeekPosition(displayQuote, quote);
682
- return { text: position == null ? "—" : formatPercentRaw(Math.max(0, Math.min(100, position))) };
685
+ if (position == null) return { text: "—" };
686
+ // A range the service read from the stored daily bars, the source's being no year's, says so as the ticker pane does.
687
+ return { text: formatPercentRaw(Math.max(0, Math.min(100, position))),
688
+ ...(quote?.yearRangeBasis === "daily-bars" ? { note: RANGE_FROM_BARS_NOTE } : {}) };
683
689
  }
684
690
  case "market_cap": {
685
691
  const cap = liveMarketCapitalization(quote, fundamentals);
@@ -258,8 +258,10 @@ exports[`the runtime exports of every public subpath are the reviewed ones 1`] =
258
258
  "ConnectionHealthRegistry",
259
259
  "DEFAULT_MAX_READ_IDS",
260
260
  "PaneInstanceProvider",
261
+ "countEscapeTowardClose",
261
262
  "deletePluginPaneStateValue",
262
263
  "getPluginPaneStateValue",
264
+ "keepEscapeFromClosing",
263
265
  "markPersistedReadId",
264
266
  "normalizePersistedReadIdState",
265
267
  "resolveTickerForPane",
@@ -290,6 +292,7 @@ exports[`the runtime exports of every public subpath are the reviewed ones 1`] =
290
292
  "usePaneTicker",
291
293
  "usePaneTickerIdentity",
292
294
  "usePaneTitle",
295
+ "usePaneUnsentWork",
293
296
  "usePaneVisible",
294
297
  "usePersistedReadIds",
295
298
  "usePluginAppActions",
@@ -373,6 +376,8 @@ exports[`the runtime exports of every public subpath are the reviewed ones 1`] =
373
376
  "getThemeColors",
374
377
  "hoverBg",
375
378
  "hoverText",
379
+ "inactiveSelectedBg",
380
+ "inactiveSelectedText",
376
381
  "paneBg",
377
382
  "paneTitleBg",
378
383
  "paneTitleText",
@@ -72,6 +72,13 @@ export type { PaneTickerIdentity } from "./pane-hooks";
72
72
  // Keyboard handling for plugin panes; the renderer decides how events arrive.
73
73
  export { useShortcut } from "../react/input";
74
74
 
75
+ // What a pane's Esc does to the close (see Esc in docs/pane-conventions.md):
76
+ // an Esc that closes a menu of the pane's own is kept from closing the pane,
77
+ // an Esc that leaves an empty field counts toward it, and a pane holding a
78
+ // draft or an answer still coming in is never closed by Esc at all.
79
+ export { countEscapeTowardClose, keepEscapeFromClosing } from "../utils/double-escape-close";
80
+ export { usePaneUnsentWork } from "../state/pane-unsent-work";
81
+
75
82
  // The size of the surface the app is drawing into. A pane that pages or
76
83
  // virtualizes its own rows needs it, and it has to come from the renderer:
77
84
  // terminal cells, desktop pixels, and a browser tab are all different.
@@ -36,6 +36,35 @@ export function useAgeClock(since: number | null): number {
36
36
  return now;
37
37
  }
38
38
 
39
+ const UTC_DAY_MS = 86_400_000;
40
+
41
+ /**
42
+ * Today's UTC date (`2026-11-12`), which moves at each UTC midnight while the
43
+ * pane can be seen and catches up when it can. A footer that leaves the day
44
+ * off a time of today (`Gloom Cloud · 12:25 UTC`) reads it again with this
45
+ * among its inputs, so a pane left open overnight names the day
46
+ * (`Thu 12 Nov 12:25 UTC`).
47
+ */
48
+ export function useUtcDay(): string {
49
+ const visible = usePaneVisible();
50
+ const [clock, setClock] = useState(() => Date.now());
51
+ const day = new Date(clock).toISOString().slice(0, 10);
52
+
53
+ useEffect(() => {
54
+ if (!visible) return;
55
+ const now = Date.now();
56
+ if (new Date(now).toISOString().slice(0, 10) !== day) {
57
+ setClock(now);
58
+ return;
59
+ }
60
+ // A timer that fires a moment early sets the same day, and this runs again for the next.
61
+ const timer = setTimeout(() => setClock(Date.now()), UTC_DAY_MS - (now % UTC_DAY_MS) + 1_000);
62
+ return () => clearTimeout(timer);
63
+ }, [clock, day, visible]);
64
+
65
+ return day;
66
+ }
67
+
39
68
  export interface AutoRefreshOptions {
40
69
  /**
41
70
  * Cadence for a pane whose data moves faster than research data, such as a
@@ -19,15 +19,34 @@ function consumeHandoffParams(search: string, keys: string[]): void {
19
19
  history.replaceState(history.state, "", url);
20
20
  }
21
21
 
22
- export function createBrowserDeepLinkBridge(): DesktopDeepLinkBridge {
22
+ /** How this page was opened: "navigate", "reload" or "back_forward". */
23
+ function pageNavigationType(): string | undefined {
24
+ try {
25
+ const [entry] = globalThis.performance?.getEntriesByType?.("navigation") ?? [];
26
+ return (entry as PerformanceNavigationTiming | undefined)?.type;
27
+ } catch {
28
+ // Intentional ignore: without the timing API the page counts as opened from its address.
29
+ return undefined;
30
+ }
31
+ }
32
+
33
+ export function createBrowserDeepLinkBridge(navigationType: () => string | undefined = pageNavigationType): DesktopDeepLinkBridge {
23
34
  // Restoring a saved pane can update the address before App subscribes.
24
35
  // Keep the incoming link intact until it has been delivered once.
25
36
  const initialSearch = window.location.search;
37
+ // A reload, or a return through history, brings back the saved workspace the
38
+ // address was written from. Its tab asks for nothing: the pane keeps the tab
39
+ // it saved, and one only Pro opens stays behind a free one (pane-choices.ts).
40
+ const restoring = (() => {
41
+ const type = navigationType();
42
+ return type === "reload" || type === "back_forward";
43
+ })();
26
44
  return {
27
45
  subscribe(listener) {
28
46
  let initial = true;
29
47
  const emit = () => {
30
- const search = initial ? initialSearch : window.location.search;
48
+ const first = initial;
49
+ const search = first ? initialSearch : window.location.search;
31
50
  initial = false;
32
51
  const layoutId = marketplaceLayoutIdFromSearch(search);
33
52
  if (layoutId) {
@@ -49,7 +68,9 @@ export function createBrowserDeepLinkBridge(): DesktopDeepLinkBridge {
49
68
  return;
50
69
  }
51
70
  const entry = researchEntryFromSearch(search);
52
- if (entry) listener({ url: `gloomberb://ticker/${encodeURIComponent(entry.symbol)}?tab=${entry.tab}` });
71
+ if (!entry) return;
72
+ const symbolUrl = `gloomberb://ticker/${encodeURIComponent(entry.symbol)}`;
73
+ listener({ url: restoring && first ? symbolUrl : `${symbolUrl}?tab=${entry.tab}` });
53
74
  };
54
75
  emit();
55
76
  window.addEventListener("popstate", emit);
@@ -0,0 +1,147 @@
1
+ import { useCallback, useEffect, useRef, useState, type MouseEvent as ReactMouseEvent, type RefObject } from "react";
2
+ import { COLUMN_DRAG_THRESHOLD_PX, columnDropBoundary, columnDropIndex } from "../../../components/ui/data-table/column-order";
3
+ import { hideDragShield, showDragShield } from "../host/drag-shield";
4
+
5
+ /** A header being dragged: the column's index, and where the drop line stands in the table's content (null where it would stay). */
6
+ export interface WebColumnDrag {
7
+ from: number;
8
+ dropLeft: number | null;
9
+ }
10
+
11
+ /** How near the body's side edge the pointer scrolls a wide table toward it while it drags a column, and how far each frame. */
12
+ const AUTO_SCROLL_EDGE_PX = 24;
13
+ const AUTO_SCROLL_STEP_PX = 8;
14
+
15
+ interface Span {
16
+ start: number;
17
+ end: number;
18
+ }
19
+
20
+ /** Where the line between two columns stands: in the middle of the gap, or just past the last column. */
21
+ function dropLineX(spans: readonly Span[], boundary: number): number | null {
22
+ const before = spans[boundary - 1];
23
+ const after = spans[boundary];
24
+ if (before && after) return (before.end + after.start) / 2;
25
+ const gap = spans.length > 1 ? Math.max(0, spans[1]!.start - spans[0]!.end) : 0;
26
+ if (before) return before.end + gap / 2;
27
+ if (after) return after.start - gap / 2;
28
+ return null;
29
+ }
30
+
31
+ /**
32
+ * A press on a movable header: released where it was, it sorts as a click
33
+ * does; moved past a few pixels, it drags the column, an accent line marks
34
+ * the gap it would drop into, and the release moves it there. A table wider
35
+ * than its body scrolls while the pointer holds at its side edge. Escape, or
36
+ * the window losing focus, puts the column back.
37
+ */
38
+ export function useWebColumnDrag({
39
+ contentRef,
40
+ bodyRef,
41
+ anchoredColumns,
42
+ onColumnMove,
43
+ onHeaderClick,
44
+ }: {
45
+ contentRef: RefObject<HTMLDivElement | null>;
46
+ bodyRef: RefObject<HTMLDivElement | null>;
47
+ anchoredColumns: number;
48
+ onColumnMove?: (columnId: string, toIndex: number) => void;
49
+ onHeaderClick?: (columnId: string) => void;
50
+ }) {
51
+ const [drag, setDrag] = useState<WebColumnDrag | null>(null);
52
+ const cleanupRef = useRef<(() => void) | null>(null);
53
+ const latest = useRef({ anchoredColumns, onColumnMove, onHeaderClick });
54
+ latest.current = { anchoredColumns, onColumnMove, onHeaderClick };
55
+ useEffect(() => () => cleanupRef.current?.(), []);
56
+
57
+ const startPress = useCallback((columnId: string, from: number, event: ReactMouseEvent<HTMLElement>) => {
58
+ cleanupRef.current?.();
59
+ const startX = event.clientX;
60
+ let pointerX = startX;
61
+ let dragging = false;
62
+ let frame = 0;
63
+ const measure = () => {
64
+ const cells = contentRef.current?.querySelectorAll<HTMLElement>(
65
+ '[data-gloom-role="data-table-header-row"] > [data-gloom-role="data-table-header-cell"]',
66
+ ) ?? [];
67
+ const spans = [...cells].map((cell) => {
68
+ const bounds = cell.getBoundingClientRect();
69
+ return { start: bounds.left, end: bounds.right };
70
+ });
71
+ // A frozen first column stays put while the others scroll under it: nothing drops among those it covers.
72
+ const frozenEnd = cells[0]?.style.position === "sticky" ? spans[0]?.end : undefined;
73
+ return { spans, frozenEnd, boundary: columnDropBoundary(spans, pointerX, latest.current.anchoredColumns, frozenEnd) };
74
+ };
75
+ const show = () => {
76
+ const { spans, frozenEnd, boundary } = measure();
77
+ const content = contentRef.current?.getBoundingClientRect();
78
+ const gapX = columnDropIndex(from, boundary) === null ? null : dropLineX(spans, boundary);
79
+ const lineX = gapX === null || frozenEnd === undefined ? gapX : Math.max(gapX, frozenEnd);
80
+ const dropLeft = lineX === null || !content ? null : lineX - content.left;
81
+ setDrag((current) => current?.from === from && current.dropLeft === dropLeft ? current : { from, dropLeft });
82
+ };
83
+ const autoScroll = () => {
84
+ frame = requestAnimationFrame(autoScroll);
85
+ const body = bodyRef.current;
86
+ if (!body || body.scrollWidth <= body.clientWidth) return;
87
+ const bounds = body.getBoundingClientRect();
88
+ const step = pointerX < bounds.left + AUTO_SCROLL_EDGE_PX ? -AUTO_SCROLL_STEP_PX
89
+ : pointerX > bounds.right - AUTO_SCROLL_EDGE_PX ? AUTO_SCROLL_STEP_PX : 0;
90
+ if (step === 0) return;
91
+ const before = body.scrollLeft;
92
+ body.scrollLeft = before + step;
93
+ if (body.scrollLeft !== before) show();
94
+ };
95
+ const cleanup = () => {
96
+ document.removeEventListener("mousemove", handleMove, true);
97
+ document.removeEventListener("mouseup", handleUp, true);
98
+ window.removeEventListener("keydown", handleKey, true);
99
+ window.removeEventListener("blur", cleanup);
100
+ cancelAnimationFrame(frame);
101
+ if (dragging) hideDragShield();
102
+ cleanupRef.current = null;
103
+ setDrag(null);
104
+ };
105
+ const handleMove = (moveEvent: MouseEvent) => {
106
+ if (moveEvent.buttons === 0) {
107
+ cleanup();
108
+ return;
109
+ }
110
+ pointerX = moveEvent.clientX;
111
+ if (!dragging) {
112
+ if (Math.abs(pointerX - startX) < COLUMN_DRAG_THRESHOLD_PX) return;
113
+ dragging = true;
114
+ showDragShield();
115
+ frame = requestAnimationFrame(autoScroll);
116
+ }
117
+ moveEvent.preventDefault();
118
+ show();
119
+ };
120
+ const handleUp = (upEvent: MouseEvent) => {
121
+ pointerX = upEvent.clientX;
122
+ const wasDragging = dragging;
123
+ const { boundary } = measure();
124
+ cleanup();
125
+ const { onColumnMove: move, onHeaderClick: sort } = latest.current;
126
+ if (!wasDragging) {
127
+ sort?.(columnId);
128
+ return;
129
+ }
130
+ const to = columnDropIndex(from, boundary);
131
+ if (to !== null) move?.(columnId, to);
132
+ };
133
+ const handleKey = (keyEvent: KeyboardEvent) => {
134
+ if (keyEvent.key !== "Escape" || !dragging) return;
135
+ keyEvent.preventDefault();
136
+ keyEvent.stopPropagation();
137
+ cleanup();
138
+ };
139
+ document.addEventListener("mousemove", handleMove, true);
140
+ document.addEventListener("mouseup", handleUp, true);
141
+ window.addEventListener("keydown", handleKey, true);
142
+ window.addEventListener("blur", cleanup);
143
+ cleanupRef.current = cleanup;
144
+ }, [bodyRef, contentRef]);
145
+
146
+ return { drag, startPress };
147
+ }