@gloom-sh/terminal 0.19.5 → 0.19.6
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 +1 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app.tsx +63 -16
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +74 -33
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +22 -4
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/portfolio/collection-name.ts +19 -0
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/sec-filings.ts +7 -1
|
@@ -19,6 +19,7 @@ import { PANE_MANAGEMENT_ACCELERATORS, type PaneManagementAccelerators } from ".
|
|
|
19
19
|
import { t, tf } from "../../../i18n";
|
|
20
20
|
import { displayWidth } from "../../../utils/format";
|
|
21
21
|
import { fireAndForget } from "../../../utils/fire-and-forget";
|
|
22
|
+
import { getDesktopWindows, windowMoveTargets } from "../../../state/desktop-windows";
|
|
22
23
|
|
|
23
24
|
const MENU_MIN_WIDTH = 18;
|
|
24
25
|
const MENU_MAX_WIDTH = 44;
|
|
@@ -217,7 +218,9 @@ export function menuForPane(
|
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
|
|
221
|
+
// Popped-out panes belong to the main window; elsewhere a pane moves to a window instead.
|
|
222
|
+
const windows = getDesktopWindows();
|
|
223
|
+
if (desktopWindowBridge?.kind === "main" && desktopWindowBridge.popOutPane && (!windows || windows.windowId === "main")) {
|
|
221
224
|
baseActions.push({
|
|
222
225
|
id: "pop-out",
|
|
223
226
|
label: "Pop Out",
|
|
@@ -227,6 +230,17 @@ export function menuForPane(
|
|
|
227
230
|
},
|
|
228
231
|
});
|
|
229
232
|
}
|
|
233
|
+
if (windows) {
|
|
234
|
+
for (const move of windowMoveTargets(windows, { prefix: "pane" })) {
|
|
235
|
+
baseActions.push({
|
|
236
|
+
id: `move-to-window:${move.key}`,
|
|
237
|
+
label: move.label,
|
|
238
|
+
onSelect: () => {
|
|
239
|
+
fireAndForget(windows.movePane(pane.instance.instanceId, move.target), "desktop.movePaneToWindow");
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
230
244
|
|
|
231
245
|
const locked = isPaneLocked(pane.instance);
|
|
232
246
|
baseActions.push({
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
exportPaneTableCsv,
|
|
21
21
|
hasPaneTableExporter,
|
|
22
22
|
} from "../../../../state/pane-table-export-registry";
|
|
23
|
+
import { getDesktopWindows } from "../../../../state/desktop-windows";
|
|
23
24
|
|
|
24
25
|
function notifyPaneLocked(pluginRegistry: PluginRegistry): void {
|
|
25
26
|
pluginRegistry.notify({ body: "Pane is locked. Unlock it in pane settings.", type: "info" });
|
|
@@ -177,6 +178,9 @@ export function useShellPaneActions({
|
|
|
177
178
|
|
|
178
179
|
const popOutFocusedPane = useCallback(() => {
|
|
179
180
|
if (!focusedPaneId || desktopWindowBridge?.kind !== "main" || !desktopWindowBridge.popOutPane) return false;
|
|
181
|
+
// Only the main window pops panes out.
|
|
182
|
+
const windows = getDesktopWindows();
|
|
183
|
+
if (windows && windows.windowId !== "main") return false;
|
|
180
184
|
if (!isPaneInLayout(visibleLayout, focusedPaneId)) return false;
|
|
181
185
|
const shot = shots.get("pop-out");
|
|
182
186
|
if (shot.refuses()) return true;
|
|
@@ -10,6 +10,7 @@ import { resolveTickerForPane, type AppState } from "../../../state/app/context"
|
|
|
10
10
|
import { resolveInstrumentForPane } from "../../../core/state/app/instrument";
|
|
11
11
|
import { paneTitleMnemonic, pinFollowingPane } from "../../../layout/pane-follow";
|
|
12
12
|
import {
|
|
13
|
+
findPaneInstance,
|
|
13
14
|
TICKER_RESEARCH_PANE_ID,
|
|
14
15
|
type LayoutConfig,
|
|
15
16
|
type PaneInstanceConfig,
|
|
@@ -34,7 +35,7 @@ export function tickerLinkMenuItems({
|
|
|
34
35
|
instance: PaneInstanceConfig;
|
|
35
36
|
layout: LayoutConfig;
|
|
36
37
|
panes: ReadonlyMap<string, PaneDef>;
|
|
37
|
-
state: Pick<AppState, "config" | "paneState" | "tickers">;
|
|
38
|
+
state: Pick<AppState, "config" | "paneState" | "tickers" | "linkedTickers">;
|
|
38
39
|
persistLayout: (nextLayout: LayoutConfig) => void;
|
|
39
40
|
}): ContextMenuItem[] {
|
|
40
41
|
const research = instance.paneId === TICKER_RESEARCH_PANE_ID;
|
|
@@ -77,7 +78,15 @@ export function tickerLinkMenuItems({
|
|
|
77
78
|
});
|
|
78
79
|
};
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
// A source in another desktop window is not in this layout to list; the link can still be cut.
|
|
82
|
+
const remoteSymbol = sourceInstanceId && !findPaneInstance(layout, sourceInstanceId)
|
|
83
|
+
? resolveTickerForPane(state as AppState, instance.instanceId)
|
|
84
|
+
: null;
|
|
85
|
+
const remoteUnlink: ContextMenuItem[] = remoteSymbol
|
|
86
|
+
? [{ id: `unlink:${sourceInstanceId}`, label: "Unlink from Pane in Another Window", onSelect: () => unlink(remoteSymbol) }]
|
|
87
|
+
: [];
|
|
88
|
+
|
|
89
|
+
return [...remoteUnlink, ...layout.instances.flatMap((source): ContextMenuItem[] => {
|
|
81
90
|
if (source.instanceId === instance.instanceId || !isPaneInLayout(layout, source.instanceId)) return [];
|
|
82
91
|
const sourceDef = panes.get(source.paneId);
|
|
83
92
|
if (!sourceDef) return [];
|
|
@@ -111,5 +120,5 @@ export function tickerLinkMenuItems({
|
|
|
111
120
|
onSelect: () => unlink(symbol),
|
|
112
121
|
}]
|
|
113
122
|
: [];
|
|
114
|
-
});
|
|
123
|
+
})];
|
|
115
124
|
}
|
|
@@ -48,6 +48,8 @@ import { teamStore } from "../../team/store";
|
|
|
48
48
|
import { buildStatusBarTabGroups, groupIdFromMarkerValue, groupMarkerValue } from "./status-bar-groups";
|
|
49
49
|
import { requestFeedbackDialog } from "../feedback-dialog";
|
|
50
50
|
import { openFormModal } from "../form-modal";
|
|
51
|
+
import { getDesktopWindows, layoutMoveTargets } from "../../state/desktop-windows";
|
|
52
|
+
import { fireAndForget } from "../../utils/fire-and-forget";
|
|
51
53
|
import { recordFunctionOpen } from "../../telemetry/usage-counts";
|
|
52
54
|
import {
|
|
53
55
|
STATUS_WIDGET_COLUMNS,
|
|
@@ -362,6 +364,24 @@ export function StatusBar({ onOpenChangelog }: { onOpenChangelog?: (version: str
|
|
|
362
364
|
enabled: layouts.length > 1,
|
|
363
365
|
onSelect: () => requestDeleteLayout(index),
|
|
364
366
|
},
|
|
367
|
+
);
|
|
368
|
+
// The desktop app's other windows, where the tab can go.
|
|
369
|
+
const windows = getDesktopWindows();
|
|
370
|
+
const layoutId = layout.id;
|
|
371
|
+
if (windows && layoutId) {
|
|
372
|
+
const moves = layoutMoveTargets(windows, layouts.length);
|
|
373
|
+
if (moves.length > 0) items.push(contextMenuDivider("layout:window-divider"));
|
|
374
|
+
for (const move of moves) {
|
|
375
|
+
items.push({
|
|
376
|
+
id: `layout:move-to-window:${move.key}`,
|
|
377
|
+
label: move.label,
|
|
378
|
+
onSelect: () => {
|
|
379
|
+
fireAndForget(windows.moveLayout(layoutId, move.target), "desktop.moveLayoutToWindow");
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
items.push(
|
|
365
385
|
contextMenuDivider("layout:actions-divider"),
|
|
366
386
|
{
|
|
367
387
|
id: "layout:gallery",
|
|
@@ -27,6 +27,7 @@ export const KEEP_FREE_KEY = "f";
|
|
|
27
27
|
export const CONNECT_BROKER_KEY = "b";
|
|
28
28
|
export const BROWSER_SIGN_IN_KEY = "b";
|
|
29
29
|
export const SKIP_DESKS_KEY = "s";
|
|
30
|
+
export const SKIP_PORTFOLIO_KEY = "s";
|
|
30
31
|
|
|
31
32
|
/** Digits jump straight to a section the header would let you click. */
|
|
32
33
|
const SECTION_DIGITS: Record<string, OnboardingSectionId> = { "1": "portfolio", "2": "cloud", "3": "pro" };
|
|
@@ -54,7 +55,7 @@ export function keyReachesPastOnboardingModal(event: KeyEventLike, keybindings:
|
|
|
54
55
|
export function useOnboardingKeyboard({
|
|
55
56
|
stage, progress, account, helpFocused, editingField, isBrokerCommitting, planAccess, continueFree, finish,
|
|
56
57
|
sectionAvailability, goToSection, portfolioSub, positions, setEditingField, positionCount,
|
|
57
|
-
continueFromPositions, openBrokerConnect, movePositionCursor, removePositionAtCursor, submitBrokerField,
|
|
58
|
+
continueFromPositions, skipPositions, openBrokerConnect, movePositionCursor, removePositionAtCursor, submitBrokerField,
|
|
58
59
|
submitAccountField, backPortfolio, continuePortfolio, setPortfolioOptionIdx, activeBrokerFields,
|
|
59
60
|
brokerFieldIdx, setBrokerSelectIdx, brokerChoices, openBrokerGuide, chosenDesks, finishDesks,
|
|
60
61
|
setDeskCursor, deskCursor, setChosenDesks, continueAccount, skipSetup, primaryUpgradeAction,
|
|
@@ -76,6 +77,7 @@ export function useOnboardingKeyboard({
|
|
|
76
77
|
setEditingField: Dispatch<SetStateAction<boolean>>;
|
|
77
78
|
positionCount: number;
|
|
78
79
|
continueFromPositions: () => void;
|
|
80
|
+
skipPositions: () => void;
|
|
79
81
|
openBrokerConnect: () => void;
|
|
80
82
|
movePositionCursor: (delta: number) => void;
|
|
81
83
|
removePositionAtCursor: () => void;
|
|
@@ -165,6 +167,8 @@ export function useOnboardingKeyboard({
|
|
|
165
167
|
positions.focusField(tab && event.shift ? POSITION_FIELDS.length - 1 : 0);
|
|
166
168
|
} else if (letter(CONNECT_BROKER_KEY) && positionCount > 0) {
|
|
167
169
|
openBrokerConnect();
|
|
170
|
+
} else if (letter(SKIP_PORTFOLIO_KEY) && positionCount === 0) {
|
|
171
|
+
skipPositions();
|
|
168
172
|
} else if (!chord && (name === "up" || name === "k")) {
|
|
169
173
|
movePositionCursor(-1);
|
|
170
174
|
} else if (!chord && (name === "down" || name === "j")) {
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
CONNECT_BROKER_KEY,
|
|
50
50
|
BROWSER_SIGN_IN_KEY,
|
|
51
51
|
SKIP_DESKS_KEY,
|
|
52
|
+
SKIP_PORTFOLIO_KEY,
|
|
52
53
|
} from "./onboarding-keyboard";
|
|
53
54
|
import { useOnboardingBrokerFields, useOnboardingBrokerForm } from "./use-onboarding-broker-form";
|
|
54
55
|
import { useOnboardingProgress, useOnboardingWorkspace, useOnboardingCompletion } from "./use-onboarding-progress";
|
|
@@ -155,7 +156,7 @@ function useOnboardingWizard({ pluginRegistry, importBrokerPositions, onComplete
|
|
|
155
156
|
}, [portfolioSub, stage]);
|
|
156
157
|
const {
|
|
157
158
|
chosenDesks, setChosenDesks, deskCursor, setDeskCursor, buildingDesks, continueFromPositions,
|
|
158
|
-
finishDesks, handleBrokerSynced,
|
|
159
|
+
skipPositions, finishDesks, handleBrokerSynced,
|
|
159
160
|
} = useOnboardingWorkspace({
|
|
160
161
|
stateRef, pluginRegistry, dispatch, positions, setEditingField, saveProgressInBackground,
|
|
161
162
|
setPersistenceError, finishingRef, brokerOptions, selectedBrokerId, setPortfolioSub,
|
|
@@ -306,7 +307,7 @@ function useOnboardingWizard({ pluginRegistry, importBrokerPositions, onComplete
|
|
|
306
307
|
useOnboardingKeyboard({
|
|
307
308
|
stage, progress, account, helpFocused, editingField, isBrokerCommitting, planAccess, continueFree,
|
|
308
309
|
finish, sectionAvailability, goToSection, portfolioSub, positions, setEditingField, positionCount,
|
|
309
|
-
continueFromPositions, openBrokerConnect, movePositionCursor, removePositionAtCursor, submitBrokerField,
|
|
310
|
+
continueFromPositions, skipPositions, openBrokerConnect, movePositionCursor, removePositionAtCursor, submitBrokerField,
|
|
310
311
|
submitAccountField, backPortfolio, continuePortfolio, setPortfolioOptionIdx, activeBrokerFields,
|
|
311
312
|
brokerFieldIdx, setBrokerSelectIdx, brokerChoices, openBrokerGuide, chosenDesks, finishDesks,
|
|
312
313
|
setDeskCursor, deskCursor, setChosenDesks, continueAccount, skipSetup, primaryUpgradeAction,
|
|
@@ -320,7 +321,7 @@ function useOnboardingWizard({ pluginRegistry, importBrokerPositions, onComplete
|
|
|
320
321
|
inputRef, editingField, selectedPositionSymbol, brokerChoices, portfolioOptionIdx, setPortfolioOptionIdx,
|
|
321
322
|
chooseBroker, activeBrokerFields, brokerFieldIdx, brokerSelectIdx, setBrokerSelectIdx, brokerValues,
|
|
322
323
|
setBrokerFieldValue, isBrokerSyncing, brokerSyncError, persistenceError, positionCount,
|
|
323
|
-
openBrokerConnect, continueFromPositions, backPortfolio, continuePortfolio, chosenDesks, deskCursor,
|
|
324
|
+
openBrokerConnect, continueFromPositions, skipPositions, backPortfolio, continuePortfolio, chosenDesks, deskCursor,
|
|
324
325
|
setDeskCursor, setChosenDesks, buildingDesks, finishDesks, account, viewportWidth, viewportHeight, continueAccount,
|
|
325
326
|
offer, planAccess, pricing, billingInterval, setBillingInterval, continueFree, primaryUpgradeAction,
|
|
326
327
|
goBack, rerun,
|
|
@@ -335,7 +336,7 @@ export function OnboardingWizard(props: OnboardingWizardProps) {
|
|
|
335
336
|
inputRef, editingField, selectedPositionSymbol, brokerChoices, portfolioOptionIdx, setPortfolioOptionIdx,
|
|
336
337
|
chooseBroker, activeBrokerFields, brokerFieldIdx, brokerSelectIdx, setBrokerSelectIdx, brokerValues,
|
|
337
338
|
setBrokerFieldValue, isBrokerSyncing, brokerSyncError, persistenceError, positionCount,
|
|
338
|
-
openBrokerConnect, continueFromPositions, backPortfolio, continuePortfolio, chosenDesks, deskCursor,
|
|
339
|
+
openBrokerConnect, continueFromPositions, skipPositions, backPortfolio, continuePortfolio, chosenDesks, deskCursor,
|
|
339
340
|
setDeskCursor, setChosenDesks, buildingDesks, finishDesks, account, viewportWidth, viewportHeight, continueAccount,
|
|
340
341
|
offer, planAccess, pricing, billingInterval, setBillingInterval, continueFree, primaryUpgradeAction,
|
|
341
342
|
goBack, rerun,
|
|
@@ -462,6 +463,16 @@ export function OnboardingWizard(props: OnboardingWizardProps) {
|
|
|
462
463
|
{brokerOptions.length > 0 && positionCount > 0 ? (
|
|
463
464
|
<OnboardingButton label="Connect a broker" variant="ghost" shortcut={CONNECT_BROKER_KEY} onPress={openBrokerConnect} />
|
|
464
465
|
) : null}
|
|
466
|
+
{/* Holding nothing yet, the step can be left as the Desks step can. */}
|
|
467
|
+
{positionCount === 0 ? (
|
|
468
|
+
<OnboardingButton
|
|
469
|
+
label="Skip"
|
|
470
|
+
variant="ghost"
|
|
471
|
+
shortcut={SKIP_PORTFOLIO_KEY}
|
|
472
|
+
disabled={positions.submitting}
|
|
473
|
+
onPress={skipPositions}
|
|
474
|
+
/>
|
|
475
|
+
) : null}
|
|
465
476
|
<OnboardingButton
|
|
466
477
|
label="Continue"
|
|
467
478
|
variant="primary"
|
|
@@ -61,14 +61,17 @@ function PreviewLine({ preview, error }: Pick<OnboardingPositionsState, "preview
|
|
|
61
61
|
const headline = getRegularSessionDisplay(preview.quote);
|
|
62
62
|
const price = headline?.price;
|
|
63
63
|
const change = headline?.changePercent;
|
|
64
|
+
// Only the name gives way to a narrow row, clipped on its right: the symbol, price and move keep every cell.
|
|
64
65
|
return (
|
|
65
66
|
<Box flexDirection="row" alignItems="center" minWidth={0} overflow="hidden">
|
|
66
|
-
<Text fg={colors.text} attributes={TextAttributes.BOLD}>{preview.symbol}</Text>
|
|
67
|
-
{preview.name ?
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
<Box flexShrink={0}><Text fg={colors.text} attributes={TextAttributes.BOLD}>{preview.symbol}</Text></Box>
|
|
68
|
+
{preview.name ? (
|
|
69
|
+
<Box flexShrink={1} minWidth={0} overflow="hidden" paddingLeft={2}><Text fg={colors.textDim}>{preview.name}</Text></Box>
|
|
70
|
+
) : null}
|
|
71
|
+
{price != null ? <Box flexShrink={0} paddingLeft={2}><Text fg={colors.text}>{formatMarketPrice(price, { maxWidth: 12 })}</Text></Box> : null}
|
|
72
|
+
{change != null ? <Box flexShrink={0} paddingLeft={1}><Text fg={shownPriceColor(change, 2, colors)}>{formatPercentRaw(change)}</Text></Box> : null}
|
|
70
73
|
{price != null && delay != null ? <Box flexShrink={0} paddingLeft={1}><DelayedMark minutes={delay} /></Box> : null}
|
|
71
|
-
{preview.duplicate ? <Text fg={colors.textMuted}>{t(" already added")}</Text> : null}
|
|
74
|
+
{preview.duplicate ? <Box flexShrink={0}><Text fg={colors.textMuted}>{t(" already added")}</Text></Box> : null}
|
|
72
75
|
</Box>
|
|
73
76
|
);
|
|
74
77
|
}
|
|
@@ -13,6 +13,7 @@ import type { useOnboardingPositions } from "./wizard-positions";
|
|
|
13
13
|
import {
|
|
14
14
|
applyFirstRunLayout,
|
|
15
15
|
buildFirstRunLayout,
|
|
16
|
+
FIRST_RUN_WATCHLIST,
|
|
16
17
|
onboardingDeskLayoutId,
|
|
17
18
|
planFirstRunWatchlist,
|
|
18
19
|
setupDeskPicks,
|
|
@@ -202,6 +203,24 @@ export function useOnboardingWorkspace({
|
|
|
202
203
|
});
|
|
203
204
|
}, [positions, saveProgressInBackground]);
|
|
204
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Leaves "What do you hold?" holding nothing, as the Desks step can be left
|
|
208
|
+
* picking nothing: the workspace is built around the first name on the
|
|
209
|
+
* first-run watchlist, and holdings can be added once it is open.
|
|
210
|
+
*/
|
|
211
|
+
const skipPositions = useCallback(() => {
|
|
212
|
+
if (positions.positions.length > 0) return;
|
|
213
|
+
setEditingField(false);
|
|
214
|
+
saveProgressInBackground({
|
|
215
|
+
stage: "desks",
|
|
216
|
+
path: "manual",
|
|
217
|
+
portfolioId: positions.portfolioId,
|
|
218
|
+
tickerSymbol: FIRST_RUN_WATCHLIST[0]!.ticker,
|
|
219
|
+
positionsImported: 0,
|
|
220
|
+
brokerName: undefined,
|
|
221
|
+
});
|
|
222
|
+
}, [positions, saveProgressInBackground]);
|
|
223
|
+
|
|
205
224
|
/**
|
|
206
225
|
* Leaves "What do you trade most?": builds the workspace with the picked desks as
|
|
207
226
|
* tabs (none when skipped, which is today's workspace) and moves on.
|
|
@@ -261,7 +280,7 @@ export function useOnboardingWorkspace({
|
|
|
261
280
|
|
|
262
281
|
return {
|
|
263
282
|
chosenDesks, setChosenDesks, deskCursor, setDeskCursor, buildingDesks, continueFromPositions,
|
|
264
|
-
finishDesks, handleBrokerSynced,
|
|
283
|
+
skipPositions, finishDesks, handleBrokerSynced,
|
|
265
284
|
};
|
|
266
285
|
}
|
|
267
286
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { memo, useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
ChartSurface,
|
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
useUiCapabilities,
|
|
8
8
|
} from "../../ui";
|
|
9
9
|
import { useThemeColors } from "../../theme/theme-context";
|
|
10
|
+
import { markPure } from "../../ui/same-props";
|
|
10
11
|
import type { PricePoint } from "../../types/financials";
|
|
11
12
|
import { resolveNativeBitmapSize, shouldRenderNativeBitmap } from "../chart/native/bitmap-support";
|
|
13
|
+
import { useNativeBitmapMetrics } from "../chart/native/use-bitmap-metrics";
|
|
12
14
|
import { renderSparklineBitmap } from "./bitmap";
|
|
13
15
|
import {
|
|
14
16
|
buildSamples,
|
|
@@ -90,10 +92,14 @@ function TerminalPriceSparkline({
|
|
|
90
92
|
}) {
|
|
91
93
|
const { nativeCharts, cellWidthPx = 8, cellHeightPx = 18, pixelRatio = 1 } = useUiCapabilities();
|
|
92
94
|
const nativeRenderer = useNativeRenderer();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
// Subscribed, not read off the renderer: the sparkline skips the renders a
|
|
96
|
+
// quote gives its row, so a resize or a late pixel size has to reach it.
|
|
97
|
+
const {
|
|
98
|
+
resolution: rendererResolution,
|
|
99
|
+
capabilities: rendererCapabilities,
|
|
100
|
+
terminalWidth: rendererTerminalWidth,
|
|
101
|
+
terminalHeight: rendererTerminalHeight,
|
|
102
|
+
} = useNativeBitmapMetrics(nativeRenderer);
|
|
97
103
|
const bitmap = useMemo(() => {
|
|
98
104
|
if (values.length < 2 || !shouldRenderNativeBitmap(nativeRenderer, nativeCharts === true)) return null;
|
|
99
105
|
const bitmapSize = resolveNativeBitmapSize({
|
|
@@ -135,7 +141,9 @@ function TerminalPriceSparkline({
|
|
|
135
141
|
);
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
export
|
|
144
|
+
export const PriceSparkline = markPure(memo(PriceSparklineView));
|
|
145
|
+
|
|
146
|
+
function PriceSparklineView({
|
|
139
147
|
priceHistory,
|
|
140
148
|
width,
|
|
141
149
|
trend,
|
|
@@ -11,6 +11,8 @@ import { usePaneLinkMenuEntry } from "../../ui/external-link";
|
|
|
11
11
|
|
|
12
12
|
export interface TickerBadgeProps {
|
|
13
13
|
symbol: string;
|
|
14
|
+
/** The listing the chip stands for when it is not the symbol as written (`2330` is `2330:TWSE`): what it resolves, prices and opens. */
|
|
15
|
+
listing?: string;
|
|
14
16
|
status: TickerBadgeStatus;
|
|
15
17
|
quote: Quote | null;
|
|
16
18
|
liveQuote?: boolean;
|
|
@@ -37,6 +39,7 @@ const NATIVE_PRICE_OVER_RESTING_TEXT = { position: "absolute", inset: 0, overflo
|
|
|
37
39
|
|
|
38
40
|
export function TickerBadge({
|
|
39
41
|
symbol,
|
|
42
|
+
listing,
|
|
40
43
|
status,
|
|
41
44
|
quote,
|
|
42
45
|
liveQuote = true,
|
|
@@ -49,8 +52,9 @@ export function TickerBadge({
|
|
|
49
52
|
}: TickerBadgeProps) {
|
|
50
53
|
const registry = getSharedRegistry();
|
|
51
54
|
const { nativeContextMenu, nativePaneChrome } = useUiCapabilities();
|
|
52
|
-
const
|
|
53
|
-
const
|
|
55
|
+
const key = listing ?? symbol;
|
|
56
|
+
const ticker = typeof registry?.getTicker === "function" ? registry.getTicker(key) : null;
|
|
57
|
+
const financials = typeof registry?.getData === "function" ? registry.getData(key) : null;
|
|
54
58
|
const openTickerContextMenu = useTickerContextMenu({
|
|
55
59
|
ticker,
|
|
56
60
|
financials,
|
|
@@ -65,7 +69,7 @@ export function TickerBadge({
|
|
|
65
69
|
const { fg: color, bg: backgroundColor } = tickerBadgeColors(tone, hovered);
|
|
66
70
|
// An ambiguous symbol is worth opening: that is how the listing gets picked.
|
|
67
71
|
const interactive = status !== "loading";
|
|
68
|
-
usePaneLinkMenuEntry(interactive ? `ticker:${
|
|
72
|
+
usePaneLinkMenuEntry(interactive ? `ticker:${key}` : null, tf("Open {ticker}", { ticker: symbol }), () => onOpen(key));
|
|
69
73
|
|
|
70
74
|
return (
|
|
71
75
|
<Box paddingRight={trailingGap ? 1 : 0} flexShrink={0} justifyContent={nativePaneChrome ? "center" : undefined}>
|
|
@@ -95,7 +99,7 @@ export function TickerBadge({
|
|
|
95
99
|
event.stopPropagation?.();
|
|
96
100
|
event.preventDefault?.();
|
|
97
101
|
if (!interactive) return;
|
|
98
|
-
onOpen(
|
|
102
|
+
onOpen(key);
|
|
99
103
|
}}
|
|
100
104
|
onContextMenu={(event: any) => {
|
|
101
105
|
void openTickerContextMenu(event);
|
|
@@ -28,6 +28,16 @@ export interface TickerBadgeListProps {
|
|
|
28
28
|
* column of looked-up symbols can mix chips and bare words.
|
|
29
29
|
*/
|
|
30
30
|
listed?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The listing a symbol stands for when its own spelling names none: a
|
|
33
|
+
* number-only Asian listing (`2330`) reads as money, so the source's venue
|
|
34
|
+
* makes it `2330:TWSE`. The chip keeps the symbol as written and looks up,
|
|
35
|
+
* prices and opens the listing, as it does for any other ticker. `null`
|
|
36
|
+
* says the source names no listing the app can read: that symbol prints as
|
|
37
|
+
* plain text, as one whose lookup fails does, never as a chip of another
|
|
38
|
+
* look beside resolved ones. Symbols not listed here stand for themselves.
|
|
39
|
+
*/
|
|
40
|
+
listings?: Readonly<Record<string, string | null>>;
|
|
31
41
|
/** Opens a badge; by default the symbol is resolved and opened as a ticker link would be. */
|
|
32
42
|
onOpen?: (symbol: string) => void;
|
|
33
43
|
}
|
|
@@ -44,6 +54,7 @@ export function TickerBadgeList({
|
|
|
44
54
|
fallbackColor = colors.textBright,
|
|
45
55
|
liveQuote = true,
|
|
46
56
|
listed = false,
|
|
57
|
+
listings,
|
|
47
58
|
onOpen,
|
|
48
59
|
}: TickerBadgeListProps) {
|
|
49
60
|
const [hoveredSymbol, setHoveredSymbol] = useState<string | null>(null);
|
|
@@ -61,9 +72,11 @@ export function TickerBadgeList({
|
|
|
61
72
|
)),
|
|
62
73
|
[symbols],
|
|
63
74
|
);
|
|
75
|
+
/** What a symbol is looked up and opened by: its listing, else itself. */
|
|
76
|
+
const keyOf = (symbol: string): string => listings?.[symbol] ?? symbol;
|
|
64
77
|
const tickerTexts = useMemo(
|
|
65
|
-
() => (listed ? [] : named.map((symbol) => `$${symbol}`)),
|
|
66
|
-
[listed, named],
|
|
78
|
+
() => (listed ? [] : named.filter((symbol) => listings?.[symbol] !== null).map((symbol) => `$${listings?.[symbol] ?? symbol}`)),
|
|
79
|
+
[listed, listings, named],
|
|
67
80
|
);
|
|
68
81
|
/**
|
|
69
82
|
* Quotes are only worth fetching where they can be read. A column with no
|
|
@@ -99,23 +112,25 @@ export function TickerBadgeList({
|
|
|
99
112
|
return named.map((symbol) => {
|
|
100
113
|
const base = displayWidth(symbol);
|
|
101
114
|
const budget = base + Math.max(0, remaining);
|
|
115
|
+
const entry = catalog[listings?.[symbol] ?? symbol];
|
|
102
116
|
const chosen = getTickerBadgeText({
|
|
103
117
|
symbol,
|
|
104
|
-
status: badgeStatus(
|
|
105
|
-
quote:
|
|
118
|
+
status: badgeStatus(entry),
|
|
119
|
+
quote: entry?.quote ?? null,
|
|
106
120
|
liveQuote: liveQuotes,
|
|
107
121
|
maxTextWidth: budget,
|
|
108
122
|
});
|
|
109
123
|
remaining -= displayWidth(chosen) - base;
|
|
110
124
|
return budget;
|
|
111
125
|
});
|
|
112
|
-
}, [catalog, liveQuotes, named, slack]);
|
|
126
|
+
}, [catalog, listings, liveQuotes, named, slack]);
|
|
113
127
|
|
|
114
128
|
return (
|
|
115
129
|
<Box flexDirection="row" width={width} height={1} overflow="hidden">
|
|
116
130
|
{named.map((symbol, index) => {
|
|
117
|
-
const
|
|
118
|
-
|
|
131
|
+
const key = keyOf(symbol);
|
|
132
|
+
const entry = catalog[key];
|
|
133
|
+
if (entry?.status === "missing" || (!listed && listings?.[symbol] === null)) {
|
|
119
134
|
return (
|
|
120
135
|
<Box key={symbol} paddingRight={1} flexShrink={0}>
|
|
121
136
|
<Text fg={fallbackColor} attributes={TextAttributes.BOLD}>{symbol}</Text>
|
|
@@ -127,6 +142,7 @@ export function TickerBadgeList({
|
|
|
127
142
|
<TickerBadge
|
|
128
143
|
key={symbol}
|
|
129
144
|
symbol={symbol}
|
|
145
|
+
listing={listings?.[symbol] ?? undefined}
|
|
130
146
|
status={badgeStatus(entry)}
|
|
131
147
|
quote={liveQuotes ? entry?.quote ?? null : null}
|
|
132
148
|
liveQuote={liveQuotes}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { memo, type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import { Box, Text, useUiCapabilities } from "../../ui";
|
|
3
|
+
import { markPure } from "../../ui/same-props";
|
|
3
4
|
import { hoverBg } from "../../theme/colors";
|
|
4
5
|
import { useThemeColors } from "../../theme/theme-context";
|
|
5
6
|
import { displayWidth, padTo, truncateToDisplayWidth } from "../../utils/format";
|
|
6
7
|
import { ExternalLinkText, usePaneLinkMenuEntry } from "./external-link";
|
|
8
|
+
import { useAppLanguage } from "../../i18n/react";
|
|
7
9
|
|
|
8
10
|
/** One column of a ColumnGrid. */
|
|
9
11
|
export interface ColumnGridColumn {
|
|
@@ -209,7 +211,11 @@ export interface ColumnGridPairProps {
|
|
|
209
211
|
* the value right-aligned in the rest and cut from its end when it is too
|
|
210
212
|
* long, and its muted detail after it. The detail gives way before the value.
|
|
211
213
|
*/
|
|
212
|
-
export
|
|
214
|
+
export const ColumnGridPair = markPure(memo(ColumnGridPairView));
|
|
215
|
+
|
|
216
|
+
function ColumnGridPairView({ label, labelWidth, width, value, valueColor, detail, url }: ColumnGridPairProps) {
|
|
217
|
+
// A link's menu entry is worded in the app's language.
|
|
218
|
+
useAppLanguage();
|
|
213
219
|
const colors = useThemeColors();
|
|
214
220
|
const { nativePaneChrome } = useUiCapabilities();
|
|
215
221
|
const color = valueColor ?? colors.text;
|
|
@@ -258,11 +258,14 @@ export function resolveDataTableVisibleWindow<T>({
|
|
|
258
258
|
scrollTop,
|
|
259
259
|
virtualize,
|
|
260
260
|
}: DataTableVisibleWindowOptions<T>): DataTableVisibleWindow<T> {
|
|
261
|
+
// A viewport the renderer has not laid out yet reads 0 (a laid-out one is at
|
|
262
|
+
// least a row): a render before the first layout keeps the default window
|
|
263
|
+
// rather than drawing one row until the size change re-renders the table.
|
|
261
264
|
const viewportHeight = virtualize
|
|
262
265
|
? Math.max(
|
|
263
266
|
1,
|
|
264
267
|
Math.min(
|
|
265
|
-
measuredViewportHeight
|
|
268
|
+
measuredViewportHeight || Math.min(items.length, 16),
|
|
266
269
|
Math.max(1, Math.ceil(appViewportHeight)),
|
|
267
270
|
),
|
|
268
271
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useId, useMemo, useRef, useState, type ReactNode } from "react";
|
|
1
|
+
import { memo, useCallback, useEffect, useId, useMemo, useRef, useState, type ReactNode } from "react";
|
|
2
2
|
import { usePaneMenuItems, usePaneTabStripKeys } from "../layout/pane/footer/registration";
|
|
3
3
|
import type { ContextMenuItem } from "../../types/context-menu";
|
|
4
4
|
import { useShortcut } from "../../react/input";
|
|
@@ -66,7 +66,10 @@ export interface TabsProps {
|
|
|
66
66
|
|
|
67
67
|
const WHEEL_DELTA_PER_CELL = 8;
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
/** A pane re-renders on each quote; its tab strip only when the tabs or their state change. */
|
|
70
|
+
export const Tabs = memo(TabsView);
|
|
71
|
+
|
|
72
|
+
function TabsView({
|
|
70
73
|
tabs: rawTabs,
|
|
71
74
|
activeValue,
|
|
72
75
|
onSelect,
|
|
@@ -232,7 +232,8 @@ export function resolveTickerForPane(state: AppState, paneId: string, seen = new
|
|
|
232
232
|
if (seen.has(paneId)) return null;
|
|
233
233
|
seen.add(paneId);
|
|
234
234
|
const instance = findPaneInstance(state.config.layout, paneId);
|
|
235
|
-
|
|
235
|
+
// A pane in another desktop window: the ticker that window shows in it ("" while it shows none).
|
|
236
|
+
if (!instance) return state.linkedTickers?.[paneId] || null;
|
|
236
237
|
const cursorSymbol = getPaneState(state, paneId).cursorSymbol;
|
|
237
238
|
if (typeof cursorSymbol === "string" && cursorSymbol.trim()) return cursorSymbol;
|
|
238
239
|
return resolveTickerFromBinding(state, instance.binding, seen);
|
|
@@ -563,18 +564,26 @@ export function focusPaneState(state: AppState, paneId: string): AppState {
|
|
|
563
564
|
};
|
|
564
565
|
}
|
|
565
566
|
|
|
567
|
+
/** Panes in another desktop window that panes here follow: their links are not orphaned. */
|
|
568
|
+
export function linkedSourceIds(state: Pick<AppState, "linkedTickers">): ReadonlySet<string> | undefined {
|
|
569
|
+
return state.linkedTickers ? new Set(Object.keys(state.linkedTickers)) : undefined;
|
|
570
|
+
}
|
|
571
|
+
|
|
566
572
|
export function withFocusedPane(
|
|
567
573
|
state: AppState,
|
|
568
574
|
config: AppConfig,
|
|
569
575
|
options: {
|
|
570
576
|
paneState?: Record<string, PaneRuntimeState>;
|
|
571
577
|
focusedPaneId?: string | null;
|
|
578
|
+
/** Follow sources in another window; `state`'s own by default. */
|
|
579
|
+
externalSourceIds?: ReadonlySet<string>;
|
|
572
580
|
} = {},
|
|
573
581
|
): AppState {
|
|
574
582
|
const normalizedLayout = normalizePaneLayout(config.layout, {
|
|
575
583
|
// Keep a follower alive on its last symbol when its source pane is gone.
|
|
576
584
|
resolveOrphanSymbol: (instanceId) => resolveTickerForPane(state, instanceId),
|
|
577
585
|
pinOrphan: pinFollowingPane,
|
|
586
|
+
externalSourceIds: options.externalSourceIds ?? linkedSourceIds(state),
|
|
578
587
|
});
|
|
579
588
|
const nextConfig = normalizedLayout === config.layout
|
|
580
589
|
? config
|
|
@@ -604,11 +613,17 @@ export function withFocusedPane(
|
|
|
604
613
|
}
|
|
605
614
|
|
|
606
615
|
export function hydrateDesktopSnapshot(state: AppState, snapshot: DesktopSharedStateSnapshot): AppState {
|
|
607
|
-
|
|
616
|
+
const linkedTickers = snapshot.linkedTickers && Object.keys(snapshot.linkedTickers).length > 0
|
|
617
|
+
? snapshot.linkedTickers
|
|
618
|
+
: undefined;
|
|
619
|
+
const next = withFocusedPane({
|
|
608
620
|
...state,
|
|
609
621
|
paneState: snapshot.paneState,
|
|
610
622
|
brokerSyncErrors: snapshot.brokerSyncErrors ?? {},
|
|
611
623
|
focusedPaneId: snapshot.focusedPaneId,
|
|
612
624
|
statusBarVisible: snapshot.statusBarVisible,
|
|
613
|
-
|
|
625
|
+
// A follower whose source in another window just closed stays on the ticker it last had there.
|
|
626
|
+
linkedTickers: linkedTickers || state.linkedTickers ? { ...state.linkedTickers, ...linkedTickers } : undefined,
|
|
627
|
+
}, snapshot.config, { externalSourceIds: linkedSourceIds({ linkedTickers }) ?? new Set() });
|
|
628
|
+
return next.linkedTickers === linkedTickers ? next : { ...next, linkedTickers };
|
|
614
629
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getPanelFocusTarget,
|
|
16
16
|
getTopFloatingPaneId,
|
|
17
17
|
hydrateDesktopSnapshot,
|
|
18
|
+
linkedSourceIds,
|
|
18
19
|
nextRecentCommands,
|
|
19
20
|
nextRecentTickers,
|
|
20
21
|
reconcilePaneState,
|
|
@@ -32,6 +33,7 @@ export {
|
|
|
32
33
|
getEffectiveThemeId,
|
|
33
34
|
getFocusedCollectionId,
|
|
34
35
|
getFocusedTickerSymbol,
|
|
36
|
+
linkedSourceIds,
|
|
35
37
|
resolveCollectionForPane,
|
|
36
38
|
resolveTickerForPane,
|
|
37
39
|
syncConfigActiveLayoutState,
|
|
@@ -81,6 +81,11 @@ export interface AppState {
|
|
|
81
81
|
focusedPaneId: string | null;
|
|
82
82
|
previousFocusedPaneId: string | null;
|
|
83
83
|
paneState: Record<string, PaneRuntimeState>;
|
|
84
|
+
/**
|
|
85
|
+
* The tickers of panes in another desktop window that panes here follow,
|
|
86
|
+
* by pane id. Set by the desktop process; absent everywhere else.
|
|
87
|
+
*/
|
|
88
|
+
linkedTickers?: Record<string, string>;
|
|
84
89
|
recentTickers: string[];
|
|
85
90
|
commandBarOpen: boolean;
|
|
86
91
|
commandBarQuery: string;
|
|
@@ -287,6 +287,8 @@ export function sanitizeLayout(
|
|
|
287
287
|
value: unknown,
|
|
288
288
|
fallback: LayoutConfig,
|
|
289
289
|
chartMigration: LegacyChartMigrationContext = {},
|
|
290
|
+
/** Panes on other tabs a pane here may follow: on another desktop window, a link may cross tabs. */
|
|
291
|
+
externalSourceIds?: ReadonlySet<string>,
|
|
290
292
|
): LayoutConfig {
|
|
291
293
|
if (!isLayoutConfig(value)) {
|
|
292
294
|
return cloneLayout(fallback);
|
|
@@ -312,6 +314,7 @@ export function sanitizeLayout(
|
|
|
312
314
|
const normalized = normalizePaneLayout(layout, {
|
|
313
315
|
defaultFollowSourceInstanceId: getDefaultFollowSourceInstanceId(layout),
|
|
314
316
|
resolveOrphanSymbol: () => null,
|
|
317
|
+
externalSourceIds,
|
|
315
318
|
});
|
|
316
319
|
return removeUnreachablePaneInstances(normalized);
|
|
317
320
|
}
|