gloomberb 0.20.4 → 0.20.6
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/README.md +3 -1
- package/README.zh-CN.md +1 -1
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +4 -1
- package/src/api-client/data.ts +148 -37
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/types/econ.ts +30 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +6 -0
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +238 -57
- package/src/cli/commands/news-search.ts +81 -14
- package/src/cli/commands/overview.ts +27 -6
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -1
- package/src/cli/early-command.ts +2 -0
- package/src/cli/errors.ts +10 -1
- package/src/cli/fx-forward.ts +89 -7
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/glossary.ts +19 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +38 -9
- package/src/cli/listing-arg.ts +17 -5
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +52 -3
- package/src/cli/output-file.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +15 -0
- package/src/cli/pane-functions/function-help.ts +4 -4
- package/src/cli/pane-functions/headless.ts +9 -4
- package/src/cli/pane-functions/index.ts +6 -4
- package/src/cli/pane-functions/resolver.ts +2 -2
- package/src/cli/result.ts +21 -2
- package/src/cli/spreadsheet-hint.ts +7 -3
- package/src/cli/treasury-yields.ts +5 -3
- package/src/components/chart/composite/legend.tsx +40 -2
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +16 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -8
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/data-table/opentui/index.tsx +11 -4
- package/src/components/ui/data-table/opentui/model.ts +8 -6
- package/src/components/ui/data-table/types.ts +6 -1
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/table-layout.ts +38 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/docs/snapshot.json +30 -13
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +147 -17
- package/src/market-data/market/status.ts +17 -1
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- package/src/plugins/builtin/alerts/metric-data.ts +15 -2
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/backtest/headless.ts +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/cds/model.ts +0 -6
- package/src/plugins/builtin/chart-composer/formula.ts +16 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
- package/src/plugins/builtin/chart-composer/headless.ts +4 -2
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
- package/src/plugins/builtin/credit-boards/client.ts +8 -0
- package/src/plugins/builtin/credit-boards/headless.ts +4 -1
- package/src/plugins/builtin/credit-boards/model.ts +58 -4
- package/src/plugins/builtin/credit-boards/series.ts +63 -6
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
- package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
- package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/model.ts +12 -6
- package/src/plugins/builtin/credit-conditions/series.ts +2 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +115 -8
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +42 -8
- package/src/plugins/builtin/econ/types.ts +3 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +3 -0
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +11 -1
- package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/index.tsx +1 -0
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/headless-schema.ts +4 -3
- package/src/plugins/builtin/research/headless.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
- package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
- package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
- package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/api.ts +47 -4
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
- package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
- package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
- package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/portfolio/collection-name.ts +22 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +44 -18
- package/src/remote/schema.ts +21 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-tree.tsx +14 -2
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/dom/data-table/frozen-column.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +27 -9
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
- package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +2 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
- package/src/sources/provider-router/cache.ts +3 -1
- package/src/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/bar-spacing.ts +33 -0
- package/src/time-series/base-series.ts +21 -3
- package/src/time-series/chart-bounds.ts +31 -0
- package/src/time-series/field-catalog.ts +17 -0
- package/src/time-series/fundamentals.ts +143 -11
- package/src/time-series/ice-credit.ts +32 -6
- package/src/time-series/resolve.ts +11 -7
- package/src/time-series/session-bar.ts +78 -9
- package/src/time-series/studies/formula.ts +53 -10
- package/src/time-series/studies/pair.ts +18 -7
- package/src/time-series/studies/units.ts +49 -2
- package/src/time-series/types.ts +12 -0
- package/src/types/desktop-window.ts +2 -0
- package/src/types/financials.ts +7 -0
- package/src/types/headless.ts +8 -0
- package/src/types/plugin-pane-settings.ts +2 -0
- package/src/types/plugin-panes.ts +22 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/shell-word.ts +13 -0
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -643,12 +643,6 @@ export function formatEventTime(eventAt: number): string {
|
|
|
643
643
|
return new Date(eventAt).toISOString().slice(0, 16).replace("T", " ");
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
-
export function formatAsOf(asOf: string | null): string | null {
|
|
647
|
-
if (!asOf) return null;
|
|
648
|
-
const parsed = Date.parse(asOf);
|
|
649
|
-
return Number.isFinite(parsed) ? `${formatEventTime(parsed)} UTC` : asOf;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
646
|
export function formatMaturity(maturity: string | null): string {
|
|
653
647
|
return maturity ?? "--";
|
|
654
648
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { currencyPairSpelling } from "../../../utils/currency-pair";
|
|
2
2
|
import { dashedCoinPair } from "../../../utils/crypto-pair";
|
|
3
3
|
import { GALLONS_PER_BARREL, isBarrelsPerTonne } from "../../../time-series/price-units";
|
|
4
|
+
import { BP_PER_PERCENT } from "../../../time-series/studies/units";
|
|
4
5
|
import { MAX_CHART_COMPOSER_SERIES } from "./chart-spec";
|
|
5
6
|
import { parseSeriesExpression, resolveChartFieldAlias, type ParsedSeriesExpression } from "./series-expression";
|
|
6
7
|
import { getTimeSeriesField } from "../../../time-series/field-catalog";
|
|
@@ -17,8 +18,10 @@ import { getTimeSeriesField } from "../../../time-series/field-catalog";
|
|
|
17
18
|
*
|
|
18
19
|
* A literal 42 on a series is the 42 gallons of a barrel: it makes a price per
|
|
19
20
|
* gallon a price per barrel. A literal 7.45 or 8.45 is the barrels in a tonne
|
|
20
|
-
* of gasoil or gasoline: it makes a price per barrel a price per tonne.
|
|
21
|
-
*
|
|
21
|
+
* of gasoil or gasoline: it makes a price per barrel a price per tonne. A
|
|
22
|
+
* literal 100 makes a percent basis points (0.93% is 93bp), and 0.01 basis
|
|
23
|
+
* points a percent. Any other number is a count and keeps the unit. A series
|
|
24
|
+
* the whole formula is
|
|
22
25
|
* divided or multiplied by changes its unit as the arithmetic does: over
|
|
23
26
|
* EURUSD=X (USD per EUR), dollars are euros.
|
|
24
27
|
*
|
|
@@ -37,6 +40,8 @@ interface FormulaLeg {
|
|
|
37
40
|
perBarrel: boolean;
|
|
38
41
|
/** The barrels in a tonne the leg was multiplied by (7.45 or 8.45), or null. */
|
|
39
42
|
perTonne: number | null;
|
|
43
|
+
/** The leg was multiplied by a literal 100 (1: a percent in bp) or 0.01 (-1: bp in percent), or neither. */
|
|
44
|
+
percentBp: 1 | -1 | null;
|
|
40
45
|
/** The leg as written: `HO=F`. */
|
|
41
46
|
text: string;
|
|
42
47
|
}
|
|
@@ -136,6 +141,11 @@ function tokenize(expression: string): Token[] {
|
|
|
136
141
|
return tokens;
|
|
137
142
|
}
|
|
138
143
|
|
|
144
|
+
/** A literal 100 makes a percent basis points (1), 0.01 basis points a percent (-1); any other number neither. */
|
|
145
|
+
function percentBasisPointFactor(value: number): 1 | -1 | null {
|
|
146
|
+
return value === BP_PER_PERCENT ? 1 : value === 1 / BP_PER_PERCENT ? -1 : null;
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
function fail(message: string): never {
|
|
140
150
|
throw new Error(message);
|
|
141
151
|
}
|
|
@@ -192,6 +202,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
192
202
|
let weight = sign;
|
|
193
203
|
let perBarrel = false;
|
|
194
204
|
let perTonne: number | null = null;
|
|
205
|
+
let percentBp: 1 | -1 | null = null;
|
|
195
206
|
const factors: Token[] = [];
|
|
196
207
|
for (;;) {
|
|
197
208
|
const factor = take();
|
|
@@ -206,6 +217,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
206
217
|
if (factor.value === 0) fail("A multiplier of 0 removes its series; leave the term out instead.");
|
|
207
218
|
if (factor.value === GALLONS_PER_BARREL && !perBarrel) perBarrel = true;
|
|
208
219
|
else if (isBarrelsPerTonne(factor.value) && perTonne === null) perTonne = factor.value;
|
|
220
|
+
else if (percentBp === null) percentBp = percentBasisPointFactor(factor.value);
|
|
209
221
|
weight *= factor.value;
|
|
210
222
|
}
|
|
211
223
|
if (peek()?.kind !== "*") break;
|
|
@@ -224,7 +236,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
224
236
|
if (legs.some((leg) => leg.text.toUpperCase() === text.toUpperCase())) {
|
|
225
237
|
fail(`${text} appears twice. Write it once with its combined multiplier, such as 2*${text}.`);
|
|
226
238
|
}
|
|
227
|
-
legs.push({ series: parsed, weight, perBarrel, perTonne, text });
|
|
239
|
+
legs.push({ series: parsed, weight, perBarrel, perTonne, percentBp, text });
|
|
228
240
|
expectTerm = false;
|
|
229
241
|
|
|
230
242
|
const next = peek();
|
|
@@ -261,6 +273,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
|
|
|
261
273
|
for (const leg of legs) {
|
|
262
274
|
if (value.value === GALLONS_PER_BARREL && !leg.perBarrel) leg.perBarrel = true;
|
|
263
275
|
else if (isBarrelsPerTonne(value.value) && leg.perTonne === null) leg.perTonne = value.value;
|
|
276
|
+
else if (leg.percentBp === null) leg.percentBp = percentBasisPointFactor(value.value);
|
|
264
277
|
leg.weight *= value.value;
|
|
265
278
|
}
|
|
266
279
|
}
|
|
@@ -202,6 +202,8 @@ export const paneSchemas = {
|
|
|
202
202
|
{ value: "operatingMargin", aliases: ["operating margin"] },
|
|
203
203
|
{ value: "netIncome", aliases: ["net income", "profit", "earnings"] },
|
|
204
204
|
{ value: "netMargin", aliases: ["net margin", "profit margin"] },
|
|
205
|
+
{ value: "ebitda", aliases: ["ebitda", "operating income plus d&a"] },
|
|
206
|
+
{ value: "depreciationAndAmortization", aliases: ["d&a", "da", "depreciation", "depreciation and amortization"] },
|
|
205
207
|
{ value: "operatingCashFlow", aliases: ["operating cash flow", "cash flow", "ocf"] },
|
|
206
208
|
{ value: "freeCashFlow", aliases: ["free cash flow", "fcf"] },
|
|
207
209
|
{ value: "freeCashFlowMargin", aliases: ["free cash flow margin", "fcf margin"] },
|
|
@@ -30,6 +30,7 @@ import type { HistorySession } from "../../../types/price-history";
|
|
|
30
30
|
import type { TickerFinancials, PricePoint, Quote } from "../../../types/financials";
|
|
31
31
|
import { chartQuoteOverrideKeyForTarget, getLiveChartQuoteTargets } from "../../../time-series/live-quotes";
|
|
32
32
|
import { createChartSeriesResolver } from "../../../capabilities";
|
|
33
|
+
import { uncoveredCapabilityMessage } from "../../../capabilities/chart-series";
|
|
33
34
|
import { loadFuturesContractTerms, loadFuturesPriceUnit } from "../../../market-data/futures-contract";
|
|
34
35
|
import { loadDailyFxCloses } from "../../../time-series/currency-conversion";
|
|
35
36
|
import { canonicalExchange, isKnownExchangeCode, isUsListingExchange, parsePublicTickerKey, publicTickerKey } from "../../../utils/exchanges";
|
|
@@ -86,7 +87,7 @@ function headlessCapabilityResolver(context: HeadlessPaneContext) {
|
|
|
86
87
|
const request = <T,>(path: string, init?: RequestInit) => context.apiClient.geo<T>(path, { ...init, signal: init?.signal ?? context.signal });
|
|
87
88
|
return resolveGeoChartSeries(request, source.seriesId, viewport, context.signal);
|
|
88
89
|
}
|
|
89
|
-
if (!registry) throw new Error(
|
|
90
|
+
if (!registry) throw new Error(uncoveredCapabilityMessage(source.capabilityId, source.seriesId));
|
|
90
91
|
return registry(source, viewport, spec);
|
|
91
92
|
};
|
|
92
93
|
}
|
|
@@ -251,7 +252,8 @@ export async function loadChartPaneModel(
|
|
|
251
252
|
errors: [...chart.errors, ...chart.series.filter((series) => series.unreportedPeriod && series.points.length === 0)
|
|
252
253
|
.map((series) => `${series.label}: no ${series.unreportedPeriod} figures are reported; use --period annual.`)],
|
|
253
254
|
unavailableSymbols: spec.series.filter((series) => series.visible !== false).flatMap((series) => {
|
|
254
|
-
if (chart.series.some((output) => output.id === series.id && output.
|
|
255
|
+
if (chart.series.some((output) => output.id === series.id && (output.notMeaningful
|
|
256
|
+
|| output.points.some((point) => point.value !== null && Number.isFinite(point.value))))) return [];
|
|
255
257
|
const source = series.source;
|
|
256
258
|
return [source.kind === "security"
|
|
257
259
|
? publicTickerKey(source.instrument.symbol, source.instrument.exchange)
|
|
@@ -520,6 +520,7 @@ export const chartComposerModule: PluginModule = {
|
|
|
520
520
|
icon: "G",
|
|
521
521
|
component: ChartComposerPane,
|
|
522
522
|
defaultPosition: "right",
|
|
523
|
+
shareItem: { ticker: true },
|
|
523
524
|
tickerFollower: chartShowsOneSecurity,
|
|
524
525
|
retargetTicker: retargetChartTicker,
|
|
525
526
|
defaultMode: "floating",
|
|
@@ -109,6 +109,7 @@ function formulaStudy(formula: ParsedFormula, inputSeriesIds: string[]): ChartSt
|
|
|
109
109
|
parameters[`weight${index + 1}`] = leg.weight;
|
|
110
110
|
if (leg.perBarrel) parameters[`perBarrel${index + 1}`] = 1;
|
|
111
111
|
if (leg.perTonne) parameters[`perTonne${index + 1}`] = leg.perTonne;
|
|
112
|
+
if (leg.percentBp) parameters[`percentBp${index + 1}`] = leg.percentBp;
|
|
112
113
|
});
|
|
113
114
|
formula.factors.forEach((factor, index) => {
|
|
114
115
|
parameters[`power${formula.legs.length + index + 1}`] = factor.power;
|
|
@@ -279,7 +279,7 @@ export function getChatComposerAreaHeight({
|
|
|
279
279
|
replyTo,
|
|
280
280
|
mentionSuggestionCount,
|
|
281
281
|
draftAttachmentCount = 0,
|
|
282
|
-
|
|
282
|
+
draftLinkRows = 0,
|
|
283
283
|
promptRows = 0,
|
|
284
284
|
}: {
|
|
285
285
|
canSend: boolean;
|
|
@@ -290,8 +290,8 @@ export function getChatComposerAreaHeight({
|
|
|
290
290
|
mentionSuggestionCount?: number;
|
|
291
291
|
/** The terminal draws a row per waiting image; the desktop strip sizes itself. */
|
|
292
292
|
draftAttachmentCount?: number;
|
|
293
|
-
/** The
|
|
294
|
-
|
|
293
|
+
/** The terminal rows the waiting share links' cards take, which an edit shows too; the desktop strip sizes itself. */
|
|
294
|
+
draftLinkRows?: number;
|
|
295
295
|
/** Terminal rows the handle prompt above the composer takes. */
|
|
296
296
|
promptRows?: number;
|
|
297
297
|
}) {
|
|
@@ -300,5 +300,6 @@ export function getChatComposerAreaHeight({
|
|
|
300
300
|
+ (editingMessage || replyTo ? 1 : 0)
|
|
301
301
|
+ Math.max(0, mentionSuggestionCount ?? 0)
|
|
302
302
|
+ (!nativePaneChrome && !editingMessage ? draftAttachmentCount : 0)
|
|
303
|
-
|
|
303
|
+
// The waiting share links' cards, each as tall as what it says.
|
|
304
|
+
+ (!nativePaneChrome ? draftLinkRows : 0);
|
|
304
305
|
}
|
|
@@ -60,6 +60,9 @@ import { openChatPaneLink } from "../pane-links/open";
|
|
|
60
60
|
import { runChatCommand, useChatFunctions } from "../pane-links/commands";
|
|
61
61
|
import type { ChatMessagePaneLink } from "../pane-links/model";
|
|
62
62
|
import { splitComposerDraft, type ComposerShareLink } from "../pane-links/composer";
|
|
63
|
+
import { useSharePreviewStates } from "../pane-links/previews";
|
|
64
|
+
import { terminalChatPaneChipRows } from "../pane-links/share-card";
|
|
65
|
+
import { terminalComposerChipWidth } from "../message/pane-chip";
|
|
63
66
|
import { teamStore } from "../../../../team/store";
|
|
64
67
|
import { requestAccountManagementTab } from "../../account-management/navigation";
|
|
65
68
|
import {
|
|
@@ -377,6 +380,13 @@ function ChatConversation({
|
|
|
377
380
|
useEffect(() => {
|
|
378
381
|
setMentionSelectedIndex(0);
|
|
379
382
|
}, [suggestionTriggerKey]);
|
|
383
|
+
// The waiting links' cards are as tall as what they say, which changes as each share is read.
|
|
384
|
+
const draftLinkStates = useSharePreviewStates(nativePaneChrome ? [] : draftLinks.map((link) => link.id));
|
|
385
|
+
const draftLinkRows = useMemo(
|
|
386
|
+
() => draftLinks.reduce((rows, link) => rows + terminalChatPaneChipRows(link, terminalComposerChipWidth(contentWidth)), 0),
|
|
387
|
+
// The rows are read from the share previews' cache, which `draftLinkStates` follows.
|
|
388
|
+
[contentWidth, draftLinkStates, draftLinks],
|
|
389
|
+
);
|
|
380
390
|
const {
|
|
381
391
|
composerHeight,
|
|
382
392
|
messageAreaHeight,
|
|
@@ -390,7 +400,7 @@ function ChatConversation({
|
|
|
390
400
|
replyTo,
|
|
391
401
|
stackHeader: stackedNav && !channelListOpen,
|
|
392
402
|
draftAttachmentCount: draftAttachments.length,
|
|
393
|
-
|
|
403
|
+
draftLinkRows,
|
|
394
404
|
promptRows: canSend && !nativePaneChrome ? chatHandlePromptRows(handlePrompt, contentWidth) : 0,
|
|
395
405
|
});
|
|
396
406
|
const {
|
|
@@ -948,7 +958,7 @@ function ChatConversation({
|
|
|
948
958
|
setSelectedIdx,
|
|
949
959
|
stickyTranscript,
|
|
950
960
|
useDefaultControllerChannel,
|
|
951
|
-
composerLayoutKey: `${editingMessage ? "" : draftAttachments.map((attachment) => attachment.status).join(",")}:${draftLinks.length}`,
|
|
961
|
+
composerLayoutKey: `${editingMessage ? "" : draftAttachments.map((attachment) => attachment.status).join(",")}:${draftLinks.length}:${draftLinkRows}`,
|
|
952
962
|
highlightMessage,
|
|
953
963
|
clearHover,
|
|
954
964
|
clearHighlight,
|
|
@@ -49,7 +49,7 @@ export function resolveChatContentHeightMetrics({
|
|
|
49
49
|
replyTo,
|
|
50
50
|
stackHeader = false,
|
|
51
51
|
draftAttachmentCount = 0,
|
|
52
|
-
|
|
52
|
+
draftLinkRows = 0,
|
|
53
53
|
promptRows = 0,
|
|
54
54
|
}: {
|
|
55
55
|
canSend: boolean;
|
|
@@ -62,7 +62,7 @@ export function resolveChatContentHeightMetrics({
|
|
|
62
62
|
/** The narrow stack's Back row is drawn above the transcript. */
|
|
63
63
|
stackHeader?: boolean;
|
|
64
64
|
draftAttachmentCount?: number;
|
|
65
|
-
|
|
65
|
+
draftLinkRows?: number;
|
|
66
66
|
/** Terminal rows the handle prompt above the composer takes. */
|
|
67
67
|
promptRows?: number;
|
|
68
68
|
}) {
|
|
@@ -79,7 +79,7 @@ export function resolveChatContentHeightMetrics({
|
|
|
79
79
|
nativePaneChrome,
|
|
80
80
|
replyTo,
|
|
81
81
|
draftAttachmentCount,
|
|
82
|
-
|
|
82
|
+
draftLinkRows,
|
|
83
83
|
promptRows,
|
|
84
84
|
});
|
|
85
85
|
// In the terminal the Back row replaces the top rule.
|
|
@@ -3,7 +3,7 @@ import type { ChatAttachment } from "../../../../api-client";
|
|
|
3
3
|
import { chatMessageTokens } from "../markdown";
|
|
4
4
|
import { chatImageLabel } from "../attachments/model";
|
|
5
5
|
import { wirePaneTarget, type ChatMessagePaneLink } from "../pane-links/model";
|
|
6
|
-
import { chatPaneLinkPane, peekSharePreview } from "../pane-links/previews";
|
|
6
|
+
import { chatPaneLinkPane, peekSharePreview, sharePreviewTitle } from "../pane-links/previews";
|
|
7
7
|
import { resolveChatCommand, type ChatFunction } from "../pane-links/commands";
|
|
8
8
|
|
|
9
9
|
export type ChatOpenTarget =
|
|
@@ -12,12 +12,12 @@ export type ChatOpenTarget =
|
|
|
12
12
|
| { kind: "link"; url: string; label: string }
|
|
13
13
|
| { kind: "image"; index: number; url: string; label: string };
|
|
14
14
|
|
|
15
|
-
/** What the Open list calls a chip: the share's title once read, else its link; a Wire post's pane; a function as written. */
|
|
15
|
+
/** What the Open list calls a chip: the share's item or title once read, else its link; a Wire post's pane; a function as written. */
|
|
16
16
|
function paneLinkLabel(link: ChatMessagePaneLink): string {
|
|
17
17
|
if (link.kind === "command") return link.query;
|
|
18
18
|
if (link.kind === "share") {
|
|
19
19
|
const preview = peekSharePreview(link.id);
|
|
20
|
-
return preview.status === "ready" ? preview
|
|
20
|
+
return preview.status === "ready" ? sharePreviewTitle(preview) : link.url;
|
|
21
21
|
}
|
|
22
22
|
const target = wirePaneTarget(link.link);
|
|
23
23
|
const name = chatPaneLinkPane(target.paneId)?.name ?? target.name;
|
|
@@ -13,6 +13,7 @@ import type { InlineTickerCatalogEntry } from "../../../state/hooks/inline-ticke
|
|
|
13
13
|
import { STICKY_BOTTOM_THRESHOLD_PX } from "../../../ui/sticky-scroll";
|
|
14
14
|
import { terminalReactionRows } from "./reactions";
|
|
15
15
|
import { chatMessagePaneLinks } from "./pane-links/model";
|
|
16
|
+
import { terminalChatPaneChipRows } from "./pane-links/share-card";
|
|
16
17
|
import { chatInlineTokens, type ChatInlineToken, type ChatTextStyle } from "./markdown";
|
|
17
18
|
|
|
18
19
|
const MESSAGE_GROUP_THRESHOLD_MS = 5 * 60 * 1000;
|
|
@@ -329,7 +330,7 @@ export function estimateMessageHeight(
|
|
|
329
330
|
const headerHeight = grouped ? 0 : 1;
|
|
330
331
|
const contentLineWidth = Math.max(width - 4, 1);
|
|
331
332
|
const imageCount = message.attachments?.length ?? 0;
|
|
332
|
-
// A
|
|
333
|
+
// A share link's card rows or a Wire post link's chip row, in place of the link's text.
|
|
333
334
|
const { links, content } = chatMessagePaneLinks(message);
|
|
334
335
|
// The terminal draws a row per image and one for a review note; an image-only message has no text row.
|
|
335
336
|
const bodyLineCount = content.length === 0 && (imageCount > 0 || links.length > 0)
|
|
@@ -337,7 +338,9 @@ export function estimateMessageHeight(
|
|
|
337
338
|
: getMessageBodyTokenLines(content, contentLineWidth, catalog ?? {}).length;
|
|
338
339
|
const reviewNoteHeight = message.attachmentReview ? 1 : 0;
|
|
339
340
|
const reactionRows = message.reactions?.length ? terminalReactionRows(message.reactions, contentLineWidth).length : 0;
|
|
340
|
-
|
|
341
|
+
// A share's card is as tall as what it says, as it reads now.
|
|
342
|
+
const linkRows = links.reduce((rows, link) => rows + terminalChatPaneChipRows(link, contentLineWidth), 0);
|
|
343
|
+
return headerHeight + (message.replyTo ? 1 : 0) + bodyLineCount + linkRows + imageCount + reviewNoteHeight + reactionRows;
|
|
341
344
|
}
|
|
342
345
|
|
|
343
346
|
export function estimateComposerHeight(text: string, width: number) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import type { ChatAttachment } from "../../../../api-client";
|
|
2
3
|
import {
|
|
3
4
|
DesktopPaneLinkChip,
|
|
4
5
|
IconButton,
|
|
5
6
|
TerminalPaneLinkChip,
|
|
7
|
+
TerminalPaneLinkItemCard,
|
|
8
|
+
terminalItemCardRows,
|
|
6
9
|
type PaneLinkChipContent,
|
|
7
10
|
} from "../../../../components/ui";
|
|
8
11
|
import { tf } from "../../../../i18n";
|
|
@@ -10,15 +13,16 @@ import { Box } from "../../../../ui";
|
|
|
10
13
|
import { colors } from "../../../../theme/colors";
|
|
11
14
|
import { wirePaneTarget, type ChatMessagePaneLink } from "../pane-links/model";
|
|
12
15
|
import { chatPaneLinkPane, useSharePreview } from "../pane-links/previews";
|
|
16
|
+
import { shareCardContent } from "../pane-links/share-card";
|
|
13
17
|
import type { ComposerShareLink } from "../pane-links/composer";
|
|
14
18
|
import { DESKTOP_DRAFT_STRIP_STYLE } from "../attachments/desktop";
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
|
-
* A chip for something a message opens in the terminal: a shared pane
|
|
18
|
-
*
|
|
19
|
-
* one), a Gloom Wire post's story
|
|
20
|
-
* backticks, drawn in its line of text.
|
|
21
|
-
*
|
|
21
|
+
* A chip for something a message opens in the terminal: a shared pane as a
|
|
22
|
+
* card (the item it was on, a line or two of it and the pane it opens, with
|
|
23
|
+
* the picture its sender posted when there is one), a Gloom Wire post's story
|
|
24
|
+
* or calendar, or a function written in backticks, drawn in its line of text.
|
|
25
|
+
* A share's card is as tall as what it says; the other chips keep one height.
|
|
22
26
|
*/
|
|
23
27
|
|
|
24
28
|
/** What a chip says, from the share or the post and nothing of the reader's own. */
|
|
@@ -26,15 +30,7 @@ function useChatPaneChipContent(link: ChatMessagePaneLink): PaneLinkChipContent
|
|
|
26
30
|
const shareId = link.kind === "share" ? link.id : "";
|
|
27
31
|
const preview = useSharePreview(shareId);
|
|
28
32
|
if (link.kind === "command") return { title: link.query, detail: link.name, icon: "" };
|
|
29
|
-
if (link.kind === "share")
|
|
30
|
-
if (preview.status !== "ready") return { title: link.url, detail: "", icon: "" };
|
|
31
|
-
const pane = chatPaneLinkPane(preview.paneId);
|
|
32
|
-
return {
|
|
33
|
-
title: preview.title,
|
|
34
|
-
detail: pane && pane.name !== preview.title ? pane.name : "",
|
|
35
|
-
icon: pane?.icon ?? "",
|
|
36
|
-
};
|
|
37
|
-
}
|
|
33
|
+
if (link.kind === "share") return shareCardContent(link.url, preview);
|
|
38
34
|
const target = wirePaneTarget(link.link);
|
|
39
35
|
const pane = chatPaneLinkPane(target.paneId);
|
|
40
36
|
return { title: pane?.name ?? target.name, detail: target.day ?? "", icon: pane?.icon ?? "" };
|
|
@@ -71,7 +67,7 @@ export function DesktopChatPaneChip({
|
|
|
71
67
|
return (
|
|
72
68
|
<DesktopPaneLinkChip
|
|
73
69
|
content={content}
|
|
74
|
-
variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "
|
|
70
|
+
variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "item"}
|
|
75
71
|
picture={link.kind === "command" ? null : preview}
|
|
76
72
|
dimmed={dimmed}
|
|
77
73
|
onOpen={() => onOpen(link)}
|
|
@@ -109,7 +105,16 @@ export function DesktopComposerPaneChips({
|
|
|
109
105
|
);
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
/**
|
|
108
|
+
/** How wide a waiting link's card is in the terminal's composer of `width`: lined up with the field's text, its x after it. */
|
|
109
|
+
export function terminalComposerChipWidth(width: number): number {
|
|
110
|
+
return Math.max(1, width - COMPOSER_CHIP_INSET - COMPOSER_CHIP_REMOVE_WIDTH - 1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Lined up with the field's text after its prompt, as a message's chips line up with its text.
|
|
114
|
+
const COMPOSER_CHIP_INSET = 3;
|
|
115
|
+
const COMPOSER_CHIP_REMOVE_WIDTH = 3;
|
|
116
|
+
|
|
117
|
+
/** The terminal's composer rows for waiting share links: the card a message draws, then its x at the end of its first row. */
|
|
113
118
|
export function TerminalComposerPaneChips({
|
|
114
119
|
links,
|
|
115
120
|
width,
|
|
@@ -122,24 +127,24 @@ export function TerminalComposerPaneChips({
|
|
|
122
127
|
/** Takes out the chip at this place in `links`, as on the desktop. */
|
|
123
128
|
onRemove: (index: number) => void;
|
|
124
129
|
}) {
|
|
125
|
-
// Lined up with the field's text after its prompt, as a message's chips line up with its text.
|
|
126
|
-
const inset = 3;
|
|
127
|
-
const removeWidth = 3;
|
|
128
130
|
return (
|
|
129
131
|
<>
|
|
130
132
|
{links.map((link, index) => (
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/>
|
|
133
|
+
<TerminalChatPaneChipRow
|
|
134
|
+
key={`${index}:${link.id}`}
|
|
135
|
+
link={link}
|
|
136
|
+
width={terminalComposerChipWidth(width)}
|
|
137
|
+
rowProps={{ width }}
|
|
138
|
+
selected={false}
|
|
139
|
+
selectedTextColor={colors.textBright}
|
|
140
|
+
onOpen={onOpen}
|
|
141
|
+
lead={<Box width={COMPOSER_CHIP_INSET} />}
|
|
142
|
+
>
|
|
140
143
|
<Box flexGrow={1} />
|
|
141
|
-
<
|
|
142
|
-
|
|
144
|
+
<Box height={1}>
|
|
145
|
+
<TerminalComposerChipRemove link={link} onRemove={() => onRemove(index)} />
|
|
146
|
+
</Box>
|
|
147
|
+
</TerminalChatPaneChipRow>
|
|
143
148
|
))}
|
|
144
149
|
</>
|
|
145
150
|
);
|
|
@@ -147,31 +152,47 @@ export function TerminalComposerPaneChips({
|
|
|
147
152
|
|
|
148
153
|
function TerminalComposerChipRemove({ link, onRemove }: { link: ComposerShareLink; onRemove: () => void }) {
|
|
149
154
|
const content = useChatPaneChipContent(link);
|
|
150
|
-
return <IconButton icon="close" label={tf("Remove {name}", { name: content.title })} onPress={onRemove} />;
|
|
155
|
+
return <IconButton icon="close" label={tf("Remove {name}", { name: content.title || content.detail })} onPress={onRemove} />;
|
|
151
156
|
}
|
|
152
157
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
158
|
+
/**
|
|
159
|
+
* A chip's row in the terminal, as tall as the chip: a share's card as it
|
|
160
|
+
* reads now, or one row. `lead` goes before the chip and `children` after it.
|
|
161
|
+
*/
|
|
162
|
+
export function TerminalChatPaneChipRow({
|
|
155
163
|
link,
|
|
156
164
|
width,
|
|
165
|
+
rowProps,
|
|
157
166
|
selected,
|
|
158
167
|
selectedTextColor,
|
|
159
168
|
onOpen,
|
|
169
|
+
lead,
|
|
170
|
+
children,
|
|
160
171
|
}: {
|
|
161
172
|
link: ChatMessagePaneLink;
|
|
173
|
+
/** The chip's own width. */
|
|
162
174
|
width: number;
|
|
175
|
+
rowProps: Record<string, unknown>;
|
|
163
176
|
selected: boolean;
|
|
164
177
|
selectedTextColor: string;
|
|
165
178
|
onOpen: (link: ChatMessagePaneLink) => void;
|
|
179
|
+
lead?: ReactNode;
|
|
180
|
+
children?: ReactNode;
|
|
166
181
|
}) {
|
|
167
182
|
const content = useChatPaneChipContent(link);
|
|
183
|
+
const share = link.kind === "share";
|
|
184
|
+
const Chip = share ? TerminalPaneLinkItemCard : TerminalPaneLinkChip;
|
|
168
185
|
return (
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
<Box {...rowProps} height={share ? terminalItemCardRows(content, width) : 1} flexDirection="row">
|
|
187
|
+
{lead}
|
|
188
|
+
<Chip
|
|
189
|
+
content={content}
|
|
190
|
+
width={width}
|
|
191
|
+
selected={selected}
|
|
192
|
+
selectedTextColor={selectedTextColor}
|
|
193
|
+
onOpen={() => onOpen(link)}
|
|
194
|
+
/>
|
|
195
|
+
{children}
|
|
196
|
+
</Box>
|
|
176
197
|
);
|
|
177
198
|
}
|
|
@@ -11,7 +11,7 @@ import { Button } from "../../../../components/ui";
|
|
|
11
11
|
import { canReactToMessage } from "../reactions";
|
|
12
12
|
import { TerminalChatReactions } from "./reactions";
|
|
13
13
|
import { TerminalChatMessageRow } from "./inline-tokens";
|
|
14
|
-
import {
|
|
14
|
+
import { TerminalChatPaneChipRow } from "./pane-chip";
|
|
15
15
|
import { chatMessagePaneLinks } from "../pane-links/model";
|
|
16
16
|
import { useSlowPendingSend } from "./pending-send";
|
|
17
17
|
import { getChatMessageRenderState } from "./render-state";
|
|
@@ -167,23 +167,21 @@ export function TerminalChatMessage({
|
|
|
167
167
|
</Box>
|
|
168
168
|
))}
|
|
169
169
|
{paneLinks.map((link, linkIndex) => (
|
|
170
|
-
<
|
|
170
|
+
<TerminalChatPaneChipRow
|
|
171
171
|
key={`${msg.id}:pane:${link.kind === "share" ? link.id : link.link.kind}`}
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
link={link}
|
|
173
|
+
width={messageBodyWidth}
|
|
174
|
+
rowProps={{
|
|
175
|
+
...messageRowProps,
|
|
176
|
+
paddingLeft: 3,
|
|
177
|
+
position: state.grouped && bodyLines.length === 0 && linkIndex === 0 ? "relative" : undefined,
|
|
178
|
+
}}
|
|
179
|
+
selected={state.isSelected}
|
|
180
|
+
selectedTextColor={state.selectedTextColor}
|
|
181
|
+
onOpen={openPaneLink}
|
|
177
182
|
>
|
|
178
|
-
<TerminalChatPaneChip
|
|
179
|
-
link={link}
|
|
180
|
-
width={messageBodyWidth}
|
|
181
|
-
selected={state.isSelected}
|
|
182
|
-
selectedTextColor={state.selectedTextColor}
|
|
183
|
-
onOpen={openPaneLink}
|
|
184
|
-
/>
|
|
185
183
|
{state.grouped && bodyLines.length === 0 && linkIndex === 0 && <ChatMessageActions floating {...actionProps} />}
|
|
186
|
-
</
|
|
184
|
+
</TerminalChatPaneChipRow>
|
|
187
185
|
))}
|
|
188
186
|
{attachments.map((attachment, imageIndex) => (
|
|
189
187
|
<Box
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { useCallback, useSyncExternalStore } from "react";
|
|
2
2
|
import { getShare } from "../../../../shares/api";
|
|
3
|
+
import type { ShareItem } from "../../../../shares/item";
|
|
4
|
+
import { plainUntrustedLine } from "../../../../utils/untrusted-text";
|
|
3
5
|
import type { PaneDef } from "../../../../types/plugin";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* What a share chip shows, read from the share itself and nothing else: its
|
|
7
|
-
* title
|
|
9
|
+
* title, the pane it holds and what that pane says it is, and the item the
|
|
10
|
+
* pane was on when it was shared. The read does not count as a view of the
|
|
11
|
+
* share.
|
|
8
12
|
*/
|
|
9
13
|
export type SharePreview =
|
|
10
14
|
| { status: "loading" }
|
|
11
|
-
| {
|
|
15
|
+
| {
|
|
16
|
+
status: "ready";
|
|
17
|
+
title: string;
|
|
18
|
+
paneId: string | null;
|
|
19
|
+
/** The pane's own description, kept with shares made before items were. */
|
|
20
|
+
description?: string;
|
|
21
|
+
item?: ShareItem;
|
|
22
|
+
}
|
|
12
23
|
| { status: "unavailable" };
|
|
13
24
|
|
|
14
25
|
const LOADING: SharePreview = { status: "loading" };
|
|
@@ -61,10 +72,19 @@ function pump(): void {
|
|
|
61
72
|
settle(id, { status: "unavailable" }, false);
|
|
62
73
|
return;
|
|
63
74
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
75
|
+
const pane = share.kind === "pane" ? share : null;
|
|
76
|
+
const paneId = pane?.data.version === 2
|
|
77
|
+
? pane.data.layout.layout.instances[0]?.paneId ?? null
|
|
66
78
|
: null;
|
|
67
|
-
|
|
79
|
+
// The sender's app wrote the title and description: plain lines, as its item is (parseShareItem).
|
|
80
|
+
const description = pane?.data.description ? plainUntrustedLine(pane.data.description) : "";
|
|
81
|
+
settle(id, {
|
|
82
|
+
status: "ready",
|
|
83
|
+
title: plainUntrustedLine(share.data.title),
|
|
84
|
+
paneId,
|
|
85
|
+
...(description ? { description } : {}),
|
|
86
|
+
...(pane?.item ? { item: pane.item } : {}),
|
|
87
|
+
}, false);
|
|
68
88
|
})
|
|
69
89
|
.catch(() => settle(id, LOADING, true))
|
|
70
90
|
.finally(() => {
|
|
@@ -83,11 +103,37 @@ function request(id: string): void {
|
|
|
83
103
|
pump();
|
|
84
104
|
}
|
|
85
105
|
|
|
106
|
+
/** What a share is called where one line names it (the Open list): the item it is on, else its own title. */
|
|
107
|
+
export function sharePreviewTitle(preview: Extract<SharePreview, { status: "ready" }>): string {
|
|
108
|
+
return preview.item?.title ?? preview.title;
|
|
109
|
+
}
|
|
110
|
+
|
|
86
111
|
/** What chips show for a share now, for code outside React (the Open list). */
|
|
87
112
|
export function peekSharePreview(id: string): SharePreview {
|
|
88
113
|
return entries.get(id)?.preview ?? LOADING;
|
|
89
114
|
}
|
|
90
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Whether each of the shares is read yet, as one string that changes when one
|
|
118
|
+
* of them is: for a parent that sizes its children's cards by what they say
|
|
119
|
+
* (the terminal's composer). Reads each share as `useSharePreview` does.
|
|
120
|
+
*/
|
|
121
|
+
export function useSharePreviewStates(ids: readonly string[]): string {
|
|
122
|
+
const key = ids.join(",");
|
|
123
|
+
const subscribe = useCallback((listener: () => void) => {
|
|
124
|
+
const watched = key ? key.split(",") : [];
|
|
125
|
+
for (const id of watched) {
|
|
126
|
+
entryFor(id).listeners.add(listener);
|
|
127
|
+
request(id);
|
|
128
|
+
}
|
|
129
|
+
return () => {
|
|
130
|
+
for (const id of watched) entries.get(id)?.listeners.delete(listener);
|
|
131
|
+
};
|
|
132
|
+
}, [key]);
|
|
133
|
+
const read = useCallback(() => (key ? key.split(",").map((id) => peekSharePreview(id).status).join(",") : ""), [key]);
|
|
134
|
+
return useSyncExternalStore(subscribe, read, read);
|
|
135
|
+
}
|
|
136
|
+
|
|
91
137
|
/** The share's title and pane, loaded once per session for every chip that shows it; "" reads nothing. */
|
|
92
138
|
export function useSharePreview(id: string): SharePreview {
|
|
93
139
|
const subscribe = useCallback((listener: () => void) => {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { terminalItemCardRows, type PaneLinkChipContent } from "../../../../components/ui/pane-link-chip";
|
|
2
|
+
import type { ChatMessagePaneLink } from "./model";
|
|
3
|
+
import { chatPaneLinkPane, peekSharePreview, type SharePreview } from "./previews";
|
|
4
|
+
|
|
5
|
+
function sameName(a: string, b: string): boolean {
|
|
6
|
+
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* What a share's card says: the item its pane was on, a line or two of it, and
|
|
11
|
+
* the pane it opens. Without an item, or with one named as its pane, the pane
|
|
12
|
+
* is said once: its row (with the share's own title when that says more, as
|
|
13
|
+
* `DES SAMPL Options · Research`) under its own description. Before the share
|
|
14
|
+
* is read the card is its link in the room most cards take; once it is gone,
|
|
15
|
+
* its link alone.
|
|
16
|
+
*/
|
|
17
|
+
export function shareCardContent(url: string, preview: SharePreview): PaneLinkChipContent {
|
|
18
|
+
if (preview.status === "loading") return { title: url, detail: "", icon: "", pending: true };
|
|
19
|
+
if (preview.status !== "ready") return { title: url, detail: "", icon: "" };
|
|
20
|
+
const pane = chatPaneLinkPane(preview.paneId);
|
|
21
|
+
const paneName = pane?.name ?? preview.item?.pane ?? "";
|
|
22
|
+
const icon = pane?.icon ?? "";
|
|
23
|
+
const item = preview.item;
|
|
24
|
+
if (item && !sameName(item.title, paneName)) {
|
|
25
|
+
return { title: item.title, excerpt: item.excerpt ?? "", detail: paneName || preview.title, icon };
|
|
26
|
+
}
|
|
27
|
+
const row = !paneName ? preview.title
|
|
28
|
+
: sameName(preview.title, paneName) ? paneName
|
|
29
|
+
: `${preview.title} · ${paneName}`;
|
|
30
|
+
return { title: "", excerpt: preview.description ?? item?.excerpt ?? "", detail: row, icon };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The rows a message's chip takes in the terminal at `width`: a share's card as it reads now, or one row. */
|
|
34
|
+
export function terminalChatPaneChipRows(link: ChatMessagePaneLink, width: number): number {
|
|
35
|
+
return link.kind === "share" ? terminalItemCardRows(shareCardContent(link.url, peekSharePreview(link.id)), width) : 1;
|
|
36
|
+
}
|