gloomberb 0.20.3 → 0.20.5
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.
- package/README.md +2 -0
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +144 -35
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/api-client/types/econ.ts +12 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +8 -2
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +154 -21
- package/src/cli/commands/news-search.ts +60 -10
- package/src/cli/commands/overview.ts +16 -1
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +20 -4
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/fx-forward.ts +25 -7
- package/src/cli/glossary.ts +19 -5
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index.ts +8 -8
- package/src/cli/known-gaps.ts +27 -1
- package/src/cli/listing-arg.ts +11 -1
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/pane-functions/function-help.ts +5 -5
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +20 -0
- package/src/components/onboarding/onboarding-wizard.tsx +16 -11
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/quote.ts +14 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +54 -13
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/market-data/market/dated-previous-close.ts +94 -15
- package/src/market-data/market/status.ts +17 -1
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/headless.ts +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +74 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +14 -4
- package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +4 -3
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +11 -5
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
- package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
- package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/plugins/installer.ts +45 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +56 -19
- package/src/remote/schema.ts +22 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +44 -15
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +37 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/resolve.ts +2 -2
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/financials.ts +1 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +116 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +243 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +22 -9
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -113,6 +113,10 @@ function parseDefaults(texts: readonly string[]): KeyChord[] {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const DEFAULT_CHORDS = new Map(KEYBINDING_ACTIONS.map((action) => [action.id, parseDefaults(action.defaults)]));
|
|
116
|
+
const TERMINAL_DEFAULT_CHORDS = new Map(KEYBINDING_ACTIONS.map((action) => [
|
|
117
|
+
action.id,
|
|
118
|
+
[...DEFAULT_CHORDS.get(action.id)!, ...parseDefaults(action.terminalDefaults ?? [])],
|
|
119
|
+
]));
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
122
|
* Two chords fire on the same keypress somewhere: identical, or one says
|
|
@@ -179,11 +183,13 @@ export function resolveKeybindings(
|
|
|
179
183
|
const hostActions = KEYBINDING_ACTIONS.filter((def) => (
|
|
180
184
|
options.host === "desktop" ? !def.terminalOnly : options.host === "terminal" ? !def.desktopOnly : true
|
|
181
185
|
));
|
|
186
|
+
// With no host the table is every host's at once (the CLI), so it has the terminal's chords too.
|
|
187
|
+
const defaults = options.host === "desktop" ? DEFAULT_CHORDS : TERMINAL_DEFAULT_CHORDS;
|
|
182
188
|
const actions: ResolvedKeybindingAction[] = hostActions.map((def) => resolveAction(
|
|
183
189
|
def,
|
|
184
190
|
undefined,
|
|
185
191
|
def.id,
|
|
186
|
-
|
|
192
|
+
defaults.get(def.id)!,
|
|
187
193
|
overrides,
|
|
188
194
|
issues,
|
|
189
195
|
));
|
|
@@ -229,12 +235,18 @@ export function resolveKeybindings(
|
|
|
229
235
|
|
|
230
236
|
/**
|
|
231
237
|
* The first action or command whose chord the event is, in table order. Actions
|
|
232
|
-
* win over commands, so a stray command binding never shadows a core key.
|
|
238
|
+
* win over commands, so a stray command binding never shadows a core key. The
|
|
239
|
+
* one exception is a command on a single key of the 1-9 family (`Alt+1`):
|
|
240
|
+
* that key was bound by hand, the family by default, so the command keeps it.
|
|
233
241
|
*/
|
|
234
242
|
export function matchKeybinding(resolved: ResolvedKeybindings, event: KeyChordEventLike): KeybindingMatch | null {
|
|
235
243
|
for (const action of resolved.actions) {
|
|
236
244
|
for (const chord of action.chords) {
|
|
237
245
|
if (!matchesKeyChord(chord, event)) continue;
|
|
246
|
+
const command = chord.key === "digit"
|
|
247
|
+
? resolved.commands.find((entry) => matchesKeyChord(entry.chord, event))
|
|
248
|
+
: undefined;
|
|
249
|
+
if (command) return { kind: "command", command };
|
|
238
250
|
return {
|
|
239
251
|
kind: "action",
|
|
240
252
|
id: action.id,
|
|
@@ -255,11 +267,18 @@ export function matchKeybinding(resolved: ResolvedKeybindings, event: KeyChordEv
|
|
|
255
267
|
* switcher's 1-9 included. Capture refuses such a chord, so a new binding never
|
|
256
268
|
* leaves a core key (the command bar, close pane, quit) dead. Null when no
|
|
257
269
|
* built-in action has it; a plugin shortcut or a bound command does not count.
|
|
270
|
+
* A command may take one digit of the 1-9 family (`Alt+1`): it wins that key
|
|
271
|
+
* (matchKeybinding), and the other eight still switch layouts.
|
|
258
272
|
*/
|
|
259
|
-
export function coreActionOnChord(
|
|
273
|
+
export function coreActionOnChord(
|
|
274
|
+
resolved: ResolvedKeybindings,
|
|
275
|
+
chord: KeyChord,
|
|
276
|
+
exceptId?: string,
|
|
277
|
+
{ command = false }: { command?: boolean } = {},
|
|
278
|
+
): ResolvedKeybindingAction | null {
|
|
260
279
|
return resolved.actions.find((action) => action.def && action.id !== exceptId
|
|
261
280
|
&& action.chords.some((existing) => keyChordsOverlap(existing, chord)
|
|
262
|
-
|| (existing.key === "digit" && /^[1-9]$/.test(chord.key) && keyChordsOverlap({ ...existing, key: chord.key }, chord))))
|
|
281
|
+
|| (!command && existing.key === "digit" && /^[1-9]$/.test(chord.key) && keyChordsOverlap({ ...existing, key: chord.key }, chord))))
|
|
263
282
|
?? null;
|
|
264
283
|
}
|
|
265
284
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import type { KeyChord } from "./chord";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether the terminal reports Control with any key (the kitty keyboard
|
|
6
|
+
* protocol), as the terminal host learns it from the terminal's answers at
|
|
7
|
+
* start: true when it does, false when the terminal answered without it, null
|
|
8
|
+
* before it answers and outside a terminal. Without the protocol Control
|
|
9
|
+
* never reaches a digit: Ctrl+1 arrives as 1, Ctrl+3 as Esc. Alt does, as Esc
|
|
10
|
+
* then the digit.
|
|
11
|
+
*/
|
|
12
|
+
let reportsControlKeys: boolean | null = null;
|
|
13
|
+
const listeners = new Set<() => void>();
|
|
14
|
+
|
|
15
|
+
export function setTerminalReportsControlKeys(value: boolean | null): void {
|
|
16
|
+
if (value === reportsControlKeys) return;
|
|
17
|
+
reportsControlKeys = value;
|
|
18
|
+
for (const listener of listeners) listener();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function subscribe(listener: () => void): () => void {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useTerminalReportsControlKeys(): boolean | null {
|
|
29
|
+
return useSyncExternalStore(subscribe, () => reportsControlKeys, () => null);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Whether a terminal without the kitty protocol can send the chord: not Control with a digit. */
|
|
33
|
+
export function legacyTerminalSends(chord: KeyChord): boolean {
|
|
34
|
+
return !((chord.ctrl || chord.primary) && (chord.key === "digit" || /^[0-9]$/.test(chord.key)));
|
|
35
|
+
}
|
|
@@ -106,8 +106,8 @@ export function useAppPaneRuntime({
|
|
|
106
106
|
));
|
|
107
107
|
}, [dispatch, stateRef]);
|
|
108
108
|
|
|
109
|
-
const activatePane = useCallback((paneId: string) => {
|
|
110
|
-
dispatch({ type: "FOCUS_PANE", paneId });
|
|
109
|
+
const activatePane = useCallback((paneId: string, options?: { trackTicker?: boolean }) => {
|
|
110
|
+
dispatch({ type: "FOCUS_PANE", paneId, ...options });
|
|
111
111
|
}, [dispatch]);
|
|
112
112
|
|
|
113
113
|
const {
|
|
@@ -6,34 +6,46 @@ import {
|
|
|
6
6
|
getDockedPaneIds,
|
|
7
7
|
isPaneInLayout,
|
|
8
8
|
isPaneDocked,
|
|
9
|
+
removePane,
|
|
9
10
|
} from "../../layout/pane-manager";
|
|
10
11
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
11
12
|
import { PluginOffError, notifyPluginOff } from "../../plugins/plugin-off";
|
|
12
13
|
import { findFixedTickerPaneForSymbol } from "../../layout/ticker-navigation";
|
|
13
14
|
import type { AppAction, AppState } from "../../state/app/context";
|
|
14
|
-
import { TICKER_RESEARCH_PANE_ID, normalizePaneId } from "../../types/config";
|
|
15
|
+
import { findPaneInstance, TICKER_RESEARCH_PANE_ID, normalizePaneId } from "../../types/config";
|
|
15
16
|
import type {
|
|
16
17
|
LayoutConfig,
|
|
17
18
|
PaneBinding,
|
|
18
19
|
PaneInstanceConfig,
|
|
19
20
|
} from "../../types/config";
|
|
20
21
|
import type { DataProvider } from "../../types/data-provider";
|
|
21
|
-
import type { PinTickerOptions } from "../../types/plugin";
|
|
22
|
+
import type { PaneDef, PinTickerOptions } from "../../types/plugin";
|
|
23
|
+
import type { BrokerContractRef } from "../../types/instrument";
|
|
22
24
|
import {
|
|
23
25
|
resolveTickerOpenTarget,
|
|
24
26
|
tickerOpenFailureMessage,
|
|
25
27
|
type TickerOpenTarget,
|
|
26
28
|
} from "../../tickers/open-target";
|
|
27
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
findExactTickerSearchMatch,
|
|
31
|
+
normalizeTickerInput,
|
|
32
|
+
savedTickerForQuery,
|
|
33
|
+
upsertTickerFromSearchResult,
|
|
34
|
+
} from "../../tickers/search";
|
|
28
35
|
import { offerTickerListings, publishTickerOpenTarget as publishOpenTarget } from "./ticker-open-target";
|
|
29
36
|
import { parsePublicTickerKey, publicTickerKey } from "../../utils/exchanges";
|
|
30
37
|
import { attentionActionForPane, captureAttentionAction } from "../../telemetry/attention-counts";
|
|
31
38
|
import { tickerHasListingSuffix } from "../../sources/listing-symbols";
|
|
32
39
|
import { instrumentFromTicker } from "../../market-data/request-types";
|
|
33
40
|
import { tickerInstrumentLabel } from "../../tickers/instrument-label";
|
|
41
|
+
import { markTickerPaneOpening } from "../../state/opening-ticker-panes";
|
|
42
|
+
import { stableStringify } from "../../utils/hash";
|
|
43
|
+
|
|
44
|
+
type LayoutHistoryEntry = AppState["layoutHistory"][number];
|
|
34
45
|
|
|
35
46
|
interface UseAppTickerOpenRuntimeOptions {
|
|
36
|
-
|
|
47
|
+
/** `trackTicker: false` keeps a pane still looking its ticker up out of the recent tickers. */
|
|
48
|
+
activatePane: (paneId: string, options?: { trackTicker?: boolean }) => void;
|
|
37
49
|
buildPaneInstance: (paneType: string, options?: {
|
|
38
50
|
title?: string;
|
|
39
51
|
binding?: PaneBinding;
|
|
@@ -44,12 +56,89 @@ interface UseAppTickerOpenRuntimeOptions {
|
|
|
44
56
|
dataProvider: DataProvider;
|
|
45
57
|
dispatch: Dispatch<AppAction>;
|
|
46
58
|
focusVisiblePane: (paneId: string, layout?: LayoutConfig) => void;
|
|
47
|
-
persistLayout: (layout: LayoutConfig, options?: { pushHistory?: boolean }) => void;
|
|
59
|
+
persistLayout: (layout: LayoutConfig, options?: { pushHistory?: boolean; focusedPaneId?: string | null }) => void;
|
|
48
60
|
pluginRegistry: PluginRegistry;
|
|
49
61
|
stateRef: { current: AppState };
|
|
50
62
|
tickerRepository: AppTickerRepositoryPort;
|
|
51
63
|
}
|
|
52
64
|
|
|
65
|
+
/** A research pane opened ahead of the lookup that finds its ticker (`openPaneAhead`). */
|
|
66
|
+
interface PaneAhead {
|
|
67
|
+
instanceId: string;
|
|
68
|
+
/** The key it is bound to until the lookup settles it. */
|
|
69
|
+
symbol: string;
|
|
70
|
+
/** The pane focused before it opened, which focus goes back to when nothing opens. */
|
|
71
|
+
sourcePaneId: string | null;
|
|
72
|
+
/** The layout it opened in, its undo history before the open, and that history as the open left it. */
|
|
73
|
+
layoutIndex: number;
|
|
74
|
+
historyBefore: LayoutHistoryEntry;
|
|
75
|
+
historyOpened: LayoutHistoryEntry | undefined;
|
|
76
|
+
stopOpening: () => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The binding a resolved target opens with, and its broker contract (`null` for the public listing). */
|
|
80
|
+
function targetPaneBinding(target: TickerOpenTarget, options?: PinTickerOptions): {
|
|
81
|
+
binding: PaneBinding;
|
|
82
|
+
instrument: BrokerContractRef | null | undefined;
|
|
83
|
+
} {
|
|
84
|
+
const instrument = options?.instrument !== undefined ? options.instrument
|
|
85
|
+
: target.instrument !== undefined ? target.instrument : instrumentFromTicker(target.ticker)?.instrument ?? undefined;
|
|
86
|
+
const listing = options?.listing ?? target.listing;
|
|
87
|
+
return {
|
|
88
|
+
binding: { kind: "fixed", symbol: target.symbol, ...(instrument !== undefined ? { instrument } : {}), ...(listing ? { listing } : {}) },
|
|
89
|
+
instrument,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The pane of `paneType` already showing the target in `layout`, which an
|
|
95
|
+
* open brings forward instead of adding another, and whether its binding
|
|
96
|
+
* stays as it is.
|
|
97
|
+
*/
|
|
98
|
+
function findTargetPane(
|
|
99
|
+
state: AppState,
|
|
100
|
+
layout: LayoutConfig,
|
|
101
|
+
paneType: string,
|
|
102
|
+
target: TickerOpenTarget,
|
|
103
|
+
instrument: BrokerContractRef | null | undefined,
|
|
104
|
+
options?: PinTickerOptions,
|
|
105
|
+
typed?: string,
|
|
106
|
+
): { existing: PaneInstanceConfig | null; keepBinding: boolean } {
|
|
107
|
+
if (options?.forceNewPane) return { existing: null, keepBinding: false };
|
|
108
|
+
const symbol = target.symbol;
|
|
109
|
+
let existing = findFixedTickerPaneForSymbol(layout, paneType, symbol, instrument);
|
|
110
|
+
// A pane bound to the key as typed (the web terminal's first pane for ?ticker=7203:TSE) is the one the
|
|
111
|
+
// resolved listing (7203:JPX) settles.
|
|
112
|
+
const typedKey = typed?.trim().toUpperCase();
|
|
113
|
+
if (!existing && typedKey && typedKey !== symbol) {
|
|
114
|
+
existing = findFixedTickerPaneForSymbol(layout, paneType, typedKey, instrument);
|
|
115
|
+
}
|
|
116
|
+
// Without a broker route, the public listing and an unnamed route are the same security: a link that names
|
|
117
|
+
// neither still finds the DES the command bar opened on the public listing, and leaves its binding as it is.
|
|
118
|
+
let keepBinding = false;
|
|
119
|
+
if (!existing && !instrument && !target.ticker.metadata.broker_contracts?.length) {
|
|
120
|
+
existing = findFixedTickerPaneForSymbol(layout, paneType, symbol, instrument === null ? undefined : null);
|
|
121
|
+
keepBinding = !!existing && instrument === undefined;
|
|
122
|
+
}
|
|
123
|
+
if (!existing && !instrument && (parsePublicTickerKey(symbol).exchange || tickerHasListingSuffix(symbol))) {
|
|
124
|
+
existing = layout.instances.find((instance) => {
|
|
125
|
+
if (instance.paneId !== paneType || instance.binding?.kind !== "fixed" || instance.binding.instrument || !isPaneInLayout(layout, instance.instanceId)) return false;
|
|
126
|
+
const ticker = state.tickers.get(instance.binding.symbol);
|
|
127
|
+
return !!ticker?.metadata.exchange && !!findExactTickerSearchMatch([
|
|
128
|
+
{ label: instance.binding.symbol, right: ticker.metadata.exchange },
|
|
129
|
+
], symbol);
|
|
130
|
+
}) ?? null;
|
|
131
|
+
}
|
|
132
|
+
return { existing, keepBinding };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Whether a pane opened ahead is still in the layout on its key: not closed, nor pointed at another ticker. */
|
|
136
|
+
function isPaneAheadInPlace(layout: LayoutConfig, ahead: PaneAhead): boolean {
|
|
137
|
+
const instance = findPaneInstance(layout, ahead.instanceId);
|
|
138
|
+
return !!instance && isPaneInLayout(layout, ahead.instanceId)
|
|
139
|
+
&& instance.binding?.kind === "fixed" && instance.binding.symbol === ahead.symbol;
|
|
140
|
+
}
|
|
141
|
+
|
|
53
142
|
export function useAppTickerOpenRuntime({
|
|
54
143
|
activatePane,
|
|
55
144
|
buildPaneInstance,
|
|
@@ -102,6 +191,47 @@ export function useAppTickerOpenRuntime({
|
|
|
102
191
|
return true;
|
|
103
192
|
}, [pluginRegistry, stateRef]);
|
|
104
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Adds a new pane of `paneType` bound to `binding`, floating or docked as
|
|
196
|
+
* asked, and focuses it. `opening` runs with its id before it is placed, for
|
|
197
|
+
* a pane still looking its ticker up, which stays out of the recent tickers.
|
|
198
|
+
*/
|
|
199
|
+
const addTickerPane = useCallback((
|
|
200
|
+
paneType: string,
|
|
201
|
+
paneDef: PaneDef,
|
|
202
|
+
binding: PaneBinding,
|
|
203
|
+
title: string,
|
|
204
|
+
options?: PinTickerOptions,
|
|
205
|
+
opening?: (instanceId: string) => void,
|
|
206
|
+
): string | null => {
|
|
207
|
+
const instance = buildPaneInstance(paneType, { title, binding });
|
|
208
|
+
if (!instance) return null;
|
|
209
|
+
opening?.(instance.instanceId);
|
|
210
|
+
|
|
211
|
+
const currentState = stateRef.current;
|
|
212
|
+
const currentLayout = currentState.config.layout;
|
|
213
|
+
const { width, height } = pluginRegistry.getTermSize();
|
|
214
|
+
const shouldFloat = options?.floating ?? true;
|
|
215
|
+
const nextLayout = shouldFloat
|
|
216
|
+
? addPaneFloating(currentLayout, instance, width, height, paneDef, { focusedPaneId: currentState.focusedPaneId })
|
|
217
|
+
: addPaneToLayout(
|
|
218
|
+
currentLayout,
|
|
219
|
+
instance,
|
|
220
|
+
{
|
|
221
|
+
relativeTo: currentState.focusedPaneId && isPaneDocked(currentLayout, currentState.focusedPaneId)
|
|
222
|
+
? currentState.focusedPaneId
|
|
223
|
+
: (getDockedPaneIds(currentLayout).at(-1) ?? instance.instanceId),
|
|
224
|
+
position: "right",
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
persistLayout(nextLayout);
|
|
228
|
+
if (paneType === TICKER_RESEARCH_PANE_ID && options?.tabId) {
|
|
229
|
+
dispatch({ type: "UPDATE_PANE_STATE", paneId: instance.instanceId, patch: { ...options.tabState, activeTabId: options.tabId } });
|
|
230
|
+
}
|
|
231
|
+
activatePane(instance.instanceId, opening ? { trackTicker: false } : undefined);
|
|
232
|
+
return instance.instanceId;
|
|
233
|
+
}, [activatePane, buildPaneInstance, dispatch, persistLayout, pluginRegistry, stateRef]);
|
|
234
|
+
|
|
105
235
|
const placePinnedTickerTarget = useCallback((target: TickerOpenTarget, options?: PinTickerOptions, typed?: string) => {
|
|
106
236
|
const paneType = normalizePaneId(options?.paneType ?? TICKER_RESEARCH_PANE_ID);
|
|
107
237
|
const paneDef = pluginRegistry.panes.get(paneType);
|
|
@@ -110,37 +240,10 @@ export function useAppTickerOpenRuntime({
|
|
|
110
240
|
|
|
111
241
|
publishTickerOpenTarget(target);
|
|
112
242
|
const symbol = target.symbol;
|
|
113
|
-
const
|
|
114
|
-
: target.instrument !== undefined ? target.instrument : instrumentFromTicker(target.ticker)?.instrument ?? undefined;
|
|
115
|
-
const listing = options?.listing ?? target.listing;
|
|
116
|
-
const binding = { kind: "fixed" as const, symbol, ...(instrument !== undefined ? { instrument } : {}), ...(listing ? { listing } : {}) };
|
|
243
|
+
const { binding, instrument } = targetPaneBinding(target, options);
|
|
117
244
|
const currentState = stateRef.current;
|
|
118
245
|
const currentLayout = currentState.config.layout;
|
|
119
|
-
|
|
120
|
-
? null
|
|
121
|
-
: findFixedTickerPaneForSymbol(currentLayout, paneType, symbol, instrument);
|
|
122
|
-
// A pane bound to the key as typed (the web terminal's first pane for ?ticker=7203:TSE) is the one the
|
|
123
|
-
// resolved listing (7203:JPX) settles.
|
|
124
|
-
const typedKey = typed?.trim().toUpperCase();
|
|
125
|
-
if (!options?.forceNewPane && !existing && typedKey && typedKey !== symbol) {
|
|
126
|
-
existing = findFixedTickerPaneForSymbol(currentLayout, paneType, typedKey, instrument);
|
|
127
|
-
}
|
|
128
|
-
// Without a broker route, the public listing and an unnamed route are the same security: a link that names
|
|
129
|
-
// neither still finds the DES the command bar opened on the public listing, and leaves its binding as it is.
|
|
130
|
-
let keepBinding = false;
|
|
131
|
-
if (!options?.forceNewPane && !existing && !instrument && !target.ticker.metadata.broker_contracts?.length) {
|
|
132
|
-
existing = findFixedTickerPaneForSymbol(currentLayout, paneType, symbol, instrument === null ? undefined : null);
|
|
133
|
-
keepBinding = !!existing && instrument === undefined;
|
|
134
|
-
}
|
|
135
|
-
if (!options?.forceNewPane && !existing && !instrument && (parsePublicTickerKey(symbol).exchange || tickerHasListingSuffix(symbol))) {
|
|
136
|
-
existing = currentLayout.instances.find((instance) => {
|
|
137
|
-
if (instance.paneId !== paneType || instance.binding?.kind !== "fixed" || instance.binding.instrument || !isPaneInLayout(currentLayout, instance.instanceId)) return false;
|
|
138
|
-
const ticker = currentState.tickers.get(instance.binding.symbol);
|
|
139
|
-
return !!ticker?.metadata.exchange && !!findExactTickerSearchMatch([
|
|
140
|
-
{ label: instance.binding.symbol, right: ticker.metadata.exchange },
|
|
141
|
-
], symbol);
|
|
142
|
-
}) ?? null;
|
|
143
|
-
}
|
|
246
|
+
const { existing, keepBinding } = findTargetPane(currentState, currentLayout, paneType, target, instrument, options, typed);
|
|
144
247
|
if (existing) {
|
|
145
248
|
// A reload can qualify a previously bare saved symbol. Reuse only the
|
|
146
249
|
// verified same listing, retaining its pane identity and its followers.
|
|
@@ -164,34 +267,9 @@ export function useAppTickerOpenRuntime({
|
|
|
164
267
|
return;
|
|
165
268
|
}
|
|
166
269
|
|
|
167
|
-
|
|
168
|
-
title: tickerInstrumentLabel(symbol, instrument),
|
|
169
|
-
binding,
|
|
170
|
-
});
|
|
171
|
-
if (!instance) return;
|
|
172
|
-
|
|
173
|
-
const { width, height } = pluginRegistry.getTermSize();
|
|
174
|
-
const shouldFloat = options?.floating ?? true;
|
|
175
|
-
const nextLayout = shouldFloat
|
|
176
|
-
? addPaneFloating(currentLayout, instance, width, height, paneDef, { focusedPaneId: currentState.focusedPaneId })
|
|
177
|
-
: addPaneToLayout(
|
|
178
|
-
currentLayout,
|
|
179
|
-
instance,
|
|
180
|
-
{
|
|
181
|
-
relativeTo: currentState.focusedPaneId && isPaneDocked(currentLayout, currentState.focusedPaneId)
|
|
182
|
-
? currentState.focusedPaneId
|
|
183
|
-
: (getDockedPaneIds(currentLayout).at(-1) ?? instance.instanceId),
|
|
184
|
-
position: "right",
|
|
185
|
-
},
|
|
186
|
-
);
|
|
187
|
-
persistLayout(nextLayout);
|
|
188
|
-
if (paneType === TICKER_RESEARCH_PANE_ID && options?.tabId) {
|
|
189
|
-
dispatch({ type: "UPDATE_PANE_STATE", paneId: instance.instanceId, patch: { ...options.tabState, activeTabId: options.tabId } });
|
|
190
|
-
}
|
|
191
|
-
activatePane(instance.instanceId);
|
|
270
|
+
addTickerPane(paneType, paneDef, binding, tickerInstrumentLabel(symbol, instrument), options);
|
|
192
271
|
}, [
|
|
193
|
-
|
|
194
|
-
buildPaneInstance,
|
|
272
|
+
addTickerPane,
|
|
195
273
|
dispatch,
|
|
196
274
|
focusVisiblePane,
|
|
197
275
|
persistLayout,
|
|
@@ -201,6 +279,116 @@ export function useAppTickerOpenRuntime({
|
|
|
201
279
|
stateRef,
|
|
202
280
|
]);
|
|
203
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Opens the research pane of a ticker the app does not hold yet before the
|
|
284
|
+
* network lookup that finds it (search and the listing's quote, seconds on
|
|
285
|
+
* a slow connection), bound to the key as given and marked as opening; the
|
|
286
|
+
* lookup settles it (`settlePaneAhead`). Null when the open waits for the
|
|
287
|
+
* lookup instead: another pane type, a broker contract, a ticker the app
|
|
288
|
+
* holds however the key spells it (it resolves here, at once), or a
|
|
289
|
+
* research pane already on the key.
|
|
290
|
+
*/
|
|
291
|
+
const openPaneAhead = useCallback((rawSymbol: string, options?: PinTickerOptions): PaneAhead | null => {
|
|
292
|
+
const paneType = normalizePaneId(options?.paneType ?? TICKER_RESEARCH_PANE_ID);
|
|
293
|
+
const paneDef = pluginRegistry.panes.get(paneType);
|
|
294
|
+
const symbol = normalizeTickerInput(null, rawSymbol);
|
|
295
|
+
if (paneType !== TICKER_RESEARCH_PANE_ID || !paneDef || !symbol || options?.instrument) return null;
|
|
296
|
+
const state = stateRef.current;
|
|
297
|
+
const layout = state.config.layout;
|
|
298
|
+
if (savedTickerForQuery(rawSymbol, state.tickers)) return null;
|
|
299
|
+
if (!options?.forceNewPane && layout.instances.some((instance) => instance.paneId === paneType
|
|
300
|
+
&& instance.binding?.kind === "fixed" && instance.binding.symbol === symbol && isPaneInLayout(layout, instance.instanceId))) return null;
|
|
301
|
+
const binding: PaneBinding = {
|
|
302
|
+
kind: "fixed",
|
|
303
|
+
symbol,
|
|
304
|
+
...(options?.instrument !== undefined ? { instrument: options.instrument } : {}),
|
|
305
|
+
...(options?.listing ? { listing: options.listing } : {}),
|
|
306
|
+
};
|
|
307
|
+
const sourcePaneId = state.focusedPaneId;
|
|
308
|
+
const layoutIndex = state.config.activeLayoutIndex;
|
|
309
|
+
const historyBefore = state.layoutHistory[layoutIndex] ?? { past: [], future: [] };
|
|
310
|
+
// Marked before it is placed, so its first frame already says it is loading.
|
|
311
|
+
let stopOpening = () => {};
|
|
312
|
+
const instanceId = addTickerPane(paneType, paneDef, binding, tickerInstrumentLabel(symbol, options?.instrument), options, (id) => {
|
|
313
|
+
stopOpening = markTickerPaneOpening(id);
|
|
314
|
+
});
|
|
315
|
+
if (!instanceId) return null;
|
|
316
|
+
const historyOpened = stateRef.current.layoutHistory[layoutIndex];
|
|
317
|
+
return { instanceId, symbol, sourcePaneId, layoutIndex, historyBefore, historyOpened, stopOpening };
|
|
318
|
+
}, [addTickerPane, pluginRegistry, stateRef]);
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Settles a pane opened ahead once the lookup answers: it is bound to the
|
|
322
|
+
* listing found, or gives way to a pane already showing that listing, or
|
|
323
|
+
* closes when nothing opens (no listing, or a choice of listings the
|
|
324
|
+
* command bar now offers), focus going back where it was. A pane closed or
|
|
325
|
+
* pointed at another ticker meanwhile is left alone. The undo history and
|
|
326
|
+
* the recent tickers end as if the open had waited for the lookup. True
|
|
327
|
+
* when the open landed in a pane.
|
|
328
|
+
*/
|
|
329
|
+
const settlePaneAhead = useCallback((
|
|
330
|
+
ahead: PaneAhead,
|
|
331
|
+
target: TickerOpenTarget | null,
|
|
332
|
+
options: PinTickerOptions | undefined,
|
|
333
|
+
typed: string,
|
|
334
|
+
): boolean => {
|
|
335
|
+
if (target) publishTickerOpenTarget(target);
|
|
336
|
+
const state = stateRef.current;
|
|
337
|
+
const layout = state.config.layout;
|
|
338
|
+
const inPlace = isPaneAheadInPlace(layout, ahead);
|
|
339
|
+
const focusedHere = inPlace && state.focusedPaneId === ahead.instanceId;
|
|
340
|
+
const without = removePane(layout, ahead.instanceId);
|
|
341
|
+
const resolved = target ? targetPaneBinding(target, options) : null;
|
|
342
|
+
const existing = inPlace && target && resolved
|
|
343
|
+
? findTargetPane(state, without, TICKER_RESEARCH_PANE_ID, target, resolved.instrument, options, typed).existing
|
|
344
|
+
: null;
|
|
345
|
+
const instance = findPaneInstance(layout, ahead.instanceId);
|
|
346
|
+
const settled = target && resolved && !existing ? {
|
|
347
|
+
binding: resolved.binding,
|
|
348
|
+
title: inPlace && instance?.title && instance.title !== tickerInstrumentLabel(ahead.symbol, options?.instrument)
|
|
349
|
+
? instance.title
|
|
350
|
+
: tickerInstrumentLabel(target.symbol, resolved.instrument),
|
|
351
|
+
} : null;
|
|
352
|
+
// The steps taken while it loaded hold it on its key. An open that came to nothing leaves
|
|
353
|
+
// no step, and the history it found comes back whole when nothing was done since.
|
|
354
|
+
const settleHistory = () => {
|
|
355
|
+
if (stateRef.current.config.activeLayoutIndex !== ahead.layoutIndex) return;
|
|
356
|
+
const untouched = !settled && state.layoutHistory[ahead.layoutIndex] === ahead.historyOpened;
|
|
357
|
+
dispatch({
|
|
358
|
+
type: "SETTLE_OPENING_PANE",
|
|
359
|
+
settlement: { paneId: ahead.instanceId, symbol: ahead.symbol, settled, ...(untouched ? { before: ahead.historyBefore } : {}) },
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
if (!inPlace || !instance) {
|
|
363
|
+
settleHistory();
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
if (!settled) {
|
|
367
|
+
if (existing) {
|
|
368
|
+
persistLayout(without, { pushHistory: false });
|
|
369
|
+
if (options?.tabId) {
|
|
370
|
+
dispatch({ type: "UPDATE_PANE_STATE", paneId: existing.instanceId, patch: { ...options.tabState, activeTabId: options.tabId } });
|
|
371
|
+
}
|
|
372
|
+
if (focusedHere) focusVisiblePane(existing.instanceId, without);
|
|
373
|
+
} else {
|
|
374
|
+
const backTo = ahead.sourcePaneId && isPaneInLayout(without, ahead.sourcePaneId) ? ahead.sourcePaneId : null;
|
|
375
|
+
persistLayout(without, { pushHistory: false, ...(focusedHere ? { focusedPaneId: backTo } : {}) });
|
|
376
|
+
}
|
|
377
|
+
settleHistory();
|
|
378
|
+
return !!existing;
|
|
379
|
+
}
|
|
380
|
+
if (settled.title !== instance.title || stableStringify(instance.binding) !== stableStringify(settled.binding)) {
|
|
381
|
+
persistLayout({
|
|
382
|
+
...layout,
|
|
383
|
+
instances: layout.instances.map((pane) => pane.instanceId === ahead.instanceId ? { ...pane, ...settled } : pane),
|
|
384
|
+
}, { pushHistory: false });
|
|
385
|
+
}
|
|
386
|
+
settleHistory();
|
|
387
|
+
// Focusing it left its key out of the recent tickers; the listing found goes in.
|
|
388
|
+
if (focusedHere && target) dispatch({ type: "TRACK_TICKER", symbol: target.symbol });
|
|
389
|
+
return true;
|
|
390
|
+
}, [dispatch, focusVisiblePane, persistLayout, publishTickerOpenTarget, stateRef]);
|
|
391
|
+
|
|
204
392
|
const openPinnedTicker = useCallback(async (rawSymbol: string, options?: PinTickerOptions) => {
|
|
205
393
|
// Before resolving, so a refused open adds no ticker either.
|
|
206
394
|
if (refuseWhileOwnerOff(rawSymbol, options, () => { void openPinnedTicker(rawSymbol, options); })) return;
|
|
@@ -218,16 +406,35 @@ export function useAppTickerOpenRuntime({
|
|
|
218
406
|
});
|
|
219
407
|
}
|
|
220
408
|
const selectedTicker = selected?.ticker;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
409
|
+
let target: TickerOpenTarget | null;
|
|
410
|
+
let placed = true;
|
|
411
|
+
if (selectedTicker) {
|
|
412
|
+
target = { symbol: selectedTicker.metadata.ticker, ticker: selectedTicker, created: selected!.created, instrument: options?.instrument, listing: options?.listing };
|
|
413
|
+
placePinnedTickerTarget(target, options, rawSymbol);
|
|
414
|
+
} else {
|
|
415
|
+
// The pane of a ticker found over the network shows now, not once the lookup answers.
|
|
416
|
+
const ahead = openPaneAhead(rawSymbol, options);
|
|
417
|
+
if (!ahead) {
|
|
418
|
+
target = await resolveOpenTickerTarget(rawSymbol, options?.instrument === null);
|
|
419
|
+
if (target) placePinnedTickerTarget(target, options, rawSymbol);
|
|
420
|
+
} else {
|
|
421
|
+
// Cleared once it settles, so no frame between says no ticker is selected.
|
|
422
|
+
try {
|
|
423
|
+
// A failure, or the choice of listings, is said only while the pane still waits: one closed was given up.
|
|
424
|
+
target = await resolveOpenTickerTarget(rawSymbol, options?.instrument === null,
|
|
425
|
+
() => isPaneAheadInPlace(stateRef.current.config.layout, ahead));
|
|
426
|
+
placed = settlePaneAhead(ahead, target, options, rawSymbol);
|
|
427
|
+
} finally {
|
|
428
|
+
ahead.stopOpening();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (!target || !placed) return;
|
|
226
433
|
const action = attentionActionForPane(options?.paneType ?? TICKER_RESEARCH_PANE_ID);
|
|
227
434
|
if (action && pluginRegistry.panes.has(options?.paneType ?? TICKER_RESEARCH_PANE_ID)) {
|
|
228
435
|
recordAttention(publicTickerKey(target.symbol, target.listing?.exchange ?? target.ticker.metadata.exchange), action);
|
|
229
436
|
}
|
|
230
|
-
}, [placePinnedTickerTarget, pluginRegistry, refuseWhileOwnerOff, resolveOpenTickerTarget, tickerRepository]);
|
|
437
|
+
}, [openPaneAhead, placePinnedTickerTarget, pluginRegistry, refuseWhileOwnerOff, resolveOpenTickerTarget, settlePaneAhead, stateRef, tickerRepository]);
|
|
231
438
|
|
|
232
439
|
return {
|
|
233
440
|
openPinnedTicker,
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"src/components/ui/pane-link-chip.tsx": {
|
|
44
44
|
"literals": {
|
|
45
45
|
"font weight": 1,
|
|
46
|
-
"radius":
|
|
46
|
+
"radius": 2,
|
|
47
47
|
"spacing": 2
|
|
48
48
|
},
|
|
49
49
|
"why": "Chat's pane-link chip, moved here unchanged so Ask Gloom's sources draw the same chip; its literals were allowed in chat (its own owner and conventions), and moving it onto the tokens would change every chip in chat."
|
|
@@ -20,6 +20,26 @@ import type {
|
|
|
20
20
|
} from "./types";
|
|
21
21
|
|
|
22
22
|
export const CHART_SERIES_CAPABILITY_KIND = "chart-series";
|
|
23
|
+
|
|
24
|
+
/** Words that ask for a government bond yield. */
|
|
25
|
+
const BOND_YIELD_WORDS = /\b(?:yield|yields|bond|bonds|treasury|treasuries|gilt|gilts|bund|bunds|govt|sovereign|mbono|bono|cetes|prefixado|jgb)\b/i;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What a chart says of a `CAP:` series nothing answers to, whether no source
|
|
29
|
+
* has its first word or its source has no series by the rest: that it is not
|
|
30
|
+
* covered, and where the nearest series are, never that a plugin or provider
|
|
31
|
+
* should be enabled (none would chart it). A government yield the curves do
|
|
32
|
+
* not carry (`CAP:bond-yield:za-10y`) points at the catalog of those they do
|
|
33
|
+
* and the world grid of 2- and 10-year yields.
|
|
34
|
+
*/
|
|
35
|
+
export function uncoveredCapabilityMessage(capabilityId: string, seriesId?: string): string {
|
|
36
|
+
const name = seriesId ? `${capabilityId}:${seriesId}` : capabilityId;
|
|
37
|
+
const words = name.replace(/[^A-Za-z0-9]+/g, " ");
|
|
38
|
+
const nearest = BOND_YIELD_WORDS.test(words)
|
|
39
|
+
? "The government yields a chart can name are listed by gloom catalog \"10Y government bond\" (CAP:bond-yield:de-10y, UST:10Y); the 2- and 10-year yields of every market GC covers are on gloom fn GC --tab world."
|
|
40
|
+
: "Series a chart can name: SYMBOL, SYMBOL:field, FUT:code, UST:maturity, FRED:series and GEO:series; gloom catalog lists them.";
|
|
41
|
+
return `CAP:${name} is not covered: no chart series is called "${name}". ${nearest}`;
|
|
42
|
+
}
|
|
23
43
|
export const MAX_CHART_SERIES_CATALOG_ITEMS = 32;
|
|
24
44
|
export const MAX_CHART_SERIES_POINTS = 20_000;
|
|
25
45
|
|
|
@@ -351,5 +371,11 @@ export function createChartSeriesResolver(invoker: CapabilityInvoker) {
|
|
|
351
371
|
source.capabilityId,
|
|
352
372
|
"resolve",
|
|
353
373
|
{ seriesId: source.seriesId, viewport } satisfies ChartSeriesResolveRequest,
|
|
354
|
-
)
|
|
374
|
+
).catch((error: unknown) => {
|
|
375
|
+
// No source registered under the id: it is not covered. A source turned off still says to turn it on.
|
|
376
|
+
if (error instanceof Error && error.message === `Capability "${source.capabilityId}" is not available.`) {
|
|
377
|
+
throw new Error(uncoveredCapabilityMessage(source.capabilityId, source.seriesId));
|
|
378
|
+
}
|
|
379
|
+
throw error;
|
|
380
|
+
});
|
|
355
381
|
}
|
|
@@ -44,10 +44,10 @@ export function describeKeybindingsForCli(config: AppConfig): Record<string, unk
|
|
|
44
44
|
* table is the terminal's and the desktop's at once, so an action either has
|
|
45
45
|
* keeps its key.
|
|
46
46
|
*/
|
|
47
|
-
function takenByCoreAction(config: AppConfig, chords: readonly KeyChord[], exceptId?: string): string | null {
|
|
47
|
+
function takenByCoreAction(config: AppConfig, chords: readonly KeyChord[], exceptId?: string, command = false): string | null {
|
|
48
48
|
const resolved = resolveKeybindings(config.keybindings);
|
|
49
49
|
for (const chord of chords) {
|
|
50
|
-
const core = coreActionOnChord(resolved, chord, exceptId);
|
|
50
|
+
const core = coreActionOnChord(resolved, chord, exceptId, { command });
|
|
51
51
|
if (core) return takenChordMessage(formatChordForHost(chord, "terminal"), core);
|
|
52
52
|
}
|
|
53
53
|
return null;
|
|
@@ -87,7 +87,7 @@ export function applyKeybindingCliSet(config: AppConfig, key: string, rawValue:
|
|
|
87
87
|
const chords = [];
|
|
88
88
|
for (const text of value.split(/\s+/)) {
|
|
89
89
|
const chord = parseKeyChord(text);
|
|
90
|
-
if (!chord) return { ok: false, message: `"${text}" is not a key chord. Examples: Ctrl+T, CmdOrCtrl+Shift+F, Alt+
|
|
90
|
+
if (!chord) return { ok: false, message: `"${text}" is not a key chord. Examples: Ctrl+T, CmdOrCtrl+Shift+F, Alt+D, F5, \`` };
|
|
91
91
|
chords.push(chord);
|
|
92
92
|
}
|
|
93
93
|
const taken = takenByCoreAction(config, chords, target);
|
|
@@ -101,7 +101,7 @@ export function applyKeybindingCliSet(config: AppConfig, key: string, rawValue:
|
|
|
101
101
|
|
|
102
102
|
if (section === "commands") {
|
|
103
103
|
const chord = parseKeyChord(target);
|
|
104
|
-
if (!chord) return { ok: false, message: `"${target}" is not a key chord. Examples: Alt+
|
|
104
|
+
if (!chord) return { ok: false, message: `"${target}" is not a key chord. Examples: Alt+D, CmdOrCtrl+Shift+N, F5` };
|
|
105
105
|
if (UNBIND_WORDS.has(value.toLowerCase()) || value === "") {
|
|
106
106
|
return {
|
|
107
107
|
ok: true,
|
|
@@ -112,7 +112,7 @@ export function applyKeybindingCliSet(config: AppConfig, key: string, rawValue:
|
|
|
112
112
|
if (isTypingChord(chord)) {
|
|
113
113
|
return { ok: false, message: `"${target}" would fire while typing; command bindings need Ctrl, Cmd, Alt or a function key.` };
|
|
114
114
|
}
|
|
115
|
-
const taken = takenByCoreAction(config, [chord]);
|
|
115
|
+
const taken = takenByCoreAction(config, [chord], undefined, true);
|
|
116
116
|
if (taken) return { ok: false, message: taken };
|
|
117
117
|
return {
|
|
118
118
|
ok: true,
|