@gloom-sh/terminal 0.19.6 → 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 (209) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/electrobun-devkit@2.0.5.patch +408 -0
  4. package/src/api-client/bond-trades.ts +59 -0
  5. package/src/api-client/crypto-markets.ts +20 -2
  6. package/src/api-client/data.ts +21 -0
  7. package/src/api-client/fund-facts.ts +23 -1
  8. package/src/api-client/index.ts +2 -0
  9. package/src/api-client/types/account.ts +86 -0
  10. package/src/api-client/types/assist.ts +32 -0
  11. package/src/api-client/types/auth.ts +63 -0
  12. package/src/api-client/types/billing.ts +54 -0
  13. package/src/api-client/types/chat.ts +180 -0
  14. package/src/api-client/types/congress.ts +107 -0
  15. package/src/api-client/types/credit.ts +110 -0
  16. package/src/api-client/types/econ.ts +158 -0
  17. package/src/api-client/types/equity-diagnostic.ts +73 -0
  18. package/src/api-client/types/filings-and-calls.ts +356 -0
  19. package/src/api-client/types/index.ts +25 -0
  20. package/src/api-client/types/jobs.ts +147 -0
  21. package/src/api-client/types/market.ts +122 -0
  22. package/src/api-client/types/news.ts +91 -0
  23. package/src/api-client/types/notes-and-theses.ts +172 -0
  24. package/src/api-client/types/quotes.ts +28 -0
  25. package/src/api-client/types/scanners.ts +125 -0
  26. package/src/api-client/types/screener.ts +65 -0
  27. package/src/api-client/types/search.ts +107 -0
  28. package/src/api-client/types/sync.ts +14 -0
  29. package/src/api-client/types/team-collections.ts +43 -0
  30. package/src/api-client/types/team-views.ts +32 -0
  31. package/src/api-client/types/teams.ts +135 -0
  32. package/src/api-client/types/ticker-data.ts +57 -0
  33. package/src/api-client/types/tweets.ts +59 -0
  34. package/src/api-client/types/world-venues.ts +23 -0
  35. package/src/app/runtime/desktop-deeplink.ts +41 -6
  36. package/src/app/runtime/plugin-seed.ts +119 -0
  37. package/src/app/runtime/startup.ts +45 -9
  38. package/src/app/star-prompt/status-line.tsx +1 -1
  39. package/src/app.tsx +2 -7
  40. package/src/architecture/ui-tokens-allowlist.json +0 -8
  41. package/src/cli/board-coins.ts +38 -5
  42. package/src/cli/commands/crypto-hints.ts +8 -1
  43. package/src/cli/commands/market.ts +29 -26
  44. package/src/cli/commands/overview.ts +13 -6
  45. package/src/cli/commands/ticker.ts +78 -18
  46. package/src/cli/company-name-hint.ts +19 -0
  47. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  48. package/src/cli/entry.ts +10 -4
  49. package/src/cli/glossary.ts +25 -0
  50. package/src/cli/helpers.ts +4 -2
  51. package/src/cli/not-a-ticker.ts +26 -1
  52. package/src/cli/pane-functions/catalog.ts +3 -1
  53. package/src/cli/pane-functions/freshness.ts +45 -29
  54. package/src/cli/pane-functions/market-session.ts +14 -5
  55. package/src/cli/restore-plugins.ts +164 -51
  56. package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
  57. package/src/components/chart-table/header.tsx +10 -1
  58. package/src/components/chart-table/layout.ts +14 -5
  59. package/src/components/command-bar/panel/index.tsx +13 -0
  60. package/src/components/command-bar/panel/layout.ts +7 -0
  61. package/src/components/command-bar/panel/runtime.ts +1 -0
  62. package/src/components/command-bar/panel/types.ts +2 -0
  63. package/src/components/data-table/export.ts +4 -1
  64. package/src/components/layout/detached-pane-shell.tsx +10 -37
  65. package/src/components/layout/double-escape-close.ts +90 -0
  66. package/src/components/layout/header.tsx +3 -2
  67. package/src/components/layout/market-summary.ts +6 -3
  68. package/src/components/layout/pane/footer/index.tsx +2 -6
  69. package/src/components/layout/pane/footer/model.ts +6 -12
  70. package/src/components/layout/shell/active-drag.ts +53 -11
  71. package/src/components/layout/shell/drag/magnets.ts +128 -19
  72. package/src/components/layout/shell/pane/actions.ts +6 -2
  73. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  74. package/src/components/layout/status-bar.tsx +4 -78
  75. package/src/components/layout/status-widget-space.ts +5 -5
  76. package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
  77. package/src/components/ui/data-table/index.tsx +5 -1
  78. package/src/components/ui/data-table/render-cell.ts +19 -0
  79. package/src/components/ui/delayed-mark.tsx +59 -7
  80. package/src/components/ui/icon.tsx +1 -8
  81. package/src/components/ui/menu.tsx +6 -1
  82. package/src/i18n/es.ts +6 -3
  83. package/src/i18n/ja.ts +6 -3
  84. package/src/i18n/ko.ts +6 -3
  85. package/src/i18n/zh-cn.ts +6 -3
  86. package/src/i18n/zh-tw.ts +6 -3
  87. package/src/market-data/fund-facts.ts +7 -1
  88. package/src/market-data/market/change-basis.ts +20 -0
  89. package/src/market-data/market/format.ts +62 -2
  90. package/src/market-data/market/futures-week.ts +3 -1
  91. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  92. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  93. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  94. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  95. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  96. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  97. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  98. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  99. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
  100. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  101. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  102. package/src/plugins/builtin/correlation/compute.ts +8 -2
  103. package/src/plugins/builtin/correlation/headless.ts +10 -9
  104. package/src/plugins/builtin/correlation/history.ts +30 -0
  105. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  106. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  107. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  108. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  109. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  110. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  111. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  112. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  113. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  114. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  115. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  116. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  117. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
  118. package/src/plugins/builtin/equity-screener/headless.ts +33 -1
  119. package/src/plugins/builtin/equity-screener/model.ts +58 -15
  120. package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
  121. package/src/plugins/builtin/executives/format.ts +5 -4
  122. package/src/plugins/builtin/executives/pane.tsx +1 -1
  123. package/src/plugins/builtin/help/index.tsx +55 -1
  124. package/src/plugins/builtin/insider/model.ts +30 -2
  125. package/src/plugins/builtin/jobs/model.ts +2 -2
  126. package/src/plugins/builtin/mna/model.ts +2 -2
  127. package/src/plugins/builtin/notes/files.ts +2 -0
  128. package/src/plugins/builtin/notes/owner.tsx +20 -1
  129. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  130. package/src/plugins/builtin/notes/store.ts +6 -1
  131. package/src/plugins/builtin/perps/headless.ts +8 -2
  132. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  133. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  134. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  135. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  136. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  137. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  138. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  139. package/src/plugins/builtin/sec/headless.ts +30 -1
  140. package/src/plugins/builtin/sec/index.tsx +26 -5
  141. package/src/plugins/builtin/series-inventory.ts +1 -0
  142. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  143. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  144. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  145. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  146. package/src/plugins/builtin/short-interest/model.ts +15 -6
  147. package/src/plugins/builtin/short-interest/types.ts +2 -0
  148. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  149. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  150. package/src/plugins/builtin/ticker-detail/overview/model.ts +19 -9
  151. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  152. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  153. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  154. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  155. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  156. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  157. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  158. package/src/plugins/extracted-plugins.ts +49 -24
  159. package/src/plugins/installer.ts +234 -32
  160. package/src/plugins/plugin-names.ts +11 -2
  161. package/src/plugins/running-installs.ts +34 -0
  162. package/src/plugins/seed-progress.ts +72 -0
  163. package/src/remote/controller.ts +9 -2
  164. package/src/remote/schema.ts +2 -1
  165. package/src/renderers/cloudflare/http-proxy.ts +67 -8
  166. package/src/renderers/cloudflare/proxy-session.ts +1 -1
  167. package/src/renderers/cloudflare/worker.ts +29 -2
  168. package/src/renderers/dom/desktop/icons.tsx +0 -2
  169. package/src/renderers/dom/styles.css +0 -3
  170. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  171. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  172. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  173. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  174. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  175. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  176. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  177. package/src/renderers/electrobun/bun/index.ts +24 -13
  178. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  179. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  180. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
  181. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  182. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  183. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  184. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  185. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  186. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  187. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  188. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  189. package/src/renderers/electrobun/view/backend-rpc.ts +8 -1
  190. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  191. package/src/renderers/electrobun/view/main.tsx +4 -3
  192. package/src/renderers/opentui/start.tsx +3 -0
  193. package/src/sources/gloomberb-cloud/index.ts +5 -7
  194. package/src/sources/provider-router/batches.ts +18 -3
  195. package/src/sources/provider-router/financials.ts +18 -4
  196. package/src/telemetry/stall-reports.ts +21 -4
  197. package/src/types/data-provider.ts +14 -0
  198. package/src/types/financials.ts +15 -3
  199. package/src/types/headless.ts +2 -0
  200. package/src/utils/double-escape-close.ts +38 -16
  201. package/src/utils/format.ts +23 -3
  202. package/src/utils/main-thread-stall.ts +21 -5
  203. package/src/utils/perf-marks.ts +88 -9
  204. package/src/utils/price-earnings.ts +18 -0
  205. package/src/utils/reported-money.ts +9 -2
  206. package/src/utils/sec.ts +34 -3
  207. package/patches/electrobun@1.18.1.patch +0 -633
  208. package/src/api-client/types.ts +0 -2441
  209. package/src/plugins/seed-notice.ts +0 -20
@@ -25,13 +25,60 @@ import { fetchCheckingRedirects, readBytesWithin, type ProxyUpstreamResult } fro
25
25
  import type { ProxySessionGate } from "./proxy-session";
26
26
 
27
27
  const PROXY_METHODS = new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]);
28
+
29
+ /** Requests a caller without a confirmed session may send to one host. */
30
+ export interface SignedOutRoute {
31
+ methods: readonly ("GET" | "HEAD" | "POST")[];
32
+ /** A path and anything under it; one ending in a slash covers only what is under it. */
33
+ path: string;
34
+ }
35
+
36
+ const READ = ["GET", "HEAD"] as const;
37
+
28
38
  /**
29
- * What a caller without a confirmed session may send. The functions that work
30
- * signed out only read (a POST carries a search, as FINRA's tape does), and
31
- * the Origin check is no barrier to a script, so anonymous use stays a
32
- * read-only proxy to the allowlisted hosts.
39
+ * What a caller without a confirmed session may send, host by host: the
40
+ * reads the plugins that work signed out make, and nothing else. The Origin
41
+ * check is no barrier to a script, so anonymous use stays a read-only proxy
42
+ * to those endpoints (a POST carries a search, as FINRA's tape and Pascal's
43
+ * market search do), never to the rest of an exchange's API. Every proxied
44
+ * host is listed, with no routes when it needs a sign-in; a test holds the
45
+ * two lists together.
33
46
  */
34
- const ANONYMOUS_METHODS = new Set(["GET", "HEAD", "POST"]);
47
+ export const SIGNED_OUT_ROUTES: Readonly<Record<string, readonly SignedOutRoute[]>> = {
48
+ "api.crypto.com": [{ methods: READ, path: "/dcm/v1/public/" }],
49
+ "api.elections.kalshi.com": [{ methods: READ, path: "/trade-api/v2/" }],
50
+ "api.fda.gov": [{ methods: READ, path: "/" }],
51
+ "api.gemini.com": [{ methods: READ, path: "/v1/prediction-markets/" }],
52
+ "api.limitless.exchange": [{ methods: READ, path: "/markets/" }],
53
+ "api.votehub.com": [{ methods: READ, path: "/polls" }],
54
+ "clinicaltrials.gov": [{ methods: READ, path: "/api/v2/" }],
55
+ "data.pascal.trade": [
56
+ { methods: READ, path: "/api/v1/markets" },
57
+ { methods: ["POST"], path: "/api/v1/markets/text-search" },
58
+ ],
59
+ "efts.sec.gov": [{ methods: READ, path: "/LATEST/search-index" }],
60
+ "forms13f.com": [{ methods: READ, path: "/api/v1/" }],
61
+ "gateway.polymarket.us": [{ methods: READ, path: "/v1/markets" }],
62
+ "markets.newyorkfed.org": [{ methods: READ, path: "/api/" }],
63
+ "nasdaqtrader.com": [{ methods: READ, path: "/rss.aspx" }],
64
+ "production.dataviz.cnn.io": [{ methods: READ, path: "/index/fearandgreed/" }],
65
+ "services-dynarep.ddwa.finra.org": [{ methods: ["POST"], path: "/public/reporting/v2/data/group/" }],
66
+ };
67
+
68
+ /** Whether a caller without a confirmed session may send `method` to `url`. */
69
+ export function signedOutRouteAllows(
70
+ url: URL,
71
+ method: string,
72
+ routes: Readonly<Record<string, readonly SignedOutRoute[]>> = SIGNED_OUT_ROUTES,
73
+ ): boolean {
74
+ const host = url.hostname.toLowerCase();
75
+ const entry = Object.entries(routes).find(([allowed]) => host === allowed || host.endsWith(`.${allowed}`));
76
+ return !!entry?.[1].some((route) => (route.methods as readonly string[]).includes(method) && (
77
+ route.path.endsWith("/")
78
+ ? url.pathname.startsWith(route.path)
79
+ : url.pathname === route.path || url.pathname.startsWith(`${route.path}/`)
80
+ ));
81
+ }
35
82
  const MAX_BODY_BYTES = 5 * 1024 * 1024;
36
83
  /** Plugin request bodies are small JSON; anything near this is not one. */
37
84
  const MAX_REQUEST_BYTES = 1024 * 1024;
@@ -90,6 +137,13 @@ function upstreamFailure(error: unknown): Response {
90
137
  export interface HttpProxyOptions {
91
138
  /** Rate limits the caller, by user when signed in. One per isolate, so its cache is shared. */
92
139
  sessions: ProxySessionGate;
140
+ /**
141
+ * The limit on signed-out calls across isolates (Cloudflare's rate limiting
142
+ * binding): false once the caller's address, or signed-out callers as a
143
+ * whole, have had their share. Absent where there is none, as in tests.
144
+ */
145
+ signedOutLimit?: (request: Request) => Promise<boolean>;
146
+ signedOutRoutes?: Readonly<Record<string, readonly SignedOutRoute[]>>;
93
147
  /** Reaches the Gloomberb API for that check. */
94
148
  fetchApi: (request: Request) => Promise<Response>;
95
149
  /** Reaches the plugin's target. */
@@ -103,7 +157,7 @@ export interface HttpProxyOptions {
103
157
  * to a third party, which is the opposite of what this exists to do.
104
158
  */
105
159
  export async function handleHttpProxy(request: Request, options: HttpProxyOptions): Promise<Response> {
106
- const { sessions, fetchApi, fetchUpstream = fetch, hosts = PROXY_ALLOWED_HOSTS } = options;
160
+ const { sessions, fetchApi, fetchUpstream = fetch, hosts = PROXY_ALLOWED_HOSTS, signedOutRoutes = SIGNED_OUT_ROUTES } = options;
107
161
  if (request.method !== "POST") {
108
162
  return proxyError("Method not allowed", 405);
109
163
  }
@@ -142,8 +196,13 @@ export async function handleHttpProxy(request: Request, options: HttpProxyOption
142
196
  if (!PROXY_METHODS.has(init.method)) {
143
197
  return proxyError("Method not allowed", 405);
144
198
  }
145
- if (!admission.signedIn && !ANONYMOUS_METHODS.has(init.method)) {
146
- return proxyError("Sign in to Gloom to send this request.", 401);
199
+ if (!admission.signedIn) {
200
+ if (!signedOutRouteAllows(target.url, init.method, signedOutRoutes)) {
201
+ return proxyError("Sign in to Gloom to send this request.", 401);
202
+ }
203
+ if (options.signedOutLimit && !(await options.signedOutLimit(request).catch(() => true))) {
204
+ return proxyError("Too many requests right now. Sign in to Gloom, or try again in a minute.", 429, { "retry-after": "60" });
205
+ }
147
206
  }
148
207
 
149
208
  const signal = AbortSignal.timeout(Math.min(init.timeoutMs ?? DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS));
@@ -106,7 +106,7 @@ export interface ProxySessionGateOptions {
106
106
  * is counted by its /64, the block one subscriber is usually handed, so
107
107
  * rotating through it does not open fresh windows.
108
108
  */
109
- function anonymousRateKey(request: Request): string {
109
+ export function anonymousRateKey(request: Request): string {
110
110
  const ip = request.headers.get("cf-connecting-ip")?.trim().toLowerCase() ?? "";
111
111
  if (!ip.includes(":")) return `ip:${ip || "unknown"}`;
112
112
  const [head = "", tail] = ip.split("::", 2);
@@ -1,13 +1,36 @@
1
1
  import { handleHttpProxy } from "./http-proxy";
2
- import { createProxySessionGate } from "./proxy-session";
2
+ import { anonymousRateKey, createProxySessionGate } from "./proxy-session";
3
3
  import { HTTP_PROXY_PATH, WEB_DIRECT_HOSTS } from "../../utils/plugin-proxy-hosts";
4
4
 
5
5
  interface StaticAssetsBinding {
6
6
  fetch(request: Request): Promise<Response>;
7
7
  }
8
8
 
9
+ /** Cloudflare's rate limiting binding: counts per key, per location, across isolates. */
10
+ interface RateLimitBinding {
11
+ limit(options: { key: string }): Promise<{ success: boolean }>;
12
+ }
13
+
9
14
  export interface WorkerEnv {
10
15
  ASSETS: StaticAssetsBinding;
16
+ /** Signed-out plugin proxy calls per address (wrangler.jsonc `ratelimits`). */
17
+ SIGNED_OUT_PROXY_PER_ADDRESS?: RateLimitBinding;
18
+ /** Signed-out plugin proxy calls from everyone together. */
19
+ SIGNED_OUT_PROXY_TOTAL?: RateLimitBinding;
20
+ }
21
+
22
+ /**
23
+ * The isolate's own window can be dodged by landing on many isolates, so a
24
+ * signed-out call also counts against Cloudflare's limits per address and
25
+ * for every signed-out caller together. Either one spent refuses it.
26
+ */
27
+ export function signedOutProxyLimit(env: WorkerEnv): ((request: Request) => Promise<boolean>) | undefined {
28
+ const { SIGNED_OUT_PROXY_PER_ADDRESS: perAddress, SIGNED_OUT_PROXY_TOTAL: total } = env;
29
+ if (!perAddress && !total) return undefined;
30
+ return async (request) => {
31
+ if (perAddress && !(await perAddress.limit({ key: anonymousRateKey(request) })).success) return false;
32
+ return !total || (await total.limit({ key: "signed-out" })).success;
33
+ };
11
34
  }
12
35
 
13
36
  const SHARE_PATH = /^\/s\/[a-f0-9]{32}\/?$/;
@@ -129,7 +152,11 @@ export async function handleRequest(request: Request, env: WorkerEnv, fetchApi:
129
152
  if (API_PATH.test(url.pathname)) return proxyApi(request, fetchApi);
130
153
  // Before the GET/HEAD gate below, since plugin requests arrive as POST.
131
154
  if (url.pathname === HTTP_PROXY_PATH) {
132
- return withSecurityHeaders(await handleHttpProxy(request, { sessions: proxySessions, fetchApi }));
155
+ return withSecurityHeaders(await handleHttpProxy(request, {
156
+ sessions: proxySessions,
157
+ fetchApi,
158
+ signedOutLimit: signedOutProxyLimit(env),
159
+ }));
133
160
  }
134
161
 
135
162
  if (request.method !== "GET" && request.method !== "HEAD") {
@@ -225,7 +225,6 @@ export function WebIconButton({
225
225
  disabled = false,
226
226
  size = 12,
227
227
  stopPropagation = true,
228
- text,
229
228
  }: IconButtonProps) {
230
229
  return (
231
230
  <button
@@ -262,7 +261,6 @@ export function WebIconButton({
262
261
  }}
263
262
  >
264
263
  <WebIcon name={icon} size={size} />
265
- {text ? <span className="gloom-icon-button-text">{text}</span> : null}
266
264
  </button>
267
265
  );
268
266
  }
@@ -1533,9 +1533,6 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
1533
1533
  .gloom-icon-button:disabled, [data-gloom-role="pane-footer-icon"] { cursor: default; }
1534
1534
  .gloom-icon-button:not(:disabled):hover { background: var(--gloom-hover-fill); color: var(--gloom-text-bright); }
1535
1535
  .gloom-icon-button[aria-pressed="true"] { color: var(--gloom-warning); }
1536
- /* A status's few characters after its icon (a delay's 15m): read without hovering, in the muted tone of the meta text around it. */
1537
- .gloom-icon-button-text, [data-gloom-role="pane-footer-icon-text"] { margin-left: var(--gloom-space-xs); color: var(--gloom-text-muted); }
1538
- .gloom-icon-button:not(:disabled):hover .gloom-icon-button-text { color: inherit; }
1539
1536
  .gloom-qb-view button:disabled { color: var(--gloom-text-muted); opacity: 0.55; cursor: default; }
1540
1537
  [data-gloom-role="field-grid-value"] button,
1541
1538
  [data-gloom-role="field-grid-value"] button > span { justify-content: flex-end !important; text-align: right; padding-inline: 0 !important; }
@@ -11,6 +11,8 @@ import {
11
11
  import { saveConfig } from "../../../../data/config/store";
12
12
  import { pluginAutoUpdateEnabled } from "../../../../plugins/auto-update";
13
13
  import { startNodePluginAutoUpdates } from "../../../../plugins/auto-update-node";
14
+ import { getPluginSeedProgress, subscribePluginSeed } from "../../../../plugins/seed-progress";
15
+ import { stopInstallCommands } from "../../../../plugins/running-installs";
14
16
  import { loadDesktopBackendPlugins } from "../../../../plugins/catalog-backend";
15
17
  import { startRemoteControlServer, type RemoteControlServer } from "../../../../remote/server";
16
18
  import type { RemoteControlRequest, RemoteControlResponse } from "../../../../remote/types";
@@ -46,6 +48,7 @@ import {
46
48
  takeExternalPluginBundles,
47
49
  } from "../external-plugins";
48
50
  import { MAIN_WINDOW_RPC_KEY, paneIdFromDetachedRpcKey } from "../window/focus";
51
+ import { runContextMenusOffThread } from "../window/context-menu-thread";
49
52
  import { measureNativeWindowCalls } from "../window/native-timing";
50
53
  import { createAppWindow } from "../window/create";
51
54
  import { desktopBootFramePath, desktopBootFramePreload, readDesktopBootFrame } from "../window/boot-frame";
@@ -214,8 +217,16 @@ export class DesktopBackend {
214
217
  // before the main window opens, so it runs before the shell's own
215
218
  // handlers wait for the windows to go.
216
219
  Electrobun.events.on("before-quit", () => {
220
+ stopInstallCommands();
217
221
  if (!this.quitting) this.windowController?.flush();
218
222
  });
223
+ // The launch restores plugins that moved into their own repositories in
224
+ // this process, after the services are up; the main window brings each
225
+ // in as it lands. Its init carries where the restore was then.
226
+ subscribePluginSeed(() => {
227
+ const seed = getPluginSeedProgress();
228
+ if (seed) this.readyMainWindowRpc()?.send["plugins.seedProgress"]({ seed });
229
+ });
219
230
  this.windowController.openWindow(MAIN_WINDOW_ID);
220
231
  this.windowController.focus(MAIN_WINDOW_ID);
221
232
  }
@@ -441,6 +452,7 @@ export class DesktopBackend {
441
452
  setStallSink((event) => recordStall("app", event));
442
453
  setStallClocks(createStallClocks());
443
454
  measureNativeWindowCalls();
455
+ runContextMenusOffThread();
444
456
  startMainThreadStallMonitor();
445
457
  }
446
458
  // The native menu shows the same accelerators the keys use, so a rebind
@@ -635,6 +647,8 @@ export class DesktopBackend {
635
647
  quit(): void {
636
648
  if (this.quitting) return;
637
649
  this.quitting = true;
650
+ // Plugin installs still running in the background end with the app.
651
+ stopInstallCommands();
638
652
  // The order a quit had with one window: the other windows close, the
639
653
  // services stop while the main window can still hear from them, and
640
654
  // the main window goes last.
@@ -11,6 +11,7 @@ import { safeExternalUrl } from "../../../../utils/external-url";
11
11
  import { getContextMenuRequestId, normalizeContextMenuItems } from "../context-menu/normalize";
12
12
  import { MAIN_WINDOW_RPC_KEY } from "../window/focus";
13
13
  import { applyDesktopWindowControl } from "../window/controls";
14
+ import { measureNativeCall } from "../window/native-timing";
14
15
  import { startSystemWindowMove, startSystemWindowResize } from "../window/windows-native";
15
16
  import { saveTextFileToDownloads } from "../../../../utils/save-text-file";
16
17
  import { setAppBadge } from "./app-badge";
@@ -138,10 +139,10 @@ export async function handleDesktopHostRequest(
138
139
  throw new Error("host.openExternal requires a URL.");
139
140
  }
140
141
  const externalUrl = safeExternalUrl(request.payload.url);
141
- return externalUrl ? Utils.openExternal(externalUrl) !== false : false;
142
+ return externalUrl ? measureNativeCall("utils.open-external", () => Utils.openExternal(externalUrl)) !== false : false;
142
143
  }
143
144
  case "host.copyText":
144
- Utils.clipboardWriteText(normalizeText(request.payload.text) ?? "");
145
+ measureNativeCall("utils.clipboard-write-text", () => Utils.clipboardWriteText(normalizeText(request.payload.text) ?? ""));
145
146
  return null;
146
147
  case "host.focusWindow": {
147
148
  const windowKey = backend.rpcs.getRpcWindowKey(rpc);
@@ -151,11 +152,11 @@ export async function handleDesktopHostRequest(
151
152
  case "host.copyPngImage": {
152
153
  const pngBase64 = normalizeText(request.payload.pngBase64);
153
154
  if (!pngBase64) throw new Error("host.copyPngImage requires PNG data.");
154
- Utils.clipboardWriteImage(new Uint8Array(Buffer.from(pngBase64, "base64")));
155
+ measureNativeCall("utils.clipboard-write-image", () => Utils.clipboardWriteImage(new Uint8Array(Buffer.from(pngBase64, "base64"))));
155
156
  return null;
156
157
  }
157
158
  case "host.readText":
158
- return Utils.clipboardReadText() ?? "";
159
+ return measureNativeCall("utils.clipboard-read-text", () => Utils.clipboardReadText()) ?? "";
159
160
  case "host.saveTextFile": {
160
161
  if (typeof request.payload.name !== "string" || typeof request.payload.text !== "string") {
161
162
  throw new Error("host.saveTextFile requires a name and text.");
@@ -164,19 +165,25 @@ export async function handleDesktopHostRequest(
164
165
  }
165
166
  case "host.notify":
166
167
  playNotificationSound(normalizeText(request.payload.sound));
167
- Utils.showNotification({
168
+ measureNativeCall("utils.show-notification", () => Utils.showNotification({
168
169
  title: normalizeText(request.payload.title) ?? "Gloom",
169
170
  body: normalizeText(request.payload.body),
170
171
  subtitle: normalizeText(request.payload.subtitle),
171
172
  silent: true,
172
- });
173
+ }));
173
174
  return null;
174
175
  case "host.showContextMenu": {
175
176
  const menu = normalizeContextMenuItems(request.payload.menu);
176
177
  if (menu.length === 0) return false;
177
178
  const requestId = getContextMenuRequestId(menu);
178
179
  if (requestId) backend.trackContextMenuRequest(requestId, rpc);
179
- ContextMenu.showContextMenu(menu as never);
180
+ // On Windows the menu opens on a thread of its own (context-menu-thread.ts)
181
+ // and this returns at once. Where that thread failed, the menu holds
182
+ // this thread until it closes, the freeze the thread removes: a stall.
183
+ // Elsewhere a menu that holds the thread waits on the person.
184
+ measureNativeCall("context-menu.show", () => ContextMenu.showContextMenu(menu as never), {
185
+ waitsOnPerson: process.platform !== "win32",
186
+ });
180
187
  return true;
181
188
  }
182
189
  case "host.saveBootFrame":
@@ -3,8 +3,9 @@ import { makePrivateDirSync } from "../../../../utils/private-files";
3
3
  import { homedir, hostname } from "os";
4
4
  import { getGloomberbDirs } from "../../../../data/config/home";
5
5
  import type { AppServices } from "../../../../core/app-services";
6
- import { restoreExtractedPlugins } from "../../../../cli/restore-plugins";
7
- import { takePluginSeedNotice } from "../../../../plugins/seed-notice";
6
+ import { prepareExtractedPluginSeed } from "../../../../cli/restore-plugins";
7
+ import { getPluginSeedProgress, type PluginSeedRecord } from "../../../../plugins/seed-progress";
8
+ import { logFailure } from "../../../../utils/log-failure";
8
9
  import {
9
10
  getDataDir,
10
11
  initDataDir,
@@ -82,8 +83,9 @@ function buildInitializationPayload(
82
83
  windowKey: string | undefined,
83
84
  ): ElectrobunBackendInit {
84
85
  const mainWindow = windowTarget.windowId === MAIN_WINDOW_RPC_KEY;
85
- // The main window says once what the launch's seed could not install.
86
- const pluginSeedNotice = mainWindow ? takePluginSeedNotice() : null;
86
+ // The main window brings in the plugins the launch restores as they land,
87
+ // and says what it could not install; later changes follow as messages.
88
+ const pluginSeed = mainWindow ? getPluginSeedProgress() : null;
87
89
  // Each full window draws its own tabs; a popped-out pane's draws the main
88
90
  // window's. Numbered like every state sent, so the window's first sync is
89
91
  // merged against it.
@@ -104,7 +106,7 @@ function buildInitializationPayload(
104
106
  paneId: windowTarget.paneId,
105
107
  ...(windowTarget.windowId ? { windowId: windowTarget.windowId, windows: backend.windowInfos() } : {}),
106
108
  ...(mainWindow ? { otherWindowTabs: backend.otherWindowTabsForInit() } : {}),
107
- ...(pluginSeedNotice ? { pluginSeedNotice } : {}),
109
+ ...(pluginSeed ? { pluginSeed } : {}),
108
110
  telemetry: {
109
111
  installId: readOrCreateInstallId(config.dataDir),
110
112
  os: describeNodeOs(),
@@ -126,8 +128,12 @@ async function resolveDesktopDataDir(): Promise<string> {
126
128
  /** The launch work, in order. Injected so a test can watch the order without a data folder. */
127
129
  export interface DesktopLaunchSteps {
128
130
  readConfig(): Promise<AppConfig>;
129
- /** Installs plugins that moved into their own repositories; returns the seed record to merge. */
130
- restorePlugins(): Promise<Partial<AppConfig> | null>;
131
+ /**
132
+ * Plans the restore of plugins that moved into their own repositories:
133
+ * the record to merge into the config, and the installs to start once the
134
+ * services are up. Reads the disk only.
135
+ */
136
+ planPluginRestore(): Promise<{ record: PluginSeedRecord; start: (() => Promise<unknown>) | null } | null>;
131
137
  startServices(config: AppConfig): Promise<unknown>;
132
138
  /** Starts compiling the plugins for the view; not awaited. */
133
139
  prefetchPluginBundles(): void;
@@ -136,11 +142,11 @@ export interface DesktopLaunchSteps {
136
142
  function desktopLaunchSteps(backend: DesktopBackend): DesktopLaunchSteps {
137
143
  return {
138
144
  readConfig: async () => initDataDir(await resolveDesktopDataDir()),
139
- // Restore plugins that moved into their own repositories before the
140
- // catalog is read, the same as the terminal does at startup. Without it a
141
- // desktop-only user silently loses a feature the day it is extracted,
142
- // since nothing else installs it for them.
143
- restorePlugins: restoreExtractedPlugins,
145
+ // Restore plugins that moved into their own repositories, the same as the
146
+ // terminal does at startup. Without it a desktop-only user silently loses
147
+ // a feature the day it is extracted, since nothing else installs it for
148
+ // them.
149
+ planPluginRestore: () => prepareExtractedPluginSeed(),
144
150
  startServices: (config) => backend.startServices(config),
145
151
  prefetchPluginBundles: () => backend.prefetchExternalPluginBundles(),
146
152
  };
@@ -169,9 +175,13 @@ export function startDesktopBackend(
169
175
  if (backend.config && backend.services) return Promise.resolve();
170
176
  const launch = (async () => {
171
177
  const initialConfig = await steps.readConfig();
172
- const seed = await steps.restorePlugins();
173
- await steps.startServices(seed ? { ...initialConfig, ...seed } : initialConfig);
178
+ const seed = await steps.planPluginRestore();
179
+ await steps.startServices(seed ? { ...initialConfig, ...seed.record } : initialConfig);
174
180
  steps.prefetchPluginBundles();
181
+ // In the background: the window draws without them, and the main window
182
+ // brings each in as it lands. Never awaited by a launch, so a clone that
183
+ // hangs holds nothing up.
184
+ void seed?.start?.().catch(logFailure("plugin-seed", "Plugin restore failed"));
175
185
  })();
176
186
  launches.set(backend, launch);
177
187
  const settled = () => {
@@ -0,0 +1,59 @@
1
+ import { lstat, mkdir } from "fs/promises";
2
+ import { dirname, join, resolve } from "path";
3
+ import { logFailure } from "../../../../utils/log-failure";
4
+
5
+ /**
6
+ * Electrobun 2 keeps an install's records (its uninstaller and the manifest
7
+ * of what the app put where) in the app's folder under Application Support,
8
+ * and its launcher writes them at every start until they exist. It never
9
+ * makes that folder: on a Mac the app is copied out of the disk image or by
10
+ * Homebrew, and the folder only appears once an update downloads into it.
11
+ * Until then every start logged "Bootstrap install failed ... FileNotFound".
12
+ * So the app makes the folder and has its bundled uninstaller write the
13
+ * records right away, as the launcher would have.
14
+ */
15
+
16
+ export interface InstallRecordsContext {
17
+ platform: string;
18
+ /** The running Bun: `<bundle>/Contents/MacOS/bun`. */
19
+ execPath: string;
20
+ /** Electrobun's folder for this install, `~/Library/Application Support/<identifier>/<channel>`. */
21
+ channelRoot: () => Promise<string>;
22
+ /** The build's channel; a dev build has no records. */
23
+ channel: () => Promise<string>;
24
+ run?: (command: string[]) => Promise<number>;
25
+ }
26
+
27
+ export type InstallRecordsResult = "none" | "written" | "failed";
28
+
29
+ const MANIFEST = ".electrobun-uninstall.json";
30
+ const MANAGER = "uninstall";
31
+
32
+ async function isFile(path: string): Promise<boolean> {
33
+ return lstat(path).then((stat) => stat.isFile(), () => false);
34
+ }
35
+
36
+ async function runQuietly(command: string[]): Promise<number> {
37
+ const child = Bun.spawn(command, { stdio: ["ignore", "ignore", "pipe"] });
38
+ const [code, stderr] = await Promise.all([child.exited, new Response(child.stderr).text()]);
39
+ if (code !== 0 && stderr.trim()) console.error(`[desktop] ${stderr.trim()}`);
40
+ return code;
41
+ }
42
+
43
+ export async function ensureInstallRecords(context: InstallRecordsContext): Promise<InstallRecordsResult> {
44
+ if (context.platform !== "darwin") return "none";
45
+ try {
46
+ if ((await context.channel()) === "dev") return "none";
47
+ const root = await context.channelRoot();
48
+ if (await isFile(join(root, MANIFEST)) && await isFile(join(root, MANAGER))) return "none";
49
+ const bundledManager = resolve(dirname(context.execPath), "..", "Resources", MANAGER);
50
+ if (!await isFile(bundledManager)) return "none";
51
+ await mkdir(root, { recursive: true });
52
+ const code = await (context.run ?? runQuietly)([bundledManager, "--bootstrap-install", root, "--quiet"]);
53
+ if (code !== 0) throw new Error(`the uninstaller exited with ${code}`);
54
+ return "written";
55
+ } catch (error) {
56
+ logFailure("desktop-install-records", "Could not write the app's install records")(error);
57
+ return "failed";
58
+ }
59
+ }