@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
@@ -20,6 +20,9 @@ import { ShortcutTable, type ShortcutTableEntry } from "./shortcut-table";
20
20
  import { resolveCommandShortcuts, resolveWindowTemplates } from "./shortcut-model";
21
21
  import { badgeColumnWidth } from "./table-cells";
22
22
  import { logFailure } from "../../../utils/log-failure";
23
+ import { VERSION } from "../../../version";
24
+ import { getCurrentPluginTarget } from "../../current-target";
25
+ import { openUrl } from "../../../components/ui/external-link";
23
26
 
24
27
  const HELP_TABS = [
25
28
  { label: "Basics", value: "basics" },
@@ -32,6 +35,12 @@ const HELP_TABS = [
32
35
 
33
36
  type HelpTabId = typeof HELP_TABS[number]["value"];
34
37
  const GLOOMBERB_ISSUES_URL = "https://github.com/gloom-sh/gloomberb/issues";
38
+ /**
39
+ * Where the web app sends people who want the installed app. The route picks
40
+ * the installer for the visitor's OS, so one link serves every platform.
41
+ */
42
+ const DESKTOP_DOWNLOAD_URL = "https://gloom.sh/download/desktop";
43
+ const DESKTOP_DOWNLOAD_DESCRIPTION = "Get Gloom for Mac or Windows";
35
44
 
36
45
  function entry(id: string, badges: string[], description: string): ShortcutTableEntry {
37
46
  return { id, badges, description };
@@ -133,6 +142,14 @@ function HelpPane({ focused, width, height }: PaneProps) {
133
142
  void rendererHost.openExternal(GLOOMBERB_ISSUES_URL);
134
143
  }, [rendererHost]);
135
144
 
145
+ const openChangelog = useCallback(() => {
146
+ createPaneFromTemplate("changelog-pane", { values: { version: VERSION } });
147
+ }, [createPaneFromTemplate]);
148
+
149
+ const openDesktopDownload = useCallback(() => {
150
+ void rendererHost.openExternal(DESKTOP_DOWNLOAD_URL);
151
+ }, [rendererHost]);
152
+
136
153
  // Each tab's actions. `l` moves between tabs, so layout actions take `a`.
137
154
  const tabHints = useMemo<PaneHint[]>(() => {
138
155
  if (activeTabId === "basics") {
@@ -198,6 +215,29 @@ function HelpPane({ focused, width, height }: PaneProps) {
198
215
  ].filter((item) => hasCode(item.badges[0]!)),
199
216
  }], [hasCode]);
200
217
 
218
+ // The app's version and, in the browser, the installed app: kept out of the
219
+ // status bar, which holds only what a new visitor needs.
220
+ const aboutRows = useMemo(() => [
221
+ ...(hasCode("CHG")
222
+ ? [{ ...entry("about-changelog", ["CHG"], tf("What's new in v{version}", { version: VERSION })), run: openChangelog }]
223
+ : []),
224
+ ...(getCurrentPluginTarget() === "web"
225
+ ? [{ ...entry("about-desktop", [], t(DESKTOP_DOWNLOAD_DESCRIPTION)), run: openDesktopDownload }]
226
+ : []),
227
+ ], [hasCode, openChangelog, openDesktopDownload]);
228
+ const aboutSections = useMemo<Array<TableSection<ShortcutTableEntry>>>(
229
+ () => aboutRows.length > 0 ? [{ label: "About", items: aboutRows }] : [],
230
+ [aboutRows],
231
+ );
232
+ // The keyboard reaches them from the pane menu, as it does Try These.
233
+ usePaneMenuItems("help:about", () => activeTabId === "basics"
234
+ ? aboutRows.map((row) => ({
235
+ id: row.id,
236
+ label: row.id === "about-desktop" ? t("Download desktop app") : `${row.description} (CHG)`,
237
+ onSelect: row.run,
238
+ }))
239
+ : null, [activeTabId, aboutRows]);
240
+
201
241
  const referenceSections = useMemo<Array<TableSection<ShortcutTableEntry>>>(() => [
202
242
  {
203
243
  label: "Command Bar",
@@ -371,7 +411,7 @@ function HelpPane({ focused, width, height }: PaneProps) {
371
411
  </Text>
372
412
 
373
413
  <Box marginTop={1}>
374
- <ShortcutTable sections={startSections} width={bodyWidth} keyWidth={keyColumnWidth} />
414
+ <ShortcutTable sections={[...startSections, ...aboutSections]} width={bodyWidth} keyWidth={keyColumnWidth} />
375
415
  </Box>
376
416
  </>
377
417
  );
@@ -420,6 +460,20 @@ function HelpPane({ focused, width, height }: PaneProps) {
420
460
  }
421
461
 
422
462
  export const helpModule: PluginModule = {
463
+ setup(ctx) {
464
+ // The browser's way to the installed app; the desktop app and the terminal are installed already.
465
+ ctx.registerCommand({
466
+ id: "download-desktop-app",
467
+ label: "Download Desktop App",
468
+ description: DESKTOP_DOWNLOAD_DESCRIPTION,
469
+ keywords: ["desktop", "download", "install", "app", "mac", "macos", "windows"],
470
+ category: "config",
471
+ hidden: () => getCurrentPluginTarget() !== "web",
472
+ execute: () => {
473
+ openUrl(DESKTOP_DOWNLOAD_URL);
474
+ },
475
+ });
476
+ },
423
477
  panes: [
424
478
  {
425
479
  id: "help",
@@ -118,7 +118,26 @@ export interface InsiderSummaryFigures {
118
118
  incomplete: boolean;
119
119
  }
120
120
 
121
- /** Totals of the loaded non-derivative buys and sales in the last 90 days, by security and side. */
121
+ /** Words a filer adds or leaves out without naming another class: "Common Stock" and "Common" are one. */
122
+ const SECURITY_FILLER_WORDS = new Set(["stock", "stocks", "share", "shares"]);
123
+
124
+ /**
125
+ * One key for every spelling filers give the same class of security: "Common
126
+ * Stock", "Common", "COMMON STOCK, $0.001 PAR VALUE" and "Common Stock, par
127
+ * value $.01 per share" are one class, and so are "Class A Common Stock" and
128
+ * "Common Stock, Class A". Class A and Class B, common and preferred, Series A
129
+ * and Series B stay apart.
130
+ */
131
+ export function securityClassKey(title: string): string {
132
+ const words = title.toLowerCase()
133
+ // A par or nominal value tail names the same shares: ", par value $0.0001 per share", "$.01 par value".
134
+ .replace(/(?:[$€£]?\s*\d*\.?\d+\s*)?\b(?:par(?:\s+value)?|nominal\s+value|stated\s+value)\b.*$/, " ")
135
+ .split(/[^a-z0-9]+/)
136
+ .filter((word) => word && !SECURITY_FILLER_WORDS.has(word));
137
+ return words.length ? [...new Set(words)].sort().join(" ") : title.trim().toLowerCase();
138
+ }
139
+
140
+ /** Totals of the loaded non-derivative buys and sales in the last 90 days, by class of security and side. */
122
141
  export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[], now = Date.now(), context: readonly ParsedInsiderFiling[] = parsed): InsiderSummaryFigures | null {
123
142
  if (parsed.some(({ isLoading }) => isLoading)) return null;
124
143
  const amendments = buildInsiderAmendmentScopes(context);
@@ -129,6 +148,8 @@ export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[
129
148
  });
130
149
  const cutoff = now - NINETY_DAYS_MS;
131
150
  const totals = new Map<string, InsiderSideTotal>();
151
+ // Shares under each spelling of a class, so a total is named the way most of its shares were filed.
152
+ const spellings = new Map<string, Map<string, number>>();
132
153
  for (const entry of parsed) {
133
154
  const { transaction } = entry;
134
155
  if (!transaction || transaction.isDerivative || transaction.shares == null || !transaction.securityTitle) continue;
@@ -136,13 +157,20 @@ export function buildInsiderSummaryFigures(parsed: readonly ParsedInsiderFiling[
136
157
  if (date == null || !Number.isFinite(date) || date < cutoff || date > now) continue;
137
158
  if (transaction.transactionType !== "P" && transaction.transactionType !== "S") continue;
138
159
  const security = transaction.securityTitle;
139
- const key = `${security}:${transaction.transactionType}`;
160
+ const key = `${securityClassKey(security)}:${transaction.transactionType}`;
140
161
  const total = totals.get(key) ?? { security, side: transaction.transactionType, shares: 0, value: 0, knownValue: true, unreconciled: false };
141
162
  total.unreconciled ||= affectingInsiderAmendments(entry, amendments).length > 0;
142
163
  total.shares += transaction.shares;
143
164
  total.knownValue &&= transaction.totalValue != null;
144
165
  total.value += transaction.totalValue ?? 0;
145
166
  totals.set(key, total);
167
+ const filed = spellings.get(key) ?? new Map<string, number>();
168
+ filed.set(security, (filed.get(security) ?? 0) + transaction.shares);
169
+ spellings.set(key, filed);
170
+ }
171
+ for (const [key, total] of totals) {
172
+ const filed = [...spellings.get(key)!];
173
+ total.security = filed.reduce((best, entry) => (entry[1] > best[1] ? entry : best), filed[0]!)[0];
146
174
  }
147
175
  return { totals: [...totals.values()], incomplete };
148
176
  }
@@ -266,10 +266,10 @@ export function buildMoverRows(movers: readonly CloudJobsMoverPayload[]): MoverR
266
266
  mover,
267
267
  ticker: mover.ticker,
268
268
  company: mover.companyName ?? "",
269
- open: formatCompact(mover.openCount),
269
+ open: formatCompact(mover.openCount, { fixedDecimals: true }),
270
270
  change: mover.change30d ? formatChange(mover.change30d) : "",
271
271
  changeValue: mover.change30d?.percent ?? mover.change30d?.count ?? null,
272
- posted30d: mover.posted30d != null ? formatCompact(mover.posted30d) : "",
272
+ posted30d: mover.posted30d != null ? formatCompact(mover.posted30d, { fixedDecimals: true }) : "",
273
273
  posted30dValue: mover.posted30d ?? null,
274
274
  new7d: mover.new7d > 0 ? String(mover.new7d) : "",
275
275
  function: functionLabel(mover.topFunction),
@@ -21,10 +21,10 @@ export function formatPerShare(amount: number, currency: string | null, maxDigit
21
21
  return sign ? `${sign}${fixed}` : `${code} ${fixed}`;
22
22
  }
23
23
 
24
- /** A headline amount: "$1.8B", "€420M", "GBP 1.2B". */
24
+ /** A headline amount: "$1.8B", "€420M", "GBP 1.2B"; "$1.80B" in a table column. */
25
25
  export function formatDealValue(value: number | null, currency: string | null): string {
26
26
  if (value == null || !Number.isFinite(value) || value <= 0) return MISSING;
27
- const compact = formatCompact(value, { fixedDecimals: false });
27
+ const compact = formatCompact(value);
28
28
  const code = currency?.trim().toUpperCase() ?? "";
29
29
  if (!code) return compact;
30
30
  const sign = CURRENCY_SIGNS[code];
@@ -5,6 +5,8 @@ export interface QuickNoteEntry {
5
5
  id: string;
6
6
  title: string;
7
7
  updatedAt?: number;
8
+ /** Who wrote a cloud note, when the server says; never saved to disk. */
9
+ createdBy?: string | null;
8
10
  }
9
11
 
10
12
  /** A stored note: `key` is what `load`/`save` take, not the file path. */
@@ -6,7 +6,7 @@ import { QueryBar } from "../../../components/ui/query-bar";
6
6
  import { Box } from "../../../ui";
7
7
  import type { DialogApi, PromptContext } from "../../../ui/dialog";
8
8
  import { colors } from "../../../theme/colors";
9
- import { teamAccentHex, teamPrefix } from "../../../team/model";
9
+ import { canManageTeam, teamAccentHex, teamPrefix } from "../../../team/model";
10
10
  import { teamStore } from "../../../team/store";
11
11
  import { logFailure } from "../../../utils/log-failure";
12
12
  import { NoteConflictError, type NoteOwner, noteOwnerKey } from "./store";
@@ -18,6 +18,25 @@ export function useNoteTeams(): TeamSummary[] {
18
18
  ).teams;
19
19
  }
20
20
 
21
+ /**
22
+ * Whether the server lets me delete a note: any of mine, and a team note I
23
+ * wrote or whose team I run. A team note without an author is one I just
24
+ * added, or one from a server that lets any member delete.
25
+ */
26
+ export function mayDeleteNote(
27
+ note: { owner: NoteOwner; createdBy?: string | null },
28
+ teams: readonly TeamSummary[],
29
+ selfUserId: string | null,
30
+ ): boolean {
31
+ const { owner } = note;
32
+ if (owner.kind === "user" || note.createdBy === undefined) return true;
33
+ if (selfUserId !== null && note.createdBy === selfUserId) return true;
34
+ return canManageTeam(teams.find((team) => team.id === owner.teamId)?.role);
35
+ }
36
+
37
+ /** Why a teammate's note offers no delete. */
38
+ export const NOT_YOUR_NOTE = "Only its author or a team admin can delete this note.";
39
+
21
40
  /** The owner a new note defaults to: the focused team, else me. */
22
41
  export function defaultNoteOwner(): NoteOwner {
23
42
  const teamId = teamStore.getDefaultTeamId();
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { apiClient } from "../../../api-client";
2
3
  import { Box, Text, type InputRenderable, type TextareaRenderable } from "../../../ui";
3
4
  import { useShortcut } from "../../../react/input";
4
5
  import { isPlainKey } from "../../../utils/keyboard";
@@ -17,7 +18,15 @@ import {
17
18
  generateNoteId,
18
19
  type QuickNoteEntry,
19
20
  } from "./model";
20
- import { chooseNoteOwner, ownerColor, ownerLabel, resolveNoteConflict, useNoteTeams } from "./owner";
21
+ import {
22
+ chooseNoteOwner,
23
+ mayDeleteNote,
24
+ NOT_YOUR_NOTE,
25
+ ownerColor,
26
+ ownerLabel,
27
+ resolveNoteConflict,
28
+ useNoteTeams,
29
+ } from "./owner";
21
30
  import { NoteConflictError, type NoteOwner, noteOwnerKey, type NotesStoreRegistry } from "./store";
22
31
  import { useSyncedText } from "./text-state";
23
32
 
@@ -63,6 +72,10 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
63
72
  const unreadableIndexRef = useRef(new Set<string>());
64
73
  const [indexError, setIndexError] = useState<{ message: string; owners: NoteOwner[] } | null>(null);
65
74
  const activeTab = tabs.find((tab) => tab.id === activeTabId);
75
+ // Closing a tab deletes its note, which a teammate's team note refuses.
76
+ const mayDelete = useCallback((tab: OwnedQuickNote) => (
77
+ mayDeleteNote(tab, teams, apiClient.getCurrentUser()?.id ?? null)
78
+ ), [teams]);
66
79
 
67
80
  const saveQuickNotesIndex = useCallback((entries: OwnedQuickNote[]) => {
68
81
  // Each owner keeps its own index; a title change only touches that store.
@@ -296,6 +309,10 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
296
309
 
297
310
  const requestRemoveTab = useCallback(async (id: string) => {
298
311
  const tab = tabs.find((entry) => entry.id === id);
312
+ if (tab && !mayDelete(tab)) {
313
+ notify({ body: NOT_YOUR_NOTE, type: "info" });
314
+ return;
315
+ }
299
316
  const store = storeFor(tab?.owner ?? { kind: "user" });
300
317
  const text = id === activeTabId
301
318
  ? readActiveNoteText()
@@ -317,7 +334,7 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
317
334
  }
318
335
 
319
336
  removeTab(id);
320
- }, [activeTabId, dialog, readActiveNoteText, removeTab, storeFor, tabs]);
337
+ }, [activeTabId, dialog, mayDelete, notify, readActiveNoteText, removeTab, storeFor, tabs]);
321
338
 
322
339
  const startRename = useCallback(() => {
323
340
  if (!activeTab) return;
@@ -404,7 +421,8 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
404
421
 
405
422
  // Deleting the only note when it is empty just swaps in another empty one,
406
423
  // and a note that failed to load reads as empty, so it would go unconfirmed.
407
- const canDelete = !!activeTabId && !readError && (tabs.length > 1 || noteText.trim().length > 0);
424
+ const canDelete = !!activeTabId && !readError && (tabs.length > 1 || noteText.trim().length > 0)
425
+ && (!activeTab || mayDelete(activeTab));
408
426
 
409
427
  usePaneFooter("quick-notes", () => ({
410
428
  info: footerWarning
@@ -426,7 +444,7 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
426
444
  label: tab.owner.kind === "team" ? `${ownerLabel(tab.owner, teams)} ${tab.title}` : tab.title,
427
445
  value: tab.id,
428
446
  ...(tab.owner.kind === "team" ? { fg: ownerColor(tab.owner, teams) } : {}),
429
- onClose: tabs.length > 1 ? (id: string) => { void requestRemoveTab(id); } : undefined,
447
+ onClose: tabs.length > 1 && mayDelete(tab) ? (id: string) => { void requestRemoveTab(id); } : undefined,
430
448
  onDoubleClick: startRenameTab,
431
449
  }));
432
450
  const selectTab = (id: string) => {
@@ -240,7 +240,12 @@ export class CloudNotesStore implements NotesStore {
240
240
  return [...index.values()]
241
241
  .filter((summary) => summary.kind === "quick")
242
242
  .sort((a, b) => a.createdAt.localeCompare(b.createdAt))
243
- .map((summary) => ({ id: summary.key, title: summary.title ?? "Note", updatedAt: Date.parse(summary.updatedAt) || undefined }));
243
+ .map((summary) => ({
244
+ id: summary.key,
245
+ title: summary.title ?? "Note",
246
+ updatedAt: Date.parse(summary.updatedAt) || undefined,
247
+ ...(summary.createdBy !== undefined ? { createdBy: summary.createdBy } : {}),
248
+ }));
244
249
  }
245
250
 
246
251
  /**
@@ -1,4 +1,4 @@
1
- import type { PerpBoardPayload, PerpBoardRow, PerpDepthRow, PerpLiquidationMarket, PerpLiquidationPrint } from "../../../api-client/perps";
1
+ import type { PerpBoardPayload, PerpBoardRow, PerpDepthRow, PerpLiquidationMarket, PerpLiquidationPrint, PerpLiquidationsPayload } from "../../../api-client/perps";
2
2
  import type { HeadlessBundleSection, HeadlessPaneColumn, HeadlessPaneLoadArgs, HeadlessPaneRow } from "../../../types/headless";
3
3
  import type { HeadlessPaneDefinition } from "../../../types/plugin";
4
4
  import { DEPTH_COLUMN_IDS, depthBandTotals, depthCellText, depthColumnLabel, depthFreshness, depthStaleNote, downStreams, LIQUIDATION_COLUMN_IDS, liquidationCellText, liquidationColumnLabel, liquidationFreshness,
@@ -108,6 +108,11 @@ const tabOf = (args: HeadlessPaneLoadArgs) => PERP_TABS.find((tab) => tab === ar
108
108
  const TITLES: Record<typeof PERP_TABS[number], string> = { board: "Perpetual markets", rankings: "Perpetual rankings", compare: "Perpetual contracts across venues",
109
109
  liquidations: "Perpetual liquidations across venues", depth: "Perpetual order book depth across venues", history: "Perpetuals", evidence: "Perpetual evidence" };
110
110
  const copy = (rows: readonly PerpBoardRow[]) => rows.map((row) => ({ ...row }));
111
+ /** The days the liquidations read back from their time (`from` to `asOf`), as a heading names them: `7 days`; null without both. */
112
+ const windowDays = (data: Pick<PerpLiquidationsPayload, "from" | "asOf">) => {
113
+ const days = Math.round((Date.parse(data.asOf) - Date.parse(data.from)) / 86_400_000);
114
+ return Number.isFinite(days) && days > 0 ? `${days} ${days === 1 ? "day" : "days"}` : null;
115
+ };
111
116
  const more = (count: number, noun: string) => `${count.toLocaleString("en-US")} more ${noun} need Gloom Pro`;
112
117
  // A table the free view leaves empty is locked: the report leaves it out and its one Pro line says what Pro adds.
113
118
  const lockedTable = (locked: unknown) => locked ? { locked: true } : {};
@@ -206,7 +211,8 @@ export const perpsHeadless: HeadlessPaneDefinition<"bundle"> = {
206
211
  return { sections: [{ title: "Totals", entries: [...entries, { key: "collectingSince", label: "Collecting since", value: data.collectingSince, formatted: time(data.collectingSince) }] },
207
212
  { title: "By contract", columns: LIQUIDATION_TEXT_COLUMNS, rows: data.markets.map((row) => ({ ...row })) },
208
213
  { title: "Hourly", columns: HOURLY_COLUMNS, rows: data.hourly.map((row) => ({ ...row })), ...locked },
209
- { title: "Largest prints", columns: printTextColumns(data.baseAsset), rows: data.largest.map((row) => ({ ...row })) }],
214
+ // The prints are the window's, not the 24 hours beside them: the heading says which.
215
+ { title: "Largest prints", textTitle: windowDays(data) ? `Largest prints, ${windowDays(data)}` : "Largest prints", columns: printTextColumns(data.baseAsset), rows: data.largest.map((row) => ({ ...row })) }],
210
216
  complete: !data.locked && data.status === "ok" && !downStreams(data).length, notes: data.notes,
211
217
  errors: data.locked ? [freePreviewNote({ shows: "liquidation totals and the three largest prints", adds: "the hourly series and the twenty largest prints" })] : [],
212
218
  freshness: liquidationFreshness(data),
@@ -55,7 +55,7 @@ export function PortfolioCashMarginDrawer({
55
55
  <Text fg={colors.textDim}>{" qty "}</Text>
56
56
  <Text fg={colors.text}>{padTo(formatMarketQuantity(balance.quantity, { isCashBalance: true, maxWidth: 14 }), 14, "right")}</Text>
57
57
  <Text fg={colors.textDim}>{" value "}</Text>
58
- <Text fg={colors.text}>{padTo(balance.baseValue != null ? formatCompact(balance.baseValue) : "—", 10, "right")}</Text>
58
+ <Text fg={colors.text}>{padTo(balance.baseValue != null ? formatCompact(balance.baseValue, { fixedDecimals: true }) : "—", 10, "right")}</Text>
59
59
  </Box>
60
60
  ))
61
61
  )}
@@ -141,15 +141,20 @@ export function matchEarningsSecFiling(row: { status: string; date: string; date
141
141
  return best?.filing ?? null;
142
142
  }
143
143
 
144
- /** Share the currency label; EE marks any unstated currencies separately. */
145
- function sharedMetricCurrency(rows: readonly EventRow[], allowUnstated = false): string | undefined {
146
- const currencies = new Set<string | undefined>();
144
+ /**
145
+ * The one currency every stated EPS and revenue amount is in, named once above
146
+ * the table (EVT and EE alike). An amount whose source stated no currency is
147
+ * marked `?` beside it rather than counted, so it never reads as that currency;
148
+ * amounts in several currencies keep their own codes.
149
+ */
150
+ function sharedMetricCurrency(rows: readonly EventRow[]): string | undefined {
151
+ const currencies = new Set<string>();
147
152
  for (const row of rows) {
148
153
  for (const [value, currency] of [
149
154
  [row.qEps, row.epsCurrency], [row.annualEps, row.epsCurrency],
150
155
  [row.qRevenue, row.revenueCurrency], [row.annualRevenue, row.revenueCurrency],
151
156
  ] as const) {
152
- if (value != null && Number.isFinite(value) && (currency || !allowUnstated)) currencies.add(currency || undefined);
157
+ if (value != null && Number.isFinite(value) && currency) currencies.add(currency);
153
158
  }
154
159
  }
155
160
  const [only] = currencies;
@@ -169,15 +174,14 @@ export function buildEventColumns(width: number, unit?: string, variant: "corpor
169
174
  { id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
170
175
  ], width, ["detail", "growth", "revenue"]);
171
176
  }
172
- const withUnit = (label: string) => unit ? `${label} ${unit}` : label;
173
177
  const columns: EventColumn[] = [
174
178
  { id: "date", label: "DATE", width: 10, align: "left" },
175
179
  { id: "status", label: "EVENT", width: 8, align: "left" },
176
180
  { id: "period", label: "PERIOD", width: 12, align: "left" },
177
- { id: "qEps", label: withUnit("Q EPS"), width: 12, align: "right" },
178
- { id: "qRevenue", label: withUnit("Q REV"), width: 12, align: "right" },
179
- { id: "annualEps", label: withUnit("ANN EPS"), width: 12, align: "right" },
180
- { id: "annualRevenue", label: withUnit("ANN REV"), width: 12, align: "right" },
181
+ { id: "qEps", label: "Q EPS", width: 12, align: "right" },
182
+ { id: "qRevenue", label: "Q REV", width: 12, align: "right" },
183
+ { id: "annualEps", label: "ANN EPS", width: 12, align: "right" },
184
+ { id: "annualRevenue", label: "ANN REV", width: 12, align: "right" },
181
185
  { id: "value", label: "VALUE", width: 11, align: "right" },
182
186
  { id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
183
187
  ];
@@ -498,7 +502,7 @@ export function CorporateActionsView({
498
502
  ? allRows.filter((row) => EARNINGS_STATUSES.has(row.status))
499
503
  : allRows
500
504
  ), [allRows, variant]);
501
- const unit = useMemo(() => sharedMetricCurrency(rows, variant === "earnings-estimates"), [rows, variant]);
505
+ const unit = useMemo(() => sharedMetricCurrency(rows), [rows]);
502
506
  const hasUnstatedCurrency = rows.some((row) =>
503
507
  ((row.qEps != null || row.annualEps != null) && !row.epsCurrency)
504
508
  || ((row.qRevenue != null || row.annualRevenue != null) && !row.revenueCurrency));
@@ -618,6 +622,11 @@ export function CorporateActionsView({
618
622
  row: EventRow,
619
623
  column: EventColumn,
620
624
  ): DataTableCell => {
625
+ // Bare under the currency named above the table, with its own code otherwise, `?` when its source stated none.
626
+ const metric = (value: number | undefined, currency: string | undefined, kind: "eps" | "revenue"): DataTableCell => {
627
+ const text = formatEventMetric(value, unit ? undefined : currency, kind);
628
+ return { text: value != null && !currency ? `${text} ?` : text, value: unit && currency ? value : undefined, color: colors.textDim };
629
+ };
621
630
  switch (column.id) {
622
631
  case "date":
623
632
  return { text: row.date, color: colors.textDim };
@@ -626,26 +635,21 @@ export function CorporateActionsView({
626
635
  case "period":
627
636
  return { text: row.period, color: colors.textDim };
628
637
  case "eps":
629
- case "revenue": {
630
- const eps = column.id === "eps";
631
- const value = eps ? row.qEps ?? row.annualEps : row.qRevenue ?? row.annualRevenue;
632
- const currency = eps ? row.epsCurrency : row.revenueCurrency;
633
- const text = formatEventMetric(value, unit ? undefined : currency, eps ? "eps" : "revenue");
634
- return { text: value != null && !currency ? `${text} ?` : text,
635
- value: unit && currency ? value : undefined, color: colors.textDim };
636
- }
638
+ return metric(row.qEps ?? row.annualEps, row.epsCurrency, "eps");
639
+ case "revenue":
640
+ return metric(row.qRevenue ?? row.annualRevenue, row.revenueCurrency, "revenue");
637
641
  case "surprise":
638
642
  return { text: row.status === "Earnings" ? row.value : "-", value: row.surprisePercent, color: row.status === "Earnings" ? toneColor(row.tone) : colors.textDim };
639
643
  case "growth":
640
644
  return { text: row.estimateGrowthMetric && row.value !== "-" ? `${row.value} ${row.estimateGrowthMetric === "eps" ? "EPS" : "rev"}` : "-", color: row.estimateGrowthMetric ? toneColor(row.tone) : colors.textDim };
641
645
  case "qEps":
642
- return { text: formatEventMetric(row.qEps, unit ? undefined : row.epsCurrency, "eps"), color: colors.textDim };
646
+ return metric(row.qEps, row.epsCurrency, "eps");
643
647
  case "qRevenue":
644
- return { text: formatEventMetric(row.qRevenue, unit ? undefined : row.revenueCurrency, "revenue"), color: colors.textDim };
648
+ return metric(row.qRevenue, row.revenueCurrency, "revenue");
645
649
  case "annualEps":
646
- return { text: formatEventMetric(row.annualEps, unit ? undefined : row.epsCurrency, "eps"), color: colors.textDim };
650
+ return metric(row.annualEps, row.epsCurrency, "eps");
647
651
  case "annualRevenue":
648
- return { text: formatEventMetric(row.annualRevenue, unit ? undefined : row.revenueCurrency, "revenue"), color: colors.textDim };
652
+ return metric(row.annualRevenue, row.revenueCurrency, "revenue");
649
653
  case "value":
650
654
  return { text: row.value, color: toneColor(row.tone) };
651
655
  case "detail":
@@ -694,7 +698,7 @@ export function CorporateActionsView({
694
698
  rootWidth={width}
695
699
  rootHeight={height}
696
700
  rootBefore={<ChartTableHeader width={width} height={height} tableRows={rows.length} tableColumns={columns}
697
- query={variant === "earnings-estimates" && currencyMeta ? <QueryBar width={width} meta={currencyMeta} /> : undefined} />}
701
+ query={currencyMeta ? <QueryBar width={width} meta={currencyMeta} /> : undefined} />}
698
702
  onRootKeyDown={handleKeyDown}
699
703
  columns={columns}
700
704
  items={rows}
@@ -702,10 +706,10 @@ export function CorporateActionsView({
702
706
  sortDirection="desc"
703
707
  getItemKey={eventRowKey}
704
708
  renderCell={renderCell}
705
- getExportMetadata={variant === "earnings-estimates" ? () => [
709
+ getExportMetadata={() => [
706
710
  ...(unit ? [["Currency", unit]] : []),
707
711
  ...(hasUnstatedCurrency ? [["?", "Currency unstated"]] : []),
708
- ] : undefined}
712
+ ]}
709
713
  selectedTextOverridesCellColor
710
714
  getRowBackgroundColor={rowBackground}
711
715
  emptyStateTitle={loading
@@ -1,13 +1,11 @@
1
1
  import type { PluginModule } from "../plugin-module";
2
- import type { PaneLock } from "../../../types/plugin";
3
- import { filesForm } from "../shared/free-routes";
4
- import { proLockNote } from "../shared/pro-lock-note";
5
2
  import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
6
3
  import {
7
4
  attachRiskFactorsPersistence,
8
5
  resetRiskFactorsPersistence,
9
6
  } from "./data";
10
7
  import { riskFactorsHeadless } from "./headless";
8
+ import { riskFactorsLockNote } from "./lock-note";
11
9
 
12
10
 
13
11
  import { RISK_FACTORS_PANE_ID, RiskFactorsPane, RiskFactorsResearchTab } from "./pane";
@@ -16,30 +14,6 @@ import { isKnownNonUsListing } from "../../../utils/sec";
16
14
  const description =
17
15
  "The company's 10-K risk factors, and what was added, dropped, or rewritten since the prior year.";
18
16
 
19
- /**
20
- * RISK is Pro whole (`useProFeatureWall`). The 10-Ks it reads are in the SEC
21
- * filing list, which needs no account: `filings` lists them with a link to
22
- * each, where Item 1A is the risk factors as written, without RISK's grouping
23
- * or its changes since the year before. A foreign issuer files a 20-F instead
24
- * (ASML), whose Item 3.D holds them. A company that files neither (IAG on
25
- * LSE) has nothing in RISK either, and the note says so.
26
- */
27
- function riskFactorsLockNote(lock: PaneLock): Promise<string> {
28
- return proLockNote(lock, {
29
- token: "RISK",
30
- does: "it groups a 10-K's risk factors by theme and shows what was added, dropped or reworded since the year before",
31
- shows: "it",
32
- free: [{
33
- text: (ticker, company) => `gloom filings ${ticker} --form 10-K lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 1A holds the risk factors as written.`,
34
- answers: (symbol, context) => filesForm(symbol, "10-K", context),
35
- }, {
36
- text: (ticker, company) => `gloom filings ${ticker} --form 20-F lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 3.D holds the risk factors as written.`,
37
- answers: (symbol, context) => filesForm(symbol, "20-F", context),
38
- }],
39
- noneFor: (ticker) => `${ticker}'s company files no 10-K or 20-F with the SEC, so RISK has no risk factors for it.`,
40
- });
41
- }
42
-
43
17
  export const riskFactorsModule: PluginModule = {
44
18
  setup(ctx) {
45
19
  attachRiskFactorsPersistence(ctx.persistence);
@@ -60,7 +34,7 @@ export const riskFactorsModule: PluginModule = {
60
34
  panes: [
61
35
  {
62
36
  id: RISK_FACTORS_PANE_ID,
63
- reportLockNote: riskFactorsLockNote,
37
+ reportLockNote: (lock) => riskFactorsLockNote(lock),
64
38
  reportRequirements: ["Gloom Cloud Pro"],
65
39
  name: "Risk Factors",
66
40
  icon: "R",
@@ -0,0 +1,58 @@
1
+ import { getWallSummary, type WallSummary } from "../../../api-client/wall-summary";
2
+ import type { PaneLock } from "../../../types/plugin";
3
+ import { filesForm } from "../shared/free-routes";
4
+ import { resolveHeadlessInstrument } from "../shared/headless-market-data";
5
+ import { proLockNote, type FreeRoute } from "../shared/pro-lock-note";
6
+
7
+ type ReadSummary = (wall: string, symbol: string, exchange?: string) => Promise<WallSummary | null>;
8
+
9
+ /**
10
+ * How gloom.sh spells a US ticker in a page's address: lower case, a share
11
+ * class after a dash (`brk-b`), as its canonical link does. The venue is no
12
+ * part of it: `aapl:nasdaq` is no page.
13
+ */
14
+ const pageTicker = (symbol: string) => symbol.trim().toLowerCase().replace(/[./]/g, "-");
15
+
16
+ /**
17
+ * The company's risk factor page on gloom.sh, which needs no account: each
18
+ * 10-K's risks with what was added, dropped or reworded. It is there for a
19
+ * company RISK has read a 10-K of, which the public wall summary counts, and
20
+ * named by the listing that check resolved, not the argument as typed.
21
+ */
22
+ function webRoute(readSummary: ReadSummary): FreeRoute {
23
+ let resolved: string | null = null;
24
+ return {
25
+ text: (ticker, company) => `gloom.sh/stocks/${pageTicker(resolved ?? ticker)}/risk-factors has ${company}'s risk factors from each 10-K, with what was added, dropped or reworded since the year before.`,
26
+ answers: async (symbol, context) => {
27
+ const { symbol: ticker, exchange } = await resolveHeadlessInstrument(context, symbol);
28
+ const summary = await readSummary("risk-wall", ticker, exchange);
29
+ const has = summary?.items.some((item) => item.label === "risk_count" && Number(item.value) > 0) ?? false;
30
+ if (has) resolved = ticker;
31
+ return has;
32
+ },
33
+ };
34
+ }
35
+
36
+ /**
37
+ * RISK is Pro whole (`useProFeatureWall`). Its reports are open on gloom.sh,
38
+ * one page per company, and the 10-Ks it reads are in the SEC filing list,
39
+ * which needs no account either: `filings` lists them with a link to each,
40
+ * where Item 1A is the risk factors as written. A foreign issuer files a 20-F
41
+ * instead (ASML), whose Item 3.D holds them. A company that files neither
42
+ * (IAG on LSE) has nothing in RISK either, and the note says so.
43
+ */
44
+ export function riskFactorsLockNote(lock: PaneLock, readSummary: ReadSummary = getWallSummary): Promise<string> {
45
+ return proLockNote(lock, {
46
+ token: "RISK",
47
+ does: "it groups a 10-K's risk factors by theme and shows what was added, dropped or reworded since the year before",
48
+ shows: "it",
49
+ free: [webRoute(readSummary), {
50
+ text: (ticker, company) => `gloom filings ${ticker} --form 10-K lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 1A holds the risk factors as written.`,
51
+ answers: (symbol, context) => filesForm(symbol, "10-K", context),
52
+ }, {
53
+ text: (ticker, company) => `gloom filings ${ticker} --form 20-F lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 3.D holds the risk factors as written.`,
54
+ answers: (symbol, context) => filesForm(symbol, "20-F", context),
55
+ }],
56
+ noneFor: (ticker) => `${ticker}'s company files no 10-K or 20-F with the SEC, so RISK has no risk factors for it.`,
57
+ });
58
+ }
@@ -71,6 +71,8 @@ function RiskLine({
71
71
  );
72
72
  }
73
73
 
74
+ const NO_RISK_FACTORS = "This 10-K lists no risk factors.";
75
+
74
76
  const RISK_WALL: ProFeatureWallCopy = {
75
77
  placement: "risk-wall",
76
78
  action: "read risk factors",
@@ -170,14 +172,17 @@ function RiskFactorsReader({
170
172
  if (year === null) return <EmptyState title={`No 10-K risk factors on file for ${ticker}.`} />;
171
173
 
172
174
  const diff = report?.diff ?? null;
175
+ // A smaller reporting company's 10-K need not list risk factors. Its report
176
+ // has none to read or compare, only the filing to open.
177
+ const listsNone = report ? report.listsNoRiskFactors === true || report.riskCount === 0 : false;
173
178
  // A choice of years names the year in the tabs or the filter; a single
174
179
  // report says which one it is here.
175
180
  const meta = report
176
181
  ? [
177
182
  years.length > 1 ? null : `${report.reportYear} 10-K`,
178
183
  `Filed ${report.filedAt?.slice(0, 10) || "unavailable"}`,
179
- `updated ${report.updatedAt?.slice(0, 10) || "unavailable"}`,
180
- diff ? null : "no prior year on file",
184
+ listsNone ? null : `updated ${report.updatedAt?.slice(0, 10) || "unavailable"}`,
185
+ diff || listsNone ? null : "no prior year on file",
181
186
  ].filter(Boolean).join(" · ")
182
187
  : "";
183
188
 
@@ -208,7 +213,9 @@ function RiskFactorsReader({
208
213
  scrollY
209
214
  paddingX={1}
210
215
  >
211
- {report ? (
216
+ {report && listsNone ? (
217
+ <PaneStatusBody empty emptyTitle={report.overview || NO_RISK_FACTORS} />
218
+ ) : report ? (
212
219
  <Box
213
220
  flexDirection="column"
214
221
  width={nativePaneChrome ? "100%" : bodyWidth}