@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
|
@@ -103,6 +103,7 @@ import { perpetualDisplaySymbol, perpetualListing, perpetualVenueName } from "..
|
|
|
103
103
|
import { useColumnClock } from "../use-column-clock";
|
|
104
104
|
import { liveMarketCapitalization } from "../../../../market-data/quotes/live-valuation";
|
|
105
105
|
import { hasUnknownOptionMultiplier } from "../../../../portfolio/position-metrics";
|
|
106
|
+
import { sharePositionMetrics } from "../../../../portfolio/column-values";
|
|
106
107
|
import { withFuturesContractSizes } from "../../../../portfolio/futures-positions";
|
|
107
108
|
import { withPurchaseDateCostFx } from "../../../../portfolio/cost-fx";
|
|
108
109
|
import { usePortfolioFuturesTerms } from "./futures-terms";
|
|
@@ -124,6 +125,8 @@ const ALLOCATION_COLUMN_IDS = new Set(["weight", "drift", "trade", "trade_value"
|
|
|
124
125
|
const FOOTER_TOTALS_THROTTLE_MS = 250;
|
|
125
126
|
const WEIGHT_TOTAL_THROTTLE_MS = 1_000;
|
|
126
127
|
const DAY_MS = 86_400_000;
|
|
128
|
+
/** One fallback for every render: a fresh `{}` would read as a changed value each time. */
|
|
129
|
+
const NO_COLLECTION_SORTS: Record<string, CollectionSortPreference> = {};
|
|
127
130
|
|
|
128
131
|
export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
129
132
|
const activateTicker = useTickerSourceActivate();
|
|
@@ -139,7 +142,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
139
142
|
|
|
140
143
|
const [currentCollectionId, setCurrentCollectionId] = usePaneStateValue<string>("collectionId", paneCollection.collectionId ?? "");
|
|
141
144
|
const [committedCursorSymbol, setCommittedCursorSymbol] = usePaneStateValue<string | null>("cursorSymbol", null);
|
|
142
|
-
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts",
|
|
145
|
+
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts", NO_COLLECTION_SORTS);
|
|
143
146
|
const [cashDrawerExpanded, setCashDrawerExpanded] = usePaneStateValue<boolean>("cashDrawerExpanded", false);
|
|
144
147
|
const [, setViewMode] = usePaneSettingValue<PortfolioViewMode>("viewMode", "table");
|
|
145
148
|
|
|
@@ -322,11 +325,12 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
322
325
|
totalsCurrency,
|
|
323
326
|
valuationBasis,
|
|
324
327
|
]);
|
|
325
|
-
|
|
328
|
+
// Cells and sort keys share each row's position figures: the clock does not move them.
|
|
329
|
+
const columnContext: ColumnContext = useMemo(() => sharePositionMetrics({ ...baseColumnContext, now }, baseColumnContext), [baseColumnContext, now]);
|
|
326
330
|
// The order only follows the per-second clock when sorting by quote age;
|
|
327
331
|
// day-based columns read the day, which the day's start stands for.
|
|
328
332
|
const sortNow = activeSort.columnId === "latency" ? now : Math.floor(now / DAY_MS) * DAY_MS;
|
|
329
|
-
const sortContext: ColumnContext = useMemo(() => ({ ...baseColumnContext, now: sortNow }), [baseColumnContext, sortNow]);
|
|
333
|
+
const sortContext: ColumnContext = useMemo(() => sharePositionMetrics({ ...baseColumnContext, now: sortNow }, baseColumnContext), [baseColumnContext, sortNow]);
|
|
330
334
|
|
|
331
335
|
const candidateSortedTickers = useMemo(
|
|
332
336
|
() => sortTickers(tickers, financialsMap, activeSort, sortContext, columns),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useDataFrameWake } from "../../../market-data/frame-wake";
|
|
2
3
|
|
|
3
4
|
function sameDeps(left: readonly unknown[], right: readonly unknown[]): boolean {
|
|
4
5
|
return left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
|
|
@@ -8,7 +9,7 @@ interface ThrottledMemoState<T> {
|
|
|
8
9
|
value: T;
|
|
9
10
|
throttledDeps: readonly unknown[];
|
|
10
11
|
immediateDeps: readonly unknown[];
|
|
11
|
-
/**
|
|
12
|
+
/** When it last recomputed, on the market data clock (monotonic, so a wall-clock step cannot stall it). */
|
|
12
13
|
at: number;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,7 +17,8 @@ interface ThrottledMemoState<T> {
|
|
|
16
17
|
* useMemo whose recomputation for `throttledDeps` (quote-driven inputs) runs at
|
|
17
18
|
* most once per interval, during a render that is happening anyway. A change
|
|
18
19
|
* to `immediateDeps` (collection, currency, rates) recomputes at once. When the
|
|
19
|
-
* input stops changing inside the interval, one trailing render catches up
|
|
20
|
+
* input stops changing inside the interval, one trailing render catches up, in
|
|
21
|
+
* a market data frame, so it shares a commit with the quotes that frame brings.
|
|
20
22
|
*/
|
|
21
23
|
export function useThrottledMemo<T>(
|
|
22
24
|
compute: () => T,
|
|
@@ -25,13 +27,10 @@ export function useThrottledMemo<T>(
|
|
|
25
27
|
intervalMs: number,
|
|
26
28
|
): T {
|
|
27
29
|
const stateRef = useRef<ThrottledMemoState<T> | null>(null);
|
|
28
|
-
const
|
|
29
|
-
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
30
|
-
const [, forceRender] = useReducer((count: number) => count + 1, 0);
|
|
31
|
-
latestThrottledDepsRef.current = throttledDeps;
|
|
30
|
+
const clock = useDataFrameWake();
|
|
32
31
|
|
|
33
32
|
const state = stateRef.current;
|
|
34
|
-
const now =
|
|
33
|
+
const now = clock.now();
|
|
35
34
|
let pending = false;
|
|
36
35
|
if (!state || !sameDeps(state.immediateDeps, immediateDeps) || now - state.at >= intervalMs) {
|
|
37
36
|
if (!state || !sameDeps(state.immediateDeps, immediateDeps) || !sameDeps(state.throttledDeps, throttledDeps)) {
|
|
@@ -42,18 +41,10 @@ export function useThrottledMemo<T>(
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
timerRef.current = null;
|
|
49
|
-
const current = stateRef.current;
|
|
50
|
-
if (current && !sameDeps(current.throttledDeps, latestThrottledDepsRef.current)) forceRender();
|
|
51
|
-
}, wait);
|
|
44
|
+
// A render that caught up in the meantime (an input changed) drops the trailing one.
|
|
45
|
+
if (pending) clock.wakeAt(stateRef.current!.at + intervalMs);
|
|
46
|
+
else clock.cancel();
|
|
52
47
|
});
|
|
53
48
|
|
|
54
|
-
useEffect(() => () => {
|
|
55
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
49
|
return stateRef.current!.value;
|
|
59
50
|
}
|
|
@@ -293,6 +293,7 @@ export function ratingReasonSource(reason: NonNullable<AnalystRatingRecord["reas
|
|
|
293
293
|
try {
|
|
294
294
|
return new URL(reason.url).hostname.replace(/^www\./, "");
|
|
295
295
|
} catch {
|
|
296
|
+
// Intentional ignore: a malformed link has no site to name, so it reads as source.
|
|
296
297
|
return "source";
|
|
297
298
|
}
|
|
298
299
|
}
|
|
@@ -22,6 +22,7 @@ import { ProWall, SignInWall } from "../cloud/auth-actions";
|
|
|
22
22
|
import { useCloudPlanAction, useCloudUpgradeAction } from "../shared/cloud-upgrade";
|
|
23
23
|
import { usePlanAccess } from "../../../api-client/plan-access";
|
|
24
24
|
import { useBoundTicker } from "../shared/ticker-request";
|
|
25
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
25
26
|
|
|
26
27
|
const FOOTER_ID = "equity-diagnostic";
|
|
27
28
|
/** Width of the "Observed"/"Reading" label column before the layout stacks. */
|
|
@@ -519,7 +520,7 @@ export function EquityDiagnosticView({ focused, width, height }: {
|
|
|
519
520
|
}).then((sourceId) => {
|
|
520
521
|
const source = sources.find((entry) => entry.id === sourceId);
|
|
521
522
|
if (source) void rendererHost.openExternal(source.url);
|
|
522
|
-
}).catch((
|
|
523
|
+
}).catch(logFailure("research.equity-diagnostic-pane", "Open diagnostic source choices failed"));
|
|
523
524
|
}, [dialog, rendererHost, sources]);
|
|
524
525
|
|
|
525
526
|
// The preview's pitch sits in the body, not an empty state, so its buttons
|
|
@@ -170,6 +170,7 @@ export const researchModule: PluginModule = {
|
|
|
170
170
|
? options.symbols
|
|
171
171
|
: parseTickerListInput(options?.arg ?? context.activeTicker ?? "", MAX_RELATIVE_VALUATION_TICKERS);
|
|
172
172
|
} catch {
|
|
173
|
+
// Intentional ignore: a ticker list the parser rejects creates no pane.
|
|
173
174
|
return null;
|
|
174
175
|
}
|
|
175
176
|
return {
|
|
@@ -162,7 +162,7 @@ export function normalizeCapCurrency(value: string): string {
|
|
|
162
162
|
try {
|
|
163
163
|
known = Intl.supportedValuesOf("currency");
|
|
164
164
|
} catch {
|
|
165
|
-
//
|
|
165
|
+
// Intentional ignore: an older runtime lists no currencies, so the shape check stands alone.
|
|
166
166
|
}
|
|
167
167
|
if (!CURRENCY_CODE.test(code) || (known.length > 0 && !known.includes(code))) {
|
|
168
168
|
throw new Error(`Invalid --currency value "${value}". Use a three-letter currency code such as USD or EUR.`);
|
|
@@ -10,6 +10,7 @@ import { notATickerSymbol } from "../../../sources/provider-errors";
|
|
|
10
10
|
import { fetchScreen } from "../equity-screener/client";
|
|
11
11
|
import { loadHeadlessFinancials } from "../shared/headless-market-data";
|
|
12
12
|
import { loadFxLegs } from "./relative-valuation-currency";
|
|
13
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
13
14
|
|
|
14
15
|
/** The pane setting holding the peers chosen for its subject (`PeerSelection`), which the report reads back too. */
|
|
15
16
|
export const PEER_SELECTION_SETTING = "peerSelection";
|
|
@@ -438,7 +439,7 @@ export async function pickPeers(symbol: string, financials: TickerFinancials | n
|
|
|
438
439
|
let failure: string | null = null;
|
|
439
440
|
try {
|
|
440
441
|
const [capUsd, industryRows, coreRows] = await Promise.all([
|
|
441
|
-
subjectCapUsd(financials, ctx).catch((
|
|
442
|
+
subjectCapUsd(financials, ctx).catch(logFailure("research.relative-valuation-peers", "Read subject market cap for peers failed", null)),
|
|
442
443
|
screenRows([{ field: "industry", op: "in", value: [group.industry] }], ctx),
|
|
443
444
|
group.related ? screenRows([{ field: "symbol", op: "in", value: [...group.related.core] }], ctx) : Promise.resolve([]),
|
|
444
445
|
]);
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
RESEARCH_SEARCH_TEMPLATE_ID,
|
|
17
17
|
} from "./model";
|
|
18
18
|
import { parseMarkedSnippet } from "./snippet";
|
|
19
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Each hit costs two rows (title, then source and snippet), and the sheet now
|
|
@@ -123,7 +124,8 @@ function createCorpusSearchProvider(
|
|
|
123
124
|
signal,
|
|
124
125
|
);
|
|
125
126
|
hits = response.hits ?? [];
|
|
126
|
-
} catch {
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (!signal.aborted) logFailure("research-search.command-bar-search", "Search documents for command bar failed")(error);
|
|
127
129
|
return [];
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
import type { IssuerListingParams } from "../../../api-client/paths";
|
|
8
8
|
import { createPluginCache } from "../../../data/plugin-cache";
|
|
9
9
|
import { secListingKey } from "../../../utils/sec";
|
|
10
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Revenue by product, segment or region comes from Gloom Cloud, which reads
|
|
@@ -94,8 +95,8 @@ export function cachedRevenueBreakdown(
|
|
|
94
95
|
if (!cached) return null;
|
|
95
96
|
try {
|
|
96
97
|
return { payload: validateRevenueBreakdown(cached.data), stale: false, refreshError: null };
|
|
97
|
-
} catch {
|
|
98
|
-
return null;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return logFailure("revenue-breakdown.client", "Validate cached revenue breakdown failed", null)(error);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -3,6 +3,7 @@ import { resolveHeadlessInstrument } from "../shared/headless-market-data";
|
|
|
3
3
|
import { loadSeasonalityHistory } from "./client";
|
|
4
4
|
import { closedHistoryBarDay, formingHistoryBar } from "../ticker-detail/data-panes/history-bars";
|
|
5
5
|
import { MONTH_LABELS, projectSeasonality, projectWeekdays, TURN_OF_MONTH_LABELS } from "./model";
|
|
6
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
6
7
|
|
|
7
8
|
const percent = (digits: number) => (value: unknown) => typeof value === "number" ? `${(value * 100).toFixed(digits)}%` : "--";
|
|
8
9
|
const statColumns = (digits: number, countHeader: string) => [{ key: "mean", header: "Avg", format: percent(digits) },
|
|
@@ -50,7 +51,7 @@ export const seasonalityHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
50
51
|
// Monthly bars are dated by their month's first day, which is no close while the month runs.
|
|
51
52
|
const bar = model.asOf?.toISOString().slice(0, 10);
|
|
52
53
|
// The venue whose sessions say whether the month still runs: the key's, or for a bare symbol its quote's.
|
|
53
|
-
const quote = bar && !instrument.exchange ? await ctx.marketData.getQuote(instrument.symbol, "").catch((
|
|
54
|
+
const quote = bar && !instrument.exchange ? await ctx.marketData.getQuote(instrument.symbol, "").catch(logFailure("seasonality.headless", "Load seasonality quote failed", null)) : null;
|
|
54
55
|
const venue = instrument.exchange || quote?.listingExchangeName || quote?.exchangeName || undefined;
|
|
55
56
|
const forming = formingHistoryBar("1mo", bar, venue, Date.now());
|
|
56
57
|
const closed = forming ? null : closedHistoryBarDay("1mo", bar, venue, Date.now());
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
import { formatShortDate } from "../../../utils/datetime-format";
|
|
10
10
|
import { secFilingItemCodes } from "../../../utils/sec";
|
|
11
11
|
import { getFilingColumnText } from "./model";
|
|
12
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
12
13
|
|
|
13
14
|
const SEC_TEMPLATE_ID = "sec-pane";
|
|
14
15
|
const FILING_ROW_LIMIT = 4;
|
|
@@ -216,8 +217,8 @@ export function createSecFilingSearchProvider(
|
|
|
216
217
|
count: RECENT_FILING_COUNT,
|
|
217
218
|
});
|
|
218
219
|
filings = entry.data ?? entry.lastGoodData ?? [];
|
|
219
|
-
} catch {
|
|
220
|
-
return [];
|
|
220
|
+
} catch (error) {
|
|
221
|
+
return logFailure("sec.command-bar-search", "Load SEC filings for command bar search failed", [])(error);
|
|
221
222
|
}
|
|
222
223
|
if (signal.aborted) return [];
|
|
223
224
|
const now = deps.now();
|
|
@@ -23,6 +23,7 @@ import { mayBeUsEquityOrFundTicker, mayBeUsEquityTicker, secFilingItemCodes, US_
|
|
|
23
23
|
import { fundAbroadProfile, venueAbroad, type FundAbroadProfile } from "./fund-abroad";
|
|
24
24
|
import { listingAnnouncementsPage } from "../../../utils/exchange-announcements";
|
|
25
25
|
import { pricingSupplementTest } from "../../../utils/sec-filings";
|
|
26
|
+
import { formatInsiderName } from "../insider/display";
|
|
26
27
|
import { parseForm4Xml } from "../insider/insider-data";
|
|
27
28
|
import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
|
|
28
29
|
import {
|
|
@@ -63,7 +64,7 @@ import {
|
|
|
63
64
|
secIssuerLabel,
|
|
64
65
|
secReportedAcceptance,
|
|
65
66
|
} from "./model";
|
|
66
|
-
import { rowSummary, rowSummaryTarget } from "./row-summaries";
|
|
67
|
+
import { ownerNames, rowSummary, rowSummaryTarget } from "./row-summaries";
|
|
67
68
|
import { usePaneTickerIdentity } from "../../../state/hooks/pane-ticker";
|
|
68
69
|
import { createSecFilingSearchProvider, resetSecFilingFocusRequests, useSecFilingFocusRequest } from "./command-bar-search";
|
|
69
70
|
|
|
@@ -150,7 +151,7 @@ function buildForm4Detail(content: string | null, filing: SecFilingItem): string
|
|
|
150
151
|
if (!tx) return buildDetailBody(filing);
|
|
151
152
|
|
|
152
153
|
const lines: string[] = [];
|
|
153
|
-
lines.push(`Insider: ${tx.reportedName}`);
|
|
154
|
+
lines.push(`Insider: ${formatInsiderName(tx.reportedName)}`);
|
|
154
155
|
if (tx.title) lines.push(`Title: ${tx.title}`);
|
|
155
156
|
for (const [index, transaction] of transactions.entries()) {
|
|
156
157
|
if (transactions.length > 1) lines.push("", `Transaction ${index + 1}`);
|
|
@@ -172,6 +173,8 @@ function toFeedItems(
|
|
|
172
173
|
documentsError: string | null,
|
|
173
174
|
contentErrors: Map<string, string>,
|
|
174
175
|
): FeedDataTableItem[] {
|
|
176
|
+
// A Form 144 names its seller freely; the insider forms read beside it say which way round.
|
|
177
|
+
const knownOwners = filings.flatMap((filing) => ownerNames(filing.form, contentCache.get(filing.accessionNumber)));
|
|
175
178
|
return filings.map((filing) => {
|
|
176
179
|
const displayTitle = getFilingDisplayTitle(filing);
|
|
177
180
|
const acceptedAt = secReportedAcceptance(filing);
|
|
@@ -186,7 +189,7 @@ function toFeedItems(
|
|
|
186
189
|
// An insider form read once says who traded and how, a fund's 24F-2NT its
|
|
187
190
|
// year's flows; the row says it too.
|
|
188
191
|
const summaryTarget = rowSummaryTarget(filing);
|
|
189
|
-
const readSummary = summaryTarget ? rowSummary(filing.form, contentCache.get(summaryTarget.accessionNumber)) : null;
|
|
192
|
+
const readSummary = summaryTarget ? rowSummary(filing.form, contentCache.get(summaryTarget.accessionNumber), knownOwners) : null;
|
|
190
193
|
const form4Detail = isOwnership && hasFetchedContent
|
|
191
194
|
? buildForm4Detail(fetchedContent ?? null, filing)
|
|
192
195
|
: null;
|
|
@@ -413,7 +416,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
|
|
|
413
416
|
const filing = visibleFilings.find((candidate) => candidate.accessionNumber === item.id);
|
|
414
417
|
if (!coordinator || !filing) return;
|
|
415
418
|
if (coordinator.getSecDocumentsEntry(filing.accessionNumber).phase !== "idle") return;
|
|
416
|
-
void coordinator.loadSecFilingDocuments(filing).catch(() => {});
|
|
419
|
+
void coordinator.loadSecFilingDocuments(filing).catch(() => { /* Intentional ignore: the coordinator keeps a failed warm-up's error, which the filing shows when opened. */ });
|
|
417
420
|
}, [visibleFilings]);
|
|
418
421
|
|
|
419
422
|
const refresh = useCallback(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SecFilingItem } from "../../../types/data-provider";
|
|
2
2
|
import { decodeHtmlEntities } from "../../../utils/html-entities";
|
|
3
3
|
import { formatCompact } from "../../../utils/format";
|
|
4
|
+
import { formatFreeformPersonName, formatInsiderName } from "../insider/display";
|
|
4
5
|
import { parseForm4Xml, transactionTypeLabel } from "../insider/insider-data";
|
|
5
6
|
import { buildInsiderTransactionTitle } from "./filing-display";
|
|
6
7
|
|
|
@@ -36,9 +37,20 @@ export function rowSummaryTarget(filing: SecFilingItem): SecFilingItem | null {
|
|
|
36
37
|
return { ...filing, accessionNumber: `${filing.accessionNumber}:${document}`, primaryDocument: document, primaryDocumentUrl: url, filingUrl: url };
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
return decodeHtmlEntities((match
|
|
40
|
+
function tagTexts(xml: string, tag: string): string[] {
|
|
41
|
+
const pattern = new RegExp(`<(?:[\\w.-]+:)?${tag}(?:\\s[^>]*)?>([\\s\\S]*?)<\\/(?:[\\w.-]+:)?${tag}\\s*>`, "gi");
|
|
42
|
+
return [...xml.matchAll(pattern)].map((match) => decodeHtmlEntities((match[1] ?? "").replace(/<[^>]*>/g, "").trim()));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const tagText = (xml: string, tag: string): string => tagTexts(xml, tag)[0] ?? "";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The reporting owners a Form 3, 4 or 5 names, spelled as filed ("COOK TIMOTHY D"):
|
|
49
|
+
* what a Form 144's free-text seller is recognised by, so one person reads alike on every row.
|
|
50
|
+
*/
|
|
51
|
+
export function ownerNames(form: string, content: string | null | undefined): string[] {
|
|
52
|
+
if (!content || !/^[345](?:\/A)?$/i.test(form.trim())) return [];
|
|
53
|
+
return tagTexts(content, "rptOwnerName").filter(Boolean);
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
const money = (value: number) => `$${formatCompact(value)}`;
|
|
@@ -47,9 +59,10 @@ const money = (value: number) => `$${formatCompact(value)}`;
|
|
|
47
59
|
* A Form 144 is a notice that someone means to sell: who, how many shares
|
|
48
60
|
* and what they were worth when it was filed.
|
|
49
61
|
*/
|
|
50
|
-
function form144Summary(xml: string): RowSummary | null {
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
62
|
+
function form144Summary(xml: string, knownOwners: readonly string[]): RowSummary | null {
|
|
63
|
+
const filedName = tagText(xml, "nameOfPersonForWhoseAccountTheSecuritiesAreToBeSold");
|
|
64
|
+
if (!filedName) return null;
|
|
65
|
+
const name = formatFreeformPersonName(filedName, knownOwners);
|
|
53
66
|
const shares = Number(tagText(xml, "noOfUnitsSold"));
|
|
54
67
|
const value = Number(tagText(xml, "aggregateMarketValue"));
|
|
55
68
|
const amount = [
|
|
@@ -62,7 +75,7 @@ function form144Summary(xml: string): RowSummary | null {
|
|
|
62
75
|
/** The reporting owner of a Form 3, which lists holdings and no transactions. */
|
|
63
76
|
function initialOwnershipSummary(xml: string): RowSummary | null {
|
|
64
77
|
const name = tagText(xml, "rptOwnerName");
|
|
65
|
-
return name ? { title: `${name}: initial holdings`, direction: null } : null;
|
|
78
|
+
return name ? { title: `${formatInsiderName(name)}: initial holdings`, direction: null } : null;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
const signedMoney = (value: number) => `${value < 0 ? "-" : "+"}${money(Math.abs(value))}`;
|
|
@@ -86,20 +99,23 @@ function fundFlowSummary(xml: string): RowSummary | null {
|
|
|
86
99
|
/**
|
|
87
100
|
* The row text of a filing whose content has been read, or null when it was
|
|
88
101
|
* not read or says nothing a row can use. An insider form with one
|
|
89
|
-
* transaction says it in full; one with several lists their kinds.
|
|
102
|
+
* transaction says it in full; one with several lists their kinds. Names read
|
|
103
|
+
* as the Insider table writes them; `knownOwners` (`ownerNames` of the
|
|
104
|
+
* insider forms read beside this one) tells a Form 144's seller which way round
|
|
105
|
+
* their name is filed.
|
|
90
106
|
*/
|
|
91
|
-
export function rowSummary(form: string, content: string | null | undefined): RowSummary | null {
|
|
107
|
+
export function rowSummary(form: string, content: string | null | undefined, knownOwners: readonly string[] = []): RowSummary | null {
|
|
92
108
|
if (!content) return null;
|
|
93
109
|
if (FUND_FLOW_FORM.test(form.trim())) return fundFlowSummary(content);
|
|
94
110
|
if (!isOwnershipForm(form)) return null;
|
|
95
111
|
const base = form.trim().replace(/\/A$/i, "");
|
|
96
|
-
if (base === "144") return form144Summary(content);
|
|
112
|
+
if (base === "144") return form144Summary(content, knownOwners);
|
|
97
113
|
const transactions = parseForm4Xml(content);
|
|
98
114
|
const first = transactions[0];
|
|
99
115
|
if (!first) return base === "3" ? initialOwnershipSummary(content) : null;
|
|
100
116
|
const codes = new Set(transactions.map((transaction) => transaction.transactionType));
|
|
101
117
|
const direction = codes.has("P") && !codes.has("S") ? "buy" : codes.has("S") && !codes.has("P") ? "sell" : null;
|
|
102
|
-
if (transactions.length === 1) return { title: `${first.reportedName}: ${buildInsiderTransactionTitle(first)}`, direction };
|
|
118
|
+
if (transactions.length === 1) return { title: `${formatInsiderName(first.reportedName)}: ${buildInsiderTransactionTitle(first)}`, direction };
|
|
103
119
|
const kinds = [...new Set(transactions.map((transaction) => transactionTypeLabel(transaction.transactionType)))];
|
|
104
|
-
return { title: `${first.reportedName}: ${transactions.length} transactions, ${kinds.join(", ")}`, direction };
|
|
120
|
+
return { title: `${formatInsiderName(first.reportedName)}: ${transactions.length} transactions, ${kinds.join(", ")}`, direction };
|
|
105
121
|
}
|
|
@@ -20,9 +20,17 @@ export interface SectorRowOutcome {
|
|
|
20
20
|
row: Partial<SectorRow> | null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The year of daily bars each fund's returns are read from, by fund. A load
|
|
25
|
+
* given one asks only for the funds it lacks and adds what it reads, so a
|
|
26
|
+
* refresh of the prices alone sends no history request.
|
|
27
|
+
*/
|
|
28
|
+
export type SectorHistories = Map<string, PricePoint[]>;
|
|
29
|
+
|
|
23
30
|
export async function loadSectorRows(
|
|
24
31
|
sectors: readonly SectorDef[],
|
|
25
32
|
provider: DataProvider,
|
|
33
|
+
options: { histories?: SectorHistories } = {},
|
|
26
34
|
): Promise<SectorRowOutcome[]> {
|
|
27
35
|
const quotes = new Map<string, Quote | null>();
|
|
28
36
|
if (provider.getQuotesBatch) {
|
|
@@ -41,10 +49,12 @@ export async function loadSectorRows(
|
|
|
41
49
|
}
|
|
42
50
|
}));
|
|
43
51
|
|
|
44
|
-
const histories = new Map(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
]
|
|
52
|
+
const histories: SectorHistories = options.histories ?? new Map();
|
|
53
|
+
// Funds whose history this load reads; a stored one is not asked again, nor for its boundary buffer.
|
|
54
|
+
const read = new Set(sectors.filter((sector) => !histories.get(sector.etf)?.length).map((sector) => sector.etf));
|
|
55
|
+
await Promise.all([...read].map(async (etf) => {
|
|
56
|
+
histories.set(etf, await provider.getPriceHistory(etf, "", "1Y").catch(logFailure("sectors", "Sector price history failed", [])));
|
|
57
|
+
}));
|
|
48
58
|
// The quotes as sent carry any pre-market or after-hours print, for its own column.
|
|
49
59
|
const sentQuotes = new Map(quotes);
|
|
50
60
|
// Pre-market quotes whose last completed session nothing confirms.
|
|
@@ -62,7 +72,7 @@ export async function loadSectorRows(
|
|
|
62
72
|
const datedQuotes = [...quoteDates].filter((entry): entry is [string, string] => entry[1] != null);
|
|
63
73
|
const confirmedQuotes = datedQuotes.filter(([symbol]) => !unconfirmed.has(symbol));
|
|
64
74
|
const asOfDate = [...(confirmedQuotes.length > 0 ? confirmedQuotes : datedQuotes).map(([, date]) => date),
|
|
65
|
-
...
|
|
75
|
+
...sectors.map((sector) => latestHistoryDate(histories.get(sector.etf) ?? []))]
|
|
66
76
|
.filter((date): date is string => date != null).sort().at(-1) ?? null;
|
|
67
77
|
|
|
68
78
|
const outcomes = await Promise.all(sectors.map(async (sector) => {
|
|
@@ -90,7 +100,7 @@ export async function loadSectorRows(
|
|
|
90
100
|
const quoteIssue = priceIssue ?? (changePercent == null ? "1D change unavailable" : null);
|
|
91
101
|
// A strict trailing request may begin after the prior year's weekend or
|
|
92
102
|
// holiday. Ask for a small boundary buffer when the provider supports it.
|
|
93
|
-
if (asOfDate && computeTrailingReturn(history, "1Y", price, asOfDate)?.value == null
|
|
103
|
+
if (read.has(sector.etf) && asOfDate && computeTrailingReturn(history, "1Y", price, asOfDate)?.value == null
|
|
94
104
|
&& provider.getDetailedPriceHistory) {
|
|
95
105
|
const start = new Date(`${sectorReturnTargetDate(asOfDate, "1Y")}T00:00:00Z`);
|
|
96
106
|
start.setUTCDate(start.getUTCDate() - SECTOR_RETURN_BASE_MAX_GAP_DAYS);
|
|
@@ -133,8 +143,8 @@ export async function loadSectorRows(
|
|
|
133
143
|
// These ETFs share a market calendar. A missing observation for one fund
|
|
134
144
|
// must not silently give it an earlier baseline than its peers. Use every
|
|
135
145
|
// reported baseline, independently of whether that fund has an ending price.
|
|
136
|
-
const sharedStartDate = (range: "1M" | "1Y") =>
|
|
137
|
-
.map((
|
|
146
|
+
const sharedStartDate = (range: "1M" | "1Y") => sectors
|
|
147
|
+
.map((sector) => sectorReturnStartDate(histories.get(sector.etf) ?? [], range, asOfDate))
|
|
138
148
|
.filter((date): date is string => !!date).sort().at(-1);
|
|
139
149
|
const monthStartDate = sharedStartDate("1M");
|
|
140
150
|
const yearStartDate = sharedStartDate("1Y");
|
|
@@ -4,7 +4,7 @@ import { DataTableView, usePaneFooter, usePaneNoticeFooter, usePaneTabs, type Da
|
|
|
4
4
|
import { handleRefreshKey, loadingErrorFooterInfo } from "../../../components/data-table/table-pane";
|
|
5
5
|
import type { PaneProps } from "../../../types/plugin";
|
|
6
6
|
import type { PluginModule } from "../plugin-module";
|
|
7
|
-
import { usePaneInstance, usePaneSettingValue } from "../../../state/app/context";
|
|
7
|
+
import { useAppSelector, usePaneInstance, usePaneSettingValue } from "../../../state/app/context";
|
|
8
8
|
import { colors, priceColor } from "../../../theme/colors";
|
|
9
9
|
import { formatCurrency, formatPercentRaw } from "../../../utils/format";
|
|
10
10
|
import { useAssetData, useDebouncedPluginPaneState, usePluginPaneState, usePluginTickerActions } from "../../runtime";
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
type SectorRowsByCollection,
|
|
47
47
|
type SectorSortPreference,
|
|
48
48
|
} from "./sector-model";
|
|
49
|
-
import { loadSectorRows } from "./client";
|
|
49
|
+
import { loadSectorRows, type SectorHistories } from "./client";
|
|
50
50
|
import { sectorsHeadless } from "./headless";
|
|
51
51
|
import { membersCache, themesCache } from "../themes/client";
|
|
52
52
|
import { themesHeadless } from "../themes/headless";
|
|
@@ -60,7 +60,9 @@ const NO_SAVED_ETFS: string[] = [];
|
|
|
60
60
|
* Prices, the day move and the returns stream; the year of history behind the
|
|
61
61
|
* returns only reloads on the app's research cadence. While the feed is not
|
|
62
62
|
* carrying a fund, the last load failed, or a fund printed in a session the
|
|
63
|
-
* board has not rolled to, the
|
|
63
|
+
* board has not rolled to, the quotes reload quietly at this pace, read
|
|
64
|
+
* against the history already loaded: outside regular hours that is all an
|
|
65
|
+
* open board asks for.
|
|
64
66
|
*/
|
|
65
67
|
const SECTOR_FALLBACK_REFRESH_MS = 60_000;
|
|
66
68
|
|
|
@@ -150,6 +152,9 @@ function EtfBoard({ collectionId, focused, width, height, rootBefore }: EtfBoard
|
|
|
150
152
|
);
|
|
151
153
|
|
|
152
154
|
const fetchGenRef = useRef(0);
|
|
155
|
+
const researchIntervalMinutes = useAppSelector((state) => state.config.refreshIntervalMinutes);
|
|
156
|
+
/** The history the last full load read, for the funds it was read for, which quote refreshes reuse. */
|
|
157
|
+
const historiesRef = useRef<{ funds: string; loadedAt: number; histories: SectorHistories } | null>(null);
|
|
153
158
|
const [loadError, setLoadError] = useState<string | null>(null);
|
|
154
159
|
|
|
155
160
|
const rows = useMemo(
|
|
@@ -223,6 +228,14 @@ function EtfBoard({ collectionId, focused, width, height, rootBefore }: EtfBoard
|
|
|
223
228
|
const gen = fetchGenRef.current;
|
|
224
229
|
const collectionId = activeCollection.id;
|
|
225
230
|
const sectorDefs = activeItems;
|
|
231
|
+
// A background refresh reads its quotes against the history already loaded
|
|
232
|
+
// for these funds, until that history is one research interval old.
|
|
233
|
+
const funds = sectorDefs.map((item) => item.etf).join(",");
|
|
234
|
+
const stored = historiesRef.current;
|
|
235
|
+
// The app's own research cadence (app-runtime): a minute at least, and an unreadable setting reloads.
|
|
236
|
+
const researchMs = Math.max(1, researchIntervalMinutes) * 60_000;
|
|
237
|
+
const reuse = background && stored?.funds === funds && Date.now() - stored.loadedAt < researchMs;
|
|
238
|
+
const histories: SectorHistories = reuse ? stored!.histories : new Map();
|
|
226
239
|
const updateRows = (updater: (rows: SectorRow[]) => SectorRow[]) => {
|
|
227
240
|
setRowsByCollection((prev) => updateRowsForCollection(prev, collectionId, sectorDefs, updater));
|
|
228
241
|
};
|
|
@@ -238,8 +251,9 @@ function EtfBoard({ collectionId, focused, width, height, rootBefore }: EtfBoard
|
|
|
238
251
|
|
|
239
252
|
if (!background) updateRows((rows) => rows.map((row) => ({ ...row, loading: true })));
|
|
240
253
|
|
|
241
|
-
loadSectorRows(sectorDefs, dataProvider).then((outcomes) => {
|
|
254
|
+
loadSectorRows(sectorDefs, dataProvider, { histories }).then((outcomes) => {
|
|
242
255
|
if (fetchGenRef.current !== gen) return;
|
|
256
|
+
if (!reuse) historiesRef.current = { funds, loadedAt: Date.now(), histories };
|
|
243
257
|
const loadedByEtf = new Map(outcomes.map((outcome) => [outcome.etf, outcome.row]));
|
|
244
258
|
updateRows((rows) => applySectorReload(rows, loadedByEtf, background));
|
|
245
259
|
|
|
@@ -253,7 +267,7 @@ function EtfBoard({ collectionId, focused, width, height, rootBefore }: EtfBoard
|
|
|
253
267
|
setLoadError("Sector data unavailable");
|
|
254
268
|
if (!background) updateRows(clearLoading);
|
|
255
269
|
});
|
|
256
|
-
}, [activeCollection.id, activeItems, dataProvider, setLastRefreshByCollection, setRowsByCollection]);
|
|
270
|
+
}, [activeCollection.id, activeItems, dataProvider, researchIntervalMinutes, setLastRefreshByCollection, setRowsByCollection]);
|
|
257
271
|
const fetchAll = useCallback(() => load(false), [load]);
|
|
258
272
|
const refreshInBackground = useCallback(() => load(true), [load]);
|
|
259
273
|
|
|
@@ -9,6 +9,7 @@ import { loadShortInterest, type ShortInterestResult } from "./client";
|
|
|
9
9
|
import { type CurrentFloat, type SettlementFloatStatistics, withPercentFloat } from "./model";
|
|
10
10
|
import { buildShortWatchRow, type ShortWatchRow } from "./watch-model";
|
|
11
11
|
import type { ShortInterestRecord } from "./types";
|
|
12
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
12
13
|
|
|
13
14
|
const CONCURRENCY = 6;
|
|
14
15
|
|
|
@@ -47,7 +48,7 @@ async function loadFloats(
|
|
|
47
48
|
): Promise<FloatSnapshot[]> {
|
|
48
49
|
const entries = await Promise.resolve()
|
|
49
50
|
.then(() => loadSnapshots(symbols.map((symbol) => ({ symbol, exchange: "" })), options))
|
|
50
|
-
.catch((
|
|
51
|
+
.catch(logFailure("short-interest.watch-client", "Load float snapshots failed", []));
|
|
51
52
|
return symbols.map((_symbol, index) => {
|
|
52
53
|
const entry = entries[index];
|
|
53
54
|
const fundamentals = (entry ? resolveEntryValue(entry) : null)?.fundamentals;
|
|
@@ -5,6 +5,7 @@ import type { SocialMentionDayPosts, SocialMentionPost, SocialMentionsPayload, S
|
|
|
5
5
|
import { createPluginCache, savedCopyForTransientFailure } from "../../../data/plugin-cache";
|
|
6
6
|
import { CLOUD_SESSION_REQUIRED } from "../shared/research-cloud-session";
|
|
7
7
|
import { unavailableOnServer } from "../shared/cloud-resource";
|
|
8
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
8
9
|
|
|
9
10
|
export const socialMentionsCache = createPluginCache<SocialMentionsPayload>({
|
|
10
11
|
kind: "social-mentions", source: "gloom-cloud", schemaVersion: 1,
|
|
@@ -71,7 +72,7 @@ export function cachedSocialMentions(symbol: string, range: SocialMentionsRange)
|
|
|
71
72
|
const cached = socialMentionsCache.get(cacheKey(symbol, range), { allowExpired: true });
|
|
72
73
|
if (!cached) return null;
|
|
73
74
|
try { return { payload: validateSocialMentions(cached.data, symbol, range), stale: false, refreshError: null }; }
|
|
74
|
-
catch { return null; }
|
|
75
|
+
catch (error) { return logFailure("social-mentions.client", "Validate cached social mentions failed", null)(error); }
|
|
75
76
|
}
|
|
76
77
|
export async function loadSocialMentions(symbol: string, range: SocialMentionsRange, force = false): Promise<SocialMentionsResource> {
|
|
77
78
|
// A refusal (a signed-out session, any other 4xx but 408 and 429) or a reply that fails validation shows as itself.
|
|
@@ -22,7 +22,7 @@ const date = (value: unknown) => text(value) && /^\d{4}-\d{2}-\d{2}$/.test(value
|
|
|
22
22
|
const timestamp = (value: unknown) => text(value) && Number.isFinite(Date.parse(value));
|
|
23
23
|
const tier = (value: unknown) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 6;
|
|
24
24
|
const claim = (value: unknown) => ["disclosed", "company_confirmed", "reported", "rumored"].includes(String(value));
|
|
25
|
-
const url = (value: unknown) => { try { return text(value) && ["http:", "https:"].includes(new URL(value).protocol); } catch { return false; } };
|
|
25
|
+
const url = (value: unknown) => { try { return text(value) && ["http:", "https:"].includes(new URL(value).protocol); } catch { /* Intentional ignore: malformed URLs fail this web link field validator. */ return false; } };
|
|
26
26
|
function evidence(value: SupplyEvidenceItem): boolean {
|
|
27
27
|
return !!value && text(value.id) && tier(value.tier) && claim(value.claimType) && url(value.url)
|
|
28
28
|
&& text(value.title) && text(value.publisher) && timestamp(value.publishedAt) && timestamp(value.fetchedAt)
|
|
@@ -70,7 +70,7 @@ export const supplyScreenshotEvidence: PaneScreenshotEvidenceHook<SupplyEvidence
|
|
|
70
70
|
// Return the validated payload: restricted quotes and glosses have been removed.
|
|
71
71
|
return { ...value, payload } as unknown as SupplyEvidence;
|
|
72
72
|
}
|
|
73
|
-
} catch { return null; }
|
|
73
|
+
} catch { /* Intentional ignore: invalid captured observations are rejected as evidence by returning null. */ return null; }
|
|
74
74
|
},
|
|
75
75
|
mismatches(evidence, { resolved, payload }) {
|
|
76
76
|
const settings = payload.config.layout.instances.find(entry => entry.instanceId === payload.paneId)?.settings;
|
|
@@ -26,6 +26,7 @@ import { isPlainKey } from "../../../utils/keyboard";
|
|
|
26
26
|
import { DATE_FIELD_EXAMPLES } from "../../../utils/calendar-date";
|
|
27
27
|
import { displayWidth } from "../../../utils/format";
|
|
28
28
|
import { useRemoteUiNode } from "../../../remote/semantic-tree";
|
|
29
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
29
30
|
|
|
30
31
|
const PATH_COLUMNS: DataTableColumn[] = [{ id: "route", label: "Route", width: 40, align: "left" }, { id: "relationships", label: "Relationships", width: 22, align: "left" }, { id: "hops", label: "Hops", width: 6, align: "right" }, { id: "score", label: "Score", width: 9, align: "right" }, { id: "confidence", label: "Confidence", width: 12, align: "right" }, { id: "exposure", label: "Estimated exposure", width: 35, align: "left" }];
|
|
31
32
|
const SOURCE_LABELS = { xbrl: "Structured filing", filing_text: "Filing text", press_release: "Company release", call: "Earnings call", news: "News", web: "Website", import: "Imported record" };
|
|
@@ -126,7 +127,7 @@ export function SupplyGraphPane({ symbol, tab, width, height, focused }: { symbo
|
|
|
126
127
|
const [visibleLinks, setVisibleLinks] = useState<string[]>([]);
|
|
127
128
|
const [inputsOpen, setInputsOpen] = useState(false);
|
|
128
129
|
const [snapshotSetting] = usePaneSettingValue<GraphPayload | null>("graphSnapshot", null);
|
|
129
|
-
const snapshot = useMemo(() => { try { return snapshotSetting ? validateGraph(snapshotSetting) : null; } catch { return null; } }, [snapshotSetting]);
|
|
130
|
+
const snapshot = useMemo(() => { try { return snapshotSetting ? validateGraph(snapshotSetting) : null; } catch (error) { return logFailure("supply-chain.graph-pane", "Validate supply chain graph snapshot failed", null)(error); } }, [snapshotSetting]);
|
|
130
131
|
const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadGraph(focus, target, options, accessKey, force), [focus, target, options, accessKey, snapshot]);
|
|
131
132
|
const resource = useAsyncResource(tab === "path" && !target ? null : loader, { initialData: () => cachedGraph(focus, target, options, accessKey), clearOnError: isAccessDenied });
|
|
132
133
|
const data = resource.data?.payload ?? null;
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
} from "./model";
|
|
37
37
|
import { RowEvidence } from "./row-evidence";
|
|
38
38
|
import { evidenceDate, evidenceLabel, isUnconfirmed, matchesSupplyOptions, supplyOptions, TIER_OPTIONS } from "./trust";
|
|
39
|
+
import { logFailure } from "../../../utils/log-failure";
|
|
39
40
|
|
|
40
41
|
type Item = { kind: "edge"; row: SupplyRow } | { kind: "locked"; id: string };
|
|
41
42
|
const itemId = (item: Item) => item.kind === "edge" ? item.row.id : item.id;
|
|
@@ -183,7 +184,7 @@ function SupplyView({ symbol, width, height, focused }: Pick<PaneProps, "width"
|
|
|
183
184
|
const accessKey = `${session.requestKey}:${access.hasProAccess ? "full" : "preview"}`;
|
|
184
185
|
const openUpgrade = useCloudUpgradeAction("splc");
|
|
185
186
|
const [snapshotSetting] = usePaneSettingValue<SupplyChainPayload | null>("supplySnapshot", null);
|
|
186
|
-
const snapshot = useMemo(() => { try { return snapshotSetting ? validateSupplyChain(snapshotSetting) : null; } catch { return null; } }, [snapshotSetting]);
|
|
187
|
+
const snapshot = useMemo(() => { try { return snapshotSetting ? validateSupplyChain(snapshotSetting) : null; } catch (error) { return logFailure("supply-chain.pane", "Validate supply chain snapshot failed", null)(error); } }, [snapshotSetting]);
|
|
187
188
|
const [openingTab] = usePaneSettingValue("tab", "table");
|
|
188
189
|
const [savedTab, setTab] = usePluginPaneState<string>("supply:tab", openingTab);
|
|
189
190
|
const graphTab = savedTab === "graph" || savedTab === "path";
|