gloomberb 0.20.9 → 0.20.10

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 (128) hide show
  1. package/package.json +1 -1
  2. package/src/api-client/auth.ts +6 -0
  3. package/src/api-client/data.ts +1 -0
  4. package/src/api-client/earnings.ts +15 -0
  5. package/src/api-client/index.ts +14 -3
  6. package/src/api-client/types/account.ts +10 -0
  7. package/src/api-client/types/billing.ts +10 -0
  8. package/src/api-client/types/econ.ts +19 -7
  9. package/src/api-client/types/market.ts +7 -0
  10. package/src/api-client/types/screener.ts +2 -0
  11. package/src/cli/commands/market.ts +18 -8
  12. package/src/cli/commands/overview.ts +26 -7
  13. package/src/cli/commands/ticker.ts +40 -15
  14. package/src/cli/desktop-pane-shot.ts +39 -0
  15. package/src/cli/errors.ts +20 -3
  16. package/src/cli/fx-pair.ts +11 -2
  17. package/src/cli/history-rows.ts +34 -3
  18. package/src/cli/index.ts +1 -1
  19. package/src/cli/listing-arg.ts +51 -13
  20. package/src/cli/pane-functions/headless.ts +4 -2
  21. package/src/cli/pane-functions/index.ts +1 -0
  22. package/src/cli/pane-functions/resolver.ts +2 -1
  23. package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
  24. package/src/cli/pane-functions/screenshot-types.ts +4 -0
  25. package/src/components/chart/composite/chart-layout.ts +7 -4
  26. package/src/components/chart/composite/composite-chart.tsx +6 -16
  27. package/src/components/chart/composite/toolbar.tsx +258 -82
  28. package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
  29. package/src/components/command-bar/list/model.ts +13 -0
  30. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
  31. package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
  32. package/src/components/command-bar/surface/index.tsx +10 -5
  33. package/src/components/command-bar/workflow/alert.ts +21 -7
  34. package/src/components/data-table/table-pane.ts +3 -1
  35. package/src/components/layout/pane/footer/model.ts +26 -1
  36. package/src/components/metric-treemap/heat-surface.tsx +2 -1
  37. package/src/components/metric-treemap/index.tsx +3 -2
  38. package/src/components/ui/confirm-dialog.tsx +253 -7
  39. package/src/components/ui/data-table/index.tsx +1 -1
  40. package/src/components/ui/data-table/types.ts +7 -0
  41. package/src/components/ui/list-view.tsx +4 -3
  42. package/src/components/ui/status.tsx +9 -6
  43. package/src/docs/snapshot.json +36 -0
  44. package/src/i18n/es.ts +12 -0
  45. package/src/i18n/ja.ts +12 -0
  46. package/src/i18n/ko.ts +12 -0
  47. package/src/i18n/zh-cn.ts +12 -0
  48. package/src/i18n/zh-tw.ts +12 -0
  49. package/src/market-data/fx-closes.ts +14 -2
  50. package/src/market-data/market/change-basis.ts +35 -1
  51. package/src/market-data/market/status.ts +37 -0
  52. package/src/market-data/performance.ts +4 -1
  53. package/src/market-data/quotes/live-valuation.ts +25 -2
  54. package/src/market-data/realized-volatility.ts +3 -0
  55. package/src/market-data/us-bond-market.ts +115 -0
  56. package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
  57. package/src/plugins/builtin/account-management/keyboard.ts +3 -0
  58. package/src/plugins/builtin/account-management/model.ts +1 -0
  59. package/src/plugins/builtin/account-management/pane.tsx +51 -5
  60. package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
  61. package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
  62. package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
  63. package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
  64. package/src/plugins/builtin/correlation/compute.ts +4 -3
  65. package/src/plugins/builtin/earnings/board-model.ts +33 -0
  66. package/src/plugins/builtin/earnings/board-table.ts +50 -11
  67. package/src/plugins/builtin/earnings/board.tsx +29 -13
  68. package/src/plugins/builtin/earnings/calendar.tsx +15 -3
  69. package/src/plugins/builtin/earnings/client.ts +4 -1
  70. package/src/plugins/builtin/earnings/headless.ts +27 -14
  71. package/src/plugins/builtin/econ/calendar-source.ts +3 -0
  72. package/src/plugins/builtin/help/index.tsx +1 -1
  73. package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
  74. package/src/plugins/builtin/iv-history/headless.ts +12 -10
  75. package/src/plugins/builtin/macro-day/headless.ts +15 -5
  76. package/src/plugins/builtin/macro-day/model.ts +17 -4
  77. package/src/plugins/builtin/macro-day/releases.ts +36 -15
  78. package/src/plugins/builtin/market-halts/model.ts +3 -2
  79. package/src/plugins/builtin/market-movers/headless.ts +2 -1
  80. package/src/plugins/builtin/market-movers/index.tsx +3 -2
  81. package/src/plugins/builtin/market-movers/model.ts +75 -22
  82. package/src/plugins/builtin/market-movers/screener.ts +2 -1
  83. package/src/plugins/builtin/market-movers/table.ts +7 -5
  84. package/src/plugins/builtin/pe-band/model.ts +4 -0
  85. package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
  86. package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
  87. package/src/plugins/builtin/portfolio-list/pane/index.tsx +2 -1
  88. package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
  89. package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
  90. package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
  91. package/src/plugins/builtin/research/analyst-headless.ts +9 -1
  92. package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
  93. package/src/plugins/builtin/research/client.ts +25 -1
  94. package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
  95. package/src/plugins/builtin/research/event-model.ts +3 -13
  96. package/src/plugins/builtin/research/event-sources.ts +3 -1
  97. package/src/plugins/builtin/short-interest/headless.ts +2 -0
  98. package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
  99. package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
  100. package/src/plugins/builtin/yield-curve/headless.ts +5 -1
  101. package/src/plugins/builtin/yield-curve/index.tsx +5 -0
  102. package/src/portfolio/column-values.ts +47 -14
  103. package/src/portfolio/return-metrics.ts +4 -2
  104. package/src/renderers/dom/host/image-surface.tsx +19 -9
  105. package/src/renderers/dom/host/input.tsx +4 -0
  106. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
  107. package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
  108. package/src/sources/provider-errors.ts +12 -0
  109. package/src/sources/provider-router/index.ts +12 -4
  110. package/src/state/pane-session.ts +145 -0
  111. package/src/tickers/search/home-listing.ts +44 -1
  112. package/src/tickers/search/index.ts +5 -2
  113. package/src/tickers/search/ranking.ts +7 -7
  114. package/src/tickers/us-listing.ts +11 -5
  115. package/src/time-series/base-series.ts +7 -1
  116. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  117. package/src/time-series/fundamentals/series.ts +6 -0
  118. package/src/time-series/resolve.ts +1 -0
  119. package/src/types/financials.ts +20 -0
  120. package/src/types/headless.ts +9 -0
  121. package/src/ui/host.tsx +2 -0
  122. package/src/utils/exchanges.ts +13 -8
  123. package/src/utils/price-earnings.ts +17 -10
  124. package/src/utils/price-history-integrity.ts +15 -0
  125. package/src/utils/reason-codes.ts +79 -0
  126. package/src/utils/share-multiples.cases.json +889 -0
  127. package/src/utils/share-multiples.ts +254 -0
  128. package/src/utils/untrusted-text.ts +11 -0
@@ -666,15 +666,9 @@ function ThemedCompositeChart({
666
666
  const patchLayout = useCallback((patch: ChartLayoutPrefs | ((layout: ChartLayoutPrefs) => ChartLayoutPrefs)) => {
667
667
  layoutStateRef.current.onChartLayoutChange((layout) => patchChartLayout(layout, typeof patch === "function" ? patch(layout) : patch));
668
668
  }, []);
669
- // The tool in hand, read when the bar is toggled (the keyboard hook below holds it).
670
- const toolInHandRef = useRef<{ armed: boolean; putDown: () => void }>({ armed: false, putDown: () => {} });
671
- // Shift+T and the chevrons act on the bar as it shows: a bar open only for
672
- // the tool in hand folds again, the tool put down, and stays hidden.
669
+ // Shift+T and the bar's own button keep it open, or let it fold to the tool in hand again.
673
670
  const toggleToolbar = useCallback(() => {
674
- const tool = toolInHandRef.current;
675
- const hidden = layoutStateRef.current.chartLayout.toolbarHidden === true && !tool.armed;
676
- if (!hidden && tool.armed) tool.putDown();
677
- patchLayout({ toolbarHidden: !hidden });
671
+ patchLayout({ toolbarPinned: layoutStateRef.current.chartLayout.toolbarPinned !== true });
678
672
  }, [patchLayout]);
679
673
  const toggleLegendCollapsed = useCallback(() => patchLayout((layout) => ({ legendCollapsed: !layout.legendCollapsed })), [patchLayout]);
680
674
  const resetPanelHeights = useCallback(() => {
@@ -721,7 +715,7 @@ function ThemedCompositeChart({
721
715
  const legendCollapsed = legendCollapsible && chartLayout.legendCollapsed === true;
722
716
  const projectedPanelCount = projectedScene?.panels.length ?? 0;
723
717
  const layoutControls = useMemo(() => ({
724
- toolbarHidden: chartLayout.toolbarHidden === true,
718
+ toolbarPinned: chartLayout.toolbarPinned === true,
725
719
  toggleToolbar,
726
720
  legendCollapsible,
727
721
  legendCollapsed,
@@ -734,7 +728,7 @@ function ThemedCompositeChart({
734
728
  restorePanels: resetPanelMaximized,
735
729
  }), [
736
730
  chartLayout.panelWeights,
737
- chartLayout.toolbarHidden,
731
+ chartLayout.toolbarPinned,
738
732
  layoutPanels?.length,
739
733
  legendCollapsed,
740
734
  legendCollapsible,
@@ -794,7 +788,6 @@ function ThemedCompositeChart({
794
788
  pickDrawColor,
795
789
  layout: layoutControls,
796
790
  });
797
- toolInHandRef.current = { armed: armedTool !== null, putDown: () => armTool(null) };
798
791
  const pressFromPointer = useCallback(() => {
799
792
  onPress?.();
800
793
  activateFromPointer();
@@ -1045,9 +1038,6 @@ function ThemedCompositeChart({
1045
1038
  // drawing. A chart outside a pane (a share page) keeps them.
1046
1039
  const toolbarWanted = paneFocused !== false || armedTool !== null || pointerDragging || toolSpan !== null;
1047
1040
  const showToolbar = interactive && navigable && toolbarWanted && plotWidth > CHART_TOOLBAR_WIDTH + 4;
1048
- // Hidden, the bar folds to the button that brings it back, and opens again
1049
- // while a tool picked from the keys is in hand, so the plot says which one.
1050
- const toolbarFolded = showToolbar && chartLayout.toolbarHidden === true && armedTool === null;
1051
1041
  // Bars shorter than a day carry a time of day the cursor reads out.
1052
1042
  const intradayBars = baseScene.timeZone !== undefined || visibleSeries.some((entry) => (
1053
1043
  !!entry.historyResolution && isIntradayResolution(entry.historyResolution)
@@ -1119,8 +1109,8 @@ function ThemedCompositeChart({
1119
1109
  drawColor={drawColor}
1120
1110
  showColors={isDrawingTool(armedTool) || !!selectedDrawingId}
1121
1111
  levelTool={levelsEditable}
1122
- folded={toolbarFolded}
1123
- onToggleFolded={() => {
1112
+ pinned={chartLayout.toolbarPinned === true}
1113
+ onTogglePinned={() => {
1124
1114
  pressFromPointer();
1125
1115
  toggleToolbar();
1126
1116
  }}
@@ -1,46 +1,64 @@
1
- import { Box, Text, useShortcutLabel } from "../../../ui";
1
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
2
+ import { Box, Text, useShortcutLabel, type BoxRenderable } from "../../../ui";
2
3
  import { colors as themeColors, hoverBg } from "../../../theme/colors";
3
4
  import { consumeChartMouseEvent, type ChartMouseEvent } from "../core/pointer";
4
5
  import { CHART_DRAWING_COLORS, type ChartToolKind } from "./tools";
5
6
  import { CHART_TOOLS } from "./tool-catalog";
6
7
 
7
- /** Icon cells plus the gap between chips. */
8
- export const CHART_TOOLBAR_WIDTH = CHART_TOOLS.length * 3 + (CHART_TOOLS.length - 1);
8
+ /** The bar's tools, a gap, and the handle that opens it. */
9
+ export const CHART_TOOLBAR_WIDTH = CHART_TOOLS.length * 3 + (CHART_TOOLS.length - 1) + 4;
9
10
 
10
- /** The bar's own button that folds it away, and the one it folds to. */
11
- const FOLD_BUTTON = {
12
- label: "Hide drawing tools",
13
- shortcut: "Shift+T",
14
- glyph: "\u2039",
15
- icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M10 3.5 5.5 8l4.5 4.5" fill="none" stroke="#000" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
16
- };
17
- const UNFOLD_BUTTON = {
18
- label: "Show drawing tools",
19
- shortcut: "Shift+T",
11
+ /** How long the bar stays open once the pointer has left it. */
12
+ export const CHART_TOOLBAR_FOLD_DELAY_MS = 300;
13
+
14
+ const SHORTCUT = "Shift+T";
15
+ /** The handle's icon and its hint, in px on the desktop: together they fix its width, so it keeps it when the bar opens. */
16
+ const HANDLE_ICON_PX = 13;
17
+ const HANDLE_HINT_PX = 9;
18
+ const HANDLE_WIDTH = `calc(var(--gloom-space-xs) * 2 + ${HANDLE_ICON_PX + HANDLE_HINT_PX}px)`;
19
+ /** The hint on the folded handle: the bar opens to its right. */
20
+ const OPEN_CHEVRON = {
20
21
  glyph: "\u203a",
21
22
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M6 3.5 10.5 8 6 12.5" fill="none" stroke="#000" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
22
23
  };
24
+ /** The handle of a bar kept open, which folds it. */
25
+ const FOLD_CHEVRON = {
26
+ glyph: "\u2039",
27
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M10 3.5 5.5 8l4.5 4.5" fill="none" stroke="#000" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
28
+ };
23
29
 
24
- function ChartToolButton({
25
- tool,
30
+ interface PressEventLike {
31
+ key?: string;
32
+ preventDefault?: () => void;
33
+ stopPropagation?: () => void;
34
+ }
35
+
36
+ /** One of the chart's icon buttons: the control radius, the icon button's hover fill, a 13px icon. */
37
+ function ChartIconButton({
38
+ label,
26
39
  active,
27
40
  isDesktopWeb,
28
41
  onPress,
29
42
  role = "composite-chart-tool",
30
- reveal,
43
+ pressed,
44
+ expanded,
45
+ width,
46
+ children,
31
47
  }: {
32
- tool: { label: string; glyph: string; icon: string; shortcut?: string; hint?: string };
48
+ label: string;
33
49
  active: boolean;
34
50
  isDesktopWeb: boolean;
35
51
  onPress: () => void;
36
52
  role?: string;
37
- /** Drawn only while the pointer is over the bar (desktop and web). */
38
- reveal?: boolean;
53
+ /** A toggle: pressed while it is the chart's tool. */
54
+ pressed?: boolean;
55
+ /** A disclosure: open while the bar shows its tools. */
56
+ expanded?: boolean;
57
+ /** The desktop button's width when it is not its icon's (CSS length). */
58
+ width?: string;
59
+ /** Terminal cells for a glyph, or the desktop's masks. */
60
+ children: ReactNode;
39
61
  }) {
40
- const keyLabel = useShortcutLabel();
41
- const named = tool.shortcut ? `${tool.label} (${keyLabel(tool.shortcut)})` : tool.label;
42
- const label = tool.hint ? `${named}. ${tool.hint}` : named;
43
- const color = active ? themeColors.text : themeColors.textDim;
44
62
  return (
45
63
  <Box
46
64
  flexDirection="row"
@@ -59,42 +77,128 @@ function ChartToolButton({
59
77
  data-gloom-interactive="true"
60
78
  data-gloom-role={role}
61
79
  data-gloom-label={label}
62
- data-gloom-reveal={reveal ? "hover" : undefined}
63
80
  data-active={active ? "true" : "false"}
64
81
  title={isDesktopWeb ? label : undefined}
65
- // A tool is a toggle button: the icon button family, pressed while it is the chart's tool.
66
82
  role={isDesktopWeb ? "button" : undefined}
67
83
  aria-label={isDesktopWeb ? label : undefined}
68
- aria-pressed={isDesktopWeb ? active : undefined}
84
+ aria-pressed={isDesktopWeb ? pressed : undefined}
85
+ aria-expanded={isDesktopWeb ? expanded : undefined}
86
+ // Focusable for assistive technology, which opens the bar with the focus.
87
+ // The keyboard's own way is Shift+T: the window keeps Tab for itself.
88
+ tabIndex={isDesktopWeb ? 0 : undefined}
89
+ onKeyDown={isDesktopWeb
90
+ ? (event: PressEventLike) => {
91
+ if (event.key !== "Enter" && event.key !== " ") return;
92
+ event.preventDefault?.();
93
+ event.stopPropagation?.();
94
+ onPress();
95
+ }
96
+ : undefined}
69
97
  // Cells size the terminal strip; the desktop chip sizes to its icon.
70
98
  // The icon button's look: the control radius, the hover fill.
71
- style={isDesktopWeb ? { width: "auto", paddingInline: "var(--gloom-space-xs)", borderRadius: "var(--gloom-radius-md)" } : undefined}
99
+ style={isDesktopWeb ? { width: width ?? "auto", paddingInline: "var(--gloom-space-xs)", borderRadius: "var(--gloom-radius-md)" } : undefined}
100
+ >
101
+ {children}
102
+ </Box>
103
+ );
104
+ }
105
+
106
+ function MaskIcon({ icon, color, size = HANDLE_ICON_PX, visible = true }: { icon: string; color: string; size?: number; visible?: boolean }) {
107
+ return (
108
+ <Box
109
+ flexShrink={0}
110
+ visible={visible}
111
+ style={{
112
+ width: size,
113
+ height: size,
114
+ backgroundColor: color,
115
+ maskImage: svgMaskUrl(icon),
116
+ WebkitMaskImage: svgMaskUrl(icon),
117
+ maskSize: "contain",
118
+ WebkitMaskSize: "contain",
119
+ maskRepeat: "no-repeat",
120
+ WebkitMaskRepeat: "no-repeat",
121
+ maskPosition: "center",
122
+ WebkitMaskPosition: "center",
123
+ }}
124
+ />
125
+ );
126
+ }
127
+
128
+ function ChartToolButton({
129
+ tool,
130
+ active,
131
+ isDesktopWeb,
132
+ onPress,
133
+ }: {
134
+ tool: { label: string; glyph: string; icon: string; shortcut?: string; hint?: string };
135
+ active: boolean;
136
+ isDesktopWeb: boolean;
137
+ onPress: () => void;
138
+ }) {
139
+ const keyLabel = useShortcutLabel();
140
+ const named = tool.shortcut ? `${tool.label} (${keyLabel(tool.shortcut)})` : tool.label;
141
+ const label = tool.hint ? `${named}. ${tool.hint}` : named;
142
+ const color = active ? themeColors.text : themeColors.textDim;
143
+ return (
144
+ <ChartIconButton label={label} active={active} pressed={active} isDesktopWeb={isDesktopWeb} onPress={onPress}>
145
+ {isDesktopWeb ? <MaskIcon icon={tool.icon} color={color} /> : <Text fg={color}>{tool.glyph}</Text>}
146
+ </ChartIconButton>
147
+ );
148
+ }
149
+
150
+ /**
151
+ * The bar's one fixed button, first in it so the pointer that opened the bar
152
+ * is still on it. Folded, it shows the tool in hand, with a hint that it
153
+ * opens; open, only the chevron, which keeps the bar open or lets it fold.
154
+ */
155
+ function ChartToolbarHandle({
156
+ tool,
157
+ armed,
158
+ expanded,
159
+ pinned,
160
+ isDesktopWeb,
161
+ onPress,
162
+ }: {
163
+ tool: { label: string; glyph: string; icon: string };
164
+ /** A tool is in hand, not the resting pan. */
165
+ armed: boolean;
166
+ expanded: boolean;
167
+ pinned: boolean;
168
+ isDesktopWeb: boolean;
169
+ onPress: () => void;
170
+ }) {
171
+ const keyLabel = useShortcutLabel();
172
+ const keys = keyLabel(SHORTCUT);
173
+ const label = expanded
174
+ ? pinned ? `Hide drawing tools (${keys})` : `Keep drawing tools open (${keys})`
175
+ : `${tool.label}. Show drawing tools (${keys})`;
176
+ const color = armed ? themeColors.text : themeColors.textDim;
177
+ const chevron = pinned ? FOLD_CHEVRON : OPEN_CHEVRON;
178
+ return (
179
+ <ChartIconButton
180
+ label={label}
181
+ active={armed && !expanded}
182
+ expanded={expanded}
183
+ width={HANDLE_WIDTH}
184
+ isDesktopWeb={isDesktopWeb}
185
+ onPress={onPress}
186
+ role="composite-chart-toolbar-toggle"
72
187
  >
73
188
  {isDesktopWeb ? (
74
- <Box
75
- flexShrink={0}
76
- style={{
77
- width: 13,
78
- height: 13,
79
- backgroundColor: color,
80
- maskImage: svgMaskUrl(tool.icon),
81
- WebkitMaskImage: svgMaskUrl(tool.icon),
82
- maskSize: "contain",
83
- WebkitMaskSize: "contain",
84
- maskRepeat: "no-repeat",
85
- WebkitMaskRepeat: "no-repeat",
86
- maskPosition: "center",
87
- WebkitMaskPosition: "center",
88
- }}
89
- />
189
+ <>
190
+ {/* Hidden, not removed, once the bar is open: the pointer that opened it is on this icon, and a press that lands as the bar opens still reaches the button.
191
+ The button keeps its width, so a pointer that came in at its edge is still on it. */}
192
+ <MaskIcon icon={tool.icon} color={color} visible={!expanded} />
193
+ <MaskIcon icon={chevron.icon} color={themeColors.textDim} size={expanded ? HANDLE_ICON_PX : HANDLE_HINT_PX} />
194
+ </>
90
195
  ) : (
91
- <Text fg={color}>{tool.glyph}</Text>
196
+ <Text fg={color}>{expanded ? chevron.glyph : `${tool.glyph}${chevron.glyph}`}</Text>
92
197
  )}
93
- </Box>
198
+ </ChartIconButton>
94
199
  );
95
200
  }
96
201
 
97
-
98
202
  function svgMaskUrl(svg: string): string {
99
203
  return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
100
204
  }
@@ -152,8 +256,8 @@ export function ChartToolbar({
152
256
  drawColor,
153
257
  showColors,
154
258
  levelTool,
155
- folded,
156
- onToggleFolded,
259
+ pinned,
260
+ onTogglePinned,
157
261
  onArmTool,
158
262
  onPickColor,
159
263
  }: {
@@ -165,15 +269,20 @@ export function ChartToolbar({
165
269
  showColors: boolean;
166
270
  /** The chart's levels can be edited here. */
167
271
  levelTool: boolean;
168
- /** Hidden by the user: the bar is the one button that brings it back. */
169
- folded: boolean;
170
- /** Folds the bar away, from the button it shows under the pointer, or opens it again. */
171
- onToggleFolded: () => void;
272
+ /** Kept open by the user. Otherwise the bar is folded to the tool in hand and opens under the pointer. */
273
+ pinned: boolean;
274
+ /** Keeps the bar open, or lets it fold again. */
275
+ onTogglePinned: () => void;
172
276
  onArmTool: (tool: ChartToolKind | null) => void;
173
277
  onPickColor: (color: string) => void;
174
278
  }) {
279
+ const barRef = useRef<BoxRenderable | null>(null);
280
+ const { open, onHover, onLeave, onFocus, onBlur, fold } = useToolbarOpening(barRef);
281
+ const expanded = pinned || open;
282
+ const tool = CHART_TOOLS.find((entry) => entry.kind === armedTool) ?? CHART_TOOLS[0]!;
175
283
  return (
176
284
  <Box
285
+ ref={barRef}
177
286
  position="absolute"
178
287
  left={left}
179
288
  top={top}
@@ -194,29 +303,37 @@ export function ChartToolbar({
194
303
  }
195
304
  : undefined}
196
305
  data-gloom-role="composite-chart-toolbar"
197
- data-gloom-reveal-scope="true"
198
- data-folded={folded ? "true" : undefined}
306
+ data-folded={expanded ? undefined : "true"}
307
+ data-pinned={pinned ? "true" : undefined}
308
+ onMouseOver={onHover}
309
+ onMouseOut={onLeave}
310
+ onFocus={isDesktopWeb ? onFocus : undefined}
311
+ onBlur={isDesktopWeb ? onBlur : undefined}
199
312
  >
200
- {folded ? (
201
- <ChartToolButton
202
- tool={UNFOLD_BUTTON}
203
- active={false}
204
- isDesktopWeb={isDesktopWeb}
205
- onPress={onToggleFolded}
206
- role="composite-chart-toolbar-toggle"
207
- />
208
- ) : null}
209
- {folded ? null : CHART_TOOLS.filter((tool) => levelTool || tool.kind !== "level").map((tool) => (
313
+ <ChartToolbarHandle
314
+ tool={tool}
315
+ armed={armedTool !== null}
316
+ expanded={expanded}
317
+ pinned={pinned}
318
+ isDesktopWeb={isDesktopWeb}
319
+ onPress={() => {
320
+ // Pressed while the bar is open only for the pointer or the focus,
321
+ // it stays open; pressed while kept open, it folds now.
322
+ if (pinned) fold();
323
+ onTogglePinned();
324
+ }}
325
+ />
326
+ {expanded ? CHART_TOOLS.filter((entry) => levelTool || entry.kind !== "level").map((entry) => (
210
327
  <ChartToolButton
211
- key={tool.kind ?? "pan"}
212
- tool={tool}
213
- active={armedTool === tool.kind}
328
+ key={entry.kind ?? "pan"}
329
+ tool={entry}
330
+ active={armedTool === entry.kind}
214
331
  isDesktopWeb={isDesktopWeb}
215
- onPress={() => onArmTool(tool.kind)}
332
+ onPress={() => onArmTool(entry.kind)}
216
333
  />
217
- ))}
334
+ )) : null}
218
335
  {/* Colours only take space while something can use them. */}
219
- {!folded && showColors ? CHART_DRAWING_COLORS.map((color) => (
336
+ {expanded && showColors ? CHART_DRAWING_COLORS.map((color) => (
220
337
  <ChartColorSwatch
221
338
  key={color}
222
339
  color={color}
@@ -225,18 +342,77 @@ export function ChartToolbar({
225
342
  onPress={() => onPickColor(color)}
226
343
  />
227
344
  )) : null}
228
- {/* The way to fold the bar shows under the pointer, so a chart at rest
229
- draws the bar as it always has; the terminal has Shift+T and the menu. */}
230
- {!folded && isDesktopWeb ? (
231
- <ChartToolButton
232
- tool={FOLD_BUTTON}
233
- active={false}
234
- isDesktopWeb={isDesktopWeb}
235
- onPress={onToggleFolded}
236
- role="composite-chart-toolbar-toggle"
237
- reveal
238
- />
239
- ) : null}
240
345
  </Box>
241
346
  );
242
347
  }
348
+
349
+ const TOOLBAR_SELECTOR = "[data-gloom-role=composite-chart-toolbar]";
350
+
351
+ /**
352
+ * Whether a pointer event lies on the bar. A mouseout between two of its icons
353
+ * does, and is no leaving. The desktop reads the bar's own box in px; the
354
+ * terminal compares its cells.
355
+ */
356
+ function pointerOnBar(bar: BoxRenderable | null, event: ChartMouseEvent): boolean {
357
+ const element = event.target?.closest?.(TOOLBAR_SELECTOR) as { getBoundingClientRect?: () => DOMRect } | null | undefined;
358
+ if (element?.getBoundingClientRect && typeof event.pixelX === "number" && typeof event.pixelY === "number") {
359
+ const box = element.getBoundingClientRect();
360
+ return event.pixelX >= box.left && event.pixelX < box.right && event.pixelY >= box.top && event.pixelY < box.bottom;
361
+ }
362
+ if (!bar || typeof event.x !== "number" || typeof event.y !== "number") return false;
363
+ const x = Number(bar.x);
364
+ const y = Number(bar.y);
365
+ return event.x >= x && event.x < x + Number(bar.width) && event.y >= y && event.y < y + Number(bar.height);
366
+ }
367
+
368
+ /**
369
+ * Whether the pointer or assistive focus has the bar open: the pointer opens it
370
+ * at once and keeps it open for a moment after it leaves the bar.
371
+ */
372
+ function useToolbarOpening(bar: { current: BoxRenderable | null }) {
373
+ const [hovered, setHovered] = useState(false);
374
+ const [focused, setFocused] = useState(false);
375
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
376
+ const insideRef = useRef(false);
377
+ // Folded by a press under the pointer: it stays folded until the pointer has left the bar.
378
+ const foldedUnderPointerRef = useRef(false);
379
+ const clearTimer = useCallback(() => {
380
+ if (timerRef.current === null) return;
381
+ clearTimeout(timerRef.current);
382
+ timerRef.current = null;
383
+ }, []);
384
+ useEffect(() => clearTimer, [clearTimer]);
385
+ const onHover = useCallback(() => {
386
+ clearTimer();
387
+ insideRef.current = true;
388
+ if (!foldedUnderPointerRef.current) setHovered(true);
389
+ }, [clearTimer]);
390
+ const onLeave = useCallback((event: ChartMouseEvent) => {
391
+ // From one icon to the next, or into the gap between: still on the bar.
392
+ if (pointerOnBar(bar.current, event)) return;
393
+ clearTimer();
394
+ insideRef.current = false;
395
+ // Back within the delay, it opens: the press that folded it is over.
396
+ foldedUnderPointerRef.current = false;
397
+ timerRef.current = setTimeout(() => {
398
+ timerRef.current = null;
399
+ setHovered(false);
400
+ }, CHART_TOOLBAR_FOLD_DELAY_MS);
401
+ }, [bar, clearTimer]);
402
+ const fold = useCallback(() => {
403
+ foldedUnderPointerRef.current = insideRef.current;
404
+ setHovered(false);
405
+ setFocused(false);
406
+ }, []);
407
+ // A press focuses a button too; only focus that shows its ring (assistive technology's) opens the bar.
408
+ const onFocus = useCallback((event: { target?: unknown }) => {
409
+ const target = event.target as { matches?: (selector: string) => boolean } | null;
410
+ if (target?.matches?.(":focus-visible") === true) setFocused(true);
411
+ }, []);
412
+ const onBlur = useCallback((event: { currentTarget?: unknown; relatedTarget?: unknown }) => {
413
+ const root = event.currentTarget as { contains?: (node: unknown) => boolean } | null;
414
+ if (event.relatedTarget && root?.contains?.(event.relatedTarget)) return;
415
+ setFocused(false);
416
+ }, []);
417
+ return { open: hovered || focused, onHover, onLeave, onFocus, onBlur, fold };
418
+ }
@@ -64,8 +64,8 @@ export interface KeyboardToolDrag {
64
64
 
65
65
  /** The chart's own layout: its tool bar, its legend and its panels' heights. */
66
66
  export interface CompositeChartLayoutControls {
67
- /** The bar is saved hidden; it still opens while a tool is in hand. */
68
- toolbarHidden: boolean;
67
+ /** The bar is kept open; otherwise it folds to the tool in hand and opens under the pointer. */
68
+ toolbarPinned: boolean;
69
69
  toggleToolbar: () => void;
70
70
  /** The legend has more than one series, so it can fold to its first. */
71
71
  legendCollapsible: boolean;
@@ -728,8 +728,7 @@ export function useCompositeChartKeyboard({
728
728
  const levelToolKeys = toolsActive && armedTool === "level" && levelsEditable;
729
729
  const canDeleteLevel = toolsActive && levelsEditable && !!selectedLevel?.editable && !selectedLevel.draggable;
730
730
  const pinState = pin ? pin.pinned : null;
731
- // Hidden as it shows: a saved hidden bar is open while a tool is in hand.
732
- const toolbarHidden = layout.toolbarHidden && armedTool === null;
731
+ const toolbarPinned = layout.toolbarPinned;
733
732
  const {
734
733
  legendCollapsible,
735
734
  legendCollapsed,
@@ -811,7 +810,7 @@ export function useCompositeChartKeyboard({
811
810
  if (resettable) menu.push({ id: "chart-reset", label: "Reset Zoom", accelerator: "0", onSelect: () => chartActionsRef.current.reset() });
812
811
  menu.push({
813
812
  id: "chart-toolbar",
814
- label: toolbarHidden ? "Show Drawing Tools" : "Hide Drawing Tools",
813
+ label: toolbarPinned ? "Hide Drawing Tools" : "Show Drawing Tools",
815
814
  accelerator: "Shift+T",
816
815
  onSelect: () => chartActionsRef.current.layout.toggleToolbar(),
817
816
  });
@@ -860,7 +859,7 @@ export function useCompositeChartKeyboard({
860
859
  levelsEditable,
861
860
  toolsActive,
862
861
  pinState,
863
- toolbarHidden,
862
+ toolbarPinned,
864
863
  legendCollapsible,
865
864
  legendCollapsed,
866
865
  panelsResizable,
@@ -2,6 +2,7 @@ import type { CommandBarResultLine } from "../../../types/plugin";
2
2
  import type { TickerRecord } from "../../../types/ticker";
3
3
  import type { BrokerContractRef, TickerListingRef } from "../../../types/instrument";
4
4
  import type { InstrumentRef } from "../../../market-data/request-types";
5
+ import { ASSIST_CATEGORY } from "../assist/model";
5
6
  import {
6
7
  buildSections,
7
8
  type CommandBarCategoryPriorities,
@@ -222,6 +223,14 @@ export function resolveListPageTarget(
222
223
  return target;
223
224
  }
224
225
 
226
+ /**
227
+ * Whether every row is the AI's offer (`Ask AI — sign up to enable`), which
228
+ * no Enter takes: nothing in the list answers what was typed.
229
+ */
230
+ function onlyAssistOffers(results: readonly ResultItem[]): boolean {
231
+ return results.length > 0 && results.every((item) => item.category === ASSIST_CATEGORY && !isDefaultSelectable(item));
232
+ }
233
+
225
234
  export function buildNativeListRows(listState: ListScreenState, rows: CommandBarListRow[]): CommandBarListRow[] {
226
235
  if (listState.searching && rows.length === 0) {
227
236
  return [{ kind: "spinner", id: "searching", label: "Searching…" }];
@@ -232,5 +241,9 @@ export function buildNativeListRows(listState: ListScreenState, rows: CommandBar
232
241
  if (listState.searching) {
233
242
  return [...rows, { kind: "spinner", id: "searching", label: "Searching…" }];
234
243
  }
244
+ // A query nothing matches says so above the offer, rather than leave the offer looking like the answer.
245
+ if (listState.query.trim() && onlyAssistOffers(listState.results)) {
246
+ return [{ kind: "message", id: "empty", label: listState.emptyLabel }, { kind: "spacer", id: "spacer:empty" }, ...rows];
247
+ }
235
248
  return rows;
236
249
  }
@@ -97,6 +97,8 @@ export function useCommandBarTickerSearchActions({
97
97
  ...tickerSelectionFromSearchResult(candidate.result),
98
98
  label: candidate.label,
99
99
  instrumentType: candidate.instrumentType,
100
+ // The names search found the saved listing by ("micro" for MSFT): it is an exact match as its search row is.
101
+ searchAliases: candidate.searchAliases,
100
102
  detail,
101
103
  badge,
102
104
  name,
@@ -162,10 +162,15 @@ export function mergeTickerSearchResultItems(
162
162
  }
163
163
 
164
164
  const SEARCH_BUSY_ITEM_ID = "search-busy";
165
+ const SEARCH_ERROR_ITEM_ID = "search-error";
165
166
 
166
- /** The busy row among a search's rows: a list left with no instruments keeps it, so nothing there reads as no listing. */
167
- function searchBusyRows(items: readonly ResultItem[]): ResultItem[] {
168
- return items.filter((item) => item.id === SEARCH_BUSY_ITEM_ID);
167
+ /**
168
+ * The busy or failed row among a search's rows: a list left with no
169
+ * instruments keeps it, so a search that did not answer never reads as one
170
+ * that found nothing.
171
+ */
172
+ function searchStatusRows(items: readonly ResultItem[]): ResultItem[] {
173
+ return items.filter((item) => item.id === SEARCH_BUSY_ITEM_ID || item.id === SEARCH_ERROR_ITEM_ID);
169
174
  }
170
175
 
171
176
  /**
@@ -185,7 +190,7 @@ export function tickerSearchFailureItems(error: unknown, query: string, localIte
185
190
  }], localItems);
186
191
  }
187
192
  return [{
188
- id: "search-error",
193
+ id: SEARCH_ERROR_ITEM_ID,
189
194
  label: "Search failed",
190
195
  detail: "Check your connection",
191
196
  category: "Search",
@@ -213,7 +218,9 @@ function isInstrumentItem(item: ResultItem): boolean {
213
218
  * further exchange of one already shown, so Saputo's SAP on Toronto is not
214
219
  * pushed out by SAP SE's fourth German venue; the rows keep their ranked order.
215
220
  * Info rows ("no matches", "search failed") are dropped: the instruments are
216
- * an extra here, never the answer.
221
+ * an extra here, never the answer. With no instruments left, a busy or
222
+ * failed search keeps its row, and one that found nothing leaves the list to
223
+ * say so (`buildNativeListRows`).
217
224
  */
218
225
  export function mergePlainRootTickerResults(
219
226
  query: string,
@@ -253,8 +260,8 @@ export function mergePlainRootTickerResults(
253
260
  const commandNamed = wordNamesCommand(query, rootItems);
254
261
  rootItems = leadWithNamedCommands(query, rootItems);
255
262
  if (instruments.length === 0) {
256
- const busy = searchBusyRows(providerItems);
257
- return busy.length > 0 ? [...rootItems, ...busy] : rootItems;
263
+ const status = searchStatusRows(providerItems);
264
+ return status.length > 0 ? [...rootItems, ...status] : rootItems;
258
265
  }
259
266
 
260
267
  // A listing that stopped trading is still the one its symbol names (SIVB, TWTR), unless a live listing
@@ -432,7 +439,7 @@ export function venueDropdownResults(symbol: string, items: ResultItem[], suffix
432
439
  if (!venueMatchesSuffix(item, suffix)) continue;
433
440
  rows.push(item.category === "Exact Match" ? item : { ...item, category: "Exact Match" });
434
441
  }
435
- return rows.length > 0 ? rows : searchBusyRows(items);
442
+ return rows.length > 0 ? rows : searchStatusRows(items);
436
443
  }
437
444
 
438
445
  /**
@@ -44,6 +44,7 @@ import { resolveSelectionKeyHints } from "../selection-hint";
44
44
  import { findPaneInstance } from "../../../types/config";
45
45
  import { getBasePaneDisplayTitle } from "../../layout/pane/title";
46
46
  import { isDialogOpen } from "../../../ui/dialog-stack";
47
+ import { logFailure } from "../../../utils/log-failure";
47
48
 
48
49
  interface CommandBarProps {
49
50
  dataProvider: DataProvider;
@@ -194,7 +195,6 @@ export function CommandBar({
194
195
  openInlineConfirm,
195
196
  openModeRoute,
196
197
  openPaneTemplateWorkflow,
197
- openPluginCommandWorkflow,
198
198
  paneShortcutItems,
199
199
  persistLayoutChange,
200
200
  pluginCommandItems,
@@ -365,14 +365,19 @@ export function CommandBar({
365
365
  if (row) runRootRow({ item: row, query: rootQueryRef.current, rank, isShortcut: () => false }, run);
366
366
  else run();
367
367
  }, [assistState, rootQueryRef, runRootRow, visibleListStateRef]);
368
+ // The offer runs the step that turns the AI on: Sign Up, or for an account
369
+ // whose email is not verified yet, sending the verification again.
368
370
  const startAssistSignUp = useCallback(() => {
369
- const signUpCommand = getAvailablePluginCommands().find((command) => command.id === "auth-signup");
370
- if (signUpCommand?.wizard?.length) {
371
- openPluginCommandWorkflow(signUpCommand);
371
+ const commands = getAvailablePluginCommands();
372
+ const command = commands.find((candidate) => candidate.id === "auth-signup")
373
+ ?? commands.find((candidate) => candidate.id === "auth-resend-verification");
374
+ if (command) {
375
+ Promise.resolve(createPluginCommandItem(command).action())
376
+ .catch(logFailure("command-bar.assist", "Start sign up from the AI offer failed"));
372
377
  return;
373
378
  }
374
379
  setRootQuery("Sign Up");
375
- }, [getAvailablePluginCommands, openPluginCommandWorkflow, setRootQuery]);
380
+ }, [createPluginCommandItem, getAvailablePluginCommands, setRootQuery]);
376
381
  // The assistant pane ships with the cloud plugin, so the row only exists
377
382
  // while that pane template is registered.
378
383
  const askGloomTemplate = useMemo(() => (