@gloom-sh/terminal 0.19.5 → 0.20.0
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/LICENSE +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +25 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -2,7 +2,7 @@ import { useState, type MutableRefObject } from "react";
|
|
|
2
2
|
import { useShortcut } from "../../../../react/input";
|
|
3
3
|
import type { ScrollBoxRenderable } from "../../../../ui";
|
|
4
4
|
import type { ChatMessage } from "../../../../api-client";
|
|
5
|
-
import { countEscapeTowardClose } from "../../../../utils/double-escape-close";
|
|
5
|
+
import { countEscapeTowardClose, keepEscapeFromClosing } from "../../../../utils/double-escape-close";
|
|
6
6
|
import { isPlainKey } from "../../../../utils/keyboard";
|
|
7
7
|
import { createOneShot } from "../../../../utils/one-shot";
|
|
8
8
|
import { scrollToBottom } from "../layout";
|
|
@@ -290,11 +290,13 @@ export function useChatContentShortcuts({
|
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
//
|
|
293
|
+
// Clearing a selection counts toward the pane's double-Esc close; closing
|
|
294
|
+
// the profile popover does not.
|
|
294
295
|
if (event.name === "escape" && (profilePopoverOpen || selectedIdx >= 0)) {
|
|
295
296
|
event.preventDefault?.();
|
|
296
297
|
event.stopPropagation?.();
|
|
297
298
|
if (profilePopoverOpen) {
|
|
299
|
+
keepEscapeFromClosing(event);
|
|
298
300
|
closeProfilePopover();
|
|
299
301
|
return;
|
|
300
302
|
}
|
|
@@ -103,7 +103,6 @@ export function useChatSnapshotState({
|
|
|
103
103
|
const [messages, setMessages] = useState<ChatMessage[]>(initialSnapshot.messages);
|
|
104
104
|
const [channelStates, setChannelStates] = useState(initialSnapshot.channelStates);
|
|
105
105
|
const [conversationActivity, setConversationActivity] = useState(initialSnapshot.conversationActivity);
|
|
106
|
-
const [hasSavedSession, setHasSavedSession] = useState(initialSnapshot.hasSavedSession);
|
|
107
106
|
const [user, setUser] = useState<{ id: string; username: string; emailVerified: boolean } | null>(initialSnapshot.user);
|
|
108
107
|
const [loading, setLoading] = useState(initialSnapshot.loading);
|
|
109
108
|
const [messagesError, setMessagesError] = useState(initialSnapshot.messagesError);
|
|
@@ -138,7 +137,6 @@ export function useChatSnapshotState({
|
|
|
138
137
|
setChannelStates(snapshot.channelStates);
|
|
139
138
|
setConversationActivity(snapshot.conversationActivity);
|
|
140
139
|
setChannelsLoading(snapshot.channelsLoading);
|
|
141
|
-
setHasSavedSession(snapshot.hasSavedSession);
|
|
142
140
|
setUser(snapshot.user);
|
|
143
141
|
setLoading(snapshot.loading);
|
|
144
142
|
setMessagesError(snapshot.messagesError);
|
|
@@ -189,7 +187,6 @@ export function useChatSnapshotState({
|
|
|
189
187
|
conversationActivity,
|
|
190
188
|
draftAttachments,
|
|
191
189
|
hasOlderMessages,
|
|
192
|
-
hasSavedSession,
|
|
193
190
|
loading,
|
|
194
191
|
loadingOlderMessages,
|
|
195
192
|
messages,
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* the account is right: same headline grammar, same explanation slot, same two
|
|
6
6
|
* actions, wherever it appears. A pane only supplies the phrase that finishes
|
|
7
7
|
* "Sign in to ...", so the copy stays in one voice instead of drifting per pane.
|
|
8
|
-
* `InlineAuthActions` is the other shape:
|
|
9
|
-
* surface that still
|
|
8
|
+
* `InlineAuthActions` is the other shape: the same actions, drawn the same
|
|
9
|
+
* way, in a surface that still shows something without them, such as the
|
|
10
|
+
* chat composer of a saved login or an unverified account.
|
|
10
11
|
* `ProWall` is the signed-in counterpart for a pane body that needs Pro.
|
|
11
12
|
*/
|
|
12
13
|
import { useId } from "react";
|
|
@@ -31,26 +32,56 @@ function openAuth(
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
const RESEND_VERIFICATION = "Resend Verification Email";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The account actions as buttons: Log in and Sign up free, or the resend for
|
|
39
|
+
* an unconfirmed address. One look for the wall and for the inline copy, so
|
|
40
|
+
* the same action never reads as two different controls.
|
|
41
|
+
*/
|
|
42
|
+
function AuthButtons({ showSignup, needsVerification, onAuth, onResend, stopPropagation = false }: {
|
|
43
|
+
showSignup: boolean;
|
|
44
|
+
needsVerification: boolean;
|
|
45
|
+
onAuth: (mode: AccountMode) => void;
|
|
46
|
+
onResend: () => void;
|
|
47
|
+
/** Inside a surface with its own pointer handling (the chat), a press stays on the button. */
|
|
48
|
+
stopPropagation?: boolean;
|
|
49
|
+
}) {
|
|
50
|
+
if (needsVerification) return <Button label={t(RESEND_VERIFICATION)} stopPropagation={stopPropagation} onPress={onResend} />;
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<Button label={t("Log in")} variant="primary" stopPropagation={stopPropagation} onPress={() => onAuth("login")} />
|
|
54
|
+
{showSignup && <Button label={t("Sign up free")} variant="secondary" stopPropagation={stopPropagation} onPress={() => onAuth("signup")} />}
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
34
59
|
export interface InlineAuthActionsProps {
|
|
35
60
|
showSignup?: boolean;
|
|
61
|
+
/** The session exists but the address is unconfirmed: the resend replaces the sign-in buttons. */
|
|
62
|
+
needsVerification?: boolean;
|
|
36
63
|
/**
|
|
37
|
-
* `buttons` is the wall's
|
|
64
|
+
* `buttons` is the wall's buttons in the wall's row, for a surface such as
|
|
38
65
|
* the chat composer where the actions must read as controls. `plain` is
|
|
39
66
|
* clickable text, for chrome that is itself a row of text (a status bar).
|
|
40
67
|
*/
|
|
41
68
|
variant?: "buttons" | "plain";
|
|
42
69
|
}
|
|
43
70
|
|
|
44
|
-
export function InlineAuthActions({ showSignup = true, variant = "buttons" }: InlineAuthActionsProps) {
|
|
71
|
+
export function InlineAuthActions({ showSignup = true, needsVerification = false, variant = "buttons" }: InlineAuthActionsProps) {
|
|
45
72
|
const { openCommandBar } = usePluginAppActions();
|
|
46
|
-
const
|
|
47
|
-
const
|
|
73
|
+
const authenticate = (mode: AccountMode) => openAuth(openCommandBar, mode);
|
|
74
|
+
const logIn = () => authenticate("login");
|
|
75
|
+
const signUp = () => authenticate("signup");
|
|
76
|
+
const resend = () => openCommandBar(RESEND_VERIFICATION);
|
|
48
77
|
// Inside a pane (the chat composer) the pane menu lists them, so they need
|
|
49
78
|
// no mouse; the status bar copy has the Log In command instead.
|
|
50
|
-
usePaneMenuItems(`inline-auth:${useId()}`, () =>
|
|
51
|
-
{ id: "
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
usePaneMenuItems(`inline-auth:${useId()}`, () => needsVerification
|
|
80
|
+
? [{ id: "resend-verification", label: t(RESEND_VERIFICATION), onSelect: resend }]
|
|
81
|
+
: [
|
|
82
|
+
{ id: "log-in", label: t("Log in"), onSelect: logIn },
|
|
83
|
+
...(showSignup ? [{ id: "sign-up", label: t("Sign up free"), onSelect: signUp }] : []),
|
|
84
|
+
], [openCommandBar, needsVerification, showSignup]);
|
|
54
85
|
if (variant === "plain") {
|
|
55
86
|
return (
|
|
56
87
|
<Box flexDirection="row">
|
|
@@ -62,10 +93,10 @@ export function InlineAuthActions({ showSignup = true, variant = "buttons" }: In
|
|
|
62
93
|
</Box>
|
|
63
94
|
);
|
|
64
95
|
}
|
|
96
|
+
// The row a wall's actions sit in (EmptyState), wrapping in a narrow pane.
|
|
65
97
|
return (
|
|
66
|
-
<Box flexDirection="row" gap={1}>
|
|
67
|
-
<
|
|
68
|
-
{showSignup && <Button label={t("Sign up free")} variant="secondary" compact stopPropagation onPress={signUp} />}
|
|
98
|
+
<Box flexDirection="row" flexWrap="wrap" gap={1}>
|
|
99
|
+
<AuthButtons showSignup={showSignup} needsVerification={needsVerification} onAuth={authenticate} onResend={resend} stopPropagation />
|
|
69
100
|
</Box>
|
|
70
101
|
);
|
|
71
102
|
}
|
|
@@ -95,7 +126,7 @@ export function SignInWall({ placement, action, needsVerification = false, hint,
|
|
|
95
126
|
const title = needsVerification
|
|
96
127
|
? tf("Verify your email to {action}.", { action: t(action) })
|
|
97
128
|
: tf("Sign in to {action}.", { action: t(action) });
|
|
98
|
-
const authenticate = (mode:
|
|
129
|
+
const authenticate = (mode: AccountMode) => {
|
|
99
130
|
recordWallCtaClicked(placement, mode);
|
|
100
131
|
openAuth(openCommandBar, mode);
|
|
101
132
|
};
|
|
@@ -107,16 +138,13 @@ export function SignInWall({ placement, action, needsVerification = false, hint,
|
|
|
107
138
|
<EmptyState
|
|
108
139
|
title={title}
|
|
109
140
|
hint={hint}
|
|
110
|
-
actions={
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
141
|
+
actions={(
|
|
142
|
+
<AuthButtons
|
|
143
|
+
showSignup
|
|
144
|
+
needsVerification={needsVerification}
|
|
145
|
+
onAuth={authenticate}
|
|
146
|
+
onResend={() => openCommandBar(RESEND_VERIFICATION)}
|
|
114
147
|
/>
|
|
115
|
-
) : (
|
|
116
|
-
<>
|
|
117
|
-
<Button label={t("Log in")} variant="primary" onPress={() => authenticate("login")} />
|
|
118
|
-
<Button label={t("Sign up free")} variant="secondary" onPress={() => authenticate("signup")} />
|
|
119
|
-
</>
|
|
120
148
|
)}
|
|
121
149
|
/>
|
|
122
150
|
</Box>
|
|
@@ -188,6 +188,8 @@ export function createGloomberbCloudPlugin(): GloomPlugin {
|
|
|
188
188
|
description: "Free market, macro, and chat services. Chat requires signup.",
|
|
189
189
|
toggleable: true,
|
|
190
190
|
order: 10,
|
|
191
|
+
// TheBuildout's panes read its API directly.
|
|
192
|
+
hosts: ["api.thebuildout.ai"],
|
|
191
193
|
modules: [
|
|
192
194
|
createCloudDataModule(),
|
|
193
195
|
chatModule,
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The arm is asked for when the offer would show, in both arms, and that is
|
|
9
9
|
* the exposure (`exposeWebExperiment`); the control shows nothing. The line
|
|
10
|
-
* sits beside the signed-out Log in
|
|
11
|
-
*
|
|
10
|
+
* sits beside the signed-out Log in and the delayed mark, which then stands
|
|
11
|
+
* without its "delayed", and never covers the terminal. Like the other
|
|
12
12
|
* status bar chips it takes no keyboard focus: its tooltip names UPGRADE, and
|
|
13
13
|
* the Hide Pro Trial Offer command hides it. Hiding keeps it away for 14 days.
|
|
14
14
|
* Where the status bar has no room for it, as on a phone, it never shows and
|
|
@@ -161,7 +161,7 @@ function WebTrialOffer({ expose = exposeWebExperiment, delayMs = TRIAL_OFFER_DEL
|
|
|
161
161
|
}, [delayMs, expose, fits, onScreen, signedOut, state]);
|
|
162
162
|
|
|
163
163
|
const showing = state === "shown" && signedOut && !isTrialOfferSnoozed(dismissedAt) && copy !== null;
|
|
164
|
-
// The
|
|
164
|
+
// The connection note gives way to the line.
|
|
165
165
|
useStatusWidgetClaim("trial-offer", showing && copy ? copy.columns : 0);
|
|
166
166
|
const hide = useCallback(() => {
|
|
167
167
|
setDismissedAt(Date.now());
|
|
@@ -3,12 +3,22 @@ import { apiClient } from "../../../api-client";
|
|
|
3
3
|
import { t, tf } from "../../../i18n";
|
|
4
4
|
import { useAppLanguage } from "../../../i18n/react";
|
|
5
5
|
import { Button } from "../../../components/ui/button";
|
|
6
|
-
import { DelayedMark } from "../../../components/ui/delayed-mark";
|
|
7
|
-
import { Box, useCommandBarShortcut, useUiCapabilities } from "../../../ui";
|
|
6
|
+
import { DelayedMark, delayedMarkWidth, useStateQuoteDelay } from "../../../components/ui/delayed-mark";
|
|
7
|
+
import { Box, Text, useCommandBarShortcut, useUiCapabilities } from "../../../ui";
|
|
8
|
+
import { useThemeColors } from "../../../theme/theme-context";
|
|
8
9
|
import { chatController, type ChatController } from "../chat/controller";
|
|
9
10
|
import { useCloudPlanAction, useCloudUpgradeAction } from "../shared/cloud-upgrade";
|
|
10
11
|
import { CLOUD_QUOTE_DELAY_MINUTES, resolvePlanAccess } from "../../../api-client/plan-access";
|
|
11
12
|
import { useTrialOfferShowing } from "./trial-offer-status-widget";
|
|
13
|
+
import {
|
|
14
|
+
STATUS_WIDGET_COLUMNS,
|
|
15
|
+
useOtherStatusWidgetClaims,
|
|
16
|
+
useStatusWidgetClaim,
|
|
17
|
+
useStatusWidgetRoom,
|
|
18
|
+
} from "../../../components/layout/status-widget-space";
|
|
19
|
+
import { displayWidth } from "../../../utils/format";
|
|
20
|
+
|
|
21
|
+
const CLAIM_ID = "cloud-upgrade";
|
|
12
22
|
|
|
13
23
|
interface CloudUpgradeStatusWidgetProps {
|
|
14
24
|
controller?: Pick<ChatController, "getSnapshot" | "subscribe">;
|
|
@@ -16,12 +26,15 @@ interface CloudUpgradeStatusWidgetProps {
|
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
28
|
* Global entitlement status: the trial countdown while Pro is on loan, or,
|
|
19
|
-
* signed out or on the free plan, the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
29
|
+
* signed out or on the free plan, the one place that says the app's prices
|
|
30
|
+
* are late (`◷ 15m delayed`), pressed for the upgrade. Said here, a price
|
|
31
|
+
* outside a pane footer leaves its own mark out. While the trial offer line
|
|
32
|
+
* already pitches Pro, the mark stands alone. Pro accounts have nothing to
|
|
33
|
+
* report.
|
|
22
34
|
*/
|
|
23
35
|
export function CloudUpgradeStatusWidget({ controller = chatController }: CloudUpgradeStatusWidgetProps) {
|
|
24
36
|
useAppLanguage();
|
|
37
|
+
const colors = useThemeColors();
|
|
25
38
|
const openUpgrade = useCloudUpgradeAction("status-widget");
|
|
26
39
|
const openPlan = useCloudPlanAction();
|
|
27
40
|
const offerShowing = useTrialOfferShowing();
|
|
@@ -29,6 +42,20 @@ export function CloudUpgradeStatusWidget({ controller = chatController }: CloudU
|
|
|
29
42
|
// The status bar takes no keyboard focus; the chip names the command instead.
|
|
30
43
|
const commandBarKey = useCommandBarShortcut();
|
|
31
44
|
const [access, setAccess] = useState(() => resolvePlanAccess(apiClient.getCurrentUser()));
|
|
45
|
+
const delayed = !access.isTrialActive && !access.hasProAccess;
|
|
46
|
+
// The bar holds back its usual columns for the widgets' own text, which
|
|
47
|
+
// this one shares with the account chip beside it: half of them are its
|
|
48
|
+
// own. The note says "delayed" where the row has room for what it draws
|
|
49
|
+
// past that half, and claims it, else it is the mark alone.
|
|
50
|
+
const room = useStatusWidgetRoom();
|
|
51
|
+
const othersClaimed = useOtherStatusWidgetClaims(CLAIM_ID);
|
|
52
|
+
const word = t("delayed");
|
|
53
|
+
// The mark, the space before the word, the word and the space after the note.
|
|
54
|
+
const noteColumns = delayedMarkWidth(CLOUD_QUOTE_DELAY_MINUTES, false) + 1 + displayWidth(word) + 1;
|
|
55
|
+
const overflow = Math.max(0, noteColumns - STATUS_WIDGET_COLUMNS / 2);
|
|
56
|
+
const spelled = !offerShowing && (nativePaneChrome || room - STATUS_WIDGET_COLUMNS - othersClaimed >= overflow);
|
|
57
|
+
useStatusWidgetClaim(CLAIM_ID, delayed && spelled && !nativePaneChrome ? overflow : 0);
|
|
58
|
+
useStateQuoteDelay(delayed);
|
|
32
59
|
|
|
33
60
|
useEffect(
|
|
34
61
|
// The chat widget already drives session refreshes; this only follows them.
|
|
@@ -51,19 +78,24 @@ export function CloudUpgradeStatusWidget({ controller = chatController }: CloudU
|
|
|
51
78
|
if (access.hasProAccess) return null;
|
|
52
79
|
|
|
53
80
|
const mark = <DelayedMark minutes={CLOUD_QUOTE_DELAY_MINUTES} />;
|
|
81
|
+
const detail = tf("{delay} delayed", { delay: `${CLOUD_QUOTE_DELAY_MINUTES}m` });
|
|
54
82
|
return (
|
|
55
|
-
<Box flexDirection="row" alignItems="center"
|
|
56
|
-
{
|
|
57
|
-
{offerShowing ? null : (
|
|
83
|
+
<Box flexDirection="row" alignItems="center" flexShrink={0} paddingRight={1} data-gloom-role="delayed-status">
|
|
84
|
+
{spelled ? (
|
|
58
85
|
<Button
|
|
59
|
-
label={
|
|
60
|
-
title={tf("Upgrade to Pro ({key}, then {command})", { key: commandBarKey, command: "UPGRADE" })}
|
|
86
|
+
label={detail}
|
|
87
|
+
title={`${detail}. ${tf("Upgrade to Pro ({key}, then {command})", { key: commandBarKey, command: "UPGRADE" })}`}
|
|
61
88
|
variant="plain"
|
|
62
89
|
compact
|
|
63
90
|
stopPropagation
|
|
64
91
|
onPress={openUpgrade}
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
>
|
|
93
|
+
<Box flexDirection="row" alignItems="center" gap={1}>
|
|
94
|
+
{mark}
|
|
95
|
+
<Text fg={colors.textDim} selectable={false}>{word}</Text>
|
|
96
|
+
</Box>
|
|
97
|
+
</Button>
|
|
98
|
+
) : mark}
|
|
67
99
|
</Box>
|
|
68
100
|
);
|
|
69
101
|
}
|
|
@@ -96,9 +96,10 @@ export function formatLag(value: number | null): string {
|
|
|
96
96
|
return value == null ? "--" : `${value}d`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** A disclosure bracket's bound, as the filing's range names it ($1k-15k): a label, short even in a table column. */
|
|
99
100
|
function formatMoneyShort(value: number | null): string {
|
|
100
101
|
if (value == null) return "--";
|
|
101
|
-
return `$${formatCompact(value)}`;
|
|
102
|
+
return `$${formatCompact(value, { fixedDecimals: false })}`;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
export function formatAmountRange(low: number | null, high: number | null, raw?: string): string {
|
|
@@ -19,6 +19,7 @@ const CONGRESS_TABS = [
|
|
|
19
19
|
import { useDebouncedPluginPaneState, usePluginPaneState } from "../../runtime";
|
|
20
20
|
import { useShortcut } from "../../../react/input";
|
|
21
21
|
import { isDetailBackNavigationKey } from "../../../utils/back-navigation";
|
|
22
|
+
import { countEscapeTowardClose } from "../../../utils/double-escape-close";
|
|
22
23
|
import { nextHeaderSort, type SortDirection } from "../../../utils/sort-values";
|
|
23
24
|
import { useAutoRefresh } from "../../../react/auto-refresh";
|
|
24
25
|
import { useInlineTickerOpener } from "../../../state/hooks/inline-tickers";
|
|
@@ -221,6 +222,8 @@ export function CongressTradesPane({ focused, width, height, tickerFilter }: Pan
|
|
|
221
222
|
useShortcut((event) => {
|
|
222
223
|
if (!focused || event.targetEditable) return;
|
|
223
224
|
if (tickerFilter && detailMode && isDetailBackNavigationKey(event)) {
|
|
225
|
+
// Ahead of the shell's own Esc handler when restored with it, so it counts the Esc itself.
|
|
226
|
+
countEscapeTowardClose(event);
|
|
224
227
|
event.preventDefault?.(); event.stopPropagation?.(); setDetailMode(null); return;
|
|
225
228
|
}
|
|
226
229
|
if (!payload) handleRefreshKey(event, refresh, { stopPropagation: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HeadlessPaneDefinition } from "../../../types/headless";
|
|
2
2
|
import type { TimeRange } from "../../../time-series/range";
|
|
3
|
-
import { formatNumber, formatSignificant } from "../../../utils/format";
|
|
3
|
+
import { formatNumber, formatSignificant, significantDecimals } from "../../../utils/format";
|
|
4
4
|
import { logFailure } from "../../../utils/log-failure";
|
|
5
5
|
import { mixedSessionCloseNote } from "../../../market-data/market/session-close-note";
|
|
6
6
|
import { resolveHeadlessInstrument, loadHeadlessSymbols } from "../shared/headless-market-data";
|
|
@@ -124,7 +124,8 @@ export const relationshipHeadless: HeadlessPaneDefinition<"series"> = {
|
|
|
124
124
|
return {
|
|
125
125
|
symbols,
|
|
126
126
|
series: [
|
|
127
|
-
|
|
127
|
+
// The latest ratio reads as Statistics reads it, to four significant digits (1.123, 0.8904), not every float digit.
|
|
128
|
+
{ id: "ratio", label: `${symbols[0]}/${symbols[1]}`, ...analysis.latestRatio != null ? { textDecimals: significantDecimals(analysis.latestRatio) } : {}, points: analysis.ratioPoints.map(({ date, close }) => ({ date: date.toISOString(), value: close })) },
|
|
128
129
|
{ id: "correlation", label: `Rolling correlation (${correlationWindow})`, textDecimals: 3, points: analysis.returns.slice(correlationWindow - 1).map(({ date }) => ({ date: date.toISOString(), value: correlations.get(date.getTime()) ?? null })) },
|
|
129
130
|
],
|
|
130
131
|
stats: [
|
|
@@ -295,15 +295,16 @@ export function CryptoBoardPane({ width, height, focused }: PaneProps) {
|
|
|
295
295
|
}, [stablecoins, supply]);
|
|
296
296
|
const supplyError = !supply && supplyResource.error ? supplyResource.error : null;
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
// Kept between quotes, so the tab strip skips the renders a board update gives the pane.
|
|
299
|
+
const tabItems = useMemo(() => CRYPTO_TABS.map((tab) => ({
|
|
299
300
|
label: tab.label,
|
|
300
301
|
value: tab.value,
|
|
301
|
-
}));
|
|
302
|
-
const selectTab = (value: string) => {
|
|
302
|
+
})), []);
|
|
303
|
+
const selectTab = useCallback((value: string) => {
|
|
303
304
|
setActiveTab(value as CryptoTab);
|
|
304
305
|
setSelectedId(null);
|
|
305
306
|
setVisibleRange(INITIAL_STREAM_RANGE);
|
|
306
|
-
};
|
|
307
|
+
}, [setActiveTab, setSelectedId]);
|
|
307
308
|
const { strip: tabStrip } = usePaneTabs({ tabs: tabItems, activeValue: activeTab, onSelect: selectTab, focused, compact: true, variant: "bare" });
|
|
308
309
|
|
|
309
310
|
usePaneNoticeFooter({
|
|
@@ -3,7 +3,7 @@ import { CUSTOM_VIEW_PANE_ID, CUSTOM_VIEW_SPEC_SETTING, CustomViewPane } from ".
|
|
|
3
3
|
import { parseViewSpec, serializeViewSpec, type ViewSpec } from "./view-spec";
|
|
4
4
|
|
|
5
5
|
export { CUSTOM_VIEW_PANE_ID } from "./pane";
|
|
6
|
-
export { setViewRefResolver, trialLoadViewSource } from "./loader";
|
|
6
|
+
export { setViewRefResolver, trialLoadViewSource, UnknownViewKeysError } from "./loader";
|
|
7
7
|
export * from "./view-spec";
|
|
8
8
|
|
|
9
9
|
export const CUSTOM_VIEW_TEMPLATE_ID = "custom-view-pane";
|
|
@@ -5,7 +5,7 @@ import type { AppConfig } from "../../../types/config";
|
|
|
5
5
|
import { getSharedRegistry, type PluginRegistry } from "../../registry";
|
|
6
6
|
import { marketContextFromRegistry } from "../cloud/askg/host";
|
|
7
7
|
import { notViewSourceMessage, unknownViewSourceMessage } from "./sources";
|
|
8
|
-
import type
|
|
8
|
+
import { applyViewProjection, unknownViewKeys, type UnknownViewKey, type ViewKeyPlace, type ViewRow, type ViewSource, type ViewSpec } from "./view-spec";
|
|
9
9
|
|
|
10
10
|
export interface LoadedView {
|
|
11
11
|
rows: ViewRow[];
|
|
@@ -113,14 +113,93 @@ export async function loadViewSource(
|
|
|
113
113
|
|
|
114
114
|
/** How long a trial load waits; under the 10 s a remote tool call is given. */
|
|
115
115
|
const VIEW_TRIAL_TIMEOUT_MS = 8_000;
|
|
116
|
+
/** Source keys a refusal lists at most. */
|
|
117
|
+
const LISTED_SOURCE_KEYS = 60;
|
|
118
|
+
|
|
119
|
+
/** The spec names keys the source's rows never carry; nothing is kept. */
|
|
120
|
+
export class UnknownViewKeysError extends Error {
|
|
121
|
+
override name = "UnknownViewKeysError";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const PLACE_NAMES: Record<ViewKeyPlace, [one: string, many: string]> = {
|
|
125
|
+
column: ["column", "columns"],
|
|
126
|
+
filter: ["filter key", "filter keys"],
|
|
127
|
+
sort: ["sort key", "sort keys"],
|
|
128
|
+
symbolKey: ["symbol key", "symbol keys"],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** `columns change1d, low30d; sort key vol` */
|
|
132
|
+
function describeUnknownKeys(unknown: readonly UnknownViewKey[]): string {
|
|
133
|
+
const byPlace = new Map<ViewKeyPlace, string[]>();
|
|
134
|
+
for (const { key, place } of unknown) byPlace.set(place, [...(byPlace.get(place) ?? []), key]);
|
|
135
|
+
return [...byPlace].map(([place, keys]) => `${PLACE_NAMES[place][keys.length === 1 ? 0 : 1]} ${keys.join(", ")}`).join("; ");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function comparable(text: string): string {
|
|
139
|
+
return text.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The source's keys, its listed columns first with their header where it says more than the key: `title (Market)`. */
|
|
143
|
+
function describeSourceKeys(columns: readonly HeadlessPaneColumn[], rowKeys: Iterable<string>): string {
|
|
144
|
+
const entries = new Map<string, string>();
|
|
145
|
+
for (const column of columns) {
|
|
146
|
+
if (entries.has(column.key)) continue;
|
|
147
|
+
const header = column.header?.trim();
|
|
148
|
+
entries.set(column.key, header && comparable(header) !== comparable(column.key) ? `${column.key} (${header})` : column.key);
|
|
149
|
+
}
|
|
150
|
+
for (const key of rowKeys) if (!entries.has(key)) entries.set(key, key);
|
|
151
|
+
const listed = [...entries.values()];
|
|
152
|
+
const more = listed.length - LISTED_SOURCE_KEYS;
|
|
153
|
+
return more > 0 ? `${listed.slice(0, LISTED_SOURCE_KEYS).join(", ")} and ${more} more` : listed.join(", ");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* What a trial load says about the spec. Names the spec uses that none of the
|
|
158
|
+
* loaded rows carry throw `UnknownViewKeysError` with the keys they do carry,
|
|
159
|
+
* so a view never opens on columns that stay blank or filters that drop every
|
|
160
|
+
* row. With no rows to read, the source's listed columns are all there is to
|
|
161
|
+
* check against and they need not list every key, so a mismatch only warns.
|
|
162
|
+
*/
|
|
163
|
+
function checkLoadedView(spec: ViewSpec, loaded: LoadedView): string[] {
|
|
164
|
+
const notes = loaded.errors.slice(0, 2);
|
|
165
|
+
const listed = new Set(loaded.columns.map((column) => column.key));
|
|
166
|
+
if (loaded.rows.length === 0) {
|
|
167
|
+
const unlisted = listed.size > 0 ? unknownViewKeys(spec, listed) : [];
|
|
168
|
+
return [
|
|
169
|
+
"The source loaded no rows.",
|
|
170
|
+
...notes,
|
|
171
|
+
...(unlisted.length > 0
|
|
172
|
+
? [`With no rows to check, these are not among the ${loaded.sourceLabel} columns: ${describeUnknownKeys(unlisted)}. Its columns: ${describeSourceKeys(loaded.columns, [])}.`]
|
|
173
|
+
: []),
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
const rowKeys = new Set<string>();
|
|
177
|
+
for (const row of loaded.rows) for (const key of Object.keys(row)) rowKeys.add(key);
|
|
178
|
+
const unknown = unknownViewKeys(spec, new Set([...listed, ...rowKeys]));
|
|
179
|
+
if (unknown.length > 0) {
|
|
180
|
+
throw new UnknownViewKeysError(
|
|
181
|
+
`Not in the ${loaded.sourceLabel} rows: ${describeUnknownKeys(unknown)}. `
|
|
182
|
+
+ `Its rows carry: ${describeSourceKeys(loaded.columns, rowKeys)}. `
|
|
183
|
+
+ "Use only those keys, and say which of the asked-for columns this source does not have.",
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const { filters } = spec.projection;
|
|
187
|
+
if (filters.length > 0 && applyViewProjection(loaded.rows, { columns: [], filters }, null).length === 0) {
|
|
188
|
+
const count = loaded.rows.length;
|
|
189
|
+
const none = count === 1 ? "The one row the source loaded does not pass" : `None of the ${count} rows the source loaded pass`;
|
|
190
|
+
return [`${none} the view's filters, so the view shows no rows.`, ...notes];
|
|
191
|
+
}
|
|
192
|
+
return notes;
|
|
193
|
+
}
|
|
116
194
|
|
|
117
195
|
/**
|
|
118
196
|
* Loads the spec's source once through `loadViewSource`, the path its pane
|
|
119
197
|
* takes, before the spec is kept. Throws what the source throws (an unknown
|
|
120
|
-
* function with the valid ones, a usage or option error, a failed read),
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
198
|
+
* function with the valid ones, a usage or option error, a failed read), or
|
|
199
|
+
* `UnknownViewKeysError` for keys its rows never carry, so nothing broken is
|
|
200
|
+
* saved. Resolves with what to tell the person: notes the source carried, an
|
|
201
|
+
* empty result, or that it had not answered in time, which is not a failure:
|
|
202
|
+
* a slow source still opens.
|
|
124
203
|
*/
|
|
125
204
|
export async function trialLoadViewSource(
|
|
126
205
|
spec: ViewSpec,
|
|
@@ -148,9 +227,7 @@ export async function trialLoadViewSource(
|
|
|
148
227
|
if (outcome === "timeout") {
|
|
149
228
|
return [`The source had not answered after ${Math.max(1, Math.round(timeoutMs / 1_000))} s, so it was not checked. The view opens and keeps loading.`];
|
|
150
229
|
}
|
|
151
|
-
return outcome
|
|
152
|
-
? ["The source loaded no rows.", ...outcome.errors.slice(0, 2)]
|
|
153
|
-
: outcome.errors.slice(0, 2);
|
|
230
|
+
return checkLoadedView(spec, outcome);
|
|
154
231
|
} finally {
|
|
155
232
|
clearTimeout(timer);
|
|
156
233
|
signal?.removeEventListener("abort", abort);
|
|
@@ -297,6 +297,34 @@ export function parseViewSpecOr(value: unknown): { spec: ViewSpec; result: ViewS
|
|
|
297
297
|
return { spec, result };
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/** Where a spec names a row key. */
|
|
301
|
+
export type ViewKeyPlace = "column" | "filter" | "sort" | "symbolKey";
|
|
302
|
+
|
|
303
|
+
export interface UnknownViewKey {
|
|
304
|
+
key: string;
|
|
305
|
+
place: ViewKeyPlace;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The row keys the spec's columns, filters, sort and symbol key name that are
|
|
310
|
+
* not in `known`, once per place, in the spec's order. A key no row carries
|
|
311
|
+
* leaves a column blank, and a filter or sort on it drops or scrambles every row.
|
|
312
|
+
*/
|
|
313
|
+
export function unknownViewKeys(spec: ViewSpec, known: ReadonlySet<string>): UnknownViewKey[] {
|
|
314
|
+
const unknown: UnknownViewKey[] = [];
|
|
315
|
+
const seen = new Set<string>();
|
|
316
|
+
const check = (key: string, place: ViewKeyPlace) => {
|
|
317
|
+
if (known.has(key) || seen.has(`${place}:${key}`)) return;
|
|
318
|
+
seen.add(`${place}:${key}`);
|
|
319
|
+
unknown.push({ key, place });
|
|
320
|
+
};
|
|
321
|
+
for (const column of spec.projection.columns) check(column.key, "column");
|
|
322
|
+
for (const filter of spec.projection.filters) check(filter.key, "filter");
|
|
323
|
+
if (spec.projection.sort) check(spec.projection.sort.by, "sort");
|
|
324
|
+
if (spec.presentation.symbolKey) check(spec.presentation.symbolKey, "symbolKey");
|
|
325
|
+
return unknown;
|
|
326
|
+
}
|
|
327
|
+
|
|
300
328
|
export function serializeViewSpec(spec: ViewSpec): string {
|
|
301
329
|
const result = validateViewSpec(spec);
|
|
302
330
|
if (!result.valid) throw new Error(result.errors.map((entry) => entry.message).join(" "));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HeadlessPaneDefinition } from "../../../types/plugin";
|
|
2
2
|
import { fetchDebtMaturities } from "./client";
|
|
3
|
-
import { bucketShare, debtAmount, debtNewestAsOf, debtNewestForm, debtNotices, debtPercent, newerQuarter } from "./model";
|
|
3
|
+
import { bucketShare, debtAmount, debtCostProxyNote, debtHistoryRows, debtNewestAsOf, debtNewestForm, debtNotices, debtPercent, newerQuarter } from "./model";
|
|
4
4
|
import { SEC_FILINGS } from "../shared/report-freshness";
|
|
5
5
|
import { resolveHeadlessIssuerListing } from "../shared/headless-market-data";
|
|
6
6
|
|
|
@@ -46,6 +46,7 @@ export const debtMaturitiesHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
46
46
|
const symbol = args.symbols[0]!;
|
|
47
47
|
const data = await fetchDebtMaturities(symbol, ctx.apiClient, await resolveHeadlessIssuerListing(ctx, symbol));
|
|
48
48
|
const quarter = newerQuarter(data);
|
|
49
|
+
const costNote = debtCostProxyNote(data.history);
|
|
49
50
|
return {
|
|
50
51
|
complete: data.status === "available",
|
|
51
52
|
errors: debtNotices(data),
|
|
@@ -111,12 +112,20 @@ export const debtMaturitiesHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
111
112
|
align: "right",
|
|
112
113
|
textFormat: percent,
|
|
113
114
|
},
|
|
115
|
+
{
|
|
116
|
+
// What the proxy divides: exports keep `filed` or `average-principal`, the text says it in words.
|
|
117
|
+
key: "borrowingCostBasis",
|
|
118
|
+
header: "Cost basis",
|
|
119
|
+
optional: true,
|
|
120
|
+
textFormat: (value) => value === "filed" ? "Filed" : value === "average-principal" ? "Avg principal" : "",
|
|
121
|
+
},
|
|
114
122
|
{ key: "currency", header: "Currency" },
|
|
115
123
|
{ key: "filed", header: "Filed" },
|
|
116
124
|
],
|
|
117
|
-
rows: data.history
|
|
125
|
+
rows: debtHistoryRows(data.history).map((row) => ({ ...row })),
|
|
118
126
|
},
|
|
119
127
|
],
|
|
128
|
+
...(costNote ? { notes: [costNote] } : {}),
|
|
120
129
|
metadata: { ...data },
|
|
121
130
|
// The latest filing dates the report (a newer 10-Q's balance date), named by its form so the date is
|
|
122
131
|
// not read as the schedule's; the history rows are past years, not stale data.
|