@gloom-sh/terminal 0.20.17 → 0.20.18
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 +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/data.ts +3 -2
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot.ts +72 -9
- package/src/cli/glossary.ts +64 -10
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/index.ts +100 -42
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +5 -4
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +43 -18
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +2 -1
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +1 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/ticker.ts +10 -2
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Portfolio, PortfolioCash } from "../types/ticker";
|
|
2
2
|
import type { BrokerAccount } from "../types/trading";
|
|
3
|
+
import { portfolioCashBalances } from "./cash-balances";
|
|
3
4
|
import { currencyMinorDigits, getCurrencySymbol, resolveAssetDisplayKind } from "../market-data/market/format";
|
|
4
5
|
import { MISSING_VALUE, formatNumber } from "../utils/format";
|
|
5
6
|
import { parseTypedNumber } from "../utils/decimal-comma";
|
|
@@ -13,7 +14,8 @@ import { parseTypedNumber } from "../utils/decimal-comma";
|
|
|
13
14
|
* at their net market value plus the cash line. A book that holds a short
|
|
14
15
|
* weighs against its gross exposure instead (WeightBasis). A holding without
|
|
15
16
|
* a price is left out of the total and the weights and is listed as
|
|
16
|
-
* unpriced, never valued at zero
|
|
17
|
+
* unpriced, never valued at zero; so is a currency's cash without a rate
|
|
18
|
+
* into the portfolio's currency.
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
/** The cash line's symbol in targets and reports. */
|
|
@@ -50,9 +52,33 @@ export interface AllocationFigures {
|
|
|
50
52
|
|
|
51
53
|
type PortfolioAllocationRow = AllocationHolding & AllocationFigures;
|
|
52
54
|
|
|
55
|
+
/** One currency of a portfolio's cash, valued in the portfolio's currency. */
|
|
56
|
+
export interface AllocationCashBalance {
|
|
57
|
+
currency: string;
|
|
58
|
+
/** In `currency`. */
|
|
59
|
+
amount: number;
|
|
60
|
+
/**
|
|
61
|
+
* In the portfolio's currency; null without a rate to convert it, which
|
|
62
|
+
* leaves it out of the total and the weights as a holding without a price is.
|
|
63
|
+
*/
|
|
64
|
+
value: number | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface PortfolioCashBalanceLine extends AllocationCashBalance {
|
|
68
|
+
/** Its own share of the weight base: null without a value, or against a hedged book's gross exposure. */
|
|
69
|
+
weight: number | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The cash line: all the portfolio's cash, whatever currencies it is in. Its
|
|
74
|
+
* target (`CASH`), drift and trade are the whole line's; each currency's
|
|
75
|
+
* balance has its own value and weight.
|
|
76
|
+
*/
|
|
53
77
|
export interface PortfolioCashLine extends AllocationFigures {
|
|
54
|
-
/**
|
|
55
|
-
value: number;
|
|
78
|
+
/** All the cash in the portfolio's currency; null while a balance has no rate. */
|
|
79
|
+
value: number | null;
|
|
80
|
+
/** One per currency, largest first, those without a value last; none for a target without cash. */
|
|
81
|
+
balances: PortfolioCashBalanceLine[];
|
|
56
82
|
}
|
|
57
83
|
|
|
58
84
|
export interface PortfolioAllocation {
|
|
@@ -60,7 +86,7 @@ export interface PortfolioAllocation {
|
|
|
60
86
|
rows: PortfolioAllocationRow[];
|
|
61
87
|
/** Present when the portfolio has cash or a cash target. */
|
|
62
88
|
cash: PortfolioCashLine | null;
|
|
63
|
-
/** Priced holdings plus cash; null when it cannot be valued. */
|
|
89
|
+
/** Priced holdings plus the cash that has a value; null when it cannot be valued. */
|
|
64
90
|
total: number | null;
|
|
65
91
|
/** What the weights are a share of. */
|
|
66
92
|
weightBasis: WeightBasis;
|
|
@@ -68,6 +94,8 @@ export interface PortfolioAllocation {
|
|
|
68
94
|
weightBase: number | null;
|
|
69
95
|
/** Held symbols without a price, left out of the total and the weights. */
|
|
70
96
|
unpriced: string[];
|
|
97
|
+
/** The currencies of cash without a rate into the portfolio's, left out of the total and the weights. */
|
|
98
|
+
unpricedCash: string[];
|
|
71
99
|
/** The targets of the listed symbols and cash added up; null when none is set. */
|
|
72
100
|
targetSum: number | null;
|
|
73
101
|
}
|
|
@@ -167,26 +195,43 @@ export function allocationTotal(holdings: readonly AllocationHolding[], cashValu
|
|
|
167
195
|
return Number.isFinite(total) ? total : null;
|
|
168
196
|
}
|
|
169
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The cash the total counts, in the portfolio's currency: every balance with a
|
|
200
|
+
* value. Null without cash, so a book of holdings alone totals as before.
|
|
201
|
+
*/
|
|
202
|
+
export function pricedCashValue(balances: readonly Pick<AllocationCashBalance, "value">[] | null | undefined): number | null {
|
|
203
|
+
if (!balances?.length) return null;
|
|
204
|
+
return balances.reduce((sum, balance) => sum + (finite(balance.value) ? balance.value : 0), 0);
|
|
205
|
+
}
|
|
206
|
+
|
|
170
207
|
export function buildPortfolioAllocation({
|
|
171
208
|
holdings,
|
|
172
|
-
|
|
209
|
+
cash = [],
|
|
173
210
|
targets,
|
|
174
211
|
}: {
|
|
175
212
|
holdings: readonly AllocationHolding[];
|
|
176
|
-
/**
|
|
177
|
-
|
|
213
|
+
/** Each currency's cash, valued in the portfolio's currency (null without a rate). */
|
|
214
|
+
cash?: readonly AllocationCashBalance[] | null;
|
|
178
215
|
targets?: Readonly<Record<string, number>>;
|
|
179
216
|
}): PortfolioAllocation {
|
|
217
|
+
const balances = cash ?? [];
|
|
218
|
+
const cashValue = pricedCashValue(balances);
|
|
180
219
|
const total = allocationTotal(holdings, cashValue);
|
|
181
220
|
const base = allocationWeightBase(holdings, cashValue);
|
|
221
|
+
// Cash is no exposure: against a gross base it keeps its target but has no weight or trade.
|
|
222
|
+
const cashBase = base.basis === "gross" ? null : base.value;
|
|
182
223
|
const rows = holdings.map((holding) => ({ ...holding, ...allocationFigures(holding, base.value, holdingTarget(targets, holding.symbol)) }));
|
|
183
224
|
const cashTarget = targets?.[CASH_SYMBOL];
|
|
184
|
-
|
|
225
|
+
// The whole line is unknown while one balance is: its weight and trade would leave that balance out.
|
|
226
|
+
const lineValue = balances.every((balance) => finite(balance.value)) ? cashValue ?? 0 : null;
|
|
227
|
+
const cashLine = balances.length > 0 || finite(cashTarget)
|
|
185
228
|
? {
|
|
186
|
-
value:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
229
|
+
value: lineValue,
|
|
230
|
+
balances: balances
|
|
231
|
+
.map((balance) => ({ ...balance, weight: finite(balance.value) ? lotWeight(balance.value, cashBase) : null }))
|
|
232
|
+
.sort((left, right) => (finite(left.value) ? 0 : 1) - (finite(right.value) ? 0 : 1)
|
|
233
|
+
|| Math.abs(right.value ?? 0) - Math.abs(left.value ?? 0)),
|
|
234
|
+
...allocationFigures({ held: true, marketValue: lineValue, units: 0, unitPrice: null }, cashBase, cashTarget),
|
|
190
235
|
}
|
|
191
236
|
: null;
|
|
192
237
|
let targetSum: number | null = null;
|
|
@@ -196,11 +241,12 @@ export function buildPortfolioAllocation({
|
|
|
196
241
|
}
|
|
197
242
|
return {
|
|
198
243
|
rows,
|
|
199
|
-
cash,
|
|
244
|
+
cash: cashLine,
|
|
200
245
|
total,
|
|
201
246
|
weightBasis: base.basis,
|
|
202
247
|
weightBase: base.value,
|
|
203
248
|
unpriced: holdings.filter((holding) => holding.held && !finite(holding.marketValue)).map((holding) => holding.symbol),
|
|
249
|
+
unpricedCash: balances.filter((balance) => !finite(balance.value)).map((balance) => balance.currency),
|
|
204
250
|
targetSum,
|
|
205
251
|
};
|
|
206
252
|
}
|
|
@@ -218,18 +264,32 @@ export function hasTargetWeights(portfolio: Pick<Portfolio, "targetWeights"> | n
|
|
|
218
264
|
return !!portfolio?.targetWeights && Object.keys(portfolio.targetWeights).length > 0;
|
|
219
265
|
}
|
|
220
266
|
|
|
267
|
+
/** A portfolio's cash, in the currencies it is held in, and where it is from. */
|
|
268
|
+
export interface ResolvedPortfolioCash {
|
|
269
|
+
/** Recorded with `portfolio cash set`, or reported by the broker account. */
|
|
270
|
+
source: "broker" | "manual";
|
|
271
|
+
/** One balance per currency: the broker account's total cash, or each currency entered by hand. */
|
|
272
|
+
balances: PortfolioCash[];
|
|
273
|
+
}
|
|
274
|
+
|
|
221
275
|
/**
|
|
222
|
-
* The portfolio's cash
|
|
223
|
-
*
|
|
276
|
+
* The portfolio's cash. A broker account that reports its cash is used
|
|
277
|
+
* instead of the balances entered by hand, so the two never add up.
|
|
224
278
|
*/
|
|
225
279
|
export function resolvePortfolioCash(
|
|
226
|
-
portfolio: Pick<Portfolio, "cash"> | null | undefined,
|
|
280
|
+
portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined,
|
|
227
281
|
account: Pick<BrokerAccount, "totalCashValue" | "currency"> | null | undefined,
|
|
228
|
-
):
|
|
282
|
+
): ResolvedPortfolioCash | null {
|
|
229
283
|
if (account && finite(account.totalCashValue)) {
|
|
230
|
-
return { amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? ""
|
|
284
|
+
return { source: "broker", balances: [{ amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? "" }] };
|
|
231
285
|
}
|
|
232
|
-
|
|
286
|
+
const balances = portfolioCashBalances(portfolio);
|
|
287
|
+
return balances.length > 0 ? { source: "manual", balances } : null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** What a cash row is called: `CASH`, or `CASH TRY` for a currency other than the portfolio's or one of several. */
|
|
291
|
+
export function cashLineLabel(currency: string | null | undefined, portfolioCurrency: string, several = false): string {
|
|
292
|
+
return currency && (several || currency !== portfolioCurrency) ? `${CASH_SYMBOL} ${currency}` : CASH_SYMBOL;
|
|
233
293
|
}
|
|
234
294
|
|
|
235
295
|
/**
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Portfolio, PortfolioCash } from "../types/ticker";
|
|
2
|
+
import { isRecord } from "../utils/guards";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A manual portfolio's cash, one balance per currency (HKD and USD side by
|
|
6
|
+
* side). The first balance is saved in `Portfolio.cash`, which every build
|
|
7
|
+
* before several currencies reads, and the others in `Portfolio.otherCash`,
|
|
8
|
+
* so such a build sees one valid balance and never a second copy of it.
|
|
9
|
+
* Every reader takes the balances from `portfolioCashBalances`, which counts
|
|
10
|
+
* each currency once, and every writer saves them with
|
|
11
|
+
* `withPortfolioCashBalances`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const CURRENCY_CODE = /^[A-Z]{3}$/;
|
|
15
|
+
|
|
16
|
+
/** A balance as saved: a finite amount in an upper-case ISO code; null for anything else. */
|
|
17
|
+
function savedBalance(value: unknown): PortfolioCash | null {
|
|
18
|
+
if (!isRecord(value) || typeof value.amount !== "number" || !Number.isFinite(value.amount)) return null;
|
|
19
|
+
return typeof value.currency === "string" && CURRENCY_CODE.test(value.currency)
|
|
20
|
+
? { amount: value.amount, currency: value.currency }
|
|
21
|
+
: null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The portfolio's cash entered by hand, `cash` first and then the other
|
|
26
|
+
* currencies in the order they were set. A currency is counted once: a
|
|
27
|
+
* second entry of it (an older build that set `cash` to a currency
|
|
28
|
+
* `otherCash` also holds) gives way to the first, which is `cash`.
|
|
29
|
+
*/
|
|
30
|
+
export function portfolioCashBalances(portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): PortfolioCash[] {
|
|
31
|
+
if (!portfolio) return [];
|
|
32
|
+
const balances: PortfolioCash[] = [];
|
|
33
|
+
const others: unknown[] = Array.isArray(portfolio.otherCash) ? portfolio.otherCash : [];
|
|
34
|
+
for (const entry of [portfolio.cash, ...others]) {
|
|
35
|
+
const balance = savedBalance(entry);
|
|
36
|
+
if (balance && !balances.some((kept) => kept.currency === balance.currency)) balances.push(balance);
|
|
37
|
+
}
|
|
38
|
+
return balances;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The portfolio holding these balances: the first in `cash`, the others in
|
|
43
|
+
* `otherCash`, neither field when there are none. Each currency once, the
|
|
44
|
+
* first entry of it kept.
|
|
45
|
+
*/
|
|
46
|
+
export function withPortfolioCashBalances<T extends object>(
|
|
47
|
+
portfolio: T,
|
|
48
|
+
balances: readonly PortfolioCash[],
|
|
49
|
+
): Omit<T, "cash" | "otherCash"> & Pick<Portfolio, "cash" | "otherCash"> {
|
|
50
|
+
const { cash: _cash, otherCash: _otherCash, ...rest } = portfolio as T & Pick<Portfolio, "cash" | "otherCash">;
|
|
51
|
+
const [first, ...others] = portfolioCashBalances({ otherCash: [...balances] });
|
|
52
|
+
return {
|
|
53
|
+
...rest,
|
|
54
|
+
...(first ? { cash: first } : {}),
|
|
55
|
+
...(others.length > 0 ? { otherCash: others } : {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A pulled portfolio from a build that does not send `otherCash` (an older
|
|
61
|
+
* desktop build, which strips it from every push), keeping the other
|
|
62
|
+
* currencies this device holds. That build saw `cash` alone, so its `cash`
|
|
63
|
+
* stands, set, replaced or cleared, and a balance here in that same currency
|
|
64
|
+
* gives way to it rather than counting twice. Anything else is taken as it
|
|
65
|
+
* came.
|
|
66
|
+
*/
|
|
67
|
+
export function withKeptOtherCash(pulled: unknown, local: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): unknown {
|
|
68
|
+
if (!isRecord(pulled) || pulled.otherCash !== undefined || !local) return pulled;
|
|
69
|
+
const [, ...others] = portfolioCashBalances(local);
|
|
70
|
+
if (others.length === 0) return pulled;
|
|
71
|
+
const seen = savedBalance(pulled.cash);
|
|
72
|
+
return withPortfolioCashBalances(pulled, [
|
|
73
|
+
...(seen ? [seen] : []),
|
|
74
|
+
...others.filter((balance) => balance.currency !== seen?.currency),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
@@ -6,6 +6,7 @@ import { parseCollectionRef } from "../team/collections";
|
|
|
6
6
|
import { findNamedCollection } from "./collection-name";
|
|
7
7
|
import { isFuturesTicker } from "./futures-positions";
|
|
8
8
|
import { manualPortfolioLots, mergeLotCostTerms, type LotCostFxConflict } from "./manual-lots";
|
|
9
|
+
import { portfolioCashBalances, withPortfolioCashBalances } from "./cash-balances";
|
|
9
10
|
|
|
10
11
|
export interface DeleteWatchlistResult {
|
|
11
12
|
config: AppConfig;
|
|
@@ -225,20 +226,54 @@ function updatePortfolio(config: AppConfig, portfolioId: string, update: (portfo
|
|
|
225
226
|
};
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
/**
|
|
229
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Records the cash a portfolio holds in one currency, beside its positions and
|
|
231
|
+
* its cash in any other currency, which stay. `replaced` is that currency's
|
|
232
|
+
* earlier balance when it differs from the new one, for the caller to say
|
|
233
|
+
* what went (HK$38,000.00 replaced by HK$39,000.00), and null when there was
|
|
234
|
+
* none or it was the same. `balances` is all the cash after the change.
|
|
235
|
+
*/
|
|
236
|
+
export function setPortfolioCash(
|
|
237
|
+
config: AppConfig,
|
|
238
|
+
portfolioId: string,
|
|
239
|
+
cash: PortfolioCash,
|
|
240
|
+
): { config: AppConfig; replaced: PortfolioCash | null; balances: PortfolioCash[] } {
|
|
230
241
|
const currency = cash.currency.trim().toUpperCase();
|
|
231
242
|
if (!Number.isFinite(cash.amount)) throw new Error("Cash amount must be a valid number.");
|
|
232
243
|
if (!/^[A-Z]{3}$/.test(currency)) throw new Error(`"${cash.currency}" is not a currency code such as USD or EUR.`);
|
|
233
|
-
|
|
244
|
+
const before = portfolioCashBalances(config.portfolios.find((portfolio) => portfolio.id === portfolioId));
|
|
245
|
+
const previous = before.find((balance) => balance.currency === currency);
|
|
246
|
+
const replaced = previous && previous.amount !== 0 && previous.amount !== cash.amount ? { ...previous } : null;
|
|
247
|
+
// A currency held already keeps its place, so the first balance stays the one an older build reads.
|
|
248
|
+
const balances = previous
|
|
249
|
+
? before.map((balance) => (balance.currency === currency ? { amount: cash.amount, currency } : balance))
|
|
250
|
+
: [...before, { amount: cash.amount, currency }];
|
|
251
|
+
return {
|
|
252
|
+
config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
|
|
253
|
+
replaced,
|
|
254
|
+
balances,
|
|
255
|
+
};
|
|
234
256
|
}
|
|
235
257
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Clears a portfolio's cash in one currency, or in every currency when none
|
|
260
|
+
* is given. `removed` is the balances cleared, empty when there was nothing
|
|
261
|
+
* to clear; `balances` is the cash left.
|
|
262
|
+
*/
|
|
263
|
+
export function clearPortfolioCash(
|
|
264
|
+
config: AppConfig,
|
|
265
|
+
portfolioId: string,
|
|
266
|
+
currency?: string,
|
|
267
|
+
): { config: AppConfig; removed: PortfolioCash[]; balances: PortfolioCash[] } {
|
|
268
|
+
const wanted = currency?.trim().toUpperCase();
|
|
269
|
+
const before = portfolioCashBalances(config.portfolios.find((entry) => entry.id === portfolioId));
|
|
270
|
+
const removed = before.filter((balance) => wanted == null || balance.currency === wanted);
|
|
271
|
+
if (removed.length === 0) return { config, removed, balances: before };
|
|
272
|
+
const balances = before.filter((balance) => !removed.includes(balance));
|
|
239
273
|
return {
|
|
240
|
-
config: updatePortfolio(config, portfolioId, (
|
|
241
|
-
|
|
274
|
+
config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
|
|
275
|
+
removed,
|
|
276
|
+
balances,
|
|
242
277
|
};
|
|
243
278
|
}
|
|
244
279
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "../../types/config";
|
|
16
16
|
import type { DesktopSharedStateSnapshot, OtherWindowTab } from "../../types/desktop-window";
|
|
17
17
|
import { MAIN_WINDOW_ID, type ExtraWindowRecord } from "./screen-setup";
|
|
18
|
+
import { applyProfileEdits, diffProfile, type ProfileJson } from "../../data/profile-merge";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Every full desktop window shows its own layout tabs from one shared config.
|
|
@@ -320,6 +321,18 @@ function inSentOrder(layouts: SavedLayout[], sentIds: readonly string[], owns: (
|
|
|
320
321
|
return reordered;
|
|
321
322
|
}
|
|
322
323
|
|
|
324
|
+
/**
|
|
325
|
+
* The plugins' settings with what a window changed in them since `before`,
|
|
326
|
+
* value by value, the window's value winning where both changed one: an
|
|
327
|
+
* alert another window or a `gloom` command added since stays when this
|
|
328
|
+
* window's alert check rewrote the same list.
|
|
329
|
+
*/
|
|
330
|
+
function mergedPluginConfig(shared: AppConfig["pluginConfig"], before: AppConfig["pluginConfig"], after: AppConfig["pluginConfig"]): AppConfig["pluginConfig"] {
|
|
331
|
+
if (deepEqual(shared, before)) return after;
|
|
332
|
+
const json = (value: AppConfig["pluginConfig"]) => JSON.parse(JSON.stringify(value ?? {})) as ProfileJson;
|
|
333
|
+
return applyProfileEdits(json(shared), diffProfile(json(before), json(after)), { conflicts: "take" }) as AppConfig["pluginConfig"];
|
|
334
|
+
}
|
|
335
|
+
|
|
323
336
|
/**
|
|
324
337
|
* Applies what `windowId` sent on top of the shared state, counting only what
|
|
325
338
|
* changed since `base`, the state the window drew from. Settings and lists
|
|
@@ -349,6 +362,7 @@ export function mergeWindowSnapshot(
|
|
|
349
362
|
for (const key of new Set([...Object.keys(afterRecord), ...Object.keys(beforeRecord)])) {
|
|
350
363
|
if (LAYOUT_KEYS.has(key) || deepEqual(afterRecord[key], beforeRecord[key])) continue;
|
|
351
364
|
if (afterRecord[key] === undefined) delete configRecord[key];
|
|
365
|
+
else if (key === "pluginConfig") configRecord[key] = mergedPluginConfig(state.config.pluginConfig, before.config.pluginConfig, after.config.pluginConfig);
|
|
352
366
|
else configRecord[key] = afterRecord[key];
|
|
353
367
|
}
|
|
354
368
|
|
|
@@ -410,6 +410,8 @@ function WebDataTableRowInner<
|
|
|
410
410
|
data-gloom-cell-instant={cell.value instanceof Date && Number.isFinite(cell.value.getTime()) ? cell.value.toISOString() : undefined}
|
|
411
411
|
// The full-precision number behind a rounded cell (a trade of -9.4596 for -9.45963753), for the same reports.
|
|
412
412
|
data-gloom-cell-value={typeof cell.value === "number" && Number.isFinite(cell.value) ? String(cell.value) : undefined}
|
|
413
|
+
// A value this row is still waiting on (DataTableCell.mayBeBlank): its blank is no lost data.
|
|
414
|
+
data-gloom-cell-may-be-blank={cell.mayBeBlank ? "true" : undefined}
|
|
413
415
|
style={{
|
|
414
416
|
minWidth: 0,
|
|
415
417
|
position: freezeFirstColumn && columnIndex === 0 ? "sticky" : undefined,
|
|
@@ -12,11 +12,36 @@ import { WebIcon, WebIconButton } from "../desktop/icons";
|
|
|
12
12
|
import { WebMenu } from "../desktop/menu";
|
|
13
13
|
import { WebPopover } from "../desktop/popover";
|
|
14
14
|
import { useHorizontalOverflow } from "./overflow-fade";
|
|
15
|
+
import { FADE_PX } from "./overflow-fade-px";
|
|
16
|
+
import { isLiveResizing, onLiveResizeEnd } from "../../../ui/live-resize";
|
|
15
17
|
import { useTopSurfaceColor } from "./top-surface";
|
|
16
18
|
import { hideDragShield, showDragShield } from "./drag-shield";
|
|
17
19
|
|
|
18
20
|
type CssVars = CSSProperties & Record<`--${string}`, string>;
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Scrolls a strip so `tab` shows. A title-bar strip also keeps it clear of
|
|
24
|
+
* the fades at its edges (overflow-fade.ts), which would fade the active tab's
|
|
25
|
+
* box and let the header's rule show through it; when the tab cannot clear
|
|
26
|
+
* both, its start shows. At either end the fade on that side goes, so the
|
|
27
|
+
* first and last tabs sit at the edge.
|
|
28
|
+
*/
|
|
29
|
+
function revealTab(list: HTMLElement | null, tab: HTMLElement | null, clearOfFades: boolean): void {
|
|
30
|
+
if (!list || !tab) return;
|
|
31
|
+
if (!clearOfFades) {
|
|
32
|
+
tab.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const box = list.getBoundingClientRect();
|
|
36
|
+
const rect = tab.getBoundingClientRect();
|
|
37
|
+
// How far to scroll right: at least this for the tab's end to clear the
|
|
38
|
+
// end fade, at most that for its start to clear the start fade.
|
|
39
|
+
const atLeast = rect.right - (box.right - FADE_PX);
|
|
40
|
+
const atMost = rect.left - (box.left + FADE_PX);
|
|
41
|
+
const delta = atLeast > 0 ? Math.min(atLeast, atMost) : atMost < 0 ? atMost : 0;
|
|
42
|
+
if (delta !== 0) list.scrollLeft += delta;
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
export function WebTabs({
|
|
21
46
|
tabs,
|
|
22
47
|
activeValue,
|
|
@@ -61,11 +86,34 @@ export function WebTabs({
|
|
|
61
86
|
// Again once the overflow chevron appears: it narrows the strip, which would
|
|
62
87
|
// otherwise push the last tab's label past the edge.
|
|
63
88
|
useEffect(() => {
|
|
64
|
-
activeTabRef.current
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
revealTab(tabListRef.current, activeTabRef.current, header);
|
|
90
|
+
}, [activeValue, tabs, overflowing, header]);
|
|
91
|
+
// A title-bar strip again when it changes width (its pane resized, focus
|
|
92
|
+
// showing the header's buttons), so the active tab stays clear of the fades;
|
|
93
|
+
// after a live resize rather than on every frame of it.
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const list = tabListRef.current;
|
|
96
|
+
if (!header || !list || typeof ResizeObserver === "undefined") return;
|
|
97
|
+
let width = list.clientWidth;
|
|
98
|
+
let pending = false;
|
|
99
|
+
const reveal = () => revealTab(list, activeTabRef.current, true);
|
|
100
|
+
const observer = new ResizeObserver(() => {
|
|
101
|
+
if (list.clientWidth === width) return;
|
|
102
|
+
width = list.clientWidth;
|
|
103
|
+
if (isLiveResizing()) pending = true;
|
|
104
|
+
else reveal();
|
|
67
105
|
});
|
|
68
|
-
|
|
106
|
+
const stopListening = onLiveResizeEnd(() => {
|
|
107
|
+
if (!pending) return;
|
|
108
|
+
pending = false;
|
|
109
|
+
reveal();
|
|
110
|
+
});
|
|
111
|
+
observer.observe(list);
|
|
112
|
+
return () => {
|
|
113
|
+
observer.disconnect();
|
|
114
|
+
stopListening();
|
|
115
|
+
};
|
|
116
|
+
}, [header]);
|
|
69
117
|
useEffect(() => {
|
|
70
118
|
if (!overflowing) setOverflowMenuOpen(false);
|
|
71
119
|
}, [overflowing]);
|
|
@@ -78,9 +126,8 @@ export function WebTabs({
|
|
|
78
126
|
onSelect(value);
|
|
79
127
|
// Also when the chosen tab was already active, so the effect above does not run.
|
|
80
128
|
requestAnimationFrame(() => {
|
|
81
|
-
tabListRef.current
|
|
82
|
-
|
|
83
|
-
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
129
|
+
const list = tabListRef.current;
|
|
130
|
+
revealTab(list, list?.querySelector<HTMLElement>(`[data-tab-value="${CSS.escape(value)}"]`) ?? null, header);
|
|
84
131
|
});
|
|
85
132
|
};
|
|
86
133
|
const startReorder = (sourceValue: string, event: ReactMouseEvent<HTMLButtonElement>) => {
|
|
@@ -220,7 +267,9 @@ export function WebTabs({
|
|
|
220
267
|
"--tab-active-fg": header ? "var(--pane-tab-active-fg)" : palette.activeFg,
|
|
221
268
|
flex: "0 0 auto",
|
|
222
269
|
minWidth: 0,
|
|
223
|
-
|
|
270
|
+
// A title-bar tab's margins are its look (styles.css): the active one
|
|
271
|
+
// reaches past the header's rule.
|
|
272
|
+
margin: header ? undefined : 0,
|
|
224
273
|
transform: `translateX(${dragTranslateX}px)${sourceDragging ? " scale(1.03)" : ""}`,
|
|
225
274
|
zIndex: dragSourceValue === tab.value ? 2 : undefined,
|
|
226
275
|
willChange: dragSourceValue ? "transform" : undefined,
|
|
@@ -319,8 +319,9 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
319
319
|
[data-gloom-role="status-bar"] span {
|
|
320
320
|
line-height: var(--cell-h);
|
|
321
321
|
}
|
|
322
|
-
/* The returning-user strip under the header: one row of shell chrome, ruled off from the layout. */
|
|
323
|
-
[data-gloom-role="since-last-visit"]
|
|
322
|
+
/* The returning-user strip and the new Pro payer's row under the header: one row of shell chrome each, ruled off from the layout. */
|
|
323
|
+
[data-gloom-role="since-last-visit"],
|
|
324
|
+
[data-gloom-role="pro-welcome"] {
|
|
324
325
|
flex: none;
|
|
325
326
|
align-items: center;
|
|
326
327
|
border-bottom: 1px solid var(--gloom-hairline);
|
|
@@ -535,6 +536,9 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
535
536
|
/* Header colour left above a box, and the box's line: the header rule's width. */
|
|
536
537
|
--pane-tab-top-gap: 2px;
|
|
537
538
|
--pane-tab-rule: 1px;
|
|
539
|
+
/* The strip hangs this far past the rule into the pane (pane/header.tsx says
|
|
540
|
+
why), and only the active tab reaches into it: the others end on the rule. */
|
|
541
|
+
padding-bottom: var(--pane-tab-overhang, 0px);
|
|
538
542
|
}
|
|
539
543
|
[data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"] {
|
|
540
544
|
height: calc(100% - var(--pane-tab-top-gap));
|
|
@@ -553,6 +557,10 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
|
|
|
553
557
|
}
|
|
554
558
|
[data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"]::after { content: none; }
|
|
555
559
|
[data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"][data-active="true"] {
|
|
560
|
+
/* Past the rule into the pane, with the label where it was. */
|
|
561
|
+
height: calc(100% - var(--pane-tab-top-gap) + var(--pane-tab-overhang, 0px));
|
|
562
|
+
margin-bottom: calc(-1 * var(--pane-tab-overhang, 0px));
|
|
563
|
+
padding-bottom: calc(var(--pane-tab-top-gap) + 2 * var(--pane-tab-rule) - var(--pane-tab-top-inset, 0px) + var(--pane-tab-overhang, 0px));
|
|
556
564
|
background-color: var(--pane-tab-active-bg, var(--gloom-bg));
|
|
557
565
|
border-color: var(--pane-tab-border, var(--gloom-hairline));
|
|
558
566
|
}
|
|
@@ -1639,13 +1647,13 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
|
|
|
1639
1647
|
/* ===== Chrome: title-bar tab overflow, query bar edges, quick-add band ===== */
|
|
1640
1648
|
|
|
1641
1649
|
/* Title-bar tabs that do not fit: a chevron after the strip lists them all.
|
|
1642
|
-
The strip hangs over the header's rules
|
|
1643
|
-
on the header's centre line. */
|
|
1650
|
+
The strip hangs over the header's rules and past the bottom one; the
|
|
1651
|
+
padding puts the chevron back on the header's centre line. */
|
|
1644
1652
|
.gloom-tab-overflow {
|
|
1645
1653
|
flex: none;
|
|
1646
1654
|
display: flex;
|
|
1647
1655
|
align-items: center;
|
|
1648
|
-
padding: var(--pane-tab-top-inset, 0px) 0 1px 2px;
|
|
1656
|
+
padding: var(--pane-tab-top-inset, 0px) 0 calc(1px + var(--pane-tab-overhang, 0px)) 2px;
|
|
1649
1657
|
}
|
|
1650
1658
|
|
|
1651
1659
|
/* A search with nothing beside it takes the room filters would have used. */
|
|
@@ -67,6 +67,10 @@ export async function handleDesktopBackendRequest(
|
|
|
67
67
|
return null;
|
|
68
68
|
case "ticker.loadAll":
|
|
69
69
|
return backend.requireServices().tickerRepository.loadAllTickers();
|
|
70
|
+
case "ticker.changesElsewhere":
|
|
71
|
+
return backend.requireServices().tickerRepository.changesElsewhere?.() ?? null;
|
|
72
|
+
case "ticker.takeDeletedElsewhere":
|
|
73
|
+
return backend.requireServices().tickerRepository.takeRowsDeletedElsewhere?.() ?? [];
|
|
70
74
|
case "ticker.load":
|
|
71
75
|
return backend.requireServices().tickerRepository.loadTicker(request.payload.symbol);
|
|
72
76
|
case "ticker.save":
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
reconcileAppSessionSnapshot,
|
|
8
8
|
type AppSessionSnapshot,
|
|
9
9
|
} from "../../../../core/state/session-persistence";
|
|
10
|
-
import { saveConfig } from "../../../../data/config/store";
|
|
10
|
+
import { saveConfig, watchExternalConfigChanges } from "../../../../data/config/store";
|
|
11
11
|
import { pluginAutoUpdateEnabled } from "../../../../plugins/auto-update";
|
|
12
12
|
import { startNodePluginAutoUpdates } from "../../../../plugins/auto-update-node";
|
|
13
13
|
import { getPluginSeedProgress, subscribePluginSeed } from "../../../../plugins/seed-progress";
|
|
@@ -167,6 +167,7 @@ export class DesktopBackend {
|
|
|
167
167
|
private pluginAutoUpdatesStarted = false;
|
|
168
168
|
private commandLinksScheduled = false;
|
|
169
169
|
private remoteControlServer: RemoteControlServer | null = null;
|
|
170
|
+
private stopWatchingConfig: (() => void) | null = null;
|
|
170
171
|
private readonly pendingDeepLinks: string[] = [];
|
|
171
172
|
private readonly contextMenuRequestRpcs = new Map<string, DesktopRpc>();
|
|
172
173
|
/** Extra windows open once the main window has drawn, like popped-out panes. */
|
|
@@ -494,15 +495,33 @@ export class DesktopBackend {
|
|
|
494
495
|
});
|
|
495
496
|
this.workspace = createDesktopWorkspace(config, this.getSessionSnapshot(), this.windowController?.screenSetup.windows);
|
|
496
497
|
this.reconcileWindows();
|
|
498
|
+
this.watchConfigWrittenElsewhere(config.dataDir);
|
|
497
499
|
return { config, services };
|
|
498
500
|
}
|
|
499
501
|
|
|
502
|
+
/**
|
|
503
|
+
* A `gloom` command run beside the app writes the same config.json (an
|
|
504
|
+
* alert, a setting, a watchlist): the change is taken in and shown in every
|
|
505
|
+
* window, so no save of the app's copy writes over it.
|
|
506
|
+
*/
|
|
507
|
+
private watchConfigWrittenElsewhere(dataDir: string): void {
|
|
508
|
+
this.stopWatchingConfig?.();
|
|
509
|
+
this.stopWatchingConfig = watchExternalConfigChanges(dataDir, (change) => {
|
|
510
|
+
if (!this.config || !this.workspace) return;
|
|
511
|
+
const next = change.apply(this.config);
|
|
512
|
+
if (next === this.config) return;
|
|
513
|
+
this.commitDesktopSnapshotInBackground(this.workspace.replaceConfig(next, { layoutChanged: false }), { persistConfig: false });
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
500
517
|
/** Compiles the view's plugins ahead of its first `plugins.listExternal`. */
|
|
501
518
|
prefetchExternalPluginBundles(): void {
|
|
502
519
|
prefetchExternalPluginBundles();
|
|
503
520
|
}
|
|
504
521
|
|
|
505
522
|
teardownServices(): void {
|
|
523
|
+
this.stopWatchingConfig?.();
|
|
524
|
+
this.stopWatchingConfig = null;
|
|
506
525
|
this.stopRemoteControlServer();
|
|
507
526
|
this.capabilityBridge.disposeAll();
|
|
508
527
|
this.httpStreamBridge.disposeAll();
|
|
@@ -908,6 +927,8 @@ export class DesktopBackend {
|
|
|
908
927
|
case "update.start":
|
|
909
928
|
case "update.apply":
|
|
910
929
|
case "ticker.loadAll":
|
|
930
|
+
case "ticker.changesElsewhere":
|
|
931
|
+
case "ticker.takeDeletedElsewhere":
|
|
911
932
|
case "ticker.load":
|
|
912
933
|
case "ticker.save":
|
|
913
934
|
case "ticker.delete":
|
|
@@ -187,7 +187,12 @@ function fromPrivateSource<T>(source: string, compile: (path: string) => T): T {
|
|
|
187
187
|
writeFileSync(path, source, { flag: "wx", mode: 0o600 });
|
|
188
188
|
return compile(path);
|
|
189
189
|
} finally {
|
|
190
|
-
|
|
190
|
+
// Windows can still hold the file for a moment; a folder left behind must not cost the window its minimum size.
|
|
191
|
+
try {
|
|
192
|
+
rmSync(folder, { recursive: true, force: true });
|
|
193
|
+
} catch (error) {
|
|
194
|
+
logFailure("window", "Could not remove the minimum size helper's temporary folder")(error);
|
|
195
|
+
}
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
|
|
@@ -272,6 +272,10 @@ interface DesktopBackendRequestMap {
|
|
|
272
272
|
/** Installs the staged update and relaunches. Sent only when the user presses Restart. */
|
|
273
273
|
"update.apply": { request: null; response: null };
|
|
274
274
|
"ticker.loadAll": { request: null; response: TickerRecord[] };
|
|
275
|
+
/** Changes when another program commits to the database (`TickerStore.changesElsewhere`). */
|
|
276
|
+
"ticker.changesElsewhere": { request: null; response: number | null };
|
|
277
|
+
/** The rows another program deleted that the backend held (`TickerRepository.takeRowsDeletedElsewhere`). */
|
|
278
|
+
"ticker.takeDeletedElsewhere": { request: null; response: string[] };
|
|
275
279
|
"ticker.load": { request: { symbol: string }; response: TickerRecord | null };
|
|
276
280
|
"ticker.save": { request: { ticker: TickerRecord }; response: null };
|
|
277
281
|
"ticker.delete": { request: { symbol: string }; response: null };
|