gloomberb 0.20.0 → 0.20.1

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 (86) hide show
  1. package/package.json +1 -1
  2. package/patches/electrobun-devkit@2.0.5.patch +268 -8
  3. package/src/api-client/crypto-markets.ts +20 -2
  4. package/src/api-client/fund-facts.ts +23 -1
  5. package/src/api-client/types/filings-and-calls.ts +6 -0
  6. package/src/app/runtime/plugin-seed.ts +119 -0
  7. package/src/app/runtime/startup.ts +45 -9
  8. package/src/app.tsx +1 -0
  9. package/src/cli/board-coins.ts +38 -5
  10. package/src/cli/commands/crypto-hints.ts +8 -1
  11. package/src/cli/commands/market.ts +29 -26
  12. package/src/cli/commands/overview.ts +13 -6
  13. package/src/cli/commands/ticker.ts +61 -14
  14. package/src/cli/company-name-hint.ts +19 -0
  15. package/src/cli/entry.ts +10 -4
  16. package/src/cli/glossary.ts +25 -0
  17. package/src/cli/helpers.ts +4 -2
  18. package/src/cli/not-a-ticker.ts +26 -1
  19. package/src/cli/pane-functions/freshness.ts +45 -29
  20. package/src/cli/pane-functions/market-session.ts +14 -5
  21. package/src/cli/restore-plugins.ts +164 -51
  22. package/src/components/chart-table/header.tsx +10 -1
  23. package/src/components/chart-table/layout.ts +14 -5
  24. package/src/components/command-bar/panel/index.tsx +13 -0
  25. package/src/components/command-bar/panel/layout.ts +7 -0
  26. package/src/components/command-bar/panel/runtime.ts +1 -0
  27. package/src/components/command-bar/panel/types.ts +2 -0
  28. package/src/i18n/es.ts +3 -0
  29. package/src/i18n/ja.ts +3 -0
  30. package/src/i18n/ko.ts +3 -0
  31. package/src/i18n/zh-cn.ts +3 -0
  32. package/src/i18n/zh-tw.ts +3 -0
  33. package/src/market-data/fund-facts.ts +7 -1
  34. package/src/market-data/market/change-basis.ts +20 -0
  35. package/src/market-data/market/format.ts +62 -2
  36. package/src/market-data/market/futures-week.ts +3 -1
  37. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  38. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  39. package/src/plugins/builtin/correlation/compute.ts +8 -2
  40. package/src/plugins/builtin/correlation/headless.ts +10 -9
  41. package/src/plugins/builtin/correlation/history.ts +30 -0
  42. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  43. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  44. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  45. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  46. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  47. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  48. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  49. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  50. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  51. package/src/plugins/builtin/perps/headless.ts +8 -2
  52. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  53. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  54. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  55. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  56. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  57. package/src/plugins/builtin/sec/headless.ts +30 -1
  58. package/src/plugins/builtin/sec/index.tsx +26 -5
  59. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  60. package/src/plugins/builtin/ticker-detail/overview/model.ts +14 -6
  61. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  62. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  63. package/src/plugins/extracted-plugins.ts +49 -24
  64. package/src/plugins/installer.ts +220 -31
  65. package/src/plugins/running-installs.ts +34 -0
  66. package/src/plugins/seed-progress.ts +72 -0
  67. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  68. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  69. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  70. package/src/renderers/electrobun/bun/index.ts +5 -0
  71. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  72. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  73. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  74. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  75. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  76. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  77. package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
  78. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  79. package/src/renderers/electrobun/view/main.tsx +4 -3
  80. package/src/renderers/opentui/start.tsx +3 -0
  81. package/src/telemetry/stall-reports.ts +21 -4
  82. package/src/utils/main-thread-stall.ts +21 -5
  83. package/src/utils/perf-marks.ts +88 -9
  84. package/src/utils/reported-money.ts +9 -2
  85. package/src/utils/sec.ts +34 -3
  86. package/src/plugins/seed-notice.ts +0 -20
@@ -9,6 +9,7 @@ import type {
9
9
  HeadlessSnapshotResult,
10
10
  } from "../../types/plugin";
11
11
  import { localTimeSuffix, parseReportTime, type ReportTime } from "../../utils/utc-time";
12
+ import { timeZoneLabel, zonedDateTimeParts } from "../../utils/zoned-date-time";
12
13
  import { isRecord } from "../../utils/guards";
13
14
  import { latestRegularSessionClose, readIndexSession } from "../../market-data/market/freshness";
14
15
  import {
@@ -962,29 +963,45 @@ function sourcesAsOfParts(freshness: ReportFreshness, sources: readonly ReportSo
962
963
  return undated && onRetrievalDay(day, freshness.retrievedAt) ? parts : [dayText(day), ...parts];
963
964
  }
964
965
 
966
+ const twoDigits = (value: number) => String(value).padStart(2, "0");
967
+
965
968
  /**
966
- * When the first venue opens again: its UTC time when that is later the same
967
- * UTC day, else its weekday at the venue (`Mon`), with the date a week out.
969
+ * When the first venue opens again, on the UTC clock and on the venue's own:
970
+ * `Wed 01:00 UTC, 09:00 SGT`. The UTC time carries its weekday unless it is
971
+ * later the same UTC day, and its date when it is over a week out; the
972
+ * venue's carries its weekday where its date is not the UTC one (`23:00 UTC,
973
+ * Wed 10:00 AET`). `short` and a venue with no known zone leave its clock out;
974
+ * the reader's own time, when they set a zone, follows both.
968
975
  */
969
- function reopenText(market: ReportMarket, now: number, local: boolean): { text: string; time: boolean } | null {
976
+ function reopenText(market: ReportMarket, now: number, local: boolean, short: boolean): string | null {
970
977
  if (!market.reopensAt || !market.reopensOn) return null;
971
978
  const at = Date.parse(market.reopensAt);
972
979
  if (!Number.isFinite(at)) return null;
973
980
  const iso = new Date(at).toISOString();
974
- if (iso.slice(0, 10) === new Date(now).toISOString().slice(0, 10)) return { text: `${iso.slice(11, 16)} UTC${local ? localTimeSuffix(at) : ""}`, time: true };
975
- return { text: at - now > WEEKDAY_ONLY_MS ? dayText(market.reopensOn) : WEEKDAYS[new Date(`${market.reopensOn}T00:00:00Z`).getUTCDay()]!, time: false };
981
+ const day = iso.slice(0, 10) === new Date(now).toISOString().slice(0, 10) ? ""
982
+ : at - now > WEEKDAY_ONLY_MS ? `${dayText(iso)} ` : `${WEEKDAYS[new Date(at).getUTCDay()]} `;
983
+ const utc = `${day}${iso.slice(11, 16)} UTC`;
984
+ const reader = local ? localTimeSuffix(at) : "";
985
+ const zone = market.reopensTimeZone;
986
+ const label = zone ? timeZoneLabel(zone) : null;
987
+ if (short || !zone || label === "UTC") return `${utc}${reader}`;
988
+ const venue = zonedDateTimeParts(at, zone);
989
+ const venueDay = `${venue.year}-${twoDigits(venue.month)}-${twoDigits(venue.day)}`;
990
+ const weekday = venueDay === iso.slice(0, 10) ? "" : `${WEEKDAYS[new Date(`${venueDay}T00:00:00Z`).getUTCDay()]} `;
991
+ return `${utc}, ${weekday}${twoDigits(venue.hour)}:${twoDigits(venue.minute)} ${label}${reader}`;
976
992
  }
977
993
 
978
994
  /**
979
- * `markets closed until Mon`; `short` is the compact form a narrow capture
980
- * falls back to (`reopens Mon`). A time is the regular session's open, and
981
- * says so (`pre-market open · regular session opens 13:30 UTC`), so it is
995
+ * `markets closed · regular session opens Wed 01:00 UTC, 09:00 SGT`; `short` is
996
+ * the compact form a narrow capture falls back to (`regular opens Wed 01:00
997
+ * UTC`). The time is the regular session's open, and says so
998
+ * (`pre-market open · regular session opens 13:30 UTC, 09:30 ET`), so it is
982
999
  * never read as when the pre-market opens, nor a US market as closed until
983
1000
  * then while its pre-market trades first. A futures venue's Sunday open is no
984
- * regular session's, so it reads `markets closed · reopens 22:00 UTC`.
1001
+ * regular session's, so it reads `markets closed · reopens 22:00 UTC, 17:00 CT`.
985
1002
  */
986
1003
  function marketText(market: ReportMarket, now: number, short: boolean, local: boolean): string {
987
- const reopen = reopenText(market, now, local);
1004
+ const reopen = reopenText(market, now, local, short);
988
1005
  switch (market.state) {
989
1006
  case "open":
990
1007
  return short ? "open" : "markets open";
@@ -992,13 +1009,12 @@ function marketText(market: ReportMarket, now: number, short: boolean, local: bo
992
1009
  return "after hours";
993
1010
  case "pre-market":
994
1011
  if (!reopen) return "pre-market open";
995
- return short ? `pre-market · regular opens ${reopen.text}` : `pre-market open · regular session opens ${reopen.text}`;
1012
+ return short ? `pre-market · regular opens ${reopen}` : `pre-market open · regular session opens ${reopen}`;
996
1013
  case "closed":
997
1014
  if (!reopen) return short ? "closed" : "markets closed";
998
1015
  // A futures venue's Sunday open is its first trade of the week, which no regular session is.
999
- if (reopen.time && market.firstTrade) return short ? `reopens ${reopen.text}` : `markets closed · reopens ${reopen.text}`;
1000
- if (reopen.time) return short ? `regular opens ${reopen.text}` : `markets closed · regular session opens ${reopen.text}`;
1001
- return short ? `reopens ${reopen.text}` : `markets closed until ${reopen.text}`;
1016
+ if (market.firstTrade) return short ? `reopens ${reopen}` : `markets closed · reopens ${reopen}`;
1017
+ return short ? `regular opens ${reopen}` : `markets closed · regular session opens ${reopen}`;
1002
1018
  default: {
1003
1019
  const _exhaustive: never = market.state;
1004
1020
  return _exhaustive;
@@ -1007,15 +1023,16 @@ function marketText(market: ReportMarket, now: number, short: boolean, local: bo
1007
1023
  }
1008
1024
 
1009
1025
  /**
1010
- * Where one venue's market stands now and the status line's words for it (`markets closed until Mon`), for a pane with
1011
- * no dated rows to read that from, such as a scanner. Null when no calendar places the venue.
1026
+ * Where one venue's market stands now and the status line's words for it (`markets closed · regular session opens
1027
+ * Mon 13:30 UTC, 09:30 ET`), for a pane with no dated rows to read that from, such as a scanner, with the open alone
1028
+ * (`Mon 13:30 UTC, 09:30 ET`) for a sentence of its own. Null when no calendar places the venue.
1012
1029
  */
1013
- export function venueMarketLine(exchange: string, now: number): { state: ReportMarket["state"]; text: string } | null {
1030
+ export function venueMarketLine(exchange: string, now: number): { state: ReportMarket["state"]; text: string; reopens: string | null } | null {
1014
1031
  const { market } = reportMarketSession([{ exchange, time: null }], now);
1015
- return market ? { state: market.state, text: marketText(market, now, false, false) } : null;
1032
+ return market ? { state: market.state, text: marketText(market, now, false, false), reopens: reopenText(market, now, false, false) } : null;
1016
1033
  }
1017
1034
 
1018
- /** Whether every market of a mixed report reads the same (`markets closed until Mon`): one line then says it for all. */
1035
+ /** Whether every market of a mixed report reads the same (`markets closed · regular session opens …`): one line then says it for all. */
1019
1036
  function sameMarketText(markets: readonly VenueMarket[], now: number): boolean {
1020
1037
  return new Set(markets.map((market) => marketText(market, now, false, false))).size === 1;
1021
1038
  }
@@ -1032,12 +1049,12 @@ function marketsText(markets: readonly VenueMarket[], now: number, short: boolea
1032
1049
  const opensAt = (market: VenueMarket) => market.reopensAt ? Date.parse(market.reopensAt) : Number.POSITIVE_INFINITY;
1033
1050
  const rank = (market: VenueMarket) => market.state === "open" ? 0 : market.state === "closed" ? 2 : 1;
1034
1051
  const ordered = [...markets].sort((left, right) => rank(left) - rank(right) || opensAt(left) - opensAt(right));
1035
- // `LSE opens 08:00 UTC · US 13:30 UTC`: a verb is said once for the timed opens that follow each other
1036
- // with it; a week's first trade after a session's open says its own (`reopens 22:00 UTC`).
1052
+ // `LSE opens 08:00 UTC, 08:00 UK · US 13:30 UTC, 09:30 ET`: a verb is said once for the opens that follow
1053
+ // each other with it; a week's first trade after a session's open says its own (`reopens 22:00 UTC`).
1037
1054
  let previousVerb: string | null = null;
1038
1055
  const parts = ordered.map((market) => {
1039
- const reopen = reopenText(market, now, local);
1040
- const verb = market.state === "closed" && reopen?.time ? market.firstTrade ? "reopens" : "opens" : null;
1056
+ const reopen = reopenText(market, now, local, short);
1057
+ const verb = market.state === "closed" && reopen ? market.firstTrade ? "reopens" : "opens" : null;
1041
1058
  const said = (() => {
1042
1059
  switch (market.state) {
1043
1060
  case "open":
@@ -1045,11 +1062,10 @@ function marketsText(markets: readonly VenueMarket[], now: number, short: boolea
1045
1062
  case "after-hours":
1046
1063
  return `${market.market} after hours`;
1047
1064
  case "pre-market":
1048
- return reopen?.time ? `${market.market} pre-market, opens ${reopen.text}` : `${market.market} pre-market`;
1065
+ return reopen ? `${market.market} pre-market, opens ${reopen}` : `${market.market} pre-market`;
1049
1066
  case "closed":
1050
1067
  if (!reopen) return `${market.market} closed`;
1051
- if (!reopen.time) return `${market.market} closed until ${reopen.text}`;
1052
- return `${market.market} ${verb === previousVerb ? "" : `${verb} `}${reopen.text}`;
1068
+ return `${market.market} ${verb === previousVerb ? "" : `${verb} `}${reopen}`;
1053
1069
  default: {
1054
1070
  const _exhaustive: never = market.state;
1055
1071
  return _exhaustive;
@@ -1067,7 +1083,7 @@ interface StatusLineDetail {
1067
1083
  asOf?: "short";
1068
1084
  /** Count stale rows without their total. */
1069
1085
  status?: "short";
1070
- /** `reopens Mon` for `markets closed until Mon`; `none` leaves the market out. */
1086
+ /** `regular opens Mon 13:30 UTC` for `markets closed · regular session opens Mon 13:30 UTC, 09:30 ET`; `none` leaves the market out. */
1071
1087
  market?: "short" | "none";
1072
1088
  /** Leave out the reader's local time beside UTC times. */
1073
1089
  local?: "none";
@@ -1178,7 +1194,7 @@ function shorterSchedules(freshness: ReportFreshness, detail: StatusLineDetail):
1178
1194
 
1179
1195
  /**
1180
1196
  * The plain status line of a capture: the longest of `statusLineVariants`,
1181
- * `Fri 9 Oct close · 15 min delayed · markets closed until Mon` for quotes.
1197
+ * `Fri 9 Oct close · 15 min delayed · markets closed · regular session opens Mon 13:30 UTC, 09:30 ET` for quotes.
1182
1198
  */
1183
1199
  export function formatStatusLine(freshness: ReportFreshness): string {
1184
1200
  return statusLineVariants(freshness)[0]!;
@@ -1318,7 +1334,7 @@ export function captureStatusLine({ report: loaded, selfDated, quoted, rendered
1318
1334
 
1319
1335
  /**
1320
1336
  * The one line every text report ends with, its source then its status line:
1321
- * `Source: Gloom Cloud · Fri 9 Oct close · 15 min delayed · markets closed until Mon`.
1337
+ * `Source: Gloom Cloud · Fri 9 Oct close · 15 min delayed · markets closed · regular session opens Mon 13:30 UTC, 09:30 ET`.
1322
1338
  * Without a dated observation it says when the report was retrieved instead.
1323
1339
  * A line that dates each of its sources names them there, so it is the status
1324
1340
  * line alone: `Sun 11 Oct 2026 · Binance 02:15 · Bybit 02:24 UTC · oldest 9 min · delayed`.
@@ -22,6 +22,8 @@ export interface ReportMarket {
22
22
  reopensAt?: string;
23
23
  /** That open's date at its venue, so a Monday open in Sydney reads Monday. */
24
24
  reopensOn?: string;
25
+ /** The venue's time zone, so the open reads on its own clock too (`09:00 SGT`). */
26
+ reopensTimeZone?: string;
25
27
  /**
26
28
  * The reopen is the week's first trade (a futures venue's Sunday evening),
27
29
  * not a regular session's open: `reopens 22:00 UTC`, never a session's name.
@@ -80,7 +82,7 @@ function venueSession(exchange: string, marketState: string | undefined, now: nu
80
82
  }
81
83
  // A futures venue's weekend gap closes every contract, so it outranks the state a quote stamped before the Friday close.
82
84
  const weekend = futuresWeekendClosure(exchange, now);
83
- if (weekend) return { state: "closed", ...(weekend.reopensAt != null && weekend.reopensOn ? { next: { date: weekend.reopensOn, open: weekend.reopensAt, firstTrade: true as const } } : {}) };
85
+ if (weekend) return { state: "closed", ...(weekend.reopensAt != null && weekend.reopensOn ? { timeZone: weekend.timeZone, next: { date: weekend.reopensOn, open: weekend.reopensAt, firstTrade: true as const } } : {}) };
84
86
  if (marketState === "REGULAR") return { state: "open" };
85
87
  const stated = marketState === "PRE" ? "pre-market" : marketState === "POST" ? "after-hours" : marketState && CLOSED_STATES.has(marketState) ? "closed" : null;
86
88
  if (!calendar) return stated ? { state: stated } : null;
@@ -248,6 +250,7 @@ export function reportVenueMarkets(observations: readonly SessionObservation[],
248
250
  ...(session.next && session.state !== "open" && session.state !== "after-hours" ? {
249
251
  reopensAt: new Date(session.next.open).toISOString(),
250
252
  reopensOn: session.next.date,
253
+ ...(session.timeZone ? { reopensTimeZone: session.timeZone } : {}),
251
254
  ...(session.next.firstTrade ? { firstTrade: true as const } : {}),
252
255
  } : {}),
253
256
  }));
@@ -279,16 +282,22 @@ export function reportMarketSession(
279
282
  const states = new Set([...sessions.values()].map((session) => session.state));
280
283
  if (states.size !== 1 || states.has("always")) return { market: null, closeDate: null, closeMarket: null };
281
284
  const state = [...states][0] as ReportMarketState;
282
- const reopen = state === "closed" || state === "pre-market"
283
- ? [...sessions.values()].reduce<NonNullable<VenueSession["next"]> | null>((first, session) => (
284
- session.next && (!first || session.next.open < first.open) ? session.next : first
285
+ const reopening = state === "closed" || state === "pre-market"
286
+ ? [...sessions.values()].reduce<VenueSession | null>((first, session) => (
287
+ session.next && (!first?.next || session.next.open < first.next.open) ? session : first
285
288
  ), null)
286
289
  : null;
290
+ const reopen = reopening?.next ?? null;
287
291
  const closeDate = (state === "closed" || state === "pre-market") && newest ? closeDateOf(newest.observation, newest.session, now) : null;
288
292
  return {
289
293
  market: {
290
294
  state,
291
- ...(reopen ? { reopensAt: new Date(reopen.open).toISOString(), reopensOn: reopen.date, ...(reopen.firstTrade ? { firstTrade: true as const } : {}) } : {}),
295
+ ...(reopen ? {
296
+ reopensAt: new Date(reopen.open).toISOString(),
297
+ reopensOn: reopen.date,
298
+ ...(reopening?.timeZone ? { reopensTimeZone: reopening.timeZone } : {}),
299
+ ...(reopen.firstTrade ? { firstTrade: true as const } : {}),
300
+ } : {}),
292
301
  },
293
302
  closeDate,
294
303
  closeMarket: closeDate && newest ? closeMarketOf(newest.exchange, newest.session) : null,
@@ -1,8 +1,15 @@
1
1
  import { saveConfig } from "../data/config/store";
2
2
  import { loadCliConfigIfAvailable } from "./context";
3
3
  import { getPluginsDir } from "../plugins/loader";
4
- import { pluginSeedFailure, pluginSeedNotice, samePluginSeedFailure, seedExtractedPlugins } from "../plugins/extracted-plugins";
5
- import { setPluginSeedNotice } from "../plugins/seed-notice";
4
+ import {
5
+ classifyExtractedPlugins,
6
+ pluginSeedFailure,
7
+ pluginSeedNotice,
8
+ seedExtractedPlugins,
9
+ } from "../plugins/extracted-plugins";
10
+ import type { PluginDirectoryInfo, PluginInstallOptions, RegistryListing } from "../plugins/installer";
11
+ import { publishPluginSeedProgress, samePluginSeedFailure, type PluginSeedEntry, type PluginSeedProgress, type PluginSeedRecord } from "../plugins/seed-progress";
12
+ import { INSTALL_TIMED_OUT } from "../plugins/running-installs";
6
13
  import { debugLog } from "../utils/debug-log";
7
14
  import type { AppConfig } from "../types/config";
8
15
  import { withDeadline } from "../utils/async-deadline";
@@ -10,68 +17,174 @@ import { withDeadline } from "../utils/async-deadline";
10
17
  const log = debugLog.createLogger("plugin-seed");
11
18
 
12
19
  /**
13
- * How long a launch waits for the plugin registry before it starts without
14
- * the plugins left to install. A connection that hangs would otherwise hold
15
- * the screen blank: the registry is read first, and git would hang the same
16
- * way after it. They are retried at the next launch.
20
+ * How long the restore waits for the plugin registry before it gives up on
21
+ * the plugins left to install. A connection that hangs there would hang the
22
+ * clones the same way; they are retried at the next launch.
17
23
  */
18
24
  const REGISTRY_WAIT_MS = 8_000;
25
+ /**
26
+ * How long one git command, and one dependency install, of the restore may
27
+ * run. A clone of one of these plugins is a few hundred kilobytes and takes
28
+ * seconds; the largest dependency install is tens of megabytes. One that runs
29
+ * past its limit is stopped, its plugin counts as not installed, the rest
30
+ * wait too (the network is not answering), and the next launch tries again.
31
+ */
32
+ const INSTALL_LIMITS = { gitMs: 60_000, dependenciesMs: 300_000 };
33
+
34
+ /** What the restore runs: git and the installer, injected so a test can stand in for them. */
35
+ export interface PluginSeedDeps {
36
+ gitInstalled(): boolean;
37
+ loadRegistryListings(): Promise<Map<string, RegistryListing>>;
38
+ installListedPlugin(ref: string, options: PluginInstallOptions, listings: ReadonlyMap<string, RegistryListing>): Promise<PluginDirectoryInfo>;
39
+ }
40
+
41
+ // Loaded only when something is left to install: nothing else on the startup path needs it.
42
+ const installerDeps = async (): Promise<PluginSeedDeps> => {
43
+ const installer = await import("../plugins/installer");
44
+ return {
45
+ gitInstalled: installer.gitInstalled,
46
+ loadRegistryListings: installer.loadRegistryListings,
47
+ installListedPlugin: installer.installListedPlugin,
48
+ };
49
+ };
50
+
51
+ export interface PluginSeedLaunch {
52
+ /**
53
+ * The config's record as of the plan, already saved: plugins found settled
54
+ * (installed by hand, switched off before the move), and git missing. A
55
+ * caller that read its config earlier merges it in.
56
+ */
57
+ record: PluginSeedRecord;
58
+ /**
59
+ * Installs what is left, one plugin at a time, publishing each change
60
+ * (seed-progress.ts), and resolves with the record to keep once all have
61
+ * settled. The app records it; nothing here saves it. Null when nothing is
62
+ * left to install.
63
+ */
64
+ start: (() => Promise<PluginSeedRecord>) | null;
65
+ }
66
+
67
+ /** Across every restore this process runs, so a later one's changes are never taken for stale. */
68
+ let progressSeq = 0;
69
+
70
+ function sortedIds(ids: readonly string[]): string[] {
71
+ return [...new Set(ids)].sort();
72
+ }
19
73
 
20
74
  /**
21
- * Reinstalls plugins that moved out of this repository into their own.
22
- *
23
- * Runs before the plugin catalog is read so a restored plugin is available in
24
- * the same session, and never blocks or prints: an offline launch should
25
- * start normally and try again next time. What it could not install becomes
26
- * one notice the app shows once it is up (`setPluginSeedNotice`), saying why
27
- * when git is missing, and `doctor` names the plugins.
75
+ * Plans the restore of plugins that moved out of this repository into their
76
+ * own, before the app starts. Reads the config and the plugins folder only,
77
+ * so it takes milliseconds and works offline: the installs themselves run
78
+ * once the app is drawn (`start`), and the app brings each plugin in as it
79
+ * lands, its saved panes appearing where they were.
28
80
  *
29
- * Returns what it recorded (the seeded ids, and what failed) so a caller that
30
- * already holds the config in memory can adopt it. The desktop loads its
31
- * config before restoring, and without this it would keep an object one
32
- * launch stale and overwrite the record on the next save.
81
+ * Never throws and never prints: the terminal app is about to own the screen.
82
+ * Null on a first run, which has nothing to restore.
33
83
  */
34
- export async function restoreExtractedPlugins(): Promise<Pick<AppConfig, "seededPlugins" | "pluginSeedFailure"> | null> {
84
+ export async function prepareExtractedPluginSeed(deps?: PluginSeedDeps): Promise<PluginSeedLaunch | null> {
35
85
  try {
36
86
  const config = await loadCliConfigIfAvailable();
37
87
  // No data directory yet means a first run: there is nothing to restore.
38
88
  if (!config) return null;
39
- // Through the registry like `gloom install`: the reviewed commit, and
40
- // nothing on a Gloomberb too old for it. That failure is retried at the
41
- // next launch, by when this Gloomberb has usually updated itself. The
42
- // registry is read once, and only when something is left to install.
43
- // Quiet: the terminal app is about to own the screen, and git's or bun's
44
- // output would be left behind in the scrollback.
45
- const { gitInstalled, installListedPlugin, loadRegistryListings } = await import("../plugins/installer");
46
- let listings: ReturnType<typeof loadRegistryListings> | undefined;
47
- let gitMissing: boolean | undefined;
48
- const result = await seedExtractedPlugins(config, async (repo) => {
49
- // Without git every clone fails the same way: no registry read, no attempt.
50
- gitMissing ??= !gitInstalled();
51
- if (gitMissing) throw new Error("git is not installed");
52
- // Only no answer at all stops here: the network hangs, and a clone would
53
- // too, so nothing is tried until the next launch. A registry that fails
54
- // is not reported as silent: the plugins install from their repositories.
55
- listings ??= withDeadline(loadRegistryListings(), REGISTRY_WAIT_MS, "the plugin registry did not answer");
56
- return installListedPlugin(repo, { quiet: true }, await listings);
57
- });
58
- // Recorded, so doctor knows a launch tried, and a failure the next launch
59
- // retries is not announced again while it lasts.
60
- const failure = pluginSeedFailure(result.failed, gitMissing === true);
61
- setPluginSeedNotice(pluginSeedNotice(failure, config.pluginSeedFailure));
62
-
63
- const seeded = [...new Set(result.seeded)].sort();
64
- const existing = [...new Set(config.seededPlugins ?? [])].sort();
65
- const record = { seededPlugins: seeded, pluginSeedFailure: failure };
66
- if (seeded.join() === existing.join() && samePluginSeedFailure(failure, config.pluginSeedFailure)) return record;
89
+ const pluginsDir = getPluginsDir();
90
+ const { pending, settled } = classifyExtractedPlugins(config, pluginsDir);
91
+ const resolved = pending.length > 0 ? deps ?? await installerDeps() : null;
92
+ // Without git every clone fails the same way, so none is tried.
93
+ const gitMissing = !!resolved && !resolved.gitInstalled();
94
+ const record: PluginSeedRecord = {
95
+ seededPlugins: sortedIds([...config.seededPlugins ?? [], ...settled]),
96
+ pluginSeedFailure: pending.length === 0 ? undefined
97
+ : gitMissing ? pluginSeedFailure(pending.map((entry) => entry.id), true) : config.pluginSeedFailure,
98
+ };
99
+ if (record.seededPlugins!.join() !== sortedIds(config.seededPlugins ?? []).join()
100
+ || !samePluginSeedFailure(record.pluginSeedFailure, config.pluginSeedFailure)) {
101
+ await saveConfig({ ...config, ...record });
102
+ }
103
+ if (!resolved) return { record, start: null };
67
104
 
68
- await saveConfig({ ...config, ...record });
69
- if (result.installed.length > 0) {
70
- log.info(`Restored ${result.installed.join(", ")} into ${getPluginsDir()}`);
105
+ const plugins: PluginSeedEntry[] = pending.map((entry) => ({
106
+ id: entry.id,
107
+ name: entry.name,
108
+ state: gitMissing ? "failed" : "installing",
109
+ }));
110
+ const publish = (outcome?: PluginSeedProgress["outcome"]) => publishPluginSeedProgress({
111
+ seq: ++progressSeq,
112
+ plugins: plugins.map((entry) => ({ ...entry })),
113
+ ...(outcome ? { outcome } : {}),
114
+ });
115
+ if (gitMissing) {
116
+ publish({ record, notice: pluginSeedNotice(record.pluginSeedFailure, config.pluginSeedFailure) });
117
+ return { record, start: null };
71
118
  }
72
- return record;
119
+ publish();
120
+ // The plan, not a second look at start: what it said is installing is
121
+ // what gets reported, including a plugin another Gloom installs meanwhile.
122
+ return { record, start: () => installPending(config, { pending, settled }, plugins, publish, resolved) };
73
123
  } catch (error) {
74
- log.error(`Plugin restore skipped: ${error}`);
124
+ log.error(`Plugin restore skipped: ${error instanceof Error ? error.message : String(error)}`);
75
125
  return null;
76
126
  }
77
127
  }
128
+
129
+ async function installPending(
130
+ config: AppConfig,
131
+ plan: ReturnType<typeof classifyExtractedPlugins>,
132
+ plugins: PluginSeedEntry[],
133
+ publish: (outcome?: PluginSeedProgress["outcome"]) => void,
134
+ deps: PluginSeedDeps,
135
+ ): Promise<PluginSeedRecord> {
136
+ let listings: Promise<Map<string, RegistryListing>> | undefined;
137
+ let stalled: unknown = null;
138
+ const result = await seedExtractedPlugins(config, async (repo) => {
139
+ // One install the network never answered: the others would wait as long.
140
+ if (stalled) throw stalled;
141
+ // Through the registry like `gloom install`: the reviewed commit, and
142
+ // nothing on a Gloomberb too old for it. That failure is retried at the
143
+ // next launch, by when this Gloomberb has usually updated itself. Only no
144
+ // answer at all stops every install: the network hangs, and a clone would
145
+ // too. A registry that fails is not silent: the plugins install from
146
+ // their repositories. Quiet: git's or bun's output would land on the
147
+ // terminal app's screen.
148
+ listings ??= withDeadline(deps.loadRegistryListings(), REGISTRY_WAIT_MS, "the plugin registry did not answer");
149
+ try {
150
+ const installed = await deps.installListedPlugin(repo, {
151
+ quiet: true,
152
+ timeouts: INSTALL_LIMITS,
153
+ requireDependencies: true,
154
+ }, await listings);
155
+ return { directory: installed.directory, ...(installed.peers?.length ? { peers: installed.peers } : {}) };
156
+ } catch (error) {
157
+ if ((error as { code?: unknown } | null)?.code === INSTALL_TIMED_OUT) stalled = error;
158
+ throw error;
159
+ }
160
+ }, getPluginsDir(), (id, installed) => {
161
+ const entry = plugins.find((candidate) => candidate.id === id);
162
+ if (!entry) return;
163
+ if (installed) Object.assign(entry, { state: "installed", ...installed });
164
+ else entry.state = "failed";
165
+ publish();
166
+ }, plan);
167
+ // Recorded, so doctor knows a launch tried, and a failure the next launch
168
+ // retries is not announced again while it lasts.
169
+ const failure = pluginSeedFailure(result.failed, false);
170
+ const record: PluginSeedRecord = { seededPlugins: sortedIds(result.seeded), pluginSeedFailure: failure };
171
+ publish({ record, notice: pluginSeedNotice(failure, config.pluginSeedFailure) });
172
+ if (result.installed.length > 0) log.info(`Restored ${result.installed.join(", ")} into ${getPluginsDir()}`);
173
+ return record;
174
+ }
175
+
176
+ /**
177
+ * The whole restore, awaited, with its record saved: for a script that
178
+ * prepares a profile (the startup benchmarks) rather than an app that keeps
179
+ * running while plugins install.
180
+ *
181
+ * @knipignore Imported by the scripts scripts/benchmark-startup.ts and scripts/desktop-measure/measure.ts run with `bun -e`.
182
+ */
183
+ export async function restoreExtractedPlugins(): Promise<PluginSeedRecord | null> {
184
+ const launch = await prepareExtractedPluginSeed();
185
+ if (!launch?.start) return launch?.record ?? null;
186
+ const record = await launch.start();
187
+ const config = await loadCliConfigIfAvailable();
188
+ if (config) await saveConfig({ ...config, ...record });
189
+ return record;
190
+ }
@@ -36,6 +36,13 @@ export interface ChartTableChart {
36
36
  minRows?: number;
37
37
  /** Content with a natural height (a few bars): the band never takes more, the table gets the rest. */
38
38
  maxRows?: number;
39
+ /**
40
+ * The most of the height the zone may take, query bar, figures and chart
41
+ * together, as a share (a third), for a board whose rows are the point and
42
+ * whose chart is context: it goes in the table's `rootAfter`, under the
43
+ * rows, and the chart gives way to a strip below its readable rows.
44
+ */
45
+ maxShare?: number;
39
46
  /** The strip for a custom chart; kit series derive their own. Null keeps no strip. */
40
47
  strip?: ChartStripSpec | null;
41
48
  /** The legend value, in the table's units; the series is passed when several share the chart. */
@@ -180,6 +187,7 @@ export function useChartTableLayout(props: ChartTableHeaderProps): ChartTableLay
180
187
  // Kit charts can draw in fewer rows under a short table; custom ones say their own least.
181
188
  compactRows: chart.render ? undefined : CHART_COMPACT_ROWS,
182
189
  maxRows: chart.maxRows,
190
+ maxShare: chart.maxShare,
183
191
  strip: chart.strip !== null,
184
192
  }
185
193
  : null,
@@ -190,7 +198,8 @@ export function useChartTableLayout(props: ChartTableHeaderProps): ChartTableLay
190
198
  * The header zone of a pane that shows figures, a chart and a table: the
191
199
  * query bar, then the figures, then the chart band, sized by
192
200
  * `chartTableLayout` for the pane's current size. It goes in the table's
193
- * `rootBefore`, and the table takes the rows it leaves.
201
+ * `rootBefore`, and the table takes the rows it leaves; a board whose rows
202
+ * come first puts it in `rootAfter` with the chart's `maxShare`.
194
203
  */
195
204
  export function ChartTableHeader(props: ChartTableHeaderProps) {
196
205
  const { width, query, chart } = props;
@@ -64,9 +64,13 @@ export interface ChartTableLayoutInput {
64
64
  /**
65
65
  * Null when there is nothing to chart. `compactRows` is the least it can
66
66
  * draw in below a short table; `maxRows` caps content with a natural
67
- * height (a few bars), whose rows beyond it go to the table.
67
+ * height (a few bars), whose rows beyond it go to the table; `maxShare`
68
+ * caps the query bar, the figures and the chart together at that share of
69
+ * `height` (a third under a board whose rows come first), the figures
70
+ * keeping one row and then the chart a strip when that is less than they
71
+ * draw in.
68
72
  */
69
- chart: { minRows?: number; compactRows?: number; maxRows?: number; strip?: boolean } | null;
73
+ chart: { minRows?: number; compactRows?: number; maxRows?: number; maxShare?: number; strip?: boolean } | null;
70
74
  }
71
75
 
72
76
  export interface ChartTableLayout {
@@ -151,9 +155,14 @@ function layoutWithFigureRows(input: ChartTableLayoutInput, body: number, figure
151
155
 
152
156
  const minRows = input.chart.minRows ?? CHART_MIN_ROWS;
153
157
  const compactRows = Math.min(minRows, input.chart.compactRows ?? minRows);
154
- const maxRows = input.chart.maxRows ?? Number.POSITIVE_INFINITY;
155
- const room = rest - tableMin;
156
- const spare = rest - tableFit;
158
+ // A share caps the whole zone, the query bar and the figures with the band, so the rows keep the rest.
159
+ const shareRows = input.chart.maxShare != null
160
+ ? Math.max(0, Math.floor(Math.max(0, input.height) * input.chart.maxShare) - (input.queryRows ?? 0) - shownRows)
161
+ : Number.POSITIVE_INFINITY;
162
+ const maxRows = Math.min(input.chart.maxRows ?? Number.POSITIVE_INFINITY, shareRows);
163
+ // A share smaller than the least the chart draws in leaves the rows its band would take to the table.
164
+ const room = Math.min(rest - tableMin, shareRows);
165
+ const spare = Math.min(rest - tableFit, shareRows);
157
166
  const full = (rows: number): ChartTableLayout => ({ figures, figureRows: shownRows, figureMaxLines, mode: "full", chartRows: Math.min(rows, maxRows) });
158
167
  if (room >= minRows) {
159
168
  // With every table row in view beside a readable chart, the chart takes
@@ -64,6 +64,7 @@ export function CommandBarPanel({
64
64
  onThemeCommit,
65
65
  onThemePreview,
66
66
  panelBounds,
67
+ clearBounds = null,
67
68
  queryDisplayWidth,
68
69
  rootGhostSuffix,
69
70
  rootShortcutFeedback,
@@ -145,6 +146,18 @@ export function CommandBarPanel({
145
146
  onOverlayClose();
146
147
  }}
147
148
  >
149
+ {/* The terminal sheet's rows are its own, edge to edge: no piece of a pane shows at its sides. */}
150
+ {clearBounds && (
151
+ <Box
152
+ position="absolute"
153
+ top={clearBounds.y}
154
+ left={clearBounds.x}
155
+ width={clearBounds.width}
156
+ height={clearBounds.height}
157
+ backgroundColor={palette.panelBg}
158
+ zIndex={100}
159
+ />
160
+ )}
148
161
  <Box
149
162
  position="absolute"
150
163
  top={0}
@@ -28,6 +28,12 @@ export interface CommandBarPanelLayout {
28
28
  nativeOccluderRect: LayoutBounds;
29
29
  nativePanelPaddingColumns: number;
30
30
  panelBounds: LayoutBounds;
31
+ /**
32
+ * The rows the terminal sheet clears behind it, relative to its top, edge
33
+ * to edge: a pane cut by the sheet's sides shows only pieces of its words
34
+ * and borders. Null on the desktop, whose sheet is a floating surface.
35
+ */
36
+ clearBounds: LayoutBounds | null;
31
37
  queryDisplayWidth: number;
32
38
  labelWidth: number;
33
39
  trailingWidth: number;
@@ -141,6 +147,7 @@ export function resolveCommandBarPanelLayout({
141
147
  width: barWidth,
142
148
  height: barHeight,
143
149
  },
150
+ clearBounds: nativePaneChrome ? null : { x: 0, y: 0, width: termWidth, height: barHeight },
144
151
  queryDisplayWidth,
145
152
  labelWidth,
146
153
  trailingWidth,
@@ -214,6 +214,7 @@ export function useCommandBarPanelRuntime({
214
214
  onThemeCommit: handleThemeCommit,
215
215
  onThemePreview: applyThemePreview,
216
216
  panelBounds: panelLayout.panelBounds,
217
+ clearBounds: panelLayout.clearBounds,
217
218
  queryDisplayWidth: panelLayout.queryDisplayWidth,
218
219
  rootGhostSuffix,
219
220
  rootShortcutFeedback,
@@ -29,6 +29,8 @@ export interface CommandBarPanelProps {
29
29
  onThemeCommit: (themeId: string) => void;
30
30
  onThemePreview: (themeId: string | null) => void;
31
31
  panelBounds: LayoutBounds;
32
+ /** What the terminal sheet clears behind it (see CommandBarPanelLayout); null on the desktop. */
33
+ clearBounds?: LayoutBounds | null;
32
34
  queryDisplayWidth: number;
33
35
  rootGhostSuffix: string | null;
34
36
  rootShortcutFeedback: string | null;
package/src/i18n/es.ts CHANGED
@@ -1131,6 +1131,9 @@ export const es: Record<string, string> = {
1131
1131
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "No hay cifras para {symbol}: Gloom no lee el sitio de su patrocinador y los conjuntos de datos de folletos y N-PORT de la SEC aún no incluyen ninguna.",
1132
1132
  "est. {range}": "est. {range}",
1133
1133
  "Shares outstanding": "Acciones en circulación",
1134
+ "Management fee": "Comisión de gestión",
1135
+ "Mgmt Fee": "Com. gestión",
1136
+ "Units per {asset}": "Unidades por {asset}",
1134
1137
  "1M flows": "Flujos 1M",
1135
1138
  "Structure": "Estructura",
1136
1139
  "Closed-end fund": "Fondo cerrado",
package/src/i18n/ja.ts CHANGED
@@ -1146,6 +1146,9 @@ export const ja: Record<string, string> = {
1146
1146
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "{symbol} の数値はありません。Gloom はスポンサーのサイトを読み込んでおらず、SEC の目論見書データセットと N-PORT データセットにもまだ掲載がありません。",
1147
1147
  "est. {range}": "推定 {range}",
1148
1148
  "Shares outstanding": "発行済口数",
1149
+ "Management fee": "運用報酬",
1150
+ "Mgmt Fee": "運用報酬",
1151
+ "Units per {asset}": "1 {asset}あたり口数",
1149
1152
  "1M flows": "1か月の資金流出入",
1150
1153
  "Structure": "形態",
1151
1154
  "Closed-end fund": "クローズドエンド型ファンド",
package/src/i18n/ko.ts CHANGED
@@ -1144,6 +1144,9 @@ export const ko: Record<string, string> = {
1144
1144
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "{symbol}의 수치가 없습니다. Gloom은 스폰서의 사이트를 읽지 않으며, SEC의 투자설명서 및 N-PORT 데이터 세트에도 아직 없습니다.",
1145
1145
  "est. {range}": "추정 {range}",
1146
1146
  "Shares outstanding": "발행 주식 수",
1147
+ "Management fee": "운용 보수",
1148
+ "Mgmt Fee": "운용 보수",
1149
+ "Units per {asset}": "{asset}당 좌수",
1147
1150
  "1M flows": "1개월 자금 유출입",
1148
1151
  "Structure": "구조",
1149
1152
  "Closed-end fund": "폐쇄형 펀드",