@gloom-sh/terminal 0.20.22 → 0.20.23

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 (195) hide show
  1. package/package.json +1 -1
  2. package/src/account/heard-from-question.tsx +6 -4
  3. package/src/account/heard-from.ts +3 -4
  4. package/src/api-client/exchange-announcements.ts +2 -2
  5. package/src/api-client/heard-from.ts +5 -7
  6. package/src/api-client/ownership-disclosures.ts +38 -5
  7. package/src/api-client/types/ticker-data.ts +3 -1
  8. package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
  9. package/src/cli/commands/market.ts +5 -3
  10. package/src/cli/commands/overview.ts +7 -9
  11. package/src/cli/listing-arg.ts +45 -18
  12. package/src/cli/pane-functions/catalog-snapshot.json +2 -2
  13. package/src/cli/pane-functions/data.ts +3 -1
  14. package/src/cli/pane-functions/freshness.ts +6 -1
  15. package/src/cli/pane-functions/function-help.ts +0 -2
  16. package/src/cli/pane-functions/market-session.ts +12 -2
  17. package/src/cli/pane-functions/screenshot-payload.ts +3 -1
  18. package/src/cli/symbol-list.ts +52 -14
  19. package/src/cli/ticker-resolution.ts +133 -38
  20. package/src/components/chart/composite/composite-chart.tsx +12 -0
  21. package/src/components/chart/composite/types.ts +18 -0
  22. package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
  23. package/src/components/chart-table/header.tsx +11 -5
  24. package/src/components/chart-table/selection.ts +20 -1
  25. package/src/components/data-table/view.tsx +2 -0
  26. package/src/components/feed-data-table/stack-view.tsx +85 -5
  27. package/src/components/layout/pane/header.tsx +12 -30
  28. package/src/components/ticker/badge/index.tsx +9 -4
  29. package/src/components/ticker/badge/list.tsx +3 -1
  30. package/src/components/ui/data-table/index.tsx +7 -1
  31. package/src/components/ui/data-table/muted-row.tsx +47 -0
  32. package/src/components/ui/data-table/opentui/index.tsx +42 -11
  33. package/src/components/ui/data-table/spill.ts +36 -0
  34. package/src/components/ui/data-table/types.ts +17 -1
  35. package/src/components/ui/data-table/use-column-order.ts +11 -0
  36. package/src/components/ui/icon.tsx +50 -3
  37. package/src/components/ui/list-view.tsx +2 -2
  38. package/src/components/ui/table-layout.ts +32 -0
  39. package/src/components/ui/terminal-hover-label.tsx +49 -0
  40. package/src/components/use-pinned-moment.ts +222 -13
  41. package/src/core/state/app/state.ts +11 -2
  42. package/src/core/state/app/types.ts +2 -1
  43. package/src/data/sqlite/access.ts +14 -1
  44. package/src/data/sqlite/checkpointer.ts +2 -2
  45. package/src/data/sqlite/database.ts +4 -0
  46. package/src/docs/snapshot.json +180 -26
  47. package/src/i18n/es.ts +1 -0
  48. package/src/i18n/ja.ts +1 -0
  49. package/src/i18n/ko.ts +1 -0
  50. package/src/i18n/zh-cn.ts +1 -0
  51. package/src/i18n/zh-tw.ts +1 -0
  52. package/src/market-data/market/freshness.ts +2 -2
  53. package/src/market-data/market/globex-day.ts +14 -0
  54. package/src/market-data/published-us-sessions.ts +3 -2
  55. package/src/market-data/quotes/live-valuation.ts +4 -2
  56. package/src/market-data/quotes/metadata.ts +48 -5
  57. package/src/market-data/quotes/regular-session-valuation.ts +12 -1
  58. package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
  59. package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
  60. package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
  61. package/src/plugins/builtin/chat/channels.ts +5 -2
  62. package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
  63. package/src/plugins/builtin/chat/content/footer.tsx +17 -7
  64. package/src/plugins/builtin/chat/content/index.tsx +108 -36
  65. package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
  66. package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
  68. package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
  69. package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
  70. package/src/plugins/builtin/chat/content/types.ts +2 -0
  71. package/src/plugins/builtin/chat/controller/channels.ts +15 -15
  72. package/src/plugins/builtin/chat/controller/index.ts +140 -34
  73. package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
  74. package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
  75. package/src/plugins/builtin/chat/controller/send.ts +41 -17
  76. package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
  77. package/src/plugins/builtin/chat/controller/state.ts +17 -8
  78. package/src/plugins/builtin/chat/controller/storage.ts +41 -4
  79. package/src/plugins/builtin/chat/controller/view.ts +6 -3
  80. package/src/plugins/builtin/chat/index.tsx +1 -1
  81. package/src/plugins/builtin/chat/layout.ts +8 -1
  82. package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
  83. package/src/plugins/builtin/chat/message/header.tsx +112 -30
  84. package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
  85. package/src/plugins/builtin/chat/message/render-state.ts +4 -2
  86. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  87. package/src/plugins/builtin/chat/message/types.ts +5 -0
  88. package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
  89. package/src/plugins/builtin/company-kpis/model.ts +11 -3
  90. package/src/plugins/builtin/correlation/compute.ts +6 -1
  91. package/src/plugins/builtin/custom-view/loader.ts +95 -34
  92. package/src/plugins/builtin/custom-view/pane.tsx +31 -41
  93. package/src/plugins/builtin/custom-view/table.ts +201 -0
  94. package/src/plugins/builtin/dividend-yield/client.ts +14 -17
  95. package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
  96. package/src/plugins/builtin/dividend-yield/model.ts +45 -6
  97. package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
  98. package/src/plugins/builtin/dividend-yield/types.ts +2 -3
  99. package/src/plugins/builtin/dividend-yield/view.ts +22 -2
  100. package/src/plugins/builtin/econ/calendar-model.ts +135 -0
  101. package/src/plugins/builtin/econ/columns.ts +132 -0
  102. package/src/plugins/builtin/econ/index.tsx +25 -65
  103. package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
  104. package/src/plugins/builtin/holders/disclosures.ts +20 -6
  105. package/src/plugins/builtin/holders/headless.ts +2 -2
  106. package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
  107. package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
  108. package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
  109. package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
  110. package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
  111. package/src/plugins/builtin/market-halts/pane.tsx +14 -2
  112. package/src/plugins/builtin/news/wire/news/row.ts +5 -12
  113. package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
  114. package/src/plugins/builtin/pe-band/headless.ts +1 -1
  115. package/src/plugins/builtin/pe-band/model.ts +41 -18
  116. package/src/plugins/builtin/pe-band/pane.tsx +6 -5
  117. package/src/plugins/builtin/perps/equity-row.tsx +4 -6
  118. package/src/plugins/builtin/perps/markets-section.tsx +19 -15
  119. package/src/plugins/builtin/perps/model.ts +10 -2
  120. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
  121. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
  122. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
  123. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
  124. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
  125. package/src/plugins/builtin/research/event-data.ts +3 -1
  126. package/src/plugins/builtin/research/event-model.ts +17 -15
  127. package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
  128. package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
  129. package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
  130. package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
  131. package/src/plugins/builtin/sec/headless.ts +8 -8
  132. package/src/plugins/builtin/sec/index.tsx +69 -29
  133. package/src/plugins/builtin/shared/report-freshness.ts +4 -1
  134. package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
  135. package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
  136. package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
  137. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
  138. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
  139. package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
  140. package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
  141. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
  142. package/src/plugins/builtin/time-sales/model.ts +16 -9
  143. package/src/plugins/builtin/time-sales/pane.tsx +27 -24
  144. package/src/plugins/builtin/treasury-daily/client.ts +43 -9
  145. package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
  146. package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
  147. package/src/portfolio/positions-import/parse.ts +14 -6
  148. package/src/portfolio/positions-import/plan.ts +3 -2
  149. package/src/react/async-resource.ts +3 -1
  150. package/src/renderers/dom/data-table/index.tsx +40 -0
  151. package/src/renderers/dom/data-table/row.tsx +39 -3
  152. package/src/renderers/dom/desktop/icons.tsx +147 -3
  153. package/src/renderers/dom/desktop/popover.tsx +2 -2
  154. package/src/renderers/dom/host/media-surface.tsx +204 -45
  155. package/src/renderers/dom/host/tabs.tsx +1 -0
  156. package/src/renderers/dom/styles.css +14 -2
  157. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  158. package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
  159. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  160. package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
  161. package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
  162. package/src/sources/gloomberb-cloud/index.ts +8 -7
  163. package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
  164. package/src/sources/listing-symbols.ts +7 -1
  165. package/src/sources/provider-router/cache.ts +5 -4
  166. package/src/sources/provider-router/financials.ts +40 -18
  167. package/src/state/app/tab-cursor.ts +47 -6
  168. package/src/telemetry/stall-clocks.ts +3 -0
  169. package/src/telemetry/stall-reports.ts +12 -3
  170. package/src/telemetry/windows-process-activity.ts +41 -0
  171. package/src/telemetry/windows-time.ts +32 -0
  172. package/src/test-support/scoped-earnings.ts +24 -0
  173. package/src/tickers/terminal-codes.ts +1 -6
  174. package/src/time-series/daily-valuation.ts +13 -6
  175. package/src/time-series/filed-trailing-eps.ts +16 -3
  176. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  177. package/src/time-series/fundamentals/historical-valuation.ts +20 -0
  178. package/src/time-series/fundamentals/series.ts +13 -1
  179. package/src/time-series/valuation-currency.ts +2 -0
  180. package/src/types/financials.ts +46 -10
  181. package/src/ui/dialog-context.ts +8 -0
  182. package/src/utils/datetime-format.ts +23 -1
  183. package/src/utils/declared-dividends.ts +12 -2
  184. package/src/utils/exchange-announcements.ts +4 -1
  185. package/src/utils/exchange-notation.generated.ts +3 -1
  186. package/src/utils/exchanges.ts +2 -1
  187. package/src/utils/fundamentals.ts +1 -0
  188. package/src/utils/main-thread-stall.ts +9 -1
  189. package/src/utils/rpc-timeout-error.ts +36 -11
  190. package/src/utils/sec.ts +3 -1
  191. package/src/utils/share-multiples.ts +1 -1
  192. package/src/utils/stall-process-activity.ts +70 -0
  193. package/src/utils/statement-scope.ts +103 -0
  194. package/src/utils/trailing-eps.ts +1 -1
  195. package/src/utils/zoned-date-time.ts +1 -0
@@ -38,6 +38,7 @@ import { resolveDataTableScrollTop } from "../visible-range";
38
38
  import { useFocusOwningPane, useVisibleRangeEmitter } from "../hooks";
39
39
  import { ObservedTableRow } from "../observed-row";
40
40
  import { useStableColumns } from "../stable-columns";
41
+ import { tableCellSpill } from "../spill";
41
42
  import { COLUMN_DRAG_THRESHOLD_CELLS, columnDropBoundary, columnDropIndex } from "../column-order";
42
43
  import {
43
44
  columnsShownWhole,
@@ -245,6 +246,29 @@ function OpenTuiDataTableRowInner<
245
246
  const rowBackgroundColor = getRowBackgroundColor?.(item, index, rowState);
246
247
  const rowBg = selected ? selectionBg : rowBackgroundColor ?? colors.bg;
247
248
  const rowHoverBg = selected ? undefined : hoverBg(colors);
249
+ const madeCells = displayColumns.map((column, columnIndex) => renderCell(item, cellColumns[columnIndex] ?? column, index, rowState));
250
+ // The cells of a column hidden under the frozen first one, as the table scrolls sideways.
251
+ const insetOf = (columnIndex: number) => {
252
+ const column = displayColumns[columnIndex];
253
+ if (!column) return 0;
254
+ const clip = columnClips?.[columnIndex] ?? null;
255
+ if (clip) return clip.inset;
256
+ return columnIndex > 0 && frozenColumnOffset !== undefined
257
+ ? Math.min(column.width, Math.max(0, frozenColumnOffset + (displayColumns[0]?.width ?? 0) + columnGap - (columnStarts[columnIndex] ?? 0))) : 0;
258
+ };
259
+ // A cut name reads on into the blank of the figure after it in its row (tableCellSpill), between two columns
260
+ // that both show whole: the frozen column, and one the viewport or the frozen column cuts, keep their cells.
261
+ const spill = displayColumns.map((column, columnIndex) => (
262
+ (columnIndex === 0 && frozenColumnOffset !== undefined) || columnClips?.[columnIndex] || columnClips?.[columnIndex + 1]
263
+ || insetOf(columnIndex) > 0 || insetOf(columnIndex + 1) > 0
264
+ ? 0 : tableCellSpill(column, madeCells[columnIndex]!, displayColumns[columnIndex + 1], madeCells[columnIndex + 1], columnGap)
265
+ ));
266
+ // The cells the edge between two columns moves right: what the text takes past its column and its blank after
267
+ // it, beyond the gap that was there.
268
+ const edgeMoved = (columnIndex: number) => {
269
+ const cells = spill[columnIndex] ?? 0;
270
+ return cells > 0 ? Math.max(0, cells + 1 - columnGap) : 0;
271
+ };
248
272
 
249
273
  return (
250
274
  <Box
@@ -271,23 +295,30 @@ function OpenTuiDataTableRowInner<
271
295
  const frozen = columnIndex === 0 && frozenColumnOffset !== undefined;
272
296
  const clip = columnClips?.[columnIndex] ?? null;
273
297
  const cellColumn = cellColumns[columnIndex] ?? column;
274
- const made = renderCell(item, cellColumn, index, rowState);
275
- // A drawn cell lays itself out in the column as drawn; its width is the one made for its column unfitted.
276
- const cell = made.content !== undefined && cellColumn !== column ? renderCell(item, column, index, rowState) : made;
298
+ const made = madeCells[columnIndex]!;
277
299
  widths[columnIndex] = made.content === undefined ? displayWidth(made.text) : made.contentWidth ?? null;
278
- const columnStart = columnStarts[columnIndex] ?? 0;
279
300
  const leadGap = tableColumnLeadGap(displayColumns, columnIndex, columnGap);
280
- const inset = clip ? clip.inset : !frozen && frozenColumnOffset !== undefined
281
- ? Math.min(column.width, Math.max(0, frozenColumnOffset + (displayColumns[0]?.width ?? 0) + columnGap - columnStart)) : 0;
282
- const shownWidth = clip ? clip.width : column.width - inset;
301
+ const inset = insetOf(columnIndex);
302
+ // The edge before this column moved right by what the name before it took; the one after it, by what its own text took.
303
+ const given = columnIndex > 0 ? edgeMoved(columnIndex - 1) : 0;
304
+ const taken = spill[columnIndex] ?? 0;
305
+ const shownWidth = (clip ? clip.width : column.width - inset) + taken - given;
306
+ // A drawn cell lays itself out in the column as drawn; its width is the one made for its column unfitted.
307
+ // One that says its width (`contentWidth`) is made for the cells of a cut column that show, as cut text
308
+ // is fitted to them, so it gives up a piece whole where the edge would cut it.
309
+ const drawnColumn = made.contentWidth !== undefined && shownWidth > 0 && shownWidth < column.width
310
+ ? { ...column, width: shownWidth } : column;
311
+ const cell = made.content !== undefined && cellColumn !== drawnColumn ? renderCell(item, drawnColumn, index, rowState) : made;
283
312
  // Cut text is fitted to what shows; a number the edge cuts stays blank in its own place,
284
- // and its cell keeps its background and its press.
285
- const fitted = fitColumnCellText(cell.text, clip ? column.width : shownWidth, column.align, clip, cell.note, cell.keepEnd);
286
- const contentCut = clip !== null && column.align === "right" && fitted.text.trim() === "";
313
+ // and its cell keeps its background and its press. A drawn cell left no cells draws nothing, as text does.
314
+ // A figure padded to its column's width gives the name before it its blank, so it is fitted without it.
315
+ const fitted = fitColumnCellText(given > 0 ? cell.text.trimStart() : cell.text, clip ? column.width : shownWidth, column.align, clip, cell.note,
316
+ cell.keepEnd);
317
+ const contentCut = shownWidth <= 0 || (clip !== null && column.align === "right" && fitted.text.trim() === "");
287
318
  return (
288
319
  <Box
289
320
  key={column.id}
290
- width={column.width + columnGap + (frozen ? horizontalPadding : 0)}
321
+ width={column.width + columnGap + (frozen ? horizontalPadding : 0) + edgeMoved(columnIndex) - given}
291
322
  marginLeft={frozen ? -horizontalPadding : leadGap}
292
323
  position="relative"
293
324
  left={frozen ? frozenColumnOffset : undefined}
@@ -0,0 +1,36 @@
1
+ import { displayWidth } from "../../../utils/format";
2
+ import type { DataTableCell, DataTableColumn } from "./types";
3
+
4
+ /** A cell that draws its text and nothing else: no drawing, artwork, note, fill or press of its own. */
5
+ function drawsPlainText(cell: DataTableCell): boolean {
6
+ return cell.content === undefined && !cell.note && cell.leading === undefined && cell.backgroundColor === undefined && !cell.onMouseDown;
7
+ }
8
+
9
+ /**
10
+ * How many cells past its column a row's text reads on. A left-aligned text
11
+ * its column cuts ("RatingDog Manufacturing …") goes on into the blank the
12
+ * right-aligned text after it leaves in the same row (a dash in a figure
13
+ * column seven cells wide leaves six), up to one blank before that text, and
14
+ * is cut there if it is longer still. Each row reads only its own blank: no
15
+ * column moves as the rows scroll by, and a long figure in another row takes
16
+ * nothing from this one. 0 when the text fits, when the next column is not
17
+ * right-aligned, or when either cell draws more than its text.
18
+ *
19
+ * Every renderer draws it from this: the terminal moves the edge between the
20
+ * two cells, the desktop and the web let the text's cell span the next
21
+ * column, its text stopping a blank before the figure.
22
+ */
23
+ export function tableCellSpill(
24
+ column: Pick<DataTableColumn, "width" | "align">,
25
+ cell: DataTableCell,
26
+ next: Pick<DataTableColumn, "width" | "align"> | undefined,
27
+ nextCell: DataTableCell | undefined,
28
+ columnGap: number,
29
+ ): number {
30
+ if (!next || !nextCell || (column.align ?? "left") !== "left" || next.align !== "right") return 0;
31
+ if (!drawsPlainText(cell) || !drawsPlainText(nextCell)) return 0;
32
+ const past = displayWidth(cell.text) - column.width;
33
+ if (past <= 0) return 0;
34
+ const blank = next.width - displayWidth(nextCell.text.trimStart()) + columnGap - 1;
35
+ return Math.max(0, Math.min(past, blank));
36
+ }
@@ -109,6 +109,10 @@ export interface DataTableCell {
109
109
  * The cells `content` takes to show whole in the terminal, where a table
110
110
  * fits its columns to what they hold before it cuts one or pushes one out of
111
111
  * view. Without it a drawn cell's column keeps the width the pane set.
112
+ *
113
+ * A cell that gives it is also made again for a column the pane's edge
114
+ * cuts, with the cells that show as the column's width, so it can give up
115
+ * a piece whole (a second link, a badge) where the edge would cut it.
112
116
  */
113
117
  contentWidth?: number;
114
118
  /**
@@ -353,6 +357,14 @@ export interface DataTableProps<
353
357
  index: number,
354
358
  rowState: DataTableRowState,
355
359
  ) => string | undefined;
360
+ /**
361
+ * A row that is shown but does not apply right now (a story or a print out
362
+ * after the tab's pinned moment): the whole row reads in `textMuted` and
363
+ * plain weight, its value colours and the content its cells draw (ticker
364
+ * badges) included, and it stays selectable. One rule for every table, so a
365
+ * pane does not mute its cells one by one.
366
+ */
367
+ isRowMuted?: (item: T, index: number) => boolean;
356
368
  emptyContent?: ReactNode;
357
369
  bodyAfter?: ReactNode;
358
370
  emptyStateTitle: string;
@@ -397,8 +409,12 @@ export interface DataTableProps<
397
409
  * What Export CSV writes in place of the rows drawn, for a pane whose
398
410
  * export is the data behind its view rather than one table: the backtest
399
411
  * writes its daily curve, as `fn BT --csv --equity` prints it.
412
+ * `inReaderOrder` puts a list of the table's columns in the order the
413
+ * reader left the table's (a header drag), as the table's own export
414
+ * writes them: a pane that writes columns the table does not draw keeps
415
+ * the reader's order with it.
400
416
  */
401
- exportCsv?: () => string;
417
+ exportCsv?: (inReaderOrder: (columns: readonly C[]) => C[]) => string;
402
418
  /**
403
419
  * The rows Export CSV writes in place of `items`, for a table that draws
404
420
  * fewer rows than it holds: a watchlist writes the rows of a collapsed group too.
@@ -33,6 +33,12 @@ const ID_SEPARATOR = "\u0000";
33
33
  export interface DataTableColumnOrder<C extends DataTableColumn> {
34
34
  /** The columns in the order the reader left them. */
35
35
  columns: C[];
36
+ /**
37
+ * Another list of the table's columns (what a pane exports, drawn or not) in the order the reader left the
38
+ * table's: the columns they share keep that order, and one the table does not draw stays after the one it
39
+ * follows in the list.
40
+ */
41
+ order: (columns: readonly C[]) => C[];
36
42
  /** Moves a column to an index of `columns`; absent where the order is fixed. */
37
43
  onColumnMove?: (columnId: string, toIndex: number) => void;
38
44
  anchoredColumns: number;
@@ -75,6 +81,10 @@ export function useDataTableColumnOrder<C extends DataTableColumn>(
75
81
  () => enabled ? orderColumns(columns, saved, anchored) : columns,
76
82
  [anchored, columns, enabled, saved],
77
83
  );
84
+ const anchoredOption = options?.anchored;
85
+ const order = useCallback((others: readonly C[]): C[] => (enabled
86
+ ? [...orderColumns(others, saved, Math.min(others.length, anchoredOption ?? rowAnchorColumnCount(others)))]
87
+ : [...others]), [anchoredOption, enabled, saved]);
78
88
  const updateSetting = useOptionalPaneSettingUpdater(paneId, COLUMN_ORDER_SETTING);
79
89
  const latest = useRef({ columns, ordered, control, key, anchored });
80
90
  latest.current = { columns, ordered, control, key, anchored };
@@ -127,6 +137,7 @@ export function useDataTableColumnOrder<C extends DataTableColumn>(
127
137
 
128
138
  return {
129
139
  columns: ordered as C[],
140
+ order,
130
141
  onColumnMove: enabled ? onColumnMove : undefined,
131
142
  anchoredColumns: anchored,
132
143
  customized,
@@ -41,7 +41,9 @@ export type IconName =
41
41
  | "pro"
42
42
  | "clock"
43
43
  | "edit"
44
- | "mail";
44
+ | "mail"
45
+ | "reply"
46
+ | "react";
45
47
 
46
48
  /** Terminal glyph for each icon; the desktop host draws SVG. */
47
49
  export const ICON_GLYPHS: Record<IconName, string> = {
@@ -95,6 +97,14 @@ export const ICON_GLYPHS: Record<IconName, string> = {
95
97
  edit: "✎",
96
98
  // A message written to you (a DM): text presentation, one cell.
97
99
  mail: "✉",
100
+ // Answer a message, and add a reaction to it: the keys that do it, Enter's
101
+ // return symbol and the plus. Menlo, SF Mono, Cascadia and DejaVu Sans Mono
102
+ // each draw the return symbol themselves, at the size of the glyphs beside
103
+ // it; ↵ is missing from SF Mono and Cascadia and comes small from a
104
+ // fallback font, and a face shrinks to a dot at text size. One cell each:
105
+ // the hooked arrow and the outlined face are emoji-capable and take two.
106
+ reply: "⏎",
107
+ react: "+",
98
108
  };
99
109
 
100
110
  export interface IconProps {
@@ -134,10 +144,17 @@ export interface IconButtonProps {
134
144
  label: string;
135
145
  /** Tooltip when it should say more than the name (a count, a state). */
136
146
  title?: string;
137
- /** Key that triggers the same action, announced to assistive tech. */
147
+ /**
148
+ * Key that triggers the same action, announced to assistive tech and named
149
+ * in the tooltip. Give it only while the key acts on what this button acts
150
+ * on: a row's action names its key on the row the keyboard is on, while its
151
+ * pane has the keys, and on no other row.
152
+ */
138
153
  shortcut?: string;
139
154
  /** The press opens a menu or dialog. */
140
155
  hasPopup?: "menu" | "dialog";
156
+ /** The menu or dialog it opens is open. */
157
+ expanded?: boolean;
141
158
  onPress?: (event?: IconButtonPressEvent) => void;
142
159
  /** Toggle state for a pressed/unpressed icon (quick settings). */
143
160
  pressed?: boolean;
@@ -146,8 +163,31 @@ export interface IconButtonProps {
146
163
  size?: number;
147
164
  /** Keep the press from also reaching a row or header behind the button. */
148
165
  stopPropagation?: boolean;
166
+ /**
167
+ * The pointer moved onto or off it. The terminal draws no tooltip, so a row
168
+ * of icons names the one under the pointer beside itself with this.
169
+ */
170
+ onHoverChange?: (hovered: boolean) => void;
171
+ /**
172
+ * Desktop: while keyboard focus is on it, show its tooltip text beside it in
173
+ * the tooltip surface, since a tooltip shows only under the pointer. For
174
+ * icons with no other visible name (a row's actions that show only when
175
+ * used). The label goes beside the nearest `ICON_GROUP_ATTRIBUTE` element
176
+ * holding the button, so it never covers the icons next to it, follows the
177
+ * group as its row moves, and hides while a list has the group scrolled
178
+ * out of view. A pointer press, which focuses the button too, shows
179
+ * nothing. When its pane gives up the app's focus (Tab to the next pane),
180
+ * the button lets go of the page's focus as well.
181
+ */
182
+ focusLabel?: boolean;
149
183
  }
150
184
 
185
+ /**
186
+ * Marks a row of icon buttons whose `focusLabel` goes beside the whole row,
187
+ * not over the icons next to the focused one.
188
+ */
189
+ export const ICON_GROUP_ATTRIBUTE = "data-gloom-icon-group";
190
+
151
191
  /**
152
192
  * The one icon-only button: pane header actions, footer indicators, dialog
153
193
  * close, window controls. Desktop draws a hover-washed square with an SVG;
@@ -159,12 +199,15 @@ export function IconButton({
159
199
  title,
160
200
  shortcut,
161
201
  hasPopup,
202
+ expanded,
162
203
  onPress,
163
204
  pressed,
164
205
  color,
165
206
  disabled = false,
166
207
  size = 12,
167
208
  stopPropagation = true,
209
+ onHoverChange,
210
+ focusLabel,
168
211
  }: IconButtonProps) {
169
212
  const colors = useThemeColors();
170
213
  const label = t(rawLabel);
@@ -175,7 +218,7 @@ export function IconButton({
175
218
  label,
176
219
  disabled,
177
220
  actions: { press: () => { if (!disabled) onPress?.(); } },
178
- metadata: { icon, pressed, ...(remoteScope ? { scope: remoteScope } : {}) },
221
+ metadata: { icon, pressed, expanded, ...(remoteScope ? { scope: remoteScope } : {}) },
179
222
  });
180
223
  const HostIconButton = useUiHost().IconButton as ComponentType<IconButtonProps> | undefined;
181
224
  if (HostIconButton) {
@@ -186,12 +229,15 @@ export function IconButton({
186
229
  title={title}
187
230
  shortcut={shortcut}
188
231
  hasPopup={hasPopup}
232
+ expanded={expanded}
189
233
  onPress={onPress}
190
234
  pressed={pressed}
191
235
  color={color}
192
236
  disabled={disabled}
193
237
  size={size}
194
238
  stopPropagation={stopPropagation}
239
+ onHoverChange={onHoverChange}
240
+ focusLabel={focusLabel}
195
241
  />
196
242
  );
197
243
  }
@@ -208,6 +254,7 @@ export function IconButton({
208
254
  }
209
255
  if (!disabled) onPress?.(event);
210
256
  }}
257
+ {...(onHoverChange ? { onMouseOver: () => onHoverChange(true), onMouseOut: () => onHoverChange(false) } : {})}
211
258
  >
212
259
  {/* Pressed takes the colour the desktop and the terminal pane header give an active toggle. */}
213
260
  <Text fg={disabled ? colors.textMuted : color ?? (pressed ? colors.warning : colors.textDim)} selectable={false}>
@@ -336,8 +336,8 @@ export function ListView({
336
336
  const syncScrollBar = useCallback(() => {
337
337
  const sb = scrollRef.current;
338
338
  if (!scrollable || !sb?.verticalScrollBar) return;
339
- sb.verticalScrollBar.visible = items.length * rowStride - terminalRowGap > (sb.viewport?.height ?? 0);
340
- }, [items.length, rowStride, scrollable, terminalRowGap]);
339
+ sb.verticalScrollBar.visible = scrollbar && items.length * rowStride - terminalRowGap > (sb.viewport?.height ?? 0);
340
+ }, [items.length, rowStride, scrollable, scrollbar, terminalRowGap]);
341
341
  useEffect(syncScrollBar, [syncScrollBar, height, flexGrow]);
342
342
  // A list that mounts before its first layout has no viewport height to
343
343
  // compare yet, which would leave a scroll bar on rows that all fit.
@@ -210,6 +210,38 @@ export function dropColumnsToFit<C extends TableWidthColumn & { id: string }>(
210
210
  /** A table's own narrow-pane order: the columns that leave first, least needed first (`dropColumnsToFit`). */
211
211
  export type TableColumnDropOrder = readonly (string | readonly string[])[];
212
212
 
213
+ /**
214
+ * `columns` with the cells only a long value needs given to the name column
215
+ * beside them. A column as wide as the widest value in the whole list holds,
216
+ * on every row, the cells one value weeks out takes (`1.522B AUD`, a rate
217
+ * range): while the name column gets fewer than `need` cells (the longest
218
+ * name listed, say), the widest of `columns` gives up a cell at a time, down
219
+ * to `plain` cells (what an ordinary value takes) and never under its header.
220
+ * That long value is then cut with an ellipsis, whole in the row's detail,
221
+ * and a name is cut only once every column is down to its floor. A column
222
+ * already as narrow is left as it is. `room` is the cells the name column
223
+ * gets beside the columns given. The list's widths, not the rows in view, so
224
+ * no column moves as the reader scrolls.
225
+ */
226
+ export function narrowColumnsForName<C extends TableWidthColumn>(
227
+ columns: readonly C[],
228
+ room: (columns: readonly C[]) => number,
229
+ need: number,
230
+ plain: number | ((column: C) => number),
231
+ ): C[] {
232
+ const floor = (column: C) => Math.max(typeof plain === "number" ? plain : plain(column), tableColumnWidth({ width: 1, label: column.label }));
233
+ let fitted = [...columns];
234
+ while (room(fitted) < need) {
235
+ let widest = -1;
236
+ for (const [index, column] of fitted.entries()) {
237
+ if (column.width > floor(column) && (widest < 0 || column.width > fitted[widest]!.width)) widest = index;
238
+ }
239
+ if (widest < 0) break;
240
+ fitted = fitted.map((column, index) => (index === widest ? { ...column, width: column.width - 1 } : column));
241
+ }
242
+ return fitted;
243
+ }
244
+
213
245
  /** The fewest cells a column set to grow is narrowed to by a fit: under it a name or a sentence reads as nothing. */
214
246
  const FIT_TEXT_FLOOR = 12;
215
247
 
@@ -0,0 +1,49 @@
1
+ import { Box, Text } from "../../ui";
2
+ import { colors } from "../../theme/colors";
3
+ import { displayWidth, truncateToDisplayWidth } from "../../utils/format";
4
+
5
+ /** A hover label shorter than this (its padding and a letter with the ellipsis) is not drawn. */
6
+ const HOVER_LABEL_MIN_WIDTH = 4;
7
+
8
+ /**
9
+ * Terminal: which side of the controls under the pointer their name goes and
10
+ * its text with a space either side, given the free cells before and after
11
+ * them in the row: after when it fits, else before, else on the roomier side
12
+ * cut to fit, else nowhere. It never covers the controls, which keep the
13
+ * pointer. The desktop names a control in its tooltip instead.
14
+ */
15
+ export function terminalHoverLabelSide(
16
+ label: string,
17
+ { before, after }: { before: number; after: number },
18
+ ): { side: "before" | "after"; text: string } | null {
19
+ const text = ` ${label} `;
20
+ const textWidth = displayWidth(text);
21
+ if (textWidth <= after) return { side: "after", text };
22
+ if (textWidth <= before) return { side: "before", text };
23
+ const room = Math.max(after, before);
24
+ if (room < HOVER_LABEL_MIN_WIDTH) return null;
25
+ const cut = ` ${truncateToDisplayWidth(label, room - 2)} `;
26
+ return { side: after >= before ? "after" : "before", text: cut };
27
+ }
28
+
29
+ /**
30
+ * Terminal: the name of the control under the pointer, drawn over its own
31
+ * row `left` cells from the left of the box that places it, in the tooltip
32
+ * surface. Nothing in the row moves for it.
33
+ */
34
+ export function TerminalHoverLabel({ text, left, role }: { text: string; left: number; role: string }) {
35
+ return (
36
+ <Box
37
+ position="absolute"
38
+ top={0}
39
+ left={left}
40
+ height={1}
41
+ width={displayWidth(text)}
42
+ zIndex={1}
43
+ backgroundColor={colors.panel}
44
+ data-gloom-role={role}
45
+ >
46
+ <Text fg={colors.textBright} selectable={false}>{text}</Text>
47
+ </Box>
48
+ );
49
+ }
@@ -1,19 +1,228 @@
1
- import { usePinnedTabTime, useUnpinTab } from "../state/app/tab-cursor";
2
- import { usePaneFooter } from "./layout/pane/footer";
1
+ import { useCallback, useContext, useEffect, useId, useMemo, useRef } from "react";
2
+ import { AppContext, useOptionalPaneInstanceId, type AppState } from "../state/app/context";
3
+ import { usePinnedTabMoment, usePinnedTabMomentReader, useUnpinTab, type PinnedMoment } from "../state/app/tab-cursor";
4
+ import { findPaneInstance } from "../types/config";
5
+ import { formatDetailDate, formatZonedMoment } from "../utils/datetime-format";
6
+ import { usePaneFooter, type PaneFooterSegment } from "./layout/pane/footer";
7
+
8
+ /**
9
+ * The footer's one form for a list that follows the tab's pinned crosshair:
10
+ * `pinned 20 Nov 14:30 HKT`. Every list names the pin on the same clock, the
11
+ * host's, with its zone said, whatever clock its own rows are on (the tape's
12
+ * New York, a column in UTC), so no list reads the moment on another clock
13
+ * without saying so. Kept in a capture of the pane: it is why the later rows
14
+ * read muted.
15
+ */
16
+ export function pinnedMomentFooterSegment(at: number, now = Date.now(), timeZone?: string): PaneFooterSegment {
17
+ return {
18
+ id: "pinned-moment",
19
+ capture: true,
20
+ title: `Crosshair pinned at ${formatDetailDate(at, "", timeZone)}`,
21
+ parts: [{ text: `pinned ${formatZonedMoment(at, now, timeZone)}`, tone: "muted" }],
22
+ variants: [[{ text: "pinned", tone: "muted" }]],
23
+ };
24
+ }
3
25
 
4
26
  /**
5
27
  * For a list that follows the tab's pinned crosshair (news, the tape): the
6
- * pinned moment, null while nothing is pinned, and while it is pinned an
7
- * `[Esc]unpin` footer hint, so the pin can be seen and lifted from a pane with
8
- * no chart, the way Esc lifts it on one. `enabled: false` while Esc means
9
- * something else here, such as going back from an open item.
28
+ * pinned moment, null while nothing is pinned. While it is pinned the footer
29
+ * says so, focused or not, and a focused pane's footer offers `[Esc]unpin`, so
30
+ * the pin can be seen and lifted from a pane with no chart, the way Esc lifts
31
+ * it on one. Only the focused pane binds the key. `enabled: false` while Esc
32
+ * means something else here, such as going back from an open item; through
33
+ * `usePinnedList` it also holds the selection still under the open item.
10
34
  */
11
- export function usePinnedMoment(registrationId: string, { enabled = true }: { enabled?: boolean } = {}): number | null {
12
- const pinnedAt = usePinnedTabTime();
35
+ function usePinnedMoment(
36
+ registrationId: string,
37
+ { enabled = true, follows = true }: {
38
+ enabled?: boolean;
39
+ /** False for a list whose rows have no time of day to read a pin against: it neither follows nor says so. */
40
+ follows?: boolean;
41
+ } = {},
42
+ ): PinnedMoment | null {
43
+ const tabPin = usePinnedTabMoment();
44
+ const pinned = follows ? tabPin : null;
13
45
  const unpin = useUnpinTab();
14
- const offered = enabled && pinnedAt !== null;
15
- usePaneFooter(registrationId, () => offered
16
- ? { hints: [{ id: "unpin", key: "Esc", label: "unpin", title: "Unpin Crosshair", onPress: unpin }] }
17
- : null, [offered, unpin]);
18
- return pinnedAt;
46
+ const at = pinned?.at ?? null;
47
+ const offered = enabled && at !== null;
48
+ // After the pane's own status and keys.
49
+ usePaneFooter(registrationId, () => at === null ? null : {
50
+ order: 1,
51
+ info: [pinnedMomentFooterSegment(at)],
52
+ hints: offered ? [{ id: "unpin", key: "Esc", label: "unpin", title: "Unpin Crosshair", onPress: unpin }] : [],
53
+ }, [at, offered, unpin]);
54
+ return pinned;
55
+ }
56
+
57
+ export interface PinFollowOptions<T> {
58
+ /** The pin the list follows; null while there is none. */
59
+ pin: PinnedMoment | null;
60
+ rows: readonly T[];
61
+ getId: (row: T) => string;
62
+ /**
63
+ * When the row came out, in ms: an instant, to the minute or finer. Null for
64
+ * a row with no time of day (a filing day): it is never picked or muted, as
65
+ * a day cannot say whether it came before a moment in it.
66
+ */
67
+ moment: (row: T) => number | null;
68
+ /** Whether a row is later than the pinned moment, for a clock finer than `moment` (the tape's nanoseconds). */
69
+ isAfter?: (row: T, at: number) => boolean;
70
+ /**
71
+ * Orders two rows by when they came out, negative when `a` is earlier, for
72
+ * a clock finer than `moment`: two prints in one millisecond are told apart
73
+ * by their nanoseconds. By `moment` when unset.
74
+ */
75
+ order?: (a: T, b: T) => number;
76
+ /**
77
+ * The id the list keeps selected, as stored: null when it has picked none,
78
+ * even if it shows its first row then, and kept while its row is gone, so
79
+ * the pin can tell a pick from a fallback.
80
+ */
81
+ selectedId: string | null;
82
+ select: (id: string) => void;
83
+ /** Follows the pin again when this changes under it: the tape's trades and quotes tabs. */
84
+ followKey?: string;
85
+ /** Names the list in its pane, which remembers what it followed for as long as the pin stays. */
86
+ name: string;
87
+ /**
88
+ * Holds the selection still while an item is open over the list, so the
89
+ * item stays the one opened; back on the list, it follows a pin that moved
90
+ * meanwhile, and keeps its row otherwise.
91
+ */
92
+ paused?: boolean;
93
+ }
94
+
95
+ export interface PinFollow<T> {
96
+ /** The row the list goes to under the pin: the newest at or before it, else the earliest; null while nothing is pinned. */
97
+ pinnedRow: T | null;
98
+ /** The pin is earlier than every row with a time. */
99
+ beforeRows: boolean;
100
+ /** A row out after the pinned moment, which reads muted. */
101
+ isAfterPin: (row: T) => boolean;
102
+ }
103
+
104
+ /**
105
+ * The row a list goes to at a pinned moment: the newest out at or before it,
106
+ * else, when every row is later, the earliest. Of rows out at the same time,
107
+ * the first in the list is the newest and the last the earliest, so a list
108
+ * newest first gets the print nearest the moment either way. Rows with no
109
+ * time are left out.
110
+ */
111
+ export function pinnedRowOf<T>(
112
+ rows: readonly T[],
113
+ at: number,
114
+ moment: (row: T) => number | null,
115
+ after: (row: T, at: number) => boolean,
116
+ order?: (a: T, b: T) => number,
117
+ ): Pick<PinFollow<T>, "pinnedRow" | "beforeRows"> {
118
+ let newest: { row: T; at: number } | null = null;
119
+ let earliest: { row: T; at: number } | null = null;
120
+ const earlier = (row: T, rowAt: number, than: { row: T; at: number }) => (order ? order(row, than.row) : rowAt - than.at);
121
+ for (const row of rows) {
122
+ const rowAt = moment(row);
123
+ if (rowAt === null || !Number.isFinite(rowAt)) continue;
124
+ if (!earliest || earlier(row, rowAt, earliest) <= 0) earliest = { row, at: rowAt };
125
+ if (!after(row, at) && (!newest || earlier(row, rowAt, newest) > 0)) newest = { row, at: rowAt };
126
+ }
127
+ return { pinnedRow: newest?.row ?? earliest?.row ?? null, beforeRows: !newest && !!earliest };
128
+ }
129
+
130
+ const NOT_PINNED = { pinnedRow: null, beforeRows: false } as const;
131
+
132
+ /**
133
+ * What each list followed of a pin, by pane and list, kept with the pin: a
134
+ * list mounted again under the same pin (back from another layout tab) keeps
135
+ * the row picked there by hand, as a list left mounted does. A pin moved or
136
+ * lifted, or gone with its tab, takes its entries with it; a list closed with
137
+ * its pane drops its own, whether or not it still followed the pin then.
138
+ */
139
+ const followedPins = new WeakMap<PinnedMoment, Map<string, string>>();
140
+
141
+ /** How many lists remember following `pin`, for tests of what a closed pane leaves behind. */
142
+ export function pinFollowersForTests(pin: PinnedMoment): number {
143
+ return followedPins.get(pin)?.size ?? 0;
144
+ }
145
+
146
+ /** Whether a pane is still open in a layout tab, the active one or one switched away from. */
147
+ function paneInLayouts(state: AppState, paneId: string): boolean {
148
+ const { layout, layouts, activeLayoutIndex } = state.config;
149
+ return findPaneInstance(layout, paneId) !== undefined
150
+ || layouts.some((tab, index) => index !== activeLayoutIndex && findPaneInstance(tab.layout, paneId) !== undefined);
151
+ }
152
+
153
+ /**
154
+ * A list that follows the tab's pinned crosshair. The selection goes to the
155
+ * newest row out by the pinned moment when the pin moves, and when the rows
156
+ * first arrive under it, never when a row streams in, so a row picked by hand
157
+ * stays picked; lifting the pin leaves the selection where it is. A pin
158
+ * before every row selects the earliest row, the one nearest the moment,
159
+ * rather than keeping the row an earlier pin picked. Following commits the
160
+ * row's id, so rows streaming in above it never move it. Rows out after the
161
+ * moment are muted (`isAfterPin`, a table's `isRowMuted`).
162
+ */
163
+ export function usePinFollow<T>({ pin, rows, getId, moment, isAfter, order, selectedId, select, followKey = "", name, paused = false }: PinFollowOptions<T>): PinFollow<T> {
164
+ const at = pin?.at ?? null;
165
+ const after = useCallback((row: T, time: number) => {
166
+ if (isAfter) return isAfter(row, time);
167
+ const rowAt = moment(row);
168
+ return rowAt !== null && rowAt > time;
169
+ }, [isAfter, moment]);
170
+ const { pinnedRow, beforeRows } = useMemo(() => at === null ? NOT_PINNED
171
+ : pinnedRowOf(rows, at, moment, after, order), [after, at, moment, order, rows]);
172
+ const targetId = pinnedRow === null ? null : getId(pinnedRow);
173
+ // Read only under a pin: a list follows nothing without one, so its renders
174
+ // never look through the rows for the selection.
175
+ const selectedShown = pin !== null && selectedId !== null && rows.some((row) => getId(row) === selectedId);
176
+ const paneId = useOptionalPaneInstanceId();
177
+ const ownId = useId();
178
+ // A list outside a pane remembers only while it stays mounted.
179
+ const memoryKey = `${paneId ?? ownId}\u0000${name}`;
180
+ const selectRef = useRef(select);
181
+ selectRef.current = select;
182
+ useEffect(() => {
183
+ if (pin === null || paused) return;
184
+ const followed = followedPins.get(pin);
185
+ // Nothing loaded yet: the rows follow once they come. Already followed:
186
+ // the selection is the user's, unless it is gone from the list.
187
+ if (targetId === null || (followed?.get(memoryKey) === followKey && selectedShown)) return;
188
+ if (followed) followed.set(memoryKey, followKey);
189
+ else followedPins.set(pin, new Map([[memoryKey, followKey]]));
190
+ if (targetId !== selectedId) selectRef.current(targetId);
191
+ }, [followKey, memoryKey, paused, pin, selectedId, selectedShown, targetId]);
192
+
193
+ // A pane closed forgets what its list followed. Read once the unmount
194
+ // settles, from the app's state then: a pane switched away from with its
195
+ // tab, or remounted in place, is still in a layout and keeps it. The entry
196
+ // is found under the tab's pin, not the one the list was given: a list that
197
+ // stopped following before it closed (a tab of its pane with no list, a
198
+ // folded chart) was given none, though its entry stays under the tab's.
199
+ const app = useContext(AppContext);
200
+ const tabPin = usePinnedTabMomentReader();
201
+ useEffect(() => () => {
202
+ queueMicrotask(() => {
203
+ if (paneId !== null && app) {
204
+ const state = "getState" in app ? app.getState() : app.state;
205
+ if (paneInLayouts(state, paneId)) return;
206
+ }
207
+ const left = tabPin();
208
+ if (left !== null) followedPins.get(left)?.delete(memoryKey);
209
+ });
210
+ }, [app, memoryKey, paneId, tabPin]);
211
+
212
+ const isAfterPin = useCallback((row: T) => at !== null && after(row, at), [after, at]);
213
+ return { pinnedRow, beforeRows, isAfterPin };
214
+ }
215
+
216
+ /**
217
+ * `usePinnedMoment` and `usePinFollow` together, for a list beside the tab's
218
+ * charts. `enabled: false`, for an item open over the list, also holds the
219
+ * selection still until it closes.
220
+ */
221
+ export function usePinnedList<T>(
222
+ registrationId: string,
223
+ options: Omit<PinFollowOptions<T>, "pin" | "name" | "paused"> & { enabled?: boolean; follows?: boolean },
224
+ ): PinFollow<T> & { pin: PinnedMoment | null } {
225
+ const { enabled, follows, ...follow } = options;
226
+ const pin = usePinnedMoment(registrationId, { enabled, follows });
227
+ return { ...usePinFollow({ ...follow, pin, name: registrationId, paused: enabled === false }), pin };
19
228
  }