@gloom-sh/terminal 0.20.22 → 0.20.23
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/account/heard-from-question.tsx +6 -4
- package/src/account/heard-from.ts +3 -4
- package/src/api-client/exchange-announcements.ts +2 -2
- package/src/api-client/heard-from.ts +5 -7
- package/src/api-client/ownership-disclosures.ts +38 -5
- package/src/api-client/types/ticker-data.ts +3 -1
- package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
- package/src/cli/commands/market.ts +5 -3
- package/src/cli/commands/overview.ts +7 -9
- package/src/cli/listing-arg.ts +45 -18
- package/src/cli/pane-functions/catalog-snapshot.json +2 -2
- package/src/cli/pane-functions/data.ts +3 -1
- package/src/cli/pane-functions/freshness.ts +6 -1
- package/src/cli/pane-functions/function-help.ts +0 -2
- package/src/cli/pane-functions/market-session.ts +12 -2
- package/src/cli/pane-functions/screenshot-payload.ts +3 -1
- package/src/cli/symbol-list.ts +52 -14
- package/src/cli/ticker-resolution.ts +133 -38
- package/src/components/chart/composite/composite-chart.tsx +12 -0
- package/src/components/chart/composite/types.ts +18 -0
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
- package/src/components/chart-table/header.tsx +11 -5
- package/src/components/chart-table/selection.ts +20 -1
- package/src/components/data-table/view.tsx +2 -0
- package/src/components/feed-data-table/stack-view.tsx +85 -5
- package/src/components/layout/pane/header.tsx +12 -30
- package/src/components/ticker/badge/index.tsx +9 -4
- package/src/components/ticker/badge/list.tsx +3 -1
- package/src/components/ui/data-table/index.tsx +7 -1
- package/src/components/ui/data-table/muted-row.tsx +47 -0
- package/src/components/ui/data-table/opentui/index.tsx +42 -11
- package/src/components/ui/data-table/spill.ts +36 -0
- package/src/components/ui/data-table/types.ts +17 -1
- package/src/components/ui/data-table/use-column-order.ts +11 -0
- package/src/components/ui/icon.tsx +50 -3
- package/src/components/ui/list-view.tsx +2 -2
- package/src/components/ui/table-layout.ts +32 -0
- package/src/components/ui/terminal-hover-label.tsx +49 -0
- package/src/components/use-pinned-moment.ts +222 -13
- package/src/core/state/app/state.ts +11 -2
- package/src/core/state/app/types.ts +2 -1
- package/src/data/sqlite/access.ts +14 -1
- package/src/data/sqlite/checkpointer.ts +2 -2
- package/src/data/sqlite/database.ts +4 -0
- package/src/docs/snapshot.json +180 -26
- package/src/i18n/es.ts +1 -0
- package/src/i18n/ja.ts +1 -0
- package/src/i18n/ko.ts +1 -0
- package/src/i18n/zh-cn.ts +1 -0
- package/src/i18n/zh-tw.ts +1 -0
- package/src/market-data/market/freshness.ts +2 -2
- package/src/market-data/market/globex-day.ts +14 -0
- package/src/market-data/published-us-sessions.ts +3 -2
- package/src/market-data/quotes/live-valuation.ts +4 -2
- package/src/market-data/quotes/metadata.ts +48 -5
- package/src/market-data/quotes/regular-session-valuation.ts +12 -1
- package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
- package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
- package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
- package/src/plugins/builtin/chat/channels.ts +5 -2
- package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
- package/src/plugins/builtin/chat/content/footer.tsx +17 -7
- package/src/plugins/builtin/chat/content/index.tsx +108 -36
- package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
- package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
- package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
- package/src/plugins/builtin/chat/content/types.ts +2 -0
- package/src/plugins/builtin/chat/controller/channels.ts +15 -15
- package/src/plugins/builtin/chat/controller/index.ts +140 -34
- package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
- package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
- package/src/plugins/builtin/chat/controller/send.ts +41 -17
- package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
- package/src/plugins/builtin/chat/controller/state.ts +17 -8
- package/src/plugins/builtin/chat/controller/storage.ts +41 -4
- package/src/plugins/builtin/chat/controller/view.ts +6 -3
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/chat/layout.ts +8 -1
- package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
- package/src/plugins/builtin/chat/message/header.tsx +112 -30
- package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
- package/src/plugins/builtin/chat/message/render-state.ts +4 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/message/types.ts +5 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
- package/src/plugins/builtin/company-kpis/model.ts +11 -3
- package/src/plugins/builtin/correlation/compute.ts +6 -1
- package/src/plugins/builtin/custom-view/loader.ts +95 -34
- package/src/plugins/builtin/custom-view/pane.tsx +31 -41
- package/src/plugins/builtin/custom-view/table.ts +201 -0
- package/src/plugins/builtin/dividend-yield/client.ts +14 -17
- package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
- package/src/plugins/builtin/dividend-yield/model.ts +45 -6
- package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
- package/src/plugins/builtin/dividend-yield/types.ts +2 -3
- package/src/plugins/builtin/dividend-yield/view.ts +22 -2
- package/src/plugins/builtin/econ/calendar-model.ts +135 -0
- package/src/plugins/builtin/econ/columns.ts +132 -0
- package/src/plugins/builtin/econ/index.tsx +25 -65
- package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
- package/src/plugins/builtin/holders/disclosures.ts +20 -6
- package/src/plugins/builtin/holders/headless.ts +2 -2
- package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
- package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
- package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
- package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
- package/src/plugins/builtin/market-halts/pane.tsx +14 -2
- package/src/plugins/builtin/news/wire/news/row.ts +5 -12
- package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
- package/src/plugins/builtin/pe-band/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/model.ts +41 -18
- package/src/plugins/builtin/pe-band/pane.tsx +6 -5
- package/src/plugins/builtin/perps/equity-row.tsx +4 -6
- package/src/plugins/builtin/perps/markets-section.tsx +19 -15
- package/src/plugins/builtin/perps/model.ts +10 -2
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
- package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
- package/src/plugins/builtin/research/event-data.ts +3 -1
- package/src/plugins/builtin/research/event-model.ts +17 -15
- package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
- package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
- package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
- package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
- package/src/plugins/builtin/sec/headless.ts +8 -8
- package/src/plugins/builtin/sec/index.tsx +69 -29
- package/src/plugins/builtin/shared/report-freshness.ts +4 -1
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
- package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
- package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
- package/src/plugins/builtin/time-sales/model.ts +16 -9
- package/src/plugins/builtin/time-sales/pane.tsx +27 -24
- package/src/plugins/builtin/treasury-daily/client.ts +43 -9
- package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
- package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
- package/src/portfolio/positions-import/parse.ts +14 -6
- package/src/portfolio/positions-import/plan.ts +3 -2
- package/src/react/async-resource.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +40 -0
- package/src/renderers/dom/data-table/row.tsx +39 -3
- package/src/renderers/dom/desktop/icons.tsx +147 -3
- package/src/renderers/dom/desktop/popover.tsx +2 -2
- package/src/renderers/dom/host/media-surface.tsx +204 -45
- package/src/renderers/dom/host/tabs.tsx +1 -0
- package/src/renderers/dom/styles.css +14 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
- package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
- package/src/sources/gloomberb-cloud/index.ts +8 -7
- package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
- package/src/sources/listing-symbols.ts +7 -1
- package/src/sources/provider-router/cache.ts +5 -4
- package/src/sources/provider-router/financials.ts +40 -18
- package/src/state/app/tab-cursor.ts +47 -6
- package/src/telemetry/stall-clocks.ts +3 -0
- package/src/telemetry/stall-reports.ts +12 -3
- package/src/telemetry/windows-process-activity.ts +41 -0
- package/src/telemetry/windows-time.ts +32 -0
- package/src/test-support/scoped-earnings.ts +24 -0
- package/src/tickers/terminal-codes.ts +1 -6
- package/src/time-series/daily-valuation.ts +13 -6
- package/src/time-series/filed-trailing-eps.ts +16 -3
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/historical-valuation.ts +20 -0
- package/src/time-series/fundamentals/series.ts +13 -1
- package/src/time-series/valuation-currency.ts +2 -0
- package/src/types/financials.ts +46 -10
- package/src/ui/dialog-context.ts +8 -0
- package/src/utils/datetime-format.ts +23 -1
- package/src/utils/declared-dividends.ts +12 -2
- package/src/utils/exchange-announcements.ts +4 -1
- package/src/utils/exchange-notation.generated.ts +3 -1
- package/src/utils/exchanges.ts +2 -1
- package/src/utils/fundamentals.ts +1 -0
- package/src/utils/main-thread-stall.ts +9 -1
- package/src/utils/rpc-timeout-error.ts +36 -11
- package/src/utils/sec.ts +3 -1
- package/src/utils/share-multiples.ts +1 -1
- package/src/utils/stall-process-activity.ts +70 -0
- package/src/utils/statement-scope.ts +103 -0
- package/src/utils/trailing-eps.ts +1 -1
- package/src/utils/zoned-date-time.ts +1 -0
|
@@ -73,7 +73,9 @@ function repriceMultiple(
|
|
|
73
73
|
export function liveTrailingPE(quote: Quote | null | undefined, fundamentals: Fundamentals | undefined): PriceEarnings | undefined {
|
|
74
74
|
// Withdrawn as no multiple of the share (utils/share-multiples).
|
|
75
75
|
if (fundamentals?.notMeaningful?.trailingPE) return NOT_MEANINGFUL;
|
|
76
|
-
const
|
|
76
|
+
const priced = pricedFundamentals(quote, fundamentals);
|
|
77
|
+
if (fundamentals?.scopedEarnings !== undefined) return priceEarningsOnEarnings(priced?.trailingPE, priced?.eps);
|
|
78
|
+
const stored = priced?.trailingPE;
|
|
77
79
|
return priceEarningsOnEarnings(repriceMultiple(stored, priceEarningsEps(fundamentals, quote?.currency), quote, fundamentals), fundamentals?.eps);
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -92,7 +94,7 @@ export function liveForwardPE(quote: Quote | null | undefined, fundamentals: Fun
|
|
|
92
94
|
export function atLivePriceEarnings<T extends Pick<TickerFinancials, "quote" | "fundamentals">>(financials: T): T {
|
|
93
95
|
const priced = atRegularSessionPrice(financials);
|
|
94
96
|
if (!priced.fundamentals) return priced;
|
|
95
|
-
const trailing = liveTrailingPE(financials.quote, financials.fundamentals);
|
|
97
|
+
const trailing = priced.fundamentals.scopedEarnings === undefined ? liveTrailingPE(financials.quote, financials.fundamentals) : priced.fundamentals.trailingPE;
|
|
96
98
|
const forward = liveForwardPE(financials.quote, financials.fundamentals);
|
|
97
99
|
return {
|
|
98
100
|
...priced,
|
|
@@ -43,8 +43,48 @@ export function mergeQuoteMetadata(known: QuoteMetadata | null | undefined, load
|
|
|
43
43
|
return Object.keys(fields).length ? { ...merged, fieldSources: fields } : merged;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const OTC_QUOTE_VENUES: ReadonlyMap<string, string> = new Map([
|
|
47
|
+
["OTC", "OTC"], ["OTC MARKETS", "OTC"], ["OTHER OTC", "OTC"],
|
|
48
|
+
["OQX", "OTCQX"], ["OTCQX", "OTCQX"], ["OTC MARKETS OTCQX", "OTCQX"],
|
|
49
|
+
["OQB", "OTCQB"], ["OTCQB", "OTCQB"], ["OTC MARKETS OTCQB", "OTCQB"],
|
|
50
|
+
["OID", "OTCID"], ["OTCID", "OTCID"], ["OTC MARKETS OTCID", "OTCID"],
|
|
51
|
+
["PNK", "PINK"], ["PINK", "PINK"], ["OTCPK", "PINK"], ["OTC MARKETS OTCPK", "PINK"],
|
|
52
|
+
["PINX", "PINK"], ["PINK SHEETS", "PINK"],
|
|
53
|
+
["OBB", "OTCBB"], ["OTCBB", "OTCBB"], ["NASDAQ OTCBB", "OTCBB"],
|
|
54
|
+
["OEM", "EXMKT"], ["EXMKT", "EXMKT"], ["EXPM", "EXMKT"],
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export function isOtcQuoteVenue(exchange?: string): boolean {
|
|
58
|
+
return OTC_QUOTE_VENUES.has(canonicalExchange(exchange));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function otcTier(exchange: string): string | undefined {
|
|
62
|
+
const venue = OTC_QUOTE_VENUES.get(exchange);
|
|
63
|
+
return venue === "OTC" ? undefined : venue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Declarations can coexist when one names OTC generally and the other names a tier. */
|
|
67
|
+
function quoteListingExchangesCompatible(left: string, right: string): boolean {
|
|
68
|
+
if (left === right) return true;
|
|
69
|
+
const leftOtc = OTC_QUOTE_VENUES.get(left);
|
|
70
|
+
const rightOtc = OTC_QUOTE_VENUES.get(right);
|
|
71
|
+
return !!leftOtc && !!rightOtc && (leftOtc === rightOtc || leftOtc === "OTC" || rightOtc === "OTC");
|
|
72
|
+
}
|
|
73
|
+
|
|
46
74
|
/** Qualified listings must agree; provider suffix spellings use the existing exact-listing normalizer. */
|
|
47
|
-
export function quoteMetadataMatchesTarget(
|
|
75
|
+
export function quoteMetadataMatchesTarget(
|
|
76
|
+
metadata: QuoteMetadata,
|
|
77
|
+
symbol: string,
|
|
78
|
+
exchange?: string,
|
|
79
|
+
options?: { allowUnnamedListing?: boolean },
|
|
80
|
+
): boolean {
|
|
81
|
+
if (options?.allowUnnamedListing && !metadata.listingExchangeName && !parsePublicTickerKey(metadata.symbol).exchange) {
|
|
82
|
+
const target = parsePublicTickerKey(symbol);
|
|
83
|
+
if (!otcTier(canonicalExchange(target.exchange || exchange))) {
|
|
84
|
+
symbol = target.symbol;
|
|
85
|
+
exchange = undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
48
88
|
// A crypto exchange's line of a pair (BTC/GBP on COINBASE PRO) is priced as the crypto venue's listing, BTC-GBP on
|
|
49
89
|
// CCC, and a quote kept under the line's key is that listing's.
|
|
50
90
|
const line = exchangeLineCoinListing(symbol, exchange);
|
|
@@ -53,14 +93,17 @@ export function quoteMetadataMatchesTarget(metadata: QuoteMetadata, symbol: stri
|
|
|
53
93
|
if (quotedLine) metadata = { ...metadata, symbol: quotedLine.symbol, listingExchangeName: quotedLine.exchange };
|
|
54
94
|
const target = parsePublicTickerKey(symbol);
|
|
55
95
|
const actual = parsePublicTickerKey(metadata.symbol);
|
|
96
|
+
const requestedExchange = canonicalExchange(target.exchange || exchange);
|
|
97
|
+
const requestedTier = otcTier(requestedExchange);
|
|
56
98
|
// An index is one series whatever its venue is called: search files ^VIX under CXI and ^RUT under WCB, while
|
|
57
99
|
// their quotes name CBOE INDICES and CHICAGO OPTIONS. Saved from search, the index must still match its quote.
|
|
58
|
-
if (target.symbol.startsWith("^") && target.symbol === actual.symbol) return true;
|
|
59
|
-
const requestedExchange = canonicalExchange(target.exchange || exchange);
|
|
100
|
+
if (target.symbol.startsWith("^") && target.symbol === actual.symbol && !isOtcQuoteVenue(requestedExchange)) return true;
|
|
60
101
|
const symbolExchange = canonicalExchange(actual.exchange);
|
|
61
102
|
const actualExchange = canonicalExchange(metadata.listingExchangeName) || symbolExchange;
|
|
62
|
-
if (symbolExchange && actualExchange && symbolExchange
|
|
63
|
-
if (requestedExchange && actualExchange
|
|
103
|
+
if (symbolExchange && actualExchange && !quoteListingExchangesCompatible(symbolExchange, actualExchange)) return false;
|
|
104
|
+
if (requestedExchange && (!quoteListingExchangesCompatible(requestedExchange, actualExchange)
|
|
105
|
+
|| (symbolExchange && !quoteListingExchangesCompatible(requestedExchange, symbolExchange)))) return false;
|
|
106
|
+
if (requestedTier && requestedTier !== otcTier(actualExchange) && requestedTier !== otcTier(symbolExchange)) return false;
|
|
64
107
|
if (target.symbol === actual.symbol) return true;
|
|
65
108
|
// Gloom Cloud answers a currency pair in one spelling however it was asked
|
|
66
109
|
// for: EUR/USD and EURUSD:CCY come back as EURUSD=X on its currency venue.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EnterpriseValueCheck, Fundamentals, Quote, TickerFinancials } from "../../types/financials";
|
|
2
2
|
import { priceEarningsEps } from "../../utils/fundamentals";
|
|
3
|
+
import { priceScopedEarnings } from "../../utils/statement-scope";
|
|
3
4
|
import type { ReportTime } from "../../utils/utc-time";
|
|
4
5
|
import { latestRegularSessionClose } from "../market/freshness";
|
|
5
6
|
import { getCompletedRegularSessionDisplay, getRegularSessionDisplay } from "../market/status";
|
|
@@ -177,7 +178,17 @@ const MEASURED_PRICE_TOLERANCE = 0.03;
|
|
|
177
178
|
* the quote's and nothing moves. A stale quote, or stale fundamentals
|
|
178
179
|
* (measured at some older price), are left as they are.
|
|
179
180
|
*/
|
|
180
|
-
export function atRegularSessionPrice<T extends Pick<TickerFinancials, "quote" | "fundamentals">>(financials: T): T {
|
|
181
|
+
export function atRegularSessionPrice<T extends Pick<TickerFinancials, "quote" | "fundamentals" | "statementScope">>(financials: T): T {
|
|
182
|
+
const priced = moveToRegularSession(financials);
|
|
183
|
+
const stats = priced.fundamentals;
|
|
184
|
+
if (!stats || (!financials.statementScope && stats.scopedEarnings === undefined)) return priced;
|
|
185
|
+
const scopedEarnings = financials.statementScope && financials.statementScope.basis !== "standalone" ? null : stats.scopedEarnings ?? null;
|
|
186
|
+
const quote = financials.quote;
|
|
187
|
+
return { ...priced, fundamentals: priceScopedEarnings({ ...stats, scopedEarnings }, regularSessionValuationPrice(quote),
|
|
188
|
+
quote, regularSessionValuationTime(quote)?.time) };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function moveToRegularSession<T extends Pick<TickerFinancials, "quote" | "fundamentals">>(financials: T): T {
|
|
181
192
|
const quote = financials.quote;
|
|
182
193
|
if (!quote || quote.stale || !positive(quote.price)) return financials;
|
|
183
194
|
const price = regularSessionValuationPrice(quote);
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type PageRequest,
|
|
11
11
|
} from "../../../components";
|
|
12
12
|
import { handleRefreshKey } from "../../../components/data-table/table-pane";
|
|
13
|
+
import { usePinnedList } from "../../../components/use-pinned-moment";
|
|
13
14
|
import { colors } from "../../../theme/colors";
|
|
14
15
|
import type { PaneProps } from "../../../types/plugin";
|
|
15
16
|
import type { ScrollBoxRenderable } from "../../../ui";
|
|
@@ -25,6 +26,11 @@ import { alertTarget, alertViewHints, deliveredAlertSubject, useOpenAlertTarget,
|
|
|
25
26
|
|
|
26
27
|
const stamp = (value: string) => value.slice(0, 16).replace("T", " ");
|
|
27
28
|
const itemId = (item: AlertHistoryItem) => item.id;
|
|
29
|
+
const historyRowId = (row: HistoryRow) => row.id;
|
|
30
|
+
const historyRowMoment = (row: HistoryRow) => {
|
|
31
|
+
const at = Date.parse(row.time);
|
|
32
|
+
return Number.isFinite(at) ? at : null;
|
|
33
|
+
};
|
|
28
34
|
/** Where a line comes from, in the Via column's few cells. */
|
|
29
35
|
const VIA_TEXT: Record<AlertHistoryVia, string> = { app: "App", cloud: "Cloud", both: "App, Cloud" };
|
|
30
36
|
|
|
@@ -125,7 +131,7 @@ export function AlertHistoryPane({ focused, width, height }: PaneProps) {
|
|
|
125
131
|
const session = useResearchCloudSession();
|
|
126
132
|
const [firedLog] = usePluginState<unknown>(FIRED_LOG_KEY, []);
|
|
127
133
|
const fired = useMemo(() => readFiredAlerts(firedLog), [firedLog]);
|
|
128
|
-
const [
|
|
134
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
129
135
|
// A new session starts the history over. A failed later page leaves what is
|
|
130
136
|
// loaded, and the next scroll to the end asks again.
|
|
131
137
|
const loadPage = useCallback(async ({ offset }: PageRequest) => {
|
|
@@ -145,8 +151,17 @@ export function AlertHistoryPane({ focused, width, height }: PaneProps) {
|
|
|
145
151
|
const loadingMore = history.loadingMore;
|
|
146
152
|
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
147
153
|
const loadMoreOnScroll = useTableLoadMore(scrollRef, history.hasMore && !loadingMore, history.loadMore);
|
|
148
|
-
|
|
154
|
+
// By id, so an alert going off while one is picked leaves it picked.
|
|
155
|
+
const selectedIndex = Math.max(0, items.findIndex((item) => item.id === selectedId));
|
|
149
156
|
const selectedItem = items[selectedIndex];
|
|
157
|
+
// A crosshair pinned in the tab picks the newest alert that went off by
|
|
158
|
+
// then and mutes the later ones; the selection follows the pin when it
|
|
159
|
+
// moves, not when an alert comes in. It reads the id as stored, so a first
|
|
160
|
+
// row shown with none picked is no pick, and a picked alert that went out
|
|
161
|
+
// of the list sends the selection to the pin's alert rather than the top.
|
|
162
|
+
const { isAfterPin } = usePinnedList<HistoryRow>("alert-history:pin", {
|
|
163
|
+
rows: items, getId: historyRowId, moment: historyRowMoment, selectedId, select: setSelectedId,
|
|
164
|
+
});
|
|
150
165
|
const selectedTarget = useMemo(() => selectedItem ? alertTarget(selectedItem.subject) : null, [selectedItem]);
|
|
151
166
|
const openTarget = useOpenAlertTarget();
|
|
152
167
|
|
|
@@ -186,12 +201,13 @@ export function AlertHistoryPane({ focused, width, height }: PaneProps) {
|
|
|
186
201
|
items={items}
|
|
187
202
|
scrollRef={scrollRef}
|
|
188
203
|
onBodyScrollActivity={loadMoreOnScroll}
|
|
189
|
-
selection={{ kind: "
|
|
204
|
+
selection={{ kind: "id", selectedId: selectedItem?.id ?? null, getId: historyRowId, onChange: setSelectedId }}
|
|
190
205
|
getItemKey={(item) => item.id}
|
|
191
206
|
onRootKeyDown={(event) => handleRefreshKey(event, history.reload)}
|
|
192
207
|
sortColumnId={null}
|
|
193
208
|
sortDirection="desc"
|
|
194
209
|
renderCell={(item, column, _index, row) => alertHistoryCell(item, column, row.selected)}
|
|
210
|
+
isRowMuted={isAfterPin}
|
|
195
211
|
emptyStateTitle={access.signedIn ? "No alerts in the last 90 days" : "No alerts fired yet"}
|
|
196
212
|
emptyStateHint={access.signedIn
|
|
197
213
|
? data?.deviceEnabled ? undefined : "Alerts push to the Gloom phone app once it is signed in."
|
|
@@ -459,6 +459,8 @@ export function BrokerOrdersView({
|
|
|
459
459
|
const disabled = !canRead || busy || !allowed?.enabled || !canChangeBrokerOrder(order);
|
|
460
460
|
const state = brokerOrderStatus(order.status);
|
|
461
461
|
const note = noteFor(order);
|
|
462
|
+
// Enter and c act on the chosen order only, so only its icons name them.
|
|
463
|
+
const keysHere = picked && focused && active && !dialogOpen;
|
|
462
464
|
// One line: side and size, price, state, then edit and cancel as icons.
|
|
463
465
|
return <Box key={key} position="relative" flexDirection="row" alignItems="center" gap={1} paddingLeft={1} height={native ? 1.6 : 1} backgroundColor={picked ? colors.panel : undefined}>
|
|
464
466
|
{picked ? <Box position="absolute" left={0} top={0} width={1} height="100%" backgroundColor={focused ? colors.borderFocused : colors.border} style={native ? { width: 2 } : undefined} /> : null}
|
|
@@ -477,8 +479,8 @@ export function BrokerOrdersView({
|
|
|
477
479
|
</Button>
|
|
478
480
|
</Box>
|
|
479
481
|
<Box flexDirection="row" flexShrink={0}>
|
|
480
|
-
<IconButton icon="edit" label="Modify order" shortcut="Enter" disabled={disabled || unsettled(order) || !broker.modifyOrder || !allowed?.modify} onPress={() => modifyOrder(order)} />
|
|
481
|
-
<IconButton icon="close" label="Cancel order" shortcut="c" color={colors.negative} disabled={disabled || !broker.cancelOrder || !allowed?.cancel} onPress={() => { void cancelOrder(order); }} />
|
|
482
|
+
<IconButton icon="edit" label="Modify order" shortcut={keysHere ? "Enter" : undefined} disabled={disabled || unsettled(order) || !broker.modifyOrder || !allowed?.modify} onPress={() => modifyOrder(order)} />
|
|
483
|
+
<IconButton icon="close" label="Cancel order" shortcut={keysHere ? "c" : undefined} color={colors.negative} disabled={disabled || !broker.cancelOrder || !allowed?.cancel} onPress={() => { void cancelOrder(order); }} />
|
|
482
484
|
</Box>
|
|
483
485
|
</Box>;
|
|
484
486
|
}) : executions.map((execution) => <Box key={execution.execId} paddingX={1} height={native ? 1.6 : 1} flexDirection="row" alignItems="center">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement, useEffect, useRef, useState, type ReactNode } from "react";
|
|
1
|
+
import { createElement, useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
|
|
2
2
|
import { Box, Text } from "../../../../ui";
|
|
3
3
|
import { Button, IconButton } from "../../../../components/ui";
|
|
4
4
|
import { useDialogKeyboard, useOptionalDialog, type AlertContext, type DialogApi } from "../../../../ui/dialog";
|
|
@@ -156,19 +156,24 @@ export function DesktopChatAttachButton({
|
|
|
156
156
|
pickerRef: { current: (() => void) | null };
|
|
157
157
|
}) {
|
|
158
158
|
const inputRef = useRef<FileInputLike | null>(null);
|
|
159
|
+
const pickerCallback = useRef<typeof onFiles | null>(null);
|
|
160
|
+
const openPicker = useCallback(() => {
|
|
161
|
+
pickerCallback.current = onFiles;
|
|
162
|
+
inputRef.current?.click();
|
|
163
|
+
}, [onFiles]);
|
|
159
164
|
useEffect(() => {
|
|
160
|
-
pickerRef.current =
|
|
165
|
+
pickerRef.current = openPicker;
|
|
161
166
|
return () => {
|
|
162
167
|
pickerRef.current = null;
|
|
163
168
|
};
|
|
164
|
-
}, [pickerRef]);
|
|
169
|
+
}, [openPicker, pickerRef]);
|
|
165
170
|
return (
|
|
166
171
|
<>
|
|
167
172
|
<IconButton
|
|
168
173
|
icon="image"
|
|
169
174
|
label="Attach Image"
|
|
170
175
|
size={14}
|
|
171
|
-
onPress={
|
|
176
|
+
onPress={openPicker}
|
|
172
177
|
/>
|
|
173
178
|
{createElement("input", {
|
|
174
179
|
ref: (node: FileInputLike | null) => {
|
|
@@ -186,7 +191,9 @@ export function DesktopChatAttachButton({
|
|
|
186
191
|
const files = Array.from(input.files ?? []);
|
|
187
192
|
// Cleared so picking the same file again still fires a change.
|
|
188
193
|
input.value = "";
|
|
189
|
-
|
|
194
|
+
const receive = pickerCallback.current;
|
|
195
|
+
pickerCallback.current = null;
|
|
196
|
+
if (files.length > 0) receive?.(files);
|
|
190
197
|
},
|
|
191
198
|
})}
|
|
192
199
|
</>
|
|
@@ -457,6 +464,23 @@ function ReviewNote({ note }: { note: ChatImageReviewNote }) {
|
|
|
457
464
|
);
|
|
458
465
|
}
|
|
459
466
|
|
|
467
|
+
export interface ChatPreviewScope {
|
|
468
|
+
isCurrent: () => boolean;
|
|
469
|
+
subscribe: (onChange: () => void) => () => void;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export function ScopedChatPreview({ scope, dismiss, children }: {
|
|
473
|
+
scope: ChatPreviewScope;
|
|
474
|
+
dismiss: () => void;
|
|
475
|
+
children: ReactNode;
|
|
476
|
+
}) {
|
|
477
|
+
const visible = useSyncExternalStore(scope.subscribe, scope.isCurrent);
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
if (!visible) dismiss();
|
|
480
|
+
}, [dismiss, visible]);
|
|
481
|
+
return visible ? children : null;
|
|
482
|
+
}
|
|
483
|
+
|
|
460
484
|
/**
|
|
461
485
|
* A message's images, each in a box sized from its stored dimensions so the
|
|
462
486
|
* transcript does not move as they load. A click opens the viewer.
|
|
@@ -468,6 +492,7 @@ export function DesktopChatMessageImages({
|
|
|
468
492
|
review,
|
|
469
493
|
dimmed,
|
|
470
494
|
onLoadError,
|
|
495
|
+
previewScope,
|
|
471
496
|
}: {
|
|
472
497
|
attachments: ChatAttachment[];
|
|
473
498
|
caption: string;
|
|
@@ -475,6 +500,7 @@ export function DesktopChatMessageImages({
|
|
|
475
500
|
review: Parameters<typeof chatImageReviewNote>[0]["attachmentReview"];
|
|
476
501
|
dimmed: boolean;
|
|
477
502
|
onLoadError?: (attachment: ChatAttachment) => void;
|
|
503
|
+
previewScope?: ChatPreviewScope;
|
|
478
504
|
}) {
|
|
479
505
|
const dialog = useOptionalDialog();
|
|
480
506
|
const rendererHost = useRendererHost();
|
|
@@ -482,8 +508,9 @@ export function DesktopChatMessageImages({
|
|
|
482
508
|
if (attachments.length === 0 && !note) return null;
|
|
483
509
|
const box = attachments.length === 1 ? SINGLE_IMAGE_BOX : GRID_IMAGE_BOX;
|
|
484
510
|
const open = (index: number) => {
|
|
511
|
+
if (previewScope && !previewScope.isCurrent()) return;
|
|
485
512
|
if (dialog) {
|
|
486
|
-
openChatImageViewer(dialog, { attachments, index, caption, author });
|
|
513
|
+
openChatImageViewer(dialog, { attachments, index, caption, author, scope: previewScope });
|
|
487
514
|
return;
|
|
488
515
|
}
|
|
489
516
|
const attachment = attachments[index];
|
|
@@ -518,19 +545,22 @@ export function DesktopChatMessageImages({
|
|
|
518
545
|
/** Opens a message's images full size, at `index`. */
|
|
519
546
|
export function openChatImageViewer(
|
|
520
547
|
dialog: DialogApi,
|
|
521
|
-
options: { attachments: ChatAttachment[]; index: number; caption: string; author: string },
|
|
548
|
+
options: { attachments: ChatAttachment[]; index: number; caption: string; author: string; scope?: ChatPreviewScope },
|
|
522
549
|
): void {
|
|
550
|
+
if (options.scope && !options.scope.isCurrent()) return;
|
|
523
551
|
void dialog.alert({
|
|
524
552
|
closeOnClickOutside: true,
|
|
525
|
-
content: (context: AlertContext) =>
|
|
526
|
-
<ChatImageLightbox
|
|
553
|
+
content: (context: AlertContext) => {
|
|
554
|
+
const lightbox = <ChatImageLightbox
|
|
527
555
|
attachments={options.attachments}
|
|
528
556
|
initialIndex={options.index}
|
|
529
557
|
caption={options.caption}
|
|
530
558
|
author={options.author}
|
|
531
559
|
dismiss={context.dismiss}
|
|
532
|
-
|
|
533
|
-
|
|
560
|
+
canOpen={options.scope?.isCurrent}
|
|
561
|
+
/>;
|
|
562
|
+
return options.scope ? <ScopedChatPreview scope={options.scope} dismiss={context.dismiss}>{lightbox}</ScopedChatPreview> : lightbox;
|
|
563
|
+
},
|
|
534
564
|
});
|
|
535
565
|
}
|
|
536
566
|
|
|
@@ -544,12 +574,14 @@ function ChatImageLightbox({
|
|
|
544
574
|
caption,
|
|
545
575
|
author,
|
|
546
576
|
dismiss,
|
|
577
|
+
canOpen,
|
|
547
578
|
}: {
|
|
548
579
|
attachments: ChatAttachment[];
|
|
549
580
|
initialIndex: number;
|
|
550
581
|
caption: string;
|
|
551
582
|
author: string;
|
|
552
583
|
dismiss: () => void;
|
|
584
|
+
canOpen?: () => boolean;
|
|
553
585
|
}) {
|
|
554
586
|
const colors = useThemeColors();
|
|
555
587
|
const rendererHost = useRendererHost();
|
|
@@ -607,7 +639,9 @@ function ChatImageLightbox({
|
|
|
607
639
|
<Text fg={colors.textMuted} style={{ flex: "1 1 auto", minWidth: 0 }}>
|
|
608
640
|
{attachment.width > 0 ? `${attachment.width}x${attachment.height} · ${formatChatImageSize(attachment.size)}` : ""}
|
|
609
641
|
</Text>
|
|
610
|
-
<Button label={t("Open in Browser")} compact onPress={() => {
|
|
642
|
+
<Button label={t("Open in Browser")} compact onPress={() => {
|
|
643
|
+
if (!canOpen || canOpen()) void rendererHost.openExternal(attachment.url);
|
|
644
|
+
}} />
|
|
611
645
|
<IconButton icon="close" label="Close" shortcut="Esc" onPress={dismiss} />
|
|
612
646
|
</Box>
|
|
613
647
|
</Box>
|
|
@@ -76,6 +76,8 @@ export async function openDmTargetFromCommand(ctx: GloomPluginContext, usernames
|
|
|
76
76
|
openDefaultChatPane(ctx);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
+
const isCurrent = chatController.captureSessionScope();
|
|
80
|
+
if (!isCurrent()) return;
|
|
79
81
|
// The command bar shows a thrown message as it is, so it says why.
|
|
80
82
|
const snapshot = chatController.getSnapshot();
|
|
81
83
|
const userByUsername = buildChatUserByUsername(snapshot.channels, snapshot.messages);
|
|
@@ -85,15 +87,16 @@ export async function openDmTargetFromCommand(ctx: GloomPluginContext, usernames
|
|
|
85
87
|
channels: snapshot.channels,
|
|
86
88
|
});
|
|
87
89
|
if (refusal) throw new Error(refusal);
|
|
88
|
-
let channel: ChatChannel;
|
|
90
|
+
let channel: ChatChannel | null;
|
|
89
91
|
try {
|
|
90
92
|
channel = usernames.length === 1
|
|
91
93
|
? await chatController.openDirectChannel({ username: usernames[0] })
|
|
92
94
|
: await chatController.openGroupChannel({ usernames });
|
|
93
95
|
} catch (error) {
|
|
96
|
+
if (!isCurrent()) return;
|
|
94
97
|
throw new Error(describeConversationStartError(error, usernames, userByUsername));
|
|
95
98
|
}
|
|
96
|
-
openChatConversation(ctx, channel.id);
|
|
99
|
+
if (channel && isCurrent()) openChatConversation(ctx, channel.id);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
/**
|