gloomberb 0.20.13 → 0.20.14

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.
Files changed (155) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
  3. package/src/account/auth-dialog.tsx +22 -4
  4. package/src/account/auth-form.tsx +6 -1
  5. package/src/account/checkout-handoff.tsx +7 -14
  6. package/src/account/device-signin-dialog.tsx +35 -24
  7. package/src/api-client/crypto-markets.ts +10 -0
  8. package/src/api-client/errors.ts +3 -1
  9. package/src/api-client/money-markets.ts +7 -0
  10. package/src/api-client/request.ts +12 -2
  11. package/src/architecture/floating-promise-allowlist.json +0 -1
  12. package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
  13. package/src/cli/commands/market.ts +95 -23
  14. package/src/cli/commands/overview.ts +18 -4
  15. package/src/cli/errors.ts +3 -1
  16. package/src/cli/freshness.ts +7 -2
  17. package/src/cli/glossary.ts +10 -5
  18. package/src/cli/helpers.ts +8 -16
  19. package/src/cli/history-export.ts +4 -0
  20. package/src/cli/known-gaps.ts +2 -2
  21. package/src/cli/listing-arg.ts +79 -11
  22. package/src/cli/not-a-ticker.ts +4 -0
  23. package/src/cli/pane-functions/catalog.ts +29 -8
  24. package/src/cli/pane-functions/headless.ts +5 -2
  25. package/src/cli/pane-functions/options.ts +7 -0
  26. package/src/cli/pane-functions/resolver.ts +61 -15
  27. package/src/cli/result.ts +22 -4
  28. package/src/cli/symbol-args.ts +5 -3
  29. package/src/cli/symbol-list.ts +23 -10
  30. package/src/cli/symbol-rows.ts +135 -3
  31. package/src/cli/treasury-yields.ts +15 -1
  32. package/src/components/chart/composite/format.ts +2 -1
  33. package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
  34. package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
  35. package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
  36. package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
  37. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
  38. package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
  39. package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
  40. package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
  41. package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
  42. package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
  43. package/src/components/chart/composite/panel-surface/props.ts +79 -0
  44. package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
  45. package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
  46. package/src/components/chart/composite/panel-surface.tsx +81 -1177
  47. package/src/components/command-bar/commands/collection-list.ts +1 -0
  48. package/src/components/command-bar/routes/root/results.ts +3 -2
  49. package/src/components/command-bar/routes/root/runtime.ts +3 -2
  50. package/src/components/command-bar/routes/root/selection.ts +3 -2
  51. package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
  52. package/src/components/layout/pane/title.ts +10 -4
  53. package/src/components/pane-settings-dialog/tui.tsx +6 -3
  54. package/src/components/pane-settings-dialog.tsx +2 -1
  55. package/src/components/pane-template-wizard.tsx +2 -0
  56. package/src/components/ui/choice-dialog.tsx +1 -1
  57. package/src/components/ui/confirm-dialog.tsx +3 -2
  58. package/src/components/ui/frame.tsx +7 -3
  59. package/src/components/ui/icon.tsx +4 -2
  60. package/src/components/ui/list-view.tsx +8 -0
  61. package/src/components/ui/number-prompt-dialog.tsx +2 -1
  62. package/src/components/use-pane-notice-footer.tsx +3 -1
  63. package/src/docs/snapshot.json +2 -2
  64. package/src/i18n/es.ts +1 -0
  65. package/src/i18n/ja.ts +1 -0
  66. package/src/i18n/ko.ts +1 -0
  67. package/src/i18n/zh-cn.ts +1 -0
  68. package/src/i18n/zh-tw.ts +1 -0
  69. package/src/market-data/market/format.ts +35 -1
  70. package/src/market-data/quotes/contributions.ts +13 -0
  71. package/src/market-data/quotes/export-identity.ts +36 -1
  72. package/src/market-data/quotes/resolution.ts +16 -0
  73. package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
  74. package/src/plugins/builtin/analytics/risk-client.ts +12 -2
  75. package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
  76. package/src/plugins/builtin/analytics/risk-math.ts +23 -6
  77. package/src/plugins/builtin/analytics/risk-model.ts +20 -9
  78. package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
  79. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
  80. package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
  81. package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
  82. package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
  83. package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
  84. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  85. package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
  86. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
  87. package/src/plugins/builtin/cpi/headless.ts +6 -1
  88. package/src/plugins/builtin/cpi/model.ts +17 -0
  89. package/src/plugins/builtin/cpi/pane.tsx +3 -1
  90. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  91. package/src/plugins/builtin/crypto-board/headless.ts +10 -2
  92. package/src/plugins/builtin/crypto-board/model.ts +89 -11
  93. package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
  94. package/src/plugins/builtin/dividend-yield/client.ts +24 -2
  95. package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
  96. package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
  97. package/src/plugins/builtin/dividend-yield/view.ts +5 -1
  98. package/src/plugins/builtin/earnings/history-table.ts +8 -0
  99. package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
  100. package/src/plugins/builtin/econ/calendar-model.ts +17 -1
  101. package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
  102. package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
  103. package/src/plugins/builtin/macro-day/headless.ts +21 -10
  104. package/src/plugins/builtin/macro-day/model.ts +40 -3
  105. package/src/plugins/builtin/macro-day/pane.tsx +26 -8
  106. package/src/plugins/builtin/macro-day/releases.ts +24 -1
  107. package/src/plugins/builtin/money-markets/client.ts +4 -1
  108. package/src/plugins/builtin/money-markets/headless.ts +15 -4
  109. package/src/plugins/builtin/money-markets/index.tsx +1 -1
  110. package/src/plugins/builtin/money-markets/pane.tsx +7 -1
  111. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
  112. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
  113. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
  114. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -0
  115. package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
  116. package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -3
  117. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
  118. package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
  119. package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
  120. package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
  121. package/src/plugins/builtin/portfolio-list/table.tsx +25 -15
  122. package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
  123. package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
  124. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
  125. package/src/plugins/builtin/ticker-detail/headless.ts +26 -1
  126. package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
  127. package/src/plugins/builtin/ticker-detail/overview/model.ts +4 -1
  128. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
  129. package/src/portfolio/collection-name.ts +2 -1
  130. package/src/portfolio/column-values.ts +14 -4
  131. package/src/portfolio/listed-symbol.ts +4 -2
  132. package/src/portfolio/period-pnl.ts +51 -1
  133. package/src/renderers/dom/dialog-host.tsx +5 -5
  134. package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
  135. package/src/renderers/opentui/dialog-host.tsx +3 -4
  136. package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
  137. package/src/sources/provider-router/history.ts +5 -2
  138. package/src/test-support/plugin-persistence.ts +12 -0
  139. package/src/tickers/company-name-listing.ts +4 -3
  140. package/src/tickers/company-name.ts +19 -1
  141. package/src/tickers/instrument-coverage.ts +27 -0
  142. package/src/tickers/search/home-listing.ts +38 -1
  143. package/src/tickers/search/index.ts +3 -2
  144. package/src/tickers/search/ranking.ts +21 -2
  145. package/src/time-series/base-series.ts +4 -0
  146. package/src/time-series/types.ts +5 -2
  147. package/src/types/financials.ts +13 -0
  148. package/src/types/headless.ts +2 -0
  149. package/src/ui/dialog-stack.ts +17 -0
  150. package/src/ui/dialog.tsx +6 -2
  151. package/src/utils/crypto-pair.ts +9 -0
  152. package/src/utils/exchanges.ts +13 -0
  153. package/src/utils/financial-statements.ts +60 -3
  154. package/src/utils/futures-generic.ts +14 -0
  155. package/src/utils/trailing-dividend.ts +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gloomberb",
3
- "version": "0.20.13",
3
+ "version": "0.20.14",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Market research and portfolio tracker for the terminal",
6
6
  "module": "src/public/index.ts",
@@ -95,6 +95,7 @@
95
95
  "check:pane-screenshot": "bun run scripts/pane-chrome/screenshot.ts",
96
96
  "check:pane-rest": "bun run scripts/pane-chrome/rest-diff.ts",
97
97
  "check:pane-layout": "bun run scripts/pane-chrome/layout-sweep.ts",
98
+ "check:pane-data": "bun run scripts/pane-chrome/data-sweep.ts",
98
99
  "check:ui-tokens": "bun run scripts/pane-chrome/ui-tokens.ts",
99
100
  "ui:benchmark": "bun run scripts/pane-chrome/ui-benchmark.ts",
100
101
  "askg:tool-sweep": "bun run scripts/askg-tool-sweep.ts",
@@ -539,7 +539,25 @@ index b9445d2cca9477dfe06026da451b6d19268fcbdd..1f5795ab76800a64fdb0acf4a1ed0186
539
539
  this._hasPointer = true;
540
540
  this._lastPointerModifiers = mouseEvent.modifiers;
541
541
  if (this._console.visible) {
542
- @@ -24437,6 +24667,8 @@ Captured external output:
542
+ @@ -24327,6 +24557,17 @@ Captured external output:
543
+ const sameElement = maybeRenderableId === this.lastOverRenderableNum;
544
+ this.lastOverRenderableNum = maybeRenderableId;
545
+ const maybeRenderable = Renderable.renderablesByNumber.get(maybeRenderableId);
546
+ + // A press where the pointer was not last over took it there: some terminals report no motion between presses,
547
+ + // so what it was over would keep its hover (a chart its crosshair) until the next move.
548
+ + if (!sameElement && mouseEvent.type === "down" && !this.capturedRenderable && this.lastOverRenderable !== maybeRenderable) {
549
+ + if (this.lastOverRenderable && !this.lastOverRenderable.isDestroyed) {
550
+ + this.lastOverRenderable.processMouseEvent(new MouseEvent(this.lastOverRenderable, { ...mouseEvent, type: "out" }));
551
+ + }
552
+ + this.lastOverRenderable = maybeRenderable;
553
+ + if (maybeRenderable) {
554
+ + maybeRenderable.processMouseEvent(new MouseEvent(maybeRenderable, { ...mouseEvent, type: "over" }));
555
+ + }
556
+ + }
557
+ if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
558
+ const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
559
+ if (canStartSelection && maybeRenderable) {
560
+ @@ -24437,6 +24678,8 @@ Captured external output:
543
561
  return;
544
562
  }
545
563
  const baseEvent = {
@@ -548,7 +566,7 @@ index b9445d2cca9477dfe06026da451b6d19268fcbdd..1f5795ab76800a64fdb0acf4a1ed0186
548
566
  type: "move",
549
567
  button: 0,
550
568
  x: this._latestPointer.x,
551
- @@ -24527,6 +24759,7 @@ Captured external output:
569
+ @@ -24527,6 +24770,7 @@ Captured external output:
552
570
  const pendingSplitFooterTransition = this.pendingSplitFooterTransition;
553
571
  const previousGeometry = calculateRenderGeometry(this._screenMode, this._terminalWidth, this._terminalHeight, this._footerHeight);
554
572
  const prevWidth = this._terminalWidth;
@@ -556,7 +574,7 @@ index b9445d2cca9477dfe06026da451b6d19268fcbdd..1f5795ab76800a64fdb0acf4a1ed0186
556
574
  const previousTerminalHeight = this._terminalHeight;
557
575
  const visiblePreviousSplitHeight = pendingSplitFooterTransition?.sourceHeight ?? previousGeometry.effectiveFooterHeight;
558
576
  this._terminalWidth = width;
559
- @@ -24832,6 +25065,11 @@ Captured external output:
577
+ @@ -24832,6 +25076,11 @@ Captured external output:
560
578
  this.clock.clearTimeout(this.resizeTimeoutId);
561
579
  this.resizeTimeoutId = null;
562
580
  }
@@ -568,7 +586,7 @@ index b9445d2cca9477dfe06026da451b6d19268fcbdd..1f5795ab76800a64fdb0acf4a1ed0186
568
586
  if (this.capabilityTimeoutId !== null) {
569
587
  this.clock.clearTimeout(this.capabilityTimeoutId);
570
588
  this.capabilityTimeoutId = null;
571
- @@ -24847,6 +25085,7 @@ Captured external output:
589
+ @@ -24847,6 +25096,7 @@ Captured external output:
572
590
  }
573
591
  this.themeModeState.cancelRefresh();
574
592
  this._isRunning = false;
@@ -10,30 +10,43 @@ import type { AuthUser } from "../api-client";
10
10
  import { DialogFrame } from "../components/ui/frame";
11
11
  import { useAppLanguage } from "../i18n/react";
12
12
  import { useDialog, type PromptContext } from "../ui/dialog";
13
+ import { clickOutsideWhileClean } from "../ui/dialog-stack";
13
14
  import { AuthForm, authFormTitle } from "./auth-form";
14
15
  import type { AccountMode } from "./auth-model";
15
16
  import { CloudVerificationPanel } from "./verification-panel";
16
17
 
17
18
  function AuthDialog({
18
19
  initialMode,
20
+ reason,
19
21
  resolve,
20
22
  dismiss,
21
- }: PromptContext<AuthUser | undefined> & { initialMode: AccountMode }) {
23
+ onCleanChange,
24
+ }: PromptContext<AuthUser | undefined> & {
25
+ initialMode: AccountMode;
26
+ reason?: string;
27
+ onCleanChange: (clean: boolean) => void;
28
+ }) {
22
29
  useAppLanguage();
23
30
  const [mode, setMode] = useState<AccountMode>(initialMode);
24
31
  const [verifyingUser, setVerifyingUser] = useState<AuthUser | null>(null);
32
+ const [typed, setTyped] = useState(false);
33
+ // A click outside closes it only while it is clean: never with something typed, nor once the account
34
+ // waits on its emailed code.
35
+ useEffect(() => onCleanChange(!typed && !verifyingUser), [onCleanChange, typed, verifyingUser]);
25
36
 
26
- if (verifyingUser) return <DialogFrame title={`Confirm ${verifyingUser.email}`}>
37
+ // The close button always closes it, so a mouse is never trapped in it.
38
+ if (verifyingUser) return <DialogFrame title={`Confirm ${verifyingUser.email}`} onClose={dismiss}>
27
39
  <CloudVerificationPanel onVerified={resolve} onContinueFree={() => resolve(verifyingUser)} />
28
40
  </DialogFrame>;
29
41
 
30
42
  return (
31
- <DialogFrame title={authFormTitle(mode)}>
43
+ <DialogFrame title={authFormTitle(mode)} subtitle={reason} onClose={dismiss}>
32
44
  <AuthForm
33
45
  initialMode={initialMode}
34
46
  onModeChange={setMode}
35
47
  onSignedIn={(user) => user.emailVerified ? resolve(user) : setVerifyingUser(user)}
36
48
  onEscape={dismiss}
49
+ onTypedChange={setTyped}
37
50
  />
38
51
  </DialogFrame>
39
52
  );
@@ -41,6 +54,8 @@ function AuthDialog({
41
54
 
42
55
  export interface AuthDialogRequest {
43
56
  mode?: AccountMode;
57
+ /** What asked for it, under the title: the delayed mark says what is delayed and by how much. */
58
+ reason?: string;
44
59
  onSignedIn?: (user: AuthUser) => void;
45
60
  }
46
61
 
@@ -77,13 +92,16 @@ export function AuthDialogHost() {
77
92
  if (openRef.current) return;
78
93
  openRef.current = true;
79
94
  openAuthDialogs += 1;
95
+ const { closeOnClickOutside, setClean } = clickOutsideWhileClean();
80
96
  void dialog
81
97
  .prompt<AuthUser | undefined>({
82
- closeOnClickOutside: false,
98
+ closeOnClickOutside,
83
99
  content: (context: unknown) => (
84
100
  <AuthDialog
85
101
  {...(context as PromptContext<AuthUser | undefined>)}
86
102
  initialMode={request.mode ?? "login"}
103
+ reason={request.reason}
104
+ onCleanChange={setClean}
87
105
  />
88
106
  ),
89
107
  })
@@ -4,7 +4,7 @@
4
4
  * own panel. The sign-in attempt it shares with onboarding lives in
5
5
  * `email-auth-attempt`, the non-React logic in `auth-model`.
6
6
  */
7
- import { useCallback, useRef, useState, type ReactNode } from "react";
7
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
8
8
  import { apiClient, type AuthUser } from "../api-client";
9
9
  import { matchesKeyChord, parseKeyChord } from "../app/keybindings";
10
10
  import { Button, Spinner, TextField } from "../components";
@@ -50,6 +50,8 @@ export interface AuthFormProps {
50
50
  onModeChange?: (mode: AccountMode) => void;
51
51
  /** Extra actions below the buttons, e.g. the gate's QR alternative. */
52
52
  footer?: ReactNode;
53
+ /** Whether anything is typed in it, so a dialog holding it closes on a stray click only while nothing would be lost. */
54
+ onTypedChange?: (typed: boolean) => void;
53
55
  }
54
56
 
55
57
  export function AuthForm({
@@ -59,6 +61,7 @@ export function AuthForm({
59
61
  shortcutScope,
60
62
  onModeChange,
61
63
  footer,
64
+ onTypedChange,
62
65
  }: AuthFormProps) {
63
66
  useAppLanguage();
64
67
  // The desktop and the web size the column and let its rows fill it, as the kit's dialogs do.
@@ -70,6 +73,8 @@ export function AuthForm({
70
73
  const [activeField, setActiveField] = useState<EmailAuthField>("email");
71
74
  const [showPassword, setShowPassword] = useState(false);
72
75
  const [resetState, setResetState] = useState<ResetState>("idle");
76
+ const typed = email !== "" || password !== "";
77
+ useEffect(() => onTypedChange?.(typed), [onTypedChange, typed]);
73
78
  const emailInputRef = useRef<InputRenderable>(null);
74
79
  const passwordInputRef = useRef<InputRenderable>(null);
75
80
  const {
@@ -17,7 +17,7 @@ import { t } from "../i18n";
17
17
  import { useAppLanguage } from "../i18n/react";
18
18
  import { useViewport } from "../react/input";
19
19
  import { colors } from "../theme/colors";
20
- import { Box, Text, TextAttributes, useUiCapabilities } from "../ui";
20
+ import { Box, useUiCapabilities } from "../ui";
21
21
  import { type DialogApi, type PromptContext, useDialogKeyboard } from "../ui/dialog";
22
22
  import { logFailure } from "../utils/log-failure";
23
23
  import { accountSession } from "./session";
@@ -187,21 +187,14 @@ function CheckoutHandoffDialog({
187
187
  );
188
188
  }
189
189
 
190
+ // The kit's frame, as every other dialog: its close button is a mouse's way out. A click outside never closes
191
+ // it: from the first moment a checkout is being opened or paid for in the browser.
190
192
  return (
191
- <Box flexDirection="column" alignItems="center">
192
- <Box height={1}>
193
- <Text fg={colors.textBright} attributes={TextAttributes.BOLD}>{title}</Text>
193
+ <DialogFrame title={title} subtitle={subtitle} footer={t("esc to close")} onClose={dismiss}>
194
+ <Box flexDirection="column" alignItems="center">
195
+ {panel(termHeight - TERMINAL_DIALOG_ROWS)}
194
196
  </Box>
195
- <Box height={1}>
196
- <Text fg={colors.textDim}>{subtitle}</Text>
197
- </Box>
198
- <Box height={1} />
199
- {panel(termHeight - TERMINAL_DIALOG_ROWS)}
200
- <Box height={1} />
201
- <Box height={1}>
202
- <Text fg={colors.textMuted}>{t("esc to close")}</Text>
203
- </Box>
204
- </Box>
197
+ </DialogFrame>
205
198
  );
206
199
  }
207
200
 
@@ -11,13 +11,15 @@ import { t, tf } from "../i18n";
11
11
  import { useAppLanguage } from "../i18n/react";
12
12
  import { useViewport } from "../react/input";
13
13
  import { colors } from "../theme/colors";
14
- import { Box, Text, TextAttributes, useUiCapabilities } from "../ui";
14
+ import { Box, useUiCapabilities } from "../ui";
15
15
  import { Button } from "../components/ui/button";
16
16
  import { DialogActions } from "../components/ui/dialog-actions";
17
17
  import { FORM_DIALOG_WIDTH, DialogFrame } from "../components/ui/frame";
18
18
  import { SignInCodePanel } from "../components/sign-in-code-panel";
19
- import { useDialog, useDialogKeyboard, type PromptContext } from "../ui/dialog";
19
+ import { useDialog, useDialogKeyboard, type DialogApi, type PromptContext } from "../ui/dialog";
20
+ import { clickOutsideWhileClean } from "../ui/dialog-stack";
20
21
  import { isPlainKey, type KeyboardModifierEventLike } from "../utils/keyboard";
22
+ import { logFailure } from "../utils/log-failure";
21
23
  import { DeviceSignInController, type DeviceSignInSnapshot } from "./device-signin";
22
24
 
23
25
  /** How long the approval stays on screen before `onApproved` moves on. */
@@ -110,12 +112,22 @@ export function DeviceSignInPanel({
110
112
  const TERMINAL_DIALOG_ROWS = 12;
111
113
  const DESKTOP_DIALOG_ROWS = 10;
112
114
 
113
- export function DeviceSignInDialog({ resolve, dismiss }: PromptContext<AuthUser | undefined>) {
115
+ /** Whether the person may be acting on the code now: shown and waiting, or approved and about to close. */
116
+ function isDeviceSignInPending(snapshot: Pick<DeviceSignInSnapshot, "phase">): boolean {
117
+ return snapshot.phase === "waiting" || snapshot.phase === "approved";
118
+ }
119
+
120
+ function DeviceSignInDialog({ resolve, dismiss, onCleanChange }: PromptContext<AuthUser | undefined> & {
121
+ /** A click outside closes it only while no code is out: never while one may be approved in the browser. */
122
+ onCleanChange?: (clean: boolean) => void;
123
+ }) {
114
124
  useAppLanguage();
115
125
  const { nativePaneChrome } = useUiCapabilities();
116
126
  const { height: termHeight } = useViewport();
117
127
  // Closes on approval after a beat so the confirmation is visible; enter skips the wait.
118
128
  const { snapshot, retry } = useDeviceSignIn({ onApproved: resolve });
129
+ const pending = isDeviceSignInPending(snapshot);
130
+ useEffect(() => onCleanChange?.(!pending), [onCleanChange, pending]);
119
131
 
120
132
  useDialogKeyboard((event) => {
121
133
  event.stopPropagation();
@@ -147,24 +159,28 @@ export function DeviceSignInDialog({ resolve, dismiss }: PromptContext<AuthUser
147
159
  );
148
160
  }
149
161
 
162
+ // The kit's frame, as every other dialog: its close button is a mouse's way out.
150
163
  return (
151
- <Box flexDirection="column" alignItems="center">
152
- <Box height={1}>
153
- <Text fg={colors.textBright} attributes={TextAttributes.BOLD}>{title}</Text>
154
- </Box>
155
- <Box height={1}>
156
- <Text fg={colors.textDim}>{subtitle}</Text>
157
- </Box>
158
- <Box height={1} />
159
- <DeviceSignInPanel snapshot={snapshot} height={Math.max(4, termHeight - TERMINAL_DIALOG_ROWS)} />
160
- <Box height={1} />
161
- <Box height={1}>
162
- <Text fg={colors.textMuted}>{t("r to refresh the code · esc to cancel")}</Text>
164
+ <DialogFrame title={title} subtitle={subtitle} footer={t("r to refresh the code · esc to cancel")} onClose={dismiss}>
165
+ <Box flexDirection="column" alignItems="center">
166
+ <DeviceSignInPanel snapshot={snapshot} height={Math.max(4, termHeight - TERMINAL_DIALOG_ROWS)} />
163
167
  </Box>
164
- </Box>
168
+ </DialogFrame>
165
169
  );
166
170
  }
167
171
 
172
+ /** Gloom's device sign-in as a full dialog, closing on a click outside while no code is out. */
173
+ export function promptDeviceSignIn(dialog: DialogApi): Promise<AuthUser | undefined> {
174
+ const { closeOnClickOutside, setClean } = clickOutsideWhileClean();
175
+ return dialog.prompt<AuthUser | undefined>({
176
+ size: "full",
177
+ closeOnClickOutside,
178
+ content: (context: unknown) => (
179
+ <DeviceSignInDialog {...(context as PromptContext<AuthUser | undefined>)} onCleanChange={setClean} />
180
+ ),
181
+ });
182
+ }
183
+
168
184
  export interface DeviceSignInDialogRequest {
169
185
  onSignedIn?: (user: AuthUser) => void;
170
186
  }
@@ -186,19 +202,14 @@ export function DeviceSignInDialogHost() {
186
202
  const listener = (request: DeviceSignInDialogRequest) => {
187
203
  if (openRef.current) return;
188
204
  openRef.current = true;
189
- void dialog
190
- .prompt<AuthUser | undefined>({
191
- size: "full",
192
- content: (context: unknown) => (
193
- <DeviceSignInDialog {...(context as PromptContext<AuthUser | undefined>)} />
194
- ),
195
- })
205
+ void promptDeviceSignIn(dialog)
196
206
  .then((signedInUser) => {
197
207
  if (signedInUser) request.onSignedIn?.(signedInUser);
198
208
  })
199
209
  .finally(() => {
200
210
  openRef.current = false;
201
- });
211
+ })
212
+ .catch(logFailure("account.device-signin-dialog", "Device sign-in dialog failed"));
202
213
  };
203
214
  dialogRequestListeners.add(listener);
204
215
  return () => {
@@ -28,6 +28,16 @@ interface CryptoDayRange {
28
28
  highAt: string;
29
29
  start: string;
30
30
  end: string;
31
+ /**
32
+ * The spot exchanges whose own 24-hour low reached `low`; one of several checked makes the low that exchange's,
33
+ * not the market's. Absent from a server that does not check, or when no exchange could be read.
34
+ */
35
+ lowVenues?: string[];
36
+ highVenues?: string[];
37
+ /** The exchanges whose own 24-hour range was read beside the composite's. */
38
+ venuesChecked?: string[];
39
+ /** The exchanges' own candles around the extremes are still being read: a later answer names them. */
40
+ venuesPending?: boolean;
31
41
  }
32
42
 
33
43
  export interface CryptoMarketAsset {
@@ -165,7 +165,9 @@ export function parseApiErrorMessage(body: string): string {
165
165
  (value): value is string =>
166
166
  typeof value === "string" && value.trim().length > 0,
167
167
  );
168
- return parts.join(" ") || validationErrorText(record) || NO_MESSAGE;
168
+ // A route can send the schema's refusal as its message, the same object written out as text.
169
+ const wrapped = parts.length === 1 ? parseApiErrorDetails(parts[0]!) : undefined;
170
+ return (wrapped && validationErrorText(wrapped)) || parts.join(" ") || validationErrorText(record) || NO_MESSAGE;
169
171
  }
170
172
 
171
173
  const NO_MESSAGE = "The server returned an error without a message.";
@@ -37,6 +37,13 @@ export interface MoneyMarketRow {
37
37
  fetchedAt: string | null;
38
38
  unavailableReason: "source-unavailable" | "metadata-unavailable" | "metadata-mismatch" | "no-observations" | "components-unavailable" | null;
39
39
  notes: string[];
40
+ /** A bill's coupon equivalent (investment rate), percent, beside its discount-basis `value`; on bill rows only. */
41
+ couponEquivalent?: number | null;
42
+ couponEquivalentAsOf?: string | null;
43
+ /** Who published the row's latest value (`U.S. Treasury`, `FRED`); older servers send none. */
44
+ sourceName?: string;
45
+ /** When the publisher last changed what was read, when it says. */
46
+ publishedAt?: string | null;
40
47
  }
41
48
 
42
49
  interface BillSnapshot {
@@ -1,4 +1,5 @@
1
1
  import { logFailure } from "../utils/log-failure";
2
+ import { debugLog } from "../utils/debug-log";
2
3
  import { httpFetch, isHttpFetchStreaming } from "../utils/http-transport";
3
4
  import { OperationTimeoutError } from "../utils/async-deadline";
4
5
  import {
@@ -18,6 +19,9 @@ import {
18
19
  import { SESSION_COOKIE_NAMES } from "./session-cookie";
19
20
  import { asDataServiceFailure, DataServiceUnreachableError, isDroppedConnection } from "../utils/network-failure";
20
21
 
22
+ /** Request failures with the endpoint they were for, which their messages leave out. */
23
+ const requestLog = debugLog.createLogger("cloud-api");
24
+
21
25
  /** The public Gloom Cloud API, which the web app's same-origin `/api` path forwards to. */
22
26
  export const DEFAULT_API_URL = "https://api.gloom.sh";
23
27
  /**
@@ -577,11 +581,17 @@ export class CloudApiRequestTransport {
577
581
  const answered = () => this.answers > answersAtStart;
578
582
  const generation = cloudApiTransportGeneration;
579
583
  const what = path.startsWith("/market/") ? "Cloud market request" : "Cloud request";
580
- const timedOut = (ms: number) => new OperationTimeoutError(`${what} timed out after ${ms}ms: ${path.split("?")[0]}`);
584
+ // The endpoint stays out of the message, which reports and panes print; the debug log's line names it.
585
+ const endpoint = path.split("?")[0]!;
586
+ const failed = (message: string) => {
587
+ requestLog.warn(message, { endpoint });
588
+ return new OperationTimeoutError(message);
589
+ };
590
+ const timedOut = (ms: number) => failed(`${what} timed out after ${ms}ms`);
581
591
  const timers: Array<ReturnType<typeof setTimeout>> = [];
582
592
  if (this.hungAt != null && Date.now() - this.hungAt < HUNG_FAIL_FAST_MS && !controller.signal.aborted) {
583
593
  callerSignal?.removeEventListener("abort", abortFromCaller);
584
- throw new DataServiceUnreachableError(new OperationTimeoutError(`${what} not sent: the last one got no answer: ${path.split("?")[0]}`));
594
+ throw new DataServiceUnreachableError(failed(`${what} not sent: the last one got no answer`));
585
595
  }
586
596
  this.pending += 1;
587
597
  try {
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "src/account/auth-dialog.tsx": ["void:dialog.prompt().then().finally()"],
3
3
  "src/account/checkout-handoff.tsx": ["void:value.opened.then()"],
4
- "src/account/device-signin-dialog.tsx": ["void:dialog.prompt().then().finally()"],
5
4
  "src/account/device-signin.ts": ["void:this.run()"],
6
5
  "src/account/email-auth-attempt.ts": ["void:function()"],
7
6
  "src/account/verification-panel.tsx": ["void:check()","void:check()","void:check()","void:check()"],
@@ -7,7 +7,7 @@
7
7
  * exported here.
8
8
  */
9
9
  import { useEffect, useRef, useState } from "react";
10
- import { apiClient, type AuthUser } from "../../api-client";
10
+ import { apiClient } from "../../api-client";
11
11
  import { SignInCodePanel } from "../../components/sign-in-code-panel";
12
12
  import { Button } from "../../components/ui/button";
13
13
  import { DialogActions } from "../../components/ui/dialog-actions";
@@ -17,11 +17,12 @@ import { useAppLanguage } from "../../i18n/react";
17
17
  import { useViewport } from "../../react/input";
18
18
  import { colors } from "../../theme/colors";
19
19
  import { useThemeColors } from "../../theme/theme-context";
20
- import { Box, Text, TextAttributes, useUiCapabilities } from "../../ui";
20
+ import { Box, Text, useUiCapabilities } from "../../ui";
21
21
  import { useDialog, useDialogKeyboard, type DialogApi, type PromptContext } from "../../ui/dialog";
22
+ import { clickOutsideWhileClean } from "../../ui/dialog-stack";
22
23
  import { isPlainKey } from "../../utils/keyboard";
23
24
  import { wrapTextLines } from "../../utils/text-wrap";
24
- import { DeviceSignInDialog } from "../../account/device-signin-dialog";
25
+ import { promptDeviceSignIn } from "../../account/device-signin-dialog";
25
26
  import type { BrokerReplacePrompt, SignedInBroker } from "./client";
26
27
  import {
27
28
  BrokerSignInController,
@@ -122,10 +123,7 @@ export function useBrokerSignInAttempt(
122
123
 
123
124
  /** Gloom's device sign-in, stacked over whatever asked for it. True once signed in. */
124
125
  export async function promptGloomSignIn(dialog: DialogApi): Promise<boolean> {
125
- return !!await dialog.prompt<AuthUser | undefined>({
126
- size: "full",
127
- content: (context: unknown) => <DeviceSignInDialog {...(context as PromptContext<AuthUser | undefined>)} />,
128
- });
126
+ return !!await promptDeviceSignIn(dialog);
129
127
  }
130
128
 
131
129
  /**
@@ -147,11 +145,14 @@ function BrokerSignInDialog({
147
145
  write,
148
146
  renew,
149
147
  replace,
148
+ onCleanChange,
150
149
  }: PromptContext<BrokerSignInOutcome> & {
151
150
  broker: SignedInBroker;
152
151
  write: boolean;
153
152
  renew: boolean;
154
153
  replace: BrokerReplacePrompt | null;
154
+ /** A click outside closes it only while no link is out: never while the broker may be connecting through one. */
155
+ onCleanChange?: (clean: boolean) => void;
155
156
  }) {
156
157
  useAppLanguage();
157
158
  const { nativePaneChrome } = useUiCapabilities();
@@ -159,6 +160,8 @@ function BrokerSignInDialog({
159
160
  // Close after a beat so "Connected" is visible; enter skips the wait. Signed
160
161
  // out closes at once, for the host to sign in to Gloom.
161
162
  const { snapshot, restart, finish } = useBrokerSignInAttempt(broker, write, resolve, { renew });
163
+ const pending = snapshot.phase === "waiting" || snapshot.phase === "connected";
164
+ useEffect(() => onCleanChange?.(!pending), [onCleanChange, pending]);
162
165
 
163
166
  useDialogKeyboard((event) => {
164
167
  event.stopPropagation();
@@ -197,27 +200,19 @@ function BrokerSignInDialog({
197
200
  );
198
201
  }
199
202
 
203
+ // The kit's frame, as every other dialog: its close button is a mouse's way out.
200
204
  return (
201
- <Box flexDirection="column" alignItems="center">
202
- <Box height={1}>
203
- <Text fg={colors.textBright} attributes={TextAttributes.BOLD}>{title}</Text>
204
- </Box>
205
- <Box height={1}>
206
- <Text fg={colors.textDim}>{subtitle}</Text>
205
+ <DialogFrame title={title} subtitle={subtitle} footer={t("r for a new link · esc to cancel")} onClose={dismiss}>
206
+ <Box flexDirection="column" alignItems="center">
207
+ <BrokerConnectView
208
+ broker={broker}
209
+ snapshot={snapshot}
210
+ height={Math.max(4, termHeight - TERMINAL_DIALOG_ROWS)}
211
+ width={Math.max(10, termWidth - TERMINAL_DIALOG_INSET)}
212
+ replace={replace}
213
+ />
207
214
  </Box>
208
- <Box height={1} />
209
- <BrokerConnectView
210
- broker={broker}
211
- snapshot={snapshot}
212
- height={Math.max(4, termHeight - TERMINAL_DIALOG_ROWS)}
213
- width={Math.max(10, termWidth - TERMINAL_DIALOG_INSET)}
214
- replace={replace}
215
- />
216
- <Box height={1} />
217
- <Box height={1}>
218
- <Text fg={colors.textMuted}>{t("r for a new link · esc to cancel")}</Text>
219
- </Box>
220
- </Box>
215
+ </DialogFrame>
221
216
  );
222
217
  }
223
218
 
@@ -335,18 +330,23 @@ export function BrokerSignInDialogHost() {
335
330
  void runBrokerSignIn(request.broker, request.write, {
336
331
  isSignedIn: () => apiClient.isSignedIn(),
337
332
  signInToGloom: () => promptGloomSignIn(dialog),
338
- connectBroker: async (broker, write, renew) => await dialog.prompt<BrokerSignInOutcome>({
339
- size: "full",
340
- content: (context: unknown) => (
341
- <BrokerSignInDialog
342
- {...(context as PromptContext<BrokerSignInOutcome>)}
343
- broker={broker}
344
- write={write}
345
- renew={renew}
346
- replace={request.replace ?? null}
347
- />
348
- ),
349
- }) ?? "cancelled",
333
+ connectBroker: async (broker, write, renew) => {
334
+ const { closeOnClickOutside, setClean } = clickOutsideWhileClean();
335
+ return await dialog.prompt<BrokerSignInOutcome>({
336
+ size: "full",
337
+ closeOnClickOutside,
338
+ content: (context: unknown) => (
339
+ <BrokerSignInDialog
340
+ {...(context as PromptContext<BrokerSignInOutcome>)}
341
+ broker={broker}
342
+ write={write}
343
+ renew={renew}
344
+ replace={request.replace ?? null}
345
+ onCleanChange={setClean}
346
+ />
347
+ ),
348
+ }) ?? "cancelled";
349
+ },
350
350
  }, { renew: request.renew })
351
351
  .then(request.resolve, () => request.resolve(false))
352
352
  .finally(() => {