gloomberb 0.19.3 → 0.19.4

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 (104) hide show
  1. package/package.json +2 -2
  2. package/src/api-client/errors.ts +8 -0
  3. package/src/api-client/index.ts +18 -0
  4. package/src/api-client/request.ts +295 -42
  5. package/src/api-client/socket.ts +95 -0
  6. package/src/app/keybindings/actions.ts +1 -1
  7. package/src/app/pane-runtime/index.tsx +1 -1
  8. package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
  9. package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
  10. package/src/app/pane-runtime/ticker-open-target.ts +12 -2
  11. package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
  12. package/src/cli/desktop-pane-shot.ts +2 -1
  13. package/src/components/command-bar/action-runtime.ts +2 -0
  14. package/src/components/command-bar/commands/direct/runtime.ts +3 -3
  15. package/src/components/command-bar/helpers.ts +2 -0
  16. package/src/components/command-bar/list/model.ts +9 -0
  17. package/src/components/command-bar/pane-actions.ts +46 -35
  18. package/src/components/command-bar/pane-templates/workflow.ts +6 -0
  19. package/src/components/command-bar/panel/index.tsx +30 -3
  20. package/src/components/command-bar/panel/types.ts +7 -0
  21. package/src/components/command-bar/routes/root/results.ts +4 -4
  22. package/src/components/command-bar/routes/root/selection.ts +3 -2
  23. package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
  24. package/src/components/command-bar/routing/launch-request.ts +3 -2
  25. package/src/components/command-bar/routing/list-state.ts +4 -1
  26. package/src/components/command-bar/surface/index.tsx +15 -1
  27. package/src/components/layout/floating-pane.tsx +10 -0
  28. package/src/components/layout/pane/frame.tsx +6 -0
  29. package/src/components/layout/pane/header.tsx +244 -42
  30. package/src/components/layout/pane/index.tsx +20 -2
  31. package/src/components/layout/shell/active-drag.ts +128 -27
  32. package/src/components/layout/shell/drag/index.ts +99 -96
  33. package/src/components/layout/shell/drag/live.ts +3 -17
  34. package/src/components/layout/shell/drag/magnets.ts +198 -0
  35. package/src/components/layout/shell/drag/overlays.tsx +77 -75
  36. package/src/components/layout/shell/drag/runtime.ts +12 -7
  37. package/src/components/layout/shell/index.tsx +66 -32
  38. package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
  39. package/src/components/layout/shell/native/surfaces.ts +1 -9
  40. package/src/components/layout/shell/native/window-state.ts +21 -25
  41. package/src/components/layout/shell/pane/layers.tsx +153 -24
  42. package/src/components/layout/shell/shortcuts.ts +4 -1
  43. package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
  44. package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
  45. package/src/components/layout/status-bar.tsx +75 -6
  46. package/src/core/app-runtime.ts +4 -1
  47. package/src/core/connection-health.ts +76 -1
  48. package/src/core/state/app/command-bar-launch.ts +12 -0
  49. package/src/core/state/app/layout.ts +4 -3
  50. package/src/core/state/app/types.ts +4 -1
  51. package/src/data/config/layout.ts +2 -2
  52. package/src/data/config/store/fold-panes.ts +6 -1
  53. package/src/i18n/es.ts +8 -1
  54. package/src/i18n/ja.ts +8 -1
  55. package/src/i18n/ko.ts +8 -1
  56. package/src/i18n/zh-cn.ts +8 -1
  57. package/src/i18n/zh-tw.ts +8 -1
  58. package/src/layout/pane-follow.ts +3 -2
  59. package/src/layout/pane-layout-move.ts +2 -1
  60. package/src/layout/pane-manager/dock-stack.ts +38 -0
  61. package/src/layout/pane-manager/dock-tree.ts +76 -15
  62. package/src/layout/pane-manager/docking.ts +48 -6
  63. package/src/layout/pane-manager/floating-actions.ts +12 -3
  64. package/src/layout/pane-manager/floating-placement.ts +189 -0
  65. package/src/layout/pane-manager/floating.ts +23 -4
  66. package/src/layout/pane-manager/gridlock.ts +16 -4
  67. package/src/layout/pane-manager/hidden-panes.ts +30 -1
  68. package/src/layout/pane-manager/index.ts +2 -0
  69. package/src/layout/pane-manager/layout-state.ts +17 -0
  70. package/src/layout/pane-manager/types.ts +4 -1
  71. package/src/layout/ticker-retarget.ts +88 -0
  72. package/src/layout-marketplace/cloud.ts +9 -1
  73. package/src/market-data/connection-follow.ts +68 -0
  74. package/src/market-data/coordinator/entries.ts +15 -3
  75. package/src/market-data/coordinator/financials.ts +20 -7
  76. package/src/market-data/coordinator/index.ts +217 -4
  77. package/src/market-data/coordinator/quotes.ts +10 -0
  78. package/src/market-data/hooks.tsx +31 -0
  79. package/src/news/aggregator.ts +12 -1
  80. package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
  81. package/src/plugins/builtin/buildout/model/index.ts +6 -0
  82. package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
  83. package/src/plugins/builtin/chart-composer/index.tsx +13 -0
  84. package/src/plugins/builtin/chat/controller/index.ts +10 -3
  85. package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
  86. package/src/plugins/builtin/chat/status-widget.tsx +3 -1
  87. package/src/plugins/builtin/help/index.tsx +1 -1
  88. package/src/plugins/builtin/sectors/client.ts +18 -8
  89. package/src/plugins/builtin/sectors/index.tsx +19 -5
  90. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
  91. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
  92. package/src/react/async-resource.ts +12 -0
  93. package/src/remote/controller.ts +3 -1
  94. package/src/renderers/browser/app-services.ts +8 -1
  95. package/src/renderers/browser/cloud-transport.ts +6 -1
  96. package/src/renderers/cloudflare/worker.ts +24 -2
  97. package/src/renderers/dom/styles.css +32 -0
  98. package/src/shares/portable-layout.ts +99 -2
  99. package/src/sources/provider-router/index.ts +2 -2
  100. package/src/sources/provider-router/sources.ts +26 -1
  101. package/src/sync/core-contributors.ts +18 -4
  102. package/src/time-series/resolve.ts +12 -0
  103. package/src/types/config.ts +17 -1
  104. package/src/types/plugin.ts +6 -0
@@ -16,7 +16,7 @@ import {
16
16
  type TickerSearchCandidate,
17
17
  type TickerSearchInstrumentClass,
18
18
  } from "../../../../tickers/search";
19
- import type { ResultItem } from "../../list/model";
19
+ import type { ResultItem, TickerPick } from "../../list/model";
20
20
  import { delistingLabel, parseListingDelisting } from "../../../../market-data/quotes/delisting";
21
21
  import {
22
22
  buildTickerSearchCacheKey,
@@ -25,6 +25,8 @@ import {
25
25
  } from "./results";
26
26
 
27
27
  interface UseCommandBarTickerSearchActionsOptions {
28
+ /** Ticker search's Enter: the focused pane, or its linked group, takes the ticker. */
29
+ changePaneTicker?: (symbol: string, options?: PinTickerOptions) => void;
28
30
  closeAll: (options?: { revertThemePreview?: boolean }) => void;
29
31
  dispatch: (action: any) => void;
30
32
  focusTicker: (symbol: string, options?: PinTickerOptions) => void;
@@ -34,6 +36,7 @@ interface UseCommandBarTickerSearchActionsOptions {
34
36
  }
35
37
 
36
38
  export function useCommandBarTickerSearchActions({
39
+ changePaneTicker,
37
40
  closeAll,
38
41
  dispatch,
39
42
  focusTicker,
@@ -55,13 +58,18 @@ export function useCommandBarTickerSearchActions({
55
58
  return ticker;
56
59
  }, [dispatch, pluginRegistry.events, tickerRepository]);
57
60
 
58
- const openTickerResearch = useCallback((result: InstrumentSearchResult, options?: { forceNewPane?: boolean }) => {
61
+ const pickTicker = useCallback((symbol: string, selection: PinTickerOptions, how: TickerPick) => {
62
+ if (how === "pane" && changePaneTicker) changePaneTicker(symbol, selection);
63
+ else focusTicker(symbol, how === "new" ? { forceNewPane: true, ...selection } : selection);
64
+ closeAll({ revertThemePreview: false });
65
+ }, [changePaneTicker, closeAll, focusTicker]);
66
+
67
+ const openTickerResearch = useCallback((result: InstrumentSearchResult, how: TickerPick) => {
59
68
  (async () => {
60
69
  const ticker = await resolveSearchTicker(result);
61
- focusTicker(ticker.metadata.ticker, { ...options, ...tickerSelectionFromSearchResult(result) });
62
- closeAll({ revertThemePreview: false });
70
+ pickTicker(ticker.metadata.ticker, tickerSelectionFromSearchResult(result), how);
63
71
  })();
64
- }, [closeAll, focusTicker, resolveSearchTicker]);
72
+ }, [pickTicker, resolveSearchTicker]);
65
73
 
66
74
  const mapTickerSearchCandidateToResultItem = useCallback((candidate: TickerSearchCandidate): ResultItem => {
67
75
  const detail = formatTickerSearchDetail(candidate);
@@ -80,6 +88,7 @@ export function useCommandBarTickerSearchActions({
80
88
  const lines = delisting ? [{ segments: [{ text: delistingLabel(delisting), emphasis: "muted" as const }] }] : undefined;
81
89
 
82
90
  if (candidate.kind === "ticker" && candidate.ticker) {
91
+ const pick = (how: TickerPick) => pickTicker(candidate.ticker!.metadata.ticker, tickerSelectionFromSearchResult(candidate.result), how);
83
92
  return {
84
93
  id: candidate.id,
85
94
  contractKey: candidate.contractKey,
@@ -95,14 +104,9 @@ export function useCommandBarTickerSearchActions({
95
104
  kind: "ticker",
96
105
  resolveTicker: async () => candidate.ticker!,
97
106
  prefetchInstrument: rowPrefetchInstrument(candidate, tickersRef.current),
98
- secondaryAction: () => {
99
- focusTicker(candidate.ticker!.metadata.ticker, { forceNewPane: true, ...tickerSelectionFromSearchResult(candidate.result) });
100
- closeAll({ revertThemePreview: false });
101
- },
102
- action: () => {
103
- focusTicker(candidate.ticker!.metadata.ticker, { ...tickerSelectionFromSearchResult(candidate.result) });
104
- closeAll({ revertThemePreview: false });
105
- },
107
+ pickTicker: pick,
108
+ secondaryAction: () => pick("new"),
109
+ action: () => pick("des"),
106
110
  };
107
111
  }
108
112
 
@@ -126,10 +130,11 @@ export function useCommandBarTickerSearchActions({
126
130
  : candidate.result!.exchange || candidate.result!.primaryExchange,
127
131
  )),
128
132
  prefetchInstrument: rowPrefetchInstrument(candidate, tickersRef.current),
129
- secondaryAction: () => openTickerResearch(candidate.result!, { forceNewPane: true }),
130
- action: () => openTickerResearch(candidate.result!),
133
+ pickTicker: (how) => openTickerResearch(candidate.result!, how),
134
+ secondaryAction: () => openTickerResearch(candidate.result!, "new"),
135
+ action: () => openTickerResearch(candidate.result!, "des"),
131
136
  };
132
- }, [closeAll, focusTicker, openTickerResearch, resolveSearchTicker]);
137
+ }, [openTickerResearch, pickTicker, resolveSearchTicker]);
133
138
 
134
139
  const buildTickerSearchResultItems = useCallback((candidates: TickerSearchCandidate[], query: string): ResultItem[] => (
135
140
  candidates.length > 0
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import type { AppState } from "../../../state/app/context";
3
+ import type { TickerSearchPayload } from "../../../core/state/app/command-bar-launch";
3
4
 
4
5
  interface UseCommandBarLaunchRequestOptions {
5
6
  commandBarLaunchRequest: AppState["commandBarLaunchRequest"];
@@ -7,7 +8,7 @@ interface UseCommandBarLaunchRequestOptions {
7
8
  openModeRoute: (
8
9
  screen: "ticker-search" | "layout",
9
10
  initialQuery?: string,
10
- payload?: Record<string, unknown>,
11
+ payload?: TickerSearchPayload,
11
12
  ) => void;
12
13
  }
13
14
 
@@ -29,7 +30,7 @@ export function useCommandBarLaunchRequest({
29
30
  processedLaunchSequenceRef.current = launch.sequence;
30
31
 
31
32
  if (launch.kind === "ticker-search") {
32
- openModeRoute("ticker-search", launch.query ?? "");
33
+ openModeRoute("ticker-search", launch.query ?? "", launch.payload);
33
34
  }
34
35
  // Submitting text needs the selection runtime, which the surface wires up
35
36
  // after this hook; it watches for run-query itself.
@@ -107,7 +107,10 @@ function buildRouteListState(options: BuildRouteListStateOptions): ListScreenSta
107
107
  return {
108
108
  kind: "mode",
109
109
  title: "Security Description",
110
- subtitle: "Resolve a ticker, then open its Ticker Research pane.",
110
+ // DES opens a research pane; the backtick's search changes the focused pane's ticker.
111
+ subtitle: currentRoute.payload?.action
112
+ ? "Resolve a ticker, then open its Ticker Research pane."
113
+ : "Resolve a ticker for the focused pane, or open it in a new pane.",
111
114
  query: currentRoute.query,
112
115
  selectedIdx: currentRoute.selectedIdx,
113
116
  hoveredIdx: currentRoute.hoveredIdx,
@@ -36,6 +36,9 @@ import { useCommandBarRouteEffects } from "../routing/effects";
36
36
  import { useCommandBarEnvironment } from "./environment";
37
37
  import { useCommandBarActionRuntime } from "../action-runtime";
38
38
  import { requestKeybindingCapture } from "../../../app/keybindings";
39
+ import { resolveTickerRetargetPane } from "../../../layout/ticker-retarget";
40
+ import { findPaneInstance } from "../../../types/config";
41
+ import { getBasePaneDisplayTitle } from "../../layout/pane/title";
39
42
  import { isDialogOpen } from "../../../ui/dialog-stack";
40
43
 
41
44
  interface CommandBarProps {
@@ -635,7 +638,18 @@ export function CommandBar({
635
638
  visibleListStateRef,
636
639
  });
637
640
 
641
+ // Plain ticker search changes the focused pane's ticker when it shows one; DES's own search opens DES.
642
+ const tickerSearchTarget = useMemo(() => {
643
+ if (currentRoute?.kind !== "mode" || currentRoute.screen !== "ticker-search" || currentRoute.payload?.action) return null;
644
+ const layout = state.config.layout;
645
+ if (!resolveTickerRetargetPane(layout, state.focusedPaneId, pluginRegistry.panes)) return null;
646
+ const focused = findPaneInstance(layout, state.focusedPaneId!);
647
+ const paneDef = focused ? pluginRegistry.panes.get(focused.paneId) : undefined;
648
+ return focused && paneDef ? getBasePaneDisplayTitle(state, focused, paneDef, pluginRegistry.panes) : null;
649
+ }, [currentRoute, pluginRegistry.panes, state]);
650
+ const runSecondary = useCallback(() => activateListSelection({ secondary: true }), [activateListSelection]);
651
+
638
652
  return (
639
- <CommandBarPanel {...panelProps} />
653
+ <CommandBarPanel {...panelProps} tickerSearchTarget={tickerSearchTarget} onRunSecondary={runSecondary} />
640
654
  );
641
655
  }
@@ -11,6 +11,12 @@ import { resolvePaneBodyFrame, shouldReservePaneFooter } from "./pane/sizing";
11
11
  interface FloatingPaneWrapperProps {
12
12
  paneId?: string;
13
13
  title: string;
14
+ /**
15
+ * Desktop and web: the ticker the title shows, drawn as a control that opens ticker search for
16
+ * the pane (`onTitleTickerPress`).
17
+ */
18
+ titleTicker?: string | null;
19
+ onTitleTickerPress?: () => void;
14
20
  x: number;
15
21
  y: number;
16
22
  width: number;
@@ -68,6 +74,8 @@ function TerminalFloatingPaneBorder({ width, height }: { width: number; height:
68
74
  export function FloatingPaneWrapper({
69
75
  paneId,
70
76
  title,
77
+ titleTicker = null,
78
+ onTitleTickerPress,
71
79
  x,
72
80
  y,
73
81
  width,
@@ -135,6 +143,8 @@ export function FloatingPaneWrapper({
135
143
  >
136
144
  <PaneHeader
137
145
  title={title}
146
+ titleTicker={titleTicker}
147
+ onTitleTickerPress={onTitleTickerPress}
138
148
  width={width}
139
149
  focused={focused}
140
150
  windowModeSelected={windowModeSelected}
@@ -3,6 +3,8 @@ import { Box } from "../../../ui";
3
3
  import { colors } from "../../../theme/colors";
4
4
  import { PaneSurfaceContext } from "./surface";
5
5
 
6
+ export type DockEdge = "left" | "right" | "top" | "bottom";
7
+
6
8
  export function getPaneWindowAttributes({
7
9
  enabled = true,
8
10
  role,
@@ -11,6 +13,7 @@ export function getPaneWindowAttributes({
11
13
  focused,
12
14
  windowModeSelected,
13
15
  showBorderColor = false,
16
+ dockEdges,
14
17
  }: {
15
18
  enabled?: boolean;
16
19
  role: string;
@@ -19,6 +22,8 @@ export function getPaneWindowAttributes({
19
22
  focused: boolean;
20
23
  windowModeSelected?: boolean;
21
24
  showBorderColor?: boolean;
25
+ /** A docked pane's sides that face another pane across the gap between them, which it rules. */
26
+ dockEdges?: readonly DockEdge[];
22
27
  }): Record<string, unknown> {
23
28
  const attributes: Record<string, unknown> = {
24
29
  "data-gloom-role": role,
@@ -31,6 +36,7 @@ export function getPaneWindowAttributes({
31
36
  if (windowModeSelected != null) {
32
37
  attributes["data-window-mode-selected"] = windowModeSelected ? "true" : "false";
33
38
  }
39
+ if (dockEdges && dockEdges.length > 0) attributes["data-dock-edges"] = dockEdges.join(" ");
34
40
  if (showBorderColor) {
35
41
  attributes.style = {
36
42
  "--pane-border-color": focused || windowModeSelected ? colors.borderFocused : colors.border,
@@ -1,11 +1,14 @@
1
1
  import { Box, Text, useActionShortcut, useNativeRenderer, useRendererHost, useUiCapabilities } from "../../../ui";
2
- import { useCallback, useRef, type ReactNode } from "react";
2
+ import { useCallback, useMemo, useRef, type ReactNode } from "react";
3
3
  import { colors, floatingPaneTitleBg, paneTitleBg, paneTitleText } from "../../../theme/colors";
4
4
  import { WEB_CELL_WIDTH } from "../../../theme/font-scale";
5
5
  import { displayWidth, truncateToDisplayWidth } from "../../../utils/format";
6
6
  import { capturePointerDrag } from "../../../ui/pointer-drag";
7
7
  import { Tabs } from "../../ui/tabs";
8
+ import { Divider } from "../../ui/display";
8
9
  import { ICON_GLYPHS, Icon, IconButton } from "../../ui/icon";
10
+ import { Button } from "../../ui/button";
11
+ import { t } from "../../../i18n";
9
12
  import type { PaneHeaderTabsRegistration } from "./header-tabs";
10
13
  import { nativePaneHeaderRows } from "./sizing";
11
14
 
@@ -25,9 +28,80 @@ export const PANE_HEADER_ASK_MIN_WIDTH = 32;
25
28
  export const PANE_HEADER_RESTORE = " - ";
26
29
  const PANE_HEADER_LOCK = " 🔒 ";
27
30
  const HIDDEN_HEADER_BUTTON = { visibility: "hidden" } as const;
31
+ /** Terminal: between two tabs of a stack, and the most of a title one tab shows. */
32
+ const STACK_TAB_SEPARATOR = " │ ";
33
+ const STACK_TAB_MAX_WIDTH = 16;
34
+
35
+ /**
36
+ * Panes stacked in one spot of the dock: the header names each as a tab in
37
+ * place of the title, the one shown first among equals.
38
+ */
39
+ export interface PaneHeaderStack {
40
+ /** In tab order. */
41
+ tabs: ReadonlyArray<{ id: string; title: string }>;
42
+ /** The pane shown. */
43
+ active: string;
44
+ /** A click on a tab: show that pane. */
45
+ onSelect: (id: string) => void;
46
+ /** A press on a tab, in place of the header's: a drag moves that pane out of the stack. */
47
+ onTabMouseDown?: (id: string, event: any) => void;
48
+ }
49
+
50
+ /**
51
+ * Terminal: each tab of a stack in its header, as text and where it starts,
52
+ * in cells from where the title starts (after the grip). The pointer runtime
53
+ * finds the tab under a press with it.
54
+ */
55
+ export function stackTabSpans(titles: readonly string[]): Array<{ start: number; text: string }> {
56
+ let start = 0;
57
+ return titles.map((title) => {
58
+ const text = truncateToDisplayWidth(title, STACK_TAB_MAX_WIDTH);
59
+ const span = { start, text };
60
+ start += displayWidth(text) + STACK_TAB_SEPARATOR.length;
61
+ return span;
62
+ });
63
+ }
64
+
65
+ /** Terminal: the cells before a header's title: the grip, after the corner a focused or floating pane draws. */
66
+ export function paneHeaderTitleStart(framed: boolean): number {
67
+ return (framed ? 2 : 0) + PANE_HEADER_GRIP.length;
68
+ }
69
+
70
+ /** Terminal: how wide a stack's tabs are, all of them. */
71
+ function stackTabsWidth(stack: PaneHeaderStack): number {
72
+ const last = stackTabSpans(stack.tabs.map((tab) => tab.title)).at(-1);
73
+ return last ? last.start + displayWidth(last.text) : 0;
74
+ }
75
+
76
+ /** Terminal: a stack's tabs in at most `width` cells (all of them with `pad`), the shown one in `activeFg`, the rest dim. */
77
+ function TerminalStackTabs({ stack, width, activeFg, pad }: { stack: PaneHeaderStack; width: number; activeFg: string; pad: boolean }) {
78
+ const spans = stackTabSpans(stack.tabs.map((tab) => tab.title));
79
+ const parts: Array<{ key: string; text: string; fg: string }> = [];
80
+ stack.tabs.forEach((tab, index) => {
81
+ if (index > 0) parts.push({ key: `sep:${tab.id}`, text: STACK_TAB_SEPARATOR, fg: colors.border });
82
+ parts.push({ key: tab.id, text: spans[index]!.text, fg: tab.id === stack.active ? activeFg : colors.textDim });
83
+ });
84
+ let left = width;
85
+ return (
86
+ <>
87
+ {parts.map((part) => {
88
+ const text = truncateToDisplayWidth(part.text, Math.max(0, left));
89
+ left -= displayWidth(text);
90
+ return text ? <Text key={part.key} fg={part.fg} selectable={false}>{text}</Text> : null;
91
+ })}
92
+ {pad && left > 0 && <Text fg={activeFg} selectable={false}>{" ".repeat(left)}</Text>}
93
+ </>
94
+ );
95
+ }
28
96
 
29
97
  interface PaneHeaderProps {
30
98
  title: string;
99
+ /**
100
+ * Desktop and web: the ticker of a single-ticker pane, drawn where its title names it as a
101
+ * control that opens ticker search for the pane (`onTitleTickerPress`).
102
+ */
103
+ titleTicker?: string | null;
104
+ onTitleTickerPress?: () => void;
31
105
  width: number;
32
106
  focused: boolean;
33
107
  windowModeSelected?: boolean;
@@ -37,6 +111,8 @@ interface PaneHeaderProps {
37
111
  quickSettings?: PaneHeaderQuickSetting[];
38
112
  /** Desktop only: the pane's primary tab strip, drawn as title-bar tabs. */
39
113
  tabs?: PaneHeaderTabsRegistration | null;
114
+ /** Panes stacked in this spot: their tabs replace the title. */
115
+ stack?: PaneHeaderStack | null;
40
116
  /** The body colour the active title-bar tab opens into. */
41
117
  bodyBackground?: string;
42
118
  /**
@@ -122,8 +198,61 @@ function TerminalPaneButton({
122
198
  );
123
199
  }
124
200
 
201
+ /**
202
+ * Where `symbol` stands in a pane's title as a word of its own ("OMON SPY", "Chart: NVDA \u29c9
203
+ * Linked to DES"), so the header can draw it as a control. Null when the title does not name it.
204
+ */
205
+ export function findTitleTicker(title: string, symbol: string): { start: number; end: number } | null {
206
+ if (!symbol) return null;
207
+ for (let start = title.indexOf(symbol); start >= 0; start = title.indexOf(symbol, start + 1)) {
208
+ const end = start + symbol.length;
209
+ if ((start === 0 || /\s/.test(title[start - 1]!)) && (end === title.length || /[\s,]/.test(title[end]!))) {
210
+ return { start, end };
211
+ }
212
+ }
213
+ return null;
214
+ }
215
+
216
+ /**
217
+ * The ticker in a single-ticker pane's title: a ghost button in the title's own type, marked
218
+ * with the chevron a query bar's choices carry, that opens ticker search for the pane. It sits
219
+ * where the title's text put the ticker, so only the chevron and the hover fill tell it apart.
220
+ */
221
+ function PaneTitleTicker({ symbol, color, onPress }: {
222
+ symbol: string;
223
+ color: string;
224
+ onPress: () => void;
225
+ }) {
226
+ const searchShortcut = useActionShortcut("ticker-search");
227
+ const label = "Change ticker";
228
+ // A span in the title's line, so the title still ends in one ellipsis. The button's inset goes
229
+ // into the space before it, so the ticker's letters stay where the title's text put them.
230
+ return (
231
+ <Text
232
+ data-gloom-role="pane-title-ticker"
233
+ style={{ display: "inline-flex", verticalAlign: "top", marginLeft: "calc(-1 * var(--gloom-space-xs))" }}
234
+ >
235
+ <Button
236
+ label={label}
237
+ title={searchShortcut ? `${t(label)} (${searchShortcut})` : t(label)}
238
+ variant="plain"
239
+ compact
240
+ stopPropagation
241
+ onPress={onPress}
242
+ >
243
+ <Text fg={color} selectable={false} style={{ fontWeight: "var(--gloom-weight-bold)" }}>{symbol}</Text>
244
+ <Text style={{ display: "inline-flex", marginLeft: "var(--gloom-space-xs)" }}>
245
+ <Icon name="chevron-down" size={9} color={colors.textMuted} />
246
+ </Text>
247
+ </Button>
248
+ </Text>
249
+ );
250
+ }
251
+
125
252
  export function PaneHeader({
126
253
  title,
254
+ titleTicker = null,
255
+ onTitleTickerPress,
127
256
  width,
128
257
  focused,
129
258
  windowModeSelected = false,
@@ -132,6 +261,7 @@ export function PaneHeader({
132
261
  showActions = false,
133
262
  quickSettings = [],
134
263
  tabs = null,
264
+ stack = null,
135
265
  bodyBackground,
136
266
  topRule = false,
137
267
  titleBar = null,
@@ -165,6 +295,7 @@ export function PaneHeader({
165
295
  const terminalQuickSettingsWidth = quickSettings.reduce((total, setting) => total + displayWidth(quickSettingText(setting)), 0)
166
296
  + displayWidth(lockText) + helpText.length;
167
297
  const textColor = paneTitleText(visuallyFocused, floating);
298
+ const tickerAt = titleTicker ? findTitleTicker(title, titleTicker) : null;
168
299
  const topInset = topRule ? 1 : 0;
169
300
  const handleTerminalHeaderMouseDown = useCallback((event: any) => {
170
301
  capturePointerDrag(nativeRenderer, terminalHeaderRef.current);
@@ -174,10 +305,20 @@ export function PaneHeader({
174
305
  // padding. Tabs and buttons stop the press before it gets here. A fullscreen
175
306
  // pane cannot move, so there the bar moves the desktop window instead.
176
307
  const windowDrag = Boolean(titleBar) || (fullscreen && titleBarOverlay === true && nativeWindowChrome === true);
177
- const beginPaneDrag = (event: { stopPropagation?: () => void }) => {
308
+ const beginPaneDrag = (event: { stopPropagation?: () => void; target?: unknown }) => {
178
309
  event.stopPropagation?.();
310
+ // A press on one of a stack's tabs moves that pane, not the one shown.
311
+ const tabId = stack?.onTabMouseDown ? stackTabOfTarget(event.target) : null;
312
+ if (tabId && stack?.onTabMouseDown) {
313
+ stack.onTabMouseDown(tabId, event);
314
+ return;
315
+ }
179
316
  onHeaderMouseDown?.(event);
180
317
  };
318
+ const stackTabItems = useMemo(
319
+ () => stack?.tabs.map((tab) => ({ label: tab.title, value: tab.id })) ?? null,
320
+ [stack?.tabs],
321
+ );
181
322
  const beginWindowDrag = (event?: { stopPropagation?: () => void; detail?: number }) => {
182
323
  event?.stopPropagation?.();
183
324
  if (titleBar) {
@@ -193,6 +334,24 @@ export function PaneHeader({
193
334
  if (nativePaneChrome) {
194
335
  // Focused, the rule is the accent; otherwise the one hairline.
195
336
  const ruleColor = visuallyFocused ? colors.borderFocused : "var(--gloom-hairline)";
337
+ // Title-bar tabs, the pane's own and a stack's alike: the strip hangs over
338
+ // the header's rules so the active tab's box opens into the pane.
339
+ const headerTabStripStyle = {
340
+ alignSelf: "stretch",
341
+ marginTop: -topInset,
342
+ marginBottom: -1,
343
+ // Undoes the negative top margin for what is centred in the strip:
344
+ // the overflow chevron, and the tab labels (styles.css).
345
+ "--pane-tab-top-inset": `${topInset}px`,
346
+ // The active tab's box opens into the pane over the bottom rule
347
+ // (styles.css), drawn in the rule's colour so the two are one line.
348
+ "--pane-tab-border": ruleColor,
349
+ // Until the strip has measured the surface under the tab (top-surface.ts).
350
+ "--pane-tab-active-bg": bodyBackground ?? colors.bg,
351
+ // The active tab reads as active whenever the pane is focused, even
352
+ // while a detail or field inside the pane owns the keyboard.
353
+ "--pane-tab-active-fg": visuallyFocused ? colors.textBright : colors.text,
354
+ } as const;
196
355
  // No width of its own: it stretches across its pane, so it follows a
197
356
  // frame a resize sizes outside React.
198
357
  return (
@@ -231,25 +390,64 @@ export function PaneHeader({
231
390
  <Icon name="grip" size={12} color={visuallyFocused ? colors.borderFocused : colors.textMuted} />
232
391
  </Box>
233
392
  )}
234
- {/* Full header height, so trimming the title to its capitals never lets
235
- this clip cut descenders. */}
236
- <Box data-gloom-role="pane-header-chrome" minWidth={0} flexShrink={tabs ? 0 : 1} overflow="hidden" flexDirection="row" alignItems="center" style={{ alignSelf: "stretch", ...(tabs ? { maxWidth: "40%" } : {}) }}>
237
- <Text
238
- fg={textColor}
239
- selectable={false}
240
- data-gloom-role="pane-title"
241
- style={{
242
- // Focus changes the colour, never the weight: a bold title would
243
- // change width as the pane takes and loses focus.
244
- fontWeight: 700,
245
- whiteSpace: "nowrap",
246
- overflow: "hidden",
247
- textOverflow: "ellipsis",
248
- }}
393
+ {stack && stackTabItems ? (
394
+ // The panes stacked here, in place of the title: the same title-bar
395
+ // tabs as a pane's own strip. A press on one moves that pane
396
+ // (beginPaneDrag), so the strip lets it through to the header.
397
+ <Box
398
+ data-gloom-role="pane-stack-tabs"
399
+ flexShrink={1}
400
+ minWidth={0}
401
+ style={{ ...headerTabStripStyle, ...(tabs ? { maxWidth: "40%" } : {}) }}
249
402
  >
250
- {title}
251
- </Text>
252
- </Box>
403
+ <Tabs
404
+ tabs={stackTabItems}
405
+ activeValue={stack.active}
406
+ onSelect={stack.onSelect}
407
+ variant="header"
408
+ focused={visuallyFocused}
409
+ keyboardNavigation={false}
410
+ paneMenu={false}
411
+ />
412
+ </Box>
413
+ ) : (
414
+ /* Full header height, so trimming the title to its capitals never lets
415
+ this clip cut descenders. */
416
+ <Box data-gloom-role="pane-header-chrome" minWidth={0} flexShrink={tabs ? 0 : 1} overflow="hidden" flexDirection="row" alignItems="center" style={{ alignSelf: "stretch", ...(tabs ? { maxWidth: "40%" } : {}) }}>
417
+ <Text
418
+ fg={textColor}
419
+ selectable={false}
420
+ data-gloom-role="pane-title"
421
+ style={{
422
+ // Focus changes the colour, never the weight: a bold title would
423
+ // change width as the pane takes and loses focus.
424
+ fontWeight: 700,
425
+ whiteSpace: "nowrap",
426
+ overflow: "hidden",
427
+ textOverflow: "ellipsis",
428
+ }}
429
+ >
430
+ {tickerAt && onTitleTickerPress ? (
431
+ <>
432
+ {title.slice(0, tickerAt.start)}
433
+ <PaneTitleTicker
434
+ symbol={title.slice(tickerAt.start, tickerAt.end)}
435
+ color={textColor}
436
+ onPress={onTitleTickerPress}
437
+ />
438
+ {title.slice(tickerAt.end)}
439
+ </>
440
+ ) : title}
441
+ </Text>
442
+ </Box>
443
+ )}
444
+ {stack && tabs && (
445
+ // Two strips, two roles: the panes stacked here, then the views of
446
+ // the one shown. The rule keeps them from reading as one strip.
447
+ <Box flexDirection="row" flexShrink={0} style={{ alignSelf: "stretch", marginLeft: "var(--gloom-space-sm)", paddingBlock: "var(--gloom-space-xs)" }}>
448
+ <Divider orientation="vertical" />
449
+ </Box>
450
+ )}
253
451
  {tabs && (
254
452
  <Box
255
453
  data-gloom-role="pane-header-tabs"
@@ -259,23 +457,7 @@ export function PaneHeader({
259
457
  // Tabs select on click; the header must not start a pane drag.
260
458
  event.stopPropagation?.();
261
459
  }}
262
- style={{
263
- alignSelf: "stretch",
264
- marginTop: -topInset,
265
- marginBottom: -1,
266
- marginLeft: "var(--gloom-space-sm)",
267
- // Undoes the negative top margin for what is centred in the strip:
268
- // the overflow chevron, and the tab labels (styles.css).
269
- "--pane-tab-top-inset": `${topInset}px`,
270
- // The active tab's box opens into the pane over the bottom rule
271
- // (styles.css), drawn in the rule's colour so the two are one line.
272
- "--pane-tab-border": ruleColor,
273
- // Until the strip has measured the surface under the tab (top-surface.ts).
274
- "--pane-tab-active-bg": bodyBackground ?? colors.bg,
275
- // The active tab reads as active whenever the pane is focused, even
276
- // while a detail or field inside the pane owns the keyboard.
277
- "--pane-tab-active-fg": visuallyFocused ? colors.textBright : colors.text,
278
- }}
460
+ style={{ ...headerTabStripStyle, marginLeft: "var(--gloom-space-sm)" }}
279
461
  >
280
462
  <Tabs
281
463
  tabs={tabs.tabs}
@@ -366,7 +548,7 @@ export function PaneHeader({
366
548
  const contentWidth = PANE_HEADER_GRIP.length + terminalQuickSettingsWidth + closeText.length + actionText.length;
367
549
  const titleWidth = Math.max(0, innerWidth - contentWidth);
368
550
  const clippedTitle = truncateToDisplayWidth(title, titleWidth);
369
- const fillLen = Math.max(0, innerWidth - PANE_HEADER_GRIP.length - displayWidth(clippedTitle) - terminalQuickSettingsWidth - actionText.length - closeText.length);
551
+ const fillLen = Math.max(0, innerWidth - PANE_HEADER_GRIP.length - (stack ? Math.min(titleWidth, stackTabsWidth(stack)) : displayWidth(clippedTitle)) - terminalQuickSettingsWidth - actionText.length - closeText.length);
370
552
  const fill = "─".repeat(fillLen);
371
553
 
372
554
  return (
@@ -382,7 +564,14 @@ export function PaneHeader({
382
564
  onMouseDragEnd={onHeaderMouseDragEnd}
383
565
  >
384
566
  <Text fg={borderColor} selectable={false}>{"┌─"}</Text>
385
- <Text fg={textColor} selectable={false}>{`${PANE_HEADER_GRIP}${clippedTitle}`}</Text>
567
+ {stack ? (
568
+ <>
569
+ <Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
570
+ <TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad={false} />
571
+ </>
572
+ ) : (
573
+ <Text fg={textColor} selectable={false}>{`${PANE_HEADER_GRIP}${clippedTitle}`}</Text>
574
+ )}
386
575
  {quickSettings.map((setting) => (
387
576
  <TerminalPaneButton
388
577
  key={setting.key}
@@ -434,9 +623,16 @@ export function PaneHeader({
434
623
  onMouseDrag={onHeaderMouseDrag}
435
624
  onMouseDragEnd={onHeaderMouseDragEnd}
436
625
  >
437
- <Text fg={textColor} selectable={false}>
438
- {`${PANE_HEADER_GRIP}${clippedTitle}${padding}`}
439
- </Text>
626
+ {stack ? (
627
+ <>
628
+ <Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
629
+ <TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad />
630
+ </>
631
+ ) : (
632
+ <Text fg={textColor} selectable={false}>
633
+ {`${PANE_HEADER_GRIP}${clippedTitle}${padding}`}
634
+ </Text>
635
+ )}
440
636
  {quickSettings.map((setting) => (
441
637
  <TerminalPaneButton
442
638
  key={setting.key}
@@ -469,3 +665,9 @@ export function PaneHeader({
469
665
  </Box>
470
666
  );
471
667
  }
668
+
669
+ /** Desktop: the stack tab a press landed on, by the tab button it hit. */
670
+ function stackTabOfTarget(target: unknown): string | null {
671
+ const element = target as { closest?: (selector: string) => { getAttribute(name: string): string | null } | null } | null;
672
+ return element?.closest?.('[data-gloom-role="pane-stack-tabs"] [data-tab-value]')?.getAttribute("data-tab-value") ?? null;
673
+ }