@gloom-sh/terminal 0.20.9 → 0.20.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-client/auth.ts +6 -0
- package/src/api-client/data.ts +1 -0
- package/src/api-client/earnings.ts +15 -0
- package/src/api-client/index.ts +14 -3
- package/src/api-client/types/account.ts +10 -0
- package/src/api-client/types/billing.ts +10 -0
- package/src/api-client/types/econ.ts +19 -7
- package/src/api-client/types/market.ts +7 -0
- package/src/api-client/types/screener.ts +2 -0
- package/src/cli/commands/market.ts +18 -8
- package/src/cli/commands/overview.ts +26 -7
- package/src/cli/commands/ticker.ts +40 -15
- package/src/cli/desktop-pane-shot.ts +39 -0
- package/src/cli/errors.ts +20 -3
- package/src/cli/fx-pair.ts +11 -2
- package/src/cli/history-rows.ts +34 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +51 -13
- package/src/cli/pane-functions/headless.ts +4 -2
- package/src/cli/pane-functions/index.ts +1 -0
- package/src/cli/pane-functions/resolver.ts +2 -1
- package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
- package/src/cli/pane-functions/screenshot-types.ts +4 -0
- package/src/components/chart/composite/chart-layout.ts +7 -4
- package/src/components/chart/composite/composite-chart.tsx +6 -16
- package/src/components/chart/composite/toolbar.tsx +258 -82
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
- package/src/components/command-bar/list/model.ts +13 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
- package/src/components/command-bar/surface/index.tsx +10 -5
- package/src/components/command-bar/workflow/alert.ts +21 -7
- package/src/components/data-table/table-pane.ts +3 -1
- package/src/components/layout/pane/footer/model.ts +26 -1
- package/src/components/metric-treemap/heat-surface.tsx +2 -1
- package/src/components/metric-treemap/index.tsx +3 -2
- package/src/components/ui/confirm-dialog.tsx +253 -7
- package/src/components/ui/data-table/index.tsx +1 -1
- package/src/components/ui/data-table/types.ts +7 -0
- package/src/components/ui/list-view.tsx +4 -3
- package/src/components/ui/status.tsx +9 -6
- package/src/docs/snapshot.json +36 -0
- package/src/i18n/es.ts +12 -0
- package/src/i18n/ja.ts +12 -0
- package/src/i18n/ko.ts +12 -0
- package/src/i18n/zh-cn.ts +12 -0
- package/src/i18n/zh-tw.ts +12 -0
- package/src/market-data/fx-closes.ts +14 -2
- package/src/market-data/market/change-basis.ts +35 -1
- package/src/market-data/market/status.ts +37 -0
- package/src/market-data/performance.ts +4 -1
- package/src/market-data/quotes/live-valuation.ts +25 -2
- package/src/market-data/realized-volatility.ts +3 -0
- package/src/market-data/us-bond-market.ts +115 -0
- package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
- package/src/plugins/builtin/account-management/keyboard.ts +3 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +51 -5
- package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
- package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
- package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
- package/src/plugins/builtin/correlation/compute.ts +4 -3
- package/src/plugins/builtin/earnings/board-model.ts +33 -0
- package/src/plugins/builtin/earnings/board-table.ts +50 -11
- package/src/plugins/builtin/earnings/board.tsx +29 -13
- package/src/plugins/builtin/earnings/calendar.tsx +15 -3
- package/src/plugins/builtin/earnings/client.ts +4 -1
- package/src/plugins/builtin/earnings/headless.ts +27 -14
- package/src/plugins/builtin/econ/calendar-source.ts +3 -0
- package/src/plugins/builtin/help/index.tsx +1 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
- package/src/plugins/builtin/iv-history/headless.ts +12 -10
- package/src/plugins/builtin/macro-day/headless.ts +15 -5
- package/src/plugins/builtin/macro-day/model.ts +17 -4
- package/src/plugins/builtin/macro-day/releases.ts +36 -15
- package/src/plugins/builtin/market-halts/model.ts +3 -2
- package/src/plugins/builtin/market-movers/headless.ts +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +3 -2
- package/src/plugins/builtin/market-movers/model.ts +75 -22
- package/src/plugins/builtin/market-movers/screener.ts +2 -1
- package/src/plugins/builtin/market-movers/table.ts +7 -5
- package/src/plugins/builtin/pe-band/model.ts +4 -0
- package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
- package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- package/src/plugins/builtin/research/analyst-headless.ts +9 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
- package/src/plugins/builtin/research/client.ts +25 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +3 -13
- package/src/plugins/builtin/research/event-sources.ts +3 -1
- package/src/plugins/builtin/short-interest/headless.ts +2 -0
- package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
- package/src/plugins/builtin/yield-curve/headless.ts +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -0
- package/src/portfolio/column-values.ts +47 -14
- package/src/portfolio/return-metrics.ts +4 -2
- package/src/renderers/dom/host/image-surface.tsx +19 -9
- package/src/renderers/dom/host/input.tsx +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
- package/src/sources/provider-errors.ts +12 -0
- package/src/sources/provider-router/index.ts +12 -4
- package/src/state/pane-session.ts +145 -0
- package/src/tickers/search/home-listing.ts +44 -1
- package/src/tickers/search/index.ts +5 -2
- package/src/tickers/search/ranking.ts +7 -7
- package/src/tickers/us-listing.ts +11 -5
- package/src/time-series/base-series.ts +7 -1
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/series.ts +6 -0
- package/src/time-series/resolve.ts +1 -0
- package/src/types/financials.ts +20 -0
- package/src/types/headless.ts +9 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchanges.ts +13 -8
- package/src/utils/price-earnings.ts +17 -10
- package/src/utils/price-history-integrity.ts +15 -0
- package/src/utils/reason-codes.ts +79 -0
- package/src/utils/share-multiples.cases.json +889 -0
- package/src/utils/share-multiples.ts +254 -0
- package/src/utils/untrusted-text.ts +11 -0
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
ScrollBox,
|
|
27
27
|
Textarea,
|
|
28
28
|
TextAttributes,
|
|
29
|
+
useRendererHost,
|
|
29
30
|
useUiCapabilities,
|
|
30
31
|
type ScrollBoxRenderable,
|
|
31
32
|
type TextareaRenderable,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
import { useDialog, type AlertContext } from "../../../ui/dialog";
|
|
34
35
|
import type { SelectControl } from "../../../components/ui/select-button";
|
|
35
36
|
import { FRAMED_TEXTAREA_DESKTOP_STYLE, fieldFrameStyle } from "../../../components/ui/fields";
|
|
36
|
-
import { apiClient, type AccountProfile, type CloudPricing } from "../../../api-client";
|
|
37
|
+
import { apiClient, type AccountProfile, type CloudPricing, type ReferralInvite } from "../../../api-client";
|
|
37
38
|
import { chatController } from "../chat/controller";
|
|
38
39
|
import { SignInWall } from "../cloud/auth-actions";
|
|
39
40
|
import { loadUpgradeOffer } from "../../../account/upgrade-dialog";
|
|
@@ -72,6 +73,7 @@ import { DeleteAccountPasswordDialog, PasswordChangeDialog } from "./password-di
|
|
|
72
73
|
import { deleteAccountConfirmingSession } from "./delete-account";
|
|
73
74
|
import { endTrialAfterWarning } from "./trial-cancel";
|
|
74
75
|
import { CalendarAccountTab } from "./calendar-tab";
|
|
76
|
+
import { InviteRow } from "./invite-row";
|
|
75
77
|
import { useAccountManagementFooter } from "./footer";
|
|
76
78
|
import { useAccountManagementKeyboard } from "./keyboard";
|
|
77
79
|
import {
|
|
@@ -128,8 +130,8 @@ const ACCOUNT_TAB_FIELD_ORDER: Record<AccountManagementTab, AccountFieldKey[]> =
|
|
|
128
130
|
],
|
|
129
131
|
// Its actions are footer hints; the tab owns its footer.
|
|
130
132
|
calendar: [],
|
|
131
|
-
// Cancel Trial shows only while a trial runs.
|
|
132
|
-
pro: ["upgradeAction", "cancelTrialAction"],
|
|
133
|
+
// Cancel Trial shows only while a trial runs, the invite once it loaded.
|
|
134
|
+
pro: ["upgradeAction", "cancelTrialAction", "inviteCopyAction"],
|
|
133
135
|
// The Teams tab owns its own keyboard handling (a list, not form fields).
|
|
134
136
|
teams: [],
|
|
135
137
|
// Remote assistants allowed to drive this terminal; a list with its own footer.
|
|
@@ -230,6 +232,8 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
230
232
|
const [pricing, setPricing] = useState<CloudPricing | null>(null);
|
|
231
233
|
// Null until the server says; only a confirmed trial is offered.
|
|
232
234
|
const [trialAvailable, setTrialAvailable] = useState<boolean | null>(null);
|
|
235
|
+
// The Pro tab's invite link; null until it loads, and when it cannot.
|
|
236
|
+
const [invite, setInvite] = useState<ReferralInvite | null>(null);
|
|
233
237
|
const [draft, setDraft] = useState<AccountDraft>(() => profileToDraft(null));
|
|
234
238
|
const [activeTab, setActiveTab] = usePluginPaneState<AccountManagementTab>("activeTab", "profile");
|
|
235
239
|
const [activeField, setActiveField] = useState<AccountFieldKey>(
|
|
@@ -268,8 +272,9 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
268
272
|
if (field === "showLocalTime" || field === "showDesks") return chatCardSupported;
|
|
269
273
|
if (field === "desks") return chatCardSupported && draft.showDesks;
|
|
270
274
|
if (field === "cancelTrialAction") return planAccess.isTrialActive;
|
|
275
|
+
if (field === "inviteCopyAction") return invite !== null;
|
|
271
276
|
return true;
|
|
272
|
-
}), [activeTab, chatCardSupported, draft.showDesks, planAccess.isTrialActive]);
|
|
277
|
+
}), [activeTab, chatCardSupported, draft.showDesks, invite, planAccess.isTrialActive]);
|
|
273
278
|
const accountTabs = ACCOUNT_TAB_DEFS.map((tab) => ({ ...tab, label: t(tab.label) }));
|
|
274
279
|
|
|
275
280
|
const planPrice = useMemo(() => formatCloudMonthlyPrice(pricing), [language, pricing]);
|
|
@@ -519,6 +524,24 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
519
524
|
};
|
|
520
525
|
}, [sessionMarker]);
|
|
521
526
|
|
|
527
|
+
// The invite link is read when the Pro tab opens, and again for another
|
|
528
|
+
// account: one account's link must never show under another's.
|
|
529
|
+
const proTabOpen = activeTab === "pro";
|
|
530
|
+
useEffect(() => {
|
|
531
|
+
setInvite(null);
|
|
532
|
+
if (!proTabOpen || !apiClient.isSignedIn()) return;
|
|
533
|
+
let cancelled = false;
|
|
534
|
+
void apiClient.getReferralInvite()
|
|
535
|
+
.then((next) => {
|
|
536
|
+
if (!cancelled) setInvite(next);
|
|
537
|
+
})
|
|
538
|
+
// A server without invites, or a failed read, leaves the row out.
|
|
539
|
+
.catch(logFailure("account-management.pane", "Load invite link failed"));
|
|
540
|
+
return () => {
|
|
541
|
+
cancelled = true;
|
|
542
|
+
};
|
|
543
|
+
}, [proTabOpen, sessionMarker]);
|
|
544
|
+
|
|
522
545
|
useEffect(() => {
|
|
523
546
|
if (!hasSession || !apiClient.isSignedIn()) return;
|
|
524
547
|
if (syncStatus.phase !== "synced" || syncStatus.revision == null) return;
|
|
@@ -757,7 +780,7 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
757
780
|
const result = await endTrialAfterWarning(
|
|
758
781
|
dialog,
|
|
759
782
|
planAccess,
|
|
760
|
-
() => apiClient.endCloudTrial(),
|
|
783
|
+
(feedback) => apiClient.endCloudTrial(feedback),
|
|
761
784
|
() => {
|
|
762
785
|
setBusy("trial");
|
|
763
786
|
setMessage({ tone: "info", text: t("Ending trial...") });
|
|
@@ -784,6 +807,17 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
784
807
|
}
|
|
785
808
|
}, [busy, dialog, planAccess]);
|
|
786
809
|
|
|
810
|
+
const renderer = useRendererHost();
|
|
811
|
+
const copyInvite = useCallback(() => {
|
|
812
|
+
setActiveField("inviteCopyAction");
|
|
813
|
+
if (!invite) return;
|
|
814
|
+
void renderer.copyText(invite.url).then(
|
|
815
|
+
() => setMessage({ tone: "success", text: t("Link copied.") }),
|
|
816
|
+
// A terminal without clipboard access: the link is selectable on the row.
|
|
817
|
+
() => setMessage({ tone: "info", text: t("Copy failed. Select the link instead.") }),
|
|
818
|
+
);
|
|
819
|
+
}, [invite, renderer]);
|
|
820
|
+
|
|
787
821
|
useAccountManagementFooter({
|
|
788
822
|
busy,
|
|
789
823
|
// The Calendar and Agents tabs save nothing and show their own status.
|
|
@@ -799,6 +833,7 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
799
833
|
deleteAccount,
|
|
800
834
|
draftRef,
|
|
801
835
|
endTrial,
|
|
836
|
+
copyInvite,
|
|
802
837
|
fieldOrder,
|
|
803
838
|
// Behind the sign-in wall the fields are not there, and Enter is the wall's.
|
|
804
839
|
focused: focused && activeTab !== "teams" && activeTab !== "calendar" && activeTab !== "agents" && (hasSession || apiClient.isSignedIn()),
|
|
@@ -1053,6 +1088,17 @@ export function AccountManagementPane({ focused, width, height }: PaneProps) {
|
|
|
1053
1088
|
</Box>
|
|
1054
1089
|
) : null}
|
|
1055
1090
|
</Box>
|
|
1091
|
+
{invite ? (
|
|
1092
|
+
<InviteRow
|
|
1093
|
+
invite={invite}
|
|
1094
|
+
active={activeField === "inviteCopyAction"}
|
|
1095
|
+
width={contentWidth}
|
|
1096
|
+
labelWidth={formLabelWidth}
|
|
1097
|
+
nodeRef={fieldNodeRef("inviteCopyAction")}
|
|
1098
|
+
onCopy={copyInvite}
|
|
1099
|
+
onFocus={() => setActiveField("inviteCopyAction")}
|
|
1100
|
+
/>
|
|
1101
|
+
) : null}
|
|
1056
1102
|
</>
|
|
1057
1103
|
) : null}
|
|
1058
1104
|
|
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { confirmDialogWithAnswer } from "../../../components/ui/confirm-dialog";
|
|
2
2
|
import { formatTrialEnd } from "../../../account/billing";
|
|
3
3
|
import { t, tf } from "../../../i18n";
|
|
4
|
+
import { CLOUD_CANCEL_COMMENT_MAX } from "../../../api-client";
|
|
5
|
+
import type { CloudCancelFeedback, CloudCancelReason } from "../../../api-client";
|
|
4
6
|
import type { PlanAccess } from "../../../api-client/plan-rules";
|
|
5
7
|
import type { DialogApi } from "../../../ui/dialog";
|
|
6
8
|
|
|
9
|
+
/** The reasons gloom.sh's cancel window offers, in its words and order. */
|
|
10
|
+
const CANCEL_REASONS: ReadonlyArray<{ id: CloudCancelReason; label: string }> = [
|
|
11
|
+
{ id: "bugs", label: "Bugs or reliability" },
|
|
12
|
+
{ id: "missing_feature", label: "Missing feature" },
|
|
13
|
+
{ id: "too_expensive", label: "Too expensive" },
|
|
14
|
+
{ id: "not_using", label: "Not using it enough" },
|
|
15
|
+
{ id: "temporary", label: "Only needed it temporarily" },
|
|
16
|
+
{ id: "other", label: "Other" },
|
|
17
|
+
];
|
|
18
|
+
|
|
7
19
|
/**
|
|
8
20
|
* Ends a Pro trial the way the account page on gloom.sh does: first a warning
|
|
9
21
|
* that it ends the trial and Pro now, and only a confirmed answer reaches the
|
|
10
22
|
* server. Ending Pro cannot be undone, so a stray Enter keeps the trial; `y`
|
|
11
|
-
* or End Trial Now ends it.
|
|
12
|
-
*
|
|
23
|
+
* or End Trial Now ends it. The warning also asks why, as the cancel window
|
|
24
|
+
* on gloom.sh does, but nothing there is required and it adds no step: the
|
|
25
|
+
* reason and note picked go with the request, and none go when none were.
|
|
26
|
+
* Null when the person kept the trial, or when no trial is running (a stale
|
|
27
|
+
* key or click after it ended), which asks nothing.
|
|
13
28
|
*/
|
|
14
29
|
export async function endTrialAfterWarning(
|
|
15
30
|
dialog: DialogApi,
|
|
16
31
|
trial: Pick<PlanAccess, "isTrialActive" | "trialEndsAt">,
|
|
17
|
-
end: () => Promise<{ endedNow?: boolean }>,
|
|
32
|
+
end: (feedback: CloudCancelFeedback) => Promise<{ endedNow?: boolean }>,
|
|
18
33
|
onConfirmed?: () => void,
|
|
19
34
|
): Promise<{ endedNow: boolean } | null> {
|
|
20
35
|
if (!trial.isTrialActive) return null;
|
|
21
36
|
const date = formatTrialEnd(trial.trialEndsAt);
|
|
22
|
-
const
|
|
37
|
+
const answer = await confirmDialogWithAnswer(dialog, {
|
|
23
38
|
closeOnClickOutside: false,
|
|
24
39
|
title: t("Cancel Trial?"),
|
|
25
40
|
body: [
|
|
@@ -32,9 +47,19 @@ export async function endTrialAfterWarning(
|
|
|
32
47
|
cancelLabel: t("Keep Trial"),
|
|
33
48
|
confirmVariant: "danger",
|
|
34
49
|
defaultAction: "cancel",
|
|
50
|
+
question: {
|
|
51
|
+
label: "What made you decide to cancel? (optional)",
|
|
52
|
+
choices: CANCEL_REASONS,
|
|
53
|
+
notePlaceholder: "Anything else? (optional)",
|
|
54
|
+
noteMaxLength: CLOUD_CANCEL_COMMENT_MAX,
|
|
55
|
+
},
|
|
35
56
|
});
|
|
36
|
-
if (!
|
|
57
|
+
if (!answer) return null;
|
|
37
58
|
onConfirmed?.();
|
|
38
|
-
const
|
|
59
|
+
const reason = CANCEL_REASONS.find(({ id }) => id === answer.choice)?.id;
|
|
60
|
+
const result = await end({
|
|
61
|
+
...(reason ? { reason } : {}),
|
|
62
|
+
...(answer.note ? { comment: answer.note } : {}),
|
|
63
|
+
});
|
|
39
64
|
return { endedNow: result.endedNow === true };
|
|
40
65
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { apiClient } from "../../../../api-client";
|
|
2
|
+
import type { RemoteControlHandler } from "../../../../remote/app-host";
|
|
3
|
+
import type { AppState } from "../../../../state/app/context";
|
|
4
|
+
import type { AppConfig } from "../../../../types/config";
|
|
5
|
+
import { getCurrentPluginTarget } from "../../../current-target";
|
|
6
|
+
import { ASKGSessionController, type ASKGControllerManifest } from "./controller";
|
|
7
|
+
import { createASKGRendererToolExecutor, loadASKGClientManifest } from "./host";
|
|
8
|
+
import { attachedPaneContext, type ASKGAttachedPane } from "./pane-attachment";
|
|
9
|
+
import { ASKGUndoManager } from "./undo";
|
|
10
|
+
import { buildASKGUserData } from "./user-data";
|
|
11
|
+
|
|
12
|
+
const CLIENT_VERSION = "1";
|
|
13
|
+
|
|
14
|
+
function clientKind(): "tui" | "desktop" | "web" {
|
|
15
|
+
const target = getCurrentPluginTarget();
|
|
16
|
+
return target === "web" || target === "desktop" ? target : "tui";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What the pane that is mounted now gives the session; the pane writes it on every render. */
|
|
20
|
+
export interface ASKGPaneBindings {
|
|
21
|
+
config: AppConfig;
|
|
22
|
+
remoteHandler: RemoteControlHandler | null;
|
|
23
|
+
getAppState: () => AppState;
|
|
24
|
+
/** The ticker open beside the pane and the pane's own id, read when a question is sent. */
|
|
25
|
+
context: { symbol: string | null; paneId: string };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The conversation an Ask Gloom pane is in: the transcript on screen and the
|
|
30
|
+
* answer still coming in. It belongs to the pane, not to one drawing of it, so
|
|
31
|
+
* docking, floating or stacking the pane picks it up where it was instead of
|
|
32
|
+
* mounting an empty conversation and fetching the last one back.
|
|
33
|
+
*/
|
|
34
|
+
export interface ASKGPaneSession {
|
|
35
|
+
controller: ASKGSessionController;
|
|
36
|
+
bindings: ASKGPaneBindings;
|
|
37
|
+
/** The pane the conversation on screen is about, read whenever a question goes. */
|
|
38
|
+
attached: { current: ASKGAttachedPane | null };
|
|
39
|
+
/** Whether this pane has already looked for the conversation it showed before. */
|
|
40
|
+
restored: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createASKGPaneSession(initial: ASKGPaneBindings): ASKGPaneSession {
|
|
44
|
+
const bindings = { ...initial };
|
|
45
|
+
const attached: ASKGPaneSession["attached"] = { current: null };
|
|
46
|
+
// Each call and each undo gets a fresh executor, so the tokens live here:
|
|
47
|
+
// an executor's own manager would forget them as soon as its call returned.
|
|
48
|
+
const undoManager = new ASKGUndoManager((request) => {
|
|
49
|
+
const handler = bindings.remoteHandler;
|
|
50
|
+
if (!handler) return Promise.reject(new Error("This window cannot undo tool calls."));
|
|
51
|
+
return handler(request);
|
|
52
|
+
});
|
|
53
|
+
const controller = new ASKGSessionController({
|
|
54
|
+
transport: apiClient.askg,
|
|
55
|
+
loadManifest: () => loadASKGClientManifest(),
|
|
56
|
+
getExecutor: (manifest: ASKGControllerManifest) => {
|
|
57
|
+
const handler = bindings.remoteHandler;
|
|
58
|
+
if (!handler) return null;
|
|
59
|
+
return createASKGRendererToolExecutor({
|
|
60
|
+
config: bindings.config,
|
|
61
|
+
remoteHandler: handler,
|
|
62
|
+
manifest: {
|
|
63
|
+
tools: manifest.tools,
|
|
64
|
+
manifestHash: manifest.manifestHash,
|
|
65
|
+
skipped: [],
|
|
66
|
+
},
|
|
67
|
+
undoManager,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
client: { kind: clientKind(), version: CLIENT_VERSION },
|
|
71
|
+
getContext: () => {
|
|
72
|
+
const state = bindings.getAppState();
|
|
73
|
+
const userData = buildASKGUserData({
|
|
74
|
+
config: state.config,
|
|
75
|
+
brokerAccounts: state.brokerAccounts,
|
|
76
|
+
tickers: state.tickers.values(),
|
|
77
|
+
});
|
|
78
|
+
const pane = attached.current;
|
|
79
|
+
// An attached pane is what the question is about: its function, its
|
|
80
|
+
// symbol and, once that may go, what it shows.
|
|
81
|
+
if (pane) return { ...attachedPaneContext(pane), ...(userData ? { userData } : {}) };
|
|
82
|
+
return {
|
|
83
|
+
...(bindings.context.symbol ? { symbol: bindings.context.symbol } : {}),
|
|
84
|
+
paneId: bindings.context.paneId,
|
|
85
|
+
...(userData ? { userData } : {}),
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return { controller, bindings, attached, restored: false };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function disposeASKGPaneSession(session: ASKGPaneSession): void {
|
|
93
|
+
session.controller.dispose();
|
|
94
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CLOUD_PLAN_KEY } from "../../shared/cloud-upgrade";
|
|
2
|
-
import { getCurrentPluginTarget } from "../../../current-target";
|
|
3
2
|
import {
|
|
4
3
|
useCallback,
|
|
5
4
|
useEffect,
|
|
@@ -44,6 +43,7 @@ import {
|
|
|
44
43
|
useAppSelector,
|
|
45
44
|
usePaneAppConfig,
|
|
46
45
|
} from "../../../../state/app/context";
|
|
46
|
+
import { usePaneSession, usePaneSessionState } from "../../../../state/pane-session";
|
|
47
47
|
import { useInlineTickers } from "../../../../state/hooks/inline-tickers";
|
|
48
48
|
import { useRemoteControlHandler } from "../../../../remote/app-host";
|
|
49
49
|
import { RemoteUiScope } from "../../../../remote/semantic-tree";
|
|
@@ -62,14 +62,12 @@ import { usePlanAccess } from "../../../../api-client/plan-access";
|
|
|
62
62
|
import { SignInWall } from "../auth-actions";
|
|
63
63
|
import { afterLayout, revealInScrollBox } from "../../../../components/ui/reveal-in-scroll-box";
|
|
64
64
|
import { describePortfolioTab } from "../../analytics/portfolio-selection";
|
|
65
|
-
import { ASKGSessionController, type ASKGControllerManifest } from "./controller";
|
|
66
65
|
import {
|
|
67
|
-
createASKGRendererToolExecutor,
|
|
68
66
|
buildASKGSourceShare,
|
|
69
67
|
type ASKGSourceShare,
|
|
70
|
-
loadASKGClientManifest,
|
|
71
68
|
resolveToolPaneTarget,
|
|
72
69
|
} from "./host";
|
|
70
|
+
import { createASKGPaneSession, disposeASKGPaneSession } from "./pane-session";
|
|
73
71
|
import { getSharedRegistry } from "../../../registry";
|
|
74
72
|
import {
|
|
75
73
|
answerReadNothing,
|
|
@@ -102,7 +100,6 @@ import type { AskGloomPaneAttachment } from "../../../../ask-gloom/pane-request"
|
|
|
102
100
|
import { moveComposerCursorToOffset } from "../../chat/content/composer-cursor";
|
|
103
101
|
import {
|
|
104
102
|
ASKG_PANE_QUESTION,
|
|
105
|
-
attachedPaneContext,
|
|
106
103
|
attachPane,
|
|
107
104
|
type ASKGAttachedPane,
|
|
108
105
|
} from "./pane-attachment";
|
|
@@ -112,9 +109,7 @@ import {
|
|
|
112
109
|
attachedPaneBlockHeight,
|
|
113
110
|
LEAVE_OUT_PANE_KEY,
|
|
114
111
|
} from "./attached-pane";
|
|
115
|
-
import { buildASKGUserData } from "./user-data";
|
|
116
112
|
import { ASKGConversationSidebar } from "./sidebar";
|
|
117
|
-
import { ASKGUndoManager } from "./undo";
|
|
118
113
|
import {
|
|
119
114
|
activeTurn,
|
|
120
115
|
canRateTurn,
|
|
@@ -146,7 +141,6 @@ import { logFailure } from "../../../../utils/log-failure";
|
|
|
146
141
|
|
|
147
142
|
export const ASKG_PANE_ID = "askg";
|
|
148
143
|
|
|
149
|
-
const CLIENT_VERSION = "1";
|
|
150
144
|
const MIN_DETAIL_HEIGHT = 8;
|
|
151
145
|
/** The composer grows with the question up to this many lines, then scrolls. */
|
|
152
146
|
const MAX_COMPOSER_LINES = 6;
|
|
@@ -155,11 +149,6 @@ const LOW_QUOTA = 20;
|
|
|
155
149
|
/** What unlocks Ask Gloom: a free account with a verified email; a paid plan only changes the model. */
|
|
156
150
|
const ASKG_WALL_HINT = "Free with a verified Gloom account.";
|
|
157
151
|
|
|
158
|
-
function clientKind(): "tui" | "desktop" | "web" {
|
|
159
|
-
const target = getCurrentPluginTarget();
|
|
160
|
-
return target === "web" || target === "desktop" ? target : "tui";
|
|
161
|
-
}
|
|
162
|
-
|
|
163
152
|
function tierLabel(row: ASKGToolRow): string | null {
|
|
164
153
|
if (row.writeTier === "read") return null;
|
|
165
154
|
if (row.writeTier === "ui-write") return "layout";
|
|
@@ -611,72 +600,37 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
611
600
|
const dialog = useDialog();
|
|
612
601
|
const rendererHost = useRendererHost();
|
|
613
602
|
|
|
614
|
-
const configRef = useRef(config);
|
|
615
|
-
configRef.current = config;
|
|
616
|
-
const remoteHandlerRef = useRef(remoteHandler);
|
|
617
|
-
remoteHandlerRef.current = remoteHandler;
|
|
618
|
-
const contextRef = useRef({ symbol: activeSymbol, paneId });
|
|
619
|
-
contextRef.current = { symbol: activeSymbol, paneId };
|
|
620
603
|
// Read when a question is sent, so portfolio and ticker changes do not re-render the pane.
|
|
621
604
|
const getAppState = useAppGetState();
|
|
622
|
-
|
|
623
|
-
|
|
605
|
+
|
|
606
|
+
// The conversation belongs to the pane, not to this drawing of it: docking
|
|
607
|
+
// or floating the pane mounts it again, and it picks the conversation up
|
|
608
|
+
// where it was (see `usePaneSession`).
|
|
609
|
+
const session = usePaneSession(
|
|
610
|
+
"askg:conversation",
|
|
611
|
+
() => createASKGPaneSession({
|
|
612
|
+
config,
|
|
613
|
+
remoteHandler,
|
|
614
|
+
getAppState,
|
|
615
|
+
context: { symbol: activeSymbol, paneId },
|
|
616
|
+
}),
|
|
617
|
+
disposeASKGPaneSession,
|
|
618
|
+
paneId,
|
|
619
|
+
);
|
|
620
|
+
const { controller } = session;
|
|
621
|
+
session.bindings.config = config;
|
|
622
|
+
session.bindings.remoteHandler = remoteHandler;
|
|
623
|
+
session.bindings.getAppState = getAppState;
|
|
624
|
+
session.bindings.context = { symbol: activeSymbol, paneId };
|
|
624
625
|
|
|
625
626
|
// The pane the conversation on screen is about, read whenever a question
|
|
626
627
|
// goes so every turn of it carries the pane.
|
|
627
|
-
const [attached, setAttachedState] =
|
|
628
|
-
const attachedRef =
|
|
628
|
+
const [attached, setAttachedState] = usePaneSessionState<ASKGAttachedPane | null>("askg:attached", null, paneId);
|
|
629
|
+
const attachedRef = session.attached;
|
|
629
630
|
const setAttached = useCallback((next: ASKGAttachedPane | null) => {
|
|
630
631
|
attachedRef.current = next;
|
|
631
632
|
setAttachedState(next);
|
|
632
|
-
}, []);
|
|
633
|
-
|
|
634
|
-
// Each call and each undo gets a fresh executor, so the tokens live here:
|
|
635
|
-
// an executor's own manager would forget them as soon as its call returned.
|
|
636
|
-
const undoManager = useMemo(() => new ASKGUndoManager((request) => {
|
|
637
|
-
const handler = remoteHandlerRef.current;
|
|
638
|
-
if (!handler) return Promise.reject(new Error("This window cannot undo tool calls."));
|
|
639
|
-
return handler(request);
|
|
640
|
-
}), []);
|
|
641
|
-
|
|
642
|
-
const controller = useMemo(() => new ASKGSessionController({
|
|
643
|
-
transport: apiClient.askg,
|
|
644
|
-
loadManifest: () => loadASKGClientManifest(),
|
|
645
|
-
getExecutor: (manifest: ASKGControllerManifest) => {
|
|
646
|
-
const handler = remoteHandlerRef.current;
|
|
647
|
-
if (!handler) return null;
|
|
648
|
-
return createASKGRendererToolExecutor({
|
|
649
|
-
config: configRef.current,
|
|
650
|
-
remoteHandler: handler,
|
|
651
|
-
manifest: {
|
|
652
|
-
tools: manifest.tools,
|
|
653
|
-
manifestHash: manifest.manifestHash,
|
|
654
|
-
skipped: [],
|
|
655
|
-
},
|
|
656
|
-
undoManager,
|
|
657
|
-
});
|
|
658
|
-
},
|
|
659
|
-
client: { kind: clientKind(), version: CLIENT_VERSION },
|
|
660
|
-
getContext: () => {
|
|
661
|
-
const state = getAppStateRef.current();
|
|
662
|
-
const userData = buildASKGUserData({
|
|
663
|
-
config: state.config,
|
|
664
|
-
brokerAccounts: state.brokerAccounts,
|
|
665
|
-
tickers: state.tickers.values(),
|
|
666
|
-
});
|
|
667
|
-
const pane = attachedRef.current;
|
|
668
|
-
// An attached pane is what the question is about: its function, its
|
|
669
|
-
// symbol and, once that may go, what it shows.
|
|
670
|
-
if (pane) return { ...attachedPaneContext(pane), ...(userData ? { userData } : {}) };
|
|
671
|
-
return {
|
|
672
|
-
...(contextRef.current.symbol ? { symbol: contextRef.current.symbol } : {}),
|
|
673
|
-
paneId: contextRef.current.paneId,
|
|
674
|
-
...(userData ? { userData } : {}),
|
|
675
|
-
};
|
|
676
|
-
},
|
|
677
|
-
}), [undoManager]);
|
|
678
|
-
|
|
679
|
-
useEffect(() => () => controller.dispose(), [controller]);
|
|
633
|
+
}, [attachedRef, setAttachedState]);
|
|
680
634
|
|
|
681
635
|
const state: ASKGConversationState = useSyncExternalStore(
|
|
682
636
|
useCallback((listener) => controller.subscribe(listener), [controller]),
|
|
@@ -684,14 +638,16 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
684
638
|
useCallback(() => controller.getState(), [controller]),
|
|
685
639
|
);
|
|
686
640
|
|
|
687
|
-
|
|
641
|
+
// What is in the composer and which row of the conversation the keyboard is
|
|
642
|
+
// on go with the conversation, so a dock change leaves them where they were.
|
|
643
|
+
const [inputValue, setInputValue] = usePaneSessionState("askg:draft", "", paneId);
|
|
688
644
|
const [inputFocused, setInputFocused] = useState(false);
|
|
689
645
|
// A tool row or a turn's folded calls; j/k walk them.
|
|
690
|
-
const [selectedId, setSelectedId] =
|
|
691
|
-
const [expandedToolCallId, setExpandedToolCallId] =
|
|
692
|
-
const [openGroups, setOpenGroups] =
|
|
646
|
+
const [selectedId, setSelectedId] = usePaneSessionState<string | null>("askg:selected", null, paneId);
|
|
647
|
+
const [expandedToolCallId, setExpandedToolCallId] = usePaneSessionState<string | null>("askg:expanded", null, paneId);
|
|
648
|
+
const [openGroups, setOpenGroups] = usePaneSessionState<ReadonlySet<string>>("askg:open-groups", () => new Set(), paneId);
|
|
693
649
|
// The answer whose thumbs down shows its reasons and the send action.
|
|
694
|
-
const [feedbackFollowUpTurnId, setFeedbackFollowUpTurnId] =
|
|
650
|
+
const [feedbackFollowUpTurnId, setFeedbackFollowUpTurnId] = usePaneSessionState<string | null>("askg:feedback-follow-up", null, paneId);
|
|
695
651
|
// The example question the keyboard is on while the pane is empty.
|
|
696
652
|
const [exampleIndex, setExampleIndex] = useState<number | null>(null);
|
|
697
653
|
const inputRef = useRef<TextareaRenderable | null>(null);
|
|
@@ -793,7 +749,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
793
749
|
}, [state]);
|
|
794
750
|
|
|
795
751
|
const profileExamples = useMemo(() => {
|
|
796
|
-
const appState =
|
|
752
|
+
const appState = getAppState();
|
|
797
753
|
return askgExampleQuestions({
|
|
798
754
|
config: appState.config,
|
|
799
755
|
tickers: appState.tickers.values(),
|
|
@@ -1019,10 +975,11 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1019
975
|
// Closing the pane is two Escs away, so the conversation it showed comes
|
|
1020
976
|
// back with the next one this session opens. A question typed with the
|
|
1021
977
|
// command that opened it starts a new one instead.
|
|
1022
|
-
const restoredRef = useRef(false);
|
|
1023
978
|
useEffect(() => {
|
|
1024
|
-
|
|
1025
|
-
|
|
979
|
+
// Once per pane: a pane that comes back from a dock change has its
|
|
980
|
+
// conversation already, and one that was started empty stays empty.
|
|
981
|
+
if (session.restored || !planAccess.emailVerified) return;
|
|
982
|
+
session.restored = true;
|
|
1026
983
|
const remembered = askgConversationListStore.rememberedOpen();
|
|
1027
984
|
if (!remembered || queuedQuestionRef.current || queuedPaneRef.current || controller.getState().turns.length > 0) return;
|
|
1028
985
|
void apiClient.askg.loadConversation(remembered).then((conversation) => {
|
|
@@ -1031,7 +988,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1031
988
|
if (!conversation || current.turns.length > 0 || current.conversationId || attachedRef.current || queuedPaneRef.current) return;
|
|
1032
989
|
controller.openConversation(conversation);
|
|
1033
990
|
}).catch(logFailure("cloud.askg.pane", "Restore the last open conversation failed"));
|
|
1034
|
-
}, [controller, planAccess.emailVerified]);
|
|
991
|
+
}, [attachedRef, controller, planAccess.emailVerified, session]);
|
|
1035
992
|
|
|
1036
993
|
useEffect(() => {
|
|
1037
994
|
if (state.conversationId) askgConversationListStore.rememberOpen(state.conversationId);
|
|
@@ -1162,7 +1119,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1162
1119
|
if (target.kind !== "pane") return;
|
|
1163
1120
|
const failed = (reason: string) => notify({ body: `Could not open ${formatSourceCommand(target.command)}: ${reason}`, type: "error" });
|
|
1164
1121
|
try {
|
|
1165
|
-
const share = await buildASKGSourceShare(target.command,
|
|
1122
|
+
const share = await buildASKGSourceShare(target.command, session.bindings.config);
|
|
1166
1123
|
openSharedPane(share.data, () => failed("panes cannot open from here."));
|
|
1167
1124
|
} catch (error) {
|
|
1168
1125
|
failed(error instanceof Error ? error.message : String(error));
|
|
@@ -1350,7 +1307,7 @@ export function ASKGPane({ paneId, focused, width, height }: PaneProps) {
|
|
|
1350
1307
|
if (source.target.kind !== "pane") continue;
|
|
1351
1308
|
const key = formatSourceCommand(source.target.command);
|
|
1352
1309
|
if (links.has(key) || pending.some((entry) => entry.key === key)) continue;
|
|
1353
|
-
const share = await buildASKGSourceShare(source.target.command,
|
|
1310
|
+
const share = await buildASKGSourceShare(source.target.command, session.bindings.config).catch((error: unknown) => {
|
|
1354
1311
|
logFailure("cloud.askg.pane", "An answer source could not be shared")(error);
|
|
1355
1312
|
return null;
|
|
1356
1313
|
});
|
|
@@ -263,7 +263,12 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
263
263
|
|
|
264
264
|
const openTicker = useInlineTickerOpener();
|
|
265
265
|
|
|
266
|
+
// The rows come in after the pane mounts, every time it mounts (docking or
|
|
267
|
+
// floating it mounts it again), so no rows yet says nothing about which row
|
|
268
|
+
// was selected. Only a loaded table with no such row moves the selection.
|
|
269
|
+
const rowsLoaded = !!payload && status === "loaded";
|
|
266
270
|
useEffect(() => {
|
|
271
|
+
if (!rowsLoaded) return;
|
|
267
272
|
if (tradeRows.length === 0) {
|
|
268
273
|
if (selectedTradeId !== null) setSelectedTradeId(null);
|
|
269
274
|
return;
|
|
@@ -271,9 +276,10 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
271
276
|
if (!selectedTrade || !selectedTradeId) {
|
|
272
277
|
setSelectedTradeId(tradeRows[0]!.id);
|
|
273
278
|
}
|
|
274
|
-
}, [selectedTrade, selectedTradeId, setSelectedTradeId, tradeRows]);
|
|
279
|
+
}, [rowsLoaded, selectedTrade, selectedTradeId, setSelectedTradeId, tradeRows]);
|
|
275
280
|
|
|
276
281
|
useEffect(() => {
|
|
282
|
+
if (!rowsLoaded) return;
|
|
277
283
|
if (memberRows.length === 0) {
|
|
278
284
|
if (selectedMemberId !== null) setSelectedMemberId(null);
|
|
279
285
|
return;
|
|
@@ -281,7 +287,7 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
281
287
|
if (!selectedMember || !selectedMemberId) {
|
|
282
288
|
setSelectedMemberId(memberRows[0]!.id);
|
|
283
289
|
}
|
|
284
|
-
}, [memberRows, selectedMember, selectedMemberId, setSelectedMemberId]);
|
|
290
|
+
}, [memberRows, rowsLoaded, selectedMember, selectedMemberId, setSelectedMemberId]);
|
|
285
291
|
|
|
286
292
|
useEffect(() => {
|
|
287
293
|
if (!payload || status !== "loaded") return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PricePoint } from "../../../types/financials";
|
|
2
2
|
import { getPricePointTimestamp } from "../../../utils/price-history";
|
|
3
|
-
import { pricePointIntegrity } from "../../../utils/price-history-integrity";
|
|
3
|
+
import { pricePointCloseCopied, pricePointIntegrity } from "../../../utils/price-history-integrity";
|
|
4
4
|
|
|
5
5
|
export interface CorrelationResult {
|
|
6
6
|
correlation: number | null;
|
|
@@ -26,13 +26,14 @@ export type ChangeBasis = "return" | "difference";
|
|
|
26
26
|
* Keep the final valid close for each UTC trading date, in chronological order.
|
|
27
27
|
* A bar whose prices contradict each other (a high under its open) is left out,
|
|
28
28
|
* as `history` leaves it blank: the series has a gap there, and the next return
|
|
29
|
-
* runs from the close before it, as across a holiday.
|
|
29
|
+
* runs from the close before it, as across a holiday. So is a pair's close its
|
|
30
|
+
* source copied from the open, which nothing rebuilt (flag close copied).
|
|
30
31
|
*/
|
|
31
32
|
export function dailyCloses(points: readonly PricePoint[]): DailyClose[] {
|
|
32
33
|
const byDate = new Map<string, number>();
|
|
33
34
|
for (const point of [...points].sort(comparePricePointsByDate)) {
|
|
34
35
|
const dateKey = toDateKey(point);
|
|
35
|
-
if (!dateKey || !Number.isFinite(point.close) || point.close <= 0 || pricePointIntegrity(point)) continue;
|
|
36
|
+
if (!dateKey || !Number.isFinite(point.close) || point.close <= 0 || pricePointIntegrity(point) || pricePointCloseCopied(point)) continue;
|
|
36
37
|
byDate.set(dateKey, point.close);
|
|
37
38
|
}
|
|
38
39
|
return [...byDate].map(([dateKey, close]) => ({ dateKey, close }));
|
|
@@ -6,6 +6,9 @@ import type { EarningsDateStatus, EarningsEpsBasis, Quote } from "../../../types
|
|
|
6
6
|
import type { TickerRecord } from "../../../types/ticker";
|
|
7
7
|
import { earningsDateStatus, earningsEpsBasis, isProvisionalActual } from "../shared/earnings-report";
|
|
8
8
|
import { calendarReport } from "../shared/earnings-calendar";
|
|
9
|
+
import { listingSuffixCandidate } from "../../../sources/listing-symbols";
|
|
10
|
+
import { isUsListingExchange } from "../../../utils/exchanges";
|
|
11
|
+
import { sameHistoryListing } from "./client";
|
|
9
12
|
import { shortDate, surprise, weekday } from "./format";
|
|
10
13
|
|
|
11
14
|
/** A held name is in a portfolio; a watched one only in watchlists. */
|
|
@@ -36,6 +39,14 @@ export interface BoardReport {
|
|
|
36
39
|
impliedMove: number | null;
|
|
37
40
|
averageMove: number | null;
|
|
38
41
|
owned: Ownership | null;
|
|
42
|
+
/** ISO currency of the EPS and sales figures; null when the report has none. The market cap is always dollars. */
|
|
43
|
+
currency?: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* A listing abroad's lines on its markets, the one shown first; on a US line
|
|
46
|
+
* the board shows instead of its listing abroad (BABA, the day 9988:HKEX
|
|
47
|
+
* reports too), that listing's. Absent for other US listings.
|
|
48
|
+
*/
|
|
49
|
+
listings?: readonly string[];
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
export type BoardRow =
|
|
@@ -145,9 +156,30 @@ export function boardReport(report: EarningsCalendarReport, owned: ReadonlyMap<s
|
|
|
145
156
|
impliedMove: report.implied?.move ?? null,
|
|
146
157
|
averageMove: report.averageReports >= MIN_AVERAGE_REPORTS ? report.averageMove : null,
|
|
147
158
|
owned: owned.get(report.symbol) ?? null,
|
|
159
|
+
// The board's US reports are in dollars; a listing abroad's say their own.
|
|
160
|
+
currency: report.currency ?? "USD",
|
|
161
|
+
...report.listings?.length ? { listings: report.listings } : {},
|
|
148
162
|
};
|
|
149
163
|
}
|
|
150
164
|
|
|
165
|
+
/** A listing as the board keys it: 0700.HK, as typed where its quote could not be read, is 0700:HKEX. */
|
|
166
|
+
export function boardKey(symbol: string): string {
|
|
167
|
+
const suffixed = listingSuffixCandidate(symbol);
|
|
168
|
+
return (suffixed ? `${suffixed.symbol}:${suffixed.exchange}` : symbol).toUpperCase();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether a board row is the listing named: its own line, or another of its
|
|
173
|
+
* company's (0939:HKEX for 601939:SSE, 9988:HKEX for BABA the day both report).
|
|
174
|
+
*/
|
|
175
|
+
export function boardRowOf(entry: Pick<BoardReport, "symbol" | "listings">, named: string): boolean {
|
|
176
|
+
const symbol = boardKey(named);
|
|
177
|
+
const [bare = symbol, venue] = symbol.split(":");
|
|
178
|
+
// A US ticker is a US row's bare symbol, never a listing abroad's.
|
|
179
|
+
if (!venue || isUsListingExchange(venue)) return !entry.symbol.includes(":") && entry.symbol.toUpperCase() === bare;
|
|
180
|
+
return [entry.symbol, ...entry.listings ?? []].some((line) => sameHistoryListing(line, symbol));
|
|
181
|
+
}
|
|
182
|
+
|
|
151
183
|
/**
|
|
152
184
|
* A company the stored calendar does not carry (a listing abroad, a date past
|
|
153
185
|
* its horizon) from the per-ticker calendar, read as every earnings surface
|
|
@@ -182,6 +214,7 @@ export function fallbackReport(event: EarningsEvent, owned: ReadonlyMap<string,
|
|
|
182
214
|
impliedMove: null,
|
|
183
215
|
averageMove: null,
|
|
184
216
|
owned: owned.get(event.symbol) ?? null,
|
|
217
|
+
currency: epsEstimate != null || dollars("revenueEstimate") != null ? "USD" : null,
|
|
185
218
|
};
|
|
186
219
|
}
|
|
187
220
|
|