@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
@@ -48,19 +48,86 @@ export interface PaneHeaderStack {
48
48
  onTabMouseDown?: (id: string, event: any) => void;
49
49
  }
50
50
 
51
+ /** Terminal: the least a tab that is not shown keeps when a stack is cut to fit: a letter and the ellipsis. */
52
+ const STACK_TAB_MIN_WIDTH = 4;
53
+ /** Terminal: between the last tab named and the count of those left out. */
54
+ const STACK_TAB_MORE_GAP = " ";
55
+
56
+ /** Terminal: one tab of a stack as its header lays it out (`stackTabSpans`). */
57
+ export interface StackTabSpan {
58
+ /** The tab's place in the stack; for the `more` count, the tab a press on it shows. */
59
+ index: number;
60
+ /** Cells from where the title starts (after the grip). */
61
+ start: number;
62
+ text: string;
63
+ /** The count of the tabs left out (`+2`), which a press steps through. */
64
+ more?: true;
65
+ }
66
+
51
67
  /**
52
- * Terminal: each tab of a stack in its header, as text and where it starts,
53
- * in cells from where the title starts (after the grip). The pointer runtime
54
- * finds the tab under a press with it.
68
+ * Terminal: the tabs of a stack its header shows in `width` cells, as text
69
+ * and where each starts, in cells from where the title starts (after the
70
+ * grip); `index` is the tab's place in the stack. Every tab shows when they
71
+ * fit. When they do not, the tab shown (`activeIndex`) keeps its name, as
72
+ * many others as keep a letter each share what is left, in tab order, and a
73
+ * dim `+n` after them counts the rest. A press on the count shows the first
74
+ * tab left out after the one shown, so pressing it again steps through them.
75
+ * The header always names what the pane shows; the count goes first when
76
+ * there is no room for it beside a letter of that name. The pointer runtime
77
+ * finds the tab under a press with the same spans.
55
78
  */
56
- export function stackTabSpans(titles: readonly string[]): Array<{ start: number; text: string }> {
79
+ export function stackTabSpans(
80
+ titles: readonly string[],
81
+ activeIndex = -1,
82
+ width = Number.POSITIVE_INFINITY,
83
+ ): StackTabSpan[] {
84
+ const labels = titles.map((title) => truncateToDisplayWidth(title, STACK_TAB_MAX_WIDTH));
85
+ const separator = STACK_TAB_SEPARATOR.length;
86
+ const natural = labels.reduce((sum, label) => sum + displayWidth(label), 0) + separator * Math.max(0, labels.length - 1);
87
+ let texts: Array<string | null> = labels;
88
+ let more: { index: number; text: string } | null = null;
89
+ if (natural > width && activeIndex >= 0 && activeIndex < labels.length) {
90
+ const shownLabel = labels[activeIndex]!;
91
+ const others = labels.map((_, index) => index).filter((index) => index !== activeIndex);
92
+ const moreWidth = (count: number) => (count > 0 ? STACK_TAB_MORE_GAP.length + `+${count}`.length : 0);
93
+ let kept: number[] = [];
94
+ let share = 0;
95
+ for (let keep = others.length; keep >= 1; keep -= 1) {
96
+ const room = width - displayWidth(shownLabel) - separator * keep - moreWidth(others.length - keep);
97
+ if (Math.floor(room / keep) >= STACK_TAB_MIN_WIDTH) {
98
+ kept = others.slice(0, keep);
99
+ share = Math.floor(room / keep);
100
+ break;
101
+ }
102
+ }
103
+ const left = others.filter((index) => !kept.includes(index));
104
+ const count = left.length > 0 ? `+${left.length}` : null;
105
+ let shown = shownLabel;
106
+ if (kept.length === 0) {
107
+ const room = width - moreWidth(left.length);
108
+ shown = truncateToDisplayWidth(shownLabel, room >= Math.min(STACK_TAB_MIN_WIDTH, displayWidth(shownLabel)) ? room : width);
109
+ }
110
+ texts = labels.map((label, index) => (
111
+ index === activeIndex ? shown : kept.includes(index) ? truncateToDisplayWidth(label, share) : null
112
+ ));
113
+ const used = texts.reduce<number>((sum, text) => sum + (text === null ? 0 : displayWidth(text)), 0)
114
+ + separator * kept.length;
115
+ if (count && used + moreWidth(left.length) <= width) {
116
+ more = { index: left.find((index) => index > activeIndex) ?? left[0]!, text: count };
117
+ }
118
+ }
57
119
  let start = 0;
58
- return titles.map((title) => {
59
- const text = truncateToDisplayWidth(title, STACK_TAB_MAX_WIDTH);
60
- const span = { start, text };
61
- start += displayWidth(text) + STACK_TAB_SEPARATOR.length;
62
- return span;
120
+ const spans: StackTabSpan[] = [];
121
+ texts.forEach((text, index) => {
122
+ if (text === null) return;
123
+ spans.push({ index, start, text });
124
+ start += displayWidth(text) + separator;
63
125
  });
126
+ if (more) {
127
+ const last = spans.at(-1);
128
+ spans.push({ index: more.index, start: last ? last.start + displayWidth(last.text) + STACK_TAB_MORE_GAP.length : 0, text: more.text, more: true });
129
+ }
130
+ return spans;
64
131
  }
65
132
 
66
133
  /** Terminal: the cells before a header's title: the grip, after the corner a focused or floating pane draws. */
@@ -68,21 +135,52 @@ export function paneHeaderTitleStart(framed: boolean): number {
68
135
  return (framed ? 2 : 0) + PANE_HEADER_GRIP.length;
69
136
  }
70
137
 
71
- /** Terminal: how wide a stack's tabs are, all of them. */
72
- function stackTabsWidth(stack: PaneHeaderStack): number {
73
- const last = stackTabSpans(stack.tabs.map((tab) => tab.title)).at(-1);
74
- return last ? last.start + displayWidth(last.text) : 0;
138
+ /** Terminal: what a header's quick settings, lock and `?` take after its title. */
139
+ export function terminalHeaderTrailingWidth(
140
+ quickSettings: ReadonlyArray<Pick<PaneHeaderQuickSetting, "icon">>,
141
+ locked: boolean,
142
+ help: boolean,
143
+ ): number {
144
+ return quickSettings.reduce((total, setting) => total + displayWidth(quickSettingText(setting)), 0)
145
+ + (locked ? displayWidth(PANE_HEADER_LOCK) : 0)
146
+ + (help ? PANE_HEADER_HELP.length : 0);
75
147
  }
76
148
 
77
- /** Terminal: a stack's tabs in at most `width` cells (all of them with `pad`), the shown one in `activeFg`, the rest dim. */
78
- function TerminalStackTabs({ stack, width, activeFg, pad }: { stack: PaneHeaderStack; width: number; activeFg: string; pad: boolean }) {
79
- const spans = stackTabSpans(stack.tabs.map((tab) => tab.title));
149
+ /**
150
+ * Terminal: the cells a header leaves its title (or a stack's tabs): its
151
+ * width less the frame a focused, floating or fullscreen pane draws, the
152
+ * grip, what follows the title (`trailing`), the menu and the corner mark a
153
+ * floating or fullscreen pane has.
154
+ */
155
+ export function terminalHeaderTitleWidth(
156
+ width: number,
157
+ { framed, corner, trailing }: { framed: boolean; corner: boolean; trailing: number },
158
+ ): number {
159
+ const frame = framed ? 4 : 0;
160
+ const cornerWidth = corner ? PANE_HEADER_CLOSE.length : 0;
161
+ return Math.max(0, width - frame - PANE_HEADER_GRIP.length - trailing - PANE_HEADER_ACTION.length - cornerWidth);
162
+ }
163
+
164
+ /** Terminal: a stack's tabs as `stackTabSpans` lays them out, the shown one in `activeFg`, the rest dim, padded to `width` with `pad`. */
165
+ function TerminalStackTabs({ stack, spans, width, activeFg, pad }: {
166
+ stack: PaneHeaderStack;
167
+ spans: ReturnType<typeof stackTabSpans>;
168
+ width: number;
169
+ activeFg: string;
170
+ pad: boolean;
171
+ }) {
172
+ let left = width;
80
173
  const parts: Array<{ key: string; text: string; fg: string }> = [];
81
- stack.tabs.forEach((tab, index) => {
82
- if (index > 0) parts.push({ key: `sep:${tab.id}`, text: STACK_TAB_SEPARATOR, fg: colors.border });
83
- parts.push({ key: tab.id, text: spans[index]!.text, fg: tab.id === stack.active ? activeFg : colors.textDim });
174
+ spans.forEach((span, position) => {
175
+ if (span.more) {
176
+ parts.push({ key: "more-gap", text: STACK_TAB_MORE_GAP, fg: colors.textDim });
177
+ parts.push({ key: "more", text: span.text, fg: colors.textDim });
178
+ return;
179
+ }
180
+ const tab = stack.tabs[span.index]!;
181
+ if (position > 0) parts.push({ key: `sep:${tab.id}`, text: STACK_TAB_SEPARATOR, fg: colors.border });
182
+ parts.push({ key: tab.id, text: span.text, fg: tab.id === stack.active ? activeFg : colors.textDim });
84
183
  });
85
- let left = width;
86
184
  return (
87
185
  <>
88
186
  {parts.map((part) => {
@@ -95,6 +193,17 @@ function TerminalStackTabs({ stack, width, activeFg, pad }: { stack: PaneHeaderS
95
193
  );
96
194
  }
97
195
 
196
+ /** The place of the tab a stack shows among its tabs. */
197
+ function stackActiveIndex(stack: PaneHeaderStack): number {
198
+ return stack.tabs.findIndex((tab) => tab.id === stack.active);
199
+ }
200
+
201
+ /** Terminal: how wide a stack's tabs are as laid out. */
202
+ function stackSpansWidth(spans: ReturnType<typeof stackTabSpans>): number {
203
+ const last = spans.at(-1);
204
+ return last ? last.start + displayWidth(last.text) : 0;
205
+ }
206
+
98
207
  interface PaneHeaderProps {
99
208
  title: string;
100
209
  /**
@@ -296,8 +405,7 @@ export function PaneHeader({
296
405
  const closeText = fullscreen ? PANE_HEADER_RESTORE : floating ? PANE_HEADER_CLOSE : "";
297
406
  const onCornerMouseDown = fullscreen ? onRestoreMouseDown : onCloseMouseDown;
298
407
  const lockText = locked ? PANE_HEADER_LOCK : "";
299
- const terminalQuickSettingsWidth = quickSettings.reduce((total, setting) => total + displayWidth(quickSettingText(setting)), 0)
300
- + displayWidth(lockText) + helpText.length;
408
+ const terminalQuickSettingsWidth = terminalHeaderTrailingWidth(quickSettings, locked, !!onHelpMouseDown);
301
409
  const textColor = paneTitleText(visuallyFocused, floating);
302
410
  const tickerAt = titleTicker ? findTitleTicker(title, titleTicker) : null;
303
411
  const topInset = topRule ? 1 : 0;
@@ -551,10 +659,10 @@ export function PaneHeader({
551
659
  // Fullscreen draws "-" in that corner. Reserve 2 for the frame.
552
660
  const borderColor = visuallyFocused ? colors.borderFocused : colors.border;
553
661
  const innerWidth = Math.max(0, width - 4);
554
- const contentWidth = PANE_HEADER_GRIP.length + terminalQuickSettingsWidth + closeText.length + actionText.length;
555
- const titleWidth = Math.max(0, innerWidth - contentWidth);
662
+ const titleWidth = terminalHeaderTitleWidth(width, { framed: true, corner: closeText.length > 0, trailing: terminalQuickSettingsWidth });
556
663
  const clippedTitle = truncateToDisplayWidth(title, titleWidth);
557
- const fillLen = Math.max(0, innerWidth - PANE_HEADER_GRIP.length - (stack ? Math.min(titleWidth, stackTabsWidth(stack)) : displayWidth(clippedTitle)) - terminalQuickSettingsWidth - actionText.length - closeText.length);
664
+ const spans = stack ? stackTabSpans(stack.tabs.map((tab) => tab.title), stackActiveIndex(stack), titleWidth) : null;
665
+ const fillLen = Math.max(0, innerWidth - PANE_HEADER_GRIP.length - (spans ? Math.min(titleWidth, stackSpansWidth(spans)) : displayWidth(clippedTitle)) - terminalQuickSettingsWidth - actionText.length - closeText.length);
558
666
  const fill = "─".repeat(fillLen);
559
667
 
560
668
  return (
@@ -570,10 +678,10 @@ export function PaneHeader({
570
678
  onMouseDragEnd={onHeaderMouseDragEnd}
571
679
  >
572
680
  <Text fg={borderColor} selectable={false}>{"┌─"}</Text>
573
- {stack ? (
681
+ {stack && spans ? (
574
682
  <>
575
683
  <Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
576
- <TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad={false} />
684
+ <TerminalStackTabs stack={stack} spans={spans} width={titleWidth} activeFg={textColor} pad={false} />
577
685
  </>
578
686
  ) : (
579
687
  <Text fg={textColor} selectable={false}>{`${PANE_HEADER_GRIP}${clippedTitle}`}</Text>
@@ -587,7 +695,7 @@ export function PaneHeader({
587
695
  onMouseDown={setting.onMouseDown}
588
696
  />
589
697
  ))}
590
- <Text fg={borderColor} selectable={false}>{fill}</Text>
698
+ {fill && <Text fg={borderColor} selectable={false}>{fill}</Text>}
591
699
  {locked && (
592
700
  <TerminalPaneButton text={lockText} fg={colors.textMuted} role="pane-lock" />
593
701
  )}
@@ -613,8 +721,9 @@ export function PaneHeader({
613
721
  );
614
722
  }
615
723
 
616
- const titleWidth = Math.max(0, width - PANE_HEADER_GRIP.length - terminalQuickSettingsWidth - actionText.length - closeText.length);
724
+ const titleWidth = terminalHeaderTitleWidth(width, { framed: false, corner: closeText.length > 0, trailing: terminalQuickSettingsWidth });
617
725
  const clippedTitle = truncateToDisplayWidth(title, titleWidth);
726
+ const spans = stack ? stackTabSpans(stack.tabs.map((tab) => tab.title), stackActiveIndex(stack), titleWidth) : null;
618
727
  const padding = " ".repeat(Math.max(0, titleWidth - displayWidth(clippedTitle)));
619
728
 
620
729
  return (
@@ -629,10 +738,10 @@ export function PaneHeader({
629
738
  onMouseDrag={onHeaderMouseDrag}
630
739
  onMouseDragEnd={onHeaderMouseDragEnd}
631
740
  >
632
- {stack ? (
741
+ {stack && spans ? (
633
742
  <>
634
743
  <Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
635
- <TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad />
744
+ <TerminalStackTabs stack={stack} spans={spans} width={titleWidth} activeFg={textColor} pad />
636
745
  </>
637
746
  ) : (
638
747
  <Text fg={textColor} selectable={false}>
@@ -1,8 +1,10 @@
1
- import { createContext, startTransition, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
2
- import { Box, Text, useNativeRenderer, useUiCapabilities, type BoxRenderable } from "../../../ui";
1
+ import { createContext, startTransition, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
2
+ import { Box, Text, useNativeRenderer, useUiCapabilities, useUiHost, type BoxRenderable, type ScrollBoxRenderable } from "../../../ui";
3
+ import { afterLayout, revealInScrollBox } from "../../ui/reveal-in-scroll-box";
4
+ import { observeScrollBoxContentSize, observeScrollBoxViewportSize } from "../../../renderers/opentui/scrollbox-layout";
3
5
  import { beginLiveResize, createCatchUp, type CatchUp } from "../../../ui/live-resize";
4
6
  import { capturePointerDrag } from "../../../ui/pointer-drag";
5
- import { blendHex, colors, hoverBg } from "../../../theme/colors";
7
+ import { blendHex, colors, hoverBg, inactiveSelectedBg } from "../../../theme/colors";
6
8
  import { t } from "../../../i18n";
7
9
  import { usePaneFooter } from "./footer/registration";
8
10
 
@@ -26,10 +28,15 @@ const WIDEN_KEY = ">";
26
28
  export interface PaneSidebarRenderState {
27
29
  backgroundColor: string;
28
30
  listWidth: number;
31
+ /**
32
+ * The fill of the row the sidebar shows as chosen, the one its `PaneSidebarRow`s
33
+ * draw: lit while the sidebar has the keys, the inactive selection otherwise.
34
+ * A row a sidebar draws itself (a section heading under the cursor) takes it too.
35
+ */
36
+ activeBackgroundColor: string;
29
37
  }
30
38
 
31
39
  interface PaneSidebarContextValue extends PaneSidebarRenderState {
32
- activeBackgroundColor: string;
33
40
  keyboardFocused: boolean;
34
41
  }
35
42
 
@@ -37,7 +44,7 @@ const PaneSidebarContext = createContext<PaneSidebarContextValue | null>(null);
37
44
 
38
45
  function usePaneSidebarContext(): PaneSidebarContextValue {
39
46
  const context = useContext(PaneSidebarContext);
40
- if (!context) throw new Error("PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
47
+ if (!context) throw new Error("PaneSidebarList, PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
41
48
  return context;
42
49
  }
43
50
 
@@ -217,12 +224,15 @@ export function PaneSidebar({
217
224
  const backgroundColor = keyboardFocused
218
225
  ? blendHex(colors.panel, colors.borderFocused, 0.18)
219
226
  : colors.panel;
227
+ // Without the keys, the terminal's inactive selection, as every list there
228
+ // has; the desktop keeps the light tint its sidebars always had (its lists
229
+ // keep the full selection, see useSelectionFill).
220
230
  const activeBackgroundColor = keyboardFocused
221
231
  ? blendHex(colors.selected, colors.borderFocused, 0.32)
222
- : blendHex(colors.panel, colors.selected, 0.35);
232
+ : nativePaneChrome ? blendHex(colors.panel, colors.selected, 0.35) : inactiveSelectedBg(colors);
223
233
  const sidebarLayoutHeight = nativePaneChrome ? "100%" : height;
224
234
  const nativeFillStyle = nativePaneChrome ? { minHeight: 0 } : undefined;
225
- const renderState = { backgroundColor, listWidth };
235
+ const renderState = { backgroundColor, listWidth, activeBackgroundColor };
226
236
  const dividerActive = resizing || dividerHovered;
227
237
  const resizeHandlers = resize && {
228
238
  onMouseDown: beginResize,
@@ -233,7 +243,7 @@ export function PaneSidebar({
233
243
  };
234
244
 
235
245
  return (
236
- <PaneSidebarContext.Provider value={{ ...renderState, activeBackgroundColor, keyboardFocused }}>
246
+ <PaneSidebarContext.Provider value={{ ...renderState, keyboardFocused }}>
237
247
  <Box
238
248
  ref={sidebarRef}
239
249
  width={width}
@@ -309,20 +319,125 @@ export function PaneSidebar({
309
319
  );
310
320
  }
311
321
 
312
- export function PaneSidebarList({ children }: { children: ReactNode }) {
322
+ interface PaneSidebarListContextValue {
323
+ /** Marks `node` as the row the list keeps in view, and brings it there. */
324
+ setCurrent: (node: BoxRenderable | null) => void;
325
+ }
326
+
327
+ const PaneSidebarListContext = createContext<PaneSidebarListContextValue | null>(null);
328
+
329
+ /**
330
+ * Keeps the row `ref` is on in view while it is `current`: the row the
331
+ * keyboard is on, or the open item. Rows outside a PaneSidebarList, and the
332
+ * desktop list, which scrolls by CSS, ignore it.
333
+ */
334
+ export function usePaneSidebarReveal(ref: RefObject<BoxRenderable | null>, current: boolean): void {
335
+ const list = useContext(PaneSidebarListContext);
336
+ useLayoutEffect(() => {
337
+ if (!list || !current) return;
338
+ list.setCurrent(ref.current);
339
+ return () => list.setCurrent(null);
340
+ }, [current, list, ref]);
341
+ }
342
+
343
+ export interface PaneSidebarListRenderState {
344
+ /** The width a row has beside the list's scrollbar, while it shows one. */
345
+ listWidth: number;
346
+ }
347
+
348
+ /**
349
+ * The scrolling part of a sidebar. The wheel scrolls it, a scrollbar shows
350
+ * while it holds more rows than fit, and the row a `PaneSidebarRow` marks
351
+ * `active` (or `usePaneSidebarReveal` marks current) stays in view as the
352
+ * keyboard moves it.
353
+ */
354
+ export function PaneSidebarList({ children }: { children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode) }) {
313
355
  const { nativePaneChrome } = useUiCapabilities();
356
+ const sidebar = usePaneSidebarContext();
357
+ if (nativePaneChrome) {
358
+ return (
359
+ <Box
360
+ flexGrow={1}
361
+ flexShrink={1}
362
+ flexBasis={0}
363
+ minHeight={0}
364
+ data-gloom-role="pane-sidebar-list"
365
+ style={{ minHeight: 0, overflowX: "hidden", overflowY: "auto" }}
366
+ >
367
+ {typeof children === "function" ? children({ listWidth: sidebar.listWidth }) : children}
368
+ </Box>
369
+ );
370
+ }
371
+ return <TerminalPaneSidebarList sidebar={sidebar}>{children}</TerminalPaneSidebarList>;
372
+ }
373
+
374
+ function TerminalPaneSidebarList({ sidebar, children }: {
375
+ sidebar: PaneSidebarContextValue;
376
+ children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode);
377
+ }) {
378
+ // The host's own ScrollBox, which the pane scroll keys do not drive: the
379
+ // list's keys move its cursor, and the pane's bring the cursor into view.
380
+ const { ScrollBox } = useUiHost();
381
+ const scrollRef = useRef<ScrollBoxRenderable | null>(null);
382
+ const currentRef = useRef<BoxRenderable | null>(null);
383
+ const [scrollbar, setScrollbar] = useState(false);
384
+ const reveal = useCallback(() => afterLayout(() => revealInScrollBox(scrollRef.current, currentRef.current)), []);
385
+ const list = useMemo<PaneSidebarListContextValue>(() => ({
386
+ setCurrent: (node) => {
387
+ currentRef.current = node;
388
+ if (node) reveal();
389
+ },
390
+ }), [reveal]);
391
+ // The scrollbar shows once the rows outgrow the list, and takes a column
392
+ // from them. Read once the whole pass is laid out: the content is at least
393
+ // as tall as the viewport, and is not yet sized to it when the viewport
394
+ // reports.
395
+ const syncScrollbar = useCallback(() => afterLayout(() => {
396
+ const scrollBox = scrollRef.current;
397
+ if (!scrollBox) return;
398
+ const viewportHeight = scrollBox.viewport?.height ?? 0;
399
+ setScrollbar(viewportHeight > 0 && scrollBox.scrollHeight > viewportHeight);
400
+ }), []);
401
+ // A list that opens, or is made shorter or taller, brings the row under the
402
+ // cursor back into view. Rows coming and going, and the scrollbar taking a
403
+ // column, leave the scroll where the wheel put it.
404
+ const viewportHeightRef = useRef(0);
405
+ const syncViewport = useCallback(() => {
406
+ syncScrollbar();
407
+ const height = scrollRef.current?.viewport?.height ?? 0;
408
+ if (height === viewportHeightRef.current) return;
409
+ viewportHeightRef.current = height;
410
+ reveal();
411
+ }, [reveal, syncScrollbar]);
412
+ useEffect(() => observeScrollBoxViewportSize(scrollRef.current, syncViewport), [syncViewport]);
413
+ useEffect(() => observeScrollBoxContentSize(scrollRef.current, syncScrollbar), [syncScrollbar]);
414
+ // In the same frame as the rows narrow or widen for it.
415
+ useLayoutEffect(() => {
416
+ const bar = scrollRef.current?.verticalScrollBar;
417
+ if (bar) bar.visible = scrollbar;
418
+ }, [scrollbar]);
419
+ const listWidth = Math.max(1, sidebar.listWidth - (scrollbar ? 1 : 0));
420
+ const context = useMemo(() => ({ ...sidebar, listWidth }), [sidebar, listWidth]);
421
+
314
422
  return (
315
- <Box
316
- flexGrow={1}
317
- flexShrink={1}
318
- flexBasis={0}
319
- minHeight={0}
320
- overflow={nativePaneChrome ? undefined : "hidden"}
321
- data-gloom-role="pane-sidebar-list"
322
- style={nativePaneChrome ? { minHeight: 0, overflowX: "hidden", overflowY: "auto" } : undefined}
323
- >
324
- {children}
325
- </Box>
423
+ <PaneSidebarContext.Provider value={context}>
424
+ <PaneSidebarListContext.Provider value={list}>
425
+ <ScrollBox
426
+ ref={scrollRef}
427
+ flexGrow={1}
428
+ flexShrink={1}
429
+ flexBasis={0}
430
+ minHeight={0}
431
+ scrollY
432
+ focusable={false}
433
+ verticalScrollbarOptions={{ visible: false }}
434
+ horizontalScrollbarOptions={{ visible: false }}
435
+ data-gloom-role="pane-sidebar-list"
436
+ >
437
+ {typeof children === "function" ? children({ listWidth }) : children}
438
+ </ScrollBox>
439
+ </PaneSidebarListContext.Provider>
440
+ </PaneSidebarContext.Provider>
326
441
  );
327
442
  }
328
443
 
@@ -349,6 +464,8 @@ export function PaneSidebarRow({
349
464
  }) {
350
465
  const { activeBackgroundColor, backgroundColor, keyboardFocused, listWidth } = usePaneSidebarContext();
351
466
  const [hovered, setHovered] = useState(false);
467
+ const rowRef = useRef<BoxRenderable>(null);
468
+ usePaneSidebarReveal(rowRef, active);
352
469
  const foregroundColor = active
353
470
  ? colors.selectedText
354
471
  : keyboardFocused
@@ -369,6 +486,7 @@ export function PaneSidebarRow({
369
486
 
370
487
  return (
371
488
  <Box
489
+ ref={rowRef}
372
490
  height={height}
373
491
  width={listWidth}
374
492
  flexDirection="row"
@@ -28,7 +28,9 @@ function buildPaneStatusInfo({
28
28
  stale = false,
29
29
  info = EMPTY_STATUS_INFO,
30
30
  }: PaneStatusInfoOptions): PaneFooterSegment[] {
31
- return [...info, ...(stale ? [STALE_SEGMENT] : []), ...loadingErrorFooterInfo(loading, error)];
31
+ // A source line that already says its data is stale (`stale (23 days old)`) is not followed by a second `stale`.
32
+ const saysStale = info.some((segment) => segment.asOf && /\bstale\b/.test(segment.parts.map((part) => part.text).join("")));
33
+ return [...info, ...(stale && !saysStale ? [STALE_SEGMENT] : []), ...loadingErrorFooterInfo(loading, error)];
32
34
  }
33
35
 
34
36
  /**
@@ -39,6 +39,7 @@ import {
39
39
  NO_LATCH,
40
40
  snapMovedRect,
41
41
  snapResizedRect,
42
+ TERMINAL_MAGNET_REST_MS,
42
43
  type MagnetDistances,
43
44
  type MagnetGlide,
44
45
  type MagnetLatch,
@@ -203,15 +204,16 @@ export function useShellActiveDrag({
203
204
  return { rect, partners: rects };
204
205
  };
205
206
  const magnetArea = { x: 0, y: 0, width, height: contentHeight };
206
- // Desktop: past the travel speed a release lands the pane where the
207
- // pointer puts it, its magnets left out (the rest check runs the last move
208
- // again once the pointer has stopped, so a release then catches). What
209
- // they hold to still follows every move, so it rests where it would have.
207
+ // The move run again once the pointer rests. A release lands where the
208
+ // pane is drawn: no catch after it.
209
+ const runAgain = event.type === "drag" ? () => { if (dragRef.current === drag) handleRef.current(event); } : undefined;
210
+ // Past the travel speed a release lands the pane where the pointer puts
211
+ // it, its magnets left out (the rest check runs the last move again once
212
+ // the pointer has stopped, so a release then catches). What they hold to
213
+ // still follows every move, so it rests where it would have.
210
214
  const travelling = () => {
211
- if (!nativePaneChrome || drag.type !== "pane-drag") return false;
212
- // A release lands where the pane is drawn: no catch after it.
213
- const rest = event.type === "drag" ? () => { if (dragRef.current === drag) handleRef.current(event); } : undefined;
214
- return memo.pace.travelling({ t: performance.now(), x: preciseX, y: preciseShellY }, magnetDistances, rest);
215
+ if (drag.type !== "pane-drag") return false;
216
+ return memo.pace.travelling({ t: performance.now(), x: preciseX, y: preciseShellY }, magnetDistances, runAgain);
215
217
  };
216
218
  // Where a move lands the pane (`rect`), and where its magnets hold it as
217
219
  // the pointer slows down (`snapped`).
@@ -224,13 +226,16 @@ export function useShellActiveDrag({
224
226
  memo.latch = snapped.latch;
225
227
  return { rect: travelling() ? rect : snapped.rect, snapped: snapped.rect };
226
228
  };
227
- // Desktop: the moving pane is drawn under the pointer while it moves, and
228
- // where its magnets hold it once the pointer slows down to place it,
229
- // gliding between the two (the frames after the pointer stops carry the
230
- // glide on). The terminal draws where a release would land it.
229
+ // The moving pane is drawn under the pointer while it moves, and where
230
+ // its magnets hold it once the pointer slows down to place it. The
231
+ // desktop glides between the two (the frames after the pointer stops
232
+ // carry the glide on); the terminal steps onto the magnets, on the move
233
+ // run again once the pointer rests.
231
234
  const drawMove = (paneId: string, free: FloatingRect, moved: { rect: FloatingRect; snapped: FloatingRect }) => {
232
235
  if (!nativePaneChrome) {
233
- updateDragFloatingRect({ paneId, rect: moved.rect });
236
+ const placing = memo.pace.placing(performance.now(), magnetDistances);
237
+ updateDragFloatingRect({ paneId, rect: placing ? moved.snapped : free });
238
+ if (!placing && runAgain) memo.pace.rest(runAgain, TERMINAL_MAGNET_REST_MS);
234
239
  return;
235
240
  }
236
241
  const { snapped } = moved;
@@ -37,16 +37,17 @@ const MAGNET_RELEASE_PX = 12;
37
37
  const TERMINAL_MAGNETS: MagnetDistances = { catchX: 1, catchY: 1, releaseX: 2, releaseY: 2 };
38
38
 
39
39
  /**
40
- * Desktop: past this pointer speed, in catch distances a second (300 px/s),
41
- * a release lands the pane where the pointer puts it, its magnets left out.
40
+ * Past this pointer speed, in catch distances a second (300 px/s on the
41
+ * desktop, 37.5 cells in the terminal), a release lands the pane where the
42
+ * pointer puts it, its magnets left out.
42
43
  */
43
44
  const MAGNET_TRAVEL_SPEED = 300 / MAGNET_CATCH_PX;
44
45
  /**
45
- * Desktop: below this pointer speed (60 px/s, about a px a frame) the pointer
46
- * is placing the pane, and it is drawn where its magnets hold it; faster, it
47
- * is drawn under the pointer. Drawing the magnets at a hand's usual speed
48
- * held the pane on each line it crossed, then jumped it up to 18 px, which
49
- * read as a drag that lags and stutters.
46
+ * Below this pointer speed (60 px/s, about a px a frame) the pointer is
47
+ * placing the pane, and it is drawn where its magnets hold it; faster, it is
48
+ * drawn under the pointer. Drawing the magnets at a hand's usual speed held
49
+ * the pane on each line it crossed, then jumped it up to 18 px (three cells
50
+ * in the terminal), which read as a drag that lags and stutters.
50
51
  */
51
52
  const MAGNET_PLACE_SPEED = 60 / MAGNET_CATCH_PX;
52
53
  /**
@@ -59,6 +60,12 @@ const GLIDE_RATE = 35;
59
60
  const SPEED_WINDOW_MS = 64;
60
61
  /** How long the pointer rests before the magnets catch where it stopped, ms. */
61
62
  export const MAGNET_REST_MS = 80;
63
+ /**
64
+ * The same in the terminal, which hears from the pointer only as it enters
65
+ * another cell: a hand placing a window there crosses five or so a second, so
66
+ * a pause shorter than that is still a drag.
67
+ */
68
+ export const TERMINAL_MAGNET_REST_MS = 200;
62
69
 
63
70
  /** Where the pointer was during a move, in cells, and when (ms). */
64
71
  interface PointerSample {
@@ -75,7 +82,7 @@ function trackPointer(track: PointerSample[], sample: PointerSample): void {
75
82
  }
76
83
 
77
84
  /**
78
- * Desktop: when a moving pane's magnets act, over one drag. `travelling`
85
+ * When a moving pane's magnets act, over one drag. `travelling`
79
86
  * takes each move and says whether the pointer is on its way somewhere; while
80
87
  * it is, a release lands the pane where the pointer puts it, and `rest` (the
81
88
  * move run again) is set to run once the pointer has stopped for
@@ -90,6 +97,12 @@ export interface MagnetPace {
90
97
  travelling(sample: PointerSample, distances: MagnetDistances, rest?: () => void): boolean;
91
98
  /** Whether the pointer, as of `now`, moves slowly enough to be placing the pane: its magnets are drawn. */
92
99
  placing(now: number, distances: MagnetDistances): boolean;
100
+ /**
101
+ * Runs `onRest` once the pointer has stopped for `ms`, unless another event
102
+ * of the drag comes first: the terminal, which draws only when an event
103
+ * comes, draws the magnets that catch where it stopped.
104
+ */
105
+ rest(onRest: () => void, ms: number): void;
93
106
  /** Drops the rest check: another event of the drag came first. */
94
107
  cancel(): void;
95
108
  /** Forgets the pointer's path, for a new drag. */
@@ -106,6 +119,17 @@ export function createMagnetPace(): MagnetPace {
106
119
  rest = null;
107
120
  frame = null;
108
121
  };
122
+ const restThen = (onRest: () => void, ms = MAGNET_REST_MS) => {
123
+ cancel();
124
+ rest = setTimeout(() => {
125
+ rest = null;
126
+ if (typeof requestAnimationFrame !== "function") return onRest();
127
+ frame = requestAnimationFrame(() => {
128
+ frame = null;
129
+ onRest();
130
+ });
131
+ }, ms);
132
+ };
109
133
  return {
110
134
  travelling(sample, distances, onRest) {
111
135
  cancel();
@@ -113,19 +137,11 @@ export function createMagnetPace(): MagnetPace {
113
137
  // The same place again (a rest check, a repeated event) is not a move.
114
138
  if (!last || last.x !== sample.x || last.y !== sample.y) trackPointer(track, sample);
115
139
  if (pointerSpeed(track, sample.t, distances) <= MAGNET_TRAVEL_SPEED) return false;
116
- if (onRest) {
117
- rest = setTimeout(() => {
118
- rest = null;
119
- if (typeof requestAnimationFrame !== "function") return onRest();
120
- frame = requestAnimationFrame(() => {
121
- frame = null;
122
- onRest();
123
- });
124
- }, MAGNET_REST_MS);
125
- }
140
+ if (onRest) restThen(onRest);
126
141
  return true;
127
142
  },
128
143
  placing: (now, distances) => pointerSpeed(track, now, distances) < MAGNET_PLACE_SPEED,
144
+ rest: restThen,
129
145
  cancel,
130
146
  reset() {
131
147
  cancel();