@gloom-sh/terminal 0.20.17 → 0.20.18

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 (304) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +3 -2
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/app/global-shortcuts.ts +5 -3
  13. package/src/app/pro-welcome/keys.ts +27 -0
  14. package/src/app/pro-welcome/model.ts +158 -0
  15. package/src/app/pro-welcome/row.tsx +176 -0
  16. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  17. package/src/app/runtime/external-profile-changes.ts +135 -0
  18. package/src/app.tsx +33 -2
  19. package/src/architecture/core-builtin-allowlist.json +1 -1
  20. package/src/architecture/floating-promise-allowlist.json +0 -1
  21. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  22. package/src/cli/alert-listing.ts +98 -0
  23. package/src/cli/commands/market.ts +138 -22
  24. package/src/cli/commands/overview.ts +7 -1
  25. package/src/cli/commands/plugins.ts +3 -2
  26. package/src/cli/commands/search.ts +30 -6
  27. package/src/cli/context.ts +16 -5
  28. package/src/cli/csv-export.ts +2 -1
  29. package/src/cli/desktop-pane-shot.ts +72 -9
  30. package/src/cli/glossary.ts +64 -10
  31. package/src/cli/history-demergers.ts +117 -0
  32. package/src/cli/history-rows.ts +6 -2
  33. package/src/cli/index.ts +1 -0
  34. package/src/cli/known-gaps.ts +16 -0
  35. package/src/cli/known-us-stocks.ts +18 -0
  36. package/src/cli/listing-arg.ts +105 -15
  37. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  38. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  39. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  40. package/src/cli/pane-functions/catalog.ts +50 -16
  41. package/src/cli/pane-functions/data.ts +16 -4
  42. package/src/cli/pane-functions/dom.ts +24 -6
  43. package/src/cli/pane-functions/freshness.ts +17 -1
  44. package/src/cli/pane-functions/index.ts +100 -42
  45. package/src/cli/pane-functions/resolver.ts +8 -5
  46. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  47. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  48. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  49. package/src/cli/quote-answer.ts +32 -16
  50. package/src/cli/registry.ts +22 -2
  51. package/src/cli/result.ts +5 -4
  52. package/src/cli/series-search.ts +45 -6
  53. package/src/cli/shot-temp-dir.ts +4 -9
  54. package/src/components/chart/composite/legend.tsx +43 -18
  55. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  56. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  57. package/src/components/chart-table/header.tsx +9 -0
  58. package/src/components/chart-table/layout.ts +11 -11
  59. package/src/components/command-bar/pane-templates/items.ts +17 -1
  60. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  61. package/src/components/command-bar/routes/root/results.ts +34 -2
  62. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  63. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  64. package/src/components/command-bar/workflow/alert.ts +19 -8
  65. package/src/components/data-table/view.tsx +15 -2
  66. package/src/components/form-modal/content.tsx +9 -4
  67. package/src/components/index.ts +1 -1
  68. package/src/components/layout/header.tsx +9 -5
  69. package/src/components/layout/pane/capture-status.ts +6 -0
  70. package/src/components/layout/pane/footer/index.tsx +2 -0
  71. package/src/components/layout/pane/footer/model.ts +113 -15
  72. package/src/components/layout/pane/header.tsx +16 -2
  73. package/src/components/market-board/index.tsx +4 -2
  74. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  75. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  76. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  77. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  78. package/src/components/onboarding/setup-cards.ts +36 -0
  79. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  80. package/src/components/onboarding/wizard-account.ts +6 -1
  81. package/src/components/onboarding/wizard-model.ts +32 -6
  82. package/src/components/onboarding/wizard-positions.ts +1 -1
  83. package/src/components/sign-in-gate.tsx +3 -1
  84. package/src/components/toggle-list.tsx +6 -8
  85. package/src/components/ui/confirm-dialog.tsx +47 -7
  86. package/src/components/ui/data-table/types.ts +8 -0
  87. package/src/components/ui/display.tsx +17 -2
  88. package/src/components/ui/index.ts +1 -1
  89. package/src/components/ui/stat-grid.tsx +4 -0
  90. package/src/components/ui/status.tsx +13 -1
  91. package/src/components/ui/table-layout.ts +2 -1
  92. package/src/components/use-pane-notice-footer.tsx +16 -3
  93. package/src/data/config/store/index.ts +31 -0
  94. package/src/data/config/store/node.ts +61 -11
  95. package/src/data/config/store/normalize.ts +4 -6
  96. package/src/data/config/store/shared-file.ts +309 -0
  97. package/src/data/profile-merge.ts +299 -0
  98. package/src/data/sqlite/checkpointer.ts +11 -1
  99. package/src/data/sqlite/database.ts +1 -1
  100. package/src/data/ticker-repository.ts +134 -10
  101. package/src/data/ticker-store.ts +67 -0
  102. package/src/data/ticker-writes.ts +5 -0
  103. package/src/i18n/es.ts +27 -0
  104. package/src/i18n/ja.ts +27 -0
  105. package/src/i18n/ko.ts +27 -0
  106. package/src/i18n/zh-cn.ts +27 -0
  107. package/src/i18n/zh-tw.ts +27 -0
  108. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  109. package/src/market-data/ah-pair.ts +103 -0
  110. package/src/market-data/depositary-pair.ts +6 -2
  111. package/src/market-data/hooks.tsx +33 -2
  112. package/src/market-data/market/change-basis.ts +2 -1
  113. package/src/market-data/market/header-market.ts +11 -0
  114. package/src/market-data/split-terms.ts +28 -0
  115. package/src/plugins/builtin/account-management/footer.ts +1 -1
  116. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  117. package/src/plugins/builtin/account-management/model.ts +1 -0
  118. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  119. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  120. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  121. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  122. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  123. package/src/plugins/builtin/alerts/cli.ts +36 -30
  124. package/src/plugins/builtin/alerts/constants.ts +10 -0
  125. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  126. package/src/plugins/builtin/alerts/format.ts +24 -8
  127. package/src/plugins/builtin/alerts/index.tsx +38 -9
  128. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  129. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  130. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  131. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  132. package/src/plugins/builtin/alerts/types.ts +7 -0
  133. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  134. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  135. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  136. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  137. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  139. package/src/plugins/builtin/awards/pane.tsx +1 -1
  140. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  141. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  142. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  143. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  144. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  145. package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
  146. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  147. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  148. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  149. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  150. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  151. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  152. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  153. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  154. package/src/plugins/builtin/composite/application.ts +14 -0
  155. package/src/plugins/builtin/composite/broker.ts +12 -0
  156. package/src/plugins/builtin/composite/credit.ts +33 -0
  157. package/src/plugins/builtin/composite/crypto.ts +10 -0
  158. package/src/plugins/builtin/composite/earnings.ts +12 -0
  159. package/src/plugins/builtin/composite/filings.ts +13 -0
  160. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  161. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  162. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  163. package/src/plugins/builtin/composite/ownership.ts +23 -0
  164. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  165. package/src/plugins/builtin/composite/quant.ts +15 -0
  166. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  167. package/src/plugins/builtin/composite/screeners.ts +11 -0
  168. package/src/plugins/builtin/composite/shared.ts +11 -0
  169. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  170. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  171. package/src/plugins/builtin/correlation/index.tsx +13 -17
  172. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  173. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  174. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  175. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  176. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  177. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  178. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  179. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  180. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  181. package/src/plugins/builtin/earnings/headless.ts +7 -4
  182. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  183. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  184. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  185. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  186. package/src/plugins/builtin/econ/index.tsx +3 -0
  187. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  188. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  189. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  190. package/src/plugins/builtin/exposure/model.ts +10 -0
  191. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  192. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  193. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  194. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  195. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  196. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  197. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  198. package/src/plugins/builtin/mna/detail.tsx +67 -6
  199. package/src/plugins/builtin/mna/headless.ts +128 -13
  200. package/src/plugins/builtin/mna/model.ts +219 -16
  201. package/src/plugins/builtin/mna/pane.tsx +34 -6
  202. package/src/plugins/builtin/money-markets/model.ts +14 -5
  203. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  204. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  205. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  206. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  207. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  208. package/src/plugins/builtin/pe-band/client.ts +13 -1
  209. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  210. package/src/plugins/builtin/pe-band/model.ts +63 -10
  211. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  212. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  213. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  214. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  215. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  216. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  217. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  218. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  219. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  220. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  221. package/src/plugins/builtin/research/event-model.ts +31 -13
  222. package/src/plugins/builtin/research/headless.ts +8 -1
  223. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  224. package/src/plugins/builtin/sectors/index.tsx +6 -9
  225. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  226. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  227. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  228. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  229. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  230. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  231. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  232. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  233. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  234. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  235. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  236. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  237. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  238. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  239. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  240. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  241. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  242. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  243. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  244. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  245. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  246. package/src/plugins/builtin/volatility/model.ts +17 -0
  247. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  248. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  249. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  250. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  251. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  252. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  253. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  254. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  255. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  256. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  257. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  258. package/src/plugins/catalog-data.ts +20 -0
  259. package/src/plugins/catalog-lazy.ts +51 -0
  260. package/src/plugins/catalog-ui.ts +16 -18
  261. package/src/plugins/host-smoke.ts +5 -2
  262. package/src/portfolio/allocation.ts +79 -19
  263. package/src/portfolio/cash-balances.ts +76 -0
  264. package/src/portfolio/mutations.ts +43 -8
  265. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  266. package/src/renderers/desktop/window-layouts.ts +14 -0
  267. package/src/renderers/dom/data-table/row.tsx +2 -0
  268. package/src/renderers/dom/host/tabs.tsx +57 -8
  269. package/src/renderers/dom/styles.css +13 -5
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  272. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  273. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  274. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  275. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  276. package/src/series/standalone-catalog.ts +5 -4
  277. package/src/series/standalone.ts +13 -7
  278. package/src/sources/gloomberb-cloud/index.ts +14 -3
  279. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  280. package/src/sources/provider-router/financials.ts +20 -13
  281. package/src/sources/provider-router/index.ts +4 -0
  282. package/src/sources/provider-router/search.ts +1 -0
  283. package/src/sync/collections-contributor.ts +3 -1
  284. package/src/sync/config-merge.ts +10 -1
  285. package/src/sync/sanitize.ts +26 -2
  286. package/src/tickers/company-name-listing.ts +16 -2
  287. package/src/tickers/listing-fate.ts +12 -8
  288. package/src/tickers/renamed-listings.ts +43 -10
  289. package/src/tickers/search/home-listing.ts +28 -0
  290. package/src/tickers/search/index.ts +19 -7
  291. package/src/tickers/terminal-codes.ts +11 -1
  292. package/src/time-series/resolve.ts +3 -1
  293. package/src/time-series/spec.ts +2 -2
  294. package/src/time-series/types.ts +1 -1
  295. package/src/types/data-provider.ts +11 -0
  296. package/src/types/financials.ts +39 -3
  297. package/src/types/ticker.ts +10 -2
  298. package/src/utils/cli-output.ts +1 -1
  299. package/src/utils/declared-dividends.ts +13 -1
  300. package/src/utils/dividend-cash.ts +5 -1
  301. package/src/utils/forward-dividend.ts +4 -3
  302. package/src/utils/remove-folder.ts +37 -0
  303. package/src/utils/trailing-dividend.ts +1 -1
  304. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -1,5 +1,6 @@
1
1
  import type { Portfolio, PortfolioCash } from "../types/ticker";
2
2
  import type { BrokerAccount } from "../types/trading";
3
+ import { portfolioCashBalances } from "./cash-balances";
3
4
  import { currencyMinorDigits, getCurrencySymbol, resolveAssetDisplayKind } from "../market-data/market/format";
4
5
  import { MISSING_VALUE, formatNumber } from "../utils/format";
5
6
  import { parseTypedNumber } from "../utils/decimal-comma";
@@ -13,7 +14,8 @@ import { parseTypedNumber } from "../utils/decimal-comma";
13
14
  * at their net market value plus the cash line. A book that holds a short
14
15
  * weighs against its gross exposure instead (WeightBasis). A holding without
15
16
  * a price is left out of the total and the weights and is listed as
16
- * unpriced, never valued at zero.
17
+ * unpriced, never valued at zero; so is a currency's cash without a rate
18
+ * into the portfolio's currency.
17
19
  */
18
20
 
19
21
  /** The cash line's symbol in targets and reports. */
@@ -50,9 +52,33 @@ export interface AllocationFigures {
50
52
 
51
53
  type PortfolioAllocationRow = AllocationHolding & AllocationFigures;
52
54
 
55
+ /** One currency of a portfolio's cash, valued in the portfolio's currency. */
56
+ export interface AllocationCashBalance {
57
+ currency: string;
58
+ /** In `currency`. */
59
+ amount: number;
60
+ /**
61
+ * In the portfolio's currency; null without a rate to convert it, which
62
+ * leaves it out of the total and the weights as a holding without a price is.
63
+ */
64
+ value: number | null;
65
+ }
66
+
67
+ interface PortfolioCashBalanceLine extends AllocationCashBalance {
68
+ /** Its own share of the weight base: null without a value, or against a hedged book's gross exposure. */
69
+ weight: number | null;
70
+ }
71
+
72
+ /**
73
+ * The cash line: all the portfolio's cash, whatever currencies it is in. Its
74
+ * target (`CASH`), drift and trade are the whole line's; each currency's
75
+ * balance has its own value and weight.
76
+ */
53
77
  export interface PortfolioCashLine extends AllocationFigures {
54
- /** In the portfolio's currency. */
55
- value: number;
78
+ /** All the cash in the portfolio's currency; null while a balance has no rate. */
79
+ value: number | null;
80
+ /** One per currency, largest first, those without a value last; none for a target without cash. */
81
+ balances: PortfolioCashBalanceLine[];
56
82
  }
57
83
 
58
84
  export interface PortfolioAllocation {
@@ -60,7 +86,7 @@ export interface PortfolioAllocation {
60
86
  rows: PortfolioAllocationRow[];
61
87
  /** Present when the portfolio has cash or a cash target. */
62
88
  cash: PortfolioCashLine | null;
63
- /** Priced holdings plus cash; null when it cannot be valued. */
89
+ /** Priced holdings plus the cash that has a value; null when it cannot be valued. */
64
90
  total: number | null;
65
91
  /** What the weights are a share of. */
66
92
  weightBasis: WeightBasis;
@@ -68,6 +94,8 @@ export interface PortfolioAllocation {
68
94
  weightBase: number | null;
69
95
  /** Held symbols without a price, left out of the total and the weights. */
70
96
  unpriced: string[];
97
+ /** The currencies of cash without a rate into the portfolio's, left out of the total and the weights. */
98
+ unpricedCash: string[];
71
99
  /** The targets of the listed symbols and cash added up; null when none is set. */
72
100
  targetSum: number | null;
73
101
  }
@@ -167,26 +195,43 @@ export function allocationTotal(holdings: readonly AllocationHolding[], cashValu
167
195
  return Number.isFinite(total) ? total : null;
168
196
  }
169
197
 
198
+ /**
199
+ * The cash the total counts, in the portfolio's currency: every balance with a
200
+ * value. Null without cash, so a book of holdings alone totals as before.
201
+ */
202
+ export function pricedCashValue(balances: readonly Pick<AllocationCashBalance, "value">[] | null | undefined): number | null {
203
+ if (!balances?.length) return null;
204
+ return balances.reduce((sum, balance) => sum + (finite(balance.value) ? balance.value : 0), 0);
205
+ }
206
+
170
207
  export function buildPortfolioAllocation({
171
208
  holdings,
172
- cashValue,
209
+ cash = [],
173
210
  targets,
174
211
  }: {
175
212
  holdings: readonly AllocationHolding[];
176
- /** The cash line in the portfolio's currency; NaN when it cannot be converted. */
177
- cashValue?: number | null;
213
+ /** Each currency's cash, valued in the portfolio's currency (null without a rate). */
214
+ cash?: readonly AllocationCashBalance[] | null;
178
215
  targets?: Readonly<Record<string, number>>;
179
216
  }): PortfolioAllocation {
217
+ const balances = cash ?? [];
218
+ const cashValue = pricedCashValue(balances);
180
219
  const total = allocationTotal(holdings, cashValue);
181
220
  const base = allocationWeightBase(holdings, cashValue);
221
+ // Cash is no exposure: against a gross base it keeps its target but has no weight or trade.
222
+ const cashBase = base.basis === "gross" ? null : base.value;
182
223
  const rows = holdings.map((holding) => ({ ...holding, ...allocationFigures(holding, base.value, holdingTarget(targets, holding.symbol)) }));
183
224
  const cashTarget = targets?.[CASH_SYMBOL];
184
- const cash = cashValue != null || finite(cashTarget)
225
+ // The whole line is unknown while one balance is: its weight and trade would leave that balance out.
226
+ const lineValue = balances.every((balance) => finite(balance.value)) ? cashValue ?? 0 : null;
227
+ const cashLine = balances.length > 0 || finite(cashTarget)
185
228
  ? {
186
- value: cashValue ?? 0,
187
- // Cash is no exposure: against a gross base it keeps its target but has no weight or trade.
188
- ...allocationFigures({ held: true, marketValue: cashValue ?? 0, units: 0, unitPrice: null },
189
- base.basis === "gross" ? null : base.value, cashTarget),
229
+ value: lineValue,
230
+ balances: balances
231
+ .map((balance) => ({ ...balance, weight: finite(balance.value) ? lotWeight(balance.value, cashBase) : null }))
232
+ .sort((left, right) => (finite(left.value) ? 0 : 1) - (finite(right.value) ? 0 : 1)
233
+ || Math.abs(right.value ?? 0) - Math.abs(left.value ?? 0)),
234
+ ...allocationFigures({ held: true, marketValue: lineValue, units: 0, unitPrice: null }, cashBase, cashTarget),
190
235
  }
191
236
  : null;
192
237
  let targetSum: number | null = null;
@@ -196,11 +241,12 @@ export function buildPortfolioAllocation({
196
241
  }
197
242
  return {
198
243
  rows,
199
- cash,
244
+ cash: cashLine,
200
245
  total,
201
246
  weightBasis: base.basis,
202
247
  weightBase: base.value,
203
248
  unpriced: holdings.filter((holding) => holding.held && !finite(holding.marketValue)).map((holding) => holding.symbol),
249
+ unpricedCash: balances.filter((balance) => !finite(balance.value)).map((balance) => balance.currency),
204
250
  targetSum,
205
251
  };
206
252
  }
@@ -218,18 +264,32 @@ export function hasTargetWeights(portfolio: Pick<Portfolio, "targetWeights"> | n
218
264
  return !!portfolio?.targetWeights && Object.keys(portfolio.targetWeights).length > 0;
219
265
  }
220
266
 
267
+ /** A portfolio's cash, in the currencies it is held in, and where it is from. */
268
+ export interface ResolvedPortfolioCash {
269
+ /** Recorded with `portfolio cash set`, or reported by the broker account. */
270
+ source: "broker" | "manual";
271
+ /** One balance per currency: the broker account's total cash, or each currency entered by hand. */
272
+ balances: PortfolioCash[];
273
+ }
274
+
221
275
  /**
222
- * The portfolio's cash in its own currency. A broker account that reports its
223
- * cash is used instead of an entry made by hand, so the two never add up.
276
+ * The portfolio's cash. A broker account that reports its cash is used
277
+ * instead of the balances entered by hand, so the two never add up.
224
278
  */
225
279
  export function resolvePortfolioCash(
226
- portfolio: Pick<Portfolio, "cash"> | null | undefined,
280
+ portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined,
227
281
  account: Pick<BrokerAccount, "totalCashValue" | "currency"> | null | undefined,
228
- ): (PortfolioCash & { source: "broker" | "manual" }) | null {
282
+ ): ResolvedPortfolioCash | null {
229
283
  if (account && finite(account.totalCashValue)) {
230
- return { amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? "", source: "broker" };
284
+ return { source: "broker", balances: [{ amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? "" }] };
231
285
  }
232
- return portfolio?.cash ? { ...portfolio.cash, source: "manual" } : null;
286
+ const balances = portfolioCashBalances(portfolio);
287
+ return balances.length > 0 ? { source: "manual", balances } : null;
288
+ }
289
+
290
+ /** What a cash row is called: `CASH`, or `CASH TRY` for a currency other than the portfolio's or one of several. */
291
+ export function cashLineLabel(currency: string | null | undefined, portfolioCurrency: string, several = false): string {
292
+ return currency && (several || currency !== portfolioCurrency) ? `${CASH_SYMBOL} ${currency}` : CASH_SYMBOL;
233
293
  }
234
294
 
235
295
  /**
@@ -0,0 +1,76 @@
1
+ import type { Portfolio, PortfolioCash } from "../types/ticker";
2
+ import { isRecord } from "../utils/guards";
3
+
4
+ /**
5
+ * A manual portfolio's cash, one balance per currency (HKD and USD side by
6
+ * side). The first balance is saved in `Portfolio.cash`, which every build
7
+ * before several currencies reads, and the others in `Portfolio.otherCash`,
8
+ * so such a build sees one valid balance and never a second copy of it.
9
+ * Every reader takes the balances from `portfolioCashBalances`, which counts
10
+ * each currency once, and every writer saves them with
11
+ * `withPortfolioCashBalances`.
12
+ */
13
+
14
+ const CURRENCY_CODE = /^[A-Z]{3}$/;
15
+
16
+ /** A balance as saved: a finite amount in an upper-case ISO code; null for anything else. */
17
+ function savedBalance(value: unknown): PortfolioCash | null {
18
+ if (!isRecord(value) || typeof value.amount !== "number" || !Number.isFinite(value.amount)) return null;
19
+ return typeof value.currency === "string" && CURRENCY_CODE.test(value.currency)
20
+ ? { amount: value.amount, currency: value.currency }
21
+ : null;
22
+ }
23
+
24
+ /**
25
+ * The portfolio's cash entered by hand, `cash` first and then the other
26
+ * currencies in the order they were set. A currency is counted once: a
27
+ * second entry of it (an older build that set `cash` to a currency
28
+ * `otherCash` also holds) gives way to the first, which is `cash`.
29
+ */
30
+ export function portfolioCashBalances(portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): PortfolioCash[] {
31
+ if (!portfolio) return [];
32
+ const balances: PortfolioCash[] = [];
33
+ const others: unknown[] = Array.isArray(portfolio.otherCash) ? portfolio.otherCash : [];
34
+ for (const entry of [portfolio.cash, ...others]) {
35
+ const balance = savedBalance(entry);
36
+ if (balance && !balances.some((kept) => kept.currency === balance.currency)) balances.push(balance);
37
+ }
38
+ return balances;
39
+ }
40
+
41
+ /**
42
+ * The portfolio holding these balances: the first in `cash`, the others in
43
+ * `otherCash`, neither field when there are none. Each currency once, the
44
+ * first entry of it kept.
45
+ */
46
+ export function withPortfolioCashBalances<T extends object>(
47
+ portfolio: T,
48
+ balances: readonly PortfolioCash[],
49
+ ): Omit<T, "cash" | "otherCash"> & Pick<Portfolio, "cash" | "otherCash"> {
50
+ const { cash: _cash, otherCash: _otherCash, ...rest } = portfolio as T & Pick<Portfolio, "cash" | "otherCash">;
51
+ const [first, ...others] = portfolioCashBalances({ otherCash: [...balances] });
52
+ return {
53
+ ...rest,
54
+ ...(first ? { cash: first } : {}),
55
+ ...(others.length > 0 ? { otherCash: others } : {}),
56
+ };
57
+ }
58
+
59
+ /**
60
+ * A pulled portfolio from a build that does not send `otherCash` (an older
61
+ * desktop build, which strips it from every push), keeping the other
62
+ * currencies this device holds. That build saw `cash` alone, so its `cash`
63
+ * stands, set, replaced or cleared, and a balance here in that same currency
64
+ * gives way to it rather than counting twice. Anything else is taken as it
65
+ * came.
66
+ */
67
+ export function withKeptOtherCash(pulled: unknown, local: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): unknown {
68
+ if (!isRecord(pulled) || pulled.otherCash !== undefined || !local) return pulled;
69
+ const [, ...others] = portfolioCashBalances(local);
70
+ if (others.length === 0) return pulled;
71
+ const seen = savedBalance(pulled.cash);
72
+ return withPortfolioCashBalances(pulled, [
73
+ ...(seen ? [seen] : []),
74
+ ...others.filter((balance) => balance.currency !== seen?.currency),
75
+ ]);
76
+ }
@@ -6,6 +6,7 @@ import { parseCollectionRef } from "../team/collections";
6
6
  import { findNamedCollection } from "./collection-name";
7
7
  import { isFuturesTicker } from "./futures-positions";
8
8
  import { manualPortfolioLots, mergeLotCostTerms, type LotCostFxConflict } from "./manual-lots";
9
+ import { portfolioCashBalances, withPortfolioCashBalances } from "./cash-balances";
9
10
 
10
11
  export interface DeleteWatchlistResult {
11
12
  config: AppConfig;
@@ -225,20 +226,54 @@ function updatePortfolio(config: AppConfig, portfolioId: string, update: (portfo
225
226
  };
226
227
  }
227
228
 
228
- /** Records the cash held beside a portfolio's positions, replacing any earlier entry. */
229
- export function setPortfolioCash(config: AppConfig, portfolioId: string, cash: PortfolioCash): AppConfig {
229
+ /**
230
+ * Records the cash a portfolio holds in one currency, beside its positions and
231
+ * its cash in any other currency, which stay. `replaced` is that currency's
232
+ * earlier balance when it differs from the new one, for the caller to say
233
+ * what went (HK$38,000.00 replaced by HK$39,000.00), and null when there was
234
+ * none or it was the same. `balances` is all the cash after the change.
235
+ */
236
+ export function setPortfolioCash(
237
+ config: AppConfig,
238
+ portfolioId: string,
239
+ cash: PortfolioCash,
240
+ ): { config: AppConfig; replaced: PortfolioCash | null; balances: PortfolioCash[] } {
230
241
  const currency = cash.currency.trim().toUpperCase();
231
242
  if (!Number.isFinite(cash.amount)) throw new Error("Cash amount must be a valid number.");
232
243
  if (!/^[A-Z]{3}$/.test(currency)) throw new Error(`"${cash.currency}" is not a currency code such as USD or EUR.`);
233
- return updatePortfolio(config, portfolioId, (portfolio) => ({ ...portfolio, cash: { amount: cash.amount, currency } }));
244
+ const before = portfolioCashBalances(config.portfolios.find((portfolio) => portfolio.id === portfolioId));
245
+ const previous = before.find((balance) => balance.currency === currency);
246
+ const replaced = previous && previous.amount !== 0 && previous.amount !== cash.amount ? { ...previous } : null;
247
+ // A currency held already keeps its place, so the first balance stays the one an older build reads.
248
+ const balances = previous
249
+ ? before.map((balance) => (balance.currency === currency ? { amount: cash.amount, currency } : balance))
250
+ : [...before, { amount: cash.amount, currency }];
251
+ return {
252
+ config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
253
+ replaced,
254
+ balances,
255
+ };
234
256
  }
235
257
 
236
- export function clearPortfolioCash(config: AppConfig, portfolioId: string): { config: AppConfig; changed: boolean } {
237
- const portfolio = config.portfolios.find((entry) => entry.id === portfolioId);
238
- if (!portfolio?.cash) return { config, changed: false };
258
+ /**
259
+ * Clears a portfolio's cash in one currency, or in every currency when none
260
+ * is given. `removed` is the balances cleared, empty when there was nothing
261
+ * to clear; `balances` is the cash left.
262
+ */
263
+ export function clearPortfolioCash(
264
+ config: AppConfig,
265
+ portfolioId: string,
266
+ currency?: string,
267
+ ): { config: AppConfig; removed: PortfolioCash[]; balances: PortfolioCash[] } {
268
+ const wanted = currency?.trim().toUpperCase();
269
+ const before = portfolioCashBalances(config.portfolios.find((entry) => entry.id === portfolioId));
270
+ const removed = before.filter((balance) => wanted == null || balance.currency === wanted);
271
+ if (removed.length === 0) return { config, removed, balances: before };
272
+ const balances = before.filter((balance) => !removed.includes(balance));
239
273
  return {
240
- config: updatePortfolio(config, portfolioId, ({ cash: _cash, ...rest }) => rest),
241
- changed: true,
274
+ config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
275
+ removed,
276
+ balances,
242
277
  };
243
278
  }
244
279
 
@@ -112,6 +112,7 @@ exports[`the runtime exports of every public subpath are the reviewed ones 1`] =
112
112
  "RangeTrack",
113
113
  "RatioBar",
114
114
  "RemoteImage",
115
+ "RowNote",
115
116
  "Section",
116
117
  "SectionHeading",
117
118
  "SegmentedControl",
@@ -15,6 +15,7 @@ import {
15
15
  } from "../../types/config";
16
16
  import type { DesktopSharedStateSnapshot, OtherWindowTab } from "../../types/desktop-window";
17
17
  import { MAIN_WINDOW_ID, type ExtraWindowRecord } from "./screen-setup";
18
+ import { applyProfileEdits, diffProfile, type ProfileJson } from "../../data/profile-merge";
18
19
 
19
20
  /**
20
21
  * Every full desktop window shows its own layout tabs from one shared config.
@@ -320,6 +321,18 @@ function inSentOrder(layouts: SavedLayout[], sentIds: readonly string[], owns: (
320
321
  return reordered;
321
322
  }
322
323
 
324
+ /**
325
+ * The plugins' settings with what a window changed in them since `before`,
326
+ * value by value, the window's value winning where both changed one: an
327
+ * alert another window or a `gloom` command added since stays when this
328
+ * window's alert check rewrote the same list.
329
+ */
330
+ function mergedPluginConfig(shared: AppConfig["pluginConfig"], before: AppConfig["pluginConfig"], after: AppConfig["pluginConfig"]): AppConfig["pluginConfig"] {
331
+ if (deepEqual(shared, before)) return after;
332
+ const json = (value: AppConfig["pluginConfig"]) => JSON.parse(JSON.stringify(value ?? {})) as ProfileJson;
333
+ return applyProfileEdits(json(shared), diffProfile(json(before), json(after)), { conflicts: "take" }) as AppConfig["pluginConfig"];
334
+ }
335
+
323
336
  /**
324
337
  * Applies what `windowId` sent on top of the shared state, counting only what
325
338
  * changed since `base`, the state the window drew from. Settings and lists
@@ -349,6 +362,7 @@ export function mergeWindowSnapshot(
349
362
  for (const key of new Set([...Object.keys(afterRecord), ...Object.keys(beforeRecord)])) {
350
363
  if (LAYOUT_KEYS.has(key) || deepEqual(afterRecord[key], beforeRecord[key])) continue;
351
364
  if (afterRecord[key] === undefined) delete configRecord[key];
365
+ else if (key === "pluginConfig") configRecord[key] = mergedPluginConfig(state.config.pluginConfig, before.config.pluginConfig, after.config.pluginConfig);
352
366
  else configRecord[key] = afterRecord[key];
353
367
  }
354
368
 
@@ -410,6 +410,8 @@ function WebDataTableRowInner<
410
410
  data-gloom-cell-instant={cell.value instanceof Date && Number.isFinite(cell.value.getTime()) ? cell.value.toISOString() : undefined}
411
411
  // The full-precision number behind a rounded cell (a trade of -9.4596 for -9.45963753), for the same reports.
412
412
  data-gloom-cell-value={typeof cell.value === "number" && Number.isFinite(cell.value) ? String(cell.value) : undefined}
413
+ // A value this row is still waiting on (DataTableCell.mayBeBlank): its blank is no lost data.
414
+ data-gloom-cell-may-be-blank={cell.mayBeBlank ? "true" : undefined}
413
415
  style={{
414
416
  minWidth: 0,
415
417
  position: freezeFirstColumn && columnIndex === 0 ? "sticky" : undefined,
@@ -12,11 +12,36 @@ import { WebIcon, WebIconButton } from "../desktop/icons";
12
12
  import { WebMenu } from "../desktop/menu";
13
13
  import { WebPopover } from "../desktop/popover";
14
14
  import { useHorizontalOverflow } from "./overflow-fade";
15
+ import { FADE_PX } from "./overflow-fade-px";
16
+ import { isLiveResizing, onLiveResizeEnd } from "../../../ui/live-resize";
15
17
  import { useTopSurfaceColor } from "./top-surface";
16
18
  import { hideDragShield, showDragShield } from "./drag-shield";
17
19
 
18
20
  type CssVars = CSSProperties & Record<`--${string}`, string>;
19
21
 
22
+ /**
23
+ * Scrolls a strip so `tab` shows. A title-bar strip also keeps it clear of
24
+ * the fades at its edges (overflow-fade.ts), which would fade the active tab's
25
+ * box and let the header's rule show through it; when the tab cannot clear
26
+ * both, its start shows. At either end the fade on that side goes, so the
27
+ * first and last tabs sit at the edge.
28
+ */
29
+ function revealTab(list: HTMLElement | null, tab: HTMLElement | null, clearOfFades: boolean): void {
30
+ if (!list || !tab) return;
31
+ if (!clearOfFades) {
32
+ tab.scrollIntoView({ block: "nearest", inline: "nearest" });
33
+ return;
34
+ }
35
+ const box = list.getBoundingClientRect();
36
+ const rect = tab.getBoundingClientRect();
37
+ // How far to scroll right: at least this for the tab's end to clear the
38
+ // end fade, at most that for its start to clear the start fade.
39
+ const atLeast = rect.right - (box.right - FADE_PX);
40
+ const atMost = rect.left - (box.left + FADE_PX);
41
+ const delta = atLeast > 0 ? Math.min(atLeast, atMost) : atMost < 0 ? atMost : 0;
42
+ if (delta !== 0) list.scrollLeft += delta;
43
+ }
44
+
20
45
  export function WebTabs({
21
46
  tabs,
22
47
  activeValue,
@@ -61,11 +86,34 @@ export function WebTabs({
61
86
  // Again once the overflow chevron appears: it narrows the strip, which would
62
87
  // otherwise push the last tab's label past the edge.
63
88
  useEffect(() => {
64
- activeTabRef.current?.scrollIntoView({
65
- block: "nearest",
66
- inline: "nearest",
89
+ revealTab(tabListRef.current, activeTabRef.current, header);
90
+ }, [activeValue, tabs, overflowing, header]);
91
+ // A title-bar strip again when it changes width (its pane resized, focus
92
+ // showing the header's buttons), so the active tab stays clear of the fades;
93
+ // after a live resize rather than on every frame of it.
94
+ useEffect(() => {
95
+ const list = tabListRef.current;
96
+ if (!header || !list || typeof ResizeObserver === "undefined") return;
97
+ let width = list.clientWidth;
98
+ let pending = false;
99
+ const reveal = () => revealTab(list, activeTabRef.current, true);
100
+ const observer = new ResizeObserver(() => {
101
+ if (list.clientWidth === width) return;
102
+ width = list.clientWidth;
103
+ if (isLiveResizing()) pending = true;
104
+ else reveal();
67
105
  });
68
- }, [activeValue, tabs, overflowing]);
106
+ const stopListening = onLiveResizeEnd(() => {
107
+ if (!pending) return;
108
+ pending = false;
109
+ reveal();
110
+ });
111
+ observer.observe(list);
112
+ return () => {
113
+ observer.disconnect();
114
+ stopListening();
115
+ };
116
+ }, [header]);
69
117
  useEffect(() => {
70
118
  if (!overflowing) setOverflowMenuOpen(false);
71
119
  }, [overflowing]);
@@ -78,9 +126,8 @@ export function WebTabs({
78
126
  onSelect(value);
79
127
  // Also when the chosen tab was already active, so the effect above does not run.
80
128
  requestAnimationFrame(() => {
81
- tabListRef.current
82
- ?.querySelector<HTMLElement>(`[data-tab-value="${CSS.escape(value)}"]`)
83
- ?.scrollIntoView({ block: "nearest", inline: "nearest" });
129
+ const list = tabListRef.current;
130
+ revealTab(list, list?.querySelector<HTMLElement>(`[data-tab-value="${CSS.escape(value)}"]`) ?? null, header);
84
131
  });
85
132
  };
86
133
  const startReorder = (sourceValue: string, event: ReactMouseEvent<HTMLButtonElement>) => {
@@ -220,7 +267,9 @@ export function WebTabs({
220
267
  "--tab-active-fg": header ? "var(--pane-tab-active-fg)" : palette.activeFg,
221
268
  flex: "0 0 auto",
222
269
  minWidth: 0,
223
- margin: 0,
270
+ // A title-bar tab's margins are its look (styles.css): the active one
271
+ // reaches past the header's rule.
272
+ margin: header ? undefined : 0,
224
273
  transform: `translateX(${dragTranslateX}px)${sourceDragging ? " scale(1.03)" : ""}`,
225
274
  zIndex: dragSourceValue === tab.value ? 2 : undefined,
226
275
  willChange: dragSourceValue ? "transform" : undefined,
@@ -319,8 +319,9 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
319
319
  [data-gloom-role="status-bar"] span {
320
320
  line-height: var(--cell-h);
321
321
  }
322
- /* The returning-user strip under the header: one row of shell chrome, ruled off from the layout. */
323
- [data-gloom-role="since-last-visit"] {
322
+ /* The returning-user strip and the new Pro payer's row under the header: one row of shell chrome each, ruled off from the layout. */
323
+ [data-gloom-role="since-last-visit"],
324
+ [data-gloom-role="pro-welcome"] {
324
325
  flex: none;
325
326
  align-items: center;
326
327
  border-bottom: 1px solid var(--gloom-hairline);
@@ -535,6 +536,9 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
535
536
  /* Header colour left above a box, and the box's line: the header rule's width. */
536
537
  --pane-tab-top-gap: 2px;
537
538
  --pane-tab-rule: 1px;
539
+ /* The strip hangs this far past the rule into the pane (pane/header.tsx says
540
+ why), and only the active tab reaches into it: the others end on the rule. */
541
+ padding-bottom: var(--pane-tab-overhang, 0px);
538
542
  }
539
543
  [data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"] {
540
544
  height: calc(100% - var(--pane-tab-top-gap));
@@ -553,6 +557,10 @@ button, [data-gloom-interactive="true"] { cursor: pointer; }
553
557
  }
554
558
  [data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"]::after { content: none; }
555
559
  [data-gloom-role="tab-list"][data-gloom-variant="header"] > [data-gloom-role="tab-button"][data-active="true"] {
560
+ /* Past the rule into the pane, with the label where it was. */
561
+ height: calc(100% - var(--pane-tab-top-gap) + var(--pane-tab-overhang, 0px));
562
+ margin-bottom: calc(-1 * var(--pane-tab-overhang, 0px));
563
+ padding-bottom: calc(var(--pane-tab-top-gap) + 2 * var(--pane-tab-rule) - var(--pane-tab-top-inset, 0px) + var(--pane-tab-overhang, 0px));
556
564
  background-color: var(--pane-tab-active-bg, var(--gloom-bg));
557
565
  border-color: var(--pane-tab-border, var(--gloom-hairline));
558
566
  }
@@ -1639,13 +1647,13 @@ html[data-gloom-screenshot="true"] [data-gloom-role="chart-watermark"] {
1639
1647
  /* ===== Chrome: title-bar tab overflow, query bar edges, quick-add band ===== */
1640
1648
 
1641
1649
  /* Title-bar tabs that do not fit: a chevron after the strip lists them all.
1642
- The strip hangs over the header's rules; the padding puts the chevron back
1643
- on the header's centre line. */
1650
+ The strip hangs over the header's rules and past the bottom one; the
1651
+ padding puts the chevron back on the header's centre line. */
1644
1652
  .gloom-tab-overflow {
1645
1653
  flex: none;
1646
1654
  display: flex;
1647
1655
  align-items: center;
1648
- padding: var(--pane-tab-top-inset, 0px) 0 1px 2px;
1656
+ padding: var(--pane-tab-top-inset, 0px) 0 calc(1px + var(--pane-tab-overhang, 0px)) 2px;
1649
1657
  }
1650
1658
 
1651
1659
  /* A search with nothing beside it takes the room filters would have used. */
@@ -67,6 +67,10 @@ export async function handleDesktopBackendRequest(
67
67
  return null;
68
68
  case "ticker.loadAll":
69
69
  return backend.requireServices().tickerRepository.loadAllTickers();
70
+ case "ticker.changesElsewhere":
71
+ return backend.requireServices().tickerRepository.changesElsewhere?.() ?? null;
72
+ case "ticker.takeDeletedElsewhere":
73
+ return backend.requireServices().tickerRepository.takeRowsDeletedElsewhere?.() ?? [];
70
74
  case "ticker.load":
71
75
  return backend.requireServices().tickerRepository.loadTicker(request.payload.symbol);
72
76
  case "ticker.save":
@@ -7,7 +7,7 @@ import {
7
7
  reconcileAppSessionSnapshot,
8
8
  type AppSessionSnapshot,
9
9
  } from "../../../../core/state/session-persistence";
10
- import { saveConfig } from "../../../../data/config/store";
10
+ import { saveConfig, watchExternalConfigChanges } from "../../../../data/config/store";
11
11
  import { pluginAutoUpdateEnabled } from "../../../../plugins/auto-update";
12
12
  import { startNodePluginAutoUpdates } from "../../../../plugins/auto-update-node";
13
13
  import { getPluginSeedProgress, subscribePluginSeed } from "../../../../plugins/seed-progress";
@@ -167,6 +167,7 @@ export class DesktopBackend {
167
167
  private pluginAutoUpdatesStarted = false;
168
168
  private commandLinksScheduled = false;
169
169
  private remoteControlServer: RemoteControlServer | null = null;
170
+ private stopWatchingConfig: (() => void) | null = null;
170
171
  private readonly pendingDeepLinks: string[] = [];
171
172
  private readonly contextMenuRequestRpcs = new Map<string, DesktopRpc>();
172
173
  /** Extra windows open once the main window has drawn, like popped-out panes. */
@@ -494,15 +495,33 @@ export class DesktopBackend {
494
495
  });
495
496
  this.workspace = createDesktopWorkspace(config, this.getSessionSnapshot(), this.windowController?.screenSetup.windows);
496
497
  this.reconcileWindows();
498
+ this.watchConfigWrittenElsewhere(config.dataDir);
497
499
  return { config, services };
498
500
  }
499
501
 
502
+ /**
503
+ * A `gloom` command run beside the app writes the same config.json (an
504
+ * alert, a setting, a watchlist): the change is taken in and shown in every
505
+ * window, so no save of the app's copy writes over it.
506
+ */
507
+ private watchConfigWrittenElsewhere(dataDir: string): void {
508
+ this.stopWatchingConfig?.();
509
+ this.stopWatchingConfig = watchExternalConfigChanges(dataDir, (change) => {
510
+ if (!this.config || !this.workspace) return;
511
+ const next = change.apply(this.config);
512
+ if (next === this.config) return;
513
+ this.commitDesktopSnapshotInBackground(this.workspace.replaceConfig(next, { layoutChanged: false }), { persistConfig: false });
514
+ });
515
+ }
516
+
500
517
  /** Compiles the view's plugins ahead of its first `plugins.listExternal`. */
501
518
  prefetchExternalPluginBundles(): void {
502
519
  prefetchExternalPluginBundles();
503
520
  }
504
521
 
505
522
  teardownServices(): void {
523
+ this.stopWatchingConfig?.();
524
+ this.stopWatchingConfig = null;
506
525
  this.stopRemoteControlServer();
507
526
  this.capabilityBridge.disposeAll();
508
527
  this.httpStreamBridge.disposeAll();
@@ -908,6 +927,8 @@ export class DesktopBackend {
908
927
  case "update.start":
909
928
  case "update.apply":
910
929
  case "ticker.loadAll":
930
+ case "ticker.changesElsewhere":
931
+ case "ticker.takeDeletedElsewhere":
911
932
  case "ticker.load":
912
933
  case "ticker.save":
913
934
  case "ticker.delete":
@@ -187,7 +187,12 @@ function fromPrivateSource<T>(source: string, compile: (path: string) => T): T {
187
187
  writeFileSync(path, source, { flag: "wx", mode: 0o600 });
188
188
  return compile(path);
189
189
  } finally {
190
- rmSync(folder, { recursive: true, force: true });
190
+ // Windows can still hold the file for a moment; a folder left behind must not cost the window its minimum size.
191
+ try {
192
+ rmSync(folder, { recursive: true, force: true });
193
+ } catch (error) {
194
+ logFailure("window", "Could not remove the minimum size helper's temporary folder")(error);
195
+ }
191
196
  }
192
197
  }
193
198
 
@@ -272,6 +272,10 @@ interface DesktopBackendRequestMap {
272
272
  /** Installs the staged update and relaunches. Sent only when the user presses Restart. */
273
273
  "update.apply": { request: null; response: null };
274
274
  "ticker.loadAll": { request: null; response: TickerRecord[] };
275
+ /** Changes when another program commits to the database (`TickerStore.changesElsewhere`). */
276
+ "ticker.changesElsewhere": { request: null; response: number | null };
277
+ /** The rows another program deleted that the backend held (`TickerRepository.takeRowsDeletedElsewhere`). */
278
+ "ticker.takeDeletedElsewhere": { request: null; response: string[] };
275
279
  "ticker.load": { request: { symbol: string }; response: TickerRecord | null };
276
280
  "ticker.save": { request: { ticker: TickerRecord }; response: null };
277
281
  "ticker.delete": { request: { symbol: string }; response: null };