gloomberb 0.20.3 → 0.20.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 (154) hide show
  1. package/package.json +1 -1
  2. package/src/account/auth-dialog.tsx +17 -0
  3. package/src/api-client/data.ts +6 -0
  4. package/src/api-client/fx-interventions.ts +64 -0
  5. package/src/api-client/index.ts +1 -0
  6. package/src/api-client/release-summaries.ts +21 -0
  7. package/src/app/keybindings/actions.ts +2 -2
  8. package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
  9. package/src/cli/commands/market.ts +77 -1
  10. package/src/cli/commands/news-search.ts +1 -3
  11. package/src/cli/commands/plugins.ts +27 -5
  12. package/src/cli/commands/system.ts +19 -3
  13. package/src/cli/commands/ticker.ts +60 -19
  14. package/src/cli/index.ts +8 -8
  15. package/src/cli/pane-functions/function-help.ts +3 -3
  16. package/src/cli/report-tables.ts +18 -6
  17. package/src/cli/result.ts +15 -7
  18. package/src/cli/types.ts +2 -0
  19. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  20. package/src/components/chart/composite/composite-chart.tsx +54 -13
  21. package/src/components/chart/composite/event-captions.ts +109 -0
  22. package/src/components/chart/composite/event-guides.ts +74 -0
  23. package/src/components/chart/composite/rasterizer.ts +2 -0
  24. package/src/components/chart/composite/text-renderer.ts +2 -0
  25. package/src/components/chart/composite/types.ts +31 -0
  26. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  27. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  28. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  29. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  30. package/src/components/layout/detached-pane-shell.tsx +1 -1
  31. package/src/components/layout/floating-pane.tsx +5 -1
  32. package/src/components/layout/pane/footer/index.tsx +21 -14
  33. package/src/components/layout/pane/footer/model.ts +6 -0
  34. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  35. package/src/components/layout/shell/active-drag.ts +149 -105
  36. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  37. package/src/components/layout/shell/drag/index.ts +47 -218
  38. package/src/components/layout/shell/drag/live.ts +10 -3
  39. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  40. package/src/components/layout/shell/drag/runtime.ts +29 -6
  41. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  42. package/src/components/layout/shell/index.tsx +11 -6
  43. package/src/components/layout/shell/menu.ts +11 -2
  44. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  45. package/src/components/layout/shell/native/window-state.ts +2 -2
  46. package/src/components/layout/shell/pane/layers.tsx +71 -7
  47. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  48. package/src/components/layout/shell/window-mode/index.ts +8 -10
  49. package/src/components/layout/window-edit/mode.ts +39 -7
  50. package/src/components/layout/window-edit/presentation.ts +1 -1
  51. package/src/components/onboarding/onboarding-keyboard.ts +4 -0
  52. package/src/components/onboarding/onboarding-wizard.tsx +8 -3
  53. package/src/components/ui/button.tsx +2 -0
  54. package/src/components/ui/choice-dialog.tsx +1 -0
  55. package/src/components/ui/data-table/index.tsx +4 -3
  56. package/src/components/ui/list-view.tsx +7 -12
  57. package/src/components/ui/loading.tsx +10 -3
  58. package/src/components/ui/menu.tsx +6 -2
  59. package/src/components/ui/quote.ts +14 -1
  60. package/src/data/config/layout.ts +5 -2
  61. package/src/docs/snapshot.json +29 -5
  62. package/src/i18n/es.ts +9 -8
  63. package/src/i18n/ja.ts +9 -8
  64. package/src/i18n/ko.ts +9 -8
  65. package/src/i18n/zh-cn.ts +9 -8
  66. package/src/i18n/zh-tw.ts +9 -8
  67. package/src/layout/pane-manager/floating-actions.ts +17 -0
  68. package/src/layout/pane-manager/floating-stack.ts +187 -0
  69. package/src/layout/pane-manager/floating.ts +4 -2
  70. package/src/layout/pane-manager/gridlock.ts +5 -1
  71. package/src/layout/pane-manager/index.ts +11 -0
  72. package/src/layout/pane-manager/layout-state.ts +10 -3
  73. package/src/market-data/futures-board.ts +46 -1
  74. package/src/market-data/futures-contract.ts +12 -3
  75. package/src/market-data/fx-interventions.ts +270 -0
  76. package/src/news/news-model.ts +44 -2
  77. package/src/plugins/builtin/alerts/cli.ts +4 -4
  78. package/src/plugins/builtin/alerts/format.ts +1 -2
  79. package/src/plugins/builtin/alerts/headless.ts +1 -2
  80. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  81. package/src/plugins/builtin/alerts/move.ts +30 -9
  82. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  83. package/src/plugins/builtin/alerts/storage.ts +4 -2
  84. package/src/plugins/builtin/alerts/types.ts +12 -0
  85. package/src/plugins/builtin/changelog/index.tsx +292 -101
  86. package/src/plugins/builtin/changelog/versions.ts +293 -0
  87. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  88. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  89. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  90. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  91. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  92. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  93. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  94. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  95. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  96. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  97. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  98. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  99. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  100. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
  101. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  102. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  103. package/src/plugins/builtin/cot/headless.ts +14 -2
  104. package/src/plugins/builtin/earnings/index.tsx +2 -2
  105. package/src/plugins/builtin/futures/index.tsx +25 -4
  106. package/src/plugins/builtin/futures/model.ts +28 -32
  107. package/src/plugins/builtin/futures/series.ts +4 -3
  108. package/src/plugins/builtin/futures/table.tsx +16 -9
  109. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  110. package/src/plugins/builtin/help/index.tsx +3 -3
  111. package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
  112. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  113. package/src/plugins/builtin/news/headless.ts +2 -2
  114. package/src/plugins/builtin/news/index.tsx +3 -3
  115. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  116. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  117. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  118. package/src/plugins/builtin/research/event-model.ts +9 -1
  119. package/src/plugins/builtin/research/event-sources.ts +22 -0
  120. package/src/plugins/builtin/research/headless.ts +3 -3
  121. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  122. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  123. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
  124. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  125. package/src/plugins/installer.ts +45 -0
  126. package/src/remote/resources.ts +12 -1
  127. package/src/remote/schema.ts +1 -0
  128. package/src/remote/semantic-helpers.ts +29 -1
  129. package/src/remote/semantic-tree.tsx +32 -15
  130. package/src/renderers/cloudflare/worker.ts +16 -1
  131. package/src/renderers/dom/styles.css +40 -6
  132. package/src/renderers/share/layout-view.tsx +1 -1
  133. package/src/sources/gloomberb-cloud/news.ts +35 -12
  134. package/src/state/opening-ticker-panes.ts +47 -0
  135. package/src/test-support/cli-context.ts +2 -0
  136. package/src/test-support/preload.ts +4 -1
  137. package/src/tickers/instrument-kind.ts +23 -3
  138. package/src/types/config.ts +5 -0
  139. package/src/types/context-menu.ts +2 -0
  140. package/src/types/plugin-commands.ts +140 -0
  141. package/src/types/plugin-context.ts +125 -0
  142. package/src/types/plugin-contributions.ts +55 -0
  143. package/src/types/plugin-definition.ts +234 -0
  144. package/src/types/plugin-notifications.ts +38 -0
  145. package/src/types/plugin-pane-settings.ts +114 -0
  146. package/src/types/plugin-pane-templates.ts +160 -0
  147. package/src/types/plugin-panes.ts +221 -0
  148. package/src/types/plugin-reports.ts +35 -0
  149. package/src/types/plugin-shared.ts +14 -0
  150. package/src/types/plugin-state.ts +71 -0
  151. package/src/types/plugin.ts +14 -1169
  152. package/src/ui/index.tsx +14 -3
  153. package/src/updater/github-releases.ts +23 -0
  154. package/src/utils/cli-output.ts +22 -9
package/src/cli/result.ts CHANGED
@@ -16,7 +16,15 @@ import { serializeCsv } from "../utils/csv";
16
16
  import { formatUtcTime, isEpochMilliseconds, isZonedIsoDateTime } from "../utils/utc-time";
17
17
  import { formatFreshnessLine, withSavedCopy, type ReportFreshness } from "./pane-functions/freshness";
18
18
  import { withSearchHints, type FredSeriesCheck } from "./not-a-ticker";
19
- import { renderReportCsv, renderReportNdjson, splitCsvFooter, withCsvFooter, type CliReportTables } from "./report-tables";
19
+ import {
20
+ exportJsonValue,
21
+ exportNumber,
22
+ renderReportCsv,
23
+ renderReportNdjson,
24
+ splitCsvFooter,
25
+ withCsvFooter,
26
+ type CliReportTables,
27
+ } from "./report-tables";
20
28
  import {
21
29
  EXPORT_DATING_COLUMNS,
22
30
  EXPORT_IDENTITY_COLUMNS,
@@ -383,7 +391,7 @@ function renderCsv<Row extends Record<string, unknown>>(
383
391
  const blanked = resolvedColumns.flatMap((column, index) => isNonFiniteNumber(values[index]) ? [column.header] : []);
384
392
  const datingCells = dating?.(row) ?? [];
385
393
  return [
386
- ...values.map((value) => isNonFiniteNumber(value) ? "" : value),
394
+ ...values.map((value) => isNonFiniteNumber(value) ? "" : typeof value === "number" ? exportNumber(value) : value),
387
395
  ...status ? [exportStatusText(status(row), blanked)] : [],
388
396
  ...identity?.(row) ?? [],
389
397
  ...datingAdded.map((index) => datingCells[index] ?? ""),
@@ -532,7 +540,7 @@ export function serializeCliResult<T, Row extends Record<string, unknown> = Reco
532
540
  ...(cited ? { source: exportSource(cited) } : {}),
533
541
  ...(columns?.length ? { columns } : {}),
534
542
  };
535
- return JSON.stringify(envelope, null, 2);
543
+ return JSON.stringify(envelope, exportJsonValue, 2);
536
544
  }
537
545
  const body = serializeCliRows(rest, options, renderOptions, cited);
538
546
  if (options.format !== "text" || !freshness) return body;
@@ -559,14 +567,14 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
559
567
  if (options.format === "ndjson") {
560
568
  const statusKey = ndjsonStatusKey(rows, renderOptions.columns as readonly CliResultColumn<never>[] | undefined);
561
569
  return rows.map((row) => {
562
- if (!isPlainObject(row)) return JSON.stringify(row);
570
+ if (!isPlainObject(row)) return JSON.stringify(row, exportJsonValue);
563
571
  const fields = ndjsonRow(row as Row, status, statusKey);
564
- if (!cited) return JSON.stringify(fields);
572
+ if (!cited) return JSON.stringify(fields, exportJsonValue);
565
573
  const identity = rowIdentity(row as Row, renderOptions.exportIdentity);
566
574
  // A dated export's own fields (a row's `released`) keep their values.
567
575
  const dating = renderOptions.exportDated
568
576
  ? Object.fromEntries(Object.entries(exportDatingFields(cited, identity)).filter(([key]) => !(key in fields))) : {};
569
- return JSON.stringify({ ...fields, ...exportIdentityFields(cited, identity), ...dating });
577
+ return JSON.stringify({ ...fields, ...exportIdentityFields(cited, identity), ...dating }, exportJsonValue);
570
578
  }).join("\n");
571
579
  }
572
580
  if (options.format === "csv") {
@@ -674,7 +682,7 @@ function exportNdjsonNotes<T, Row extends Record<string, unknown>>(
674
682
 
675
683
  export function serializeCliError(error: CliErrorObject, options: CliGlobalOptions): string {
676
684
  if (options.format === "json" || options.format === "ndjson") {
677
- return JSON.stringify({ ok: false, error }, null, options.format === "json" ? 2 : 0);
685
+ return JSON.stringify({ ok: false, error }, exportJsonValue, options.format === "json" ? 2 : 0);
678
686
  }
679
687
  return error.details == null ? error.message : `${error.message}\n${String(error.details)}`;
680
688
  }
package/src/cli/types.ts CHANGED
@@ -29,6 +29,8 @@ export type MarketContext = ConfigContext & {
29
29
  statementSources?: StatementReportSources;
30
30
  /** Daily FX closes (`fx --date`, converted INS values); Gloom Cloud unless a test stands in for it. */
31
31
  fxHistory?: FxHistoryClient;
32
+ /** Japan's intervention record for a yen pair's notes; Gloom Cloud unless a test stands in for it. */
33
+ fxInterventions?: () => Promise<import("../api-client/fx-interventions").FxInterventionsPayload | null>;
32
34
  };
33
35
 
34
36
  export type CliServicesContext = {
@@ -1,6 +1,7 @@
1
1
  import { memo } from "react";
2
2
  import { Box, Text, useUiCapabilities } from "../../../ui";
3
3
  import type { CompositeChartXMarker } from "./types";
4
+ import type { EventCaptionPlacement } from "./event-captions";
4
5
 
5
6
  export interface StaticChartXAxisLabel {
6
7
  label: string;
@@ -493,3 +494,24 @@ export function StaticXMarkerLabels({
493
494
  </Box>
494
495
  );
495
496
  }
497
+
498
+ /** Events' captions in the row under the axis, laid out by `layoutEventCaptions`. */
499
+ export function EventCaptions({
500
+ captions,
501
+ width,
502
+ color,
503
+ }: {
504
+ captions: readonly EventCaptionPlacement[];
505
+ width: number;
506
+ color?: string;
507
+ }) {
508
+ return (
509
+ <Box position="relative" width={width} height={1}>
510
+ {captions.map(({ id, left, text }) => (
511
+ <Box key={id} position="absolute" left={left} top={0} width={text.length} height={1} overflow="hidden" zIndex={2}>
512
+ <Text fg={color}>{text}</Text>
513
+ </Box>
514
+ ))}
515
+ </Box>
516
+ );
517
+ }
@@ -48,7 +48,8 @@ import { reuseResolvedSeriesList } from "./panel-series";
48
48
  import { consumeChartMouseEvent, type ChartMouseEvent } from "../core/pointer";
49
49
  import { useChartViewResetListener } from "../core/view-reset";
50
50
  import { useShowChartTextFallback } from "../native/use-chart-text-fallback";
51
- import { StaticXAxisLabels, StaticXMarkerLabels, StaticXMarkerOverlay } from "./axis-overlays";
51
+ import { EventCaptions, StaticXAxisLabels, StaticXMarkerLabels, StaticXMarkerOverlay } from "./axis-overlays";
52
+ import { layoutEventCaptions } from "./event-captions";
52
53
  import { formatCompositeCursorAxisDate } from "./format";
53
54
  import {
54
55
  createCompositeCursorSource,
@@ -64,7 +65,7 @@ import {
64
65
  } from "./interactions";
65
66
  import { NO_VALUE_SCALES, resolveAxisDragSpanFactor } from "./value-scale";
66
67
  import { useCompositeValueScales } from "./use-composite-value-scales";
67
- import { COMPOSITE_RIGHT_OFFSET_RATIO } from "./time-scale";
68
+ import { COMPOSITE_RIGHT_OFFSET_RATIO, projectCompositeTimestamp } from "./time-scale";
68
69
  import {
69
70
  allocateCompositePanelHeights,
70
71
  buildCompositeChartScene,
@@ -77,7 +78,9 @@ import type {
77
78
  CompositeChartColors,
78
79
  CompositeChartProps,
79
80
  CompositeChartScene,
81
+ CompositeChartEvent,
80
82
  CompositeChartXMarker,
83
+ CompositeEventGuide,
81
84
  CompositePanelScene,
82
85
  } from "./types";
83
86
 
@@ -104,6 +107,8 @@ function chartWatermarkScale(plotWidthPx: number, plotHeightPx: number): number
104
107
  }
105
108
 
106
109
  const NO_X_MARKERS: readonly CompositeChartXMarker[] = [];
110
+ const NO_EVENTS: readonly CompositeChartEvent[] = [];
111
+ const NO_PROJECTED_EVENTS: readonly { event: CompositeChartEvent; guide: CompositeEventGuide }[] = [];
107
112
  const subscribeToNothing = () => () => {};
108
113
  const holdsNothing = () => false;
109
114
 
@@ -207,6 +212,8 @@ function ThemedCompositeChart({
207
212
  panelRules = !navigable,
208
213
  formatAxisValue,
209
214
  xAxis,
215
+ events,
216
+ mergeEventCaptions,
210
217
  remoteKind,
211
218
  allowHistoricalBackfill = false,
212
219
  axisWidth = 9,
@@ -336,8 +343,16 @@ function ThemedCompositeChart({
336
343
  // The pane's range control asks for this when its selected range is chosen again.
337
344
  useChartViewResetListener(resetView, interactive);
338
345
  const timeAxisRows = showTimeAxis ? 1 : 0;
339
- const xMarkers = xAxis?.markers ?? NO_X_MARKERS;
340
- const xMarkerRows = xMarkers.some((marker) => marker.label) ? 1 : 0;
346
+ const axisMarkers = xAxis?.markers ?? NO_X_MARKERS;
347
+ // Events in the view; their captions' row is kept whenever the chart has any, so panning never moves the plot.
348
+ const viewStart = effectiveViewport?.start.getTime() ?? null;
349
+ const viewEnd = effectiveViewport?.end.getTime() ?? null;
350
+ const timedEvents = !xAxis && events?.length ? events : NO_EVENTS;
351
+ const eventsInView = useMemo(() => (
352
+ timedEvents.length === 0 || viewStart === null || viewEnd === null ? NO_EVENTS
353
+ : timedEvents.filter((event) => event.time <= viewEnd && (event.endTime ?? event.time) >= viewStart)
354
+ ), [timedEvents, viewEnd, viewStart]);
355
+ const xMarkerRows = axisMarkers.some((marker) => marker.label) || timedEvents.some((event) => event.captions?.length) ? 1 : 0;
341
356
  const panelCount = new Set(panelSeries.map((entry) => entry.panelId)).size;
342
357
  // One legend line, or up to a few when its entries cannot share one and each
343
358
  // panel keeps a readable plot: the legend says how many it needs while no
@@ -493,18 +508,40 @@ function ThemedCompositeChart({
493
508
  1,
494
509
  Math.round(plotWidth * cellWidthPx * Math.max(1, pixelRatio)),
495
510
  );
511
+ // An event is a guide at its time on the scale the bars are drawn on, so it sits on its bar.
512
+ const projectedEvents = useMemo(() => {
513
+ if (eventsInView.length === 0 || !projectedScene) return NO_PROJECTED_EVENTS;
514
+ const projected = eventsInView.flatMap((event) => {
515
+ const ratio = projectCompositeTimestamp(projectedScene.timeScale, event.time)?.ratio;
516
+ const end = event.endTime === undefined ? undefined : projectCompositeTimestamp(projectedScene.timeScale, event.endTime)?.ratio;
517
+ if (ratio == null || event.endTime !== undefined && end == null) return [];
518
+ if (end === undefined ? ratio < 0 || ratio > 1 : end! < 0 || ratio > 1) return [];
519
+ const guide: CompositeEventGuide = { xRatio: ratio, ...(end !== undefined ? { endXRatio: end! } : {}), dotted: event.dotted === true };
520
+ return [{ event, guide }];
521
+ });
522
+ return projected.length > 0 ? projected : NO_PROJECTED_EVENTS;
523
+ }, [eventsInView, projectedScene]);
496
524
  const baseScene = useMemo<CompositeChartScene | null>(() => {
497
525
  if (!projectedScene || !layoutPanels) return null;
526
+ const eventGuides = projectedEvents.length > 0 ? projectedEvents.map(({ guide }) => guide) : null;
498
527
  const laidOut: CompositeChartScene = {
499
528
  ...projectedScene,
500
529
  width: plotWidth,
501
530
  height: layoutPanels.reduce((sum, panel) => sum + panel.height, 0),
502
- panels: layoutPanels,
531
+ panels: eventGuides ? layoutPanels.map((panel) => ({ ...panel, eventGuides })) : layoutPanels,
503
532
  // A panel with the whole plot still leaves the legend every series' value.
504
533
  ...(maximizedPanelId ? { cursorPanels: projectedScene.panels } : {}),
505
534
  };
506
535
  return downsampleCompositeChartScene(laidOut, downsampleWidth);
507
- }, [downsampleWidth, layoutPanels, maximizedPanelId, plotWidth, projectedScene]);
536
+ }, [downsampleWidth, layoutPanels, maximizedPanelId, plotWidth, projectedEvents, projectedScene]);
537
+ // The events' captions, in the row under the axis, each beside its guide.
538
+ const eventCaptions = useMemo(() => {
539
+ if (projectedEvents.length === 0) return [];
540
+ const column = (ratio: number) => Math.round(Math.min(1, Math.max(0, ratio)) * Math.max(0, plotWidth - 1));
541
+ return layoutEventCaptions(projectedEvents.map(({ event, guide }) => ({
542
+ event, from: column(guide.xRatio), to: column(guide.endXRatio ?? guide.xRatio),
543
+ })), plotWidth, mergeEventCaptions);
544
+ }, [mergeEventCaptions, plotWidth, projectedEvents]);
508
545
  // The cursor shown: the chart's own, or else the owner's.
509
546
  const currentCursorTimestamp = useCallback(
510
547
  () => (ownsCursor ? ownCursor.get() : null) ?? ownerCursorTimestamp,
@@ -1207,7 +1244,7 @@ function ThemedCompositeChart({
1207
1244
  <AsciiText text="Gloomberb" font="wordmark" scale={watermarkScale} color={resolvedColors.textDim} />
1208
1245
  </Box>
1209
1246
  ) : null}
1210
- {xMarkers.length > 0 ? (
1247
+ {axisMarkers.length > 0 ? (
1211
1248
  <Box
1212
1249
  position="absolute"
1213
1250
  left={leftPadding}
@@ -1218,7 +1255,7 @@ function ThemedCompositeChart({
1218
1255
  style={isDesktopWeb ? { ...plotInsetStyle, pointerEvents: "none" } : undefined}
1219
1256
  >
1220
1257
  <StaticXMarkerOverlay
1221
- markers={xMarkers}
1258
+ markers={axisMarkers}
1222
1259
  width={plotWidth}
1223
1260
  height={plotHeight}
1224
1261
  fallbackColor={resolvedColors.textDim}
@@ -1255,11 +1292,15 @@ function ThemedCompositeChart({
1255
1292
  {xMarkerRows > 0 ? (
1256
1293
  <Box flexDirection="row" width={totalWidth} height={1} style={isDesktopWeb ? DESKTOP_FULL_ROW : undefined}>
1257
1294
  {leftPadding > 0 ? <Box width={leftPadding} /> : null}
1258
- <StaticXMarkerLabels
1259
- markers={xMarkers}
1260
- width={plotWidth}
1261
- fallbackColor={resolvedColors.textDim}
1262
- />
1295
+ {axisMarkers.length > 0 ? (
1296
+ <StaticXMarkerLabels
1297
+ markers={axisMarkers}
1298
+ width={plotWidth}
1299
+ fallbackColor={resolvedColors.textDim}
1300
+ />
1301
+ ) : (
1302
+ <EventCaptions captions={eventCaptions} width={plotWidth} color={resolvedColors.textDim} />
1303
+ )}
1263
1304
  {rightPadding > 0 ? <Box width={rightPadding} /> : null}
1264
1305
  </Box>
1265
1306
  ) : null}
@@ -0,0 +1,109 @@
1
+ import type { CompositeChartEvent } from "./types";
2
+
3
+ /** A caption never sits further than this many cells from its guide. */
4
+ const NEAR_CELLS = 2;
5
+
6
+ /** An event in view, with the plot columns its guide (or its period) covers. */
7
+ export interface EventCaptionAnchor {
8
+ event: CompositeChartEvent;
9
+ from: number;
10
+ to: number;
11
+ }
12
+
13
+ /** A caption laid out in the row under the axis. */
14
+ export interface EventCaptionPlacement {
15
+ id: string;
16
+ left: number;
17
+ text: string;
18
+ }
19
+
20
+ interface Group {
21
+ events: CompositeChartEvent[];
22
+ from: number;
23
+ to: number;
24
+ captions: readonly string[];
25
+ /** The caption shown: an index into `captions`, longest first. */
26
+ level: number;
27
+ }
28
+
29
+ interface Placed {
30
+ group: Group;
31
+ left: number;
32
+ }
33
+
34
+ /**
35
+ * Where a caption goes: centred on its guide, inside the plot, ending at
36
+ * `limit` at the latest, and never more than two cells from its guide; null
37
+ * when it cannot.
38
+ */
39
+ function captionLeft(group: Group, text: string, width: number, limit: number): number | null {
40
+ const length = text.length;
41
+ if (length === 0 || length > width) return null;
42
+ const centred = Math.round((group.from + group.to) / 2 - (length - 1) / 2);
43
+ const left = Math.min(Math.max(0, Math.min(width - length, centred)), limit - length + 1);
44
+ if (left < 0) return null;
45
+ const right = left + length - 1;
46
+ const gap = group.to < left ? left - group.to : group.from > right ? group.from - right : 0;
47
+ return gap <= NEAR_CELLS ? left : null;
48
+ }
49
+
50
+ /** The longest caption of `group` from its level on that fits before `limit`. */
51
+ function fit(group: Group, width: number, limit: number): Placed | null {
52
+ for (let level = group.level; level < group.captions.length; level += 1) {
53
+ const left = captionLeft(group, group.captions[level]!, width, limit);
54
+ if (left !== null) return { group: { ...group, level }, left };
55
+ }
56
+ return null;
57
+ }
58
+
59
+ /**
60
+ * The events' captions in one row, newest first so the latest keeps the most
61
+ * room. Each is the longest of its captions that fits beside its guide; when
62
+ * two collide, the older one takes a shorter caption, then the newer one
63
+ * does, then the two share one caption (`merge`), and without one, or with
64
+ * no room even for that, the older is left out. A caption is never moved away
65
+ * from its guide to find room.
66
+ */
67
+ export function layoutEventCaptions(
68
+ anchors: readonly EventCaptionAnchor[],
69
+ width: number,
70
+ merge?: (events: readonly CompositeChartEvent[]) => readonly string[],
71
+ ): EventCaptionPlacement[] {
72
+ const groups = anchors
73
+ .filter((anchor) => anchor.event.captions?.length)
74
+ .map((anchor): Group => ({ events: [anchor.event], from: anchor.from, to: anchor.to, captions: anchor.event.captions!, level: 0 }))
75
+ .sort((left, right) => left.from - right.from || left.to - right.to);
76
+ const placed: Placed[] = [];
77
+ // The last column free for a caption left of those placed, a blank cell between two.
78
+ const limit = () => (placed.length > 0 ? placed.at(-1)!.left - 2 : width - 1);
79
+ for (let index = groups.length - 1; index >= 0; index -= 1) {
80
+ const group = groups[index]!;
81
+ for (;;) {
82
+ const own = fit(group, width, limit());
83
+ if (own) {
84
+ placed.push(own);
85
+ break;
86
+ }
87
+ const right = placed.at(-1);
88
+ if (!right) break;
89
+ if (right.group.level < right.group.captions.length - 1) {
90
+ placed.pop();
91
+ const shorter = fit({ ...right.group, level: right.group.level + 1 }, width, limit());
92
+ placed.push(shorter ?? right);
93
+ if (shorter) continue;
94
+ }
95
+ if (merge) {
96
+ placed.pop();
97
+ const events = [...group.events, ...right.group.events];
98
+ const shared = fit({ events, from: group.from, to: Math.max(group.to, right.group.to), captions: merge(events), level: 0 }, width, limit());
99
+ placed.push(shared ?? right);
100
+ }
101
+ break;
102
+ }
103
+ }
104
+ return placed.reverse().map(({ group, left }) => ({
105
+ id: group.events.map((event) => event.id).join("+"),
106
+ left,
107
+ text: group.captions[group.level]!,
108
+ }));
109
+ }
@@ -0,0 +1,74 @@
1
+ import { fillRect, parseHex } from "../native/raster/primitives";
2
+ import { clamp } from "../../../utils/math";
3
+ import type { CompositeEventGuide } from "./types";
4
+
5
+ const GUIDE_OPACITY = 0.55;
6
+ /** A period's span, as faint as extended hours' shading. */
7
+ const SPAN_OPACITY = 0.08;
8
+ const DOT_PIXELS = 3;
9
+ const GAP_PIXELS = 3;
10
+ /** The text plot's guide, and a dotted one: glyphs no candle, cursor or session break draws. */
11
+ const EVENT_GUIDE_CHAR = "╎";
12
+ const DOTTED_EVENT_GUIDE_CHAR = "┆";
13
+
14
+ /** The guide's edges inside the plot: its own x, or a period's first and last. */
15
+ function edges(guide: CompositeEventGuide): number[] {
16
+ const ratios = guide.endXRatio === undefined ? [guide.xRatio] : [guide.xRatio, guide.endXRatio];
17
+ return ratios.filter((ratio) => ratio >= 0 && ratio <= 1);
18
+ }
19
+
20
+ /**
21
+ * Dated events' guides in a panel's bitmap, painted before the marks so a bar
22
+ * on the event's day still reads across its own guide: one pixel wide on the
23
+ * bar's centre, dotted for an event whose day is not known yet. A period is
24
+ * shaded from its first day to its last, a guide at each end.
25
+ */
26
+ export function paintEventGuides(
27
+ data: Uint8Array,
28
+ width: number,
29
+ height: number,
30
+ guides: readonly CompositeEventGuide[],
31
+ color: string,
32
+ ): void {
33
+ const tint = parseHex(color);
34
+ const maxX = Math.max(width - 1, 0);
35
+ for (const guide of guides) {
36
+ if (guide.endXRatio !== undefined) {
37
+ const from = Math.round(clamp(guide.xRatio, 0, 1) * maxX), to = Math.round(clamp(guide.endXRatio, 0, 1) * maxX);
38
+ if (to > from) fillRect(data, width, height, from, 0, to, height - 1, tint, SPAN_OPACITY);
39
+ }
40
+ for (const ratio of edges(guide)) {
41
+ const x = Math.round(ratio * maxX);
42
+ if (!guide.dotted) {
43
+ fillRect(data, width, height, x, 0, x, height - 1, tint, GUIDE_OPACITY);
44
+ continue;
45
+ }
46
+ for (let y = 0; y < height; y += DOT_PIXELS + GAP_PIXELS) {
47
+ fillRect(data, width, height, x, y, x, Math.min(y + DOT_PIXELS - 1, height - 1), tint, GUIDE_OPACITY);
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ const open = (cell: string | undefined) => cell === undefined || cell === " " || cell === "·";
54
+
55
+ /**
56
+ * The text plot's guides, `╎`, or `┆` for an event whose day is not known
57
+ * yet (at each end of its period), in blank and grid cells only, and never
58
+ * in the cell just above or below a mark, so the day's candle keeps its high
59
+ * and low readable.
60
+ */
61
+ export function writeEventGuidesText(rows: string[][], width: number, guides: readonly CompositeEventGuide[]): void {
62
+ const maxX = Math.max(width - 1, 0);
63
+ const writes: { row: number; x: number; char: string }[] = [];
64
+ for (const guide of guides) {
65
+ const char = guide.dotted ? DOTTED_EVENT_GUIDE_CHAR : EVENT_GUIDE_CHAR;
66
+ for (const ratio of edges(guide)) {
67
+ const x = clamp(Math.round(ratio * maxX), 0, maxX);
68
+ rows.forEach((row, index) => {
69
+ if (open(row[x]) && open(rows[index - 1]?.[x]) && open(rows[index + 1]?.[x])) writes.push({ row: index, x, char });
70
+ });
71
+ }
72
+ }
73
+ for (const { row, x, char } of writes) rows[row]![x] = char;
74
+ }
@@ -14,6 +14,7 @@ import {
14
14
  type CompositeColumnGroupCenter,
15
15
  type CompositeColumnLayout,
16
16
  } from "./column-layout";
17
+ import { paintEventGuides } from "./event-guides";
17
18
  import { compositeGridRatios } from "./format";
18
19
  import { projectCompositeValue } from "./scene";
19
20
  import { paintVolumeProfile } from "./volume-profile-paint";
@@ -553,6 +554,7 @@ export function renderCompositePanelBitmap(
553
554
  fillRect(data, width, height, 0, y, width - 1, y + 0.6, grid, 0.42);
554
555
  }
555
556
  if (panel.volumeProfile) paintVolumeProfile(data, width, height, panel.volumeProfile);
557
+ if (panel.eventGuides) paintEventGuides(data, width, height, panel.eventGuides, options.colors.textDim);
556
558
  // Under the bars, which read across it.
557
559
  if (panel.priorClose) {
558
560
  drawDashedLevel(data, width, height, panel.priorClose.yRatio, parseHex(options.colors.textDim),
@@ -1,4 +1,5 @@
1
1
  import { displayWidth, padTo } from "../../../utils/format";
2
+ import { writeEventGuidesText } from "./event-guides";
2
3
  import { compositeAxisTicks, compositeGridRatios, type CompositeAxisValueFormatter } from "./format";
3
4
  import { resolveCompositeObservationWidth } from "./rasterizer";
4
5
  import { buildCompositeColumnLayout, type CompositeColumnLayout } from "./column-layout";
@@ -336,6 +337,7 @@ export function renderCompositePanelText(
336
337
 
337
338
  if (panel.volumeProfile) writeVolumeProfileText(rows, plotWidth, panel.volumeProfile);
338
339
  if (panel.extendedHours) writeSessionBreaksText(rows, plotWidth, panel.extendedHours);
340
+ if (panel.eventGuides) writeEventGuidesText(rows, plotWidth, panel.eventGuides);
339
341
 
340
342
  // Blank cells only, so the dashed level reads as if it ran under the marks.
341
343
  if (panel.lastPrice) {
@@ -147,6 +147,8 @@ export interface CompositePanelScene {
147
147
  lastPrice?: CompositeLastPriceMarker;
148
148
  /** Present on a panel holding a volume-profile study. */
149
149
  volumeProfile?: CompositeVolumeProfile;
150
+ /** Guides at dated events, shared by every panel and drawn under the marks. */
151
+ eventGuides?: readonly CompositeEventGuide[];
150
152
  /** Plot spans (x ratios) of intraday bars outside the regular session, shared by every panel. */
151
153
  extendedHours?: readonly CompositeExtendedHoursSpan[];
152
154
  /** The previous session's close on a one-day chart, drawn as a dotted reference line. */
@@ -227,6 +229,31 @@ export interface CompositeChartXMarker {
227
229
  lineChar?: string;
228
230
  }
229
231
 
232
+ /**
233
+ * Something that happened at a time (an intervention): a guide through every
234
+ * panel at that time, drawn under the marks, and its caption in the row below
235
+ * the axis. The row is kept while the chart has events, so the plot does not
236
+ * move as one pans in or out of view; one outside the view is not drawn.
237
+ */
238
+ export interface CompositeChartEvent {
239
+ id: string;
240
+ /** The instant, in ms: the time of the bar it belongs on, so the guide is on that bar. */
241
+ time: number;
242
+ /** A period's last bar: the event is shaded from `time` to it, with a guide at each end. */
243
+ endTime?: number;
244
+ /** Its caption, longest first: the row shows the longest that fits beside the guide. */
245
+ captions?: readonly string[];
246
+ /** Its day is not known yet (a total for a period): the guides are dotted. */
247
+ dotted?: boolean;
248
+ }
249
+
250
+ /** Where a `CompositeChartEvent` falls in the plot; a period partly in view has an edge outside 0-1. */
251
+ export interface CompositeEventGuide {
252
+ xRatio: number;
253
+ endXRatio?: number;
254
+ dotted: boolean;
255
+ }
256
+
230
257
  /** Replaces the date axis for charts whose x is not time: a fraction, a tenor, a return. */
231
258
  export interface CompositeChartXAxis {
232
259
  /** Evenly spread labels drawn instead of date ticks. */
@@ -305,6 +332,10 @@ export interface CompositeChartProps {
305
332
  */
306
333
  formatAxisValue?: (value: number, domain: CompositeAxisDomain) => string;
307
334
  xAxis?: CompositeChartXAxis;
335
+ /** Dated events on a time axis; a chart with `xAxis` has no time to put them at. */
336
+ events?: readonly CompositeChartEvent[];
337
+ /** One caption, longest first, for events too close to caption apart; without it the older caption is left out. */
338
+ mergeEventCaptions?: (events: readonly CompositeChartEvent[]) => readonly string[];
308
339
  /** Tagged onto the plot's semantic node so remote clients can find this chart. */
309
340
  remoteKind?: string;
310
341
  /** Permit panning into an older unloaded window so the owner can backfill it. */
@@ -71,8 +71,8 @@ export function buildFocusedPaneLayoutItems({
71
71
  return [
72
72
  {
73
73
  id: "layout-toggle-mode",
74
- label: focusedFloating ? "Dock Pane" : "Float Pane",
75
- detail: focusedFloating ? "Return the focused window to the layout" : "Detach the focused pane into a floating window",
74
+ label: focusedFloating ? "Return to Layout" : "Float Pane",
75
+ detail: focusedFloating ? "Return the focused window to the layout" : "Take the focused pane out of the layout into a floating window",
76
76
  category: "Focused Pane",
77
77
  kind: "action",
78
78
  action: () => {
@@ -115,7 +115,7 @@ export function buildFocusedPaneLayoutItems({
115
115
  label: tf("Move Back to {layout}", { layout: moveBack.name }),
116
116
  detail: moveBack.original
117
117
  ? "Return the focused pane to the layout it came from"
118
- : "The layout it came from is gone, so it docks in this one instead",
118
+ : "The layout it came from is gone, so it goes into this one instead",
119
119
  category: "Focused Pane",
120
120
  kind: "action" as const,
121
121
  action: () => {
@@ -157,8 +157,8 @@ export function buildFocusedPaneLayoutItems({
157
157
  return {
158
158
  id: paneId,
159
159
  label: instance.title || pluginRegistry.panes.get(instance.paneId)?.name || instance.paneId,
160
- detail: isFloating ? "Floating window" : "Docked pane",
161
- description: isFloating ? "Floating window" : "Docked pane",
160
+ detail: isFloating ? "Floating window" : "In the layout",
161
+ description: isFloating ? "Floating window" : "In the layout",
162
162
  };
163
163
  });
164
164
  if (pickerOptions.length === 0) return;
@@ -14,6 +14,7 @@ import {
14
14
  QUICK_LOOK_TICKER_SEARCH_OPTIONS,
15
15
  tickerSearchFailureItems,
16
16
  venueDropdownResults,
17
+ withMajorCoinCandidate,
17
18
  type RootTickerReading,
18
19
  } from "../ticker-search/results";
19
20
  import { ProviderBusyError, SEARCH_BUSY_MESSAGE } from "../../../../sources/provider-errors";
@@ -78,19 +79,19 @@ function buildInstantAnswer(options: {
78
79
  const { query, fromIndex, cached, tickers, savedSymbolKeys, buildTickerSearchResultItems, localTickerSearchResultItems } = options;
79
80
  const localItems = () => localTickerSearchResultItems(query, { limit: 6 });
80
81
  if (cached) {
81
- return { query, items: mergeTickerSearchResultItems(query, buildTickerSearchResultItems(cached, query), localItems()), fromIndex: false };
82
+ return { query, items: mergeTickerSearchResultItems(query, buildTickerSearchResultItems(withMajorCoinCandidate(query, cached, tickers), query), localItems()), fromIndex: false };
82
83
  }
83
84
  if (!fromIndex) return null;
84
85
  const symbol = symbolSearchQuery(query);
85
86
  const known = knownListings(symbol);
86
87
  if (known.length === 0 && !savedSymbolKeys.has(listingIndexKey(symbol))) return null;
87
- const candidates = buildTickerSearchCandidates({
88
+ const candidates = withMajorCoinCandidate(symbol, buildTickerSearchCandidates({
88
89
  query: symbol,
89
90
  tickers,
90
91
  providerResults: known,
91
92
  totalLimit: LISTING_SEARCH_LIMIT,
92
93
  ...QUICK_LOOK_TICKER_SEARCH_OPTIONS,
93
- });
94
+ }), tickers);
94
95
  if (candidates.length === 0) return null;
95
96
  // Only the exact lines: looser matches are search's to rank.
96
97
  const items = mergeTickerSearchResultItems(query, buildTickerSearchResultItems(candidates, query), localItems())
@@ -264,7 +265,7 @@ export function useRootProviderSearch(options: {
264
265
  published = true;
265
266
  setRootProviderResults(mergeTickerSearchResultItems(
266
267
  searchQuery,
267
- buildTickerSearchResultItems(candidates, searchQuery),
268
+ buildTickerSearchResultItems(withMajorCoinCandidate(searchQuery, candidates, tickers), searchQuery),
268
269
  localTickerSearchResultItems(searchQuery, { limit: 6 }),
269
270
  ));
270
271
  setRootProviderResultsQuery(searchQuery);
@@ -1,9 +1,11 @@
1
1
  import type { TickerRecord } from "../../../../types/ticker";
2
2
  import {
3
+ buildTickerSearchCandidates,
3
4
  createLocalTickerSearchCandidates,
4
5
  findExactTickerSearchMatch,
5
6
  type TickerSearchCandidate,
6
7
  } from "../../../../tickers/search";
8
+ import { MAJOR_COIN_NAMES } from "../../../../utils/crypto-pair";
7
9
  import {
8
10
  assetClassMarketSymbol,
9
11
  instrumentClassCode,
@@ -83,9 +85,58 @@ export function isExactTickerResultMatch(item: ResultItem, rawQuery: string): bo
83
85
  || answersToIndexCode(item, query)
84
86
  // "brent" and "oil" are how a benchmark future is typed; its own symbol is BZ=F or CL=F.
85
87
  || answersToFutureName(item, query)
88
+ // BTC is how bitcoin is typed; its own symbol is BTC-USD.
89
+ || majorCoinPairSymbol(query) === parsePublicTickerKey(item.label.trim().toUpperCase()).symbol
86
90
  ));
87
91
  }
88
92
 
93
+ /** BTC-USD for BTC: the dollar pair of a coin whose bare ticker is how it is typed (`MAJOR_COIN_NAMES`). */
94
+ function majorCoinPairSymbol(query: string): string | null {
95
+ const base = query.trim().toUpperCase();
96
+ return MAJOR_COIN_NAMES.has(base) ? `${base}-USD` : null;
97
+ }
98
+
99
+ /**
100
+ * A major coin's bare ticker (BTC, ETH, SOL) is how the coin is asked for, but
101
+ * search lists only the funds and companies of those letters (BTC is
102
+ * Grayscale's Bitcoin Mini Trust), with no coin among them. The bar adds the
103
+ * coin's dollar pair, the row search sends for "bitcoin", as the CLI's quote
104
+ * points to it ("For bitcoin use BTC-USD"); a pair search sends far down its
105
+ * list (ETH-USD after every ETH listing) moves up the same way. It leads when
106
+ * the listing it would follow cannot be what was meant: one named for the coin,
107
+ * or one that stopped trading. A live company of those letters (LINK is
108
+ * Interlink Electronics) keeps the lead, with the coin right after it.
109
+ */
110
+ export function withMajorCoinCandidate(
111
+ query: string,
112
+ candidates: TickerSearchCandidate[],
113
+ tickers: ReadonlyMap<string, TickerRecord>,
114
+ ): TickerSearchCandidate[] {
115
+ const symbol = majorCoinPairSymbol(query);
116
+ const coin = MAJOR_COIN_NAMES.get(query.trim().toUpperCase());
117
+ if (!symbol || !coin) return candidates;
118
+ const isPair = (candidate: TickerSearchCandidate) => parsePublicTickerKey(candidate.symbol).symbol === symbol;
119
+ const sent = candidates.find(isPair);
120
+ const name = coin.replace(/\b[a-z]/g, (letter) => letter.toUpperCase());
121
+ const [pair] = sent ? [sent] : buildTickerSearchCandidates({
122
+ query: symbol,
123
+ tickers,
124
+ providerResults: [{ providerId: "gloomberb-cloud", symbol, name, exchange: "CCC", type: "CRYPTOCURRENCY", currency: "USD" }],
125
+ totalLimit: 1,
126
+ localLimit: 0,
127
+ });
128
+ if (!pair) return candidates;
129
+ const rest = candidates.filter((candidate) => !isPair(candidate));
130
+ const base = query.trim().toUpperCase();
131
+ const at = rest.findIndex((candidate) => parsePublicTickerKey(candidate.symbol).symbol === base);
132
+ if (at < 0) return [pair, ...rest];
133
+ const listing = rest[at]!;
134
+ const listingName = listing.result?.name ?? listing.ticker?.metadata.name ?? "";
135
+ const cannotBeIt = !!listing.result?.delisting || new RegExp(`\\b${coin}\\b`, "i").test(listingName);
136
+ const index = cannotBeIt ? at : at + 1;
137
+ return [...rest.slice(0, index), pair, ...rest.slice(index)];
138
+ }
139
+
89
140
  export function mergeTickerSearchResultItems(
90
141
  query: string,
91
142
  rankedItems: ResultItem[],