gloomberb 0.19.3 → 0.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/api-client/errors.ts +8 -0
- package/src/api-client/index.ts +18 -0
- package/src/api-client/request.ts +295 -42
- package/src/api-client/socket.ts +95 -0
- package/src/app/keybindings/actions.ts +1 -1
- package/src/app/pane-runtime/index.tsx +1 -1
- package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
- package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
- package/src/app/pane-runtime/ticker-open-target.ts +12 -2
- package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
- package/src/cli/desktop-pane-shot.ts +2 -1
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/commands/direct/runtime.ts +3 -3
- package/src/components/command-bar/helpers.ts +2 -0
- package/src/components/command-bar/list/model.ts +9 -0
- package/src/components/command-bar/pane-actions.ts +46 -35
- package/src/components/command-bar/pane-templates/workflow.ts +6 -0
- package/src/components/command-bar/panel/index.tsx +30 -3
- package/src/components/command-bar/panel/types.ts +7 -0
- package/src/components/command-bar/routes/root/results.ts +4 -4
- package/src/components/command-bar/routes/root/selection.ts +3 -2
- package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
- package/src/components/command-bar/routing/launch-request.ts +3 -2
- package/src/components/command-bar/routing/list-state.ts +4 -1
- package/src/components/command-bar/surface/index.tsx +15 -1
- package/src/components/layout/floating-pane.tsx +10 -0
- package/src/components/layout/pane/frame.tsx +6 -0
- package/src/components/layout/pane/header.tsx +244 -42
- package/src/components/layout/pane/index.tsx +20 -2
- package/src/components/layout/shell/active-drag.ts +128 -27
- package/src/components/layout/shell/drag/index.ts +99 -96
- package/src/components/layout/shell/drag/live.ts +3 -17
- package/src/components/layout/shell/drag/magnets.ts +198 -0
- package/src/components/layout/shell/drag/overlays.tsx +77 -75
- package/src/components/layout/shell/drag/runtime.ts +12 -7
- package/src/components/layout/shell/index.tsx +66 -32
- package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
- package/src/components/layout/shell/native/surfaces.ts +1 -9
- package/src/components/layout/shell/native/window-state.ts +21 -25
- package/src/components/layout/shell/pane/layers.tsx +153 -24
- package/src/components/layout/shell/shortcuts.ts +4 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
- package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
- package/src/components/layout/status-bar.tsx +75 -6
- package/src/core/app-runtime.ts +4 -1
- package/src/core/connection-health.ts +76 -1
- package/src/core/state/app/command-bar-launch.ts +12 -0
- package/src/core/state/app/layout.ts +4 -3
- package/src/core/state/app/types.ts +4 -1
- package/src/data/config/layout.ts +2 -2
- package/src/data/config/store/fold-panes.ts +6 -1
- package/src/i18n/es.ts +8 -1
- package/src/i18n/ja.ts +8 -1
- package/src/i18n/ko.ts +8 -1
- package/src/i18n/zh-cn.ts +8 -1
- package/src/i18n/zh-tw.ts +8 -1
- package/src/layout/pane-follow.ts +3 -2
- package/src/layout/pane-layout-move.ts +2 -1
- package/src/layout/pane-manager/dock-stack.ts +38 -0
- package/src/layout/pane-manager/dock-tree.ts +76 -15
- package/src/layout/pane-manager/docking.ts +48 -6
- package/src/layout/pane-manager/floating-actions.ts +12 -3
- package/src/layout/pane-manager/floating-placement.ts +189 -0
- package/src/layout/pane-manager/floating.ts +23 -4
- package/src/layout/pane-manager/gridlock.ts +16 -4
- package/src/layout/pane-manager/hidden-panes.ts +30 -1
- package/src/layout/pane-manager/index.ts +2 -0
- package/src/layout/pane-manager/layout-state.ts +17 -0
- package/src/layout/pane-manager/types.ts +4 -1
- package/src/layout/ticker-retarget.ts +88 -0
- package/src/layout-marketplace/cloud.ts +9 -1
- package/src/market-data/connection-follow.ts +68 -0
- package/src/market-data/coordinator/entries.ts +15 -3
- package/src/market-data/coordinator/financials.ts +20 -7
- package/src/market-data/coordinator/index.ts +217 -4
- package/src/market-data/coordinator/quotes.ts +10 -0
- package/src/market-data/hooks.tsx +31 -0
- package/src/news/aggregator.ts +12 -1
- package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
- package/src/plugins/builtin/buildout/model/index.ts +6 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
- package/src/plugins/builtin/chart-composer/index.tsx +13 -0
- package/src/plugins/builtin/chat/controller/index.ts +10 -3
- package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
- package/src/plugins/builtin/chat/status-widget.tsx +3 -1
- package/src/plugins/builtin/help/index.tsx +1 -1
- package/src/plugins/builtin/sectors/client.ts +18 -8
- package/src/plugins/builtin/sectors/index.tsx +19 -5
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
- package/src/react/async-resource.ts +12 -0
- package/src/remote/controller.ts +3 -1
- package/src/renderers/browser/app-services.ts +8 -1
- package/src/renderers/browser/cloud-transport.ts +6 -1
- package/src/renderers/cloudflare/worker.ts +24 -2
- package/src/renderers/dom/styles.css +32 -0
- package/src/shares/portable-layout.ts +99 -2
- package/src/sources/provider-router/index.ts +2 -2
- package/src/sources/provider-router/sources.ts +26 -1
- package/src/sync/core-contributors.ts +18 -4
- package/src/time-series/resolve.ts +12 -0
- package/src/types/config.ts +17 -1
- package/src/types/plugin.ts +6 -0
package/src/api-client/socket.ts
CHANGED
|
@@ -31,6 +31,24 @@ import {
|
|
|
31
31
|
} from "../core/connection-health";
|
|
32
32
|
|
|
33
33
|
const QUOTE_SUBSCRIPTION_FLUSH_MS = 25;
|
|
34
|
+
/** How long a connection may take to open before the attempt is dropped and tried again. */
|
|
35
|
+
export const SOCKET_CONNECT_TIMEOUT_MS = 10_000;
|
|
36
|
+
/**
|
|
37
|
+
* An open connection that has sent nothing for this long is asked whether it
|
|
38
|
+
* is still there: a `ping`, which the server answers with a `pong`.
|
|
39
|
+
*/
|
|
40
|
+
export const SOCKET_QUIET_PING_MS = 10_000;
|
|
41
|
+
/**
|
|
42
|
+
* A connection that has not answered a ping in this long, nothing else come
|
|
43
|
+
* back meanwhile, is taken for dead (a half-open link: a laptop that slept, a
|
|
44
|
+
* network that changed under it). It is dropped and opened again; until then
|
|
45
|
+
* prices it streamed read as stale. Only an unanswered ping drops it: silence
|
|
46
|
+
* alone does not, since a check that runs late (a hidden tab's throttled
|
|
47
|
+
* timers, a wake from sleep) finds any connection silent.
|
|
48
|
+
*/
|
|
49
|
+
export const SOCKET_PING_ANSWER_MS = 10_000;
|
|
50
|
+
/** How often an open connection's silence is checked; it never needs to be exact. */
|
|
51
|
+
const SOCKET_SILENCE_CHECK_MS = 2_500;
|
|
34
52
|
/**
|
|
35
53
|
* Protocol features this client can read. A server lists the ones it offers
|
|
36
54
|
* in "ready"; the client opts into the shared ones, so an older server never
|
|
@@ -96,6 +114,8 @@ type CloudApiSocketDelegate = {
|
|
|
96
114
|
clearWebSocketTokenForFallback: () => boolean;
|
|
97
115
|
markCurrentUserUnverified: () => void;
|
|
98
116
|
updateCurrentUserFromSocket: (user: Partial<AuthUser>) => void;
|
|
117
|
+
/** The service answered on this connection (it opened, or sent a frame); see `CloudApiRequestTransport.noteServiceAnswered`. */
|
|
118
|
+
onServiceAnswered?: () => void;
|
|
99
119
|
};
|
|
100
120
|
|
|
101
121
|
type ChatSendMessage = (
|
|
@@ -122,6 +142,13 @@ export class CloudApiSocket {
|
|
|
122
142
|
private ws: WebSocket | null = null;
|
|
123
143
|
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
124
144
|
private reconnectDelayMs = 1000;
|
|
145
|
+
/** Gives up on a connection that has not opened in SOCKET_CONNECT_TIMEOUT_MS. */
|
|
146
|
+
private connectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
147
|
+
/** Checks the open connection's silence (SOCKET_QUIET_PING_MS, SOCKET_PING_ANSWER_MS). */
|
|
148
|
+
private silenceTimer: ReturnType<typeof setInterval> | null = null;
|
|
149
|
+
/** When the open connection last sent anything, and when the ping still unanswered went out. */
|
|
150
|
+
private lastFrameAt = 0;
|
|
151
|
+
private pingedAt: number | null = null;
|
|
125
152
|
|
|
126
153
|
private readonly channelListeners = new Map<string, Set<ChannelListener>>();
|
|
127
154
|
private readonly chatMentionCandidatesListeners = new Set<() => void>();
|
|
@@ -196,6 +223,7 @@ export class CloudApiSocket {
|
|
|
196
223
|
clearTimeout(this.reconnectTimer);
|
|
197
224
|
this.reconnectTimer = null;
|
|
198
225
|
}
|
|
226
|
+
this.stopWatching();
|
|
199
227
|
const ws = this.ws;
|
|
200
228
|
this.ws = null;
|
|
201
229
|
if (ws) {
|
|
@@ -860,9 +888,16 @@ export class CloudApiSocket {
|
|
|
860
888
|
return;
|
|
861
889
|
}
|
|
862
890
|
this.ws = ws;
|
|
891
|
+
// A link that swallows the handshake never says so: the attempt is dropped and tried again.
|
|
892
|
+
this.connectTimer = setTimeout(() => {
|
|
893
|
+
this.connectTimer = null;
|
|
894
|
+
if (this.ws === ws) this.dropUnansweredSocket(ws, "Connecting timed out");
|
|
895
|
+
}, SOCKET_CONNECT_TIMEOUT_MS);
|
|
863
896
|
|
|
864
897
|
ws.onopen = () => {
|
|
865
898
|
if (this.ws !== ws) return;
|
|
899
|
+
this.watchSilence();
|
|
900
|
+
this.delegate.onServiceAnswered?.();
|
|
866
901
|
cloudApiLog.info("websocket open");
|
|
867
902
|
this.health.reportSocketState(
|
|
868
903
|
GLOOM_CLOUD_SOCKET_CONNECTION_ID,
|
|
@@ -878,6 +913,9 @@ export class CloudApiSocket {
|
|
|
878
913
|
|
|
879
914
|
ws.onmessage = (event) => {
|
|
880
915
|
if (this.ws !== ws) return;
|
|
916
|
+
this.lastFrameAt = Date.now();
|
|
917
|
+
this.pingedAt = null;
|
|
918
|
+
this.delegate.onServiceAnswered?.();
|
|
881
919
|
void this.handleSocketMessage(String(event.data));
|
|
882
920
|
};
|
|
883
921
|
|
|
@@ -885,6 +923,7 @@ export class CloudApiSocket {
|
|
|
885
923
|
const activeSocket = this.ws === ws;
|
|
886
924
|
if (this.ws === ws) {
|
|
887
925
|
this.ws = null;
|
|
926
|
+
this.stopWatching();
|
|
888
927
|
this.emitTapeStatus({ type: "disconnected", reason: "Stream disconnected; observed window may contain gaps" });
|
|
889
928
|
}
|
|
890
929
|
const closeEvent = event as CloseEvent | undefined;
|
|
@@ -927,6 +966,62 @@ export class CloudApiSocket {
|
|
|
927
966
|
};
|
|
928
967
|
}
|
|
929
968
|
|
|
969
|
+
/** From the open: the connection's silence is checked until it closes. */
|
|
970
|
+
private watchSilence(): void {
|
|
971
|
+
this.stopWatching();
|
|
972
|
+
this.lastFrameAt = Date.now();
|
|
973
|
+
this.pingedAt = null;
|
|
974
|
+
this.silenceTimer = setInterval(() => this.checkSilence(), SOCKET_SILENCE_CHECK_MS);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
private stopWatching(): void {
|
|
978
|
+
if (this.connectTimer) clearTimeout(this.connectTimer);
|
|
979
|
+
if (this.silenceTimer) clearInterval(this.silenceTimer);
|
|
980
|
+
this.connectTimer = null;
|
|
981
|
+
this.silenceTimer = null;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* A connection that went quiet is pinged; one that leaves the ping
|
|
986
|
+
* unanswered for SOCKET_PING_ANSWER_MS is half open, and is dropped and
|
|
987
|
+
* opened again. Anything it sends answers the ping.
|
|
988
|
+
*/
|
|
989
|
+
private checkSilence(): void {
|
|
990
|
+
const ws = this.ws;
|
|
991
|
+
if (!ws || ws.readyState !== WebSocket.OPEN) return;
|
|
992
|
+
const now = Date.now();
|
|
993
|
+
if (this.pingedAt != null) {
|
|
994
|
+
if (now - this.pingedAt >= SOCKET_PING_ANSWER_MS) this.dropUnansweredSocket(ws, "No answer from the stream");
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (now - this.lastFrameAt >= SOCKET_QUIET_PING_MS) {
|
|
998
|
+
this.pingedAt = now;
|
|
999
|
+
this.sendFrame({ type: "ping" });
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Gives up on a connection that never opened or went silent: what it was
|
|
1005
|
+
* carrying is reported as interrupted (the stream's health turns to error,
|
|
1006
|
+
* which marks its prices stale), and a new one is opened with the backoff.
|
|
1007
|
+
* Its close, if it ever comes, is for a socket no longer in use.
|
|
1008
|
+
*/
|
|
1009
|
+
private dropUnansweredSocket(ws: WebSocket, reason: string): void {
|
|
1010
|
+
if (this.ws !== ws) return;
|
|
1011
|
+
this.ws = null;
|
|
1012
|
+
this.stopWatching();
|
|
1013
|
+
cloudApiLog.warn("websocket unanswered; reconnecting", { reason, quoteTargets: this.quoteTargets.size });
|
|
1014
|
+
try {
|
|
1015
|
+
ws.close();
|
|
1016
|
+
} catch {
|
|
1017
|
+
// Intentional ignore: a socket that cannot close is dropped all the same.
|
|
1018
|
+
}
|
|
1019
|
+
this.emitTapeStatus({ type: "disconnected", reason: "Stream disconnected; observed window may contain gaps" });
|
|
1020
|
+
this.emitConnection("closed");
|
|
1021
|
+
this.health.reportSocketState(GLOOM_CLOUD_SOCKET_CONNECTION_ID, "error", reason);
|
|
1022
|
+
this.scheduleReconnect();
|
|
1023
|
+
}
|
|
1024
|
+
|
|
930
1025
|
/**
|
|
931
1026
|
* A socket that could not be constructed is an error to show, not to throw:
|
|
932
1027
|
* ensureSocket runs from effects and timers nobody awaits. The reconnect
|
|
@@ -85,7 +85,7 @@ export const KEYBINDING_ACTIONS: readonly KeybindingActionDef[] = [
|
|
|
85
85
|
{
|
|
86
86
|
id: "ticker-search",
|
|
87
87
|
category: "Global Keys",
|
|
88
|
-
description: "
|
|
88
|
+
description: "Change the focused pane's ticker.",
|
|
89
89
|
// One chord on purpose: the command bar already searches symbols for
|
|
90
90
|
// free text, so a layout without a backtick key still has Ctrl+P and
|
|
91
91
|
// typing. A dedicated key is a rebind away for anyone who wants one.
|
|
@@ -185,7 +185,7 @@ export function useAppPaneRuntime({
|
|
|
185
185
|
const dockedPaneIds = getDockedPaneIds(nextLayout);
|
|
186
186
|
|
|
187
187
|
if (options?.placement === "floating" || (options?.placement !== "docked" && paneDef.defaultMode === "floating")) {
|
|
188
|
-
nextLayout = addPaneFloating(nextLayout, instance, width, height, paneDef);
|
|
188
|
+
nextLayout = addPaneFloating(nextLayout, instance, width, height, paneDef, { focusedPaneId });
|
|
189
189
|
} else if (relativeTo && findDockLeaf(nextLayout, relativeTo)) {
|
|
190
190
|
nextLayout = addPaneToLayout(nextLayout, instance, { relativeTo, position: relativePosition });
|
|
191
191
|
} else if (dockedPaneIds.length === 0) {
|
|
@@ -106,7 +106,7 @@ export function useAppTickerInspectorRuntime({
|
|
|
106
106
|
const sourceDocked = findDockLeaf(state.config.layout, sourcePaneId);
|
|
107
107
|
const layout = sourceDocked && paneDef.defaultMode !== "floating"
|
|
108
108
|
? addPaneToLayout(state.config.layout, instance, { relativeTo: sourcePaneId, position: "right" })
|
|
109
|
-
: addPaneFloating(state.config.layout, instance, width, height, paneDef);
|
|
109
|
+
: addPaneFloating(state.config.layout, instance, width, height, paneDef, { focusedPaneId: sourcePaneId });
|
|
110
110
|
return { layout, instance };
|
|
111
111
|
}, [pluginRegistry, resolveInspectorPane, state.config.layout]);
|
|
112
112
|
|
|
@@ -173,7 +173,7 @@ export function useAppTickerOpenRuntime({
|
|
|
173
173
|
const { width, height } = pluginRegistry.getTermSize();
|
|
174
174
|
const shouldFloat = options?.floating ?? true;
|
|
175
175
|
const nextLayout = shouldFloat
|
|
176
|
-
? addPaneFloating(currentLayout, instance, width, height, paneDef)
|
|
176
|
+
? addPaneFloating(currentLayout, instance, width, height, paneDef, { focusedPaneId: currentState.focusedPaneId })
|
|
177
177
|
: addPaneToLayout(
|
|
178
178
|
currentLayout,
|
|
179
179
|
instance,
|
|
@@ -5,6 +5,7 @@ import type { TickerRecord } from "../../types/ticker";
|
|
|
5
5
|
import type { TickerOpenTarget } from "../../tickers/open-target";
|
|
6
6
|
import { AmbiguousTickerError } from "../../tickers/search";
|
|
7
7
|
import { isDialogOpen } from "../../ui/dialog-stack";
|
|
8
|
+
import { SECURITY_DESCRIPTION_SEARCH } from "../../core/state/app/command-bar-launch";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A resolved open joins the app's tickers: the store takes the record when it
|
|
@@ -24,8 +25,17 @@ export function publishTickerOpenTarget(target: TickerOpenTarget, { tickers, dis
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* An open whose symbol names several listings offers them in ticker search, unless a dialog would
|
|
30
|
+
* sit over the bar. The pick opens the listing, as the open would have, rather than changing the
|
|
31
|
+
* focused pane's ticker.
|
|
32
|
+
*/
|
|
28
33
|
export function offerTickerListings(error: unknown, rawSymbol: string, dispatch: Dispatch<AppAction>): void {
|
|
29
34
|
if (!(error instanceof AmbiguousTickerError) || isDialogOpen()) return;
|
|
30
|
-
dispatch({
|
|
35
|
+
dispatch({
|
|
36
|
+
type: "SET_COMMAND_BAR",
|
|
37
|
+
open: true,
|
|
38
|
+
query: rawSymbol,
|
|
39
|
+
launch: { kind: "ticker-search", query: rawSymbol, payload: SECURITY_DESCRIPTION_SEARCH },
|
|
40
|
+
});
|
|
31
41
|
}
|
|
@@ -16,11 +16,14 @@ const AUTH_IN_FAMILY = /^\/cloud\/auth(?:\/|$)/;
|
|
|
16
16
|
* session cut to its user, see `isShotSessionPath`), plan prices, the service
|
|
17
17
|
* probe, the roadmap, the layout gallery (marketplace and team layouts),
|
|
18
18
|
* theses, and a signed-in broker's catalog, connection status, holdings,
|
|
19
|
-
* orders and fills.
|
|
19
|
+
* orders and fills. The Buildout plan is one: its answer is the plan and its
|
|
20
|
+
* prices, never the token `POST /account/buildout/token` mints, which stays
|
|
21
|
+
* refused, so the Buildout panes cannot be drawn with a plan's data.
|
|
20
22
|
*/
|
|
21
23
|
const READ_PATHS = [
|
|
22
24
|
/^\/auth\/get-session$/,
|
|
23
25
|
/^\/account\/cloud$/,
|
|
26
|
+
/^\/account\/buildout$/,
|
|
24
27
|
/^\/pricing$/,
|
|
25
28
|
/^\/health$/,
|
|
26
29
|
/^\/roadmap$/,
|
|
@@ -30,8 +33,13 @@ const READ_PATHS = [
|
|
|
30
33
|
/^\/brokers\/connectors$/,
|
|
31
34
|
/^\/brokers\/[a-z][a-z0-9-]{0,31}(?:\/(?:snapshot|orders|executions))?$/,
|
|
32
35
|
];
|
|
33
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Reads sent as a POST because their query is a list or a definition: batches,
|
|
38
|
+
* scans, analyses and the equity screen's query. Its saved-screen writes,
|
|
39
|
+
* ticker check and export are not here.
|
|
40
|
+
*/
|
|
34
41
|
const READ_POSTS = new Set([
|
|
42
|
+
"/cloud/equity-screener/query",
|
|
35
43
|
"/cloud/exposure/analyze",
|
|
36
44
|
"/cloud/perps/equities",
|
|
37
45
|
"/market/financials/batch",
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
type ShotApiSocketCall,
|
|
31
31
|
type ShotApiSocketReply,
|
|
32
32
|
} from "./desktop-pane-shot-routes";
|
|
33
|
+
import { SHOT_REQUEST_REFUSED } from "../api-client/errors";
|
|
33
34
|
import { SESSION_COOKIE_NAMES } from "../api-client/session-cookie";
|
|
34
35
|
import { isShotApiRequestAllowed, isShotSessionPath } from "./desktop-pane-shot-api-policy";
|
|
35
36
|
import { renderElectrobunViewHtml } from "../renderers/dom/build-assets";
|
|
@@ -472,7 +473,7 @@ async function proxyShotApiRequest(
|
|
|
472
473
|
const basePath = baseUrl.pathname.replace(/\/+$/, "");
|
|
473
474
|
let path = requestUrl.pathname.slice(SHOT_API_PROXY_PREFIX.length) || "/";
|
|
474
475
|
let method = request.method.toUpperCase();
|
|
475
|
-
if (!isShotApiRequestAllowed(method, path)) return shotApiError(
|
|
476
|
+
if (!isShotApiRequestAllowed(method, path)) return shotApiError(SHOT_REQUEST_REFUSED, 403);
|
|
476
477
|
const headers = new Headers();
|
|
477
478
|
for (const name of SHOT_API_REQUEST_HEADERS) {
|
|
478
479
|
const value = request.headers.get(name);
|
|
@@ -74,6 +74,7 @@ export function useCommandBarActionRuntime({
|
|
|
74
74
|
tickers,
|
|
75
75
|
}: UseCommandBarActionRuntimeOptions) {
|
|
76
76
|
const {
|
|
77
|
+
changePaneTicker,
|
|
77
78
|
duplicatePane,
|
|
78
79
|
focusTicker,
|
|
79
80
|
persistLayoutChange,
|
|
@@ -90,6 +91,7 @@ export function useCommandBarActionRuntime({
|
|
|
90
91
|
readTickerSearchCache,
|
|
91
92
|
writeTickerSearchCache,
|
|
92
93
|
} = useCommandBarTickerSearchActions({
|
|
94
|
+
changePaneTicker,
|
|
93
95
|
closeAll,
|
|
94
96
|
dispatch,
|
|
95
97
|
focusTicker,
|
|
@@ -14,7 +14,7 @@ import { normalizeTickerInput } from "../../../../tickers/search";
|
|
|
14
14
|
import { useRendererHost } from "../../../../ui";
|
|
15
15
|
import type { ThemePickerHandle } from "../../theme-picker";
|
|
16
16
|
import type { Command } from "../registry";
|
|
17
|
-
import type
|
|
17
|
+
import { SECURITY_DESCRIPTION_SEARCH, type CollectionCommandId } from "../../helpers";
|
|
18
18
|
import {
|
|
19
19
|
runDirectCommandAction,
|
|
20
20
|
} from "./index";
|
|
@@ -93,7 +93,7 @@ export function useCommandBarDirectCommandRuntime({
|
|
|
93
93
|
closeAll({ revertThemePreview: false });
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
openModeRoute("ticker-search", "");
|
|
96
|
+
openModeRoute("ticker-search", "", SECURITY_DESCRIPTION_SEARCH);
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -113,7 +113,7 @@ export function useCommandBarDirectCommandRuntime({
|
|
|
113
113
|
closeAll({ revertThemePreview: false });
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
openModeRoute("ticker-search", trimmed);
|
|
116
|
+
openModeRoute("ticker-search", trimmed, SECURITY_DESCRIPTION_SEARCH);
|
|
117
117
|
}, [
|
|
118
118
|
activeCollectionId,
|
|
119
119
|
activeTickerSymbol,
|
|
@@ -15,6 +15,8 @@ export {
|
|
|
15
15
|
export type RouteCommandId = "security-description" | "layout";
|
|
16
16
|
export type CollectionCommandId = "add-watchlist" | "add-portfolio" | "remove-watchlist" | "remove-portfolio";
|
|
17
17
|
|
|
18
|
+
export { SECURITY_DESCRIPTION_SEARCH } from "../../core/state/app/command-bar-launch";
|
|
19
|
+
|
|
18
20
|
export function isRouteCommandId(commandId: string): commandId is RouteCommandId {
|
|
19
21
|
return commandId === "security-description"
|
|
20
22
|
|| commandId === "layout";
|
|
@@ -40,6 +40,12 @@ export interface ResultItem {
|
|
|
40
40
|
listing?: TickerListingRef;
|
|
41
41
|
/** Materialize this exact listing when another command consumes the row. */
|
|
42
42
|
resolveTicker?: () => Promise<TickerRecord>;
|
|
43
|
+
/**
|
|
44
|
+
* A ticker row's three choices: `des` opens it as DES does (the row's `action`), `new` in a
|
|
45
|
+
* new research pane (its `secondaryAction`), and `pane` changes the focused pane's ticker, as
|
|
46
|
+
* ticker search's Enter does.
|
|
47
|
+
*/
|
|
48
|
+
pickTicker?: (how: TickerPick) => void;
|
|
43
49
|
/**
|
|
44
50
|
* What the pane this row opens will load, so the bar can warm it while the
|
|
45
51
|
* row is the pick. Unset when only opening can tell (a broker contract, a
|
|
@@ -73,6 +79,9 @@ export interface ResultItem {
|
|
|
73
79
|
action: () => void | Promise<void>;
|
|
74
80
|
}
|
|
75
81
|
|
|
82
|
+
/** What choosing a ticker row does; see `ResultItem.pickTicker`. */
|
|
83
|
+
export type TickerPick = "des" | "pane" | "new";
|
|
84
|
+
|
|
76
85
|
/** A row plain Enter can run, so the untouched selection may rest on it. */
|
|
77
86
|
export function isDefaultSelectable(item: ResultItem): boolean {
|
|
78
87
|
return item.disabled !== true && item.defaultSelectable !== false;
|
|
@@ -6,16 +6,17 @@ import {
|
|
|
6
6
|
resolveFollowBindingInstance,
|
|
7
7
|
TICKER_RESEARCH_PANE_ID,
|
|
8
8
|
type LayoutConfig,
|
|
9
|
+
type PaneInstanceConfig,
|
|
9
10
|
} from "../../types/config";
|
|
10
11
|
import {
|
|
11
12
|
addPaneFloating,
|
|
12
13
|
addPaneToLayout,
|
|
13
14
|
} from "../../layout/pane-manager";
|
|
15
|
+
import { resolveTickerRetargetPane, retargetTickerPane } from "../../layout/ticker-retarget";
|
|
14
16
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
15
17
|
import type { PinTickerOptions } from "../../types/plugin";
|
|
16
|
-
import { tickerInstrumentLabel } from "../../tickers/instrument-label";
|
|
17
18
|
import { instrumentFromTicker } from "../../market-data/request-types";
|
|
18
|
-
import type
|
|
19
|
+
import { resolveTickerForPane, type AppAction, type AppState } from "../../state/app/context";
|
|
19
20
|
import { recordFunctionOpen } from "../../telemetry/usage-counts";
|
|
20
21
|
|
|
21
22
|
/** Points the portfolio pane the focus follows (or the main one) at a collection. */
|
|
@@ -46,24 +47,6 @@ export function useCommandBarPaneActions({
|
|
|
46
47
|
pluginRegistry,
|
|
47
48
|
stateRef,
|
|
48
49
|
}: CommandBarPaneActionsOptions) {
|
|
49
|
-
const retargetTickerResearchPane = useCallback((paneId: string, symbol: string, options?: PinTickerOptions) => {
|
|
50
|
-
const currentState = stateRef.current;
|
|
51
|
-
const targetPane = findPaneInstance(currentState.config.layout, paneId);
|
|
52
|
-
if (!targetPane || targetPane.paneId !== TICKER_RESEARCH_PANE_ID) return;
|
|
53
|
-
const instrument = options?.instrument !== undefined ? options.instrument : instrumentFromTicker(currentState.tickers.get(symbol))?.instrument ?? undefined;
|
|
54
|
-
|
|
55
|
-
const nextLayout = {
|
|
56
|
-
...currentState.config.layout,
|
|
57
|
-
instances: currentState.config.layout.instances.map((instance) => (
|
|
58
|
-
instance.instanceId === targetPane.instanceId
|
|
59
|
-
? { ...instance, title: tickerInstrumentLabel(symbol, instrument), binding: { kind: "fixed" as const, symbol, ...(instrument !== undefined ? { instrument } : {}), ...(options?.listing ? { listing: options.listing } : {}) } }
|
|
60
|
-
: instance
|
|
61
|
-
)),
|
|
62
|
-
};
|
|
63
|
-
dispatch({ type: "UPDATE_LAYOUT", layout: nextLayout });
|
|
64
|
-
dispatch({ type: "FOCUS_PANE", paneId: targetPane.instanceId });
|
|
65
|
-
}, [dispatch, stateRef]);
|
|
66
|
-
|
|
67
50
|
const openFixedTickerPane = useCallback((symbol: string, options?: PinTickerOptions) => {
|
|
68
51
|
pluginRegistry.pinTicker(symbol, {
|
|
69
52
|
floating: true,
|
|
@@ -74,29 +57,56 @@ export function useCommandBarPaneActions({
|
|
|
74
57
|
});
|
|
75
58
|
}, [pluginRegistry]);
|
|
76
59
|
|
|
60
|
+
const persistLayoutChange = useCallback((nextLayout: LayoutConfig) => {
|
|
61
|
+
pluginRegistry.updateLayout(nextLayout);
|
|
62
|
+
}, [pluginRegistry]);
|
|
63
|
+
|
|
64
|
+
/** Pins `target` on the ticker; the focus stays on the pane it was on. */
|
|
65
|
+
const retargetPane = useCallback((target: PaneInstanceConfig, symbol: string, options?: PinTickerOptions) => {
|
|
66
|
+
const currentState = stateRef.current;
|
|
67
|
+
// Opening a research pane is counted in pinTicker; retargeting one here is DES too.
|
|
68
|
+
if (target.paneId === TICKER_RESEARCH_PANE_ID) recordFunctionOpen({ shortcut: "DES", externalPluginId: null });
|
|
69
|
+
const instrument = options?.instrument !== undefined
|
|
70
|
+
? options.instrument
|
|
71
|
+
: instrumentFromTicker(currentState.tickers.get(symbol))?.instrument ?? undefined;
|
|
72
|
+
persistLayoutChange(retargetTickerPane(currentState.config.layout, target, symbol, {
|
|
73
|
+
instrument,
|
|
74
|
+
listing: options?.listing,
|
|
75
|
+
previous: resolveTickerForPane(currentState, target.instanceId),
|
|
76
|
+
paneDef: pluginRegistry.panes.get(target.paneId),
|
|
77
|
+
}));
|
|
78
|
+
dispatch({ type: "FOCUS_PANE", paneId: currentState.focusedPaneId ?? target.instanceId });
|
|
79
|
+
}, [dispatch, persistLayoutChange, pluginRegistry.panes, stateRef]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* DES and the command bar's ticker rows: a focused Ticker Research pane changes to the ticker,
|
|
83
|
+
* and from any other pane a research pane opens on it.
|
|
84
|
+
*/
|
|
77
85
|
const focusTicker = useCallback((symbol: string, options?: PinTickerOptions) => {
|
|
78
86
|
const currentState = stateRef.current;
|
|
79
87
|
const focusedPane = currentState.focusedPaneId
|
|
80
88
|
? findPaneInstance(currentState.config.layout, currentState.focusedPaneId)
|
|
81
89
|
: null;
|
|
82
|
-
if (options?.forceNewPane) {
|
|
83
|
-
|
|
90
|
+
if (!options?.forceNewPane && focusedPane?.paneId === TICKER_RESEARCH_PANE_ID) {
|
|
91
|
+
retargetPane(focusedPane, symbol, options);
|
|
84
92
|
return;
|
|
85
93
|
}
|
|
86
|
-
|
|
87
|
-
if (focusedPane?.paneId === TICKER_RESEARCH_PANE_ID) {
|
|
88
|
-
// Opening a research pane is counted in pinTicker; retargeting one here is DES too.
|
|
89
|
-
recordFunctionOpen({ shortcut: "DES", externalPluginId: null });
|
|
90
|
-
retargetTickerResearchPane(focusedPane.instanceId, symbol, options);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
94
|
openFixedTickerPane(symbol, options);
|
|
95
|
-
}, [openFixedTickerPane,
|
|
95
|
+
}, [openFixedTickerPane, retargetPane, stateRef]);
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Ticker search's Enter (the backtick, or the ticker in a pane's header): the focused pane
|
|
99
|
+
* changes to the ticker when it shows one, with the panes linked to it (the rule is
|
|
100
|
+
* `resolveTickerRetargetPane`). From any other pane it does what DES does.
|
|
101
|
+
*/
|
|
102
|
+
const changePaneTicker = useCallback((symbol: string, options?: PinTickerOptions) => {
|
|
103
|
+
const currentState = stateRef.current;
|
|
104
|
+
const target = options?.forceNewPane
|
|
105
|
+
? null
|
|
106
|
+
: resolveTickerRetargetPane(currentState.config.layout, currentState.focusedPaneId, pluginRegistry.panes);
|
|
107
|
+
if (target) retargetPane(target, symbol, options);
|
|
108
|
+
else focusTicker(symbol, options);
|
|
109
|
+
}, [focusTicker, pluginRegistry.panes, retargetPane, stateRef]);
|
|
100
110
|
|
|
101
111
|
const duplicatePane = useCallback((paneId: string) => {
|
|
102
112
|
const currentState = stateRef.current;
|
|
@@ -114,13 +124,14 @@ export function useCommandBarPaneActions({
|
|
|
114
124
|
|
|
115
125
|
const { width, height } = pluginRegistry.getTermSize();
|
|
116
126
|
const nextLayout = currentState.config.layout.floating.some((entry) => entry.instanceId === paneId)
|
|
117
|
-
? addPaneFloating(currentState.config.layout, duplicate, width, height, paneDef)
|
|
127
|
+
? addPaneFloating(currentState.config.layout, duplicate, width, height, paneDef, { focusedPaneId: paneId })
|
|
118
128
|
: addPaneToLayout(currentState.config.layout, duplicate, { relativeTo: paneId, position: "right" });
|
|
119
129
|
persistLayoutChange(nextLayout);
|
|
120
130
|
dispatch({ type: "FOCUS_PANE", paneId: duplicate.instanceId });
|
|
121
131
|
}, [dispatch, persistLayoutChange, pluginRegistry, stateRef]);
|
|
122
132
|
|
|
123
133
|
return {
|
|
134
|
+
changePaneTicker,
|
|
124
135
|
duplicatePane,
|
|
125
136
|
focusTicker,
|
|
126
137
|
persistLayoutChange,
|
|
@@ -256,6 +256,12 @@ export function useCommandBarPaneTemplateActions({
|
|
|
256
256
|
},
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
+
// Plain ticker search (the backtick, a pane header's ticker) changes the focused pane's ticker;
|
|
260
|
+
// a search DES opened keeps opening DES.
|
|
261
|
+
if (!routeAction && item.pickTicker) {
|
|
262
|
+
const pick = item.pickTicker;
|
|
263
|
+
return { ...item, action: () => pick("pane") };
|
|
264
|
+
}
|
|
259
265
|
return item;
|
|
260
266
|
}, [executeCollectionCommand, notify, openPaneTemplateDirect, pluginRegistry.paneTemplates]);
|
|
261
267
|
|
|
@@ -2,8 +2,8 @@ import { useLayoutEffect, useState } from "react";
|
|
|
2
2
|
import { t, tf } from "../../../i18n";
|
|
3
3
|
import { useThemeColors } from "../../../theme/theme-context";
|
|
4
4
|
import { Box, Text, TextAttributes } from "../../../ui";
|
|
5
|
-
import { truncateToDisplayWidth } from "../../../utils/format";
|
|
6
|
-
import { Button } from "../../ui";
|
|
5
|
+
import { displayWidth, truncateToDisplayWidth } from "../../../utils/format";
|
|
6
|
+
import { Button, terminalButtonColumns } from "../../ui";
|
|
7
7
|
import type { ListScreenState } from "../list/model";
|
|
8
8
|
import { CommandBarListBody } from "../list/view";
|
|
9
9
|
import { ThemePicker } from "../theme-picker";
|
|
@@ -18,6 +18,13 @@ import type { CommandBarPanelProps } from "./types";
|
|
|
18
18
|
|
|
19
19
|
const COMMAND_BAR_OVERLAY_Z_INDEX = 2_147_483_646;
|
|
20
20
|
const COMMAND_BAR_PANEL_Z_INDEX = 2_147_483_647;
|
|
21
|
+
const NEW_PANE_LABEL = "New pane";
|
|
22
|
+
|
|
23
|
+
/** Ticker search's title when Enter changes a pane: the pane's name gives way first. */
|
|
24
|
+
function changeTickerTitle(pane: string, width: number): string {
|
|
25
|
+
const full = tf("Change ticker · {pane}", { pane });
|
|
26
|
+
return displayWidth(full) <= width ? full : truncateToDisplayWidth(t("Change ticker"), width);
|
|
27
|
+
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* The root screen keeps the closed prompt's own words. Opening the bar puts the
|
|
@@ -68,9 +75,12 @@ export function CommandBarPanel({
|
|
|
68
75
|
themePickerFilter,
|
|
69
76
|
themePickerRef,
|
|
70
77
|
trailingWidth,
|
|
78
|
+
tickerSearchTarget = null,
|
|
79
|
+
onRunSecondary,
|
|
71
80
|
visibleListState,
|
|
72
81
|
}: CommandBarPanelProps) {
|
|
73
82
|
const colors = useThemeColors();
|
|
83
|
+
const newPaneColumns = terminalButtonColumns({ label: NEW_PANE_LABEL, shortcut: "Shift+Enter", compact: true });
|
|
74
84
|
const palette = useCommandBarPalette(nativePaneChrome);
|
|
75
85
|
// The count already includes this opening, so this reads the same until the bar closes.
|
|
76
86
|
const intro = useAppSelector((state) => showsCommandBarIntro(state.config));
|
|
@@ -191,8 +201,25 @@ export function CommandBarPanel({
|
|
|
191
201
|
/>
|
|
192
202
|
<Box width={2} />
|
|
193
203
|
<Text fg={palette.text} attributes={TextAttributes.BOLD}>
|
|
194
|
-
{
|
|
204
|
+
{tickerSearchTarget
|
|
205
|
+
? changeTickerTitle(tickerSearchTarget, Math.max(1, queryDisplayWidth - 8 - newPaneColumns - 2))
|
|
206
|
+
: truncateToDisplayWidth(t(getCommandBarPanelTitle(currentRoute)), Math.max(1, queryDisplayWidth - 8))}
|
|
195
207
|
</Text>
|
|
208
|
+
{tickerSearchTarget && (
|
|
209
|
+
<>
|
|
210
|
+
<Box flexGrow={1} />
|
|
211
|
+
{/* Enter changes the pane; opening another one is the secondary action. */}
|
|
212
|
+
<Button
|
|
213
|
+
label={NEW_PANE_LABEL}
|
|
214
|
+
variant="plain"
|
|
215
|
+
compact
|
|
216
|
+
flush
|
|
217
|
+
stopPropagation
|
|
218
|
+
shortcut="Shift+Enter"
|
|
219
|
+
onPress={onRunSecondary}
|
|
220
|
+
/>
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
196
223
|
</>
|
|
197
224
|
) : rootShortcutFeedback ? (
|
|
198
225
|
// Says what Enter runs, and a click on it runs the same.
|
|
@@ -46,5 +46,12 @@ export interface CommandBarPanelProps {
|
|
|
46
46
|
themePickerFilter: string;
|
|
47
47
|
themePickerRef: RefObject<ThemePickerHandle | null>;
|
|
48
48
|
trailingWidth: number;
|
|
49
|
+
/**
|
|
50
|
+
* Ticker search's Enter changes this pane's ticker (its title, as its header shows it): the
|
|
51
|
+
* chrome row says so and offers the new pane the secondary action opens. Null otherwise.
|
|
52
|
+
*/
|
|
53
|
+
tickerSearchTarget?: string | null;
|
|
54
|
+
/** Runs the selected row's secondary action, as Shift+Enter does. */
|
|
55
|
+
onRunSecondary?: () => void;
|
|
49
56
|
visibleListState: ListScreenState | null;
|
|
50
57
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type AssistRowHandlers,
|
|
14
14
|
} from "../../assist/model";
|
|
15
15
|
import { matchPrefix, type Command } from "../../commands/registry";
|
|
16
|
-
import { isCollectionCommand } from "../../helpers";
|
|
16
|
+
import { isCollectionCommand, SECURITY_DESCRIPTION_SEARCH } from "../../helpers";
|
|
17
17
|
import { recentPaneTemplateArg } from "../../pane-templates/items";
|
|
18
18
|
import { dedupeById } from "../../view-model";
|
|
19
19
|
import type { ResultItem } from "../../list/model";
|
|
@@ -74,7 +74,7 @@ export interface RootResultModelOptions {
|
|
|
74
74
|
hasPaneSettings: (paneId: string) => boolean;
|
|
75
75
|
localTickerSearchResultItems: (query?: string, options?: { category?: string; limit?: number }) => ResultItem[];
|
|
76
76
|
nonShortcutPaneTemplateItems: (filterQuery?: string) => ResultItem[];
|
|
77
|
-
openModeRoute: (screen: "ticker-search" | "layout", initialQuery?: string) => void;
|
|
77
|
+
openModeRoute: (screen: "ticker-search" | "layout", initialQuery?: string, payload?: Record<string, unknown>) => void;
|
|
78
78
|
paneShortcutItems: (options?: PaneShortcutItemsOptions) => ResultItem[];
|
|
79
79
|
pluginCommandItems: () => ResultItem[];
|
|
80
80
|
pluginCommandResultItems: (command: CommandDef, shortcutArg: string) => ResultItem[];
|
|
@@ -336,7 +336,7 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
|
|
|
336
336
|
detail: "Open security details after resolving a ticker",
|
|
337
337
|
category: "Search",
|
|
338
338
|
kind: "command",
|
|
339
|
-
action: () => openModeRoute("ticker-search", ""),
|
|
339
|
+
action: () => openModeRoute("ticker-search", "", SECURITY_DESCRIPTION_SEARCH),
|
|
340
340
|
});
|
|
341
341
|
} else if (match.arg) {
|
|
342
342
|
items.push(...localTickerSearchResultItems(match.arg, { limit: 6 }));
|
|
@@ -372,7 +372,7 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
|
|
|
372
372
|
templatesForCode: getAvailablePaneShortcutTemplates,
|
|
373
373
|
createTemplateItem: (template) => createPaneTemplateItem(template, { showShortcut: true }),
|
|
374
374
|
lookUpCompany: availableCommands.some((command) => command.id === "security-description")
|
|
375
|
-
? () => openModeRoute("ticker-search", "")
|
|
375
|
+
? () => openModeRoute("ticker-search", "", SECURITY_DESCRIPTION_SEARCH)
|
|
376
376
|
: null,
|
|
377
377
|
}));
|
|
378
378
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getCollectionCommandAction,
|
|
10
10
|
getCollectionCommandVerb,
|
|
11
11
|
isCollectionCommand,
|
|
12
|
+
SECURITY_DESCRIPTION_SEARCH,
|
|
12
13
|
type CollectionCommandId,
|
|
13
14
|
} from "../../helpers";
|
|
14
15
|
import type { ResultItem } from "../../list/model";
|
|
@@ -83,7 +84,7 @@ export function acceptRootShortcutTabAction(options: RootSelectionCommandOptions
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
if (intent.command.id === "security-description") {
|
|
86
|
-
options.openModeRoute("ticker-search", intent.argText);
|
|
87
|
+
options.openModeRoute("ticker-search", intent.argText, SECURITY_DESCRIPTION_SEARCH);
|
|
87
88
|
return true;
|
|
88
89
|
}
|
|
89
90
|
if (isCollectionCommand(intent.command.id)) {
|
|
@@ -151,7 +152,7 @@ export function buildImmediateRootSelection(options: RootSelectionCommandOptions
|
|
|
151
152
|
detail: "Open security details for a ticker",
|
|
152
153
|
category: "Search",
|
|
153
154
|
kind: "command",
|
|
154
|
-
action: () => options.openModeRoute("ticker-search", ""),
|
|
155
|
+
action: () => options.openModeRoute("ticker-search", "", SECURITY_DESCRIPTION_SEARCH),
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
158
|
return {
|