@gloom-sh/terminal 0.19.3 → 0.19.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/package.json +4 -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/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +119 -27
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +10 -6
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
- package/src/cli/desktop-pane-shot.ts +2 -1
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +17 -2
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +9 -1
- package/src/cli/pane-functions/headless.ts +7 -3
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/series-search.ts +4 -5
- package/src/components/chart/composite/panel-bitmap.ts +28 -2
- package/src/components/chart/composite/time-axis.ts +17 -2
- 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 +160 -28
- 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 +304 -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/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- package/src/components/quote-flash.ts +36 -32
- 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/events.ts +17 -1
- 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/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/hooks.tsx +43 -3
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/news/aggregator.ts +12 -1
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- package/src/plugins/builtin/bond-calculator/math.ts +1 -1
- package/src/plugins/builtin/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -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/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -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/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/econ/calendar-model.ts +2 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/futures/series.ts +16 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +3 -2
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/index.tsx +7 -4
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/sectors/client.ts +18 -8
- package/src/plugins/builtin/sectors/index.tsx +19 -5
- package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- package/src/plugins/builtin/yield-curve/headless.ts +3 -1
- package/src/portfolio/column-values.ts +76 -10
- 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/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- package/src/renderers/dom/styles.css +32 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +6 -0
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/shares/portable-layout.ts +99 -2
- package/src/sources/provider-router/index.ts +9 -3
- package/src/sources/provider-router/sources.ts +26 -1
- package/src/sync/core-contributors.ts +18 -4
- package/src/time-series/price-units.ts +11 -0
- package/src/time-series/resolve.ts +12 -0
- package/src/types/config.ts +17 -1
- package/src/types/plugin.ts +6 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/fx-market-hours.ts +43 -0
|
@@ -55,6 +55,8 @@ import {
|
|
|
55
55
|
usePublishStatusWidgetRoom,
|
|
56
56
|
} from "./status-widget-space";
|
|
57
57
|
import { StarPromptStatusLine } from "../../app/star-prompt/status-line";
|
|
58
|
+
import { connectionHealth as sharedConnectionHealth, GLOOM_CLOUD_HTTP_CONNECTION_ID } from "../../core/connection-health";
|
|
59
|
+
import { DATA_SERVICE_UNREACHABLE_MESSAGE } from "../../utils/network-failure";
|
|
58
60
|
|
|
59
61
|
type StatusBarEvent = { stopPropagation?: () => void; preventDefault?: () => void };
|
|
60
62
|
type HoveredControl = string | null;
|
|
@@ -66,6 +68,14 @@ type SetHoveredControl = (updater: (current: HoveredControl) => HoveredControl)
|
|
|
66
68
|
*/
|
|
67
69
|
const DESKTOP_DOWNLOAD_URL = "https://gloom.sh/download/desktop";
|
|
68
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The note while the data service gives no answer at all, and its short form
|
|
73
|
+
* for a narrow terminal. Every pane's own failure says why; this says once,
|
|
74
|
+
* for the whole app, that it is the connection, and goes when it answers.
|
|
75
|
+
*/
|
|
76
|
+
const CONNECTION_NOTE = "Can't reach the data service";
|
|
77
|
+
const CONNECTION_NOTE_SHORT = "Offline";
|
|
78
|
+
|
|
69
79
|
type LayoutTabItem = {
|
|
70
80
|
label: string;
|
|
71
81
|
value: string;
|
|
@@ -88,6 +98,9 @@ type StatusBarViewProps = {
|
|
|
88
98
|
openChangelog?: (event?: StatusBarEvent) => void;
|
|
89
99
|
openLayoutContextMenu: (index: number, event: any) => void | Promise<unknown>;
|
|
90
100
|
rightAvailableWidth: number;
|
|
101
|
+
/** The connection note to show (CONNECTION_NOTE or its short form), or null while the data service answers. */
|
|
102
|
+
connectionNote: string | null;
|
|
103
|
+
openConnections: () => void;
|
|
91
104
|
setHoveredControl: SetHoveredControl;
|
|
92
105
|
showTidyWindows: boolean;
|
|
93
106
|
};
|
|
@@ -397,6 +410,17 @@ export function StatusBar({ onOpenChangelog }: { onOpenChangelog?: (version: str
|
|
|
397
410
|
onContextMenu: handleLayoutTabContextMenu,
|
|
398
411
|
}));
|
|
399
412
|
|
|
413
|
+
// Unreachable from the first request that got no answer until anything answers again.
|
|
414
|
+
const health = registry?.connectionHealth ?? sharedConnectionHealth;
|
|
415
|
+
const subscribeHealth = useCallback((onChange: () => void) => health.subscribe(onChange), [health]);
|
|
416
|
+
const dataServiceUnreachable = useSyncExternalStore(
|
|
417
|
+
subscribeHealth,
|
|
418
|
+
() => health.unreachableSince(GLOOM_CLOUD_HTTP_CONNECTION_ID) != null,
|
|
419
|
+
);
|
|
420
|
+
const openConnections = () => {
|
|
421
|
+
registry?.showPane("connections");
|
|
422
|
+
};
|
|
423
|
+
|
|
400
424
|
const claimedWidgetColumns = useClaimedStatusWidgetColumns();
|
|
401
425
|
const tidyWindowsKey = actionKey("tidy-windows");
|
|
402
426
|
const controlsWidth = (TERMINAL_NEW_LAYOUT_LABEL.length + 1)
|
|
@@ -413,6 +437,15 @@ export function StatusBar({ onOpenChangelog }: { onOpenChangelog?: (version: str
|
|
|
413
437
|
|
|
414
438
|
if (!statusBarVisible) return null;
|
|
415
439
|
|
|
440
|
+
// Feedback keeps the bottom-right corner; the connection note comes before
|
|
441
|
+
// the version chip, which gives way first, also to a widget that claimed
|
|
442
|
+
// more than the usual room. A narrow terminal shortens the note.
|
|
443
|
+
const rightWidth = Math.max(0, termWidth - leftWidth - STATUS_WIDGET_COLUMNS - claimedWidgetColumns - feedbackWidth);
|
|
444
|
+
const connectionNote = !dataServiceUnreachable ? null
|
|
445
|
+
: nativePaneChrome || rightWidth >= displayWidth(t(CONNECTION_NOTE)) + 1 ? CONNECTION_NOTE
|
|
446
|
+
: rightWidth >= displayWidth(t(CONNECTION_NOTE_SHORT)) + 1 ? CONNECTION_NOTE_SHORT : null;
|
|
447
|
+
const connectionNoteWidth = connectionNote && !nativePaneChrome ? displayWidth(t(connectionNote)) + 1 : 0;
|
|
448
|
+
|
|
416
449
|
const viewProps: StatusBarViewProps = {
|
|
417
450
|
activeLayoutIdx,
|
|
418
451
|
activeLayoutValue,
|
|
@@ -425,9 +458,9 @@ export function StatusBar({ onOpenChangelog }: { onOpenChangelog?: (version: str
|
|
|
425
458
|
layoutTabsWidth: tabsWidth,
|
|
426
459
|
openChangelog: onOpenChangelog ? openChangelog : undefined,
|
|
427
460
|
openLayoutContextMenu,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
461
|
+
rightAvailableWidth: Math.max(0, rightWidth - connectionNoteWidth),
|
|
462
|
+
connectionNote,
|
|
463
|
+
openConnections,
|
|
431
464
|
setHoveredControl,
|
|
432
465
|
showTidyWindows,
|
|
433
466
|
tidyWindowsKey,
|
|
@@ -464,6 +497,7 @@ function NativeStatusBar({
|
|
|
464
497
|
<NativeNewLayout />
|
|
465
498
|
{showTidyWindows && <NativeTidyWindows {...props} />}
|
|
466
499
|
<Box flexGrow={1} minWidth={0} />
|
|
500
|
+
<StatusBarConnectionNote nativePaneChrome {...props} />
|
|
467
501
|
<StatusBarSummary nativePaneChrome {...props} />
|
|
468
502
|
{/* Widgets keep their width; the layout tabs give way instead. */}
|
|
469
503
|
<Box flexShrink={0} flexDirection="row" alignItems="center" data-gloom-role="status-widgets">
|
|
@@ -496,6 +530,7 @@ function TerminalStatusBar({
|
|
|
496
530
|
<TerminalNewLayout {...props} />
|
|
497
531
|
{showTidyWindows && <TerminalTidyWindows {...props} />}
|
|
498
532
|
<Box flexGrow={1} minWidth={0} />
|
|
533
|
+
<StatusBarConnectionNote nativePaneChrome={false} {...props} />
|
|
499
534
|
<StatusBarSummary nativePaneChrome={false} {...props} />
|
|
500
535
|
<StarPromptStatusLine />
|
|
501
536
|
<PluginSlot name="status:widget" />
|
|
@@ -599,6 +634,33 @@ function StatusBarSummary({
|
|
|
599
634
|
);
|
|
600
635
|
}
|
|
601
636
|
|
|
637
|
+
/**
|
|
638
|
+
* Says the data service is unreachable while it is, in the warning tone a
|
|
639
|
+
* pane footer gives a failure; it opens Connections, which has the detail.
|
|
640
|
+
*/
|
|
641
|
+
function StatusBarConnectionNote({
|
|
642
|
+
connectionNote,
|
|
643
|
+
hoveredControl,
|
|
644
|
+
nativePaneChrome,
|
|
645
|
+
openConnections,
|
|
646
|
+
setHoveredControl,
|
|
647
|
+
}: Pick<StatusBarViewProps, "connectionNote" | "hoveredControl" | "openConnections" | "setHoveredControl"> & { nativePaneChrome: boolean }) {
|
|
648
|
+
if (!connectionNote) return null;
|
|
649
|
+
return (
|
|
650
|
+
<StatusBarChip
|
|
651
|
+
hoveredControl={hoveredControl}
|
|
652
|
+
id="connection"
|
|
653
|
+
label={t(connectionNote)}
|
|
654
|
+
nativePaneChrome={nativePaneChrome}
|
|
655
|
+
onPress={openConnections}
|
|
656
|
+
role="button"
|
|
657
|
+
setHoveredControl={setHoveredControl}
|
|
658
|
+
title={`${t(DATA_SERVICE_UNREACHABLE_MESSAGE)}. ${t("Open Connections")} (CONN)`}
|
|
659
|
+
tone="warning"
|
|
660
|
+
/>
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
602
664
|
/** Opens Send Feedback from the bottom-right corner, on every renderer. */
|
|
603
665
|
function StatusBarFeedback({
|
|
604
666
|
hoveredControl,
|
|
@@ -619,7 +681,10 @@ function StatusBarFeedback({
|
|
|
619
681
|
);
|
|
620
682
|
}
|
|
621
683
|
|
|
622
|
-
/**
|
|
684
|
+
/**
|
|
685
|
+
* Dim text at the row's right edge that lights up when it can be pressed; a
|
|
686
|
+
* `warning` one keeps the warning tone, as a footer's failure does.
|
|
687
|
+
*/
|
|
623
688
|
function StatusBarChip({
|
|
624
689
|
hoveredControl,
|
|
625
690
|
id,
|
|
@@ -629,6 +694,7 @@ function StatusBarChip({
|
|
|
629
694
|
role,
|
|
630
695
|
setHoveredControl,
|
|
631
696
|
title,
|
|
697
|
+
tone,
|
|
632
698
|
}: Pick<StatusBarViewProps, "hoveredControl" | "setHoveredControl"> & {
|
|
633
699
|
id: string;
|
|
634
700
|
label: string;
|
|
@@ -636,13 +702,16 @@ function StatusBarChip({
|
|
|
636
702
|
onPress?: (event?: StatusBarEvent) => void;
|
|
637
703
|
role: "button" | "link";
|
|
638
704
|
title?: string;
|
|
705
|
+
tone?: "warning";
|
|
639
706
|
}) {
|
|
640
707
|
const colors = useThemeColors();
|
|
641
708
|
const hovered = hoveredControl === id;
|
|
642
709
|
if (nativePaneChrome && onPress) {
|
|
643
710
|
return (
|
|
644
711
|
<Box paddingRight={1} flexShrink={0}>
|
|
645
|
-
<Button variant="plain" compact label={title ?? label} displayLabel={label} title={title} onPress={() => onPress()}
|
|
712
|
+
<Button variant="plain" compact label={title ?? label} displayLabel={tone ? undefined : label} title={title} onPress={() => onPress()}>
|
|
713
|
+
{tone ? <Text fg={colors[tone]}>{label}</Text> : undefined}
|
|
714
|
+
</Button>
|
|
646
715
|
</Box>
|
|
647
716
|
);
|
|
648
717
|
}
|
|
@@ -656,7 +725,7 @@ function StatusBarChip({
|
|
|
656
725
|
return (
|
|
657
726
|
<Box paddingRight={1} flexShrink={0}>
|
|
658
727
|
<Text
|
|
659
|
-
fg={hovered && press ? colors.text : colors.textDim}
|
|
728
|
+
fg={tone ? colors[tone] : hovered && press ? colors.text : colors.textDim}
|
|
660
729
|
{...(!nativePaneChrome ? { bg: hovered && press ? hoverBg(colors) : undefined } : {})}
|
|
661
730
|
title={press ? title : undefined}
|
|
662
731
|
aria-label={press ? title : undefined}
|
|
@@ -3,6 +3,7 @@ import { useCallback } from "react";
|
|
|
3
3
|
import { t } from "../../i18n";
|
|
4
4
|
import { useAppLanguage } from "../../i18n/react";
|
|
5
5
|
import { TITLEBAR_OVERLAY_HEIGHT_PX } from "./titlebar-overlay";
|
|
6
|
+
import { useWindowMaximized } from "./window-fullscreen";
|
|
6
7
|
|
|
7
8
|
const WINDOWS_CONTROL_SIZE_PX = TITLEBAR_OVERLAY_HEIGHT_PX;
|
|
8
9
|
export const WINDOWS_CONTROL_GROUP_WIDTH_PX = WINDOWS_CONTROL_SIZE_PX * 3;
|
|
@@ -47,58 +48,118 @@ function WindowControlIcon({ action }: { action: WindowControlAction }) {
|
|
|
47
48
|
);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The page covers the top of its window's frame, so the strip along its top
|
|
53
|
+
* stands in for the frame's top edge: a press there resizes the window, and at
|
|
54
|
+
* either end diagonally, as Windows does from a native frame.
|
|
55
|
+
*/
|
|
56
|
+
const TOP_EDGE_HEIGHT_PX = 4;
|
|
57
|
+
const TOP_CORNER_WIDTH_PX = 16;
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
useAppLanguage();
|
|
56
|
-
const rendererHost = useRendererHost();
|
|
59
|
+
type TopEdge = "top" | "top-left" | "top-right";
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
const TOP_EDGES: Array<{ edge: TopEdge; cursor: string; width?: number }> = [
|
|
62
|
+
{ edge: "top-left", cursor: "nwse-resize", width: TOP_CORNER_WIDTH_PX },
|
|
63
|
+
{ edge: "top", cursor: "ns-resize" },
|
|
64
|
+
{ edge: "top-right", cursor: "nesw-resize", width: TOP_CORNER_WIDTH_PX },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
function WindowTopEdge() {
|
|
68
|
+
const rendererHost = useRendererHost();
|
|
69
|
+
// A maximized window has no edge to pull, and its buttons must take a press
|
|
70
|
+
// at the screen's very top.
|
|
71
|
+
const maximized = useWindowMaximized();
|
|
72
|
+
const startResize = useCallback((edge: TopEdge, event: { stopPropagation?: () => void; preventDefault?: () => void }) => {
|
|
59
73
|
stopMouse(event);
|
|
60
|
-
void rendererHost.
|
|
74
|
+
void rendererHost.startWindowResize?.(edge);
|
|
61
75
|
}, [rendererHost]);
|
|
62
76
|
|
|
77
|
+
if (maximized) return null;
|
|
63
78
|
return (
|
|
64
79
|
<Box
|
|
65
80
|
flexDirection="row"
|
|
66
|
-
|
|
67
|
-
flexShrink={0}
|
|
68
|
-
width={`${WINDOWS_CONTROL_GROUP_WIDTH_PX}px`}
|
|
69
|
-
data-gloom-role="window-controls"
|
|
70
|
-
data-window-kind={windowKind}
|
|
71
|
-
aria-hidden={false}
|
|
81
|
+
data-gloom-role="window-top-edge"
|
|
72
82
|
style={{
|
|
73
83
|
position: "fixed",
|
|
74
84
|
top: 0,
|
|
85
|
+
left: 0,
|
|
75
86
|
right: 0,
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
zIndex: 1000,
|
|
80
|
-
backgroundColor: "inherit",
|
|
87
|
+
height: `${TOP_EDGE_HEIGHT_PX}px`,
|
|
88
|
+
// Over the buttons too: a native frame's top edge runs above them.
|
|
89
|
+
zIndex: 1001,
|
|
81
90
|
}}
|
|
82
91
|
>
|
|
83
|
-
{
|
|
92
|
+
{TOP_EDGES.map(({ edge, cursor, width }) => (
|
|
84
93
|
<Box
|
|
85
|
-
key={
|
|
86
|
-
alignItems="center"
|
|
87
|
-
justifyContent="center"
|
|
88
|
-
flexShrink={0}
|
|
89
|
-
width={`${WINDOWS_CONTROL_SIZE_PX}px`}
|
|
94
|
+
key={edge}
|
|
90
95
|
height="100%"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
>
|
|
99
|
-
<WindowControlIcon action={control.action} />
|
|
100
|
-
</Box>
|
|
96
|
+
flexGrow={width ? 0 : 1}
|
|
97
|
+
flexShrink={0}
|
|
98
|
+
width={width ? `${width}px` : undefined}
|
|
99
|
+
data-window-edge={edge}
|
|
100
|
+
style={{ cursor }}
|
|
101
|
+
onMouseDown={(event: { stopPropagation?: () => void; preventDefault?: () => void }) => startResize(edge, event)}
|
|
102
|
+
/>
|
|
101
103
|
))}
|
|
102
104
|
</Box>
|
|
103
105
|
);
|
|
104
106
|
}
|
|
107
|
+
|
|
108
|
+
interface WindowControlsProps {
|
|
109
|
+
windowKind?: "main" | "detached";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function WindowControls({ windowKind = "main" }: WindowControlsProps) {
|
|
113
|
+
useAppLanguage();
|
|
114
|
+
const rendererHost = useRendererHost();
|
|
115
|
+
|
|
116
|
+
const controlWindow = useCallback((action: WindowControlAction, event: { stopPropagation?: () => void; preventDefault?: () => void }) => {
|
|
117
|
+
stopMouse(event);
|
|
118
|
+
void rendererHost.controlWindow?.(action);
|
|
119
|
+
}, [rendererHost]);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
<WindowTopEdge />
|
|
124
|
+
<Box
|
|
125
|
+
flexDirection="row"
|
|
126
|
+
alignItems="stretch"
|
|
127
|
+
flexShrink={0}
|
|
128
|
+
width={`${WINDOWS_CONTROL_GROUP_WIDTH_PX}px`}
|
|
129
|
+
data-gloom-role="window-controls"
|
|
130
|
+
data-window-kind={windowKind}
|
|
131
|
+
aria-hidden={false}
|
|
132
|
+
style={{
|
|
133
|
+
position: "fixed",
|
|
134
|
+
top: 0,
|
|
135
|
+
right: 0,
|
|
136
|
+
// A popped-out window's title bar is its pane header, which ends in a
|
|
137
|
+
// 1px rule; the buttons stop above it so the rule runs the full width.
|
|
138
|
+
height: `${WINDOWS_CONTROL_SIZE_PX - (windowKind === "detached" ? 1 : 0)}px`,
|
|
139
|
+
zIndex: 1000,
|
|
140
|
+
backgroundColor: "inherit",
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
{WINDOWS_CONTROLS.map((control) => (
|
|
144
|
+
<Box
|
|
145
|
+
key={control.action}
|
|
146
|
+
alignItems="center"
|
|
147
|
+
justifyContent="center"
|
|
148
|
+
flexShrink={0}
|
|
149
|
+
width={`${WINDOWS_CONTROL_SIZE_PX}px`}
|
|
150
|
+
height="100%"
|
|
151
|
+
data-gloom-role="window-control"
|
|
152
|
+
data-window-control-action={control.action}
|
|
153
|
+
data-gloom-interactive="true"
|
|
154
|
+
role="button"
|
|
155
|
+
aria-label={t(control.labelKey)}
|
|
156
|
+
title={t(control.labelKey)}
|
|
157
|
+
onMouseDown={(event: { stopPropagation?: () => void; preventDefault?: () => void }) => controlWindow(control.action, event)}
|
|
158
|
+
>
|
|
159
|
+
<WindowControlIcon action={control.action} />
|
|
160
|
+
</Box>
|
|
161
|
+
))}
|
|
162
|
+
</Box>
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -30,3 +30,23 @@ function subscribeWindowFullscreen(listener: () => void): () => void {
|
|
|
30
30
|
export function useWindowFullscreen(): boolean {
|
|
31
31
|
return useSyncExternalStore(subscribeWindowFullscreen, isWindowFullscreen, () => false);
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
let windowMaximized = false;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether the window hosting this view is maximized. On Windows it then has
|
|
38
|
+
* no edge to resize from, and its buttons run to the screen's top edge.
|
|
39
|
+
*/
|
|
40
|
+
export function setWindowMaximized(next: boolean): void {
|
|
41
|
+
if (windowMaximized === next) return;
|
|
42
|
+
windowMaximized = next;
|
|
43
|
+
for (const listener of [...listeners]) listener();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isWindowMaximized(): boolean {
|
|
47
|
+
return windowMaximized;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function useWindowMaximized(): boolean {
|
|
51
|
+
return useSyncExternalStore(subscribeWindowFullscreen, isWindowMaximized, () => false);
|
|
52
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useEffect, useRef
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
2
|
import type { TickerFinancials } from "../types/financials";
|
|
3
3
|
import { getActiveQuoteDisplay } from "../market-data/market/status";
|
|
4
|
+
import { useDataFrameWake } from "../market-data/frame-wake";
|
|
4
5
|
|
|
5
6
|
export type QuoteFlashDirection = "up" | "down" | "flat";
|
|
6
7
|
|
|
@@ -99,47 +100,50 @@ function sameFlashes(left: Map<string, QuoteFlashDirection>, right: Map<string,
|
|
|
99
100
|
|
|
100
101
|
const EMPTY_FLASHES = new Map<string, QuoteFlashDirection>();
|
|
101
102
|
|
|
103
|
+
function sameDeps(left: readonly unknown[] | null, right: readonly unknown[]): boolean {
|
|
104
|
+
return !!left && left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The flashes to show. New prices are observed while rendering, so a price and
|
|
109
|
+
* its flash reach the screen in the same commit, and a flash ends in the first
|
|
110
|
+
* market data frame after it is due, with whatever quotes that frame brings:
|
|
111
|
+
* neither costs a commit (in the terminal, a full redraw) of its own.
|
|
112
|
+
*/
|
|
102
113
|
function useFlashTracker(
|
|
103
114
|
collect: (tracker: QuoteFlashTracker, now: number) => void,
|
|
104
115
|
enabled: boolean,
|
|
105
116
|
deps: readonly unknown[],
|
|
106
117
|
): Map<string, QuoteFlashDirection> {
|
|
107
|
-
const [flashes, setFlashes] = useState<Map<string, QuoteFlashDirection>>(EMPTY_FLASHES);
|
|
108
118
|
const trackerRef = useRef<QuoteFlashTracker | null>(null);
|
|
109
119
|
trackerRef.current ??= new QuoteFlashTracker();
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
const tracker = trackerRef.current;
|
|
121
|
+
const observedRef = useRef<readonly unknown[] | null>(null);
|
|
122
|
+
const shownRef = useRef<Map<string, QuoteFlashDirection>>(EMPTY_FLASHES);
|
|
123
|
+
const clock = useDataFrameWake();
|
|
124
|
+
|
|
125
|
+
const now = clock.now();
|
|
126
|
+
// Once per set of inputs: a render for any other reason (or a repeated one) observes nothing.
|
|
127
|
+
if (!sameDeps(observedRef.current, deps)) {
|
|
128
|
+
observedRef.current = deps;
|
|
129
|
+
collect(tracker, now);
|
|
130
|
+
}
|
|
131
|
+
let flashes = EMPTY_FLASHES;
|
|
132
|
+
if (!enabled) {
|
|
133
|
+
tracker.clear();
|
|
134
|
+
} else {
|
|
115
135
|
tracker.prune(now);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (nextAt != null) {
|
|
122
|
-
timeoutRef.current = setTimeout(publish, Math.max(0, nextAt - Date.now()));
|
|
123
|
-
}
|
|
124
|
-
};
|
|
136
|
+
const active = tracker.active(now);
|
|
137
|
+
flashes = sameFlashes(shownRef.current, active) ? shownRef.current : active.size === 0 ? EMPTY_FLASHES : active;
|
|
138
|
+
}
|
|
139
|
+
shownRef.current = flashes;
|
|
140
|
+
const endsAt = enabled ? tracker.nextChangeAt(now) : null;
|
|
125
141
|
|
|
142
|
+
// Booked after every render that still shows a flash.
|
|
126
143
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!enabled) {
|
|
131
|
-
tracker.clear();
|
|
132
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
133
|
-
timeoutRef.current = null;
|
|
134
|
-
setFlashes(EMPTY_FLASHES);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
publish();
|
|
138
|
-
}, [enabled, ...deps]);
|
|
139
|
-
|
|
140
|
-
useEffect(() => () => {
|
|
141
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
142
|
-
}, []);
|
|
144
|
+
if (endsAt != null) clock.wakeAt(endsAt);
|
|
145
|
+
else clock.cancel();
|
|
146
|
+
});
|
|
143
147
|
|
|
144
148
|
return flashes;
|
|
145
149
|
}
|
package/src/core/app-runtime.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MarketDataCoordinator, getSharedMarketDataCoordinator, setSharedMarketDataCoordinator } from "../market-data/coordinator";
|
|
2
|
+
import { followDataServiceHealth } from "../market-data/connection-follow";
|
|
2
3
|
import { NewsService, type NewsServiceOptions } from "../news/aggregator";
|
|
3
4
|
import { cloudNewsSession } from "../news/cloud-session";
|
|
4
5
|
import { getSharedNewsService, setSharedNewsService } from "../news/hooks";
|
|
@@ -59,6 +60,8 @@ export function createAppRuntime({
|
|
|
59
60
|
// Usage counts keep a mnemonic for these; a plugin installed later is not one of them.
|
|
60
61
|
rememberBuiltinPlugins(plugins.filter((plugin) => !externalPlugins?.some((entry) => entry.plugin === plugin)));
|
|
61
62
|
const marketData = new MarketDataCoordinator(dataProvider);
|
|
63
|
+
// What an outage failed loads again once the data service answers; prices read stale while their stream is down.
|
|
64
|
+
const stopFollowingHealth = followDataServiceHealth(pluginRegistry.connectionHealth, marketData);
|
|
62
65
|
const newsService = new NewsService({
|
|
63
66
|
connectionHealth: pluginRegistry.connectionHealth,
|
|
64
67
|
pollIntervalMs: () => Math.max(1, config.refreshIntervalMinutes) * 60_000,
|
|
@@ -95,7 +98,7 @@ export function createAppRuntime({
|
|
|
95
98
|
if (getSharedMarketDataCoordinator() === marketData) setSharedMarketDataCoordinator(null);
|
|
96
99
|
if (getSharedNewsService() === newsService) setSharedNewsService(null);
|
|
97
100
|
dispose(
|
|
98
|
-
disposeReady, () => newsService.stop(), () => marketData.destroy(),
|
|
101
|
+
disposeReady, () => newsService.stop(), stopFollowingHealth, () => marketData.destroy(),
|
|
99
102
|
// An async setup may still use persistence or contribute panes. Dispose it
|
|
100
103
|
// after setup settles, so it cannot write into a closed store or leak late contributions.
|
|
101
104
|
registering ? undefined : disposePlugins,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { errorMessage } from "../utils/errors";
|
|
2
|
+
import { logFailure } from "../utils/log-failure";
|
|
2
3
|
|
|
3
4
|
type ConnectionHealthKind = "asset-data" | "news" | "api" | "websocket" | "capability";
|
|
4
5
|
export type ConnectionHealthStatus = "idle" | "connecting" | "connected" | "disconnected" | "error";
|
|
@@ -33,6 +34,12 @@ export interface ConnectionHealthState extends ConnectionHealthSource {
|
|
|
33
34
|
socketState: ConnectionSocketState | null;
|
|
34
35
|
lastTransitionAt: number | null;
|
|
35
36
|
currentDetail: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Since when the service behind the source gave no answer at all (a refused
|
|
39
|
+
* connection, or one that hung with nothing back), while nothing it sent has
|
|
40
|
+
* come back since; null while it answers. See `reportReachability`.
|
|
41
|
+
*/
|
|
42
|
+
unreachableSince: number | null;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
export interface ConnectionHealthSnapshot {
|
|
@@ -60,6 +67,7 @@ export const GLOOM_CLOUD_FRED_CONNECTION_ID = "gloom-cloud-fred";
|
|
|
60
67
|
|
|
61
68
|
const MAX_RECENT_REQUESTS = 20;
|
|
62
69
|
const DEFAULT_REQUEST_STATUS_TTL_MS = 60_000;
|
|
70
|
+
const logRecoveryListenerFailure = logFailure("core.connection-health", "A recovery listener failed");
|
|
63
71
|
|
|
64
72
|
function socketStatus(state: ConnectionSocketState): ConnectionHealthStatus {
|
|
65
73
|
if (state === "open") return "connected";
|
|
@@ -82,6 +90,7 @@ export class ConnectionHealthRegistry {
|
|
|
82
90
|
private readonly sources = new Map<string, ConnectionHealthState>();
|
|
83
91
|
private readonly registrations = new Map<string, symbol>();
|
|
84
92
|
private readonly listeners = new Set<() => void>();
|
|
93
|
+
private readonly recoveryListeners = new Set<(sourceId: string) => void>();
|
|
85
94
|
private readonly external = new Map<string, ConnectionHealthState[]>();
|
|
86
95
|
private readonly now: () => number;
|
|
87
96
|
private readonly clock: () => number;
|
|
@@ -110,6 +119,7 @@ export class ConnectionHealthRegistry {
|
|
|
110
119
|
socketState: source.kind === "websocket" ? "idle" : null,
|
|
111
120
|
lastTransitionAt: null,
|
|
112
121
|
currentDetail: source.detail ?? null,
|
|
122
|
+
unreachableSince: null,
|
|
113
123
|
});
|
|
114
124
|
|
|
115
125
|
this.emit();
|
|
@@ -156,6 +166,63 @@ export class ConnectionHealthRegistry {
|
|
|
156
166
|
this.emit();
|
|
157
167
|
}
|
|
158
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Whether the service behind a source answers at all. A request refused, or
|
|
171
|
+
* hung with nothing back, makes it unreachable; the first answer of any kind
|
|
172
|
+
* after that makes it reachable again, and `subscribeRecovery` listeners
|
|
173
|
+
* hear of it, so what failed during the outage can be asked again.
|
|
174
|
+
*/
|
|
175
|
+
reportReachability(sourceId: string, reachable: boolean): void {
|
|
176
|
+
const source = this.sources.get(sourceId);
|
|
177
|
+
if (!source || (source.unreachableSince === null) === reachable) return;
|
|
178
|
+
this.sources.set(sourceId, { ...source, unreachableSince: reachable ? null : this.now() });
|
|
179
|
+
this.emit();
|
|
180
|
+
if (reachable) this.emitRecovery(sourceId);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Tells recovery listeners the source answers again. They run inside the
|
|
185
|
+
* request that brought the answer: one that throws must fail neither that
|
|
186
|
+
* request nor the listeners after it.
|
|
187
|
+
*/
|
|
188
|
+
private emitRecovery(sourceId: string): void {
|
|
189
|
+
for (const listener of [...this.recoveryListeners]) {
|
|
190
|
+
try {
|
|
191
|
+
listener(sourceId);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
logRecoveryListenerFailure(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Since when the source's service gave no answer at all, or null while it answers (`reportReachability`). */
|
|
199
|
+
unreachableSince(sourceId: string): number | null {
|
|
200
|
+
return this.peek(sourceId)?.unreachableSince ?? null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** A websocket source's state as last reported, or null for another kind of source or one not registered. */
|
|
204
|
+
socketState(sourceId: string): ConnectionSocketState | null {
|
|
205
|
+
return this.peek(sourceId)?.socketState ?? null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The source's state as `getSnapshot` shows it, without a copy: another
|
|
210
|
+
* process's (`replaceExternalSnapshot`) over this one's own.
|
|
211
|
+
*/
|
|
212
|
+
private peek(sourceId: string): ConnectionHealthState | null {
|
|
213
|
+
for (const external of this.external.values()) {
|
|
214
|
+
const source = external.find((entry) => entry.id === sourceId);
|
|
215
|
+
if (source) return source;
|
|
216
|
+
}
|
|
217
|
+
return this.sources.get(sourceId) ?? null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Called with the source's id each time its service answers again after it went unanswered. */
|
|
221
|
+
subscribeRecovery(listener: (sourceId: string) => void): () => void {
|
|
222
|
+
this.recoveryListeners.add(listener);
|
|
223
|
+
return () => this.recoveryListeners.delete(listener);
|
|
224
|
+
}
|
|
225
|
+
|
|
159
226
|
subscribe(listener: () => void): () => void {
|
|
160
227
|
this.listeners.add(listener);
|
|
161
228
|
return () => this.listeners.delete(listener);
|
|
@@ -182,8 +249,16 @@ export class ConnectionHealthRegistry {
|
|
|
182
249
|
}
|
|
183
250
|
|
|
184
251
|
replaceExternalSnapshot(namespace: string, snapshot: ConnectionHealthSnapshot): void {
|
|
185
|
-
this.external.
|
|
252
|
+
const previous = this.external.get(namespace) ?? [];
|
|
253
|
+
const next = snapshot.sources.map(cloneState);
|
|
254
|
+
this.external.set(namespace, next);
|
|
186
255
|
this.emit();
|
|
256
|
+
// Another process's service answering again is a recovery here too (the desktop app's data requests run in its backend).
|
|
257
|
+
for (const source of next) {
|
|
258
|
+
if (source.unreachableSince != null) continue;
|
|
259
|
+
if (previous.find((entry) => entry.id === source.id)?.unreachableSince == null) continue;
|
|
260
|
+
this.emitRecovery(source.id);
|
|
261
|
+
}
|
|
187
262
|
}
|
|
188
263
|
|
|
189
264
|
clearExternalSnapshot(namespace: string): void {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a ticker search's rows do, carried by its route (and by a launch request that opens one).
|
|
3
|
+
* Without one, Enter changes the focused pane's ticker (`layout/ticker-retarget.ts`).
|
|
4
|
+
*/
|
|
5
|
+
export type TickerSearchPayload = Readonly<Record<string, unknown>>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The ticker search DES opens: its rows open DES. So does every search that opens on a ticker
|
|
9
|
+
* rather than on a pane: plain `DES`, the listings of an ambiguous open, remote control's ticker
|
|
10
|
+
* mode. Only the backtick and a pane header's ticker search for the focused pane.
|
|
11
|
+
*/
|
|
12
|
+
export const SECURITY_DESCRIPTION_SEARCH: TickerSearchPayload = { action: "security-description" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compactFloatingZ, getDockLeafLayouts, getDockedPaneIds } from "../../../layout/pane-manager";
|
|
1
|
+
import { compactFloatingZ, getDockLeafLayouts, getDockedPaneIds, showDockTab } from "../../../layout/pane-manager";
|
|
2
2
|
import { pinFollowingPane } from "../../../layout/pane-follow";
|
|
3
3
|
import {
|
|
4
4
|
cloneLayout,
|
|
@@ -538,7 +538,8 @@ export function materializeDetachedLayouts(config: AppConfig): AppConfig {
|
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
export function focusPaneState(state: AppState, paneId: string): AppState {
|
|
541
|
-
|
|
541
|
+
// A tab of a stack is shown when it takes focus.
|
|
542
|
+
const layout = showDockTab(bringFloatingToFront(state.config.layout, paneId), paneId);
|
|
542
543
|
const config = layout !== state.config.layout ? { ...state.config, layout } : state.config;
|
|
543
544
|
const recentTickers = nextRecentTickers(
|
|
544
545
|
state.recentTickers,
|
|
@@ -586,7 +587,7 @@ export function withFocusedPane(
|
|
|
586
587
|
? (options.focusedPaneId ?? null)
|
|
587
588
|
: state.focusedPaneId;
|
|
588
589
|
const focusedPaneId = resolveFocusedPaneId(nextConfig.layout, requestedFocusedPaneId);
|
|
589
|
-
const focusedLayout = focusedPaneId ? bringFloatingToFront(nextConfig.layout, focusedPaneId) : nextConfig.layout;
|
|
590
|
+
const focusedLayout = focusedPaneId ? showDockTab(bringFloatingToFront(nextConfig.layout, focusedPaneId), focusedPaneId) : nextConfig.layout;
|
|
590
591
|
const focusedConfig = focusedLayout === nextConfig.layout ? nextConfig : { ...nextConfig, layout: focusedLayout };
|
|
591
592
|
const syncedConfig = syncConfigActiveLayoutState(focusedConfig, nextPaneState, focusedPaneId);
|
|
592
593
|
return {
|
|
@@ -4,6 +4,7 @@ import type { DesktopSharedStateSnapshot } from "../../../types/desktop-window";
|
|
|
4
4
|
import type { Quote, TickerFinancials } from "../../../types/financials";
|
|
5
5
|
import type { TickerRecord } from "../../../types/ticker";
|
|
6
6
|
import type { ReleaseInfo, UpdateProgress } from "../../../updater";
|
|
7
|
+
import type { TickerSearchPayload } from "./command-bar-launch";
|
|
7
8
|
|
|
8
9
|
export interface PaneRuntimeState {
|
|
9
10
|
cursorSymbol?: string | null;
|
|
@@ -33,6 +34,8 @@ interface CommandBarLaunchRequestBase {
|
|
|
33
34
|
interface CommandBarTickerSearchLaunchRequest extends CommandBarLaunchRequestBase {
|
|
34
35
|
kind: "ticker-search";
|
|
35
36
|
query?: string;
|
|
37
|
+
/** The search route's payload: `SECURITY_DESCRIPTION_SEARCH` opens DES rather than changing the focused pane. */
|
|
38
|
+
payload?: TickerSearchPayload;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -54,7 +57,7 @@ interface CommandBarAddListingLaunchRequest extends CommandBarLaunchRequestBase
|
|
|
54
57
|
|
|
55
58
|
/** Forms open in their own modal (`openFormModal`), so the bar launches only its own screens. */
|
|
56
59
|
type CommandBarLaunch =
|
|
57
|
-
| { kind: "ticker-search"; query?: string }
|
|
60
|
+
| { kind: "ticker-search"; query?: string; payload?: TickerSearchPayload }
|
|
58
61
|
| { kind: "run-query"; query: string }
|
|
59
62
|
| { kind: "add-listing"; collectionId: string; collectionKind: "watchlist" | "portfolio" };
|
|
60
63
|
|