@gloom-sh/terminal 0.19.5 → 0.20.0

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 (318) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
  4. package/patches/electrobun-devkit@2.0.5.patch +148 -0
  5. package/src/api-client/bond-trades.ts +59 -0
  6. package/src/api-client/data.ts +21 -0
  7. package/src/api-client/equity-screener.ts +23 -0
  8. package/src/api-client/index.ts +2 -0
  9. package/src/api-client/types/account.ts +86 -0
  10. package/src/api-client/types/assist.ts +32 -0
  11. package/src/api-client/types/auth.ts +63 -0
  12. package/src/api-client/types/billing.ts +54 -0
  13. package/src/api-client/types/chat.ts +180 -0
  14. package/src/api-client/types/congress.ts +107 -0
  15. package/src/api-client/types/credit.ts +110 -0
  16. package/src/api-client/types/econ.ts +158 -0
  17. package/src/api-client/types/equity-diagnostic.ts +73 -0
  18. package/src/api-client/types/filings-and-calls.ts +350 -0
  19. package/src/api-client/types/index.ts +25 -0
  20. package/src/api-client/types/jobs.ts +147 -0
  21. package/src/api-client/types/market.ts +122 -0
  22. package/src/api-client/types/news.ts +91 -0
  23. package/src/api-client/types/notes-and-theses.ts +172 -0
  24. package/src/api-client/types/quotes.ts +28 -0
  25. package/src/api-client/types/scanners.ts +125 -0
  26. package/src/api-client/types/screener.ts +65 -0
  27. package/src/api-client/types/search.ts +107 -0
  28. package/src/api-client/types/sync.ts +14 -0
  29. package/src/api-client/types/team-collections.ts +43 -0
  30. package/src/api-client/types/team-views.ts +32 -0
  31. package/src/api-client/types/teams.ts +135 -0
  32. package/src/api-client/types/ticker-data.ts +57 -0
  33. package/src/api-client/types/tweets.ts +59 -0
  34. package/src/api-client/types/world-venues.ts +23 -0
  35. package/src/app/pane-runtime/index.tsx +2 -0
  36. package/src/app/pane-runtime/plugin-bindings.ts +10 -1
  37. package/src/app/runtime/desktop-deeplink.ts +41 -6
  38. package/src/app/star-prompt/status-line.tsx +1 -1
  39. package/src/app.tsx +64 -23
  40. package/src/architecture/ui-tokens-allowlist.json +0 -8
  41. package/src/cli/commands/market.ts +149 -10
  42. package/src/cli/commands/search.ts +21 -3
  43. package/src/cli/commands/ticker.ts +90 -36
  44. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  45. package/src/cli/glossary.ts +3 -3
  46. package/src/cli/known-gaps.ts +8 -0
  47. package/src/cli/listing-arg.ts +12 -0
  48. package/src/cli/pane-functions/capabilities.ts +2 -0
  49. package/src/cli/pane-functions/catalog.ts +25 -5
  50. package/src/cli/pane-functions/function-help.ts +8 -5
  51. package/src/cli/pane-functions/headless.ts +4 -3
  52. package/src/cli/pane-functions/resolver.ts +75 -2
  53. package/src/cli/quote-answer.ts +9 -0
  54. package/src/cli/symbol-list.ts +54 -2
  55. package/src/cli/symbol-rows.ts +14 -2
  56. package/src/cli/ticker-resolution.ts +89 -20
  57. package/src/components/chart/composite/axis-overlays.tsx +60 -27
  58. package/src/components/chart/composite/composite-chart.tsx +118 -63
  59. package/src/components/chart/composite/cursor-source.ts +111 -0
  60. package/src/components/chart/composite/format.ts +168 -6
  61. package/src/components/chart/composite/legend.tsx +8 -4
  62. package/src/components/chart/composite/panel-labels.ts +20 -1
  63. package/src/components/chart/composite/panel-surface.tsx +201 -92
  64. package/src/components/chart/composite/price-axis-labels.tsx +92 -46
  65. package/src/components/chart/composite/price-series.ts +31 -8
  66. package/src/components/chart/composite/scene.ts +154 -59
  67. package/src/components/chart/composite/series-axis-tags.tsx +4 -2
  68. package/src/components/chart/composite/time-axis.ts +13 -5
  69. package/src/components/chart/composite/time-scale.ts +211 -56
  70. package/src/components/chart/composite/types.ts +11 -1
  71. package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
  72. package/src/components/chart/curve/curve-surface.tsx +5 -2
  73. package/src/components/chart/curve/model.ts +4 -1
  74. package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
  75. package/src/components/chart/static/series.ts +3 -0
  76. package/src/components/command-bar/commands/collection-list.ts +81 -0
  77. package/src/components/command-bar/commands/direct/index.ts +6 -0
  78. package/src/components/command-bar/commands/registry.ts +8 -0
  79. package/src/components/command-bar/layout-items/current-layout.ts +22 -1
  80. package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
  81. package/src/components/command-bar/pane-templates/items.ts +19 -3
  82. package/src/components/command-bar/pane-templates/workflow.ts +5 -0
  83. package/src/components/command-bar/routes/root/results.ts +23 -3
  84. package/src/components/command-bar/routes/root/selection.ts +4 -2
  85. package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
  86. package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
  87. package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
  88. package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
  89. package/src/components/command-bar/surface/environment.ts +2 -0
  90. package/src/components/command-bar/view-model.ts +7 -0
  91. package/src/components/command-bar/workflow/ops.ts +2 -1
  92. package/src/components/command-bar/workflow/tickers.ts +20 -0
  93. package/src/components/data-table/export.ts +4 -1
  94. package/src/components/layout/detached-pane-shell.tsx +10 -37
  95. package/src/components/layout/double-escape-close.ts +90 -0
  96. package/src/components/layout/header.tsx +3 -2
  97. package/src/components/layout/market-summary.ts +6 -3
  98. package/src/components/layout/pane/footer/index.tsx +2 -6
  99. package/src/components/layout/pane/footer/model.ts +6 -12
  100. package/src/components/layout/shell/active-drag.ts +53 -11
  101. package/src/components/layout/shell/drag/magnets.ts +128 -19
  102. package/src/components/layout/shell/menu.ts +15 -1
  103. package/src/components/layout/shell/pane/actions.ts +10 -2
  104. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  105. package/src/components/layout/shell/ticker-link-menu.ts +12 -3
  106. package/src/components/layout/status-bar.tsx +24 -78
  107. package/src/components/layout/status-widget-space.ts +5 -5
  108. package/src/components/onboarding/onboarding-keyboard.ts +5 -1
  109. package/src/components/onboarding/onboarding-wizard.tsx +15 -4
  110. package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
  111. package/src/components/onboarding/use-onboarding-progress.ts +20 -1
  112. package/src/components/price-sparkline/view.tsx +14 -6
  113. package/src/components/ticker/badge/index.tsx +8 -4
  114. package/src/components/ticker/badge/list.tsx +23 -7
  115. package/src/components/ui/column-grid.tsx +8 -2
  116. package/src/components/ui/data-table/index.tsx +5 -1
  117. package/src/components/ui/data-table/opentui/model.ts +4 -1
  118. package/src/components/ui/data-table/render-cell.ts +19 -0
  119. package/src/components/ui/delayed-mark.tsx +59 -7
  120. package/src/components/ui/icon.tsx +1 -8
  121. package/src/components/ui/menu.tsx +6 -1
  122. package/src/components/ui/tabs.tsx +5 -2
  123. package/src/core/state/app/layout.ts +18 -3
  124. package/src/core/state/app/state.ts +2 -0
  125. package/src/core/state/app/types.ts +5 -0
  126. package/src/data/config/layout.ts +3 -0
  127. package/src/data/config/store/normalize.ts +39 -4
  128. package/src/i18n/es.ts +13 -3
  129. package/src/i18n/ja.ts +13 -3
  130. package/src/i18n/ko.ts +13 -3
  131. package/src/i18n/zh-cn.ts +13 -3
  132. package/src/i18n/zh-tw.ts +13 -3
  133. package/src/layout/pane-manager/floating-placement.ts +7 -4
  134. package/src/layout/pane-manager/floating.ts +5 -2
  135. package/src/market-data/bond-funds.ts +19 -0
  136. package/src/market-data/futures-contract.ts +14 -3
  137. package/src/market-data/market/freshness.ts +18 -0
  138. package/src/market-data/market/status.ts +15 -2
  139. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  140. package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
  141. package/src/plugins/builtin/bond-calculator/model.ts +14 -5
  142. package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
  143. package/src/plugins/builtin/buildout/cells.tsx +25 -45
  144. package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
  145. package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
  146. package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
  147. package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
  148. package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
  149. package/src/plugins/builtin/buildout/format.ts +23 -1
  150. package/src/plugins/builtin/buildout/model/types.ts +1 -0
  151. package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
  152. package/src/plugins/builtin/buildout/table-model.ts +12 -4
  153. package/src/plugins/builtin/cds/headless.ts +1 -0
  154. package/src/plugins/builtin/cds/index.tsx +1 -1
  155. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  156. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  157. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  158. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  159. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  160. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  161. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  162. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
  163. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  164. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  165. package/src/plugins/builtin/correlation/headless.ts +3 -2
  166. package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
  167. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  168. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  169. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  170. package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
  171. package/src/plugins/builtin/debt-maturities/model.ts +66 -0
  172. package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
  173. package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
  174. package/src/plugins/builtin/econ/calendar-model.ts +28 -6
  175. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  176. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
  177. package/src/plugins/builtin/equity-screener/headless.ts +37 -3
  178. package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
  179. package/src/plugins/builtin/equity-screener/model.ts +238 -27
  180. package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
  181. package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
  182. package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
  183. package/src/plugins/builtin/executives/format.ts +5 -4
  184. package/src/plugins/builtin/executives/pane.tsx +1 -1
  185. package/src/plugins/builtin/futures-curve/client.ts +19 -0
  186. package/src/plugins/builtin/futures-curve/headless.ts +52 -13
  187. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  188. package/src/plugins/builtin/futures-curve/model.ts +77 -6
  189. package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
  190. package/src/plugins/builtin/help/index.tsx +55 -1
  191. package/src/plugins/builtin/insider/model.ts +30 -2
  192. package/src/plugins/builtin/jobs/model.ts +2 -2
  193. package/src/plugins/builtin/macro-day/client.ts +41 -0
  194. package/src/plugins/builtin/macro-day/headless.ts +19 -9
  195. package/src/plugins/builtin/macro-day/model.ts +3 -1
  196. package/src/plugins/builtin/market-movers/index.tsx +4 -3
  197. package/src/plugins/builtin/mna/distress/headless.ts +1 -0
  198. package/src/plugins/builtin/mna/model.ts +2 -2
  199. package/src/plugins/builtin/notes/files.ts +2 -0
  200. package/src/plugins/builtin/notes/owner.tsx +20 -1
  201. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  202. package/src/plugins/builtin/notes/store.ts +6 -1
  203. package/src/plugins/builtin/perps/pane.tsx +3 -1
  204. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
  205. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
  206. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  207. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  208. package/src/plugins/builtin/rate-path/headless.ts +24 -10
  209. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  210. package/src/plugins/builtin/research/event-model.ts +10 -3
  211. package/src/plugins/builtin/research/events-headless.ts +20 -2
  212. package/src/plugins/builtin/sec/fund-facts.ts +17 -1
  213. package/src/plugins/builtin/sec/index.tsx +1 -1
  214. package/src/plugins/builtin/series-inventory.ts +1 -0
  215. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  216. package/src/plugins/builtin/shared/members-menu.tsx +103 -38
  217. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  218. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  219. package/src/plugins/builtin/short-interest/model.ts +15 -6
  220. package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
  221. package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
  222. package/src/plugins/builtin/short-interest/types.ts +2 -0
  223. package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
  224. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  225. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  226. package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
  227. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  228. package/src/plugins/builtin/time-sales/pane.tsx +3 -2
  229. package/src/plugins/builtin/trace-bonds/client.ts +7 -4
  230. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  231. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  232. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  233. package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
  234. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  235. package/src/plugins/builtin/volatility/client.ts +6 -1
  236. package/src/plugins/builtin/volatility/headless.ts +0 -1
  237. package/src/plugins/builtin/yield-curve/curves.ts +15 -0
  238. package/src/plugins/builtin/yield-curve/headless.ts +6 -1
  239. package/src/plugins/builtin/yield-curve/index.tsx +5 -8
  240. package/src/plugins/host-modules.ts +22 -3
  241. package/src/plugins/host-smoke.ts +6 -3
  242. package/src/plugins/installer.ts +16 -3
  243. package/src/plugins/plugin-names.ts +11 -2
  244. package/src/portfolio/collection-name.ts +19 -0
  245. package/src/remote/controller.ts +9 -2
  246. package/src/remote/schema.ts +2 -1
  247. package/src/renderers/browser/http-proxy-transport.ts +78 -8
  248. package/src/renderers/cloudflare/http-proxy.ts +73 -3
  249. package/src/renderers/cloudflare/proxy-session.ts +47 -24
  250. package/src/renderers/cloudflare/worker.ts +44 -4
  251. package/src/renderers/desktop/geometry.ts +279 -0
  252. package/src/renderers/desktop/screen-setup.ts +246 -0
  253. package/src/renderers/desktop/sequential-window-host.ts +179 -0
  254. package/src/renderers/desktop/test-utils.ts +71 -0
  255. package/src/renderers/desktop/window-controller.ts +433 -0
  256. package/src/renderers/desktop/window-host.ts +70 -0
  257. package/src/renderers/desktop/window-layouts.ts +630 -0
  258. package/src/renderers/dom/data-frames.ts +15 -4
  259. package/src/renderers/dom/desktop/icons.tsx +0 -2
  260. package/src/renderers/dom/styles.css +0 -3
  261. package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
  262. package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
  263. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
  264. package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
  265. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
  266. package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
  267. package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
  268. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  269. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  270. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  271. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
  272. package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
  273. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  274. package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
  275. package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
  276. package/src/renderers/electrobun/bun/index.ts +22 -109
  277. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  278. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
  279. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  280. package/src/renderers/electrobun/bun/window/focus.ts +0 -25
  281. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  282. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  283. package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
  284. package/src/renderers/electrobun/shared/protocol.ts +44 -2
  285. package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
  286. package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
  287. package/src/renderers/electrobun/view/main.tsx +13 -7
  288. package/src/series/fred-argument.ts +17 -0
  289. package/src/sources/gloomberb-cloud/index.ts +5 -7
  290. package/src/sources/provider-router/batches.ts +18 -3
  291. package/src/sources/provider-router/financial-routes.ts +7 -1
  292. package/src/sources/provider-router/financials.ts +18 -4
  293. package/src/state/app/context/index.tsx +16 -2
  294. package/src/state/desktop-windows.ts +63 -0
  295. package/src/sync/other-window-tabs.ts +62 -0
  296. package/src/tickers/company-name-listing.ts +23 -3
  297. package/src/tickers/listing-fate.ts +147 -1
  298. package/src/tickers/terminal-codes.ts +5 -0
  299. package/src/time-series/types.ts +6 -0
  300. package/src/types/config.ts +10 -1
  301. package/src/types/data-provider.ts +14 -0
  302. package/src/types/desktop-window.ts +71 -2
  303. package/src/types/financials.ts +19 -3
  304. package/src/types/headless.ts +21 -0
  305. package/src/types/plugin.ts +6 -0
  306. package/src/ui/index.tsx +14 -13
  307. package/src/ui/same-props.ts +58 -0
  308. package/src/utils/cli-output.ts +33 -4
  309. package/src/utils/double-escape-close.ts +38 -16
  310. package/src/utils/format.ts +30 -5
  311. package/src/utils/futures-generic.ts +12 -0
  312. package/src/utils/http-proxy-upstream.ts +6 -2
  313. package/src/utils/plugin-proxy-hosts.json +0 -4
  314. package/src/utils/plugin-proxy-hosts.ts +22 -0
  315. package/src/utils/price-earnings.ts +18 -0
  316. package/src/utils/sec-filings.ts +7 -1
  317. package/patches/electrobun@1.18.1.patch +0 -633
  318. package/src/api-client/types.ts +0 -2441
@@ -0,0 +1,81 @@
1
+ import { useCallback, useSyncExternalStore } from "react";
2
+ import type { NativeRendererHost, PixelResolution } from "../../../ui";
3
+
4
+ /** What a bitmap's pixel size and kitty support are worked out from. */
5
+ export interface NativeBitmapMetrics {
6
+ resolution: PixelResolution | null;
7
+ terminalWidth: number;
8
+ terminalHeight: number;
9
+ capabilities: unknown;
10
+ }
11
+
12
+ interface MetricsHub {
13
+ snapshot: NativeBitmapMetrics | null;
14
+ consumers: Set<() => void>;
15
+ notify: () => void;
16
+ }
17
+
18
+ const hubs = new WeakMap<NativeRendererHost, MetricsHub>();
19
+
20
+ function hubFor(renderer: NativeRendererHost): MetricsHub {
21
+ let hub = hubs.get(renderer);
22
+ if (!hub) {
23
+ const created: MetricsHub = {
24
+ snapshot: null,
25
+ consumers: new Set(),
26
+ notify: () => {
27
+ for (const consumer of created.consumers) consumer();
28
+ },
29
+ };
30
+ hubs.set(renderer, created);
31
+ hub = created;
32
+ }
33
+ return hub;
34
+ }
35
+
36
+ function readMetrics(renderer: NativeRendererHost): NativeBitmapMetrics {
37
+ const hub = hubFor(renderer);
38
+ const last = hub.snapshot;
39
+ const resolution = renderer.resolution ?? null;
40
+ const { terminalWidth, terminalHeight, capabilities } = renderer;
41
+ if (
42
+ last
43
+ && last.terminalWidth === terminalWidth
44
+ && last.terminalHeight === terminalHeight
45
+ && last.capabilities === capabilities
46
+ && (last.resolution === resolution || (!!last.resolution && !!resolution
47
+ && last.resolution.width === resolution.width && last.resolution.height === resolution.height))
48
+ ) return last;
49
+ hub.snapshot = { resolution, terminalWidth, terminalHeight, capabilities };
50
+ return hub.snapshot;
51
+ }
52
+
53
+ // One listener trio per renderer however many bitmaps watch it, as in renderer-selection.
54
+ function subscribe(renderer: NativeRendererHost, onChange: () => void): () => void {
55
+ const hub = hubFor(renderer);
56
+ if (hub.consumers.size === 0) {
57
+ renderer.on("resize", hub.notify);
58
+ renderer.on("resolution", hub.notify);
59
+ renderer.on("capabilities", hub.notify);
60
+ }
61
+ hub.consumers.add(onChange);
62
+ return () => {
63
+ hub.consumers.delete(onChange);
64
+ if (hub.consumers.size > 0) return;
65
+ renderer.off("resize", hub.notify);
66
+ renderer.off("resolution", hub.notify);
67
+ renderer.off("capabilities", hub.notify);
68
+ };
69
+ }
70
+
71
+ /**
72
+ * The renderer's pixel resolution, cell grid and capabilities, re-rendering the
73
+ * caller when a resize, a font zoom or a late terminal reply changes them. A
74
+ * bitmap sized from these during render needs this rather than reading them off
75
+ * the renderer, or a parent that stops re-rendering leaves it at its old size.
76
+ */
77
+ export function useNativeBitmapMetrics(renderer: NativeRendererHost): NativeBitmapMetrics {
78
+ const subscribeToRenderer = useCallback((onChange: () => void) => subscribe(renderer, onChange), [renderer]);
79
+ const getSnapshot = useCallback(() => readMetrics(renderer), [renderer]);
80
+ return useSyncExternalStore(subscribeToRenderer, getSnapshot, getSnapshot);
81
+ }
@@ -25,6 +25,8 @@ export interface StaticSeriesOptions {
25
25
  calendarSpaced?: boolean;
26
26
  /** Columns below zero in this colour. */
27
27
  negativeColor?: string;
28
+ /** The grid its axis ticks fall on (`ResolvedSeries.tickGrid`). */
29
+ tickGrid?: number;
28
30
  }
29
31
 
30
32
  export function staticSeries(points: TimeSeriesPoint[], options: StaticSeriesOptions): ResolvedSeries {
@@ -43,6 +45,7 @@ export function staticSeries(points: TimeSeriesPoint[], options: StaticSeriesOpt
43
45
  interpolation: "none",
44
46
  ...(options.calendarSpaced ? {} : { timeBasis: INDEX_SPACED_TIME_BASIS }),
45
47
  ...(options.negativeColor ? { negativeColor: options.negativeColor } : {}),
48
+ ...(options.tickGrid ? { tickGrid: options.tickGrid } : {}),
46
49
  points,
47
50
  };
48
51
  }
@@ -3,6 +3,7 @@ import type { TickerRecord } from "../../../types/ticker";
3
3
  import { splitSymbolArgs, splitSymbolWords, symbolInputKey, uniqueSymbols } from "../../../cli/symbol-args";
4
4
  import { protectFigureCommas } from "../../../cli/symbol-cells";
5
5
  import { readSymbolList } from "../../../cli/symbol-list";
6
+ import { endsInLegalForm, isLegalForm, readTerminalListingCode } from "../../../tickers/terminal-codes";
6
7
  import { readNameEntries } from "../../../cli/name-entries";
7
8
  import {
8
9
  addSymbols,
@@ -43,6 +44,86 @@ export interface PastedSymbolList {
43
44
  separated: boolean;
44
45
  }
45
46
 
47
+ /** A symbol as one word, in capitals: NFE, BRK.B, 0700, VOD:LSE. */
48
+ const CAPITAL_SYMBOL = /^\$?[A-Z0-9][A-Z0-9.\-]{0,11}(?::[A-Z0-9]{1,8})?$/;
49
+
50
+ /**
51
+ * A ticker among words split by spaces alone: up to five letters, with a share
52
+ * class (BRK.B) or a venue (VOD:LSE), or a numeric code (0700). A longer word
53
+ * in capitals is a name's (FORTRESS, AMERICA).
54
+ */
55
+ const SPACED_TICKER = /^\$?(?:[A-Z]{1,5}(?:[.\-][A-Z]{1,2})?|\d{4,6})(?::[A-Z]{1,8})?$/;
56
+
57
+ /** Words that join a name's other words (BANK OF AMERICA, PROCTER & GAMBLE), never a symbol of a list. */
58
+ const JOINING_WORDS: ReadonlySet<string> = new Set(["OF", "AND", "&", "THE", "FOR", "DE", "DU", "DES", "DEL", "LA", "LE"]);
59
+
60
+ /** A terminal code with spaces (`NFE US Equity`, `VOD LN`), never a name before its legal form (`SAP SE`). */
61
+ function isSpacedCode(entry: string): boolean {
62
+ return entry.includes(" ") && !endsInLegalForm(entry) && readTerminalListingCode(entry) != null;
63
+ }
64
+
65
+ /**
66
+ * A company's name as a list holds one: up to five words, the first and each
67
+ * but a joining word capitalized (`Apple Inc`, `Bank of America`, `NEW
68
+ * FORTRESS ENERGY INC`). A sentence is none: `how did NVDA do today`, `and why?`.
69
+ */
70
+ function isShortName(entry: string): boolean {
71
+ const words = entry.split(/\s+/);
72
+ return words.length <= 5 && !/[?!]/.test(entry) && /^\p{Lu}/u.test(words[0]!)
73
+ && words.every((word) => /^[\p{Lu}\d&]/u.test(word) || JOINING_WORDS.has(word.toUpperCase()));
74
+ }
75
+
76
+ /**
77
+ * The entries of a list split by commas, semicolons, tabs or lines, when every
78
+ * one is a symbol, a terminal code or a short name, and two or more hold a
79
+ * symbol or there are three or more: `NFE, RAD`, `Apple, Microsoft, Nvidia`.
80
+ * Null for a sentence with a comma (`how did NVDA do today, and why?`).
81
+ */
82
+ function separatedList(query: string): string[] | null {
83
+ const entries = uniqueSymbols(splitSymbolArgs([query])).symbols;
84
+ if (entries.length < 2) return null;
85
+ let symbols = 0;
86
+ for (const entry of entries) {
87
+ const symbol = isSpacedCode(entry) || (CAPITAL_SYMBOL.test(entry) && !JOINING_WORDS.has(entry));
88
+ if (!symbol && !isShortName(entry)) return null;
89
+ if (symbol) symbols += 1;
90
+ }
91
+ return symbols >= 1 || entries.length >= 3 ? entries : null;
92
+ }
93
+
94
+ /**
95
+ * The symbols of a list pasted into the bare command bar, which flattens its
96
+ * lines into spaces: entries split by commas, semicolons, tabs or lines
97
+ * (`separatedList`), or by spaces alone three or more tickers in capitals,
98
+ * where Bloomberg's cells keep their words (`NFE US Equity RAD US Equity`).
99
+ * Null for anything else, which stays a search: a name in capitals (`BANK OF
100
+ * AMERICA`, `NEW FORTRESS ENERGY INC`), a sentence, one code.
101
+ */
102
+ export function pastedRootList(query: string): string[] | null {
103
+ const text = protectFigureCommas(query.trim());
104
+ if (/[,;\t\r\n]/.test(text)) return separatedList(query);
105
+ const words = text.split(/\s+/).filter(Boolean);
106
+ const entries: string[] = [];
107
+ let codes = 0;
108
+ for (let index = 0; index < words.length;) {
109
+ // A terminal code's words read as one: `NFE US Equity`, `1128 HK Equity`, `VOD LN`.
110
+ const code = [3, 2].map((size) => words.slice(index, index + size).join(" "))
111
+ .find((candidate) => candidate.split(" ").length > 1 && isSpacedCode(candidate));
112
+ if (code) {
113
+ entries.push(code);
114
+ index += code.split(" ").length;
115
+ codes += 1;
116
+ continue;
117
+ }
118
+ const word = words[index]!;
119
+ if (!SPACED_TICKER.test(word) || JOINING_WORDS.has(word) || isLegalForm(word)) return null;
120
+ entries.push(word.replace(/^\$/, ""));
121
+ index += 1;
122
+ }
123
+ const unique = [...new Set(entries)];
124
+ return unique.length >= 3 || (codes > 0 && unique.length >= 2) ? unique : null;
125
+ }
126
+
46
127
  /**
47
128
  * The entries of text typed or pasted after `AW`, split as `gloom quote`
48
129
  * splits its arguments (`splitSymbolArgs`): on commas, semicolons, tabs and
@@ -33,6 +33,8 @@ import { ATTENTION_OFF_MESSAGE } from "../../../../telemetry/attention-setting";
33
33
  import { NIGHTLY_CHANNEL_SUMMARY, withUpdateChannel } from "../../../../updater/channel";
34
34
  import { isPrereleaseVersion } from "../../../../utils/semver";
35
35
  import { VERSION } from "../../../../version";
36
+ import { getDesktopWindows } from "../../../../state/desktop-windows";
37
+ import { fireAndForget } from "../../../../utils/fire-and-forget";
36
38
 
37
39
  type NotifyFn = (body: string, options?: { type?: "info" | "success" | "error" }) => void;
38
40
 
@@ -125,6 +127,10 @@ export function runDirectCommandAction(options: {
125
127
  closeAll({ revertThemePreview: false });
126
128
  pluginRegistry.openWindowMode(state.focusedPaneId ?? undefined, parseWindowModeCommandArg(arg) ?? "move");
127
129
  return;
130
+ case "new-window":
131
+ closeAll({ revertThemePreview: false });
132
+ fireAndForget(getDesktopWindows()?.openWindow(), "desktop.openWindow");
133
+ return;
128
134
  case "minimize-window":
129
135
  case "maximize-window":
130
136
  closeAll({ revertThemePreview: false });
@@ -189,6 +189,14 @@ export const commands: Command[] = [
189
189
  argPlaceholder: "move|resize",
190
190
  category: "Config",
191
191
  },
192
+ // Listed only in the desktop app's full windows.
193
+ {
194
+ id: "new-window",
195
+ prefix: "",
196
+ label: "New Window",
197
+ description: "Open another app window with its own layout tabs, for another screen",
198
+ category: "Config",
199
+ },
192
200
  // The keyboard's way to the title bar buttons the desktop draws for itself
193
201
  // on Windows; the command bar lists these only on that host.
194
202
  {
@@ -9,7 +9,27 @@ import {
9
9
  } from "../../../types/config";
10
10
  import { groupIdFor } from "../../layout/status-bar-groups";
11
11
  import type { ResultItem } from "../list/model";
12
- import type { LayoutItemsContext } from "./types";
12
+ import type { CloseAll, LayoutItemsContext } from "./types";
13
+ import { getDesktopWindows, layoutMoveTargets } from "../../../state/desktop-windows";
14
+ import { fireAndForget } from "../../../utils/fire-and-forget";
15
+
16
+ /** The desktop app's other windows, and a new one, where the current layout tab can go. */
17
+ function layoutWindowMoves(layoutId: string | undefined, tabCount: number, closeAll: CloseAll): ResultItem[] {
18
+ const windows = getDesktopWindows();
19
+ if (!windows || !layoutId) return [];
20
+ return layoutMoveTargets(windows, tabCount).map((move) => ({
21
+ id: `layout-move-to-window:${move.key}`,
22
+ label: move.label,
23
+ detail: move.detail ?? "Open a window for the current layout tab",
24
+ searchText: "screen monitor display",
25
+ category: "Current Layout",
26
+ kind: "action" as const,
27
+ action: () => {
28
+ closeAll({ revertThemePreview: false });
29
+ fireAndForget(windows.moveLayout(layoutId, move.target), "desktop.moveLayoutToWindow");
30
+ },
31
+ }));
32
+ }
13
33
 
14
34
  /**
15
35
  * The saved layouts drawn in the same run of status bar tabs as `index`, in tab
@@ -176,6 +196,7 @@ export function buildCurrentLayoutItems({
176
196
  },
177
197
  moveLayoutTab(-1),
178
198
  moveLayoutTab(1),
199
+ ...layoutWindowMoves(state.config.layouts[activeLayoutIndex]?.id, state.config.layouts.length, closeAll),
179
200
  {
180
201
  id: "layout-duplicate-layout",
181
202
  label: "Duplicate Layout",
@@ -9,8 +9,28 @@ import { resolveTickerForPane } from "../../../state/app/context";
9
9
  import { findPaneInstance } from "../../../types/config";
10
10
  import { tf } from "../../../i18n";
11
11
  import type { ResultItem } from "../list/model";
12
- import type { LayoutItemsContext } from "./types";
13
12
  import { WINDOW_MODE_COMMAND_OPTIONS } from "./window-mode";
13
+ import { getDesktopWindows, windowMoveTargets } from "../../../state/desktop-windows";
14
+ import { fireAndForget } from "../../../utils/fire-and-forget";
15
+ import type { CloseAll, LayoutItemsContext } from "./types";
16
+
17
+ /** The desktop app's other windows, and a new one, where the focused pane can go. */
18
+ function focusedPaneWindowMoves(paneId: string, closeAll: CloseAll): ResultItem[] {
19
+ const windows = getDesktopWindows();
20
+ if (!windows) return [];
21
+ return windowMoveTargets(windows, { prefix: "pane" }).map((move) => ({
22
+ id: `layout-move-to-window:${move.key}`,
23
+ label: move.label,
24
+ detail: move.detail ?? "Open a window for the focused pane",
25
+ searchText: "screen monitor display",
26
+ category: "Focused Pane",
27
+ kind: "action" as const,
28
+ action: () => {
29
+ closeAll({ revertThemePreview: false });
30
+ fireAndForget(windows.movePane(paneId, move.target), "desktop.movePaneToWindow");
31
+ },
32
+ }));
33
+ }
14
34
 
15
35
  export function buildFocusedPaneLayoutItems({
16
36
  closeAll,
@@ -103,6 +123,7 @@ export function buildFocusedPaneLayoutItems({
103
123
  pluginRegistry.movePaneBack(focusedPane.instanceId);
104
124
  },
105
125
  }] : []),
126
+ ...focusedPaneWindowMoves(focusedPane.instanceId, closeAll),
106
127
  ...WINDOW_MODE_COMMAND_OPTIONS.map((option) => ({
107
128
  id: `layout-window-mode:${option.mode}`,
108
129
  label: option.label,
@@ -8,6 +8,7 @@ import type {
8
8
  import { fuzzyFilter } from "../../../utils/fuzzy-search";
9
9
  import { summarizeError } from "../helpers";
10
10
  import type { ResultItem } from "../list/model";
11
+ import { tickerFirstQuery } from "../routes/root/ticker-first";
11
12
 
12
13
  type LogErrorFn = (message: string, details: Record<string, unknown>) => void;
13
14
 
@@ -129,13 +130,28 @@ export function getAvailablePaneShortcutTemplatesForQuery(options: {
129
130
  query: string;
130
131
  logError?: LogErrorFn;
131
132
  }): PaneTemplateDef[] {
132
- const trimmed = options.query.trim();
133
- const upper = trimmed.toUpperCase();
134
133
  const disabledPluginIds = new Set(options.disabledPlugins);
135
134
  const enabled = [...options.pluginRegistry.paneTemplates.values()].filter((template) => {
136
135
  const pluginId = options.pluginRegistry.getPaneTemplatePluginId(template.id);
137
136
  return !pluginId || !disabledPluginIds.has(pluginId);
138
137
  });
138
+ const typed = matchingShortcutTemplates(options, enabled, options.query.trim());
139
+ if (typed.length > 0) return typed;
140
+ // Bloomberg's order, the ticker first (`NFE CDS`), is the code's with that ticker.
141
+ const reordered = tickerFirstQuery(options.query, (code) => enabled.some((template) => {
142
+ const argKind = getPaneTemplateArgKind(template);
143
+ return (argKind === "ticker" || argKind === "ticker-list" || (argKind === "text" && template.shortcut?.focusedIssuer === true))
144
+ && paneTemplateShortcutPrefixes(template).some((prefix) => prefix.toUpperCase() === code);
145
+ }));
146
+ return reordered ? matchingShortcutTemplates(options, enabled, reordered) : [];
147
+ }
148
+
149
+ function matchingShortcutTemplates(
150
+ options: { context: PaneTemplateContext; query: string; logError?: LogErrorFn },
151
+ enabled: readonly PaneTemplateDef[],
152
+ trimmed: string,
153
+ ): PaneTemplateDef[] {
154
+ const upper = trimmed.toUpperCase();
139
155
  return enabled.filter((template) => {
140
156
  const argKind = getPaneTemplateArgKind(template);
141
157
  // The longest matching mnemonic wins, so an alias sharing a stem cannot shadow the typed one.
@@ -157,7 +173,7 @@ export function getAvailablePaneShortcutTemplatesForQuery(options: {
157
173
  } catch (error) {
158
174
  options.logError?.("Pane shortcut canCreate failed", {
159
175
  templateId: template.id,
160
- query: options.query,
176
+ query: trimmed,
161
177
  error: summarizeError(error),
162
178
  });
163
179
  return false;
@@ -178,11 +178,14 @@ export function useCommandBarPaneTemplateActions({
178
178
  return;
179
179
  }
180
180
  try {
181
+ // A watchlist's name reads as its symbols, at most the function's maximum, and the bar says so.
182
+ const notes: string[] = [];
181
183
  const symbols = await resolveTickerListInput(
182
184
  trimmedList,
183
185
  activeCollectionId,
184
186
  buildWorkflowDeps(),
185
187
  template.shortcut?.keepArgToken,
188
+ { maximum: template.headless?.argument.maximum, notes },
186
189
  );
187
190
  const createOptions = {
188
191
  arg: trimmedList,
@@ -192,6 +195,7 @@ export function useCommandBarPaneTemplateActions({
192
195
  openPaneTemplateWorkflow(template, { arg: trimmedArg });
193
196
  return;
194
197
  }
198
+ if (notes.length > 0) notify(notes.join(" "), { type: "info" });
195
199
  await openPaneTemplateDirect(template, createOptions);
196
200
  } catch {
197
201
  openPaneTemplateWorkflow(template, { arg: trimmedArg });
@@ -209,6 +213,7 @@ export function useCommandBarPaneTemplateActions({
209
213
  activeTickerSymbol,
210
214
  buildWorkflowDeps,
211
215
  getPaneTemplateContext,
216
+ notify,
212
217
  openModeRoute,
213
218
  openPaneTemplateDirect,
214
219
  openPaneTemplateWorkflow,
@@ -13,11 +13,12 @@ import {
13
13
  type AssistRowHandlers,
14
14
  } from "../../assist/model";
15
15
  import { matchPrefix, type Command } from "../../commands/registry";
16
+ import { pastedRootList } from "../../commands/collection-list";
16
17
  import { isCollectionCommand, SECURITY_DESCRIPTION_SEARCH } from "../../helpers";
17
18
  import { recentPaneTemplateArg } from "../../pane-templates/items";
18
- import { dedupeById } from "../../view-model";
19
+ import { dedupeById, PASTED_LIST_CATEGORY } from "../../view-model";
19
20
  import type { ResultItem } from "../../list/model";
20
- import type { parseRootShortcutIntent } from "./shortcuts";
21
+ import { shortcutArgument, type parseRootShortcutIntent } from "./shortcuts";
21
22
  import type { CommandBarRoute } from "../../workflow/types";
22
23
  import { createRootCommandItemBuilder } from "./command-items";
23
24
  import { buildRootShortcutItem } from "./shortcut-items";
@@ -127,6 +128,22 @@ function isAssistSectionVisible(
127
128
  return assist.auto;
128
129
  }
129
130
 
131
+ /** "Add 4 symbols to a watchlist", which runs AW on the list as its entries, Bloomberg's codes kept whole. */
132
+ function pastedListItem(
133
+ symbols: readonly string[],
134
+ executeCollectionCommand: RootResultModelOptions["executeCollectionCommand"],
135
+ ): ResultItem {
136
+ const shown = symbols.slice(0, 6).join(", ");
137
+ return {
138
+ id: `pasted-list:${symbols.length}:${symbols[0]}`,
139
+ label: `Add ${symbols.length} symbols to a watchlist`,
140
+ detail: symbols.length > 6 ? `${shown} and ${symbols.length - 6} more` : shown,
141
+ category: PASTED_LIST_CATEGORY,
142
+ kind: "action",
143
+ action: () => { void executeCollectionCommand("add-watchlist", symbols.join(", ")); },
144
+ };
145
+ }
146
+
130
147
  /**
131
148
  * The text a key would replay. An inferred ticker is left out on purpose: the
132
149
  * key should follow the focused ticker at press time, not freeze today's.
@@ -277,6 +294,8 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
277
294
 
278
295
  const items: ResultItem[] = [];
279
296
  const match = matchPrefix(rootQuery, availableCommands);
297
+ // A pasted list, which the bar flattens into one line, leads with adding its symbols. The AI is still offered.
298
+ const pastedList = rootShortcutIntent.kind === "none" && !match && rootQuery ? pastedRootList(rootQuery) : null;
280
299
  let initialIdx = 0;
281
300
  // Off when the code's own rows only say why the argument opens nothing (`PF Nope`).
282
301
  let shortcutRuns = true;
@@ -296,7 +315,7 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
296
315
  const templateItems = matchingTemplates.length > 0
297
316
  ? matchingTemplates.map((template) => createPaneTemplateItem(template, {
298
317
  category: "Panes",
299
- createOptions: rootShortcutIntent.argText ? { arg: rootShortcutIntent.argText } : undefined,
318
+ createOptions: shortcutArgument(rootShortcutIntent) ? { arg: shortcutArgument(rootShortcutIntent) } : undefined,
300
319
  showShortcut: true,
301
320
  shortcutExecution: true,
302
321
  }))
@@ -396,6 +415,7 @@ export function buildRootResultModel(options: RootResultModelOptions): RootResul
396
415
  ...tickerActionItems(),
397
416
  ...pluginCommandItems(),
398
417
  ];
418
+ if (pastedList) items.push(pastedListItem(pastedList, executeCollectionCommand));
399
419
  items.push(...rankMatchBlock(allItems, providerMatchItems, rootQuery));
400
420
  }
401
421
 
@@ -14,7 +14,7 @@ import {
14
14
  } from "../../helpers";
15
15
  import type { ResultItem } from "../../list/model";
16
16
  import { getPaneTemplateArgKind } from "../../pane-templates/items";
17
- import { parseRootShortcutIntent } from "./shortcuts";
17
+ import { parseRootShortcutIntent, shortcutArgument } from "./shortcuts";
18
18
  import { buildHelpArgumentItems } from "./help-items";
19
19
  import { recordFunctionOpen } from "../../../../telemetry/usage-counts";
20
20
 
@@ -109,9 +109,11 @@ export function buildImmediateRootSelection(options: RootSelectionCommandOptions
109
109
  promptTicker: options.promptTickerSymbol,
110
110
  });
111
111
  if (intent.kind !== "none" && intent.source === "pane-template") {
112
+ // An issuer's function opens on the ticker in focus it was given, as if typed.
113
+ const arg = shortcutArgument(intent);
112
114
  return options.createPaneTemplateItem(intent.template, {
113
115
  category: "Panes",
114
- createOptions: intent.argText ? { arg: intent.argText } : undefined,
116
+ createOptions: arg ? { arg } : undefined,
115
117
  showShortcut: true,
116
118
  shortcutExecution: true,
117
119
  });
@@ -35,7 +35,7 @@ export function buildRootShortcutFeedback({
35
35
  if (rootShortcutIntent.source === "pane-template") {
36
36
  const argKind = getPaneTemplateArgKind(rootShortcutIntent.template);
37
37
  if (argKind === "ticker") {
38
- if (rootShortcutIntent.template.shortcut?.argOptional && !rootShortcutIntent.argText) {
38
+ if (rootShortcutIntent.template.shortcut?.argOptional && !rootShortcutIntent.argText && !rootShortcutIntent.inferredArg) {
39
39
  return `Shortcut: ${rootShortcutIntent.label}`;
40
40
  }
41
41
  // Same ticker the intent inferred: the prompt's, so a linked desk counts.
@@ -17,7 +17,7 @@ import {
17
17
  resolvePreferredCollectionTarget,
18
18
  resolveSoleCollectionTarget,
19
19
  } from "../../workflow/ops";
20
- import type { parseRootShortcutIntent } from "./shortcuts";
20
+ import { shortcutArgument, type parseRootShortcutIntent } from "./shortcuts";
21
21
  import { recordFunctionOpen } from "../../../../telemetry/usage-counts";
22
22
 
23
23
  type RootShortcutIntent = ReturnType<typeof parseRootShortcutIntent>;
@@ -62,11 +62,10 @@ export function buildRootShortcutItem({
62
62
  if (rootShortcutIntent.kind === "none") return null;
63
63
 
64
64
  if (rootShortcutIntent.source === "pane-template") {
65
+ const arg = shortcutArgument(rootShortcutIntent);
65
66
  return createPaneTemplateItem(rootShortcutIntent.template, {
66
67
  category: "Panes",
67
- createOptions: rootShortcutIntent.argText
68
- ? { arg: rootShortcutIntent.argText }
69
- : undefined,
68
+ createOptions: arg ? { arg } : undefined,
70
69
  showShortcut: true,
71
70
  shortcutExecution: true,
72
71
  });
@@ -1,4 +1,8 @@
1
1
  import type { CommandDef, PaneTemplateDef } from "../../../../types/plugin";
2
+ import { tickerFirstQuery } from "./ticker-first";
3
+ import { kindFromListingSyntax } from "../../../../tickers/instrument-kind";
4
+ import { isRoundTheClockCoin } from "../../../../utils/crypto-pair";
5
+ import { parsePublicTickerKey } from "../../../../utils/exchanges";
2
6
  import { getCommandPrefixes, type Command } from "../../commands/registry";
3
7
  import { getPaneTemplateDisplayLabel, paneTemplateShortcutPrefixes } from "../../pane-templates/items";
4
8
 
@@ -14,6 +18,8 @@ interface ShortcutIntentBase {
14
18
  argPlaceholder?: string;
15
19
  argText: string;
16
20
  completionQuery: string | null;
21
+ /** The ticker in focus the argument was filled with, when none was typed. */
22
+ inferredArg?: string;
17
23
  }
18
24
 
19
25
  interface CommandShortcutIntent extends ShortcutIntentBase {
@@ -72,9 +78,9 @@ export function getPluginCommandShortcutArgKind(command: CommandDef): RootShortc
72
78
  return command.shortcutArg?.kind ?? (command.shortcutArg ? "text" : null);
73
79
  }
74
80
 
75
- function inferShortcutArg(argKind: RootShortcutArgKind | null, activeTicker: string | null): string | null {
81
+ function inferShortcutArg(argKind: RootShortcutArgKind | null, activeTicker: string | null, issuer = false): string | null {
76
82
  if (!activeTicker) return null;
77
- if (argKind === "ticker" || argKind === "ticker-list") {
83
+ if (argKind === "ticker" || argKind === "ticker-list" || (issuer && argKind === "text")) {
78
84
  return activeTicker;
79
85
  }
80
86
  return null;
@@ -142,6 +148,28 @@ export function leadingShortcutCode({
142
148
  .find((candidate) => candidate.prefix === first)?.prefix ?? null;
143
149
  }
144
150
 
151
+ /** What a shortcut opens with: the argument typed, else the ticker in focus an issuer's function took. */
152
+ export function shortcutArgument(intent: Exclude<ShortcutIntent, { kind: "none" }>): string {
153
+ return intent.argText || intent.inferredArg || "";
154
+ }
155
+
156
+ /** A function whose argument is a company it reports on, which opens on the ticker in focus when none is typed. */
157
+ function takesIssuer(template: PaneTemplateDef | undefined): boolean {
158
+ return template?.shortcut?.focusedIssuer === true;
159
+ }
160
+
161
+ /**
162
+ * Whether a ticker in focus can be a company an issuer's function reports on:
163
+ * never an index, a currency or coin pair, a future or a coin (`^VIX`,
164
+ * `EURUSD=X`, `EUR/USD`, `CL=F`, `BTC-USD`), with which CDS and TRACE open
165
+ * market-wide.
166
+ */
167
+ function canBeIssuer(symbol: string): boolean {
168
+ const { symbol: bare, exchange } = parsePublicTickerKey(symbol);
169
+ if (bare.includes("/") || isRoundTheClockCoin(symbol, exchange)) return false;
170
+ return kindFromListingSyntax(symbol, exchange) == null;
171
+ }
172
+
145
173
  export function parseRootShortcutIntent({
146
174
  query,
147
175
  commands,
@@ -158,23 +186,38 @@ export function parseRootShortcutIntent({
158
186
  /** The command prompt's instrument, used when a pane requires a ticker and the focused pane has none. */
159
187
  promptTicker?: string | null;
160
188
  }): ShortcutIntent {
161
- const trimmed = query.trim();
162
- if (!trimmed) return { kind: "none" };
189
+ const typed = query.trim();
190
+ if (!typed) return { kind: "none" };
163
191
 
164
- const upper = trimmed.toUpperCase();
165
- const match = buildShortcutCandidates(commands, pluginCommands, paneTemplates).find((candidate) => {
166
- if (upper === candidate.prefix) return true;
167
- return !!candidate.argKind && upper.startsWith(`${candidate.prefix} `);
168
- });
169
- if (!match) return { kind: "none" };
192
+ const candidates = buildShortcutCandidates(commands, pluginCommands, paneTemplates);
193
+ const leading = (text: string) => {
194
+ const upper = text.toUpperCase();
195
+ return candidates.find((candidate) => {
196
+ if (upper === candidate.prefix) return true;
197
+ return !!candidate.argKind && upper.startsWith(`${candidate.prefix} `);
198
+ });
199
+ };
200
+ let trimmed = typed;
201
+ let match = leading(trimmed);
202
+ if (!match) {
203
+ // Bloomberg's order, the ticker first: `NFE CDS`, `NFE US Equity CDS`.
204
+ const reordered = tickerFirstQuery(typed, (code) => candidates.some((candidate) => candidate.prefix === code && candidate.argKind
205
+ && (candidate.argKind !== "text" || takesIssuer(candidate.template))));
206
+ match = reordered ? leading(reordered) : undefined;
207
+ if (!reordered || !match) return { kind: "none" };
208
+ trimmed = reordered;
209
+ }
170
210
 
171
211
  const argText = trimmed.slice(match.prefix.length).trim();
172
- // A pane that requires a ticker takes the one already in the prompt. An
173
- // optional ticker stays unbound, and other commands keep the focused ticker.
212
+ // A pane that requires a ticker takes the one already in the prompt, and so
213
+ // does one that takes an issuer (CDS, TRACE). Another optional ticker stays
214
+ // unbound, and other commands keep the focused ticker.
215
+ const issuer = takesIssuer(match.template);
216
+ const focused = promptTicker ?? activeTicker;
174
217
  const inferFrom = match.source === "pane-template"
175
- ? (match.template?.shortcut?.argOptional ? null : (promptTicker ?? activeTicker))
218
+ ? (match.template?.shortcut?.argOptional && !(issuer && focused && canBeIssuer(focused)) ? null : focused)
176
219
  : activeTicker;
177
- const inferredArg = inferShortcutArg(match.argKind, inferFrom);
220
+ const inferredArg = inferShortcutArg(match.argKind, inferFrom, issuer);
178
221
  const completionQuery = inferredArg ? `${match.prefix} ${inferredArg}` : null;
179
222
 
180
223
  let kind: Exclude<ShortcutIntentKind, "none">;
@@ -195,6 +238,7 @@ export function parseRootShortcutIntent({
195
238
  argPlaceholder: match.argPlaceholder,
196
239
  argText,
197
240
  completionQuery,
241
+ ...(kind === "inferred-complete" && inferredArg && issuer ? { inferredArg } : {}),
198
242
  };
199
243
 
200
244
  if (match.source === "command" && match.command) {
@@ -0,0 +1,32 @@
1
+ import { readTerminalListingCode } from "../../../../tickers/terminal-codes";
2
+
3
+ /** A plain ticker, as one word: NFE, BRK.B, 0700, VOD:LSE. */
4
+ const TICKER_WORD = /^\$?[A-Za-z0-9][A-Za-z0-9.\-]{0,11}(?::[A-Za-z0-9]{1,8})?$/;
5
+
6
+ /**
7
+ * The ticker a query names before a function code: one word, or a terminal
8
+ * code (`NFE US Equity`, `VOD LN`) read as its listing. Null for anything
9
+ * else, so a company's name stays a search.
10
+ */
11
+ function tickerBeforeCode(text: string): string | null {
12
+ const words = text.trim().split(/\s+/);
13
+ if (words.length === 1) return TICKER_WORD.test(words[0]!) ? words[0]!.replace(/^\$/, "").toUpperCase() : null;
14
+ return readTerminalListingCode(text)?.key ?? null;
15
+ }
16
+
17
+ /**
18
+ * A query in Bloomberg's word order, the ticker first, as the bar reads it:
19
+ * `NFE CDS` and `NFE US Equity CDS` are `CDS NFE`, when `takesTicker` says
20
+ * the last word is a function code that takes one. Null for anything else,
21
+ * and for a whole query that is a listing's code, whose market code is a
22
+ * function's too: `SAP GR` is SAP on Xetra, `AMD GF` AMD in Frankfurt,
23
+ * `600519 CG` Moutai in Shanghai.
24
+ */
25
+ export function tickerFirstQuery(query: string, takesTicker: (code: string) => boolean): string | null {
26
+ const words = query.trim().split(/\s+/);
27
+ if (words.length < 2 || readTerminalListingCode(query) != null) return null;
28
+ const code = words.at(-1)!.toUpperCase();
29
+ if (!takesTicker(code)) return null;
30
+ const ticker = tickerBeforeCode(words.slice(0, -1).join(" "));
31
+ return ticker ? `${code} ${ticker}` : null;
32
+ }