gloomberb 0.20.4 → 0.20.6

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 (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. package/src/utils/untrusted-text.ts +29 -0
@@ -643,12 +643,6 @@ export function formatEventTime(eventAt: number): string {
643
643
  return new Date(eventAt).toISOString().slice(0, 16).replace("T", " ");
644
644
  }
645
645
 
646
- export function formatAsOf(asOf: string | null): string | null {
647
- if (!asOf) return null;
648
- const parsed = Date.parse(asOf);
649
- return Number.isFinite(parsed) ? `${formatEventTime(parsed)} UTC` : asOf;
650
- }
651
-
652
646
  export function formatMaturity(maturity: string | null): string {
653
647
  return maturity ?? "--";
654
648
  }
@@ -1,6 +1,7 @@
1
1
  import { currencyPairSpelling } from "../../../utils/currency-pair";
2
2
  import { dashedCoinPair } from "../../../utils/crypto-pair";
3
3
  import { GALLONS_PER_BARREL, isBarrelsPerTonne } from "../../../time-series/price-units";
4
+ import { BP_PER_PERCENT } from "../../../time-series/studies/units";
4
5
  import { MAX_CHART_COMPOSER_SERIES } from "./chart-spec";
5
6
  import { parseSeriesExpression, resolveChartFieldAlias, type ParsedSeriesExpression } from "./series-expression";
6
7
  import { getTimeSeriesField } from "../../../time-series/field-catalog";
@@ -17,8 +18,10 @@ import { getTimeSeriesField } from "../../../time-series/field-catalog";
17
18
  *
18
19
  * A literal 42 on a series is the 42 gallons of a barrel: it makes a price per
19
20
  * gallon a price per barrel. A literal 7.45 or 8.45 is the barrels in a tonne
20
- * of gasoil or gasoline: it makes a price per barrel a price per tonne. Any
21
- * other number is a count and keeps the unit. A series the whole formula is
21
+ * of gasoil or gasoline: it makes a price per barrel a price per tonne. A
22
+ * literal 100 makes a percent basis points (0.93% is 93bp), and 0.01 basis
23
+ * points a percent. Any other number is a count and keeps the unit. A series
24
+ * the whole formula is
22
25
  * divided or multiplied by changes its unit as the arithmetic does: over
23
26
  * EURUSD=X (USD per EUR), dollars are euros.
24
27
  *
@@ -37,6 +40,8 @@ interface FormulaLeg {
37
40
  perBarrel: boolean;
38
41
  /** The barrels in a tonne the leg was multiplied by (7.45 or 8.45), or null. */
39
42
  perTonne: number | null;
43
+ /** The leg was multiplied by a literal 100 (1: a percent in bp) or 0.01 (-1: bp in percent), or neither. */
44
+ percentBp: 1 | -1 | null;
40
45
  /** The leg as written: `HO=F`. */
41
46
  text: string;
42
47
  }
@@ -136,6 +141,11 @@ function tokenize(expression: string): Token[] {
136
141
  return tokens;
137
142
  }
138
143
 
144
+ /** A literal 100 makes a percent basis points (1), 0.01 basis points a percent (-1); any other number neither. */
145
+ function percentBasisPointFactor(value: number): 1 | -1 | null {
146
+ return value === BP_PER_PERCENT ? 1 : value === 1 / BP_PER_PERCENT ? -1 : null;
147
+ }
148
+
139
149
  function fail(message: string): never {
140
150
  throw new Error(message);
141
151
  }
@@ -192,6 +202,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
192
202
  let weight = sign;
193
203
  let perBarrel = false;
194
204
  let perTonne: number | null = null;
205
+ let percentBp: 1 | -1 | null = null;
195
206
  const factors: Token[] = [];
196
207
  for (;;) {
197
208
  const factor = take();
@@ -206,6 +217,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
206
217
  if (factor.value === 0) fail("A multiplier of 0 removes its series; leave the term out instead.");
207
218
  if (factor.value === GALLONS_PER_BARREL && !perBarrel) perBarrel = true;
208
219
  else if (isBarrelsPerTonne(factor.value) && perTonne === null) perTonne = factor.value;
220
+ else if (percentBp === null) percentBp = percentBasisPointFactor(factor.value);
209
221
  weight *= factor.value;
210
222
  }
211
223
  if (peek()?.kind !== "*") break;
@@ -224,7 +236,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
224
236
  if (legs.some((leg) => leg.text.toUpperCase() === text.toUpperCase())) {
225
237
  fail(`${text} appears twice. Write it once with its combined multiplier, such as 2*${text}.`);
226
238
  }
227
- legs.push({ series: parsed, weight, perBarrel, perTonne, text });
239
+ legs.push({ series: parsed, weight, perBarrel, perTonne, percentBp, text });
228
240
  expectTerm = false;
229
241
 
230
242
  const next = peek();
@@ -261,6 +273,7 @@ export function parseFormulaExpression(expression: string): ParsedFormula | null
261
273
  for (const leg of legs) {
262
274
  if (value.value === GALLONS_PER_BARREL && !leg.perBarrel) leg.perBarrel = true;
263
275
  else if (isBarrelsPerTonne(value.value) && leg.perTonne === null) leg.perTonne = value.value;
276
+ else if (leg.percentBp === null) leg.percentBp = percentBasisPointFactor(value.value);
264
277
  leg.weight *= value.value;
265
278
  }
266
279
  }
@@ -202,6 +202,8 @@ export const paneSchemas = {
202
202
  { value: "operatingMargin", aliases: ["operating margin"] },
203
203
  { value: "netIncome", aliases: ["net income", "profit", "earnings"] },
204
204
  { value: "netMargin", aliases: ["net margin", "profit margin"] },
205
+ { value: "ebitda", aliases: ["ebitda", "operating income plus d&a"] },
206
+ { value: "depreciationAndAmortization", aliases: ["d&a", "da", "depreciation", "depreciation and amortization"] },
205
207
  { value: "operatingCashFlow", aliases: ["operating cash flow", "cash flow", "ocf"] },
206
208
  { value: "freeCashFlow", aliases: ["free cash flow", "fcf"] },
207
209
  { value: "freeCashFlowMargin", aliases: ["free cash flow margin", "fcf margin"] },
@@ -30,6 +30,7 @@ import type { HistorySession } from "../../../types/price-history";
30
30
  import type { TickerFinancials, PricePoint, Quote } from "../../../types/financials";
31
31
  import { chartQuoteOverrideKeyForTarget, getLiveChartQuoteTargets } from "../../../time-series/live-quotes";
32
32
  import { createChartSeriesResolver } from "../../../capabilities";
33
+ import { uncoveredCapabilityMessage } from "../../../capabilities/chart-series";
33
34
  import { loadFuturesContractTerms, loadFuturesPriceUnit } from "../../../market-data/futures-contract";
34
35
  import { loadDailyFxCloses } from "../../../time-series/currency-conversion";
35
36
  import { canonicalExchange, isKnownExchangeCode, isUsListingExchange, parsePublicTickerKey, publicTickerKey } from "../../../utils/exchanges";
@@ -86,7 +87,7 @@ function headlessCapabilityResolver(context: HeadlessPaneContext) {
86
87
  const request = <T,>(path: string, init?: RequestInit) => context.apiClient.geo<T>(path, { ...init, signal: init?.signal ?? context.signal });
87
88
  return resolveGeoChartSeries(request, source.seriesId, viewport, context.signal);
88
89
  }
89
- if (!registry) throw new Error(`Chart series capability "${source.capabilityId}" is unavailable. Enable its plugin or provider.`);
90
+ if (!registry) throw new Error(uncoveredCapabilityMessage(source.capabilityId, source.seriesId));
90
91
  return registry(source, viewport, spec);
91
92
  };
92
93
  }
@@ -251,7 +252,8 @@ export async function loadChartPaneModel(
251
252
  errors: [...chart.errors, ...chart.series.filter((series) => series.unreportedPeriod && series.points.length === 0)
252
253
  .map((series) => `${series.label}: no ${series.unreportedPeriod} figures are reported; use --period annual.`)],
253
254
  unavailableSymbols: spec.series.filter((series) => series.visible !== false).flatMap((series) => {
254
- if (chart.series.some((output) => output.id === series.id && output.points.some((point) => point.value !== null && Number.isFinite(point.value)))) return [];
255
+ if (chart.series.some((output) => output.id === series.id && (output.notMeaningful
256
+ || output.points.some((point) => point.value !== null && Number.isFinite(point.value))))) return [];
255
257
  const source = series.source;
256
258
  return [source.kind === "security"
257
259
  ? publicTickerKey(source.instrument.symbol, source.instrument.exchange)
@@ -520,6 +520,7 @@ export const chartComposerModule: PluginModule = {
520
520
  icon: "G",
521
521
  component: ChartComposerPane,
522
522
  defaultPosition: "right",
523
+ shareItem: { ticker: true },
523
524
  tickerFollower: chartShowsOneSecurity,
524
525
  retargetTicker: retargetChartTicker,
525
526
  defaultMode: "floating",
@@ -109,6 +109,7 @@ function formulaStudy(formula: ParsedFormula, inputSeriesIds: string[]): ChartSt
109
109
  parameters[`weight${index + 1}`] = leg.weight;
110
110
  if (leg.perBarrel) parameters[`perBarrel${index + 1}`] = 1;
111
111
  if (leg.perTonne) parameters[`perTonne${index + 1}`] = leg.perTonne;
112
+ if (leg.percentBp) parameters[`percentBp${index + 1}`] = leg.percentBp;
112
113
  });
113
114
  formula.factors.forEach((factor, index) => {
114
115
  parameters[`power${formula.legs.length + index + 1}`] = factor.power;
@@ -279,7 +279,7 @@ export function getChatComposerAreaHeight({
279
279
  replyTo,
280
280
  mentionSuggestionCount,
281
281
  draftAttachmentCount = 0,
282
- draftLinkCount = 0,
282
+ draftLinkRows = 0,
283
283
  promptRows = 0,
284
284
  }: {
285
285
  canSend: boolean;
@@ -290,8 +290,8 @@ export function getChatComposerAreaHeight({
290
290
  mentionSuggestionCount?: number;
291
291
  /** The terminal draws a row per waiting image; the desktop strip sizes itself. */
292
292
  draftAttachmentCount?: number;
293
- /** The same for waiting share links, which an edit shows too. */
294
- draftLinkCount?: number;
293
+ /** The terminal rows the waiting share links' cards take, which an edit shows too; the desktop strip sizes itself. */
294
+ draftLinkRows?: number;
295
295
  /** Terminal rows the handle prompt above the composer takes. */
296
296
  promptRows?: number;
297
297
  }) {
@@ -300,5 +300,6 @@ export function getChatComposerAreaHeight({
300
300
  + (editingMessage || replyTo ? 1 : 0)
301
301
  + Math.max(0, mentionSuggestionCount ?? 0)
302
302
  + (!nativePaneChrome && !editingMessage ? draftAttachmentCount : 0)
303
- + (!nativePaneChrome ? draftLinkCount : 0);
303
+ // The waiting share links' cards, each as tall as what it says.
304
+ + (!nativePaneChrome ? draftLinkRows : 0);
304
305
  }
@@ -60,6 +60,9 @@ import { openChatPaneLink } from "../pane-links/open";
60
60
  import { runChatCommand, useChatFunctions } from "../pane-links/commands";
61
61
  import type { ChatMessagePaneLink } from "../pane-links/model";
62
62
  import { splitComposerDraft, type ComposerShareLink } from "../pane-links/composer";
63
+ import { useSharePreviewStates } from "../pane-links/previews";
64
+ import { terminalChatPaneChipRows } from "../pane-links/share-card";
65
+ import { terminalComposerChipWidth } from "../message/pane-chip";
63
66
  import { teamStore } from "../../../../team/store";
64
67
  import { requestAccountManagementTab } from "../../account-management/navigation";
65
68
  import {
@@ -377,6 +380,13 @@ function ChatConversation({
377
380
  useEffect(() => {
378
381
  setMentionSelectedIndex(0);
379
382
  }, [suggestionTriggerKey]);
383
+ // The waiting links' cards are as tall as what they say, which changes as each share is read.
384
+ const draftLinkStates = useSharePreviewStates(nativePaneChrome ? [] : draftLinks.map((link) => link.id));
385
+ const draftLinkRows = useMemo(
386
+ () => draftLinks.reduce((rows, link) => rows + terminalChatPaneChipRows(link, terminalComposerChipWidth(contentWidth)), 0),
387
+ // The rows are read from the share previews' cache, which `draftLinkStates` follows.
388
+ [contentWidth, draftLinkStates, draftLinks],
389
+ );
380
390
  const {
381
391
  composerHeight,
382
392
  messageAreaHeight,
@@ -390,7 +400,7 @@ function ChatConversation({
390
400
  replyTo,
391
401
  stackHeader: stackedNav && !channelListOpen,
392
402
  draftAttachmentCount: draftAttachments.length,
393
- draftLinkCount: draftLinks.length,
403
+ draftLinkRows,
394
404
  promptRows: canSend && !nativePaneChrome ? chatHandlePromptRows(handlePrompt, contentWidth) : 0,
395
405
  });
396
406
  const {
@@ -948,7 +958,7 @@ function ChatConversation({
948
958
  setSelectedIdx,
949
959
  stickyTranscript,
950
960
  useDefaultControllerChannel,
951
- composerLayoutKey: `${editingMessage ? "" : draftAttachments.map((attachment) => attachment.status).join(",")}:${draftLinks.length}`,
961
+ composerLayoutKey: `${editingMessage ? "" : draftAttachments.map((attachment) => attachment.status).join(",")}:${draftLinks.length}:${draftLinkRows}`,
952
962
  highlightMessage,
953
963
  clearHover,
954
964
  clearHighlight,
@@ -49,7 +49,7 @@ export function resolveChatContentHeightMetrics({
49
49
  replyTo,
50
50
  stackHeader = false,
51
51
  draftAttachmentCount = 0,
52
- draftLinkCount = 0,
52
+ draftLinkRows = 0,
53
53
  promptRows = 0,
54
54
  }: {
55
55
  canSend: boolean;
@@ -62,7 +62,7 @@ export function resolveChatContentHeightMetrics({
62
62
  /** The narrow stack's Back row is drawn above the transcript. */
63
63
  stackHeader?: boolean;
64
64
  draftAttachmentCount?: number;
65
- draftLinkCount?: number;
65
+ draftLinkRows?: number;
66
66
  /** Terminal rows the handle prompt above the composer takes. */
67
67
  promptRows?: number;
68
68
  }) {
@@ -79,7 +79,7 @@ export function resolveChatContentHeightMetrics({
79
79
  nativePaneChrome,
80
80
  replyTo,
81
81
  draftAttachmentCount,
82
- draftLinkCount,
82
+ draftLinkRows,
83
83
  promptRows,
84
84
  });
85
85
  // In the terminal the Back row replaces the top rule.
@@ -3,7 +3,7 @@ import type { ChatAttachment } from "../../../../api-client";
3
3
  import { chatMessageTokens } from "../markdown";
4
4
  import { chatImageLabel } from "../attachments/model";
5
5
  import { wirePaneTarget, type ChatMessagePaneLink } from "../pane-links/model";
6
- import { chatPaneLinkPane, peekSharePreview } from "../pane-links/previews";
6
+ import { chatPaneLinkPane, peekSharePreview, sharePreviewTitle } from "../pane-links/previews";
7
7
  import { resolveChatCommand, type ChatFunction } from "../pane-links/commands";
8
8
 
9
9
  export type ChatOpenTarget =
@@ -12,12 +12,12 @@ export type ChatOpenTarget =
12
12
  | { kind: "link"; url: string; label: string }
13
13
  | { kind: "image"; index: number; url: string; label: string };
14
14
 
15
- /** What the Open list calls a chip: the share's title once read, else its link; a Wire post's pane; a function as written. */
15
+ /** What the Open list calls a chip: the share's item or title once read, else its link; a Wire post's pane; a function as written. */
16
16
  function paneLinkLabel(link: ChatMessagePaneLink): string {
17
17
  if (link.kind === "command") return link.query;
18
18
  if (link.kind === "share") {
19
19
  const preview = peekSharePreview(link.id);
20
- return preview.status === "ready" ? preview.title : link.url;
20
+ return preview.status === "ready" ? sharePreviewTitle(preview) : link.url;
21
21
  }
22
22
  const target = wirePaneTarget(link.link);
23
23
  const name = chatPaneLinkPane(target.paneId)?.name ?? target.name;
@@ -13,6 +13,7 @@ import type { InlineTickerCatalogEntry } from "../../../state/hooks/inline-ticke
13
13
  import { STICKY_BOTTOM_THRESHOLD_PX } from "../../../ui/sticky-scroll";
14
14
  import { terminalReactionRows } from "./reactions";
15
15
  import { chatMessagePaneLinks } from "./pane-links/model";
16
+ import { terminalChatPaneChipRows } from "./pane-links/share-card";
16
17
  import { chatInlineTokens, type ChatInlineToken, type ChatTextStyle } from "./markdown";
17
18
 
18
19
  const MESSAGE_GROUP_THRESHOLD_MS = 5 * 60 * 1000;
@@ -329,7 +330,7 @@ export function estimateMessageHeight(
329
330
  const headerHeight = grouped ? 0 : 1;
330
331
  const contentLineWidth = Math.max(width - 4, 1);
331
332
  const imageCount = message.attachments?.length ?? 0;
332
- // A chip row for each share link or Wire post link, in place of the link's text.
333
+ // A share link's card rows or a Wire post link's chip row, in place of the link's text.
333
334
  const { links, content } = chatMessagePaneLinks(message);
334
335
  // The terminal draws a row per image and one for a review note; an image-only message has no text row.
335
336
  const bodyLineCount = content.length === 0 && (imageCount > 0 || links.length > 0)
@@ -337,7 +338,9 @@ export function estimateMessageHeight(
337
338
  : getMessageBodyTokenLines(content, contentLineWidth, catalog ?? {}).length;
338
339
  const reviewNoteHeight = message.attachmentReview ? 1 : 0;
339
340
  const reactionRows = message.reactions?.length ? terminalReactionRows(message.reactions, contentLineWidth).length : 0;
340
- return headerHeight + (message.replyTo ? 1 : 0) + bodyLineCount + links.length + imageCount + reviewNoteHeight + reactionRows;
341
+ // A share's card is as tall as what it says, as it reads now.
342
+ const linkRows = links.reduce((rows, link) => rows + terminalChatPaneChipRows(link, contentLineWidth), 0);
343
+ return headerHeight + (message.replyTo ? 1 : 0) + bodyLineCount + linkRows + imageCount + reviewNoteHeight + reactionRows;
341
344
  }
342
345
 
343
346
  export function estimateComposerHeight(text: string, width: number) {
@@ -1,8 +1,11 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { ChatAttachment } from "../../../../api-client";
2
3
  import {
3
4
  DesktopPaneLinkChip,
4
5
  IconButton,
5
6
  TerminalPaneLinkChip,
7
+ TerminalPaneLinkItemCard,
8
+ terminalItemCardRows,
6
9
  type PaneLinkChipContent,
7
10
  } from "../../../../components/ui";
8
11
  import { tf } from "../../../../i18n";
@@ -10,15 +13,16 @@ import { Box } from "../../../../ui";
10
13
  import { colors } from "../../../../theme/colors";
11
14
  import { wirePaneTarget, type ChatMessagePaneLink } from "../pane-links/model";
12
15
  import { chatPaneLinkPane, useSharePreview } from "../pane-links/previews";
16
+ import { shareCardContent } from "../pane-links/share-card";
13
17
  import type { ComposerShareLink } from "../pane-links/composer";
14
18
  import { DESKTOP_DRAFT_STRIP_STYLE } from "../attachments/desktop";
15
19
 
16
20
  /**
17
- * A chip for something a message opens in the terminal: a shared pane (its
18
- * title and the pane it is, with the picture its sender posted when there is
19
- * one), a Gloom Wire post's story or calendar, or a function written in
20
- * backticks, drawn in its line of text. It always takes the same room, before
21
- * and after the share is read, so the transcript never moves.
21
+ * A chip for something a message opens in the terminal: a shared pane as a
22
+ * card (the item it was on, a line or two of it and the pane it opens, with
23
+ * the picture its sender posted when there is one), a Gloom Wire post's story
24
+ * or calendar, or a function written in backticks, drawn in its line of text.
25
+ * A share's card is as tall as what it says; the other chips keep one height.
22
26
  */
23
27
 
24
28
  /** What a chip says, from the share or the post and nothing of the reader's own. */
@@ -26,15 +30,7 @@ function useChatPaneChipContent(link: ChatMessagePaneLink): PaneLinkChipContent
26
30
  const shareId = link.kind === "share" ? link.id : "";
27
31
  const preview = useSharePreview(shareId);
28
32
  if (link.kind === "command") return { title: link.query, detail: link.name, icon: "" };
29
- if (link.kind === "share") {
30
- if (preview.status !== "ready") return { title: link.url, detail: "", icon: "" };
31
- const pane = chatPaneLinkPane(preview.paneId);
32
- return {
33
- title: preview.title,
34
- detail: pane && pane.name !== preview.title ? pane.name : "",
35
- icon: pane?.icon ?? "",
36
- };
37
- }
33
+ if (link.kind === "share") return shareCardContent(link.url, preview);
38
34
  const target = wirePaneTarget(link.link);
39
35
  const pane = chatPaneLinkPane(target.paneId);
40
36
  return { title: pane?.name ?? target.name, detail: target.day ?? "", icon: pane?.icon ?? "" };
@@ -71,7 +67,7 @@ export function DesktopChatPaneChip({
71
67
  return (
72
68
  <DesktopPaneLinkChip
73
69
  content={content}
74
- variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "card"}
70
+ variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "item"}
75
71
  picture={link.kind === "command" ? null : preview}
76
72
  dimmed={dimmed}
77
73
  onOpen={() => onOpen(link)}
@@ -109,7 +105,16 @@ export function DesktopComposerPaneChips({
109
105
  );
110
106
  }
111
107
 
112
- /** The terminal's composer rows for waiting share links: the chip a message draws, then its x at the row's end. */
108
+ /** How wide a waiting link's card is in the terminal's composer of `width`: lined up with the field's text, its x after it. */
109
+ export function terminalComposerChipWidth(width: number): number {
110
+ return Math.max(1, width - COMPOSER_CHIP_INSET - COMPOSER_CHIP_REMOVE_WIDTH - 1);
111
+ }
112
+
113
+ // Lined up with the field's text after its prompt, as a message's chips line up with its text.
114
+ const COMPOSER_CHIP_INSET = 3;
115
+ const COMPOSER_CHIP_REMOVE_WIDTH = 3;
116
+
117
+ /** The terminal's composer rows for waiting share links: the card a message draws, then its x at the end of its first row. */
113
118
  export function TerminalComposerPaneChips({
114
119
  links,
115
120
  width,
@@ -122,24 +127,24 @@ export function TerminalComposerPaneChips({
122
127
  /** Takes out the chip at this place in `links`, as on the desktop. */
123
128
  onRemove: (index: number) => void;
124
129
  }) {
125
- // Lined up with the field's text after its prompt, as a message's chips line up with its text.
126
- const inset = 3;
127
- const removeWidth = 3;
128
130
  return (
129
131
  <>
130
132
  {links.map((link, index) => (
131
- <Box key={`${index}:${link.id}`} width={width} height={1} flexDirection="row">
132
- <Box width={inset} />
133
- <TerminalChatPaneChip
134
- link={link}
135
- width={Math.max(1, width - inset - removeWidth - 1)}
136
- selected={false}
137
- selectedTextColor={colors.textBright}
138
- onOpen={onOpen}
139
- />
133
+ <TerminalChatPaneChipRow
134
+ key={`${index}:${link.id}`}
135
+ link={link}
136
+ width={terminalComposerChipWidth(width)}
137
+ rowProps={{ width }}
138
+ selected={false}
139
+ selectedTextColor={colors.textBright}
140
+ onOpen={onOpen}
141
+ lead={<Box width={COMPOSER_CHIP_INSET} />}
142
+ >
140
143
  <Box flexGrow={1} />
141
- <TerminalComposerChipRemove link={link} onRemove={() => onRemove(index)} />
142
- </Box>
144
+ <Box height={1}>
145
+ <TerminalComposerChipRemove link={link} onRemove={() => onRemove(index)} />
146
+ </Box>
147
+ </TerminalChatPaneChipRow>
143
148
  ))}
144
149
  </>
145
150
  );
@@ -147,31 +152,47 @@ export function TerminalComposerPaneChips({
147
152
 
148
153
  function TerminalComposerChipRemove({ link, onRemove }: { link: ComposerShareLink; onRemove: () => void }) {
149
154
  const content = useChatPaneChipContent(link);
150
- return <IconButton icon="close" label={tf("Remove {name}", { name: content.title })} onPress={onRemove} />;
155
+ return <IconButton icon="close" label={tf("Remove {name}", { name: content.title || content.detail })} onPress={onRemove} />;
151
156
  }
152
157
 
153
- /** One row in the terminal: the pane's letter, the title and the pane, cut to the line. */
154
- export function TerminalChatPaneChip({
158
+ /**
159
+ * A chip's row in the terminal, as tall as the chip: a share's card as it
160
+ * reads now, or one row. `lead` goes before the chip and `children` after it.
161
+ */
162
+ export function TerminalChatPaneChipRow({
155
163
  link,
156
164
  width,
165
+ rowProps,
157
166
  selected,
158
167
  selectedTextColor,
159
168
  onOpen,
169
+ lead,
170
+ children,
160
171
  }: {
161
172
  link: ChatMessagePaneLink;
173
+ /** The chip's own width. */
162
174
  width: number;
175
+ rowProps: Record<string, unknown>;
163
176
  selected: boolean;
164
177
  selectedTextColor: string;
165
178
  onOpen: (link: ChatMessagePaneLink) => void;
179
+ lead?: ReactNode;
180
+ children?: ReactNode;
166
181
  }) {
167
182
  const content = useChatPaneChipContent(link);
183
+ const share = link.kind === "share";
184
+ const Chip = share ? TerminalPaneLinkItemCard : TerminalPaneLinkChip;
168
185
  return (
169
- <TerminalPaneLinkChip
170
- content={content}
171
- width={width}
172
- selected={selected}
173
- selectedTextColor={selectedTextColor}
174
- onOpen={() => onOpen(link)}
175
- />
186
+ <Box {...rowProps} height={share ? terminalItemCardRows(content, width) : 1} flexDirection="row">
187
+ {lead}
188
+ <Chip
189
+ content={content}
190
+ width={width}
191
+ selected={selected}
192
+ selectedTextColor={selectedTextColor}
193
+ onOpen={() => onOpen(link)}
194
+ />
195
+ {children}
196
+ </Box>
176
197
  );
177
198
  }
@@ -11,7 +11,7 @@ import { Button } from "../../../../components/ui";
11
11
  import { canReactToMessage } from "../reactions";
12
12
  import { TerminalChatReactions } from "./reactions";
13
13
  import { TerminalChatMessageRow } from "./inline-tokens";
14
- import { TerminalChatPaneChip } from "./pane-chip";
14
+ import { TerminalChatPaneChipRow } from "./pane-chip";
15
15
  import { chatMessagePaneLinks } from "../pane-links/model";
16
16
  import { useSlowPendingSend } from "./pending-send";
17
17
  import { getChatMessageRenderState } from "./render-state";
@@ -167,23 +167,21 @@ export function TerminalChatMessage({
167
167
  </Box>
168
168
  ))}
169
169
  {paneLinks.map((link, linkIndex) => (
170
- <Box
170
+ <TerminalChatPaneChipRow
171
171
  key={`${msg.id}:pane:${link.kind === "share" ? link.id : link.link.kind}`}
172
- {...messageRowProps}
173
- paddingLeft={3}
174
- height={1}
175
- flexDirection="row"
176
- position={state.grouped && bodyLines.length === 0 && linkIndex === 0 ? "relative" : undefined}
172
+ link={link}
173
+ width={messageBodyWidth}
174
+ rowProps={{
175
+ ...messageRowProps,
176
+ paddingLeft: 3,
177
+ position: state.grouped && bodyLines.length === 0 && linkIndex === 0 ? "relative" : undefined,
178
+ }}
179
+ selected={state.isSelected}
180
+ selectedTextColor={state.selectedTextColor}
181
+ onOpen={openPaneLink}
177
182
  >
178
- <TerminalChatPaneChip
179
- link={link}
180
- width={messageBodyWidth}
181
- selected={state.isSelected}
182
- selectedTextColor={state.selectedTextColor}
183
- onOpen={openPaneLink}
184
- />
185
183
  {state.grouped && bodyLines.length === 0 && linkIndex === 0 && <ChatMessageActions floating {...actionProps} />}
186
- </Box>
184
+ </TerminalChatPaneChipRow>
187
185
  ))}
188
186
  {attachments.map((attachment, imageIndex) => (
189
187
  <Box
@@ -1,14 +1,25 @@
1
1
  import { useCallback, useSyncExternalStore } from "react";
2
2
  import { getShare } from "../../../../shares/api";
3
+ import type { ShareItem } from "../../../../shares/item";
4
+ import { plainUntrustedLine } from "../../../../utils/untrusted-text";
3
5
  import type { PaneDef } from "../../../../types/plugin";
4
6
 
5
7
  /**
6
8
  * What a share chip shows, read from the share itself and nothing else: its
7
- * title and the pane it holds. The read does not count as a view of the share.
9
+ * title, the pane it holds and what that pane says it is, and the item the
10
+ * pane was on when it was shared. The read does not count as a view of the
11
+ * share.
8
12
  */
9
13
  export type SharePreview =
10
14
  | { status: "loading" }
11
- | { status: "ready"; title: string; paneId: string | null }
15
+ | {
16
+ status: "ready";
17
+ title: string;
18
+ paneId: string | null;
19
+ /** The pane's own description, kept with shares made before items were. */
20
+ description?: string;
21
+ item?: ShareItem;
22
+ }
12
23
  | { status: "unavailable" };
13
24
 
14
25
  const LOADING: SharePreview = { status: "loading" };
@@ -61,10 +72,19 @@ function pump(): void {
61
72
  settle(id, { status: "unavailable" }, false);
62
73
  return;
63
74
  }
64
- const paneId = share.kind === "pane" && share.data.version === 2
65
- ? share.data.layout.layout.instances[0]?.paneId ?? null
75
+ const pane = share.kind === "pane" ? share : null;
76
+ const paneId = pane?.data.version === 2
77
+ ? pane.data.layout.layout.instances[0]?.paneId ?? null
66
78
  : null;
67
- settle(id, { status: "ready", title: share.data.title, paneId }, false);
79
+ // The sender's app wrote the title and description: plain lines, as its item is (parseShareItem).
80
+ const description = pane?.data.description ? plainUntrustedLine(pane.data.description) : "";
81
+ settle(id, {
82
+ status: "ready",
83
+ title: plainUntrustedLine(share.data.title),
84
+ paneId,
85
+ ...(description ? { description } : {}),
86
+ ...(pane?.item ? { item: pane.item } : {}),
87
+ }, false);
68
88
  })
69
89
  .catch(() => settle(id, LOADING, true))
70
90
  .finally(() => {
@@ -83,11 +103,37 @@ function request(id: string): void {
83
103
  pump();
84
104
  }
85
105
 
106
+ /** What a share is called where one line names it (the Open list): the item it is on, else its own title. */
107
+ export function sharePreviewTitle(preview: Extract<SharePreview, { status: "ready" }>): string {
108
+ return preview.item?.title ?? preview.title;
109
+ }
110
+
86
111
  /** What chips show for a share now, for code outside React (the Open list). */
87
112
  export function peekSharePreview(id: string): SharePreview {
88
113
  return entries.get(id)?.preview ?? LOADING;
89
114
  }
90
115
 
116
+ /**
117
+ * Whether each of the shares is read yet, as one string that changes when one
118
+ * of them is: for a parent that sizes its children's cards by what they say
119
+ * (the terminal's composer). Reads each share as `useSharePreview` does.
120
+ */
121
+ export function useSharePreviewStates(ids: readonly string[]): string {
122
+ const key = ids.join(",");
123
+ const subscribe = useCallback((listener: () => void) => {
124
+ const watched = key ? key.split(",") : [];
125
+ for (const id of watched) {
126
+ entryFor(id).listeners.add(listener);
127
+ request(id);
128
+ }
129
+ return () => {
130
+ for (const id of watched) entries.get(id)?.listeners.delete(listener);
131
+ };
132
+ }, [key]);
133
+ const read = useCallback(() => (key ? key.split(",").map((id) => peekSharePreview(id).status).join(",") : ""), [key]);
134
+ return useSyncExternalStore(subscribe, read, read);
135
+ }
136
+
91
137
  /** The share's title and pane, loaded once per session for every chip that shows it; "" reads nothing. */
92
138
  export function useSharePreview(id: string): SharePreview {
93
139
  const subscribe = useCallback((listener: () => void) => {
@@ -0,0 +1,36 @@
1
+ import { terminalItemCardRows, type PaneLinkChipContent } from "../../../../components/ui/pane-link-chip";
2
+ import type { ChatMessagePaneLink } from "./model";
3
+ import { chatPaneLinkPane, peekSharePreview, type SharePreview } from "./previews";
4
+
5
+ function sameName(a: string, b: string): boolean {
6
+ return a.trim().toLowerCase() === b.trim().toLowerCase();
7
+ }
8
+
9
+ /**
10
+ * What a share's card says: the item its pane was on, a line or two of it, and
11
+ * the pane it opens. Without an item, or with one named as its pane, the pane
12
+ * is said once: its row (with the share's own title when that says more, as
13
+ * `DES SAMPL Options · Research`) under its own description. Before the share
14
+ * is read the card is its link in the room most cards take; once it is gone,
15
+ * its link alone.
16
+ */
17
+ export function shareCardContent(url: string, preview: SharePreview): PaneLinkChipContent {
18
+ if (preview.status === "loading") return { title: url, detail: "", icon: "", pending: true };
19
+ if (preview.status !== "ready") return { title: url, detail: "", icon: "" };
20
+ const pane = chatPaneLinkPane(preview.paneId);
21
+ const paneName = pane?.name ?? preview.item?.pane ?? "";
22
+ const icon = pane?.icon ?? "";
23
+ const item = preview.item;
24
+ if (item && !sameName(item.title, paneName)) {
25
+ return { title: item.title, excerpt: item.excerpt ?? "", detail: paneName || preview.title, icon };
26
+ }
27
+ const row = !paneName ? preview.title
28
+ : sameName(preview.title, paneName) ? paneName
29
+ : `${preview.title} · ${paneName}`;
30
+ return { title: "", excerpt: preview.description ?? item?.excerpt ?? "", detail: row, icon };
31
+ }
32
+
33
+ /** The rows a message's chip takes in the terminal at `width`: a share's card as it reads now, or one row. */
34
+ export function terminalChatPaneChipRows(link: ChatMessagePaneLink, width: number): number {
35
+ return link.kind === "share" ? terminalItemCardRows(shareCardContent(link.url, peekSharePreview(link.id)), width) : 1;
36
+ }