gloomberb 0.18.2 → 0.18.3

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 (157) hide show
  1. package/package.json +1 -1
  2. package/patches/electrobun@1.18.1.patch +106 -5
  3. package/src/api-client/data.ts +15 -0
  4. package/src/api-client/index.ts +2 -0
  5. package/src/api-client/request.ts +5 -3
  6. package/src/api-client/telemetry.ts +17 -0
  7. package/src/app/global-shortcuts.ts +1 -16
  8. package/src/app/runtime/update.ts +28 -8
  9. package/src/architecture/pane-tabs-allowlist.json +65 -0
  10. package/src/cli/commands/market.ts +73 -33
  11. package/src/cli/commands/ticker.ts +82 -25
  12. package/src/cli/help.ts +1 -1
  13. package/src/cli/index.ts +8 -0
  14. package/src/cli/issuer-membership.ts +103 -0
  15. package/src/cli/listing-arg.ts +15 -2
  16. package/src/cli/name-entries.ts +51 -12
  17. package/src/cli/pane-functions/capabilities.ts +2 -0
  18. package/src/cli/pane-functions/catalog.ts +16 -0
  19. package/src/cli/pane-functions/dom.ts +2 -1
  20. package/src/cli/pane-functions/headless.ts +25 -6
  21. package/src/cli/pane-functions/index.ts +64 -5
  22. package/src/cli/pane-functions/resolver.ts +19 -5
  23. package/src/cli/report-tables.ts +136 -18
  24. package/src/cli/result.ts +12 -4
  25. package/src/cli/symbol-list.ts +47 -11
  26. package/src/components/chart/composite/composite-chart.tsx +14 -5
  27. package/src/components/chart/composite/drawing-store.ts +26 -6
  28. package/src/components/chart/composite/interactions.ts +2 -1
  29. package/src/components/chart/composite/panel-surface.tsx +11 -0
  30. package/src/components/chart/composite/types.ts +6 -0
  31. package/src/components/chart/composite/use-composite-chart-keyboard.ts +1 -1
  32. package/src/components/command-bar/routes/root/command-items.ts +32 -6
  33. package/src/components/data-table/view.tsx +23 -3
  34. package/src/components/index.ts +1 -0
  35. package/src/components/layout/detached-pane-shell.tsx +1 -0
  36. package/src/components/layout/floating-pane.tsx +1 -0
  37. package/src/components/layout/header.tsx +228 -55
  38. package/src/components/layout/pane/header.tsx +10 -3
  39. package/src/components/layout/pane/index.tsx +1 -0
  40. package/src/components/layout/pane/pane-tabs.tsx +9 -1
  41. package/src/components/ui/stat-grid.tsx +28 -3
  42. package/src/components/ui/status.tsx +3 -1
  43. package/src/core/app-services.ts +4 -0
  44. package/src/i18n/es.ts +22 -0
  45. package/src/i18n/ja.ts +22 -0
  46. package/src/i18n/ko.ts +22 -0
  47. package/src/i18n/zh-cn.ts +22 -0
  48. package/src/i18n/zh-tw.ts +22 -0
  49. package/src/plugins/builtin/alerts/alert-engine.ts +3 -1
  50. package/src/plugins/builtin/alerts/events.ts +1 -0
  51. package/src/plugins/builtin/alerts/research-rules.ts +1 -0
  52. package/src/plugins/builtin/analytics/risk-pane.tsx +10 -7
  53. package/src/plugins/builtin/attention/pane.tsx +16 -14
  54. package/src/plugins/builtin/awards/pane.tsx +6 -6
  55. package/src/plugins/builtin/backtest/export.ts +1 -1
  56. package/src/plugins/builtin/broker-trading/dock.tsx +4 -2
  57. package/src/plugins/builtin/broker-trading/pane.tsx +6 -4
  58. package/src/plugins/builtin/broker-trading/ticket.tsx +10 -5
  59. package/src/plugins/builtin/buildout/pane/index.tsx +9 -6
  60. package/src/plugins/builtin/catalysts/client.ts +2 -2
  61. package/src/plugins/builtin/catalysts/pane.tsx +3 -3
  62. package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
  63. package/src/plugins/builtin/commodity-balances/pane.tsx +3 -4
  64. package/src/plugins/builtin/company-attention/app-rank.tsx +4 -5
  65. package/src/plugins/builtin/company-attention/pane.tsx +13 -11
  66. package/src/plugins/builtin/company-kpis/pane.tsx +4 -3
  67. package/src/plugins/builtin/correlation/headless.ts +2 -1
  68. package/src/plugins/builtin/correlation/relationship/model.ts +1 -0
  69. package/src/plugins/builtin/correlation/settings.ts +1 -0
  70. package/src/plugins/builtin/cot/pane.tsx +4 -3
  71. package/src/plugins/builtin/credit-documents/pane.tsx +8 -7
  72. package/src/plugins/builtin/debt-maturities/pane.tsx +4 -3
  73. package/src/plugins/builtin/doe/pane.tsx +1 -1
  74. package/src/plugins/builtin/equity-screener/headless.ts +10 -0
  75. package/src/plugins/builtin/equity-screener/model.ts +28 -0
  76. package/src/plugins/builtin/equity-screener/pane.tsx +105 -98
  77. package/src/plugins/builtin/exposure/pane.tsx +10 -9
  78. package/src/plugins/builtin/gpu/board.tsx +4 -1
  79. package/src/plugins/builtin/gpu/changes.tsx +10 -10
  80. package/src/plugins/builtin/gpu/equities.tsx +4 -1
  81. package/src/plugins/builtin/gpu/history.tsx +4 -2
  82. package/src/plugins/builtin/gpu/pane.tsx +5 -3
  83. package/src/plugins/builtin/holders/client.ts +2 -1
  84. package/src/plugins/builtin/holders/headless.ts +2 -1
  85. package/src/plugins/builtin/holders/thirteenf-match.ts +3 -1
  86. package/src/plugins/builtin/insider/base-values.ts +11 -7
  87. package/src/plugins/builtin/insider/client.ts +3 -0
  88. package/src/plugins/builtin/insider/headless.ts +19 -6
  89. package/src/plugins/builtin/insider/index.tsx +17 -8
  90. package/src/plugins/builtin/insider/issuer.ts +34 -4
  91. package/src/plugins/builtin/insider/signals-client.ts +2 -2
  92. package/src/plugins/builtin/insider/table-model.ts +35 -13
  93. package/src/plugins/builtin/insider/table.tsx +5 -2
  94. package/src/plugins/builtin/iv-history/events.ts +145 -0
  95. package/src/plugins/builtin/iv-history/format.ts +3 -0
  96. package/src/plugins/builtin/iv-history/headless.ts +91 -7
  97. package/src/plugins/builtin/jodi/pane.tsx +4 -4
  98. package/src/plugins/builtin/market-movers/client.ts +4 -3
  99. package/src/plugins/builtin/market-movers/screener.ts +4 -3
  100. package/src/plugins/builtin/notes/cli.ts +1 -1
  101. package/src/plugins/builtin/notes/export.ts +17 -6
  102. package/src/plugins/builtin/notes/files.ts +16 -5
  103. package/src/plugins/builtin/options/enrichment-model.ts +10 -9
  104. package/src/plugins/builtin/options/model-spot.ts +70 -4
  105. package/src/plugins/builtin/options/view.tsx +41 -13
  106. package/src/plugins/builtin/options-calculator/pane.tsx +3 -2
  107. package/src/plugins/builtin/options-positioning/headless.ts +11 -3
  108. package/src/plugins/builtin/options-positioning/model.ts +24 -0
  109. package/src/plugins/builtin/options-positioning/pane.tsx +10 -12
  110. package/src/plugins/builtin/options-scenario/client.ts +19 -1
  111. package/src/plugins/builtin/options-scenario/headless.ts +13 -6
  112. package/src/plugins/builtin/options-scenario/pane.tsx +13 -5
  113. package/src/plugins/builtin/plugin-marketplace/pane.tsx +5 -4
  114. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +8 -5
  115. package/src/plugins/builtin/power/client.ts +2 -2
  116. package/src/plugins/builtin/power/pane.tsx +36 -31
  117. package/src/plugins/builtin/reverse-dcf/client.ts +2 -1
  118. package/src/plugins/builtin/reverse-dcf/model.ts +4 -3
  119. package/src/plugins/builtin/seasonality/client.ts +2 -1
  120. package/src/plugins/builtin/sectors/client.ts +4 -3
  121. package/src/plugins/builtin/shared/cloud-resource.ts +15 -2
  122. package/src/plugins/builtin/shared/research-trading.tsx +2 -0
  123. package/src/plugins/builtin/shared/series-list-detail.tsx +3 -1
  124. package/src/plugins/builtin/shared/volatility/options.ts +2 -1
  125. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  126. package/src/plugins/builtin/vol-surface/client.ts +23 -3
  127. package/src/plugins/builtin/vol-surface/headless.ts +33 -14
  128. package/src/plugins/builtin/vol-surface/model.ts +30 -10
  129. package/src/plugins/builtin/vol-surface/pane.tsx +33 -13
  130. package/src/plugins/builtin/vol-surface/stored.ts +34 -3
  131. package/src/plugins/builtin/vol-surface/tables.ts +14 -0
  132. package/src/renderers/dom/desktop/controls.tsx +1 -1
  133. package/src/renderers/dom/desktop/query-bar.tsx +2 -0
  134. package/src/renderers/dom/host/tabs.tsx +16 -5
  135. package/src/renderers/dom/host/top-surface.ts +127 -0
  136. package/src/renderers/dom/styles.css +39 -0
  137. package/src/renderers/electrobun/bun/core-capabilities.ts +9 -1
  138. package/src/renderers/electrobun/bun/desktop/backend.ts +10 -0
  139. package/src/renderers/electrobun/bun/desktop/update.ts +210 -30
  140. package/src/renderers/electrobun/view/news-source.ts +4 -2
  141. package/src/renderers/electrobun/view/remote/asset-data-client.ts +8 -1
  142. package/src/renderers/opentui/start.tsx +7 -0
  143. package/src/sources/gloomberb-cloud/index.ts +7 -0
  144. package/src/sources/provider-router/index.ts +16 -0
  145. package/src/telemetry/crash-reports.ts +4 -0
  146. package/src/telemetry/update-failures-node.ts +59 -0
  147. package/src/telemetry/update-failures.ts +307 -0
  148. package/src/tickers/company-name-listing.ts +9 -7
  149. package/src/tickers/company-name.ts +43 -0
  150. package/src/tickers/listing-fate.ts +30 -0
  151. package/src/types/data-provider.ts +6 -0
  152. package/src/types/headless.ts +7 -0
  153. package/src/types/issuer-listings.ts +28 -0
  154. package/src/updater/failure.ts +163 -0
  155. package/src/updater/index.ts +87 -23
  156. package/src/utils/currency-pair.ts +26 -0
  157. package/src/utils/sec.ts +68 -0
@@ -1,3 +1,5 @@
1
+ import { readdir, rm } from "fs/promises";
2
+ import { basename, dirname, join } from "path";
1
3
  import type Electrobun from "electrobun/bun";
2
4
  import type { UpdateStatusEntry } from "electrobun/bun";
3
5
  import type { UpdateChannel } from "../../../../types/config";
@@ -15,6 +17,20 @@ import {
15
17
  type GitHubReleaseListing,
16
18
  } from "../../../../updater/github-releases";
17
19
  import { stagedUpdateFitsChannel } from "../../../../updater/channel";
20
+ import {
21
+ classifyUpdateError,
22
+ httpStatusFailureCode,
23
+ type UpdateFailure,
24
+ type UpdateFailureCode,
25
+ } from "../../../../updater/failure";
26
+ import {
27
+ forgetStagedUpdate,
28
+ noteUpdateApplying,
29
+ noteUpdateStaged,
30
+ reportUpdateFailure,
31
+ type UpdateInstallKind,
32
+ } from "../../../../telemetry/update-failures";
33
+ import { logFailure } from "../../../../utils/log-failure";
18
34
  import { compareSemver, isPrereleaseVersion } from "../../../../utils/semver";
19
35
  import { VERSION } from "../../../../version";
20
36
 
@@ -27,7 +43,14 @@ type ElectrobunUpdater = typeof Electrobun.Updater;
27
43
  */
28
44
  export type ElectrobunUpdaterApi = Pick<
29
45
  ElectrobunUpdater,
30
- "checkForUpdate" | "downloadUpdate" | "applyUpdate" | "updateInfo" | "clearStatusHistory" | "onStatusChange" | "setUpdateSource"
46
+ | "checkForUpdate"
47
+ | "downloadUpdate"
48
+ | "applyUpdate"
49
+ | "updateInfo"
50
+ | "clearStatusHistory"
51
+ | "getStatusHistory"
52
+ | "onStatusChange"
53
+ | "setUpdateSource"
31
54
  > & {
32
55
  localInfo: Pick<ElectrobunUpdater["localInfo"], "channel" | "baseUrl">;
33
56
  };
@@ -37,12 +60,111 @@ type ListReleases = () => Promise<GitHubReleaseListing[]>;
37
60
 
38
61
  const NIGHTLY_RELEASE_WINDOW = 30;
39
62
 
63
+ /** A step that failed for a reason known where it was thrown. */
64
+ class DesktopUpdateError extends Error {
65
+ constructor(message: string, readonly code: UpdateFailureCode) {
66
+ super(message);
67
+ this.name = "DesktopUpdateError";
68
+ }
69
+ }
70
+
71
+ /** `<app>.previous` and `<app>.previous-<suffix>`: what an install moves the old app to. */
72
+ function isUpdateAside(entry: string, appName: string): boolean {
73
+ if (!entry.startsWith(`${appName}.previous`)) return false;
74
+ const rest = entry.slice(appName.length + ".previous".length);
75
+ return rest === "" || /^-[0-9a-z]+(?:-\d+)?$/.test(rest);
76
+ }
77
+
78
+ /**
79
+ * Removes the copies of the app an install moved aside and could not remove
80
+ * then (the Electrobun patch's `replaceAppBundle`), from beside the app this
81
+ * process runs from: starting from it means the install that left them worked.
82
+ * macOS keeps the app in its bundle, Linux in `<app data>/app` (`bin/bun`
83
+ * inside it); Windows installs through its own script and leaves none.
84
+ * Resolves to the paths it removed.
85
+ */
86
+ export async function removeUpdateAsides(
87
+ execPath: string = process.execPath,
88
+ platform: string = process.platform,
89
+ ): Promise<string[]> {
90
+ const app = platform === "darwin"
91
+ ? /^(.*?\.app)\/Contents\/MacOS\/[^/]+$/.exec(execPath)?.[1]
92
+ : platform === "linux" && basename(dirname(execPath)) === "bin" ? dirname(dirname(execPath)) : undefined;
93
+ if (!app) return [];
94
+ const folder = dirname(app);
95
+ const removed: string[] = [];
96
+ for (const entry of await readdir(folder).catch(() => [] as string[])) {
97
+ if (!isUpdateAside(entry, basename(app))) continue;
98
+ const path = join(folder, entry);
99
+ // One that still cannot be removed (another user's) is tried again at the next start.
100
+ const done = await rm(path, { recursive: true, force: true }).then(() => true, logFailure("desktop-update", "Could not remove an old copy of the app", false));
101
+ if (done) removed.push(path);
102
+ }
103
+ return removed;
104
+ }
105
+
106
+ /**
107
+ * Where the running app sits, for update failure reports and for what an
108
+ * install that cannot replace it means. Electrobun replaces the macOS bundle
109
+ * the app runs from; on Windows and Linux it always installs into its own
110
+ * folder under the user's app data.
111
+ */
112
+ export function detectDesktopInstallKind(
113
+ execPath: string = process.execPath,
114
+ platform: string = process.platform,
115
+ homeDir: string = process.env.HOME ?? "",
116
+ ): UpdateInstallKind {
117
+ if (platform !== "darwin") return platform === "win32" || platform === "linux" ? "desktop-app-data" : "unknown";
118
+ const bundle = /^(.*?\.app)\/Contents\//.exec(execPath)?.[1];
119
+ if (!bundle) return "unknown";
120
+ if (bundle.includes("/AppTranslocation/")) return "desktop-translocated";
121
+ if (bundle.startsWith("/Volumes/")) return "desktop-volume";
122
+ if (bundle.startsWith("/Applications/") || (homeDir && bundle.startsWith(`${homeDir}/Applications/`))) return "desktop-applications";
123
+ return "desktop-elsewhere";
124
+ }
125
+
126
+ /**
127
+ * On macOS a bundle that cannot be replaced where it runs (a disk image, the
128
+ * read-only copy App Translocation runs, another volume) is fixed by moving
129
+ * the app to Applications, which is what the header then says. Anywhere else
130
+ * a move across disks keeps its own reason: from Applications, moving the app
131
+ * again would not help.
132
+ */
133
+ function installFailureCode(code: UpdateFailureCode, installKind: UpdateInstallKind): UpdateFailureCode {
134
+ const movable = installKind === "desktop-translocated" || installKind === "desktop-volume";
135
+ if (movable && (code === "permission_denied" || code === "read_only" || code === "wrong_location" || code === "cross_device")) return "wrong_location";
136
+ return code;
137
+ }
138
+
139
+ /**
140
+ * Why Electrobun's check failed. It returns one message for every failure, so
141
+ * the status it emitted just before says whether the server answered (with
142
+ * which status) or could not be reached.
143
+ */
144
+ function checkFailureCode(error: string, history: UpdateStatusEntry[]): UpdateFailureCode {
145
+ const last = history.at(-1);
146
+ const status = last?.status === "error" ? /HTTP (\d{3})/.exec(last.message)?.[1] : undefined;
147
+ if (status) return httpStatusFailureCode(Number(status));
148
+ if (/Invalid update\.json/i.test(error)) return "bad_response";
149
+ const code = classifyUpdateError(error);
150
+ // "Failed to fetch update info" with no status before it: the request itself threw.
151
+ return code === "unknown" ? "offline" : code;
152
+ }
153
+
154
+ /** Why a download that Electrobun returned from did not leave an update ready. */
155
+ function downloadFailureCode(error: string, lastErrorStatus: UpdateStatusEntry | null): UpdateFailure {
156
+ if (/zstd/i.test(error)) return { phase: "verify", code: "corrupt" };
157
+ if (lastErrorStatus?.message.startsWith("Failed to download:")) return { phase: "download", code: "http_error" };
158
+ const code = classifyUpdateError(error);
159
+ return { phase: "download", code: code === "unknown" ? "interrupted" : code };
160
+ }
161
+
40
162
  async function listGitHubReleases(): Promise<GitHubReleaseListing[]> {
41
163
  const response = await fetch(`${GITHUB_RELEASES_API_URL}?per_page=${NIGHTLY_RELEASE_WINDOW}`, {
42
164
  headers: { Accept: "application/vnd.github+json" },
43
165
  signal: AbortSignal.timeout(10_000),
44
166
  });
45
- if (!response.ok) throw new Error(`GitHub returned ${response.status}`);
167
+ if (!response.ok) throw new DesktopUpdateError(`GitHub returned ${response.status}`, httpStatusFailureCode(response.status));
46
168
  const data: unknown = await response.json();
47
169
  if (!Array.isArray(data)) throw new Error("GitHub returned an unexpected releases payload");
48
170
  return data as GitHubReleaseListing[];
@@ -88,6 +210,12 @@ function hasDesktopManifest(release: GitHubReleaseListing): boolean {
88
210
  return release.assets?.some((asset) => asset.name === manifest) === true;
89
211
  }
90
212
 
213
+ /**
214
+ * The progress an Electrobun status means. An `error` status is left to the
215
+ * caller: during a download Electrobun emits some it recovers from (a patch
216
+ * that does not apply falls back to the full download), so only the outcome
217
+ * says whether the download failed.
218
+ */
91
219
  function mapDesktopUpdateStatus(entry: UpdateStatusEntry): UpdateProgress | null {
92
220
  const progress = entry.details?.progress;
93
221
  switch (entry.status) {
@@ -120,11 +248,6 @@ function mapDesktopUpdateStatus(entry: UpdateStatusEntry): UpdateProgress | null
120
248
  // once `updateInfo().updateReady` confirms it.
121
249
  case "complete":
122
250
  return { phase: "done", message: "Update installed, restarting..." };
123
- case "error":
124
- return {
125
- phase: "error",
126
- error: entry.details?.errorMessage || entry.message,
127
- };
128
251
  default:
129
252
  return null;
130
253
  }
@@ -133,9 +256,12 @@ function mapDesktopUpdateStatus(entry: UpdateStatusEntry): UpdateProgress | null
133
256
  export function createElectrobunDesktopUpdater(
134
257
  updater: ElectrobunUpdaterApi,
135
258
  {
259
+ installKind = detectDesktopInstallKind(),
136
260
  listReleases = listGitHubReleases,
137
261
  runningVersion = VERSION,
138
262
  }: {
263
+ /** Where the app runs from, which an install that cannot replace it is blamed on. */
264
+ installKind?: UpdateInstallKind;
139
265
  listReleases?: ListReleases;
140
266
  /** The version of the installed app, which a download checks as. */
141
267
  runningVersion?: string;
@@ -152,6 +278,15 @@ export function createElectrobunDesktopUpdater(
152
278
  /** An apply is under way, or finished and the app is quitting. */
153
279
  let applyInProgress = false;
154
280
 
281
+ /** The error progress for a failed step, reported to error tracking on the way. */
282
+ function failed(failure: UpdateFailure, error: string, release?: { version?: string; channel?: UpdateChannel } | null): UpdateProgress {
283
+ reportUpdateFailure(failure, {
284
+ targetVersion: release?.version,
285
+ channel: release?.channel === "nightly" ? "nightly" : "stable",
286
+ });
287
+ return { phase: "error", error, failure };
288
+ }
289
+
155
290
  /**
156
291
  * Forgets a downloaded update `updateChannel` does not allow: a nightly
157
292
  * build staged before the switch back to stable. Electrobun's own ready
@@ -159,7 +294,10 @@ export function createElectrobunDesktopUpdater(
159
294
  * a restart cannot install it, and its files go with the next download.
160
295
  */
161
296
  function dropStagedMisfit(updateChannel: UpdateChannel): void {
162
- if (readyRelease && !applyInProgress && !stagedUpdateFitsChannel(readyRelease, updateChannel)) readyRelease = null;
297
+ if (readyRelease && !applyInProgress && !stagedUpdateFitsChannel(readyRelease, updateChannel)) {
298
+ readyRelease = null;
299
+ forgetStagedUpdate();
300
+ }
163
301
  }
164
302
 
165
303
  async function releaseInfo(updateInfo: { version?: string; hash?: string }, currentVersion: string): Promise<ReleaseInfo> {
@@ -177,6 +315,13 @@ export function createElectrobunDesktopUpdater(
177
315
  };
178
316
  }
179
317
 
318
+ /** Electrobun's check, with the failure it ended in named. */
319
+ async function checkElectrobun(): Promise<Awaited<ReturnType<ElectrobunUpdaterApi["checkForUpdate"]>> | { error: string; code: UpdateFailureCode }> {
320
+ const info = await updater.checkForUpdate();
321
+ if (!info.error) return info;
322
+ return { error: info.error, code: checkFailureCode(info.error, updater.getStatusHistory()) };
323
+ }
324
+
180
325
  /**
181
326
  * Nightly: the highest version among the newest releases that has this
182
327
  * platform's desktop manifest, nightly or stable, fetched from that release's
@@ -192,8 +337,8 @@ export function createElectrobunDesktopUpdater(
192
337
  const baseUrl = githubReleaseDownloadBaseUrl(target.tag_name);
193
338
  updater.setUpdateSource({ channel: filesChannel, baseUrl });
194
339
 
195
- const info = await updater.checkForUpdate();
196
- if (info.error) return { kind: "error", error: info.error };
340
+ const info = await checkElectrobun();
341
+ if ("code" in info) throw new DesktopUpdateError(info.error, info.code);
197
342
  // The same build as the one installed.
198
343
  if (!info.updateAvailable) return { kind: "current" };
199
344
 
@@ -210,7 +355,11 @@ export function createElectrobunDesktopUpdater(
210
355
  };
211
356
  }
212
357
 
213
- async function check(currentVersion: string, updateChannel: UpdateChannel = "stable"): Promise<UpdateCheckResult> {
358
+ /**
359
+ * The check, without reporting: a download runs it first and reports what
360
+ * went wrong itself.
361
+ */
362
+ async function checkQuietly(currentVersion: string, updateChannel: UpdateChannel): Promise<UpdateCheckResult> {
214
363
  dropStagedMisfit(updateChannel);
215
364
  // A downloaded update the channel still allows stays the answer until the
216
365
  // user restarts into it, and asking Electrobun again would discard its
@@ -229,9 +378,9 @@ export function createElectrobunDesktopUpdater(
229
378
 
230
379
  // Stable is the release version.json names, as it always was.
231
380
  updater.setUpdateSource(null);
232
- const info = await updater.checkForUpdate();
233
- if (info.error) {
234
- return { kind: "error", error: info.error };
381
+ const info = await checkElectrobun();
382
+ if ("code" in info) {
383
+ return { kind: "error", error: info.error, failure: { phase: "check", code: info.code } };
235
384
  }
236
385
  if (!info.updateAvailable) {
237
386
  return { kind: "current" };
@@ -247,13 +396,21 @@ export function createElectrobunDesktopUpdater(
247
396
  release: await releaseInfo(info, currentVersion),
248
397
  };
249
398
  } catch (error) {
399
+ const code = error instanceof DesktopUpdateError ? error.code : classifyUpdateError(error);
250
400
  return {
251
401
  kind: "error",
252
402
  error: error instanceof Error ? error.message : "Desktop update check failed",
403
+ failure: { phase: "check", code },
253
404
  };
254
405
  }
255
406
  }
256
407
 
408
+ async function check(currentVersion: string, updateChannel: UpdateChannel = "stable"): Promise<UpdateCheckResult> {
409
+ const result = await checkQuietly(currentVersion, updateChannel);
410
+ if (result.kind === "error" && result.failure) reportUpdateFailure(result.failure, { channel: updateChannel });
411
+ return result;
412
+ }
413
+
257
414
  async function download(
258
415
  release: Pick<ReleaseInfo, "channel">,
259
416
  onProgress: (progress: UpdateProgress) => void,
@@ -277,17 +434,25 @@ export function createElectrobunDesktopUpdater(
277
434
  }
278
435
 
279
436
  downloadInProgress = true;
437
+ /** The last error Electrobun emitted on the way, which may or may not have ended the download. */
438
+ let lastErrorStatus: UpdateStatusEntry | null = null;
439
+ /** The release the download is for, once the check has found it. */
440
+ let target: ReleaseInfo | null = null;
280
441
  updater.clearStatusHistory();
281
442
  updater.onStatusChange((entry) => {
443
+ if (entry.status === "error") {
444
+ lastErrorStatus = entry;
445
+ return;
446
+ }
282
447
  const progress = mapDesktopUpdateStatus(entry);
283
448
  if (progress) onProgress(progress);
284
449
  });
285
450
 
286
451
  try {
287
452
  onProgress({ phase: "downloading", percent: 0 });
288
- const result = await check(runningVersion, updateChannel);
453
+ const result = await checkQuietly(runningVersion, updateChannel);
289
454
  if (result.kind === "error") {
290
- onProgress({ phase: "error", error: result.error });
455
+ onProgress(failed(result.failure ?? { phase: "check", code: "unknown" }, result.error, { channel: updateChannel }));
291
456
  return;
292
457
  }
293
458
  if (result.kind !== "available") {
@@ -297,27 +462,31 @@ export function createElectrobunDesktopUpdater(
297
462
  });
298
463
  return;
299
464
  }
465
+ target = result.release;
300
466
 
301
467
  await updater.downloadUpdate();
302
468
  const updateInfo = updater.updateInfo();
303
469
  if (updateInfo?.error) {
304
- onProgress({ phase: "error", error: updateInfo.error });
470
+ onProgress(failed(downloadFailureCode(updateInfo.error, lastErrorStatus), updateInfo.error, result.release));
305
471
  return;
306
472
  }
307
473
  if (!updateInfo?.updateReady) {
308
- onProgress({ phase: "error", error: "Desktop update did not finish downloading." });
474
+ onProgress(failed({ phase: "download", code: "interrupted" }, "Desktop update did not finish downloading.", result.release));
309
475
  return;
310
476
  }
311
477
 
312
478
  // Downloaded, not installed: applying relaunches the app, and that waits
313
479
  // for the user's explicit request (`apply`).
314
480
  readyRelease = result.release;
481
+ noteUpdateStaged(result.release.version, updateChannel);
315
482
  onProgress({ phase: "ready", canRestart: true });
316
483
  } catch (error) {
317
- onProgress({
318
- phase: "error",
319
- error: error instanceof Error ? error.message : "Desktop update failed",
320
- });
484
+ const code = classifyUpdateError(error);
485
+ onProgress(failed(
486
+ { phase: "download", code: code === "unknown" ? "interrupted" : code },
487
+ error instanceof Error ? error.message : "Desktop update failed",
488
+ { version: target?.version, channel: updateChannel },
489
+ ));
321
490
  } finally {
322
491
  downloadInProgress = false;
323
492
  updater.onStatusChange(null);
@@ -327,11 +496,13 @@ export function createElectrobunDesktopUpdater(
327
496
  async function apply(onProgress: (progress: UpdateProgress) => void): Promise<void> {
328
497
  if (applyInProgress || downloadInProgress) return;
329
498
  if (!readyRelease || !updater.updateInfo()?.updateReady) {
499
+ const missing = readyRelease;
330
500
  readyRelease = null;
331
- onProgress({ phase: "error", error: "The downloaded update is no longer available." });
501
+ onProgress(failed({ phase: "apply", code: "staged_missing" }, "The downloaded update is no longer available.", missing));
332
502
  return;
333
503
  }
334
504
 
505
+ const target = readyRelease;
335
506
  applyInProgress = true;
336
507
  let relaunching = false;
337
508
  let reportedError = false;
@@ -339,7 +510,19 @@ export function createElectrobunDesktopUpdater(
339
510
  if (progress.phase === "error") reportedError = true;
340
511
  onProgress(progress);
341
512
  };
513
+ const installFailed = (error: unknown, message: string) => {
514
+ // Electrobun names the system error in its message ("Failed to replace app: EACCES: ...").
515
+ const code = installFailureCode(classifyUpdateError(error), installKind);
516
+ report(failed({ phase: relaunching ? "relaunch" : "apply", code }, message, target));
517
+ };
518
+ // Kept before Electrobun quits the app, so the next launch can tell whether it took.
519
+ noteUpdateApplying(target.version, target.channel === "nightly" ? "nightly" : "stable");
342
520
  updater.onStatusChange((entry) => {
521
+ if (entry.status === "error") {
522
+ const message = entry.details?.errorMessage || entry.message;
523
+ installFailed(message, message);
524
+ return;
525
+ }
343
526
  if (entry.status === "launching-new-version" || entry.status === "complete") relaunching = true;
344
527
  const progress = mapDesktopUpdateStatus(entry);
345
528
  if (progress) report(progress);
@@ -348,16 +531,13 @@ export function createElectrobunDesktopUpdater(
348
531
  try {
349
532
  report({ phase: "replacing" });
350
533
  await updater.applyUpdate();
351
- // Electrobun returns without a status when it cannot install, for example
352
- // when a newer release replaced the one that was downloaded.
534
+ // Electrobun returns without a status when it finds nothing to install:
535
+ // the downloaded files are gone, or hold no app.
353
536
  if (!relaunching && !reportedError) {
354
- report({ phase: "error", error: "Desktop update could not be installed." });
537
+ report(failed({ phase: "apply", code: "staged_missing" }, "Desktop update could not be installed.", target));
355
538
  }
356
539
  } catch (error) {
357
- report({
358
- phase: "error",
359
- error: error instanceof Error ? error.message : "Desktop update failed",
360
- });
540
+ installFailed(error, error instanceof Error ? error.message : "Desktop update failed");
361
541
  } finally {
362
542
  updater.onStatusChange(null);
363
543
  }
@@ -1,12 +1,13 @@
1
1
  import { apiClient } from "../../../api-client";
2
2
  import { newsProvider, type NewsCapability } from "../../../capabilities";
3
3
  import { cloudNewsParams, mapCloudNewsArticle } from "../../../sources/gloomberb-cloud/news";
4
- import type { NewsArticle, NewsQuery } from "../../../types/news-source";
4
+ import type { NewsArticle, NewsPage, NewsQuery } from "../../../news/types";
5
5
 
6
6
  interface BackendNews {
7
7
  id: string;
8
8
  name: string;
9
9
  getNews(query: NewsQuery): Promise<NewsArticle[]>;
10
+ getNewsPage(query: NewsQuery): Promise<NewsPage>;
10
11
  }
11
12
 
12
13
  type CloudNewsClient = Pick<typeof apiClient, "getCloudNews" | "getCloudNewsStory">;
@@ -33,7 +34,8 @@ export function createDesktopNewsSource(backend: BackendNews, client: CloudNewsC
33
34
  nextCursor: response.nextCursor ?? null,
34
35
  };
35
36
  } catch {
36
- return { articles: await backend.getNews(query), nextCursor: null };
37
+ // The aggregate page keeps RSS failures beside any usable stories.
38
+ return backend.getNewsPage(query);
37
39
  }
38
40
  },
39
41
  fetchNewsStory: async (storyId) => mapCloudNewsArticle(await client.getCloudNewsStory(storyId)),
@@ -1,5 +1,5 @@
1
1
  import type { CapabilityManifest } from "../../../../capabilities";
2
- import type { NewsArticle, NewsQuery } from "../../../../news/types";
2
+ import type { NewsArticle, NewsPage, NewsQuery } from "../../../../news/types";
3
3
  import type { DataProvider } from "../../../../types/data-provider";
4
4
  import type { TickerFinancials } from "../../../../types/financials";
5
5
  import { backendRequest, getElectrobunBackendInitSnapshot, subscribeBackendCapability } from "../backend-rpc";
@@ -14,6 +14,7 @@ const ASSET_DATA_REQUEST_TIMEOUT_MS = 115_000;
14
14
 
15
15
  export type RemoteAssetDataClient = DataProvider & {
16
16
  getNews(query: NewsQuery): Promise<NewsArticle[]>;
17
+ getNewsPage(query: NewsQuery): Promise<NewsPage>;
17
18
  };
18
19
 
19
20
  interface RemoteAssetDataClientBase {
@@ -21,6 +22,7 @@ interface RemoteAssetDataClientBase {
21
22
  name: string;
22
23
  getCachedFinancialsForTargets: NonNullable<DataProvider["getCachedFinancialsForTargets"]>;
23
24
  getNews(query: NewsQuery): Promise<NewsArticle[]>;
25
+ getNewsPage(query: NewsQuery): Promise<NewsPage>;
24
26
  subscribeQuotes: NonNullable<DataProvider["subscribeQuotes"]>;
25
27
  }
26
28
 
@@ -130,6 +132,11 @@ export function createRemoteAssetDataClient(): RemoteAssetDataClient {
130
132
  ? invoke<NewsArticle[]>(NEWS_CAPABILITY_ID, "fetchNews", { query })
131
133
  : Promise.resolve([])
132
134
  ),
135
+ getNewsPage: (query) => (
136
+ hasRendererOperation(newsOperations, "fetchNewsPage")
137
+ ? invoke<NewsPage>(NEWS_CAPABILITY_ID, "fetchNewsPage", { query })
138
+ : Promise.reject(new Error("News is unavailable."))
139
+ ),
133
140
  subscribeQuotes: (targets, onQuote) => {
134
141
  if (!hasRendererOperation(assetDataOperations, "subscribeQuotes")) return () => {};
135
142
  return quoteSubscriptions.subscribe(targets, onQuote);
@@ -37,6 +37,9 @@ import {
37
37
  readOrCreateInstallId,
38
38
  } from "../../telemetry/crash-reports-node";
39
39
  import { currentTelemetryConfig } from "../../telemetry/live-config";
40
+ import { installUpdateFailureReporter } from "../../telemetry/update-failures";
41
+ import { createNodeUpdateFailureHost } from "../../telemetry/update-failures-node";
42
+ import { terminalInstallKind } from "../../updater";
40
43
  import { flushUsageCounts, installUsageCounter, usageCountsEnabled } from "../../telemetry/usage-counts";
41
44
  import { attentionCountsEnabled, installAttentionCounter } from "../../telemetry/attention-counts";
42
45
  import { starPromptEnvironmentAllows } from "../../app/star-prompt/model";
@@ -117,6 +120,10 @@ export async function startOpenTuiApp({ externalPlugins, cliLaunchRequest }: Sta
117
120
  surface: "terminal",
118
121
  getConfig: () => ({ dataDir: config.dataDir, telemetry: currentTelemetryConfig(config)?.telemetry }),
119
122
  }));
123
+ installUpdateFailureReporter(createNodeUpdateFailureHost({
124
+ installKind: terminalInstallKind(),
125
+ getDataDir: () => config.dataDir,
126
+ }));
120
127
  installUsageCounter({
121
128
  surface: "terminal",
122
129
  os: describeNodeOs(),
@@ -30,6 +30,7 @@ import { parseHistorySession } from "../../market-data/history-session";
30
30
  import { quoteMetadataFromQuote, quoteMetadataMatchesTarget } from "../../market-data/quotes/metadata";
31
31
  import type { InstrumentSearchResult } from "../../types/instrument";
32
32
  import type { TickerChanges } from "../../types/ticker-changes";
33
+ import type { IssuerListings } from "../../types/issuer-listings";
33
34
  import {
34
35
  apiClient,
35
36
  type CloudAnalystResearchPayload,
@@ -718,6 +719,12 @@ export class GloomberbCloudProvider implements AssetDataProvider {
718
719
  return cloudTickerChangesBatch(symbols, options);
719
720
  }
720
721
 
722
+ async getIssuerListings(symbol: string, exchange = "", options: { signal?: AbortSignal } = {}): Promise<IssuerListings | null> {
723
+ const response = await apiClient.getCloudIssuerListings(symbol, exchange, options);
724
+ // "empty" is an answer: the service holds no company for the listing.
725
+ return response.status === "success" || response.status === "partial" ? response.data : null;
726
+ }
727
+
721
728
  async searchBatch(queries: string[], options: { limit?: number; signal?: AbortSignal } = {}): Promise<Map<string, InstrumentSearchResult[]> | null> {
722
729
  const answers = await cloudSearchBatch(queries, options);
723
730
  if (!answers) return null;
@@ -26,6 +26,7 @@ import { mergeQuoteMetadata, quoteMetadataFromQuote, quoteMetadataMatchesTarget
26
26
  import type { NewsArticle, NewsQuery } from "../../news/types";
27
27
  import type { BrokerContractRef, InstrumentSearchResult } from "../../types/instrument";
28
28
  import type { TickerChanges } from "../../types/ticker-changes";
29
+ import type { IssuerListings } from "../../types/issuer-listings";
29
30
  import type { TimeRange } from "../../time-series/range";
30
31
  import type { ChartResolutionSupport, ManualChartResolution } from "../../time-series/resolution";
31
32
  import { debugLog } from "../../utils/debug-log";
@@ -317,6 +318,21 @@ export class AssetDataRouter implements DataProvider {
317
318
  return null;
318
319
  }
319
320
 
321
+ /** The first source that holds the company's listings; one that fails is passed over. */
322
+ async getIssuerListings(symbol: string, exchange?: string, options?: { signal?: AbortSignal }): Promise<IssuerListings | null> {
323
+ for (const provider of this.providersInPriorityOrder()) {
324
+ if (!provider.getIssuerListings) continue;
325
+ try {
326
+ const listings = await provider.getIssuerListings(symbol, exchange, options);
327
+ if (listings) return listings;
328
+ } catch (error) {
329
+ if (options?.signal?.aborted) return null;
330
+ logFailure("sources.provider-router.index", "Issuer listings failed")(error);
331
+ }
332
+ }
333
+ return null;
334
+ }
335
+
320
336
  async getEarningsCalendar(symbols: string[], context?: MarketDataRequestContext) {
321
337
  return this.supplementalRoutes.getEarningsCalendar(symbols, context);
322
338
  }
@@ -5,6 +5,7 @@ import {
5
5
  type CrashReportKind,
6
6
  type CrashReportSurface,
7
7
  type CrashReportsPayload,
8
+ type UpdateFailureReport,
8
9
  } from "../api-client";
9
10
  import type { TelemetryConfig } from "../types/config";
10
11
  import { isSleepRpcTimeout } from "../utils/rpc-timeout-error";
@@ -68,6 +69,8 @@ export interface CrashReportContext {
68
69
  pane?: string;
69
70
  /** React's component stack for a render crash; appended to the stack. */
70
71
  componentStack?: string | null;
72
+ /** A failed update step (update-failures.ts), sent as it is: it holds no free text. */
73
+ update?: UpdateFailureReport;
71
74
  }
72
75
 
73
76
  interface PendingError {
@@ -167,6 +170,7 @@ function toReportError(error: unknown, context: CrashReportContext): PendingErro
167
170
  ...(stack ? { stack } : {}),
168
171
  ...(context.plugin ? { plugin: clip(context.plugin, MAX_LABEL_LENGTH) } : {}),
169
172
  ...(context.pane ? { pane: clip(context.pane, MAX_LABEL_LENGTH) } : {}),
173
+ ...(context.update ? { update: context.update } : {}),
170
174
  },
171
175
  };
172
176
  }
@@ -0,0 +1,59 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
2
+ import { join } from "path";
3
+ import type { UpdateChannel } from "../types/config";
4
+ import type {
5
+ UpdateAttempt,
6
+ UpdateFailureReporterHost,
7
+ UpdateInstallKind,
8
+ UpdateReportState,
9
+ } from "./update-failures";
10
+
11
+ /** Next to config.json: when each update failure was last reported, and the last update attempt. */
12
+ const STATE_FILE = "update-reports.json";
13
+
14
+ function readAttempt(value: unknown): UpdateAttempt | undefined {
15
+ if (!value || typeof value !== "object") return undefined;
16
+ const { from, to, channel, at } = value as Record<string, unknown>;
17
+ if (typeof from !== "string" || typeof to !== "string" || typeof at !== "number" || !Number.isFinite(at)) return undefined;
18
+ return { from, to, channel: (channel === "nightly" ? "nightly" : "stable") satisfies UpdateChannel, at };
19
+ }
20
+
21
+ /** The saved state, keeping only entries of the right shape. */
22
+ function parseUpdateReportState(text: string): UpdateReportState {
23
+ const parsed: unknown = JSON.parse(text);
24
+ const record = parsed && typeof parsed === "object" ? parsed as Record<string, unknown> : {};
25
+ const sent: Record<string, number> = {};
26
+ if (record.sent && typeof record.sent === "object") {
27
+ for (const [key, at] of Object.entries(record.sent as Record<string, unknown>)) {
28
+ if (typeof at === "number" && Number.isFinite(at)) sent[key] = at;
29
+ }
30
+ }
31
+ const staged = readAttempt(record.staged);
32
+ const applying = readAttempt(record.applying);
33
+ return { sent, ...(staged ? { staged } : {}), ...(applying ? { applying } : {}) };
34
+ }
35
+
36
+ /** The update failure reporter for a Bun process (the terminal app, the desktop app's main process). */
37
+ export function createNodeUpdateFailureHost(options: {
38
+ installKind: UpdateInstallKind;
39
+ /** The profile's data folder, or null before the config is loaded. */
40
+ getDataDir(): string | null;
41
+ }): UpdateFailureReporterHost {
42
+ return {
43
+ installKind: options.installKind,
44
+ platform: process.platform,
45
+ arch: process.arch,
46
+ load: () => {
47
+ const dir = options.getDataDir();
48
+ const path = dir ? join(dir, STATE_FILE) : null;
49
+ if (!path || !existsSync(path)) return { sent: {} };
50
+ return parseUpdateReportState(readFileSync(path, "utf-8"));
51
+ },
52
+ save: (state) => {
53
+ const dir = options.getDataDir();
54
+ if (!dir) return;
55
+ mkdirSync(dir, { recursive: true });
56
+ writeFileSync(join(dir, STATE_FILE), JSON.stringify(state), "utf-8");
57
+ },
58
+ };
59
+ }