@gloom-sh/terminal 0.20.9 → 0.20.11

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 (212) hide show
  1. package/package.json +1 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
  3. package/src/api-client/auth.ts +6 -0
  4. package/src/api-client/data.ts +1 -0
  5. package/src/api-client/earnings.ts +15 -0
  6. package/src/api-client/index.ts +14 -3
  7. package/src/api-client/socket-connection.ts +355 -0
  8. package/src/api-client/socket-features.ts +75 -0
  9. package/src/api-client/socket-frames.ts +161 -0
  10. package/src/api-client/socket-listeners.ts +207 -0
  11. package/src/api-client/socket-quotes.ts +332 -0
  12. package/src/api-client/socket.ts +150 -983
  13. package/src/api-client/types/account.ts +10 -0
  14. package/src/api-client/types/billing.ts +10 -0
  15. package/src/api-client/types/econ.ts +19 -7
  16. package/src/api-client/types/market.ts +7 -0
  17. package/src/api-client/types/screener.ts +2 -0
  18. package/src/brokers/signed-in/adapter.ts +19 -5
  19. package/src/brokers/signed-in/client.ts +13 -1
  20. package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
  21. package/src/cli/commands/market.ts +18 -8
  22. package/src/cli/commands/overview.ts +26 -7
  23. package/src/cli/commands/ticker.ts +40 -15
  24. package/src/cli/desktop-pane-shot.ts +39 -0
  25. package/src/cli/errors.ts +20 -3
  26. package/src/cli/fx-pair.ts +11 -2
  27. package/src/cli/history-rows.ts +34 -3
  28. package/src/cli/index.ts +1 -1
  29. package/src/cli/listing-arg.ts +51 -13
  30. package/src/cli/pane-functions/headless.ts +4 -2
  31. package/src/cli/pane-functions/index.ts +1 -0
  32. package/src/cli/pane-functions/resolver.ts +2 -1
  33. package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
  34. package/src/cli/pane-functions/screenshot-types.ts +4 -0
  35. package/src/components/chart/composite/chart-layout.ts +7 -4
  36. package/src/components/chart/composite/composite-chart.tsx +6 -16
  37. package/src/components/chart/composite/toolbar.tsx +258 -82
  38. package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
  39. package/src/components/chart/native/kitty/manager.ts +2 -0
  40. package/src/components/chart/native/surface/manager.ts +211 -11
  41. package/src/components/command-bar/list/model.ts +13 -0
  42. package/src/components/command-bar/panel/index.tsx +2 -13
  43. package/src/components/command-bar/panel/layout.ts +1 -7
  44. package/src/components/command-bar/panel/runtime.ts +0 -1
  45. package/src/components/command-bar/panel/types.ts +0 -2
  46. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
  47. package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
  48. package/src/components/command-bar/surface/index.tsx +10 -5
  49. package/src/components/command-bar/workflow/alert.ts +21 -7
  50. package/src/components/data-table/column-menu.tsx +89 -0
  51. package/src/components/data-table/sort-menu.tsx +9 -2
  52. package/src/components/data-table/table-pane.ts +3 -1
  53. package/src/components/data-table/view.tsx +33 -6
  54. package/src/components/form-modal/content.tsx +10 -0
  55. package/src/components/index.ts +1 -1
  56. package/src/components/layout/pane/footer/index.tsx +25 -11
  57. package/src/components/layout/pane/footer/model.ts +88 -21
  58. package/src/components/layout/pane/sidebar.tsx +125 -15
  59. package/src/components/layout/shell/active-drag.ts +18 -13
  60. package/src/components/layout/shell/drag/magnets.ts +34 -18
  61. package/src/components/metric-treemap/heat-surface.tsx +2 -1
  62. package/src/components/metric-treemap/index.tsx +3 -2
  63. package/src/components/ticker/list-table-view.tsx +5 -0
  64. package/src/components/ui/confirm-dialog.tsx +253 -7
  65. package/src/components/ui/data-table/column-order.ts +180 -0
  66. package/src/components/ui/data-table/index.tsx +13 -2
  67. package/src/components/ui/data-table/opentui/index.tsx +267 -23
  68. package/src/components/ui/data-table/opentui/model.ts +43 -4
  69. package/src/components/ui/data-table/types.ts +56 -0
  70. package/src/components/ui/data-table/use-column-order.ts +135 -0
  71. package/src/components/ui/index.ts +1 -1
  72. package/src/components/ui/list-view.tsx +4 -3
  73. package/src/components/ui/status.tsx +9 -6
  74. package/src/components/ui/table-layout.ts +120 -0
  75. package/src/docs/snapshot.json +39 -2
  76. package/src/i18n/es.ts +14 -0
  77. package/src/i18n/ja.ts +14 -0
  78. package/src/i18n/ko.ts +14 -0
  79. package/src/i18n/zh-cn.ts +14 -0
  80. package/src/i18n/zh-tw.ts +14 -0
  81. package/src/market-data/coordinator/index.ts +4 -3
  82. package/src/market-data/coordinator/quotes.ts +12 -4
  83. package/src/market-data/fx-closes.ts +14 -2
  84. package/src/market-data/market/change-basis.ts +35 -1
  85. package/src/market-data/market/status.ts +37 -0
  86. package/src/market-data/performance.ts +4 -1
  87. package/src/market-data/quotes/freshness.ts +12 -0
  88. package/src/market-data/quotes/live-valuation.ts +26 -3
  89. package/src/market-data/quotes/regular-session-valuation.ts +1 -1
  90. package/src/market-data/realized-volatility.ts +3 -0
  91. package/src/market-data/us-bond-market.ts +115 -0
  92. package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
  93. package/src/plugins/builtin/account-management/keyboard.ts +3 -0
  94. package/src/plugins/builtin/account-management/model.ts +1 -0
  95. package/src/plugins/builtin/account-management/pane.tsx +51 -5
  96. package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
  97. package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
  98. package/src/plugins/builtin/broker-manager/index.tsx +6 -6
  99. package/src/plugins/builtin/broker-manager/model.ts +15 -6
  100. package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
  101. package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
  102. package/src/plugins/builtin/broker-manager/table.ts +10 -4
  103. package/src/plugins/builtin/chat/sidebar.tsx +33 -16
  104. package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
  105. package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
  106. package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
  107. package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
  108. package/src/plugins/builtin/correlation/compute.ts +4 -3
  109. package/src/plugins/builtin/earnings/board-model.ts +33 -0
  110. package/src/plugins/builtin/earnings/board-table.ts +50 -11
  111. package/src/plugins/builtin/earnings/board.tsx +29 -13
  112. package/src/plugins/builtin/earnings/calendar.tsx +15 -3
  113. package/src/plugins/builtin/earnings/client.ts +4 -1
  114. package/src/plugins/builtin/earnings/headless.ts +27 -14
  115. package/src/plugins/builtin/econ/calendar-source.ts +3 -0
  116. package/src/plugins/builtin/equity-screener/live.ts +74 -18
  117. package/src/plugins/builtin/equity-screener/model.ts +19 -4
  118. package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
  119. package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
  120. package/src/plugins/builtin/equity-screener/results.ts +22 -2
  121. package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
  122. package/src/plugins/builtin/futures/index.tsx +15 -1
  123. package/src/plugins/builtin/futures/table.tsx +1 -1
  124. package/src/plugins/builtin/fx-matrix/index.tsx +2 -0
  125. package/src/plugins/builtin/help/index.tsx +1 -1
  126. package/src/plugins/builtin/holders/pane.tsx +30 -20
  127. package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
  128. package/src/plugins/builtin/iv-history/events.ts +5 -0
  129. package/src/plugins/builtin/iv-history/headless.ts +19 -12
  130. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
  131. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  132. package/src/plugins/builtin/macro-day/model.ts +17 -4
  133. package/src/plugins/builtin/macro-day/releases.ts +36 -15
  134. package/src/plugins/builtin/market-halts/model.ts +3 -2
  135. package/src/plugins/builtin/market-movers/headless.ts +2 -1
  136. package/src/plugins/builtin/market-movers/index.tsx +3 -2
  137. package/src/plugins/builtin/market-movers/model.ts +75 -22
  138. package/src/plugins/builtin/market-movers/screener.ts +2 -1
  139. package/src/plugins/builtin/market-movers/table.ts +7 -5
  140. package/src/plugins/builtin/options/view.tsx +2 -0
  141. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  142. package/src/plugins/builtin/pe-band/model.ts +4 -0
  143. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  144. package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
  145. package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
  146. package/src/plugins/builtin/portfolio-list/pane/index.tsx +15 -1
  147. package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
  148. package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
  149. package/src/plugins/builtin/portfolio-list/table.tsx +18 -1
  150. package/src/plugins/builtin/rate-path/pane.tsx +2 -0
  151. package/src/plugins/builtin/research/analyst-headless.ts +9 -1
  152. package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
  153. package/src/plugins/builtin/research/client.ts +25 -1
  154. package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
  155. package/src/plugins/builtin/research/event-model.ts +3 -13
  156. package/src/plugins/builtin/research/event-sources.ts +3 -1
  157. package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
  158. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
  159. package/src/plugins/builtin/seasonality/pane.tsx +2 -1
  160. package/src/plugins/builtin/short-interest/headless.ts +2 -0
  161. package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
  162. package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
  163. package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
  164. package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
  165. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
  166. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
  167. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  168. package/src/plugins/builtin/vol-surface/pane.tsx +2 -1
  169. package/src/plugins/builtin/world-indices/index.tsx +5 -1
  170. package/src/plugins/builtin/yield-curve/headless.ts +5 -1
  171. package/src/plugins/builtin/yield-curve/index.tsx +7 -1
  172. package/src/portfolio/column-values.ts +47 -14
  173. package/src/portfolio/return-metrics.ts +4 -2
  174. package/src/renderers/dom/data-table/column-drag.ts +147 -0
  175. package/src/renderers/dom/data-table/index.tsx +22 -0
  176. package/src/renderers/dom/data-table/row.tsx +27 -5
  177. package/src/renderers/dom/host/image-surface.tsx +19 -9
  178. package/src/renderers/dom/host/input.tsx +4 -0
  179. package/src/renderers/dom/styles.css +22 -0
  180. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
  181. package/src/renderers/opentui/chart-surface.tsx +1 -0
  182. package/src/renderers/opentui/frame-hits.ts +33 -0
  183. package/src/renderers/opentui/host.tsx +2 -0
  184. package/src/renderers/opentui/native-surface.ts +14 -21
  185. package/src/renderers/opentui/test-utils.tsx +3 -0
  186. package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
  187. package/src/sources/provider-errors.ts +12 -0
  188. package/src/sources/provider-router/index.ts +12 -4
  189. package/src/state/app/context/index.tsx +22 -0
  190. package/src/state/pane-session.ts +145 -0
  191. package/src/test-support/app-store.ts +24 -1
  192. package/src/tickers/search/home-listing.ts +44 -1
  193. package/src/tickers/search/index.ts +5 -2
  194. package/src/tickers/search/ranking.ts +7 -7
  195. package/src/tickers/us-listing.ts +11 -5
  196. package/src/time-series/base-series.ts +7 -1
  197. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  198. package/src/time-series/fundamentals/series.ts +6 -0
  199. package/src/time-series/live-quotes.ts +3 -9
  200. package/src/time-series/resolve.ts +1 -0
  201. package/src/types/financials.ts +20 -0
  202. package/src/types/headless.ts +9 -0
  203. package/src/ui/host.tsx +20 -0
  204. package/src/ui/pointer-drag.ts +11 -2
  205. package/src/utils/exchanges.ts +13 -8
  206. package/src/utils/fundamentals.ts +14 -3
  207. package/src/utils/price-earnings.ts +17 -10
  208. package/src/utils/price-history-integrity.ts +15 -0
  209. package/src/utils/reason-codes.ts +79 -0
  210. package/src/utils/share-multiples.cases.json +1667 -0
  211. package/src/utils/share-multiples.ts +384 -0
  212. package/src/utils/untrusted-text.ts +11 -0
@@ -4,6 +4,9 @@ import { useOptionalDialog, type PromptContext } from "../../ui/dialog";
4
4
  import { usePaneMenuItems } from "../layout/pane/footer";
5
5
  import { ChoiceDialog } from "../ui/choice-dialog";
6
6
  import type { DataTableColumn } from "../ui";
7
+ import type { ContextMenuItem } from "../../types/context-menu";
8
+
9
+ const NO_ITEMS: readonly ContextMenuItem[] = [];
7
10
 
8
11
  /**
9
12
  * A sortable table's header clicks, for the keyboard: "Sort by…" in the pane
@@ -17,6 +20,7 @@ export function useDataTableSortMenu({
17
20
  sortDirection,
18
21
  onHeaderClick,
19
22
  onSortChange,
23
+ columnItems = NO_ITEMS,
20
24
  }: {
21
25
  enabled: boolean;
22
26
  columns: DataTableColumn[];
@@ -25,6 +29,8 @@ export function useDataTableSortMenu({
25
29
  onHeaderClick: (columnId: string) => void;
26
30
  /** Sets a direction outright, for a header click that cycles through "unsorted". */
27
31
  onSortChange?: (columnId: string, direction: "asc" | "desc") => void;
32
+ /** The table's column entries (Move Column…, Reset Columns), listed with its sort. */
33
+ columnItems?: readonly ContextMenuItem[];
28
34
  }) {
29
35
  const dialog = useOptionalDialog();
30
36
  const registrationId = `data-table-sort:${useId()}`;
@@ -39,7 +45,7 @@ export function useDataTableSortMenu({
39
45
  const sortableColumns = columns.filter((column) => column.label.trim().length > 0);
40
46
 
41
47
  usePaneMenuItems(registrationId, () => {
42
- if (!enabled || !dialog || sortableColumns.length === 0) return null;
48
+ if (!enabled || !dialog || sortableColumns.length === 0) return columnItems.length > 0 ? [...columnItems] : null;
43
49
  const chooseColumn = async () => {
44
50
  const current = latest.current;
45
51
  const arrow = current.sortDirection === "asc" ? "▲" : "▼";
@@ -70,6 +76,7 @@ export function useDataTableSortMenu({
70
76
  ...(sortColumnId
71
77
  ? [{ id: "sort-reverse", label: "Reverse Sort", onSelect: reverse }]
72
78
  : []),
79
+ ...columnItems,
73
80
  ];
74
- }, [dialog, enabled, sortColumnId, sortableColumns.length]);
81
+ }, [columnItems, dialog, enabled, sortColumnId, sortableColumns.length]);
75
82
  }
@@ -3,9 +3,11 @@ import type { DataTableKeyEvent } from "./view";
3
3
  import type { PaneFooterSegment } from "../layout/pane/footer";
4
4
  import { useShortcut } from "../../react/input";
5
5
  import { isPlainKey } from "../../utils/keyboard";
6
+ import { readableStatus } from "../../utils/reason-codes";
6
7
 
8
+ /** `loading`, and the failure in words: a bare reason code (UPSTREAM_ERROR) reads as what happened. */
7
9
  export function loadingErrorFooterInfo(loading: boolean, error: string | null | undefined): PaneFooterSegment[] {
8
- const message = error?.trim() ?? "";
10
+ const message = readableStatus(error?.trim() ?? "");
9
11
  return [
10
12
  ...(loading ? [{ id: "loading", parts: [{ text: "loading", tone: "muted" as const }] }] : []),
11
13
  ...(message ? [{ id: "error", parts: [{ text: message, tone: "warning" as const }] }] : []),
@@ -13,7 +13,9 @@ import { useBeforeShortcut, useShortcut } from "../../react/input";
13
13
  import { isPlainKey, isPlainKeyboardEvent } from "../../utils/keyboard";
14
14
  import { DataTable, PaneStatusBody, type DataTableColumn, type DataTableProps, type PaneStatusBodyProps } from "../ui";
15
15
  import { useDataTableSortMenu } from "./sort-menu";
16
- import { tableFreezesFirstColumn, tableRevealLeft, tableScrollStep } from "../ui/table-layout";
16
+ import { useDataTableColumnMenuItems } from "./column-menu";
17
+ import { drawnTableColumns, tableFreezesFirstColumn, tableRevealLeft, tableScrollStep } from "../ui/table-layout";
18
+ import { useDataTableColumnOrder } from "../ui/data-table/use-column-order";
17
19
  import {
18
20
  TableViewFrame,
19
21
  useResetTableScroll,
@@ -211,13 +213,31 @@ export function DataTableView<
211
213
  ...tableProps
212
214
  }: DataTableViewProps<T, C>) {
213
215
  const onHeaderClick = tableProps.onHeaderClick;
216
+ // Ordered here, so a sideways step and a revealed column count the columns as they are drawn.
217
+ const columnOrder = useDataTableColumnOrder(
218
+ tableProps.columns,
219
+ tableProps.onColumnMove ? false : tableProps.columnReorder,
220
+ { menu: false },
221
+ );
222
+ const columns = columnOrder.columns;
223
+ const onColumnMove = tableProps.onColumnMove ?? columnOrder.onColumnMove;
224
+ const anchoredColumns = tableProps.onColumnMove ? tableProps.anchoredColumns ?? 1 : columnOrder.anchoredColumns;
225
+ const columnItems = useDataTableColumnMenuItems({
226
+ enabled: focused && keyboardNavigation,
227
+ columns,
228
+ anchoredColumns,
229
+ onColumnMove,
230
+ customized: columnOrder.customized,
231
+ reset: columnOrder.reset,
232
+ });
214
233
  useDataTableSortMenu({
215
234
  enabled: focused && keyboardNavigation && !!onHeaderClick && (sortable ?? true),
216
- columns: isColumnSortable ? tableProps.columns.filter(isColumnSortable) : tableProps.columns,
235
+ columns: isColumnSortable ? columns.filter(isColumnSortable) : columns,
217
236
  sortColumnId: tableProps.sortColumnId ?? null,
218
237
  sortDirection: tableProps.sortDirection ?? "asc",
219
238
  onHeaderClick: onHeaderClick ?? ignoreHeaderClick,
220
239
  onSortChange,
240
+ columnItems,
221
241
  });
222
242
  const {
223
243
  effectiveHeaderScrollRef,
@@ -697,13 +717,15 @@ export function DataTableView<
697
717
  // At either edge the key is still the table's, so it never falls through
698
718
  // to switch a tab.
699
719
  stopTableKey(event);
720
+ // The columns in their order, at the widths the terminal's fit drew them.
721
+ const drawn = drawnTableColumns.get(body) ?? columns;
700
722
  const nextLeft = tableScrollStep({
701
- columns: tableProps.columns,
723
+ columns: drawn,
702
724
  columnGap: tableProps.columnGap,
703
725
  horizontalPadding: tableProps.horizontalPadding,
704
726
  frozenFirstColumn: tableFreezesFirstColumn({
705
727
  freezeFirstColumn: tableProps.freezeFirstColumn,
706
- columns: tableProps.columns,
728
+ columns: drawn,
707
729
  columnGap: tableProps.columnGap,
708
730
  horizontalPadding: tableProps.horizontalPadding,
709
731
  viewportWidth,
@@ -725,7 +747,7 @@ export function DataTableView<
725
747
  // The column asked for, in the middle of the scrolled columns once the body has its width. Keyed on the
726
748
  // column and the pane's width only: a refresh that resizes a column to its new figures, or a scroll the
727
749
  // reader made with Shift+arrows, stays where it is. An empty table waits for its rows.
728
- const revealColumnIndex = revealColumnId == null ? -1 : tableProps.columns.findIndex((column) => column.id === revealColumnId);
750
+ const revealColumnIndex = revealColumnId == null ? -1 : columns.findIndex((column) => column.id === revealColumnId);
729
751
  const revealKey = revealColumnIndex < 0 ? null : `${revealColumnIndex}:${rootWidth ?? ""}`;
730
752
  const revealedKeyRef = useRef<string | null>(null);
731
753
  const hasRows = tableProps.items.length > 0;
@@ -742,7 +764,8 @@ export function DataTableView<
742
764
  if (scrollWidth > 0) revealedKeyRef.current = revealKey;
743
765
  return scrollWidth > 0;
744
766
  }
745
- const shared = { columns: tableProps.columns, columnGap: tableProps.columnGap, horizontalPadding: tableProps.horizontalPadding };
767
+ // The columns in their order, at the widths the terminal's fit drew them.
768
+ const shared = { columns: drawnTableColumns.get(body) ?? columns, columnGap: tableProps.columnGap, horizontalPadding: tableProps.horizontalPadding };
746
769
  const nextLeft = tableRevealLeft({ ...shared, columnIndex: revealColumnIndex, viewportWidth, maxLeft,
747
770
  frozenFirstColumn: tableFreezesFirstColumn({ ...shared, freezeFirstColumn: tableProps.freezeFirstColumn, viewportWidth, overflows: true }) });
748
771
  if (nextLeft !== body.scrollLeft) {
@@ -811,6 +834,10 @@ export function DataTableView<
811
834
  >
812
835
  {bodyStatusShown(status) ? <PaneStatusBody {...status} /> : <DataTable<T, C>
813
836
  {...tableProps}
837
+ columns={columns}
838
+ columnReorder={false}
839
+ onColumnMove={onColumnMove}
840
+ anchoredColumns={anchoredColumns}
814
841
  headerScrollRef={effectiveHeaderScrollRef}
815
842
  scrollRef={effectiveScrollRef}
816
843
  syncHeaderScroll={effectiveSyncHeaderScroll}
@@ -467,6 +467,16 @@ export function FormModalContent({
467
467
  }
468
468
  }, [desktop, showsFields]);
469
469
 
470
+ // A body its fields fit shows no scrollbar. Left to the scroll box, a bar shown while the body was shorter
471
+ // would stay: it takes the text a column, and a line as wide as the body wraps to a row more than it holds.
472
+ const bodyFits = fieldRowsHeight <= availableRows;
473
+ useLayoutEffect(() => {
474
+ const bar = desktop || !showsFields ? null : scrollRef.current?.verticalScrollBar;
475
+ if (!bar) return;
476
+ if (bodyFits) bar.visible = false;
477
+ else bar.resetVisibilityControl?.();
478
+ }, [bodyFits, desktop, showsFields]);
479
+
470
480
  // After layout, so a field that dependsOn just revealed is measured, and
471
481
  // again when the body's height changes (an error line takes a row from it).
472
482
  useEffect(() => {
@@ -147,7 +147,7 @@ export {
147
147
  export type {
148
148
  ActionRowProps, BadgeProps, BulletListProps, ButtonProps, ButtonVariant, CardProps, CheckboxProps, ChoiceDialogChoice, ColumnGridCell,
149
149
  ColumnGridColumn, ColumnGridLink, ColumnGridPairProps, ColumnGridProps, ConfirmDialogOptions, CountryFlagProps,
150
- DataTableCell, DataTableColumn, DataTableProps, DataTableVisibleRange, DetailScrollBodyProps, DialogFrameProps,
150
+ DataTableCell, DataTableColumn, DataTableColumnReorder, DataTableProps, DataTableVisibleRange, DetailScrollBodyProps, DialogFrameProps,
151
151
  DisclosureMarkerProps, DividerProps, EmptyStateProps, FieldGridProps, FieldLabelProps, FieldRing, FieldRingOptions,
152
152
  FigureListItem, FigureListProps, GridField,
153
153
  IconButtonPressEvent, IconButtonProps, IconName, IconProps, InlineQuickAddRowProps,
@@ -18,6 +18,7 @@ import {
18
18
  separatesPaneFooterSegments,
19
19
  hasPaneFooterContent,
20
20
  layoutPaneFooterHintRow,
21
+ paneFooterInfoWidth,
21
22
  paneHintTitle,
22
23
  terminalHintMetrics,
23
24
  totalHintsWidth,
@@ -51,6 +52,9 @@ export {
51
52
  usePaneMenuItems,
52
53
  } from "./registration";
53
54
 
55
+ /** Terminal: blank cells between a framed footer's last hint and the frame's end. */
56
+ const FOOTER_FRAME_GAP = 1;
57
+
54
58
  function footerToneColor(part: PaneFooterPart): string {
55
59
  if (part.color) return part.color;
56
60
  switch (part.tone) {
@@ -86,10 +90,11 @@ function terminalSegmentKey(segment: PaneFooterSegment, focused: boolean): strin
86
90
  : "";
87
91
  }
88
92
 
89
- /** Columns an icon segment keeps when hints crowd the footer. */
93
+ /** Columns an icon segment keeps when hints crowd the footer: in the terminal, what it draws (`◷15m`, `⚠[!]`). */
90
94
  function iconSegmentReserve(segment: PaneFooterSegment, focused: boolean, nativePaneChrome: boolean): number {
91
95
  if (!segment.icon) return 0;
92
- return nativePaneChrome ? 3 : Math.max(3, 1 + terminalSegmentKey(segment, focused).length);
96
+ if (nativePaneChrome) return 3;
97
+ return Math.max(3, paneFooterInfoWidth([segment]) + terminalSegmentKey(segment, focused).length);
93
98
  }
94
99
 
95
100
  function SegmentView({ segment, focused }: { segment: PaneFooterSegment; focused: boolean }) {
@@ -265,12 +270,15 @@ function FooterContent({
265
270
  width,
266
271
  showBackground = true,
267
272
  nativePaneChrome = false,
273
+ trailingGap = 0,
268
274
  }: {
269
275
  footer: CombinedPaneFooter;
270
276
  focused: boolean;
271
277
  width?: number;
272
278
  showBackground?: boolean;
273
279
  nativePaneChrome?: boolean;
280
+ /** Blank cells of the band after the hints, past `width`, so they never touch the frame. */
281
+ trailingGap?: number;
274
282
  }) {
275
283
  const hasInfo = footer.info.length > 0;
276
284
  const actionableHints = focused ? footer.hints.filter((hint) => !hint.disabled) : [];
@@ -283,8 +291,10 @@ function FooterContent({
283
291
  const keyLabel = useShortcutLabel();
284
292
  const { cellWidthPx = 8 } = useUiCapabilities();
285
293
  const metrics = nativePaneChrome ? desktopHintMetrics(cellWidthPx) : terminalHintMetrics(keyLabel);
294
+ // A segment with shorter forms takes the longest that fits beside the hints, gaps and terminal keys included.
295
+ const keysWidth = nativePaneChrome ? 0 : footer.info.reduce((total, segment) => total + terminalSegmentKey(segment, focused).length, 0);
286
296
  const row = availableWidth !== null
287
- ? layoutPaneFooterHintRow({ ...footer, hints: actionableHints }, availableWidth, iconReserve, metrics)
297
+ ? layoutPaneFooterHintRow({ ...footer, hints: actionableHints }, availableWidth, iconReserve, metrics, { terminal: !nativePaneChrome, keysWidth })
288
298
  : null;
289
299
  const shownHints = row?.hints ?? actionableHints;
290
300
  const overflowHints = row?.overflow ?? [];
@@ -293,9 +303,7 @@ function FooterContent({
293
303
  const infoWidth = availableWidth !== null && hasInfo
294
304
  ? (row?.infoWidth ?? Math.max(0, availableWidth - hintsWidth))
295
305
  : undefined;
296
- // A segment with shorter forms takes the longest that fits beside the hints, gaps and terminal keys included.
297
- const keysWidth = nativePaneChrome ? 0 : footer.info.reduce((total, segment) => total + terminalSegmentKey(segment, focused).length, 0);
298
- const info = infoWidth != null ? fitPaneFooterInfo(footer.info, infoWidth - keysWidth, { besideHints: hasHints }) : footer.info;
306
+ const info = infoWidth != null ? fitPaneFooterInfo(footer.info, infoWidth - keysWidth, { besideHints: hasHints, terminal: !nativePaneChrome }) : footer.info;
299
307
  const lastTextIndex = info.findLastIndex((segment) => !segment.icon);
300
308
 
301
309
  if (!hasInfo && !hasHints) {
@@ -312,6 +320,7 @@ function FooterContent({
312
320
  flexDirection="row"
313
321
  justifyContent="space-between"
314
322
  overflow="hidden"
323
+ paddingRight={trailingGap > 0 ? trailingGap : undefined}
315
324
  backgroundColor={backgroundColor}
316
325
  >
317
326
  {hasInfo && (
@@ -428,16 +437,21 @@ export function PaneFooterBar({
428
437
  }
429
438
 
430
439
  if (focused || showBorder) {
431
- const contentWidth = Math.max(0, Math.floor(width) - 1 - reservedRight - (reservedRight > 0 ? 0 : 1));
440
+ // The row ends as the title bar does (` x ─┐`): the last hint, a blank, then the rule's last dash
441
+ // and the corner, or the floating pane's `─◢` in the cells it reserves. A hint against the dash
442
+ // read as one word (`ticker─`).
443
+ const ruleEnd = reservedRight > 0 ? "" : "─┘";
444
+ const rowWidth = Math.max(0, Math.floor(width) - 1 - reservedRight - ruleEnd.length);
445
+ const contentWidth = Math.max(0, rowWidth - FOOTER_FRAME_GAP);
432
446
  return (
433
447
  <Box height={1} width={width} flexDirection="row" data-gloom-role="pane-footer" data-focused={focused ? "true" : "false"} data-empty={empty ? "true" : "false"}>
434
448
  <Text fg={borderColor} selectable={false}>└</Text>
435
- <Box width={contentWidth} height={1} overflow="hidden">
449
+ <Box width={rowWidth} height={1} overflow="hidden">
436
450
  {empty
437
- ? <Text fg={borderColor} selectable={false}>{"─".repeat(contentWidth)}</Text>
438
- : <FooterContent footer={resolvedFooter} focused={focused} width={contentWidth} />}
451
+ ? <Text fg={borderColor} selectable={false}>{"─".repeat(rowWidth)}</Text>
452
+ : <FooterContent footer={resolvedFooter} focused={focused} width={contentWidth} trailingGap={rowWidth - contentWidth} />}
439
453
  </Box>
440
- {reservedRight === 0 && <Text fg={borderColor} selectable={false}>┘</Text>}
454
+ {ruleEnd && <Text fg={borderColor} selectable={false}>{ruleEnd}</Text>}
441
455
  </Box>
442
456
  );
443
457
  }
@@ -3,6 +3,7 @@ import { t, tf } from "../../../../i18n";
3
3
  import { type CompanyFrom, companyFromLabel } from "../../../../types/company-from";
4
4
  import { clipToDisplayWidth, displayWidth } from "../../../../utils/format";
5
5
  import { formatShortDate } from "../../../../utils/datetime-format";
6
+ import { readableStatus } from "../../../../utils/reason-codes";
6
7
  import { getShortcutHintWidth } from "../../../ui/shortcut-hint";
7
8
  import { KEY_HINT_GAP_PX, keycapText, keyHintCells, keyHintTitle, keyHintWords } from "../../../ui/key-hint-words";
8
9
 
@@ -343,6 +344,11 @@ export function totalHintsWidth(hints: readonly Pick<PaneHint, "key" | "label" |
343
344
  return Math.ceil(hints.reduce((total, hint, index) => total + (index > 0 ? metrics.gap : 0) + metrics.width(hint), 0) - 1e-9);
344
345
  }
345
346
 
347
+ /** Cells `segments` take side by side, separators and gaps included, the terminal's keys aside. */
348
+ export function paneFooterInfoWidth(segments: readonly PaneFooterSegment[]): number {
349
+ return infoTextWidth(segments);
350
+ }
351
+
346
352
  function infoTextWidth(segments: readonly PaneFooterSegment[]): number {
347
353
  if (segments.length === 0) return 0;
348
354
  return segments.reduce((total, segment, index) => {
@@ -370,22 +376,33 @@ function stepDownTogether(info: PaneFooterSegment[], width: number): PaneFooterS
370
376
  return fitted;
371
377
  }
372
378
 
379
+ /** A warning, an icon or a pressable segment, which a row too narrow never cuts or leaves out. */
380
+ function holdsItsPlace(segment: PaneFooterSegment): boolean {
381
+ return !!segment.icon || !!segment.onPress || segment.parts.some((part) => part.tone === "warning" || part.tone === "negative");
382
+ }
383
+
373
384
  /**
374
385
  * A trailing status cut mid-word reads as part of the hints beside it ("quote
375
- * 12h t[x] put"): one that does not fit ends in an ellipsis a column short of
376
- * them, or is left out when less than half of it would show, until the row
377
- * fits or `keep` segments are left. A warning, an icon or a pressable segment
378
- * stays as it is, clipped by the row if it must be.
386
+ * 12h t[x] put"): the last segment that does not fit ends in an ellipsis (a
387
+ * column short of the hints when it ends the row), or is left out when less
388
+ * than half of it would show, until the row fits or only the first `keep`
389
+ * segments are left to give way. A warning, an icon or a pressable segment
390
+ * holds its place, clipped by the row if it must be; in the terminal
391
+ * (`pastHeld`) the text before it gives way instead (a delay clock after the
392
+ * count it qualifies), where the desktop stops there.
379
393
  */
380
- function trimTrailing(info: PaneFooterSegment[], width: number, keep: number): PaneFooterSegment[] {
394
+ function trimTrailing(info: PaneFooterSegment[], width: number, keep: number, pastHeld: boolean): PaneFooterSegment[] {
381
395
  let fitted = info;
382
- while (fitted.length > keep && infoTextWidth(fitted) > width) {
383
- const last = fitted.at(-1)!;
384
- if (last.icon || last.onPress || last.parts.some((part) => part.tone === "warning" || part.tone === "negative")) break;
385
- // After the separator, a column short of the hints.
386
- const room = width - infoTextWidth(fitted.slice(0, -1)) - segmentGapWidth(fitted.at(-2)!, last) - 1;
387
- if (room * 2 >= infoTextWidth([last])) return [...fitted.slice(0, -1), clipSegment(last, room)];
388
- fitted = fitted.slice(0, -1);
396
+ while (infoTextWidth(fitted) > width) {
397
+ const index = pastHeld
398
+ ? fitted.findLastIndex((segment) => !holdsItsPlace(segment))
399
+ : holdsItsPlace(fitted.at(-1)!) ? -1 : fitted.length - 1;
400
+ if (index < keep) break;
401
+ const segment = fitted[index]!;
402
+ const own = infoTextWidth([segment]);
403
+ const room = width - (infoTextWidth(fitted) - own) - (index === fitted.length - 1 ? 1 : 0);
404
+ if (room * 2 >= own) return [...fitted.slice(0, index), clipSegment(segment, room), ...fitted.slice(index + 1)];
405
+ fitted = [...fitted.slice(0, index), ...fitted.slice(index + 1)];
389
406
  }
390
407
  return fitted;
391
408
  }
@@ -402,18 +419,22 @@ function trimTrailing(info: PaneFooterSegment[], width: number, keep: number): P
402
419
  * With no hints beside it (a pane picture's footer), the row clips the rest,
403
420
  * so a frame that fits its own status line sees it overflow.
404
421
  */
405
- export function fitPaneFooterInfo(info: PaneFooterSegment[], width: number, { besideHints = true }: { besideHints?: boolean } = {}): PaneFooterSegment[] {
422
+ export function fitPaneFooterInfo(
423
+ info: PaneFooterSegment[],
424
+ width: number,
425
+ { besideHints = true, terminal = false }: { besideHints?: boolean; terminal?: boolean } = {},
426
+ ): PaneFooterSegment[] {
406
427
  // How long ago the data loaded goes first, whole: a cut age (`fetched just`) says nothing.
407
428
  if (infoTextWidth(info) > width && info.some((segment) => segment.age)) {
408
- return fitPaneFooterInfo(info.filter((segment) => !segment.age), width, { besideHints });
429
+ return fitPaneFooterInfo(info.filter((segment) => !segment.age), width, { besideHints, terminal });
409
430
  }
410
431
  if (!besideHints) return stepDownTogether(info, width);
411
432
  const lastWithVariants = info.findLastIndex((segment) => (segment.variants?.length ?? 0) > 0);
412
433
  if (lastWithVariants >= 0 && lastWithVariants < info.length - 1 && infoTextWidth(info) > width) {
413
- const trimmed = trimTrailing(info, width, lastWithVariants + 1);
434
+ const trimmed = trimTrailing(info, width, lastWithVariants + 1, terminal);
414
435
  if (infoTextWidth(trimmed) <= width) return trimmed;
415
436
  }
416
- return trimTrailing(stepDownTogether(info, width), width, 1);
437
+ return trimTrailing(stepDownTogether(info, width), width, 1, terminal);
417
438
  }
418
439
 
419
440
  /** A segment cut to `width` behind an ellipsis, each part keeping its tone; the full text stays as its title. */
@@ -452,12 +473,28 @@ export interface PaneFooterHintRow {
452
473
  infoWidth: number;
453
474
  }
454
475
 
455
- /** Hints that fit this footer row, and the rest, which a More control owns. */
476
+ export interface PaneFooterHintRowOptions {
477
+ /** The terminal's row (layoutPaneFooterHintRow); the desktop's leaves it out. */
478
+ terminal?: boolean;
479
+ /** What the terminal draws besides the status's own text (`[!]` after an icon). */
480
+ keysWidth?: number;
481
+ }
482
+
483
+ /**
484
+ * Hints that fit this footer row, and the rest, which a More control owns.
485
+ * The status gives way to the hints down to its floor (INFO_FLOOR_CHARS,
486
+ * WARNING_FLOOR_CHARS, or `iconReserve`, the cells its icons take). In the
487
+ * terminal the status is kept whole while the first hint and More still fit
488
+ * beside it, hints going under More from the right first, and the status and
489
+ * the hints keep a column between them, so they never read as one
490
+ * ("777 matchesU◷1[m]etric").
491
+ */
456
492
  export function layoutPaneFooterHintRow(
457
493
  footer: CombinedPaneFooter,
458
494
  contentWidth: number,
459
495
  iconReserve = 0,
460
496
  metrics: PaneHintMetrics = TERMINAL_HINT_METRICS,
497
+ { terminal = false, keysWidth = 0 }: PaneFooterHintRowOptions = {},
461
498
  ): PaneFooterHintRow {
462
499
  const width = Math.max(0, Math.floor(contentWidth));
463
500
  const hints = footer.hints.filter((hint) => !hint.disabled);
@@ -468,8 +505,14 @@ export function layoutPaneFooterHintRow(
468
505
  const textFloor = footer.info.length === 0 ? 0
469
506
  : warning || infoChars <= WARNING_FLOOR_CHARS ? Math.min(WARNING_FLOOR_CHARS, infoChars)
470
507
  : INFO_FLOOR_CHARS;
471
- const infoFloor = Math.min(width, Math.max(iconReserve, textFloor));
472
- const hintBudget = Math.max(0, width - infoFloor - (infoFloor > 0 && hints.length > 0 ? 1 : 0));
508
+ const status = footer.info.length === 0 ? 0 : infoChars + keysWidth;
509
+ const leastHints = hints.length === 0 ? 0 : Math.min(
510
+ totalHintsWidth(hints, metrics),
511
+ Math.ceil(metrics.width(hints[0]!) + metrics.gap + moreControl(Number.POSITIVE_INFINITY).width),
512
+ );
513
+ const wholeStatus = terminal && status > 0 && status + (leastHints > 0 ? HINT_GAP + leastHints : 0) <= width;
514
+ const infoFloor = Math.min(width, wholeStatus ? status : Math.max(iconReserve, textFloor));
515
+ const hintBudget = Math.max(0, width - infoFloor - (infoFloor > 0 && hints.length > 0 ? HINT_GAP : 0));
473
516
  const more = moreControl(hintBudget);
474
517
  let visible = hints;
475
518
  let overflow: PaneHint[] = [];
@@ -494,7 +537,7 @@ export function layoutPaneFooterHintRow(
494
537
  moreLabel: more.label,
495
538
  moreWidth: more.width,
496
539
  hintsWidth,
497
- infoWidth: Math.max(0, width - hintsWidth),
540
+ infoWidth: Math.max(0, width - hintsWidth - (terminal && footer.info.length > 0 && hintsWidth > 0 ? HINT_GAP : 0)),
498
541
  };
499
542
  }
500
543
 
@@ -544,7 +587,31 @@ export function combinePaneFooterRegistrations(registrations: Map<string, PaneFo
544
587
  const shown = kept.some((hint) => !hint.besideOthers && !hint.disabled) ? kept : kept.filter((hint) => !hint.besideOthers);
545
588
 
546
589
  if (info.length === 0 && shown.length === 0 && menu.length === 0 && keys.length === 0) return EMPTY_FOOTER;
547
- return { info: savedCopyFirst(info), hints: shown, menu, keys };
590
+ return { info: savedCopyFirst(info.map(readableFailure)), hints: shown, menu, keys };
591
+ }
592
+
593
+ const failureTone = (part: PaneFooterPart) => part.tone === "warning" || part.tone === "negative";
594
+
595
+ /**
596
+ * A failure a pane put in its footer itself, in words: a bare reason code
597
+ * (UPSTREAM_ERROR) reads as what happened, as `loadingErrorFooterInfo` says
598
+ * it. Only warning and negative parts, so a symbol shown as data stays.
599
+ */
600
+ function readableFailure(segment: PaneFooterSegment): PaneFooterSegment {
601
+ const read = (parts: PaneFooterPart[]) => {
602
+ let changed = false;
603
+ const next = parts.map((part) => {
604
+ const text = failureTone(part) ? readableStatus(part.text) : part.text;
605
+ if (text === part.text) return part;
606
+ changed = true;
607
+ return { ...part, text };
608
+ });
609
+ return changed ? next : parts;
610
+ };
611
+ const parts = read(segment.parts);
612
+ const variants = segment.variants?.map(read);
613
+ const same = parts === segment.parts && (variants ?? []).every((variant, index) => variant === segment.variants![index]);
614
+ return same ? segment : { ...segment, parts, ...(variants ? { variants } : {}) };
548
615
  }
549
616
 
550
617
  /**
@@ -1,5 +1,7 @@
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
7
  import { blendHex, colors, hoverBg } from "../../../theme/colors";
@@ -37,7 +39,7 @@ const PaneSidebarContext = createContext<PaneSidebarContextValue | null>(null);
37
39
 
38
40
  function usePaneSidebarContext(): PaneSidebarContextValue {
39
41
  const context = useContext(PaneSidebarContext);
40
- if (!context) throw new Error("PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
42
+ if (!context) throw new Error("PaneSidebarList, PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
41
43
  return context;
42
44
  }
43
45
 
@@ -309,20 +311,125 @@ export function PaneSidebar({
309
311
  );
310
312
  }
311
313
 
312
- export function PaneSidebarList({ children }: { children: ReactNode }) {
314
+ interface PaneSidebarListContextValue {
315
+ /** Marks `node` as the row the list keeps in view, and brings it there. */
316
+ setCurrent: (node: BoxRenderable | null) => void;
317
+ }
318
+
319
+ const PaneSidebarListContext = createContext<PaneSidebarListContextValue | null>(null);
320
+
321
+ /**
322
+ * Keeps the row `ref` is on in view while it is `current`: the row the
323
+ * keyboard is on, or the open item. Rows outside a PaneSidebarList, and the
324
+ * desktop list, which scrolls by CSS, ignore it.
325
+ */
326
+ export function usePaneSidebarReveal(ref: RefObject<BoxRenderable | null>, current: boolean): void {
327
+ const list = useContext(PaneSidebarListContext);
328
+ useLayoutEffect(() => {
329
+ if (!list || !current) return;
330
+ list.setCurrent(ref.current);
331
+ return () => list.setCurrent(null);
332
+ }, [current, list, ref]);
333
+ }
334
+
335
+ export interface PaneSidebarListRenderState {
336
+ /** The width a row has beside the list's scrollbar, while it shows one. */
337
+ listWidth: number;
338
+ }
339
+
340
+ /**
341
+ * The scrolling part of a sidebar. The wheel scrolls it, a scrollbar shows
342
+ * while it holds more rows than fit, and the row a `PaneSidebarRow` marks
343
+ * `active` (or `usePaneSidebarReveal` marks current) stays in view as the
344
+ * keyboard moves it.
345
+ */
346
+ export function PaneSidebarList({ children }: { children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode) }) {
313
347
  const { nativePaneChrome } = useUiCapabilities();
348
+ const sidebar = usePaneSidebarContext();
349
+ if (nativePaneChrome) {
350
+ return (
351
+ <Box
352
+ flexGrow={1}
353
+ flexShrink={1}
354
+ flexBasis={0}
355
+ minHeight={0}
356
+ data-gloom-role="pane-sidebar-list"
357
+ style={{ minHeight: 0, overflowX: "hidden", overflowY: "auto" }}
358
+ >
359
+ {typeof children === "function" ? children({ listWidth: sidebar.listWidth }) : children}
360
+ </Box>
361
+ );
362
+ }
363
+ return <TerminalPaneSidebarList sidebar={sidebar}>{children}</TerminalPaneSidebarList>;
364
+ }
365
+
366
+ function TerminalPaneSidebarList({ sidebar, children }: {
367
+ sidebar: PaneSidebarContextValue;
368
+ children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode);
369
+ }) {
370
+ // The host's own ScrollBox, which the pane scroll keys do not drive: the
371
+ // list's keys move its cursor, and the pane's bring the cursor into view.
372
+ const { ScrollBox } = useUiHost();
373
+ const scrollRef = useRef<ScrollBoxRenderable | null>(null);
374
+ const currentRef = useRef<BoxRenderable | null>(null);
375
+ const [scrollbar, setScrollbar] = useState(false);
376
+ const reveal = useCallback(() => afterLayout(() => revealInScrollBox(scrollRef.current, currentRef.current)), []);
377
+ const list = useMemo<PaneSidebarListContextValue>(() => ({
378
+ setCurrent: (node) => {
379
+ currentRef.current = node;
380
+ if (node) reveal();
381
+ },
382
+ }), [reveal]);
383
+ // The scrollbar shows once the rows outgrow the list, and takes a column
384
+ // from them. Read once the whole pass is laid out: the content is at least
385
+ // as tall as the viewport, and is not yet sized to it when the viewport
386
+ // reports.
387
+ const syncScrollbar = useCallback(() => afterLayout(() => {
388
+ const scrollBox = scrollRef.current;
389
+ if (!scrollBox) return;
390
+ const viewportHeight = scrollBox.viewport?.height ?? 0;
391
+ setScrollbar(viewportHeight > 0 && scrollBox.scrollHeight > viewportHeight);
392
+ }), []);
393
+ // A list that opens, or is made shorter or taller, brings the row under the
394
+ // cursor back into view. Rows coming and going, and the scrollbar taking a
395
+ // column, leave the scroll where the wheel put it.
396
+ const viewportHeightRef = useRef(0);
397
+ const syncViewport = useCallback(() => {
398
+ syncScrollbar();
399
+ const height = scrollRef.current?.viewport?.height ?? 0;
400
+ if (height === viewportHeightRef.current) return;
401
+ viewportHeightRef.current = height;
402
+ reveal();
403
+ }, [reveal, syncScrollbar]);
404
+ useEffect(() => observeScrollBoxViewportSize(scrollRef.current, syncViewport), [syncViewport]);
405
+ useEffect(() => observeScrollBoxContentSize(scrollRef.current, syncScrollbar), [syncScrollbar]);
406
+ // In the same frame as the rows narrow or widen for it.
407
+ useLayoutEffect(() => {
408
+ const bar = scrollRef.current?.verticalScrollBar;
409
+ if (bar) bar.visible = scrollbar;
410
+ }, [scrollbar]);
411
+ const listWidth = Math.max(1, sidebar.listWidth - (scrollbar ? 1 : 0));
412
+ const context = useMemo(() => ({ ...sidebar, listWidth }), [sidebar, listWidth]);
413
+
314
414
  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>
415
+ <PaneSidebarContext.Provider value={context}>
416
+ <PaneSidebarListContext.Provider value={list}>
417
+ <ScrollBox
418
+ ref={scrollRef}
419
+ flexGrow={1}
420
+ flexShrink={1}
421
+ flexBasis={0}
422
+ minHeight={0}
423
+ scrollY
424
+ focusable={false}
425
+ verticalScrollbarOptions={{ visible: false }}
426
+ horizontalScrollbarOptions={{ visible: false }}
427
+ data-gloom-role="pane-sidebar-list"
428
+ >
429
+ {typeof children === "function" ? children({ listWidth }) : children}
430
+ </ScrollBox>
431
+ </PaneSidebarListContext.Provider>
432
+ </PaneSidebarContext.Provider>
326
433
  );
327
434
  }
328
435
 
@@ -349,6 +456,8 @@ export function PaneSidebarRow({
349
456
  }) {
350
457
  const { activeBackgroundColor, backgroundColor, keyboardFocused, listWidth } = usePaneSidebarContext();
351
458
  const [hovered, setHovered] = useState(false);
459
+ const rowRef = useRef<BoxRenderable>(null);
460
+ usePaneSidebarReveal(rowRef, active);
352
461
  const foregroundColor = active
353
462
  ? colors.selectedText
354
463
  : keyboardFocused
@@ -369,6 +478,7 @@ export function PaneSidebarRow({
369
478
 
370
479
  return (
371
480
  <Box
481
+ ref={rowRef}
372
482
  height={height}
373
483
  width={listWidth}
374
484
  flexDirection="row"