@gloom-sh/terminal 0.19.3 → 0.19.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 (226) hide show
  1. package/package.json +4 -2
  2. package/src/api-client/errors.ts +8 -0
  3. package/src/api-client/index.ts +18 -0
  4. package/src/api-client/request.ts +295 -42
  5. package/src/api-client/socket.ts +95 -0
  6. package/src/app/keybindings/actions.ts +1 -1
  7. package/src/app/pane-runtime/index.tsx +1 -1
  8. package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
  9. package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
  10. package/src/app/pane-runtime/ticker-open-target.ts +12 -2
  11. package/src/cli/commands/command-utils.ts +4 -0
  12. package/src/cli/commands/market.ts +119 -27
  13. package/src/cli/commands/search.ts +1 -1
  14. package/src/cli/commands/ticker.ts +10 -6
  15. package/src/cli/currency-name-hint.ts +60 -0
  16. package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
  17. package/src/cli/desktop-pane-shot.ts +2 -1
  18. package/src/cli/history-rows.ts +18 -1
  19. package/src/cli/known-gaps.ts +17 -2
  20. package/src/cli/not-a-ticker.ts +5 -3
  21. package/src/cli/pane-functions/catalog.ts +9 -1
  22. package/src/cli/pane-functions/headless.ts +7 -3
  23. package/src/cli/pane-functions/market-session.ts +6 -7
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  26. package/src/components/chart/composite/time-axis.ts +17 -2
  27. package/src/components/command-bar/action-runtime.ts +2 -0
  28. package/src/components/command-bar/commands/direct/runtime.ts +3 -3
  29. package/src/components/command-bar/helpers.ts +2 -0
  30. package/src/components/command-bar/list/model.ts +9 -0
  31. package/src/components/command-bar/pane-actions.ts +46 -35
  32. package/src/components/command-bar/pane-templates/workflow.ts +6 -0
  33. package/src/components/command-bar/panel/index.tsx +30 -3
  34. package/src/components/command-bar/panel/types.ts +7 -0
  35. package/src/components/command-bar/routes/root/results.ts +4 -4
  36. package/src/components/command-bar/routes/root/selection.ts +3 -2
  37. package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
  38. package/src/components/command-bar/routing/launch-request.ts +3 -2
  39. package/src/components/command-bar/routing/list-state.ts +4 -1
  40. package/src/components/command-bar/surface/index.tsx +15 -1
  41. package/src/components/layout/floating-pane.tsx +10 -0
  42. package/src/components/layout/pane/frame.tsx +6 -0
  43. package/src/components/layout/pane/header.tsx +244 -42
  44. package/src/components/layout/pane/index.tsx +20 -2
  45. package/src/components/layout/shell/active-drag.ts +160 -28
  46. package/src/components/layout/shell/drag/index.ts +99 -96
  47. package/src/components/layout/shell/drag/live.ts +3 -17
  48. package/src/components/layout/shell/drag/magnets.ts +304 -0
  49. package/src/components/layout/shell/drag/overlays.tsx +77 -75
  50. package/src/components/layout/shell/drag/runtime.ts +12 -7
  51. package/src/components/layout/shell/index.tsx +66 -32
  52. package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
  53. package/src/components/layout/shell/native/surfaces.ts +1 -9
  54. package/src/components/layout/shell/native/window-state.ts +21 -25
  55. package/src/components/layout/shell/pane/layers.tsx +153 -24
  56. package/src/components/layout/shell/shortcuts.ts +4 -1
  57. package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
  58. package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
  59. package/src/components/layout/status-bar.tsx +75 -6
  60. package/src/components/layout/window-controls.tsx +96 -35
  61. package/src/components/layout/window-fullscreen.ts +20 -0
  62. package/src/components/quote-flash.ts +36 -32
  63. package/src/core/app-runtime.ts +4 -1
  64. package/src/core/connection-health.ts +76 -1
  65. package/src/core/state/app/command-bar-launch.ts +12 -0
  66. package/src/core/state/app/layout.ts +4 -3
  67. package/src/core/state/app/types.ts +4 -1
  68. package/src/data/config/layout.ts +2 -2
  69. package/src/data/config/store/fold-panes.ts +6 -1
  70. package/src/i18n/es.ts +8 -1
  71. package/src/i18n/ja.ts +8 -1
  72. package/src/i18n/ko.ts +8 -1
  73. package/src/i18n/zh-cn.ts +8 -1
  74. package/src/i18n/zh-tw.ts +8 -1
  75. package/src/layout/pane-follow.ts +3 -2
  76. package/src/layout/pane-layout-move.ts +2 -1
  77. package/src/layout/pane-manager/dock-stack.ts +38 -0
  78. package/src/layout/pane-manager/dock-tree.ts +76 -15
  79. package/src/layout/pane-manager/docking.ts +48 -6
  80. package/src/layout/pane-manager/floating-actions.ts +12 -3
  81. package/src/layout/pane-manager/floating-placement.ts +189 -0
  82. package/src/layout/pane-manager/floating.ts +23 -4
  83. package/src/layout/pane-manager/gridlock.ts +16 -4
  84. package/src/layout/pane-manager/hidden-panes.ts +30 -1
  85. package/src/layout/pane-manager/index.ts +2 -0
  86. package/src/layout/pane-manager/layout-state.ts +17 -0
  87. package/src/layout/pane-manager/types.ts +4 -1
  88. package/src/layout/ticker-retarget.ts +88 -0
  89. package/src/layout-marketplace/cloud.ts +9 -1
  90. package/src/market-data/connection-follow.ts +68 -0
  91. package/src/market-data/coordinator/entries.ts +15 -3
  92. package/src/market-data/coordinator/events.ts +17 -1
  93. package/src/market-data/coordinator/financials.ts +20 -7
  94. package/src/market-data/coordinator/index.ts +217 -4
  95. package/src/market-data/coordinator/quotes.ts +10 -0
  96. package/src/market-data/frame-scheduler.ts +47 -10
  97. package/src/market-data/frame-wake.ts +74 -0
  98. package/src/market-data/futures-board.ts +7 -6
  99. package/src/market-data/hooks.tsx +43 -3
  100. package/src/market-data/performance.ts +78 -9
  101. package/src/market-data/request-types.ts +6 -3
  102. package/src/news/aggregator.ts +12 -1
  103. package/src/plugins/builtin/alerts/cli.ts +2 -1
  104. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  105. package/src/plugins/builtin/attention/evidence.ts +1 -1
  106. package/src/plugins/builtin/awards/client.ts +1 -1
  107. package/src/plugins/builtin/awards/evidence.ts +1 -1
  108. package/src/plugins/builtin/awards/pane.tsx +2 -1
  109. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  110. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  111. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  112. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  113. package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
  114. package/src/plugins/builtin/buildout/model/index.ts +6 -0
  115. package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
  116. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  117. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  118. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  119. package/src/plugins/builtin/chart-composer/index.tsx +13 -0
  120. package/src/plugins/builtin/chat/controller/index.ts +10 -3
  121. package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
  122. package/src/plugins/builtin/chat/status-widget.tsx +3 -1
  123. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  124. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  125. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  126. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  127. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  128. package/src/plugins/builtin/cot/headless.ts +9 -3
  129. package/src/plugins/builtin/cot/model.ts +44 -3
  130. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  131. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  132. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  133. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  134. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  135. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  136. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  137. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  138. package/src/plugins/builtin/futures/series.ts +16 -1
  139. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  140. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  141. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  142. package/src/plugins/builtin/gpu/headless.ts +2 -1
  143. package/src/plugins/builtin/help/function-card.tsx +2 -1
  144. package/src/plugins/builtin/help/index.tsx +3 -2
  145. package/src/plugins/builtin/insider/display.ts +45 -6
  146. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  147. package/src/plugins/builtin/iv-history/client.ts +2 -1
  148. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  149. package/src/plugins/builtin/jobs/pages.ts +4 -4
  150. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  151. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  152. package/src/plugins/builtin/members/client.ts +1 -1
  153. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  154. package/src/plugins/builtin/mna/pane.tsx +4 -1
  155. package/src/plugins/builtin/options/market-reference.ts +1 -1
  156. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  157. package/src/plugins/builtin/options/view.tsx +2 -1
  158. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  159. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  160. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  161. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  162. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  163. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  164. package/src/plugins/builtin/perps/client.ts +1 -1
  165. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  166. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  167. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  168. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  169. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  170. package/src/plugins/builtin/research/index.tsx +1 -0
  171. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  172. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  173. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  174. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  175. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  176. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  177. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  178. package/src/plugins/builtin/sec/index.tsx +7 -4
  179. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  180. package/src/plugins/builtin/sectors/client.ts +18 -8
  181. package/src/plugins/builtin/sectors/index.tsx +19 -5
  182. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  183. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  184. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  185. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  186. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  187. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  188. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  189. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  190. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  191. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
  192. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
  193. package/src/plugins/builtin/time-sales/client.ts +1 -0
  194. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  195. package/src/plugins/builtin/yield-curve/headless.ts +3 -1
  196. package/src/portfolio/column-values.ts +76 -10
  197. package/src/react/async-resource.ts +12 -0
  198. package/src/remote/controller.ts +3 -1
  199. package/src/renderers/browser/app-services.ts +8 -1
  200. package/src/renderers/browser/cloud-transport.ts +6 -1
  201. package/src/renderers/cloudflare/worker.ts +24 -2
  202. package/src/renderers/dom/host/box.tsx +204 -176
  203. package/src/renderers/dom/host/style.ts +49 -20
  204. package/src/renderers/dom/host/text.tsx +3 -2
  205. package/src/renderers/dom/styles.css +32 -0
  206. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  207. package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
  208. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  209. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  210. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  211. package/src/renderers/electrobun/shared/protocol.ts +6 -0
  212. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  213. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  214. package/src/shares/portable-layout.ts +99 -2
  215. package/src/sources/provider-router/index.ts +9 -3
  216. package/src/sources/provider-router/sources.ts +26 -1
  217. package/src/sync/core-contributors.ts +18 -4
  218. package/src/time-series/price-units.ts +11 -0
  219. package/src/time-series/resolve.ts +12 -0
  220. package/src/types/config.ts +17 -1
  221. package/src/types/plugin.ts +6 -0
  222. package/src/ui/host.tsx +2 -0
  223. package/src/utils/currency-names.ts +20 -0
  224. package/src/utils/currency-pair.ts +6 -0
  225. package/src/utils/exchange-rate-snapshot.ts +20 -2
  226. package/src/utils/fx-market-hours.ts +43 -0
@@ -5,12 +5,13 @@ import type {
5
5
  DesktopBackendRequestResponse,
6
6
  DesktopHostRequest,
7
7
  DesktopWindowControlAction,
8
+ DesktopWindowResizeEdge,
8
9
  } from "../../shared/protocol";
9
10
  import { safeExternalUrl } from "../../../../utils/external-url";
10
11
  import { getContextMenuRequestId, normalizeContextMenuItems } from "../context-menu/normalize";
11
12
  import { MAIN_WINDOW_RPC_KEY } from "../window/focus";
12
13
  import { applyDesktopWindowControl } from "../window/controls";
13
- import { startSystemWindowMove } from "../window/windows-native";
14
+ import { startSystemWindowMove, startSystemWindowResize } from "../window/windows-native";
14
15
  import { saveTextFileToDownloads } from "../../../../utils/save-text-file";
15
16
  import { setAppBadge } from "./app-badge";
16
17
  import { desktopBootFramePath, saveDesktopBootFrame } from "../window/boot-frame";
@@ -55,6 +56,14 @@ function isWindowFullscreen(backend: DesktopBackend, windowKey: string | undefin
55
56
  }
56
57
  }
57
58
 
59
+ function isWindowMaximized(backend: DesktopBackend, windowKey: string | undefined): boolean {
60
+ try {
61
+ return windowForRpcKey(backend, windowKey)?.isMaximized?.() === true;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+
58
67
  function controlWindow(
59
68
  backend: DesktopBackend,
60
69
  windowKey: string | undefined,
@@ -82,6 +91,11 @@ function exitDesktopApp(backend: DesktopBackend): void {
82
91
  Utils.quit();
83
92
  }
84
93
 
94
+ function normalizeWindowResizeEdge(edge: unknown): DesktopWindowResizeEdge {
95
+ if (edge === "top" || edge === "top-left" || edge === "top-right") return edge;
96
+ throw new Error("host.startWindowResize requires a top edge or corner.");
97
+ }
98
+
85
99
  function normalizeWindowControlAction(action: unknown): DesktopWindowControlAction {
86
100
  if (action === "minimize" || action === "toggle-maximize" || action === "close") {
87
101
  return action;
@@ -112,6 +126,8 @@ export async function handleDesktopHostRequest(
112
126
  }
113
127
  case "host.windowFullscreen":
114
128
  return isWindowFullscreen(backend, backend.rpcs.getRpcWindowKey(rpc));
129
+ case "host.windowMaximized":
130
+ return isWindowMaximized(backend, backend.rpcs.getRpcWindowKey(rpc));
115
131
  case "host.startWindowDrag": {
116
132
  const targetWindow = windowForRpcKey(backend, backend.rpcs.getRpcWindowKey(rpc));
117
133
  if (!targetWindow?.ptr || !startSystemWindowMove(targetWindow.ptr)) {
@@ -119,6 +135,14 @@ export async function handleDesktopHostRequest(
119
135
  }
120
136
  return null;
121
137
  }
138
+ case "host.startWindowResize": {
139
+ const edge = normalizeWindowResizeEdge(request.payload.edge);
140
+ const targetWindow = windowForRpcKey(backend, backend.rpcs.getRpcWindowKey(rpc));
141
+ if (!targetWindow?.ptr || !startSystemWindowResize(targetWindow.ptr, edge)) {
142
+ throw new Error("This window cannot be resized by the system.");
143
+ }
144
+ return null;
145
+ }
122
146
  case "host.openExternal": {
123
147
  if (typeof request.payload.url !== "string") {
124
148
  throw new Error("host.openExternal requires a URL.");
@@ -144,6 +144,14 @@ try {
144
144
  ].join("\n");
145
145
  }
146
146
 
147
+ /**
148
+ * How long a restart waits for its script, with the error screen saying the
149
+ * restart was asked. Windows PowerShell started by the Task Scheduler can take
150
+ * over 20 s to run its first line: 23 s on an idle Windows on Arm machine,
151
+ * over a minute on a busy one, where a task runs below normal priority.
152
+ */
153
+ const RESTART_SCRIPT_START_TIMEOUT_MS = 120_000;
154
+
147
155
  /**
148
156
  * Electrobun puts the Windows app in a job that ends every process it starts
149
157
  * when it exits, so the script runs from a scheduled task, which outlives it.
@@ -164,7 +172,7 @@ async function scheduleWindowsRelaunch(context: RelaunchContext): Promise<void>
164
172
  taskName: `GloomRestart-${context.pid}`,
165
173
  home: context.home,
166
174
  }));
167
- const answer = await runScriptAfterExit(script, log, cancel, `GloomRestart-${context.pid}`);
175
+ const answer = await runScriptAfterExit(script, log, cancel, `GloomRestart-${context.pid}`, RESTART_SCRIPT_START_TIMEOUT_MS);
168
176
  if (answer.kind !== "started") throw new Error(`the restart script did not start: ${answer.reason}`);
169
177
  }
170
178
 
@@ -5,7 +5,10 @@ import { readFile, writeFile } from "fs/promises";
5
5
  * it runs: its own files are locked until it quits.
6
6
  */
7
7
 
8
- /** How long a script has to answer before the app stops waiting and keeps running. */
8
+ /**
9
+ * How long a script has, by default, to answer before the app stops waiting
10
+ * and keeps running. The app may still be opening: no window shows until then.
11
+ */
9
12
  const SCRIPT_START_TIMEOUT_MS = 20_000;
10
13
 
11
14
  /**
@@ -62,16 +65,16 @@ function schtasks(...args: string[]): void {
62
65
  * Runs `script` from the scheduled task `taskName`, which outlives the app (a
63
66
  * child of its process dies with it), and resolves to the answer it writes to
64
67
  * `log`: only on `started` may the app quit for it. The script removes the
65
- * task. When it does not answer in time, the app writes `cancel`, which keeps
66
- * a script that starts late from doing anything, and this throws with the
67
- * task gone, as it does when the task could not be made.
68
+ * task. When it does not answer within `timeoutMs`, the app writes `cancel`,
69
+ * which keeps a script that starts late from doing anything, and this throws
70
+ * with the task gone, as it does when the task could not be made.
68
71
  */
69
- export async function runScriptAfterExit(script: string, log: string, cancel: string, taskName: string): Promise<ScriptAnswer> {
72
+ export async function runScriptAfterExit(script: string, log: string, cancel: string, taskName: string, timeoutMs = SCRIPT_START_TIMEOUT_MS): Promise<ScriptAnswer> {
70
73
  const command = powershellCommand(script).map((part) => (part === script ? `"${part}"` : part)).join(" ");
71
74
  try {
72
75
  schtasks("/create", "/tn", taskName, "/tr", command, "/sc", "once", "/st", "00:00", "/f");
73
76
  schtasks("/run", "/tn", taskName);
74
- const deadline = Date.now() + SCRIPT_START_TIMEOUT_MS;
77
+ const deadline = Date.now() + timeoutMs;
75
78
  while (Date.now() < deadline) {
76
79
  const answer = scriptAnswer(await readFile(log, "utf8").catch(() => ""));
77
80
  if (answer) return answer;
@@ -1,4 +1,5 @@
1
1
  import { dlopen, FFIType, ptr, type Pointer } from "bun:ffi";
2
+ import type { DesktopWindowResizeEdge } from "../../shared/protocol";
2
3
 
3
4
  const WINDOWS_HANDLE_MAX_ATTEMPTS = 20;
4
5
  const WINDOWS_HANDLE_RETRY_DELAY_MS = 100;
@@ -57,6 +58,10 @@ function loadWin32() {
57
58
  args: [FFIType.u32, FFIType.ptr],
58
59
  returns: FFIType.bool,
59
60
  },
61
+ IsZoomed: {
62
+ args: [FFIType.ptr],
63
+ returns: FFIType.bool,
64
+ },
60
65
  });
61
66
  }
62
67
 
@@ -93,6 +98,8 @@ export function fitPageToClientArea(windowHandle: Pointer): boolean {
93
98
  const WM_NCLBUTTONDOWN = 0x00a1;
94
99
  const WM_CANCELMODE = 0x001f;
95
100
  const HTCAPTION = 2;
101
+ /** HTTOP, HTTOPLEFT, HTTOPRIGHT. */
102
+ const TOP_EDGE_HIT_TESTS: Record<DesktopWindowResizeEdge, number> = { top: 12, "top-left": 13, "top-right": 14 };
96
103
  /** GUITHREADINFO on 64-bit Windows: two DWORDs, six window handles, a RECT. */
97
104
  const GUI_THREAD_INFO_SIZE = 72;
98
105
  const GUI_THREAD_INFO_CAPTURE_OFFSET = 24;
@@ -126,12 +133,30 @@ function mouseCaptureOnThreadOf(win32: Win32, windowHandle: Pointer): Pointer |
126
133
  export function startSystemWindowMove(windowHandle: Pointer): boolean {
127
134
  const win32 = win32OrNull();
128
135
  if (!win32) return false;
136
+ return pressNonClientArea(win32, windowHandle, HTCAPTION);
137
+ }
138
+
139
+ /**
140
+ * Hands a press on the page's top edge to Windows as a press on the frame's
141
+ * top edge, which the page covers: its size loop then resizes the window until
142
+ * the button comes up. A maximized window has no edge to pull, so the press
143
+ * moves it, as one at the top of a maximized title bar does. False off Windows.
144
+ */
145
+ export function startSystemWindowResize(windowHandle: Pointer, edge: DesktopWindowResizeEdge): boolean {
146
+ const win32 = win32OrNull();
147
+ if (!win32) return false;
148
+ const hitTest = win32.symbols.IsZoomed(windowHandle) ? HTCAPTION : TOP_EDGE_HIT_TESTS[edge];
149
+ return pressNonClientArea(win32, windowHandle, hitTest);
150
+ }
151
+
152
+ /** Presses the window's frame at `hitTest` where the pointer is, after the page lets go of the mouse. */
153
+ function pressNonClientArea(win32: Win32, windowHandle: Pointer, hitTest: number): boolean {
129
154
  const point = new Int32Array(2);
130
155
  if (!win32.symbols.GetCursorPos(ptr(point))) return false;
131
156
  const capture = mouseCaptureOnThreadOf(win32, windowHandle);
132
157
  if (capture && capture !== windowHandle) win32.symbols.PostMessageW(capture, WM_CANCELMODE, 0n, 0n);
133
158
  const position = ((point[1]! & 0xffff) << 16) | (point[0]! & 0xffff);
134
- return win32.symbols.PostMessageW(windowHandle, WM_NCLBUTTONDOWN, BigInt(HTCAPTION), BigInt(position >>> 0));
159
+ return win32.symbols.PostMessageW(windowHandle, WM_NCLBUTTONDOWN, BigInt(hitTest), BigInt(position >>> 0));
135
160
  }
136
161
 
137
162
  export function wideString(value: string): Uint8Array {
@@ -60,6 +60,9 @@ export interface DesktopRestartMessage {
60
60
 
61
61
  export type DesktopWindowControlAction = "minimize" | "toggle-maximize" | "close";
62
62
 
63
+ /** The window edges the page pulls itself: the frame's own stop under its top. */
64
+ export type DesktopWindowResizeEdge = "top" | "top-left" | "top-right";
65
+
63
66
  export type DesktopContextMenuItem =
64
67
  | { type: "divider" }
65
68
  | {
@@ -212,8 +215,11 @@ interface DesktopBackendRequestMap {
212
215
  "host.exit": { request: null; response: null };
213
216
  "host.windowControl": { request: { action: DesktopWindowControlAction }; response: null };
214
217
  "host.windowFullscreen": { request: null; response: boolean };
218
+ "host.windowMaximized": { request: null; response: boolean };
215
219
  /** Windows: moves the window with the pointer through the system's own move loop. */
216
220
  "host.startWindowDrag": { request: null; response: null };
221
+ /** Windows: resizes the window from its top edge through the system's own size loop. */
222
+ "host.startWindowResize": { request: { edge: DesktopWindowResizeEdge }; response: null };
217
223
  "host.openExternal": { request: { url: string }; response: boolean };
218
224
  "host.copyText": { request: { text: string }; response: null };
219
225
  "host.focusWindow": { request: null; response: null };
@@ -47,6 +47,13 @@ export const webRendererHost: RendererHost = {
47
47
  if (action === "close") await flushUsageCounts({ timeoutMs: 1_000 });
48
48
  await backendRequest("host.windowControl", { action });
49
49
  },
50
+ startWindowResize(edge) {
51
+ // Windows resizes the window itself, as it does from a native frame's edge.
52
+ if (detectPlatform() !== "win32") return;
53
+ void backendRequest("host.startWindowResize", { edge }).catch((error: unknown) => {
54
+ console.error("[desktop] could not start resizing the window", error instanceof Error ? error.message : String(error));
55
+ });
56
+ },
50
57
  async openExternal(url) {
51
58
  return await backendRequest("host.openExternal", { url });
52
59
  },
@@ -1,4 +1,5 @@
1
- import { setWindowFullscreen } from "../../../components/layout/window-fullscreen";
1
+ import { setWindowFullscreen, setWindowMaximized } from "../../../components/layout/window-fullscreen";
2
+ import { detectPlatform } from "../../../utils/platform";
2
3
  import { backendRequest } from "./backend-rpc";
3
4
 
4
5
  /**
@@ -12,7 +13,8 @@ const RESIZE_SETTLE_MS = 120;
12
13
  * Keeps the view's idea of its window's fullscreen state current. Electrobun
13
14
  * emits no fullscreen event and a webview cannot see its window's style mask,
14
15
  * but entering and leaving fullscreen always resizes the window, so the host
15
- * is asked every time the size settles.
16
+ * is asked every time the size settles. On Windows, so is maximizing, which
17
+ * takes away the window's top edge.
16
18
  */
17
19
  export function installElectrobunWindowFullscreenTracking(): () => void {
18
20
  let settleTimer: ReturnType<typeof setTimeout> | null = null;
@@ -26,7 +28,12 @@ export function installElectrobunWindowFullscreenTracking(): () => void {
26
28
  }
27
29
  reading = true;
28
30
  try {
29
- setWindowFullscreen(await backendRequest("host.windowFullscreen") === true);
31
+ const [fullscreen, maximized] = await Promise.all([
32
+ backendRequest("host.windowFullscreen"),
33
+ detectPlatform() === "win32" ? backendRequest("host.windowMaximized") : false,
34
+ ]);
35
+ setWindowFullscreen(fullscreen === true);
36
+ setWindowMaximized(maximized === true);
30
37
  } catch {
31
38
  // A host too old to answer has the window chrome the header already
32
39
  // assumes, so leaving the last known state alone is the safe read.
@@ -16,6 +16,8 @@ import type {
16
16
  } from "../types/plugin";
17
17
  import type { TickerRecord } from "../types/ticker";
18
18
  import { isRecord } from "../utils/guards";
19
+ import { buildDockStack, isDockStack } from "../layout/pane-manager/dock-stack";
20
+ import { getDockedInstanceIds } from "../layout/pane-manager/dock-tree";
19
21
 
20
22
  const MAX_LAYOUT_BYTES = 128 * 1024;
21
23
  // Pane runtime state doubles as a cache (news panes keep six figures of bytes of
@@ -464,6 +466,81 @@ function mapDockNode(node: DockLayoutNode | null, ids: ReadonlyMap<string, strin
464
466
  };
465
467
  }
466
468
 
469
+ /**
470
+ * A stack of tabs travels as its panes side by side, the form every app and
471
+ * the gallery accept, with its tabs in the state of its first pane under this
472
+ * key: an app that knows stacks puts them back together, and an older one
473
+ * shows them side by side and ignores the key.
474
+ */
475
+ export const SHARED_STACK_STATE_KEY = "dockStack";
476
+
477
+ interface SharedStack {
478
+ /** The stack's panes in tab order. */
479
+ tabs: string[];
480
+ /** The one it shows. */
481
+ shown: string;
482
+ }
483
+
484
+ /** Panes side by side, as even as a split tree goes, as shallow as it goes too: a long stack stays within the depth a share allows. */
485
+ function sideBySide(ids: readonly string[]): DockLayoutNode {
486
+ if (ids.length === 1) return { kind: "pane", instanceId: ids[0]! };
487
+ const half = Math.ceil(ids.length / 2);
488
+ return {
489
+ kind: "split",
490
+ axis: "horizontal",
491
+ ratio: half / ids.length,
492
+ first: sideBySide(ids.slice(0, half)),
493
+ second: sideBySide(ids.slice(half)),
494
+ };
495
+ }
496
+
497
+ /** `node` with every stack laid out side by side, the stacks it had added to `stacks`. */
498
+ function withStacksSideBySide(node: DockLayoutNode | null, stacks: SharedStack[]): DockLayoutNode | null {
499
+ if (!node || node.kind === "pane") return node;
500
+ if (isDockStack(node)) {
501
+ const tabs = getDockedInstanceIds(node);
502
+ stacks.push({ tabs, shown: tabs.includes(node.tabs.active) ? node.tabs.active : tabs[0]! });
503
+ return sideBySide(tabs);
504
+ }
505
+ return {
506
+ kind: "split",
507
+ axis: node.axis,
508
+ ratio: node.ratio,
509
+ first: withStacksSideBySide(node.first, stacks)!,
510
+ second: withStacksSideBySide(node.second, stacks)!,
511
+ };
512
+ }
513
+
514
+ function parseSharedStack(value: unknown): SharedStack | null {
515
+ if (!isRecord(value) || !Array.isArray(value.tabs) || typeof value.shown !== "string") return null;
516
+ const tabs = value.tabs.filter((id): id is string => typeof id === "string");
517
+ return tabs.length === value.tabs.length ? { tabs, shown: value.shown } : null;
518
+ }
519
+
520
+ /**
521
+ * `node` with the panes of `stack` stacked again, where they still fill one
522
+ * part of the tree on their own; as it is otherwise.
523
+ */
524
+ function restack(node: DockLayoutNode | null, stack: SharedStack): DockLayoutNode | null {
525
+ const want = new Set(stack.tabs);
526
+ let done = false;
527
+ const visit = (current: DockLayoutNode): { node: DockLayoutNode; ids: string[] } => {
528
+ if (current.kind === "pane") return { node: current, ids: [current.instanceId] };
529
+ const first = visit(current.first);
530
+ const second = visit(current.second);
531
+ const ids = [...first.ids, ...second.ids];
532
+ if (!done && ids.length === want.size && ids.every((id) => want.has(id))) {
533
+ done = true;
534
+ return { node: buildDockStack(stack.tabs, stack.shown)!, ids };
535
+ }
536
+ return {
537
+ node: first.node === current.first && second.node === current.second ? current : { ...current, first: first.node, second: second.node },
538
+ ids,
539
+ };
540
+ };
541
+ return node && want.size > 1 ? visit(node).node : node;
542
+ }
543
+
467
544
  function mapBinding(binding: PaneBinding | undefined, ids: ReadonlyMap<string, string>): PaneBinding | undefined {
468
545
  return binding?.kind === "follow"
469
546
  ? { kind: "follow", sourceInstanceId: ids.get(binding.sourceInstanceId) ?? binding.sourceInstanceId }
@@ -525,8 +602,17 @@ function publishableLayout(
525
602
  ...(settings ? { settings } : {}),
526
603
  };
527
604
  });
605
+ const stacks: SharedStack[] = [];
606
+ const dockRoot = mapDockNode(withStacksSideBySide(publicLayout.dockRoot, stacks), ids);
607
+ for (const stack of stacks) {
608
+ const tabs = stack.tabs.map((id) => ids.get(id) ?? id);
609
+ projectedState[tabs[0]!] = {
610
+ ...projectedState[tabs[0]!],
611
+ [SHARED_STACK_STATE_KEY]: { tabs, shown: ids.get(stack.shown) ?? stack.shown },
612
+ } as PaneRuntimeState;
613
+ }
528
614
  const projected: LayoutConfig = {
529
- dockRoot: mapDockNode(publicLayout.dockRoot, ids),
615
+ dockRoot,
530
616
  instances,
531
617
  floating: publicLayout.floating.map(({ instanceId, x, y, width, height, zIndex }) => ({
532
618
  instanceId: ids.get(instanceId) ?? instanceId,
@@ -665,8 +751,19 @@ export function materializeMarketplaceLayout(
665
751
  createId(instance.paneId, index),
666
752
  ]));
667
753
  if (new Set(ids.values()).size !== ids.size) throw new Error("Could not create unique pane ids for this layout.");
754
+ // The stacks travel side by side, their tabs noted in their first pane's state.
755
+ let dockRoot = mapDockNode(source.layout.dockRoot, ids);
756
+ for (const [id, state] of Object.entries(source.paneState)) {
757
+ const stack = parseSharedStack(state?.[SHARED_STACK_STATE_KEY]);
758
+ if (!stack) continue;
759
+ const tabs = stack.tabs.map((tab) => ids.get(folded.idMap.get(tab) ?? tab)).filter((tab): tab is string => !!tab);
760
+ const shown = ids.get(folded.idMap.get(stack.shown) ?? stack.shown);
761
+ if (tabs.length > 1 && tabs.length === new Set(tabs).size) dockRoot = restack(dockRoot, { tabs, shown: shown ?? tabs[0]! });
762
+ const { [SHARED_STACK_STATE_KEY]: _stack, ...rest } = state;
763
+ source.paneState[id] = rest as PaneRuntimeState;
764
+ }
668
765
  const layout: LayoutConfig = {
669
- dockRoot: mapDockNode(source.layout.dockRoot, ids),
766
+ dockRoot,
670
767
  instances: source.layout.instances.map((instance) => ({
671
768
  ...structuredClone(instance),
672
769
  instanceId: ids.get(instance.instanceId)!,
@@ -33,6 +33,7 @@ import type { TimeRange } from "../../time-series/range";
33
33
  import type { ChartResolutionSupport, ManualChartResolution } from "../../time-series/resolution";
34
34
  import { debugLog } from "../../utils/debug-log";
35
35
  import { errorMessage } from "../../utils/errors";
36
+ import { isPastPreCloseRefetch } from "../../utils/exchange-rate-snapshot";
36
37
  import { ProviderRouterBatchRoutes } from "./batches";
37
38
  import { createSignedInRealtimeCloudAccess, type RealtimeCloudAccess } from "./realtime-access";
38
39
  import { mapListingTargets, publicListingExchange } from "../listing-target";
@@ -51,7 +52,7 @@ import {
51
52
  type ProviderRouterCachePolicyKey,
52
53
  } from "./cache";
53
54
  import { ProviderRouterSearchRoutes } from "./search";
54
- import { collectCapabilityRouteSources, normalizeRouteSource } from "./sources";
55
+ import { collectCapabilityRouteSources, mergeRouteSourcesById, normalizeRouteSource } from "./sources";
55
56
  import type { ProviderRouterCoreDeps } from "./route-types";
56
57
  import { withProviderConnectionHealth } from "./connection-health";
57
58
  import { withFiledTrailingEps } from "../../time-series/filed-trailing-eps";
@@ -362,7 +363,12 @@ export class AssetDataRouter implements DataProvider {
362
363
  }
363
364
 
364
365
  async getExchangeRate(fromCurrency: string, context?: Pick<MarketDataRequestContext, "cacheMode">): Promise<number> {
365
- return (await this.getCachedQuery("getExchangeRate", [fromCurrency]).load({ force: context?.cacheMode === "refresh", background: this.revalidateInBackground })).value;
366
+ const query = this.getCachedQuery("getExchangeRate", [fromCurrency]);
367
+ // A rate read before the FX week closed is no close: once the close is out, wait for it instead of showing
368
+ // the old rate while it is read again, which the caller would then hold as read now.
369
+ const cached = query.getSnapshot().result;
370
+ const background = this.revalidateInBackground && !(cached && isPastPreCloseRefetch(cached));
371
+ return (await query.load({ force: context?.cacheMode === "refresh", background })).value;
366
372
  }
367
373
 
368
374
  async search(query: string, context?: SearchRequestContext): Promise<InstrumentSearchResult[]> {
@@ -612,7 +618,7 @@ export class AssetDataRouter implements DataProvider {
612
618
  ...this.registry.getEnabledCapabilities("news"),
613
619
  ]));
614
620
  }
615
- return sources
621
+ return mergeRouteSourcesById(sources)
616
622
  .filter((source) => source.id !== this.id && source.id !== this.fallbackSource?.id)
617
623
  .sort((a, b) => routeSourcePriority(a) - routeSourcePriority(b));
618
624
  }
@@ -1,5 +1,5 @@
1
1
  import type { AssetDataCapability, NewsCapability, PluginCapability } from "../../capabilities";
2
- import type { CapabilityRouteSource } from "../../types/capability-route-source";
2
+ import { routeSourcePriority, type CapabilityRouteSource } from "../../types/capability-route-source";
3
3
  import type { DataProvider } from "../../types/data-provider";
4
4
 
5
5
  type RouteSourceCapability = AssetDataCapability | NewsCapability;
@@ -20,6 +20,31 @@ export function collectCapabilityRouteSources(capabilities: PluginCapability[]):
20
20
  return [...capabilitySources.values()];
21
21
  }
22
22
 
23
+ /**
24
+ * One source per id. A host can hand the router a source a plugin also
25
+ * registers (the web app passes its own Gloom Cloud client, which stays when
26
+ * the plugin is turned off): asked as two, every read that falls through to
27
+ * the next source, or races it, sends the same request twice. The first one
28
+ * listed keeps its clients; the other fills in what it lacks.
29
+ */
30
+ export function mergeRouteSourcesById(sources: readonly CapabilityRouteSource[]): CapabilityRouteSource[] {
31
+ const byId = new Map<string, CapabilityRouteSource>();
32
+ for (const source of sources) {
33
+ const kept = byId.get(source.id);
34
+ byId.set(source.id, kept ? {
35
+ id: kept.id,
36
+ name: kept.name,
37
+ priority: kept.priority === undefined && source.priority === undefined
38
+ ? undefined : Math.min(routeSourcePriority(kept), routeSourcePriority(source)),
39
+ cachePolicy: kept.cachePolicy ?? source.cachePolicy,
40
+ isEnabled: kept.isEnabled ?? source.isEnabled,
41
+ market: kept.market ?? source.market,
42
+ news: kept.news ?? source.news,
43
+ } : source);
44
+ }
45
+ return [...byId.values()];
46
+ }
47
+
23
48
  function routeSourceFromMarketProvider(provider: DataProvider): CapabilityRouteSource {
24
49
  return {
25
50
  id: provider.id,
@@ -726,10 +726,23 @@ function withLocalSessionLayoutState(
726
726
  });
727
727
  }
728
728
 
729
+ /** A dock tree with no stack's shown tab: like stacking order, it follows whichever pane was focused last. */
730
+ function withoutShownTabs(node: unknown): unknown {
731
+ if (!isRecord(node) || node.kind !== "split") return node;
732
+ const { tabs, ...rest } = node;
733
+ return {
734
+ ...rest,
735
+ first: withoutShownTabs(node.first),
736
+ second: withoutShownTabs(node.second),
737
+ ...(tabs === undefined ? {} : { tabs: true }),
738
+ };
739
+ }
740
+
729
741
  /**
730
- * A layout as the user arranged it. Stacking order follows whichever floating
731
- * pane was focused last, and a pane in its own desktop window is one a
732
- * terminal draws inline as a floating pane, so neither tells two copies apart.
742
+ * A layout as the user arranged it. Stacking order and the tab a stack shows
743
+ * follow whichever pane was focused last, and a pane in its own desktop window
744
+ * is one a terminal draws inline as a floating pane, so none of them tells two
745
+ * copies apart.
733
746
  */
734
747
  function arrangedLayout(layout: unknown): unknown {
735
748
  if (!isRecord(layout)) return layout;
@@ -743,7 +756,7 @@ function arrangedLayout(layout: unknown): unknown {
743
756
  });
744
757
  const instanceId = (entry: unknown) => (isRecord(entry) ? String(entry.instanceId) : "");
745
758
  windows.sort((left, right) => instanceId(left).localeCompare(instanceId(right)));
746
- return { ...layout, floating: windows, detached: [] };
759
+ return { ...layout, dockRoot: withoutShownTabs(layout.dockRoot), floating: windows, detached: [] };
747
760
  }
748
761
 
749
762
  // Pulled and last synced payloads are compared on every sync and never change.
@@ -1575,6 +1588,7 @@ export function createCoreSyncContributors(): SyncContributor[] {
1575
1588
  }
1576
1589
 
1577
1590
  export const __syncContributorInternalsForTests = {
1591
+ layoutIntent,
1578
1592
  sanitizeUnknown,
1579
1593
  collectCoreConfigPayload,
1580
1594
  collectCoreCollectionsPayload,
@@ -125,6 +125,17 @@ export function perTonneUnit(unit: string): string {
125
125
  return isPerBarrelUnit(unit) ? unit.replace(/(\/\s*)\S.*$/, "$1tonne") : unit;
126
126
  }
127
127
 
128
+ /**
129
+ * A rate of one currency in another as reports and exports name it: `JPY /
130
+ * USD`, the chart's unit for USDJPY=X, is `JPY per USD`, as `history` says,
131
+ * and a currency future's `USD / CHF` is `USD per CHF`. Any other unit
132
+ * (`USD / barrel`, `USD`) is returned as it is.
133
+ */
134
+ export function currencyRateUnitText(unit: string): string {
135
+ const match = /^([A-Z]{3})\s*\/\s*([A-Z]{3})$/.exec(unit.trim());
136
+ return match ? `${match[1]} per ${match[2]}` : unit;
137
+ }
138
+
128
139
  /**
129
140
  * What a currency pair's price counts: the quote currency one unit of the
130
141
  * base buys, so EURUSD=X is USD / EUR and USDJPY=X JPY / USD. Null for a
@@ -26,6 +26,8 @@ import { TIME_RANGES, type TimeRange } from "./range";
26
26
  import type { DataProvider } from "../types/data-provider";
27
27
  import type { CorporateActionsData, EarningsAction, Quote, TickerFinancials } from "../types/financials";
28
28
  import { mergeQuoteMetadata, quoteMetadataFromQuote, quoteMetadataMatchesTarget } from "../market-data/quotes/metadata";
29
+ import { getSharedMarketDataCoordinator } from "../market-data/coordinator";
30
+ import { resolveEntryData } from "../market-data/selectors";
29
31
  import type { FredSeriesRequest } from "../sources/gloomberb-cloud/fred-series";
30
32
  import { fredCreditCoverageNotice } from "./economic";
31
33
  import {
@@ -392,6 +394,16 @@ async function resolveChartSpecPass(
392
394
  const loadQuoteMetadata = (source: Extract<ChartSeriesSpec["source"], { kind: "security" }>) => {
393
395
  const key = instrumentKey(source);
394
396
  let pending = cache.quoteMetadataByInstrument.get(key);
397
+ // The pane showing this listing has usually just read its quote: its
398
+ // currency and type answer without asking the server for the quote again.
399
+ const held = resolveEntryData(getSharedMarketDataCoordinator()?.getQuoteEntry(source.instrument));
400
+ const heldMetadata = held ? quoteMetadataFromQuote(held) : null;
401
+ if (!pending && heldMetadata?.currency && heldMetadata.instrumentType
402
+ && quoteMetadataMatchesTarget(heldMetadata, source.instrument.symbol, source.instrument.exchange)) {
403
+ pending = Promise.resolve(heldMetadata);
404
+ cache.quoteMetadataByInstrument.set(key, pending);
405
+ cache.revision += 1;
406
+ }
395
407
  if (!pending) {
396
408
  const provider = sources.dataProvider!;
397
409
  pending = Promise.resolve().then(() => provider.getQuoteMetadata
@@ -1,6 +1,7 @@
1
1
  import type { Portfolio, Watchlist } from "./ticker";
2
2
  import type { BrokerContractRef, TickerListingRef } from "./instrument";
3
3
  import type { LanguagePreference } from "../i18n/languages";
4
+ import { buildDockStack } from "../layout/pane-manager/dock-stack";
4
5
 
5
6
  export const CURRENT_CONFIG_VERSION = 28;
6
7
 
@@ -42,7 +43,8 @@ export type PaneBinding =
42
43
  export interface DockedPlacementMemory {
43
44
  path?: Array<0 | 1>;
44
45
  anchorInstanceId?: string;
45
- position?: "left" | "right" | "above" | "below";
46
+ /** "tab": a tab of the stack `anchorInstanceId` is in. */
47
+ position?: "left" | "right" | "above" | "below" | "tab";
46
48
  }
47
49
 
48
50
  export interface FloatingPlacementMemory {
@@ -114,6 +116,11 @@ export interface DockSplitNode {
114
116
  ratio: number;
115
117
  first: DockLayoutNode;
116
118
  second: DockLayoutNode;
119
+ /**
120
+ * Set on every split of a stack of tabs, with the pane it shows: the panes
121
+ * under it share one spot (see layout/pane-manager/dock-stack.ts).
122
+ */
123
+ tabs?: { active: string };
117
124
  }
118
125
 
119
126
  export type DockLayoutNode = DockPaneNode | DockSplitNode;
@@ -624,6 +631,7 @@ function cloneDockNode(node: DockLayoutNode): DockLayoutNode {
624
631
  ratio: node.ratio,
625
632
  first: cloneDockNode(node.first),
626
633
  second: cloneDockNode(node.second),
634
+ ...(node.tabs ? { tabs: { active: node.tabs.active } } : {}),
627
635
  };
628
636
  }
629
637
 
@@ -645,6 +653,14 @@ function normalizeDockNode(
645
653
 
646
654
  if ((node as DockSplitNode).kind !== "split") return null;
647
655
  const split = node as DockSplitNode;
656
+ if (split.tabs) {
657
+ // Whatever is under a stack is its tabs, nested or not: a pane put back
658
+ // at a place inside it (its remembered spot) joins it.
659
+ const plain: DockSplitNode = { kind: "split", axis: split.axis, ratio: split.ratio, first: split.first, second: split.second };
660
+ const flat = normalizeDockNode(plain, validInstanceIds, seenPaneIds);
661
+ const active = typeof split.tabs.active === "string" ? split.tabs.active : null;
662
+ return flat ? buildDockStack(getDockedPaneIdsFromNode(flat), active) : null;
663
+ }
648
664
  const first = normalizeDockNode(split.first, validInstanceIds, seenPaneIds);
649
665
  const second = normalizeDockNode(split.second, validInstanceIds, seenPaneIds);
650
666
  if (!first && !second) return null;
@@ -151,6 +151,12 @@ export interface PaneDef {
151
151
  * win over the binding.
152
152
  */
153
153
  tickerFollower?: boolean | ((pane: PaneInstanceConfig) => boolean);
154
+ /**
155
+ * A single-ticker pane that keeps its ticker somewhere besides its binding (a chart's series)
156
+ * moves it here when ticker search changes the ticker the pane shows. The host has already set
157
+ * the binding and the title; `previous` is the ticker the pane showed until now.
158
+ */
159
+ retargetTicker?(pane: PaneInstanceConfig, symbol: string, previous: string | null): PaneInstanceConfig;
154
160
  /**
155
161
  * Instrument kinds this pane has data for, such as `["equity"]` for company
156
162
  * data, as a research tab declares them. Bound to a ticker of another known
package/src/ui/host.tsx CHANGED
@@ -727,6 +727,8 @@ export interface RendererHost {
727
727
  */
728
728
  startWindowDrag?(press?: { detail?: number }): Promise<void> | void;
729
729
  controlWindow?(action: "minimize" | "toggle-maximize" | "close"): Promise<void> | void;
730
+ /** From a press on the page's top edge, where its own window frame has none to pull. */
731
+ startWindowResize?(edge: "top" | "top-left" | "top-right"): Promise<void> | void;
730
732
  /**
731
733
  * Opens a link in the person's browser. Resolves false when no browser could
732
734
  * be shown from here (a terminal over SSH, or no opener installed), so the
@@ -126,3 +126,23 @@ export function currenciesNamed(text: string): readonly NamedCurrency[] {
126
126
  if (!key) return [];
127
127
  return names.get(key) ?? (key.endsWith("s") ? names.get(key.slice(0, -1)) : undefined) ?? [];
128
128
  }
129
+
130
+ /** Codes that are also English words, read as a currency only when typed in capitals: "try" is a verb before it is the lira. */
131
+ export const WORD_CURRENCY_CODES: ReadonlySet<string> = new Set(["TRY", "PEN", "COP", "MAD", "RUB", "CAD"]);
132
+
133
+ let namedCodes: ReadonlySet<string> | undefined;
134
+
135
+ /**
136
+ * The currency a three-letter code names, as a query types it: `jpy` and
137
+ * `JPY` are JPY, `TRY` the lira but `try` nothing (`WORD_CURRENCY_CODES`).
138
+ * Only the currencies named here count, so `all` is no Albanian lek. Null for
139
+ * any other text.
140
+ */
141
+ export function currencyCodeTyped(text: string): string | null {
142
+ const typed = text.trim();
143
+ if (!/^[A-Za-z]{3}$/.test(typed)) return null;
144
+ namedCodes ??= new Set(CURRENCY_NAMES.map(([code]) => code));
145
+ const code = typed.toUpperCase();
146
+ if (!namedCodes.has(code)) return null;
147
+ return typed === code || !WORD_CURRENCY_CODES.has(code) ? code : null;
148
+ }