gloomberb 0.20.4 → 0.20.5

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 (217) hide show
  1. package/README.md +2 -0
  2. package/bin/gloom +9 -0
  3. package/bin/without-bun.cjs +98 -0
  4. package/package.json +3 -1
  5. package/src/api-client/data.ts +138 -35
  6. package/src/api-client/types/econ.ts +12 -0
  7. package/src/api-client/yield-curves.ts +1 -1
  8. package/src/app/global-shortcuts.ts +4 -1
  9. package/src/app/keybindings/actions.ts +6 -0
  10. package/src/app/keybindings/config.ts +2 -1
  11. package/src/app/keybindings/index.ts +1 -0
  12. package/src/app/keybindings/labels.ts +6 -1
  13. package/src/app/keybindings/resolve.ts +23 -4
  14. package/src/app/keybindings/terminal-keys.ts +35 -0
  15. package/src/app/pane-runtime/index.tsx +2 -2
  16. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  17. package/src/architecture/ui-literals-allowlist.json +1 -1
  18. package/src/capabilities/chart-series.ts +27 -1
  19. package/src/cli/commands/keybindings.ts +5 -5
  20. package/src/cli/commands/market.ts +78 -21
  21. package/src/cli/commands/news-search.ts +59 -7
  22. package/src/cli/commands/overview.ts +16 -1
  23. package/src/cli/commands/remote.ts +16 -17
  24. package/src/cli/commands/system.ts +1 -1
  25. package/src/cli/fx-forward.ts +25 -7
  26. package/src/cli/glossary.ts +19 -5
  27. package/src/cli/history-rows.ts +5 -3
  28. package/src/cli/known-gaps.ts +27 -1
  29. package/src/cli/listing-arg.ts +11 -1
  30. package/src/cli/name-entries.ts +5 -1
  31. package/src/cli/not-a-ticker.ts +4 -0
  32. package/src/cli/pane-functions/function-help.ts +2 -2
  33. package/src/components/command-bar/pane-settings.ts +2 -2
  34. package/src/components/command-bar/routes/root/results.ts +6 -2
  35. package/src/components/input-search-bar.tsx +9 -2
  36. package/src/components/layout/pane/header.tsx +2 -0
  37. package/src/components/layout/shell/pane/capture.ts +4 -1
  38. package/src/components/layout/status-bar.tsx +6 -1
  39. package/src/components/onboarding/first-run-workspace.ts +44 -2
  40. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  41. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  42. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  43. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  44. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  45. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  46. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  47. package/src/components/pane-settings-dialog/value.ts +6 -0
  48. package/src/components/pane-settings-dialog.tsx +3 -3
  49. package/src/components/reader/detail-reader.tsx +4 -0
  50. package/src/components/ui/index.ts +1 -1
  51. package/src/components/ui/page-stack-view.tsx +3 -0
  52. package/src/components/ui/pane-link-chip.tsx +269 -54
  53. package/src/components/ui/query-bar.tsx +2 -1
  54. package/src/components/ui/tabs.tsx +97 -19
  55. package/src/core/state/app/layout-reducer.ts +7 -0
  56. package/src/core/state/app/layout.ts +44 -7
  57. package/src/core/state/app/state.ts +1 -1
  58. package/src/core/state/app/types.ts +22 -2
  59. package/src/docs/snapshot.json +27 -10
  60. package/src/market-data/depositary-pair.ts +5 -3
  61. package/src/market-data/market/dated-previous-close.ts +94 -15
  62. package/src/market-data/market/status.ts +17 -1
  63. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  64. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  65. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  66. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  67. package/src/plugins/builtin/awards/index.tsx +1 -1
  68. package/src/plugins/builtin/buildout/index.tsx +1 -0
  69. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  70. package/src/plugins/builtin/cds/headless.ts +4 -0
  71. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  72. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  73. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  74. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  75. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  76. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  77. package/src/plugins/builtin/chat/layout.ts +5 -2
  78. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  79. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  80. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  81. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  82. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  83. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  84. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  85. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  86. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  87. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  88. package/src/plugins/builtin/cot/index.tsx +1 -1
  89. package/src/plugins/builtin/cpi/index.tsx +1 -1
  90. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  91. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  92. package/src/plugins/builtin/doe/index.tsx +1 -1
  93. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  94. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  95. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  96. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  97. package/src/plugins/builtin/econ/index.tsx +1 -0
  98. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  99. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  100. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  101. package/src/plugins/builtin/executives/index.tsx +1 -0
  102. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  103. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  104. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  105. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  106. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  107. package/src/plugins/builtin/gpu/index.tsx +1 -1
  108. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  109. package/src/plugins/builtin/help/index.tsx +11 -1
  110. package/src/plugins/builtin/help/keybindings-editor.tsx +1 -1
  111. package/src/plugins/builtin/holders/index.tsx +1 -0
  112. package/src/plugins/builtin/holders/report-header.ts +2 -2
  113. package/src/plugins/builtin/insider/index.tsx +1 -0
  114. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  115. package/src/plugins/builtin/jobs/index.tsx +1 -0
  116. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  117. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  118. package/src/plugins/builtin/macro-day/model.ts +19 -3
  119. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  120. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  121. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  122. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  123. package/src/plugins/builtin/members/index.tsx +1 -1
  124. package/src/plugins/builtin/mna/index.tsx +1 -0
  125. package/src/plugins/builtin/news/index.tsx +1 -0
  126. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  127. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  128. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  129. package/src/plugins/builtin/options/index.tsx +1 -0
  130. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  131. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  132. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  133. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  134. package/src/plugins/builtin/power/index.tsx +1 -1
  135. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  136. package/src/plugins/builtin/research/headless.ts +10 -4
  137. package/src/plugins/builtin/research/index.tsx +4 -0
  138. package/src/plugins/builtin/research-search/index.tsx +1 -0
  139. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  140. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  141. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  142. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  143. package/src/plugins/builtin/scanner/headless.ts +52 -13
  144. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  145. package/src/plugins/builtin/sec/index.tsx +1 -0
  146. package/src/plugins/builtin/series-inventory.ts +1 -1
  147. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  148. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  149. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  150. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  151. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  152. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  153. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  154. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  155. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  156. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  157. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  158. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  159. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  160. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  161. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  162. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  163. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  164. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  165. package/src/plugins/builtin/time-sales/client.ts +9 -11
  166. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  167. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  168. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  169. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  170. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  171. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  172. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  173. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  174. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  175. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  176. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  177. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  178. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  179. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  180. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  181. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  182. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  183. package/src/portfolio/column-values.ts +2 -1
  184. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  185. package/src/public/remote.ts +7 -1
  186. package/src/remote/client.ts +191 -11
  187. package/src/remote/controller-utils.ts +13 -1
  188. package/src/remote/controller.ts +88 -26
  189. package/src/remote/endpoint.ts +24 -0
  190. package/src/remote/form.ts +59 -4
  191. package/src/remote/resources.ts +44 -18
  192. package/src/remote/schema.ts +21 -9
  193. package/src/remote/secrets.ts +12 -0
  194. package/src/remote/semantic-tree.tsx +14 -2
  195. package/src/remote/server.ts +2 -1
  196. package/src/remote/surface.tsx +192 -0
  197. package/src/remote/types.ts +5 -0
  198. package/src/renderers/opentui/host.tsx +6 -0
  199. package/src/series/standalone.ts +2 -2
  200. package/src/shares/api.ts +21 -4
  201. package/src/shares/item.ts +73 -0
  202. package/src/shares/pane-item.ts +205 -0
  203. package/src/shares/pane.ts +4 -0
  204. package/src/shares/payload.ts +9 -5
  205. package/src/sources/gloomberb-cloud/news.ts +2 -0
  206. package/src/tickers/renamed-listings.ts +105 -0
  207. package/src/tickers/search/index.ts +103 -16
  208. package/src/time-series/resolve.ts +2 -2
  209. package/src/types/financials.ts +1 -0
  210. package/src/types/plugin-pane-settings.ts +2 -0
  211. package/src/types/plugin-panes.ts +22 -0
  212. package/src/utils/central-banks.ts +86 -1
  213. package/src/utils/datetime-format.ts +12 -3
  214. package/src/utils/depositary-receipt.ts +28 -3
  215. package/src/utils/fundamentals.ts +14 -0
  216. package/src/utils/max-drawdown.ts +97 -16
  217. package/src/utils/untrusted-text.ts +29 -0
@@ -0,0 +1,91 @@
1
+ import type { HeadlessBundleResult, HeadlessPaneContext, HeadlessPaneLoadArgs, HeadlessPaneRow } from "../../../types/headless";
2
+ import { canonicalTickerKey } from "../../../utils/exchanges";
3
+ import { formatNumber } from "../../../utils/format";
4
+ import { CASH_SYMBOL } from "../../../portfolio/allocation";
5
+ import type { FundMembersPayload } from "../../../api-client/members";
6
+ import { collectionHoldingsHeadless } from "../portfolio-list/headless";
7
+
8
+ const SECTOR_NAMES: Record<string, string> = {
9
+ technology: "Information Technology", "information technology": "Information Technology",
10
+ "financial services": "Financials", financials: "Financials", "health care": "Health Care", healthcare: "Health Care",
11
+ "consumer cyclical": "Consumer Discretionary", "consumer discretionary": "Consumer Discretionary",
12
+ "consumer defensive": "Consumer Staples", "consumer staples": "Consumer Staples",
13
+ "basic materials": "Materials", materials: "Materials", "communication services": "Communication Services", communication: "Communication Services",
14
+ "cash and/or derivatives": "Cash", cash: "Cash",
15
+ energy: "Energy", industrials: "Industrials", "real estate": "Real Estate", utilities: "Utilities",
16
+ };
17
+ const sectorName = (value: unknown) => typeof value === "string" ? SECTOR_NAMES[value.trim().toLowerCase()] ?? null : null;
18
+
19
+ /** Signed positions as a share of net liquidation, including cash. Unknowns stay in the denominator. */
20
+ export function comparePortfolioSectors(positions: HeadlessPaneRow[], total: number, benchmark: FundMembersPayload,
21
+ sectors: ReadonlyMap<string, string | null>) {
22
+ if (!Number.isFinite(total) || total <= 0) throw new Error("Sector comparison needs positive net liquidation.");
23
+ const book = new Map<string, number>(), index = new Map<string, number>();
24
+ const unknown: HeadlessPaneRow[] = [];
25
+ for (const member of benchmark.members) {
26
+ const sector = sectorName(member.sector) ?? "Unknown benchmark sector";
27
+ if (member.weight != null && Number.isFinite(member.weight)) index.set(sector, (index.get(sector) ?? 0) + member.weight * 100);
28
+ }
29
+ if (![...index.values()].some(weight => weight > 0)) throw new Error("No benchmark sector weights are available.");
30
+ for (const position of positions) {
31
+ const symbol = String(position.symbol);
32
+ const sector = symbol === CASH_SYMBOL ? "Cash" : sectorName(sectors.get(canonicalTickerKey(symbol, typeof position.exchange === "string" ? position.exchange : undefined))) ?? "Unclassified / funds";
33
+ const value = position.marketValue;
34
+ if (typeof value !== "number" || !Number.isFinite(value)) {
35
+ unknown.push({ symbol, reason: "Position has no market value", weightPercent: null });
36
+ continue;
37
+ }
38
+ const weight = 100 * value / total;
39
+ book.set(sector, (book.get(sector) ?? 0) + weight);
40
+ if (sector === "Unclassified / funds") unknown.push({ symbol, reason: "No company sector; funds are not looked through", weightPercent: weight });
41
+ }
42
+ const rows = [...new Set([...book.keys(), ...index.keys()])].map(sector => ({ sector,
43
+ portfolioWeightPercent: book.get(sector) ?? 0, benchmarkWeightPercent: index.get(sector) ?? 0,
44
+ activeWeightPp: (book.get(sector) ?? 0) - (index.get(sector) ?? 0),
45
+ })).sort((a, b) => b.activeWeightPp - a.activeWeightPp || a.sector.localeCompare(b.sector));
46
+ return { rows, unknown };
47
+ }
48
+
49
+ export async function portfolioSectorReport(args: HeadlessPaneLoadArgs, ctx: HeadlessPaneContext): Promise<HeadlessBundleResult> {
50
+ const [holdings, benchmark] = await Promise.all([
51
+ collectionHoldingsHeadless.load({ ...args, options: { limit: 200, close: false } }, ctx),
52
+ ctx.apiClient.getFundMembers("SPY"),
53
+ ]);
54
+ const rows = holdings.rows;
55
+ const metadata = holdings.metadata ?? {};
56
+ const total = (metadata.totals as { total?: number } | undefined)?.total;
57
+ if (typeof total !== "number") throw new Error("Sector comparison needs portfolio holdings with net liquidation.");
58
+ const sectors = new Map<string, string | null>();
59
+ const missing = rows.filter(row => row.symbol !== CASH_SYMBOL);
60
+ // The batch preserves exact listing keys; membership under a matching bare ticker never classifies a namesake abroad.
61
+ if (missing.length && ctx.marketData.getTickerFinancialsBatch) {
62
+ for (let offset = 0; offset < missing.length; offset += 50) {
63
+ const chunk = missing.slice(offset, offset + 50);
64
+ const loaded = await ctx.marketData.getTickerFinancialsBatch(chunk.map(row => ({ symbol: String(row.symbol), exchange: String(row.exchange ?? "") })));
65
+ loaded.forEach(result => {
66
+ const financials = result.financials;
67
+ const fund = /ETF|FUND|MUTUAL/i.test(financials?.quote?.instrumentType ?? "");
68
+ sectors.set(canonicalTickerKey(result.target.symbol, result.target.exchange), fund ? null : financials?.profile?.sector ?? null);
69
+ });
70
+ }
71
+ }
72
+ ctx.signal.throwIfAborted();
73
+ const comparison = comparePortfolioSectors(rows, total, benchmark, sectors);
74
+ const truncated = typeof metadata.positions === "number" && metadata.positions > missing.length;
75
+ const unknownBenchmark = comparison.rows.some(row => row.sector === "Unknown benchmark sector");
76
+ return {
77
+ sections: [
78
+ { title: `Sectors vs S&P 500 (${benchmark.fund.ticker} holdings)`, columns: [
79
+ { key: "sector", header: "Sector" }, { key: "portfolioWeightPercent", header: "Book %", align: "right", format: value => formatNumber(Number(value), 2) },
80
+ { key: "benchmarkWeightPercent", header: `${benchmark.fund.ticker} %`, align: "right", format: value => formatNumber(Number(value), 2) }, { key: "activeWeightPp", header: "Active pp", align: "right", format: value => formatNumber(Number(value), 2) },
81
+ ], rows: comparison.rows },
82
+ { title: "Unclassified holdings", columns: [{ key: "symbol", header: "Ticker" }, { key: "weightPercent", header: "Book %" }, { key: "reason", header: "Reason" }], rows: comparison.unknown },
83
+ ],
84
+ complete: holdings.complete !== false && !truncated && !benchmark.stale && comparison.unknown.length === 0 && !unknownBenchmark,
85
+ notes: ["Signed market values / net liquidation, cash included; active weights are percentage points. Direct company sectors; funds are not looked through. Unknown weights remain in the denominator.",
86
+ `Benchmark: ${benchmark.fund.ticker} holdings as of ${benchmark.asOf}.`],
87
+ errors: [...(holdings.errors ?? []), ...(truncated ? ["Portfolio list exceeds 200 rows; the comparison covers only those returned."] : []),
88
+ ...(benchmark.stale ? ["Benchmark holdings are stale."] : [])],
89
+ metadata: { portfolio: metadata.collection, currency: metadata.currency, netLiquidation: total, benchmark: benchmark.fund.ticker, benchmarkAsOf: benchmark.asOf },
90
+ };
91
+ }
@@ -8,7 +8,7 @@ export const awardsModule: PluginModule = {
8
8
  setup(ctx) { awardsCache.attach(ctx.persistence); awardDetailCache.attach(ctx.persistence); },
9
9
  dispose() { awardsCache.reset(); awardDetailCache.reset(); },
10
10
  panes: [{ id: "awards", name: "Government Awards", icon: "A", get component(): typeof import("./pane").AwardsPane { const { AwardsPane } = require("./pane"); return AwardsPane; }, defaultPosition: "right", defaultMode: "floating",
11
- defaultFloatingSize: { width: 132, height: 34 }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: awardsHeadless,
11
+ defaultFloatingSize: { width: 132, height: 34 }, shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], tableExport: true, headless: awardsHeadless,
12
12
  quickSettings: [{ type: "toggle", key: "awardAlerts", icon: "zap", label: "New awards above 1% of annual revenue" }],
13
13
  settings: { title: "Government awards", fields: [{ type: "toggle", key: "awardAlerts", label: "New awards above 1% of annual revenue", description: "Notify while this pane is visible. Starts with the next refresh; historical backfills are excluded." }] } }],
14
14
  paneTemplates: [{ id: "awards-pane", paneId: "awards", label: "Government Awards", description: "Pro: government awards, company history, agency concentration and revenue exposure with source evidence.",
@@ -47,6 +47,7 @@ export const buildoutModule: PluginModule = {
47
47
  defaultPosition: "right",
48
48
  defaultMode: "floating",
49
49
  defaultFloatingSize: { width: 120, height: 32 },
50
+ shareItem: { ticker: true },
50
51
  tickerFollower: true,
51
52
  instruments: ["equity"],
52
53
  reportOptions: [COMPANY_TAB_OPTION],
@@ -17,8 +17,8 @@ export const catalystsModule: PluginModule = {
17
17
  },
18
18
  dispose() { catalystCache.reset(); catalystDetailCache.reset(); },
19
19
  panes: [
20
- { id: "catalysts", name: "Catalysts", icon: "C", component: CatalystsPane, defaultPosition: "right", tickerFollower: true, instruments: ["equity"], defaultMode: "floating", defaultFloatingSize: { width: 130, height: 32 }, tableExport: true, headless: catalystsHeadless },
21
- { id: "litigation", name: "Litigation", icon: "L", component: LitigationPane, defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 120, height: 30 }, tickerFollower: true,
20
+ { id: "catalysts", name: "Catalysts", icon: "C", component: CatalystsPane, defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], defaultMode: "floating", defaultFloatingSize: { width: 130, height: 32 }, tableExport: true, headless: catalystsHeadless },
21
+ { id: "litigation", name: "Litigation", icon: "L", component: LitigationPane, defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 120, height: 30 }, shareItem: { ticker: true }, tickerFollower: true,
22
22
  // A fund's trust can be a party (a sponsor's case against the SEC); an index or a pair never is.
23
23
  instruments: ["equity", "fund"], tableExport: true, headless: litigationHeadless },
24
24
  ],
@@ -273,6 +273,10 @@ function projectCdsHeadless({ activity, history, levels, sort, days = DAILY_DAYS
273
273
  // The 5Y figures are dated by their level's day, each trade and each daily level by its own.
274
274
  const levelDate = line ? spreadSummary(line)?.date : undefined;
275
275
  const sections: HeadlessBundleSection[] = [
276
+ ...(!entries.length ? [{ title: "Level coverage", columns: [
277
+ { key: "issuer", header: "Issuer" }, { key: "tenor", header: "Tenor" }, { key: "status", header: "Status" }, { key: "reason", header: "Reason" },
278
+ ], rows: [{ issuer: name, tenor: "5Y", status: history instanceof Error ? "check-failed" : unmatched ? "not-covered" : why ? "not-derivable" : "no-traded-level",
279
+ spreadBp: null, reason: history instanceof Error ? "The spread history check failed." : unmatched ? empty : why ?? `No traded 5Y level on file for ${name} in the last two years.` }] }] : []),
276
280
  ...(entries.length ? [{ title: name, entries, symbol: name, ...(levelDate ? { asOf: levelDate } : {}) }] : []),
277
281
  {
278
282
  title: "Trades",
@@ -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
  }
@@ -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",
@@ -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) => {