@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
@@ -106,8 +106,8 @@ function sanitizeDockedPlacementMemory(raw: unknown): DockedPlacementMemory | un
106
106
  const anchorInstanceId = typeof (raw as { anchorInstanceId?: unknown }).anchorInstanceId === "string"
107
107
  ? (raw as { anchorInstanceId: string }).anchorInstanceId
108
108
  : undefined;
109
- const position = ["left", "right", "above", "below"].includes(String((raw as { position?: unknown }).position))
110
- ? (raw as { position: "left" | "right" | "above" | "below" }).position
109
+ const position = ["left", "right", "above", "below", "tab"].includes(String((raw as { position?: unknown }).position))
110
+ ? (raw as { position: NonNullable<DockedPlacementMemory["position"]> }).position
111
111
  : undefined;
112
112
  if (!path && !anchorInstanceId && !position) return undefined;
113
113
  return {
@@ -94,7 +94,12 @@ function interestInstanceId(instanceId: string): string {
94
94
  function mapNode(node: DockLayoutNode | null, idMap: Map<string, string>): DockLayoutNode | null {
95
95
  if (!node) return null;
96
96
  if (node.kind === "pane") return { ...node, instanceId: idMap.get(node.instanceId) ?? node.instanceId };
97
- return { ...node, first: mapNode(node.first, idMap)!, second: mapNode(node.second, idMap)! };
97
+ return {
98
+ ...node,
99
+ first: mapNode(node.first, idMap)!,
100
+ second: mapNode(node.second, idMap)!,
101
+ ...(node.tabs ? { tabs: { active: idMap.get(node.tabs.active) ?? node.tabs.active } } : {}),
102
+ };
98
103
  }
99
104
 
100
105
  /** Daily short volume becomes the short interest pane's volume tab, and sovereign CDS the index board's Sovereign tab. */
package/src/i18n/es.ts CHANGED
@@ -174,6 +174,9 @@ export const es: Record<string, string> = {
174
174
  "Reset Layout": "Restablecer diseño",
175
175
  "Reset Current Layout": "Restablecer diseño actual",
176
176
  "Security Description": "Descripción del valor",
177
+ "Change ticker": "Cambiar ticker",
178
+ "Change ticker · {pane}": "Cambiar ticker · {pane}",
179
+ "New pane": "Nuevo panel",
177
180
 
178
181
  // ── Core command descriptions ────────────────────────────────
179
182
  "Show or hide the keyboard shortcuts bar": "Mostrar u ocultar la barra de atajos",
@@ -219,6 +222,7 @@ export const es: Record<string, string> = {
219
222
  "Create or update a manual position without leaving the command bar.": "Crea o actualiza una posición manual sin salir de la barra de comandos.",
220
223
  "Organize panes and saved layouts.": "Organiza paneles y diseños guardados.",
221
224
  "Resolve a ticker, then open its Ticker Research pane.": "Resuelve un ticker y abre su panel de análisis.",
225
+ "Resolve a ticker for the focused pane, or open it in a new pane.": "Resuelve un ticker para el panel activo o ábrelo en un panel nuevo.",
222
226
  "Toggle optional plugins without leaving the command bar.": "Alterna plugins opcionales sin salir de la barra de comandos.",
223
227
 
224
228
  // ── Layout actions ───────────────────────────────────────────
@@ -246,6 +250,8 @@ export const es: Record<string, string> = {
246
250
  "Share Pane": "Compartir panel",
247
251
  "Pop Out": "Abrir en ventana",
248
252
  "Move Window...": "Mover ventana...",
253
+ "Change Ticker...": "Cambiar ticker...",
254
+ "Change Ticker": "Cambiar ticker",
249
255
  "Resize Window...": "Redimensionar ventana...",
250
256
  "Move Window": "Mover ventana",
251
257
  "Resize Window": "Redimensionar ventana",
@@ -552,7 +558,8 @@ export const es: Record<string, string> = {
552
558
  "Cycle windows or resize handles.": "Alternar ventanas o controles de tamaño.",
553
559
  "Commit pending changes or exit window mode.": "Confirmar cambios pendientes o salir del modo ventana.",
554
560
  "Open command mode for actions, pane commands, and typed prefixes.": "Abrir el modo comando para acciones, comandos de panel y prefijos.",
555
- "Open ticker search directly.": "Abrir directamente la búsqueda de tickers.",
561
+ "Change the focused pane's ticker.": "Cambia el ticker del panel activo.",
562
+ "Ticker search: Enter changes the focused pane's ticker and the panes linked to it, as a click on the ticker in a pane's title does on the desktop and the web. Shift+Enter opens a new pane. From a pane with no ticker it opens DES.": "Búsqueda de tickers: Enter cambia el ticker del panel activo y de los paneles vinculados a él, como un clic en el ticker del título de un panel en el escritorio y la web. Shift+Enter abre un panel nuevo. Desde un panel sin ticker abre DES.",
556
563
  "Open security details for a specific ticker.": "Abrir los detalles de un ticker específico.",
557
564
  "Move through command bar results.": "Moverse por los resultados de la barra de comandos.",
558
565
  "Run the selected result or its secondary action.": "Ejecutar el resultado seleccionado o su acción secundaria.",
package/src/i18n/ja.ts CHANGED
@@ -175,6 +175,9 @@ export const ja: Record<string, string> = {
175
175
  "Reset Layout": "レイアウトをリセット",
176
176
  "Reset Current Layout": "現在のレイアウトをリセット",
177
177
  "Security Description": "銘柄詳細",
178
+ "Change ticker": "銘柄を変更",
179
+ "Change ticker · {pane}": "銘柄を変更 · {pane}",
180
+ "New pane": "新しいペイン",
178
181
 
179
182
  // ── Core command descriptions ────────────────────────────────
180
183
  "Show or hide the keyboard shortcuts bar": "キーボードショートカットバーを表示/非表示",
@@ -220,6 +223,7 @@ export const ja: Record<string, string> = {
220
223
  "Create or update a manual position without leaving the command bar.": "コマンドバー内で手動ポジションを作成または更新します。",
221
224
  "Organize panes and saved layouts.": "ペインと保存されたレイアウトを整理します。",
222
225
  "Resolve a ticker, then open its Ticker Research pane.": "銘柄コードを確認して銘柄リサーチを開きます。",
226
+ "Resolve a ticker for the focused pane, or open it in a new pane.": "選択中のペインの銘柄コードを確認するか、新しいペインで開きます。",
223
227
  "Toggle optional plugins without leaving the command bar.": "コマンド バーを離れることなく、オプションのプラグインを切り替えます。",
224
228
 
225
229
  // ── Layout actions ───────────────────────────────────────────
@@ -247,6 +251,8 @@ export const ja: Record<string, string> = {
247
251
  "Share Pane": "ペインを共有",
248
252
  "Pop Out": "別ウィンドウで表示",
249
253
  "Move Window...": "ウィンドウを移動...",
254
+ "Change Ticker...": "銘柄を変更...",
255
+ "Change Ticker": "銘柄を変更",
250
256
  "Resize Window...": "ウィンドウのサイズを変更...",
251
257
  "Move Window": "ウィンドウを移動",
252
258
  "Resize Window": "ウィンドウのサイズを変更",
@@ -553,7 +559,8 @@ export const ja: Record<string, string> = {
553
559
  "Cycle windows or resize handles.": "ウィンドウを循環させるか、ハンドルのサイズを変更します。",
554
560
  "Commit pending changes or exit window mode.": "保留中の変更をコミットするか、ウィンドウ モードを終了します。",
555
561
  "Open command mode for actions, pane commands, and typed prefixes.": "アクション、ペイン コマンド、および入力されたプレフィックスのコマンド モードを開きます。",
556
- "Open ticker search directly.": "銘柄検索を直接開きます。",
562
+ "Change the focused pane's ticker.": "選択中のペインの銘柄を変更します。",
563
+ "Ticker search: Enter changes the focused pane's ticker and the panes linked to it, as a click on the ticker in a pane's title does on the desktop and the web. Shift+Enter opens a new pane. From a pane with no ticker it opens DES.": "銘柄検索: Enter で選択中のペインとリンクされたペインの銘柄を変更します。デスクトップと Web ではペインのタイトルの銘柄をクリックしても同じです。Shift+Enter で新しいペインを開きます。銘柄のないペインからは DES を開きます。",
557
564
  "Open security details for a specific ticker.": "指定した銘柄の詳細を開きます。",
558
565
  "Move through command bar results.": "コマンド バーの結果を移動します。",
559
566
  "Run the selected result or its secondary action.": "選択した結果またはその二次アクションを実行します。",
package/src/i18n/ko.ts CHANGED
@@ -173,6 +173,9 @@ export const ko: Record<string, string> = {
173
173
  "Reset Layout": "레이아웃 재설정",
174
174
  "Reset Current Layout": "현재 레이아웃 재설정",
175
175
  "Security Description": "종목 상세",
176
+ "Change ticker": "종목 변경",
177
+ "Change ticker · {pane}": "종목 변경 · {pane}",
178
+ "New pane": "새 패널",
176
179
 
177
180
  // ── Core command descriptions ────────────────────────────────
178
181
  "Show or hide the keyboard shortcuts bar": "키보드 단축키 표시줄 표시 또는 숨기기",
@@ -218,6 +221,7 @@ export const ko: Record<string, string> = {
218
221
  "Create or update a manual position without leaving the command bar.": "명령 팔레트에서 수동 포지션을 만들거나 업데이트합니다.",
219
222
  "Organize panes and saved layouts.": "패널과 저장된 레이아웃을 관리합니다.",
220
223
  "Resolve a ticker, then open its Ticker Research pane.": "종목코드를 확인한 뒤 종목 리서치 패널을 엽니다.",
224
+ "Resolve a ticker for the focused pane, or open it in a new pane.": "포커스 패널의 종목코드를 확인하거나 새 패널에서 엽니다.",
221
225
  "Toggle optional plugins without leaving the command bar.": "명령 팔레트에서 선택 플러그인을 켜거나 끕니다.",
222
226
 
223
227
  // ── Layout actions ───────────────────────────────────────────
@@ -245,6 +249,8 @@ export const ko: Record<string, string> = {
245
249
  "Share Pane": "창 공유",
246
250
  "Pop Out": "별도 창으로 열기",
247
251
  "Move Window...": "창 이동...",
252
+ "Change Ticker...": "종목 변경...",
253
+ "Change Ticker": "종목 변경",
248
254
  "Resize Window...": "창 크기 조정...",
249
255
  "Move Window": "창 이동",
250
256
  "Resize Window": "창 크기 조정",
@@ -551,7 +557,8 @@ export const ko: Record<string, string> = {
551
557
  "Cycle windows or resize handles.": "창 또는 크기 조절점을 순환합니다.",
552
558
  "Commit pending changes or exit window mode.": "변경 사항을 적용하거나 창 모드를 종료합니다.",
553
559
  "Open command mode for actions, pane commands, and typed prefixes.": "작업, 패널 명령 및 접두사를 위한 명령 모드를 엽니다.",
554
- "Open ticker search directly.": "종목 검색을 바로 엽니다.",
560
+ "Change the focused pane's ticker.": "포커스 패널의 종목을 변경합니다.",
561
+ "Ticker search: Enter changes the focused pane's ticker and the panes linked to it, as a click on the ticker in a pane's title does on the desktop and the web. Shift+Enter opens a new pane. From a pane with no ticker it opens DES.": "종목 검색: Enter는 포커스 패널과 연결된 패널의 종목을 변경합니다. 데스크톱과 웹에서는 패널 제목의 종목을 클릭해도 같습니다. Shift+Enter는 새 패널을 엽니다. 종목이 없는 패널에서는 DES를 엽니다.",
555
562
  "Open security details for a specific ticker.": "특정 종목의 상세 정보를 엽니다.",
556
563
  "Move through command bar results.": "명령 팔레트 결과 사이를 이동합니다.",
557
564
  "Run the selected result or its secondary action.": "선택한 결과 또는 해당 보조 작업을 실행합니다.",
package/src/i18n/zh-cn.ts CHANGED
@@ -175,6 +175,9 @@ export const zhCN: Record<string, string> = {
175
175
  "Reset Layout": "重置布局",
176
176
  "Reset Current Layout": "重置当前布局",
177
177
  "Security Description": "证券详情",
178
+ "Change ticker": "更改股票代码",
179
+ "Change ticker · {pane}": "更改股票代码 · {pane}",
180
+ "New pane": "新面板",
178
181
 
179
182
  // ── Core command descriptions ────────────────────────────────
180
183
  "Show or hide the keyboard shortcuts bar": "显示或隐藏快捷键状态栏",
@@ -220,6 +223,7 @@ export const zhCN: Record<string, string> = {
220
223
  "Create or update a manual position without leaving the command bar.": "在命令栏内直接创建或更新手动持仓。",
221
224
  "Organize panes and saved layouts.": "管理面板与已存布局。",
222
225
  "Resolve a ticker, then open its Ticker Research pane.": "解析股票代码并打开其研究面板。",
226
+ "Resolve a ticker for the focused pane, or open it in a new pane.": "为当前面板解析股票代码,或在新面板中打开。",
223
227
  "Toggle optional plugins without leaving the command bar.": "在命令栏内直接启停可选插件。",
224
228
 
225
229
  // ── Layout actions ───────────────────────────────────────────
@@ -247,6 +251,8 @@ export const zhCN: Record<string, string> = {
247
251
  "Share Pane": "分享窗格",
248
252
  "Pop Out": "弹出窗口",
249
253
  "Move Window...": "移动窗口...",
254
+ "Change Ticker...": "更改股票代码...",
255
+ "Change Ticker": "更改股票代码",
250
256
  "Resize Window...": "调整窗口大小...",
251
257
  "Move Window": "移动窗口",
252
258
  "Resize Window": "调整窗口大小",
@@ -553,7 +559,8 @@ export const zhCN: Record<string, string> = {
553
559
  "Cycle windows or resize handles.": "循环切换窗口或缩放控制点。",
554
560
  "Commit pending changes or exit window mode.": "提交更改或退出窗口模式。",
555
561
  "Open command mode for actions, pane commands, and typed prefixes.": "打开命令模式:操作、面板命令与前缀输入。",
556
- "Open ticker search directly.": "直接打开股票搜索。",
562
+ "Change the focused pane's ticker.": "更改当前面板的股票代码。",
563
+ "Ticker search: Enter changes the focused pane's ticker and the panes linked to it, as a click on the ticker in a pane's title does on the desktop and the web. Shift+Enter opens a new pane. From a pane with no ticker it opens DES.": "股票搜索:Enter 更改当前面板及其链接面板的股票代码,与在桌面版和网页版中点击面板标题中的代码相同。Shift+Enter 在新面板中打开。在没有代码的面板中则打开 DES。",
557
564
  "Open security details for a specific ticker.": "打开指定股票的证券详情。",
558
565
  "Move through command bar results.": "在命令栏结果间移动。",
559
566
  "Run the selected result or its secondary action.": "执行所选结果或其次要操作。",
package/src/i18n/zh-tw.ts CHANGED
@@ -175,6 +175,9 @@ export const zhTW: Record<string, string> = {
175
175
  "Reset Layout": "重置版面設定",
176
176
  "Reset Current Layout": "重置目前版面設定",
177
177
  "Security Description": "證券詳情",
178
+ "Change ticker": "變更股票代號",
179
+ "Change ticker · {pane}": "變更股票代號 · {pane}",
180
+ "New pane": "新面板",
178
181
 
179
182
  // ── Core command descriptions ────────────────────────────────
180
183
  "Show or hide the keyboard shortcuts bar": "顯示或隱藏快速鍵狀態列",
@@ -220,6 +223,7 @@ export const zhTW: Record<string, string> = {
220
223
  "Create or update a manual position without leaving the command bar.": "直接在命令列建立或更新手動部位。",
221
224
  "Organize panes and saved layouts.": "管理面板與已儲存的版面設定。",
222
225
  "Resolve a ticker, then open its Ticker Research pane.": "解析股票代號並開啟其研究面板。",
226
+ "Resolve a ticker for the focused pane, or open it in a new pane.": "為目前面板解析股票代號,或在新面板中開啟。",
223
227
  "Toggle optional plugins without leaving the command bar.": "在命令列內直接啟停可選外掛。",
224
228
 
225
229
  // ── Layout actions ───────────────────────────────────────────
@@ -247,6 +251,8 @@ export const zhTW: Record<string, string> = {
247
251
  "Share Pane": "分享窗格",
248
252
  "Pop Out": "彈出視窗",
249
253
  "Move Window...": "移動視窗...",
254
+ "Change Ticker...": "變更股票代號...",
255
+ "Change Ticker": "變更股票代號",
250
256
  "Resize Window...": "調整視窗大小...",
251
257
  "Move Window": "移動視窗",
252
258
  "Resize Window": "調整視窗大小",
@@ -553,7 +559,8 @@ export const zhTW: Record<string, string> = {
553
559
  "Cycle windows or resize handles.": "循環切換視窗或縮放控制點。",
554
560
  "Commit pending changes or exit window mode.": "確認待處理的變更或結束視窗模式。",
555
561
  "Open command mode for actions, pane commands, and typed prefixes.": "開啟命令模式:操作、面板命令與字首輸入。",
556
- "Open ticker search directly.": "直接開啟股票搜尋。",
562
+ "Change the focused pane's ticker.": "變更目前面板的股票代號。",
563
+ "Ticker search: Enter changes the focused pane's ticker and the panes linked to it, as a click on the ticker in a pane's title does on the desktop and the web. Shift+Enter opens a new pane. From a pane with no ticker it opens DES.": "股票搜尋:Enter 變更目前面板及其連結面板的股票代號,與在桌面版和網頁版中點擊面板標題中的代號相同。Shift+Enter 在新面板中開啟。在沒有代號的面板中則開啟 DES。",
557
564
  "Open security details for a specific ticker.": "開啟指定股票的證券詳情。",
558
565
  "Move through command bar results.": "在命令列結果間移動。",
559
566
  "Run the selected result or its secondary action.": "執行所選結果或其次要操作。",
@@ -13,9 +13,10 @@ export function paneTitleMnemonic(title: string | undefined): string | null {
13
13
  /**
14
14
  * The title a pin gives a follower: a pane linked from its menu keeps only its command ("OMON"),
15
15
  * and one linked some other way still names the ticker it opened on ("OMON AAPL"); both name the
16
- * pinned ticker ("OMON MSFT"). Any other title is the user's or the pane's own and stays.
16
+ * pinned ticker ("OMON MSFT"). Any other title is the user's or the pane's own and stays. Ticker
17
+ * search changing a pane's ticker (`retargetTickerPane`) names the new one the same way.
17
18
  */
18
- function pinnedTitle(instance: PaneInstanceConfig, pinned: string): string | null {
19
+ export function pinnedTitle(instance: PaneInstanceConfig, pinned: string): string | null {
19
20
  if (instance.paneId === TICKER_RESEARCH_PANE_ID) return null;
20
21
  const title = instance.title?.trim();
21
22
  const mnemonic = paneTitleMnemonic(title);
@@ -15,7 +15,7 @@ import { pinFollowingPane } from "./pane-follow";
15
15
  import { findDockLeaf, getNodeAtPath, getRepresentativeLeafId } from "./pane-manager/dock-tree";
16
16
  import { dockPane, insertAtRootEdge, resizeSplitAtPath } from "./pane-manager/docking";
17
17
  import { floatAtRect } from "./pane-manager/floating-actions";
18
- import { finalizeLayout, removePane } from "./pane-manager/layout-state";
18
+ import { finalizeLayout, removePane, stackTabMemory } from "./pane-manager/layout-state";
19
19
 
20
20
  let nextSavedLayoutSeq = 0;
21
21
 
@@ -92,6 +92,7 @@ function pinOrphanedFollowers(
92
92
  function dockedPlacement(layout: LayoutConfig, paneId: string): PaneMovedFrom["docked"] {
93
93
  const leaf = findDockLeaf(layout, paneId);
94
94
  if (!leaf) return { path: [] };
95
+ if (leaf.stackPath) return { path: [...leaf.path], ...stackTabMemory(layout.dockRoot, leaf.stackPath, paneId) };
95
96
  if (leaf.path.length === 0) return { path: [] };
96
97
  const parent = getNodeAtPath(layout.dockRoot, leaf.path.slice(0, -1));
97
98
  if (!parent || parent.kind !== "split") return { path: [...leaf.path] };
@@ -0,0 +1,38 @@
1
+ import type { DockLayoutNode, DockSplitNode } from "../../types/config";
2
+
3
+ /**
4
+ * Panes stacked as tabs in one spot of the dock, one shown at a time: the
5
+ * panes of the subtree, first to last, as a chain of splits that each carry
6
+ * `tabs`. A build from before tabs reads the chain as a plain split and shows
7
+ * the panes side by side instead of losing them, and a split that loses one
8
+ * side is still a stack.
9
+ */
10
+ export type DockStackNode = DockSplitNode & { tabs: { active: string } };
11
+
12
+ export function isDockStack(node: DockLayoutNode | null | undefined): node is DockStackNode {
13
+ return node?.kind === "split" && !!node.tabs;
14
+ }
15
+
16
+ /**
17
+ * The stack of `instanceIds` showing `active` (the first when it is not one
18
+ * of them), in its stored form; one pane is a plain pane, none is nothing.
19
+ */
20
+ export function buildDockStack(instanceIds: readonly string[], active?: string | null): DockLayoutNode | null {
21
+ const ids = [...new Set(instanceIds)];
22
+ if (ids.length === 0) return null;
23
+ const shown = active && ids.includes(active) ? active : ids[0]!;
24
+ const chain = (index: number): DockLayoutNode => {
25
+ if (index === ids.length - 1) return { kind: "pane", instanceId: ids[index]! };
26
+ return {
27
+ kind: "split",
28
+ axis: "horizontal",
29
+ // Even widths where a build from before tabs shows them side by side
30
+ // (as far as a split's 0.1 to 0.9 allows).
31
+ ratio: Math.max(0.1, Math.min(0.9, 1 / (ids.length - index))),
32
+ first: { kind: "pane", instanceId: ids[index]! },
33
+ second: chain(index + 1),
34
+ tabs: { active: shown },
35
+ };
36
+ };
37
+ return chain(0);
38
+ }
@@ -1,8 +1,5 @@
1
- import type {
2
- DockLayoutNode,
3
- DockSplitNode,
4
- LayoutConfig,
5
- } from "../../types/config";
1
+ import type { DockLayoutNode, DockSplitNode, LayoutConfig } from "../../types/config";
2
+ import { buildDockStack, isDockStack } from "./dock-stack";
6
3
 
7
4
  const MIN_PANE_WIDTH = 20;
8
5
  const MIN_DOCKED_HEIGHT = 5;
@@ -22,10 +19,18 @@ export interface LayoutBounds {
22
19
  export interface DockLeafRef {
23
20
  instanceId: string;
24
21
  path: Array<0 | 1>;
22
+ /** A tab of a stack: where the stack is, the spot the pane shares. */
23
+ stackPath?: Array<0 | 1>;
25
24
  }
26
25
 
26
+ /**
27
+ * A spot of the dock on screen: one pane, or a stack of tabs showing
28
+ * `instanceId` (its `path` is then the stack's).
29
+ */
27
30
  export interface DockLeafLayout extends DockLeafRef {
28
31
  rect: LayoutBounds;
32
+ /** A stack: its tabs in order. */
33
+ stack?: readonly string[];
29
34
  }
30
35
 
31
36
  export interface DockDividerLayout {
@@ -44,6 +49,12 @@ export interface DockGeometryOptions {
44
49
  precise?: boolean;
45
50
  dividerSize?: number | { horizontal: number; vertical: number };
46
51
  reserveDividerGutters?: boolean;
52
+ /**
53
+ * Precise only: the space left between two panes, in cells per axis (the
54
+ * desktop's 4px). Each pane gives up half of it on the side it shares with
55
+ * the other; the split and its divider stay where the ratio puts them.
56
+ */
57
+ gap?: number | { horizontal: number; vertical: number };
47
58
  }
48
59
 
49
60
  export function clampRatio(ratio: number): number {
@@ -51,23 +62,37 @@ export function clampRatio(ratio: number): number {
51
62
  return Math.max(0.1, Math.min(0.9, ratio));
52
63
  }
53
64
 
54
- export function collectDockLeafRefs(node: DockLayoutNode | null, path: Array<0 | 1> = [], result: DockLeafRef[] = []): DockLeafRef[] {
65
+ /** Every docked pane, tabs of a stack included, and where it is in the tree. */
66
+ export function collectDockLeafRefs(
67
+ node: DockLayoutNode | null,
68
+ path: Array<0 | 1> = [],
69
+ result: DockLeafRef[] = [],
70
+ stackPath?: Array<0 | 1>,
71
+ ): DockLeafRef[] {
55
72
  if (!node) return result;
56
73
  if (node.kind === "pane") {
57
- result.push({ instanceId: node.instanceId, path });
74
+ result.push(stackPath ? { instanceId: node.instanceId, path, stackPath } : { instanceId: node.instanceId, path });
58
75
  return result;
59
76
  }
60
- collectDockLeafRefs(node.first, [...path, 0], result);
61
- collectDockLeafRefs(node.second, [...path, 1], result);
77
+ const inStack = stackPath ?? (isDockStack(node) ? path : undefined);
78
+ collectDockLeafRefs(node.first, [...path, 0], result, inStack);
79
+ collectDockLeafRefs(node.second, [...path, 1], result, inStack);
62
80
  return result;
63
81
  }
64
82
 
83
+ /** The pane a stack shows: its `active` tab, or its first when that is gone. */
84
+ export function dockStackShown(node: DockLayoutNode): string {
85
+ const members = getDockedInstanceIds(node);
86
+ return isDockStack(node) && members.includes(node.tabs.active) ? node.tabs.active : members[0]!;
87
+ }
88
+
65
89
  export function getDockedInstanceIds(node: DockLayoutNode | null): string[] {
66
90
  return collectDockLeafRefs(node).map((entry) => entry.instanceId);
67
91
  }
68
92
 
69
93
  export function getRepresentativeLeafId(node: DockLayoutNode, preferStart: boolean): string {
70
94
  if (node.kind === "pane") return node.instanceId;
95
+ if (isDockStack(node)) return dockStackShown(node);
71
96
  return getRepresentativeLeafId(preferStart ? node.first : node.second, preferStart);
72
97
  }
73
98
 
@@ -100,6 +125,20 @@ export function removeNodeAtPath(node: DockLayoutNode | null, path: Array<0 | 1>
100
125
  if (!node) return null;
101
126
  if (path.length === 0) return null;
102
127
  if (node.kind !== "split") return node;
128
+ if (isDockStack(node)) {
129
+ // A tab leaves its stack; the stack shows the tab next to it if that was the one shown.
130
+ const members = getDockedInstanceIds(node);
131
+ const removed = getNodeAtPath(node, path);
132
+ if (!removed) return node;
133
+ const leaving = new Set(getDockedInstanceIds(removed));
134
+ const kept = members.filter((id) => !leaving.has(id));
135
+ const shown = dockStackShown(node);
136
+ const index = members.indexOf(shown);
137
+ const next = leaving.has(shown)
138
+ ? members.slice(index + 1).find((id) => !leaving.has(id)) ?? kept.at(-1)
139
+ : shown;
140
+ return buildDockStack(kept, next);
141
+ }
103
142
 
104
143
  const [head, ...rest] = path;
105
144
  if (head === 0) {
@@ -167,27 +206,36 @@ function collectDockGeometry(
167
206
  leaves.push({ instanceId: node.instanceId, path, rect: { ...bounds } });
168
207
  return { leaves, dividers };
169
208
  }
209
+ if (isDockStack(node)) {
210
+ // One spot, the tab shown; the splits that hold the tabs are not laid out.
211
+ leaves.push({ instanceId: dockStackShown(node), path, rect: { ...bounds }, stack: getDockedInstanceIds(node) });
212
+ return { leaves, dividers };
213
+ }
170
214
 
171
215
  const precise = options.precise === true;
172
216
  const dividerSize = typeof options.dividerSize === "object"
173
217
  ? options.dividerSize[node.axis]
174
218
  : options.dividerSize ?? 1;
175
219
  const reserveDividerGutters = options.reserveDividerGutters === true && !precise;
220
+ const gap = precise
221
+ ? Math.max(0, typeof options.gap === "object" ? options.gap[node.axis] : options.gap ?? 0)
222
+ : 0;
176
223
 
177
224
  if (node.axis === "horizontal") {
178
225
  const reserveDividerGutter = reserveDividerGutters && bounds.width > dividerSize;
179
226
  const splitWidth = reserveDividerGutter ? bounds.width - dividerSize : bounds.width;
180
227
  const [firstWidth, secondWidth] = resolveSplitSizes(splitWidth, node.ratio, MIN_PANE_WIDTH, precise);
181
- const firstBounds = { x: bounds.x, y: bounds.y, width: firstWidth, height: bounds.height };
228
+ const halfGap = Math.min(gap / 2, firstWidth / 2, secondWidth / 2);
229
+ const firstBounds = { x: bounds.x, y: bounds.y, width: firstWidth - halfGap, height: bounds.height };
182
230
  const dividerX = reserveDividerGutter
183
231
  ? bounds.x + firstWidth
184
232
  : precise
185
233
  ? bounds.x + firstWidth - (dividerSize / 2)
186
234
  : bounds.x + firstWidth - 1;
187
235
  const secondBounds = {
188
- x: reserveDividerGutter ? bounds.x + firstWidth + dividerSize : bounds.x + firstWidth,
236
+ x: reserveDividerGutter ? bounds.x + firstWidth + dividerSize : bounds.x + firstWidth + halfGap,
189
237
  y: bounds.y,
190
- width: secondWidth,
238
+ width: secondWidth - halfGap,
191
239
  height: bounds.height,
192
240
  };
193
241
  dividers.push({
@@ -210,7 +258,8 @@ function collectDockGeometry(
210
258
  const reserveDividerGutter = reserveDividerGutters && bounds.height > dividerSize;
211
259
  const splitHeight = reserveDividerGutter ? bounds.height - dividerSize : bounds.height;
212
260
  const [firstHeight, secondHeight] = resolveSplitSizes(splitHeight, node.ratio, MIN_DOCKED_HEIGHT, precise);
213
- const firstBounds = { x: bounds.x, y: bounds.y, width: bounds.width, height: firstHeight };
261
+ const halfGap = Math.min(gap / 2, firstHeight / 2, secondHeight / 2);
262
+ const firstBounds = { x: bounds.x, y: bounds.y, width: bounds.width, height: firstHeight - halfGap };
214
263
  const dividerY = reserveDividerGutter
215
264
  ? bounds.y + firstHeight
216
265
  : precise
@@ -218,9 +267,9 @@ function collectDockGeometry(
218
267
  : bounds.y + firstHeight - 1;
219
268
  const secondBounds = {
220
269
  x: bounds.x,
221
- y: reserveDividerGutter ? bounds.y + firstHeight + dividerSize : bounds.y + firstHeight,
270
+ y: reserveDividerGutter ? bounds.y + firstHeight + dividerSize : bounds.y + firstHeight + halfGap,
222
271
  width: bounds.width,
223
- height: secondHeight,
272
+ height: secondHeight - halfGap,
224
273
  };
225
274
  dividers.push({
226
275
  path,
@@ -300,3 +349,15 @@ export function getDockResizeTargets(
300
349
  }))
301
350
  .sort((left, right) => right.path.length - left.path.length);
302
351
  }
352
+
353
+ /** The layout with `instanceId` shown in its stack: the same layout when it is not a tab, or is shown already. */
354
+ export function showDockTab(layout: LayoutConfig, instanceId: string): LayoutConfig {
355
+ const leaf = findDockLeaf(layout, instanceId);
356
+ if (!leaf?.stackPath || !layout.dockRoot) return layout;
357
+ const stack = getNodeAtPath(layout.dockRoot, leaf.stackPath);
358
+ if (!stack || !isDockStack(stack) || dockStackShown(stack) === instanceId) return layout;
359
+ return {
360
+ ...layout,
361
+ dockRoot: replaceNodeAtPath(layout.dockRoot, leaf.stackPath, buildDockStack(getDockedInstanceIds(stack), instanceId)!),
362
+ };
363
+ }
@@ -1,9 +1,11 @@
1
- import type { LayoutConfig, PaneInstanceConfig } from "../../types/config";
1
+ import type { DockLayoutNode, LayoutConfig, PaneInstanceConfig } from "../../types/config";
2
2
  import { findPaneInstance } from "../../types/config";
3
+ import { buildDockStack } from "./dock-stack";
3
4
  import {
4
5
  buildSplitAroundNode,
5
6
  clampRatio,
6
7
  findDockLeaf,
8
+ getDockedInstanceIds,
7
9
  getNodeAtPath,
8
10
  replaceNodeAtPath,
9
11
  type DockGeometryOptions,
@@ -64,11 +66,28 @@ function insertRelativeToLeaf(layout: LayoutConfig, instanceId: string, targetId
64
66
  const base = detachPane(layout, instanceId);
65
67
  const targetLeaf = findDockLeaf(base, targetId);
66
68
  if (!targetLeaf || !base.dockRoot) return layout;
67
- const targetNode = getNodeAtPath(base.dockRoot, targetLeaf.path);
69
+ // Beside a tab is beside its whole stack.
70
+ const spotPath = targetLeaf.stackPath ?? targetLeaf.path;
71
+ const targetNode = getNodeAtPath(base.dockRoot, spotPath);
68
72
  if (!targetNode) return layout;
69
73
  return finalizeLayout({
70
74
  ...base,
71
- dockRoot: replaceNodeAtPath(base.dockRoot, targetLeaf.path, buildSplitAroundNode(targetNode, instanceId, position)),
75
+ dockRoot: replaceNodeAtPath(base.dockRoot, spotPath, buildSplitAroundNode(targetNode, instanceId, position)),
76
+ });
77
+ }
78
+
79
+ /** `instanceId` as the last tab of the spot `targetId` is in, shown: the spot becomes a stack if it was one pane. */
80
+ function stackOnto(layout: LayoutConfig, instanceId: string, targetId: string): LayoutConfig {
81
+ if (instanceId === targetId) return layout;
82
+ const base = detachPane(layout, instanceId);
83
+ const targetLeaf = findDockLeaf(base, targetId);
84
+ if (!targetLeaf || !base.dockRoot) return layout;
85
+ const spotPath = targetLeaf.stackPath ?? targetLeaf.path;
86
+ const spot = getNodeAtPath(base.dockRoot, spotPath);
87
+ if (!spot) return layout;
88
+ return finalizeLayout({
89
+ ...base,
90
+ dockRoot: replaceNodeAtPath(base.dockRoot, spotPath, buildDockStack([...getDockedInstanceIds(spot), instanceId], instanceId)!),
72
91
  });
73
92
  }
74
93
 
@@ -92,6 +111,12 @@ export function dockPane(layout: LayoutConfig, instanceId: string, target?: Dock
92
111
 
93
112
  const instance = findPaneInstance(layout, instanceId);
94
113
  const dockedMemory = instance?.placementMemory?.docked;
114
+ if (dockedMemory?.position === "tab") {
115
+ // A tab goes back into its stack while a pane of it is still docked.
116
+ const anchor = dockedMemory.anchorInstanceId;
117
+ if (anchor && anchor !== instanceId && findDockLeaf(layout, anchor)) return stackOnto(layout, instanceId, anchor);
118
+ return insertAtRootEdge(layout, instanceId, "right");
119
+ }
95
120
  if (dockedMemory?.position && dockedMemory.path && dockedMemory.path.length > 0) {
96
121
  return insertRelativeToSubtreePath(layout, instanceId, dockedMemory.path.slice(0, -1), dockedMemory.position);
97
122
  }
@@ -108,10 +133,13 @@ export function applyDrop(layout: LayoutConfig, draggedId: string, dropTarget: D
108
133
  if (dropTarget.kind === "frame") {
109
134
  return insertAtRootEdge(layout, draggedId, dropTarget.edge);
110
135
  }
136
+ if (dropTarget.kind === "tab") {
137
+ return stackOnto(layout, draggedId, dropTarget.targetId);
138
+ }
111
139
 
112
140
  const normalized = normalizeDropPosition(dropTarget.position);
113
141
  if (normalized === "center") {
114
- return swapPanes(layout, draggedId, dropTarget.targetId);
142
+ return stackOnto(layout, draggedId, dropTarget.targetId);
115
143
  }
116
144
  const direction = normalized === "top" ? "above" : normalized === "bottom" ? "below" : normalized;
117
145
  return insertRelativeToLeaf(layout, draggedId, dropTarget.targetId, direction);
@@ -131,6 +159,18 @@ export function simulateDrop(
131
159
  };
132
160
  }
133
161
 
162
+ /** `node` with each stack that showed a pane in `moved` showing the pane that took its place. */
163
+ function withShownTabsMoved(node: DockLayoutNode | null, moved: ReadonlyMap<string, string>): DockLayoutNode | null {
164
+ if (!node || node.kind === "pane") return node;
165
+ const active = node.tabs ? moved.get(node.tabs.active) : undefined;
166
+ return {
167
+ ...node,
168
+ first: withShownTabsMoved(node.first, moved)!,
169
+ second: withShownTabsMoved(node.second, moved)!,
170
+ ...(node.tabs && active ? { tabs: { active } } : {}),
171
+ };
172
+ }
173
+
134
174
  export function swapPanes(layout: LayoutConfig, firstId: string, secondId: string): LayoutConfig {
135
175
  if (firstId === secondId) return layout;
136
176
  const firstLeaf = findDockLeaf(layout, firstId);
@@ -146,7 +186,9 @@ export function swapPanes(layout: LayoutConfig, firstId: string, secondId: strin
146
186
  if (!firstNode || !secondNode || firstNode.kind !== "pane" || secondNode.kind !== "pane") return layout;
147
187
  const withFirst = replaceNodeAtPath(layout.dockRoot, firstLeaf.path, { kind: "pane", instanceId: secondId });
148
188
  const withSecond = replaceNodeAtPath(withFirst, secondLeaf.path, { kind: "pane", instanceId: firstId });
149
- return finalizeLayout({ ...layout, dockRoot: withSecond });
189
+ // A tab trades places too, and is still the one shown where it was.
190
+ const moved = new Map([[firstId, secondId], [secondId, firstId]]);
191
+ return finalizeLayout({ ...layout, dockRoot: withShownTabsMoved(withSecond, moved) });
150
192
  }
151
193
 
152
194
  if (firstFloating && secondFloating) {
@@ -165,7 +207,7 @@ export function swapPanes(layout: LayoutConfig, firstId: string, secondId: strin
165
207
  const dockedLeaf = firstLeaf ?? secondLeaf!;
166
208
  const floatingEntry = firstFloating ?? secondFloating!;
167
209
  const base = layout.dockRoot && dockedLeaf
168
- ? replaceNodeAtPath(layout.dockRoot, dockedLeaf.path, { kind: "pane", instanceId: floatingId })
210
+ ? withShownTabsMoved(replaceNodeAtPath(layout.dockRoot, dockedLeaf.path, { kind: "pane", instanceId: floatingId }), new Map([[dockedId, floatingId]]))
169
211
  : layout.dockRoot;
170
212
 
171
213
  return finalizeLayout({
@@ -9,6 +9,7 @@ import {
9
9
  clampFloatingRect,
10
10
  clampFloatingRectWithinBounds,
11
11
  defaultFloatingRect,
12
+ defaultFloatingSize,
12
13
  compactFloatingZ,
13
14
  maxFloatingZ,
14
15
  MIN_FLOAT_HEIGHT,
@@ -19,6 +20,7 @@ import {
19
20
  import type { LayoutBounds } from "./dock-tree";
20
21
  import type { FloatingResizeCorner } from "./types";
21
22
  import { detachPane, ensurePaneInstance, finalizeLayout } from "./layout-state";
23
+ import { avoidStackedRect, placeFloatingRect, type FloatingPlacementOptions } from "./floating-placement";
22
24
 
23
25
  export function detachPaneToFrame(
24
26
  layout: LayoutConfig,
@@ -112,19 +114,25 @@ export function resizeFloatingPaneFromCorner(
112
114
  }));
113
115
  }
114
116
 
117
+ /**
118
+ * Floats a pane where it floated last, or, the first time, where there is
119
+ * room (`placeFloatingRect`). Either way it never lands exactly on another
120
+ * window.
121
+ */
115
122
  export function floatPane(
116
123
  layout: LayoutConfig,
117
124
  instanceId: string,
118
125
  termWidth: number,
119
126
  termHeight: number,
120
127
  def?: PaneDef,
128
+ options?: FloatingPlacementOptions,
121
129
  ): LayoutConfig {
122
130
  const instance = findPaneInstance(layout, instanceId);
123
131
  if (!instance) return layout;
124
132
  const remembered = instance.placementMemory?.floating;
125
133
  const rect = remembered
126
- ? clampFloatingRect(remembered, termWidth, termHeight)
127
- : defaultFloatingRect(termWidth, termHeight, def);
134
+ ? avoidStackedRect(layout, instanceId, clampFloatingRect(remembered, termWidth, termHeight), termWidth, termHeight)
135
+ : placeFloatingRect(layout, instanceId, defaultFloatingSize(termWidth, termHeight, def), termWidth, termHeight, options);
128
136
  return floatAtRect(layout, instanceId, rect);
129
137
  }
130
138
 
@@ -134,10 +142,11 @@ export function addPaneFloating(
134
142
  termWidth: number,
135
143
  termHeight: number,
136
144
  def?: PaneDef,
145
+ options?: FloatingPlacementOptions,
137
146
  ): LayoutConfig {
138
147
  const resolvedInstance = typeof instance === "string" ? createPaneInstance(instance) : instance;
139
148
  const withInstance = ensurePaneInstance(layout, resolvedInstance);
140
- return floatPane(withInstance, resolvedInstance.instanceId, termWidth, termHeight, def);
149
+ return floatPane(withInstance, resolvedInstance.instanceId, termWidth, termHeight, def, options);
141
150
  }
142
151
 
143
152
  export function bringToFront(layout: LayoutConfig, instanceId: string): LayoutConfig {