@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
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { PinnedMoment } from "../../../state/app/tab-cursor";
2
3
  import type { CompositeAxisValueFormatter } from "./format";
3
4
  import type { CompositeChartLevels } from "./levels";
4
5
  import type { SeriesLineCue } from "./series-cues";
@@ -289,6 +290,8 @@ interface CompositeCursorLink {
289
290
  pinned?(): boolean;
290
291
  /** Pins the shared cursor at a time no pointer moves, or unpins it with null. */
291
292
  pin?(time: number | null): void;
293
+ /** The pinned moment, the same object until the pin moves; null while nothing is pinned. */
294
+ pinnedMoment?(): PinnedMoment | null;
292
295
  }
293
296
 
294
297
  export interface CompositeChartProps {
@@ -352,6 +355,21 @@ export interface CompositeChartProps {
352
355
  * with a time axis in a pane shares its layout tab's; null keeps it out.
353
356
  */
354
357
  cursorLink?: CompositeCursorLink | null;
358
+ /**
359
+ * The pane's keys pin the tab's crosshair here though the chart is not
360
+ * focused, for a chart over a table whose arrows step the table: `p` (the
361
+ * footer's pin) pins it at the chart's cursor or lifts it, and while it is
362
+ * pinned Left and Right move the pin a bar and Esc lifts it. Set it only
363
+ * while the pane is focused.
364
+ */
365
+ pinKeys?: boolean;
366
+ /**
367
+ * Told the tab's pinned moment each time it moves, and null when it lifts,
368
+ * for an owner whose own cursor follows the pin (the table under a chart
369
+ * selects the row at it). A chart that does not share the tab's crosshair
370
+ * (a custom x axis) never tells it a pin.
371
+ */
372
+ onPinnedMomentChange?: (moment: PinnedMoment | null) => void;
355
373
  viewport?: {
356
374
  start: Date;
357
375
  end: Date;
@@ -105,6 +105,7 @@ export function useCompositeChartKeyboard({
105
105
  restingCursor,
106
106
  updateCursor,
107
107
  pin,
108
+ pinKeys = false,
108
109
  onActivate,
109
110
  timePick,
110
111
  pricePick,
@@ -145,6 +146,8 @@ export function useCompositeChartKeyboard({
145
146
  updateCursor: (date: Date | null) => void;
146
147
  /** The tab's crosshair pin, when there is a cursor to pin or a pin to lift. */
147
148
  pin: { pinned: boolean; toggle: () => void } | null;
149
+ /** The pin's keys work while the pane is focused, though the chart is not (`CompositeChartProps.pinKeys`). */
150
+ pinKeys?: boolean;
148
151
  onActivate: CompositeChartProps["onActivate"];
149
152
  timePick: CompositeChartProps["timePick"];
150
153
  pricePick: CompositeChartProps["pricePick"];
@@ -233,6 +236,8 @@ export function useCompositeChartKeyboard({
233
236
  const arrowsClaimed = usePaneArrowsClaimed();
234
237
  const keyboardActive = focused && interactive;
235
238
  const toolsActive = keyboardActive && navigable;
239
+ // A chart over a table takes only the pin's keys, the table keeping the rest.
240
+ const pinKeysActive = !keyboardActive && pinKeys && interactive && !!pin;
236
241
  // Under a tab strip, a chart you pan and draw on is one focus level down: the
237
242
  // strip keeps Left, Right, h and l until Down, Enter, a click or a tool moves
238
243
  // into the chart, and Esc or Up hands them back. A pane with no strip (G)
@@ -463,11 +468,28 @@ export function useCompositeChartKeyboard({
463
468
  // (Backspace back, Esc close) whichever mounted first; a dialog opened over
464
469
  // it is a newer scope and still comes first.
465
470
  useShortcut((event) => {
466
- if (!keyboardActive) return;
471
+ if (!keyboardActive && !pinKeysActive) return;
467
472
  const consume = () => {
468
473
  event.preventDefault();
469
474
  event.stopPropagation();
470
475
  };
476
+ if (!keyboardActive) {
477
+ // While pinned, Esc lifts the pin and Left and Right move it a bar, as
478
+ // on a focused chart; the table's selection follows it there.
479
+ if (!pin?.pinned || !scene) return;
480
+ if (isPlainKey(event, "escape")) {
481
+ consume();
482
+ pin.toggle();
483
+ return;
484
+ }
485
+ if (isPlainKey(event, "left", "right") && !arrowsClaimed) {
486
+ consume();
487
+ const nextDate = resolveAdjacentCompositeCursorDate(scene, keyboardCursorDateRef.current, event.name === "left" ? -1 : 1);
488
+ keyboardCursorDateRef.current = nextDate;
489
+ updateCursor(nextDate);
490
+ }
491
+ return;
492
+ }
471
493
  if (timePick && scene && isPlainKey(event, "return", "enter", "escape")) {
472
494
  consume();
473
495
  // A pick, like a placement below, is unfinished input: ending it is no half of a close.
@@ -676,7 +698,7 @@ export function useCompositeChartKeyboard({
676
698
  case "zoom-out":
677
699
  zoomViewport(1 / COMPOSITE_ZOOM_STEP_FACTOR);
678
700
  }
679
- }, { enabled: keyboardActive, scope: keyboardId });
701
+ }, { enabled: keyboardActive || pinKeysActive, scope: keyboardId });
680
702
 
681
703
  // The keys a mode adds show where they act: Enter with a tool in hand, Space
682
704
  // on a legend entry. Everything else the chart answers is in the pane menu.
@@ -737,7 +759,18 @@ export function useCompositeChartKeyboard({
737
759
  panelMaximized,
738
760
  } = layout;
739
761
  usePaneFooter(keyboardId, () => {
740
- if (!keyboardActive || !scene) return null;
762
+ if (!scene) return null;
763
+ const pinHint: PaneHint | null = pinState === null ? null : {
764
+ id: "chart-pin",
765
+ key: "p",
766
+ // "[p]in", and "[p] unpin" for the word that does not start with its key.
767
+ label: pinState ? " unpin" : "in",
768
+ title: pinState ? "Unpin Crosshair" : "Pin Crosshair",
769
+ // A pane whose own `p` means something else keeps it.
770
+ yieldsKey: true,
771
+ onPress: () => chartActionsRef.current.togglePin(),
772
+ };
773
+ if (!keyboardActive) return pinKeysActive && pinHint ? { order: 10, hints: [pinHint] } : null;
741
774
  const hints: PaneHint[] = [];
742
775
  if (timePickLabel) {
743
776
  hints.push({ id: "chart-pick", key: "Enter", label: timePickLabel, onPress: () => pickingPrice ? chartActionsRef.current.pickPrice() : chartActionsRef.current.pick() });
@@ -755,18 +788,7 @@ export function useCompositeChartKeyboard({
755
788
  onPress: () => chartActionsRef.current.levelAction(),
756
789
  });
757
790
  }
758
- if (pinState !== null) {
759
- hints.push({
760
- id: "chart-pin",
761
- key: "p",
762
- // "[p]in", and "[p] unpin" for the word that does not start with its key.
763
- label: pinState ? " unpin" : "in",
764
- title: pinState ? "Unpin Crosshair" : "Pin Crosshair",
765
- // A pane whose own `p` means something else keeps it.
766
- yieldsKey: true,
767
- onPress: () => chartActionsRef.current.togglePin(),
768
- });
769
- }
791
+ if (pinHint) hints.push(pinHint);
770
792
  if (legendKeysActive && legendEntryToggleable) {
771
793
  hints.push({
772
794
  id: "chart-series",
@@ -843,6 +865,7 @@ export function useCompositeChartKeyboard({
843
865
  canDeleteDrawing,
844
866
  drawingKeysActive,
845
867
  keyboardActive,
868
+ pinKeysActive,
846
869
  legendEntryToggleable,
847
870
  legendEntryVisible,
848
871
  legendKeysActive,
@@ -31,6 +31,7 @@ export interface ChartStripSpec {
31
31
  export interface ChartTableChart {
32
32
  /** Series the kit chart draws. Their labels are the chart's caption, so name what is plotted. */
33
33
  series?: readonly ResolvedSeries[];
34
+ allowSinglePoint?: boolean;
34
35
  panels?: ChartPanelSpec[];
35
36
  /** A chart the kit does not draw itself (a curve, a scatter), given the band's size. */
36
37
  render?: (size: { width: number; height: number }) => ReactNode;
@@ -54,6 +55,9 @@ export interface ChartTableChart {
54
55
  cursorDate?: Date | null;
55
56
  onCursorDateChange?: (date: Date | null) => void;
56
57
  onActivate?: () => void;
58
+ /** From `useChartTableSelection`: the pane's `p` pins the tab's crosshair on the chart, and the table follows the pin. */
59
+ pinKeys?: boolean;
60
+ onPinnedMomentChange?: CompositeChartProps["onPinnedMomentChange"];
57
61
  viewport?: { start: Date; end: Date };
58
62
  /** Ticks for an x axis that is not a calendar: one per bar, a tenor, a contract month. */
59
63
  xAxis?: CompositeChartProps["xAxis"];
@@ -88,13 +92,13 @@ export interface ChartTableHeaderProps {
88
92
  }
89
93
 
90
94
  /** The first shown series with a line to draw, and its values. */
91
- function plottable(series: readonly ResolvedSeries[] | undefined): { entry: ResolvedSeries; values: number[] } | null {
95
+ function plottable({ series, allowSinglePoint }: ChartTableChart): { entry: ResolvedSeries; values: number[] } | null {
92
96
  for (const entry of series ?? []) {
93
97
  if (entry.hidden) continue;
94
98
  const values = entry.points.flatMap((point) => (
95
99
  point.value != null && Number.isFinite(point.value) ? [point.value] : []
96
100
  ));
97
- if (values.length >= 2) return { entry, values };
101
+ if (values.length >= (allowSinglePoint ? 1 : 2)) return { entry, values };
98
102
  }
99
103
  return null;
100
104
  }
@@ -114,7 +118,7 @@ function seriesSpan(series: readonly ResolvedSeries[]): { first: number; last: n
114
118
  }
115
119
 
116
120
  function stripFromSeries(chart: ChartTableChart): ChartStripSpec | null {
117
- const line = plottable(chart.series);
121
+ const line = plottable(chart);
118
122
  const latest = line?.values.at(-1);
119
123
  if (!line || latest == null) return null;
120
124
  return {
@@ -178,7 +182,7 @@ export function ChartStrip({ strip, width, figures = [] }: {
178
182
  /** Where a pane puts its chart when it wants the kit's layout without the kit's header. */
179
183
  export function useChartTableLayout(props: ChartTableHeaderProps): ChartTableLayout {
180
184
  const { chart } = props;
181
- const hasChart = !!chart && (!!chart.render || !!plottable(chart.series) || !!chart.loading || !!chart.empty);
185
+ const hasChart = !!chart && (!!chart.render || !!plottable(chart) || !!chart.loading || !!chart.empty);
182
186
  return chartTableLayout({
183
187
  width: props.width,
184
188
  height: props.height,
@@ -234,7 +238,7 @@ export function ChartTableHeader(props: ChartTableHeaderProps) {
234
238
  if (chart && layout.mode === "full") {
235
239
  // No padding: the legend's own one-cell inset lines it up with the figures and the table.
236
240
  const size = { width: Math.max(1, width), height: layout.chartRows };
237
- const ready = !!chart.render || !!plottable(series);
241
+ const ready = !!chart.render || !!plottable(chart);
238
242
  band = (
239
243
  <Box height={layout.chartRows} flexShrink={0} overflow="hidden">
240
244
  {!ready ? (
@@ -256,6 +260,8 @@ export function ChartTableHeader(props: ChartTableHeaderProps) {
256
260
  cursorDate={chart.cursorDate}
257
261
  onCursorDateChange={chart.onCursorDateChange}
258
262
  onActivate={chart.onActivate}
263
+ pinKeys={chart.pinKeys}
264
+ onPinnedMomentChange={chart.onPinnedMomentChange}
259
265
  viewport={viewport}
260
266
  xAxis={chart.xAxis}
261
267
  legendAccessory={chart.legendAccessory}
@@ -1,7 +1,9 @@
1
1
  import { useCallback, useMemo, useRef, useState } from "react";
2
2
  import { usePaneArrowsClaimed } from "../layout/pane/footer/registration";
3
3
  import { useShortcut } from "../../react/input";
4
+ import type { PinnedMoment } from "../../state/app/tab-cursor";
4
5
  import { isPlainKey } from "../../utils/keyboard";
6
+ import { usePinFollow } from "../use-pinned-moment";
5
7
 
6
8
  export interface ChartTableSelectionOptions<T> {
7
9
  rows: readonly T[];
@@ -22,6 +24,10 @@ export interface ChartTableSelection {
22
24
  onCursorDateChange: (date: Date | null) => void;
23
25
  /** Clicking the chart selects the row under the pointer. */
24
26
  onActivate: () => void;
27
+ /** While the pane is focused, `p` pins the tab's crosshair at the chart's cursor; see `CompositeChartProps.pinKeys`. */
28
+ pinKeys: boolean;
29
+ /** The chart says where the tab's pin is, and the selection follows it. */
30
+ onPinnedMomentChange: (moment: PinnedMoment | null) => void;
25
31
  }
26
32
 
27
33
  interface DatedRow {
@@ -63,6 +69,12 @@ function undatedNeighbours(
63
69
  * nearest row; Left and Right step to the previous and next row in time, the
64
70
  * direction the chart reads, whatever order the table is sorted in. From a
65
71
  * row with no point they step to the nearest row that has one.
72
+ *
73
+ * The tab's pinned crosshair is the chart's too: `p` pins it at the chart's
74
+ * cursor and lifts it, and while it is pinned Left and Right move the pin a
75
+ * bar and Esc lifts it, as on a focused chart. The selection follows the pin
76
+ * to the newest row at or before it when it moves, so a row picked by hand
77
+ * under the pin stays picked. A chart with no time axis shares no pin.
66
78
  */
67
79
  export function useChartTableSelection<T>({
68
80
  rows,
@@ -137,9 +149,16 @@ export function useChartTableSelection<T>({
137
149
  if (next) onSelect(next.id);
138
150
  }, { enabled: enabled && focused && !arrowsClaimed && dated.length > 0 });
139
151
 
152
+ const [pin, setPin] = useState<PinnedMoment | null>(null);
153
+ const moment = useCallback((row: T) => {
154
+ const time = getDate(row)?.getTime();
155
+ return time != null && Number.isFinite(time) ? time : null;
156
+ }, [getDate]);
157
+ usePinFollow({ pin: enabled ? pin : null, rows, getId, moment, selectedId, select: onSelect, name: "chart-table" });
158
+
140
159
  const shownHover = hover && hover.under === selectedId ? hover.date : null;
141
160
  const cursorDate = !enabled
142
161
  ? null
143
162
  : shownHover ?? (selected ? new Date(selected.time) : null);
144
- return { cursorDate, onCursorDateChange, onActivate };
163
+ return { cursorDate, onCursorDateChange, onActivate, pinKeys: enabled && focused, onPinnedMomentChange: setPin };
145
164
  }
@@ -928,6 +928,8 @@ export function DataTableView<
928
928
  {bodyStatusShown(status) ? <PaneStatusBody {...status} /> : <DataTable<T, C>
929
929
  {...tableProps}
930
930
  columns={columns}
931
+ // The table drawn here gets the columns in order; a pane's own export gets that order to put on its columns.
932
+ exportCsv={tableProps.exportCsv && (() => tableProps.exportCsv!(columnOrder.order))}
931
933
  columnReorder={false}
932
934
  onColumnMove={onColumnMove}
933
935
  anchoredColumns={anchoredColumns}
@@ -10,6 +10,7 @@ import { nextHeaderSort } from "../../utils/sort-values";
10
10
  import { toTimestampMillis } from "../../utils/timestamp";
11
11
  import { DataTableStackView } from "../data-table/stack-view";
12
12
  import { usePaneFooter } from "../layout/pane/footer";
13
+ import { usePinnedList } from "../use-pinned-moment";
13
14
  import type { DataTableKeyEvent, DataTableRootKeyContext } from "../data-table/view";
14
15
  import {
15
16
  activeStackIndex,
@@ -55,6 +56,14 @@ export interface FeedDataTableTimeColumn {
55
56
  label: string;
56
57
  width: number;
57
58
  format: (timestamp: Date | string) => string;
59
+ /**
60
+ * Each item's `timestamp` is an instant, to the minute or finer, so the
61
+ * feed follows the tab's pinned crosshair: it selects the newest item out
62
+ * by the pinned moment and mutes the later ones. The default column (how
63
+ * long ago) is one. Leave it unset for a day, such as a filing date: a day
64
+ * cannot say whether it came before a moment in it.
65
+ */
66
+ instant?: boolean;
58
67
  }
59
68
 
60
69
  interface FeedDataTableStackViewProps {
@@ -84,9 +93,41 @@ interface FeedDataTableStackViewProps {
84
93
  }
85
94
 
86
95
  function timestampValue(item: FeedDataTableItem): number {
87
- if (!item.timestamp) return 0;
96
+ return itemMoment(item) ?? 0;
97
+ }
98
+
99
+ function itemMoment(item: FeedDataTableItem): number | null {
100
+ if (!item.timestamp) return null;
88
101
  const timestamp = toTimestampMillis(item.timestamp);
89
- return Number.isFinite(timestamp) ? timestamp : 0;
102
+ return Number.isFinite(timestamp) ? timestamp : null;
103
+ }
104
+
105
+ const rowId = (row: DetailRow) => row.item.id;
106
+ const rowMoment = (row: DetailRow) => itemMoment(row.item);
107
+
108
+ /** The item the selection is on, by id, and whether it went out of the list. */
109
+ interface KeptSelection {
110
+ index: number;
111
+ id: string | null;
112
+ lost: boolean;
113
+ }
114
+
115
+ /**
116
+ * Where the selection is once the items or the owner's index change. The
117
+ * owner moving the index moves it. In a feed that streams (`streams`), items
118
+ * coming in above it, or going out, leave it on the same item, though its
119
+ * index moves; when its item goes out, it takes the row now in its place, and
120
+ * says the item was `lost`, so a pin can pick the row at the pin instead. A
121
+ * feed that does not stream (filings by day) keeps the owner's index as it
122
+ * is, so an owner that sends a filtered list back to its top gets the top.
123
+ */
124
+ function keepSelection(kept: KeptSelection, items: readonly FeedDataTableItem[], index: number, streams: boolean): KeptSelection {
125
+ const id = items[index]?.id ?? null;
126
+ if (!streams || index !== kept.index || kept.id === null) {
127
+ return index === kept.index && id === kept.id && !kept.lost ? kept : { index, id, lost: false };
128
+ }
129
+ if (id === kept.id || items.some((item) => item.id === kept.id)) return kept;
130
+ return { index, id: items[Math.min(index, items.length - 1)]?.id ?? null, lost: true };
90
131
  }
91
132
 
92
133
  function compareText(a: string, b: string): number {
@@ -177,8 +218,26 @@ export function FeedDataTableStackView({
177
218
  const sortedRows = useMemo(() => {
178
219
  return sortIndexedStackRows(items, sortPreference, compareRows);
179
220
  }, [items, sortPreference]);
221
+ // The owner keeps an index; a feed of instants, which streams and follows
222
+ // the tab's pin, keeps the item at it. It moves the owner's index along with
223
+ // the item (below), and the row drawn selected is the item's from the first
224
+ // frame.
225
+ const streams = timeColumn ? timeColumn.instant === true : true;
226
+ const [keptState, setKept] = useState<KeptSelection>(() => ({ index: selectedIdx, id: items[selectedIdx]?.id ?? null, lost: false }));
227
+ let kept = keptState;
228
+ const nextKept = keepSelection(kept, items, selectedIdx, streams);
229
+ if (nextKept !== kept) {
230
+ kept = nextKept;
231
+ setKept(nextKept);
232
+ }
233
+ const keptIdx = kept.id === null ? -1
234
+ : items[selectedIdx]?.id === kept.id ? selectedIdx : items.findIndex((item) => item.id === kept.id);
235
+ const shownIdx = keptIdx >= 0 ? keptIdx : selectedIdx;
236
+ useEffect(() => {
237
+ if (keptIdx >= 0 && keptIdx !== selectedIdx) onSelect(keptIdx);
238
+ }, [keptIdx, onSelect, selectedIdx]);
180
239
  const selectedRowIndex = sortedRows.findIndex(
181
- (row) => row.itemIndex === selectedIdx,
240
+ (row) => row.itemIndex === shownIdx,
182
241
  );
183
242
  const activeRowIndex = activeStackIndex(sortedRows.length, selectedRowIndex);
184
243
  const openItem = useMemo(
@@ -228,10 +287,30 @@ export function FeedDataTableStackView({
228
287
  }, [activeOpenItemId, controlled, onOpenItemIdChange]);
229
288
 
230
289
  useEffect(() => {
231
- if (items.length > 0 && selectedIdx >= items.length) {
290
+ if (keptIdx < 0 && items.length > 0 && selectedIdx >= items.length) {
232
291
  onSelect(Math.max(0, items.length - 1));
233
292
  }
234
- }, [items.length, onSelect, selectedIdx]);
293
+ }, [items.length, keptIdx, onSelect, selectedIdx]);
294
+
295
+ // Items out at an instant follow the tab's pinned crosshair, as the news
296
+ // feeds do: the newest out by then is selected when the pin moves, the
297
+ // later ones read muted. A selected item gone from the feed reads as no
298
+ // selection there, so the pin's row takes its place.
299
+ const selectRow = useCallback((id: string) => {
300
+ const row = sortedRows.find((entry) => entry.item.id === id);
301
+ if (!row) return;
302
+ setKept((current) => (current.lost ? { ...current, lost: false } : current));
303
+ onSelect(row.itemIndex);
304
+ }, [onSelect, sortedRows]);
305
+ const { isAfterPin } = usePinnedList<DetailRow>("feed-table:pin", {
306
+ follows: streams,
307
+ enabled: !openItem,
308
+ rows: sortedRows,
309
+ getId: rowId,
310
+ moment: rowMoment,
311
+ selectedId: kept.lost ? null : kept.id,
312
+ select: selectRow,
313
+ });
235
314
 
236
315
  const renderCell = useCallback((
237
316
  row: DetailRow,
@@ -310,6 +389,7 @@ export function FeedDataTableStackView({
310
389
  )}
311
390
  getItemKey={(row) => row.item.id}
312
391
  renderCell={renderCell}
392
+ isRowMuted={isAfterPin}
313
393
  selectedTextOverridesCellColor
314
394
  emptyStateTitle={t(emptyStateTitle)}
315
395
  emptyStateHint={emptyStateHint}
@@ -9,6 +9,7 @@ import { capturePointerDrag } from "../../../ui/pointer-drag";
9
9
  import { Tabs } from "../../ui/tabs";
10
10
  import { Divider } from "../../ui/display";
11
11
  import { ICON_GLYPHS, Icon, IconButton } from "../../ui/icon";
12
+ import { TerminalHoverLabel, terminalHoverLabelSide } from "../../ui/terminal-hover-label";
12
13
  import { Button } from "../../ui/button";
13
14
  import { t } from "../../../i18n";
14
15
  import type { PaneHeaderTabsRegistration } from "./header-tabs";
@@ -320,16 +321,13 @@ function quickSettingTitle(setting: Pick<PaneHeaderQuickSetting, "label" | "acti
320
321
  return `${setting.label}: ${setting.active ? "on" : "off"}`;
321
322
  }
322
323
 
323
- /** Terminal: a hover label shorter than this (its padding and a letter with the ellipsis) is not drawn. */
324
- const QUICK_SETTING_LABEL_MIN_WIDTH = 4;
325
-
326
324
  /**
327
325
  * Terminal: where the label of the quick setting under the pointer goes in
328
326
  * its header's row, in cells from the header's left edge, and its text with
329
327
  * a space either side. It sits over the row beside the glyph, so nothing in
330
328
  * the header moves and the title keeps its width: after the glyph when it
331
329
  * fits before the frame's corner, else before it, else on the roomier side,
332
- * cut to fit. It never covers the glyph, which keeps the pointer.
330
+ * cut to fit (`terminalHoverLabelSide`).
333
331
  */
334
332
  export function terminalQuickSettingLabelPlacement(
335
333
  label: string,
@@ -343,18 +341,15 @@ export function terminalQuickSettingLabelPlacement(
343
341
  },
344
342
  ): { left: number; text: string } | null {
345
343
  const corner = framed ? 2 : 0;
346
- const after = Math.max(0, width - corner - (buttonStart + buttonWidth));
347
- const before = Math.max(0, buttonStart - corner);
348
- const text = ` ${label} `;
349
- const textWidth = displayWidth(text);
350
- if (textWidth <= after) return { left: buttonStart + buttonWidth, text };
351
- if (textWidth <= before) return { left: buttonStart - textWidth, text };
352
- const room = Math.max(after, before);
353
- if (room < QUICK_SETTING_LABEL_MIN_WIDTH) return null;
354
- const cut = ` ${truncateToDisplayWidth(label, room - 2)} `;
355
- return after >= before
356
- ? { left: buttonStart + buttonWidth, text: cut }
357
- : { left: buttonStart - displayWidth(cut), text: cut };
344
+ const placement = terminalHoverLabelSide(label, {
345
+ before: Math.max(0, buttonStart - corner),
346
+ after: Math.max(0, width - corner - (buttonStart + buttonWidth)),
347
+ });
348
+ if (!placement) return null;
349
+ return {
350
+ left: placement.side === "after" ? buttonStart + buttonWidth : buttonStart - displayWidth(placement.text),
351
+ text: placement.text,
352
+ };
358
353
  }
359
354
 
360
355
  /** Terminal: where each quick setting's button starts, in cells from the header's left edge, after `start`. */
@@ -384,20 +379,7 @@ function TerminalQuickSettingLabel({ setting, buttonStart, width, framed }: {
384
379
  framed,
385
380
  });
386
381
  if (!placement) return null;
387
- return (
388
- <Box
389
- position="absolute"
390
- top={0}
391
- left={placement.left}
392
- height={1}
393
- width={displayWidth(placement.text)}
394
- zIndex={1}
395
- backgroundColor={colors.panel}
396
- data-gloom-role="pane-quick-setting-label"
397
- >
398
- <Text fg={colors.textBright} selectable={false}>{placement.text}</Text>
399
- </Box>
400
- );
382
+ return <TerminalHoverLabel text={placement.text} left={placement.left} role="pane-quick-setting-label" />;
401
383
  }
402
384
 
403
385
  function TerminalPaneButton({
@@ -8,6 +8,7 @@ import { getTickerBadgeHoverText, getTickerBadgeText, tickerBadgeColors, type Ti
8
8
  import { displayWidth, padTo } from "../../../utils/format";
9
9
  import { tf } from "../../../i18n";
10
10
  import { usePaneLinkMenuEntry } from "../../ui/external-link";
11
+ import { useDataTableRowMuted } from "../../ui/data-table/muted-row";
11
12
 
12
13
  export interface TickerBadgeProps {
13
14
  symbol: string;
@@ -65,7 +66,11 @@ export function TickerBadge({
65
66
  });
66
67
  const quoteForDisplay = liveQuote ? quote : null;
67
68
  const shownMove = liveQuote && move != null && Number.isFinite(move) ? move : null;
68
- const tone = status === "ready" && shownMove != null
69
+ // A badge in a muted table row reads as the row does: muted, plain, no tone of its move.
70
+ const muted = useDataTableRowMuted();
71
+ const weight = muted ? TextAttributes.NONE : TextAttributes.BOLD;
72
+ const tone = muted ? colors.textMuted
73
+ : status === "ready" && shownMove != null
69
74
  ? priceColor(shownMove)
70
75
  : status === "ready" && quoteForDisplay
71
76
  ? priceColor(quoteForDisplay.changePercent)
@@ -113,18 +118,18 @@ export function TickerBadge({
113
118
  >
114
119
  {nativePaneChrome ? (
115
120
  <>
116
- <Text fg={color} attributes={TextAttributes.BOLD} style={price ? NATIVE_RESTING_TEXT_UNDER_PRICE : undefined}>
121
+ <Text fg={color} attributes={weight} style={price ? NATIVE_RESTING_TEXT_UNDER_PRICE : undefined}>
117
122
  {text}
118
123
  </Text>
119
124
  {price ? (
120
125
  <Box flexDirection="row" justifyContent="center" alignItems="center" style={NATIVE_PRICE_OVER_RESTING_TEXT}>
121
- <Text fg={color} attributes={TextAttributes.BOLD}>{price}</Text>
126
+ <Text fg={color} attributes={weight}>{price}</Text>
122
127
  </Box>
123
128
  ) : null}
124
129
  </>
125
130
  ) : (
126
131
  // Cells are exact: the price, centred in the resting text's cells, takes as many.
127
- <Text fg={color} attributes={TextAttributes.BOLD}>
132
+ <Text fg={color} attributes={weight}>
128
133
  {price ? padTo(price, displayWidth(text), "center") : text}
129
134
  </Text>
130
135
  )}
@@ -5,6 +5,7 @@ import { useInlineTickers, type InlineTickerCatalogEntry } from "../../../state/
5
5
  import { displayWidth } from "../../../utils/format";
6
6
  import { TickerBadge } from "./index";
7
7
  import { getTickerBadgeText, type TickerBadgeStatus } from "./format";
8
+ import { useDataTableRowMuted } from "../../ui/data-table/muted-row";
8
9
 
9
10
  /**
10
11
  * Rows scroll under the cursor, so a badge only starts resolving once its row
@@ -59,6 +60,7 @@ export function TickerBadgeList({
59
60
  onOpen,
60
61
  }: TickerBadgeListProps) {
61
62
  const [hoveredSymbol, setHoveredSymbol] = useState<string | null>(null);
63
+ const muted = useDataTableRowMuted();
62
64
  /**
63
65
  * A blank symbol names nothing, and a badge is a filled chip: drawing one for
64
66
  * it puts an empty block where a reader expects a ticker, which looks like a
@@ -134,7 +136,7 @@ export function TickerBadgeList({
134
136
  if (entry?.status === "missing" || listings?.[symbol] === null) {
135
137
  return (
136
138
  <Box key={symbol} paddingRight={1} flexShrink={0}>
137
- <Text fg={fallbackColor} attributes={TextAttributes.BOLD}>{symbol}</Text>
139
+ <Text fg={muted ? colors.textMuted : fallbackColor} attributes={muted ? TextAttributes.NONE : TextAttributes.BOLD}>{symbol}</Text>
138
140
  </Box>
139
141
  );
140
142
  }
@@ -15,6 +15,7 @@ import { headerCase } from "../header-case";
15
15
  import { tPlugin } from "../../../i18n";
16
16
  import { useTranslationRevision } from "../../../i18n/react";
17
17
  import { figureColumnCells } from "./render-cell";
18
+ import { mutedRowCells } from "./muted-row";
18
19
  import { useDataTableColumnOrder } from "./use-column-order";
19
20
  import { dataTableDisplayColumns } from "./display-columns";
20
21
  import { sameVisibleRange } from "./visible-range";
@@ -36,7 +37,10 @@ export function DataTable<T, C extends DataTableColumn = DataTableColumn>(
36
37
  ownProps: DataTableProps<T, C>,
37
38
  ) {
38
39
  // Every renderer, report and export reads the cells through this, so a column of figures lines up everywhere.
39
- const drawnCell = useMemo(() => figureColumnCells(ownProps.renderCell), [ownProps.renderCell]);
40
+ const drawnCell = useMemo(
41
+ () => mutedRowCells(figureColumnCells(ownProps.renderCell), ownProps.isRowMuted),
42
+ [ownProps.isRowMuted, ownProps.renderCell],
43
+ );
40
44
  // A row source's reports and exports read each row's current data; a row on screen is drawn from it already.
41
45
  const renderCell = useMemo((): DataTableProps<T, C>["renderCell"] => {
42
46
  const source = ownProps.rowSource;
@@ -56,6 +60,8 @@ export function DataTable<T, C extends DataTableColumn = DataTableColumn>(
56
60
  exportIdentity,
57
61
  // Exports and reports read the columns in the order the reader sees them.
58
62
  columns: order.columns,
63
+ // A pane's own export gets the same order to put on the columns it writes (`DataTableView` passes its own).
64
+ exportCsv: ownProps.exportCsv && (() => ownProps.exportCsv!(order.order)),
59
65
  onColumnMove: ownProps.onColumnMove ?? order.onColumnMove,
60
66
  anchoredColumns: ownProps.onColumnMove ? ownProps.anchoredColumns : order.anchoredColumns,
61
67
  };
@@ -0,0 +1,47 @@
1
+ import { createContext, useContext, type ReactNode } from "react";
2
+ import { TextAttributes } from "../../../ui";
3
+ import { colors } from "../../../theme/colors";
4
+ import type { DataTableCell, DataTableColumn, DataTableProps } from "./types";
5
+
6
+ const MutedRowContext = createContext(false);
7
+
8
+ /**
9
+ * Whether the drawn content around it is in a muted table row
10
+ * (`DataTableProps.isRowMuted`): a cell's own components (ticker badges) read
11
+ * it and draw muted and plain, as the row's text does.
12
+ */
13
+ export function useDataTableRowMuted(): boolean {
14
+ return useContext(MutedRowContext);
15
+ }
16
+
17
+ function MutedContent({ children }: { children: ReactNode }) {
18
+ return <MutedRowContext value>{children}</MutedRowContext>;
19
+ }
20
+
21
+ type RenderCell<T, C extends DataTableColumn> = DataTableProps<T, C>["renderCell"];
22
+
23
+ /**
24
+ * A table's cells with its muted rows (`isRowMuted`) drawn the one way: every
25
+ * cell in `textMuted` and plain weight, its value colours included, and the
26
+ * content a cell draws itself told to do the same. The selection still shows
27
+ * on a muted row, which stays selectable.
28
+ */
29
+ export function mutedRowCells<T, C extends DataTableColumn>(
30
+ renderCell: RenderCell<T, C>,
31
+ isRowMuted: DataTableProps<T, C>["isRowMuted"],
32
+ ): RenderCell<T, C> {
33
+ if (!isRowMuted) return renderCell;
34
+ return (item, column, index, rowState) => {
35
+ const cell = renderCell(item, column, index, rowState);
36
+ if (!isRowMuted(item, index)) return cell;
37
+ const muted: DataTableCell = {
38
+ ...cell,
39
+ // The selected row keeps the selection's text colour, so it reads on its fill.
40
+ color: rowState.selected ? undefined : colors.textMuted,
41
+ keepColorWhenSelected: false,
42
+ attributes: (cell.attributes ?? 0) & ~TextAttributes.BOLD,
43
+ };
44
+ if (cell.content !== undefined) muted.content = <MutedContent>{cell.content}</MutedContent>;
45
+ return muted;
46
+ };
47
+ }