tmux-ide 2.9.17 → 2.9.18

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 (26) hide show
  1. package/bin/cli.js +629 -320
  2. package/package.json +1 -1
  3. package/packages/daemon/dist/doctor.js +101 -2
  4. package/packages/daemon/dist/lib/daemon-embed.js +4 -1
  5. package/packages/daemon/dist/lib/native-split-capability.js +20 -0
  6. package/packages/daemon/dist/lib/tmux-server-owner.js +2 -1
  7. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  8. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  9. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  10. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  11. package/packages/daemon/dist/terminal/mirror/control-channel.js +3 -2
  12. package/packages/daemon/dist/terminal/mirror/mirror-service.js +47 -11
  13. package/packages/daemon/dist/terminal/mirror/session-channel.js +19 -4
  14. package/packages/daemon/dist/terminal/mirror/window-split-authority.js +9 -2
  15. package/packages/daemon/dist/terminal/protocol/native-split-resize.js +16 -16
  16. package/packages/daemon/dist/terminal/protocol/stock-split-resize.js +194 -0
  17. package/packages/daemon/src/doctor.ts +104 -2
  18. package/packages/daemon/src/lib/daemon-embed.ts +4 -0
  19. package/packages/daemon/src/lib/native-split-capability.ts +21 -0
  20. package/packages/daemon/src/lib/tmux-server-owner.ts +2 -0
  21. package/packages/daemon/src/terminal/mirror/control-channel.ts +3 -2
  22. package/packages/daemon/src/terminal/mirror/mirror-service.ts +51 -12
  23. package/packages/daemon/src/terminal/mirror/session-channel.ts +23 -4
  24. package/packages/daemon/src/terminal/mirror/window-split-authority.ts +15 -4
  25. package/packages/daemon/src/terminal/protocol/native-split-resize.ts +16 -16
  26. package/packages/daemon/src/terminal/protocol/stock-split-resize.ts +268 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmux-ide",
3
- "version": "2.9.17",
3
+ "version": "2.9.18",
4
4
  "description": "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,8 +1,11 @@
1
1
  import { requireSupportedTmuxVersion } from "./lib/tmux-version.js";
2
2
  import { resolveTmuxExecutable } from "./lib/tmux-client-execution.js";
3
+ import { TMUX_SOCKET_PATH_ENV } from "./lib/runtime-namespace.js";
3
4
  import { execSync, execFileSync } from "node:child_process";
4
- import { accessSync, constants, existsSync } from "node:fs";
5
- import { resolve, dirname } from "node:path";
5
+ import { accessSync, constants, existsSync, mkdtempSync, rmSync } from "node:fs";
6
+ import { tmpdir } from "node:os";
7
+ import { resolve, dirname, join } from "node:path";
8
+ import { nativeSplitCapability } from "./terminal/protocol/native-split-resize.js";
6
9
  import { fileURLToPath } from "node:url";
7
10
  import { getCurrentVersion, getUpdateStatus } from "./lib/update-check.js";
8
11
  import { installedSkillVersion } from "./lib/skill-sync.js";
@@ -149,6 +152,96 @@ function check(label, fn, { optional = false } = {}) {
149
152
  return { label, pass: false, detail: e.message, optional };
150
153
  }
151
154
  }
155
+ const UNKNOWN = (command) => new RegExp(`^unknown command: ${command}$`, "mu");
156
+ /** The same reading of the server as the mirror's: stock only when it refuses both
157
+ * native commands by name, and full only with the split capability it requires. */
158
+ function nativeCommands(probe) {
159
+ const ask = (command) => {
160
+ try {
161
+ return { output: probe([command, "-V"]) };
162
+ }
163
+ catch (error) {
164
+ const failure = error;
165
+ return { failure: String(failure.stderr ?? failure.message ?? "") };
166
+ }
167
+ };
168
+ const split = ask("tmux-ide-resize-split");
169
+ const events = ask("tmux-ide-events");
170
+ const failures = [split.failure, events.failure].filter((text) => text !== undefined);
171
+ if (failures.some((text) => /no server running|error connecting/u.test(text)))
172
+ return "no-server";
173
+ const refused = (answer, command) => answer.failure !== undefined && UNKNOWN(command).test(answer.failure);
174
+ if (refused(split, "tmux-ide-resize-split") && refused(events, "tmux-ide-events"))
175
+ return "stock";
176
+ if (split.output !== undefined && events.output !== undefined) {
177
+ try {
178
+ return nativeSplitCapability(split.output) ? "full" : "partial";
179
+ }
180
+ catch {
181
+ return "partial";
182
+ }
183
+ }
184
+ return failures.length === 2 ? "unknown" : "partial";
185
+ }
186
+ /** Reads the server a session would use. With none running, a throwaway private
187
+ * server shows what the resolved binary would start. */
188
+ export function tmuxFeaturesRow(probeServer, probeBinary) {
189
+ let answer = nativeCommands(probeServer);
190
+ if (answer === "no-server")
191
+ answer = nativeCommands(probeBinary);
192
+ const details = {
193
+ full: "bundled tmux: full features",
194
+ stock: "stock tmux: reduced features",
195
+ partial: "this tmux has only some tmux-ide commands: no pane dividers",
196
+ "no-server": "could not read the tmux server's features",
197
+ unknown: "could not read the tmux server's features",
198
+ };
199
+ return {
200
+ label: "tmux features",
201
+ pass: answer === "full" || answer === "stock",
202
+ detail: details[answer],
203
+ optional: true,
204
+ };
205
+ }
206
+ function runTmuxFeatureProbes(executable) {
207
+ const run = (prefix) => (args) => execFileSync(executable, [...prefix, ...args], {
208
+ encoding: "utf8",
209
+ stdio: ["ignore", "pipe", "pipe"],
210
+ timeout: 3000,
211
+ });
212
+ const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
213
+ const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
214
+ const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
215
+ const cleanups = [];
216
+ const probeBinary = (() => {
217
+ let scratch = null;
218
+ return (args) => {
219
+ scratch ??= (() => {
220
+ const dir = mkdtempSync(join(tmpdir(), "tmi-doctor-"));
221
+ const prefix = ["-S", join(dir, "s"), "-f", "/dev/null"];
222
+ cleanups.push(() => {
223
+ try {
224
+ run(prefix)(["kill-server"]);
225
+ }
226
+ catch {
227
+ // The server is already gone.
228
+ }
229
+ rmSync(dir, { recursive: true, force: true });
230
+ });
231
+ run(prefix)(["new-session", "-d", "-s", "probe"]);
232
+ return { dir, prefix };
233
+ })();
234
+ return run(scratch.prefix)(args);
235
+ };
236
+ })();
237
+ try {
238
+ return tmuxFeaturesRow(run(server), probeBinary);
239
+ }
240
+ finally {
241
+ for (const cleanup of cleanups)
242
+ cleanup();
243
+ }
244
+ }
152
245
  export function nodeVersionRow(version) {
153
246
  const major = Number(version.split(".")[0]);
154
247
  const pass = Number.isInteger(major) && major >= 20;
@@ -190,6 +283,12 @@ export async function doctor({ json, } = {}) {
190
283
  requireSupportedTmuxVersion(version);
191
284
  return `${version} (${executable})`;
192
285
  }));
286
+ try {
287
+ checks.push(runTmuxFeatureProbes(resolveTmuxExecutable()));
288
+ }
289
+ catch {
290
+ // The tmux version row above already reports a missing executable.
291
+ }
193
292
  checks.push(nodeVersionRow(process.versions.node));
194
293
  checks.push(check("256-color terminal", () => {
195
294
  const term = process.env.TERM ?? "";
@@ -10,7 +10,7 @@ import { createNativeBrowserResolver } from "./tmux-native-browser.js";
10
10
  import { createNativeSurfaceContextResolver } from "./native-surface-context.js";
11
11
  import { NativeSurfaceProviderRegistry } from "../terminal/graphics/native-surface-provider.js";
12
12
  import { TmuxServerVersionSchemaZ } from "@tmux-ide/contracts";
13
- import { createNativeSplitCapabilityProbe, createNativeSplitReadiness, } from "./native-split-capability.js";
13
+ import { createNativeSplitCapabilityProbe, createNativeSplitReadiness, createStockSplitProbe, } from "./native-split-capability.js";
14
14
  import { executeCanonicalSplitMutation } from "./canonical-split-mutation.js";
15
15
  import { createGuardedNativeSplitResize } from "./guarded-native-split-resize.js";
16
16
  import { WindowLinkTargetSchemaZ } from "@tmux-ide/contracts";
@@ -1112,6 +1112,9 @@ async function startEmbeddedDaemonGeneration(opts) {
1112
1112
  observation: () => observationSelector ?? null,
1113
1113
  runPinnedTmux: nativeGenerationTmuxRunner,
1114
1114
  }),
1115
+ splitLayoutStock: createStockSplitProbe({
1116
+ runPinnedTmux: nativeGenerationTmuxRunner,
1117
+ }),
1115
1118
  createOwnedViewerAdapter: () => ownedViewerFactory?.(),
1116
1119
  nativeServerIdentity: initialNativeServerIdentity,
1117
1120
  executable: tmuxAuthority.executablePath,
@@ -80,3 +80,23 @@ export function createNativeSplitReadiness(options) {
80
80
  pending = null;
81
81
  }));
82
82
  }
83
+ const NATIVE_COMMANDS = ["tmux-ide-resize-split", "tmux-ide-events"];
84
+ /** True only when the selected server refuses every native command by name. A
85
+ * timeout, a lost server or any other failure says nothing, so it stays false. */
86
+ export function createStockSplitProbe(options) {
87
+ return async () => {
88
+ for (const command of NATIVE_COMMANDS) {
89
+ try {
90
+ await options.runPinnedTmux([command, "-V"]);
91
+ return false;
92
+ }
93
+ catch (error) {
94
+ const failure = error;
95
+ const text = String(failure?.cause?.stderr ?? failure?.stderr ?? "");
96
+ if (!new RegExp(`^unknown command: ${command}$`, "mu").test(text))
97
+ return false;
98
+ }
99
+ }
100
+ return true;
101
+ };
102
+ }
@@ -1,7 +1,7 @@
1
1
  import { createNativeBrowserResolver } from "./tmux-native-browser.js";
2
2
  import { createNativeSurfaceContextResolver } from "./native-surface-context.js";
3
3
  import { shellEscape } from "./shell.js";
4
- import { createNativeSplitCapabilityProbe, createNativeSplitReadiness, } from "./native-split-capability.js";
4
+ import { createNativeSplitCapabilityProbe, createNativeSplitReadiness, createStockSplitProbe, } from "./native-split-capability.js";
5
5
  import { executeCanonicalSplitMutation } from "./canonical-split-mutation.js";
6
6
  import { createGuardedNativeSplitResize } from "./guarded-native-split-resize.js";
7
7
  import { execFileSync } from "node:child_process";
@@ -287,6 +287,7 @@ export async function createNativeTmuxServerOwner(options) {
287
287
  observation: () => observationSelector ?? null,
288
288
  runPinnedTmux: generationRun,
289
289
  }),
290
+ splitLayoutStock: createStockSplitProbe({ runPinnedTmux: generationRun }),
290
291
  createOwnedViewerAdapter: createOwnedViewerAdapterFactory({
291
292
  environmentId: options.environmentId,
292
293
  serverScope: { serverId: options.serverId, generation },
@@ -21,9 +21,9 @@
21
21
  <key>CFBundlePackageType</key>
22
22
  <string>APPL</string>
23
23
  <key>CFBundleShortVersionString</key>
24
- <string>2.9.17</string>
24
+ <string>2.9.18</string>
25
25
  <key>CFBundleVersion</key>
26
- <string>2.9.17</string>
26
+ <string>2.9.18</string>
27
27
  <key>LSMinimumSystemVersion</key>
28
28
  <string>11.0</string>
29
29
  <key>LSUIElement</key>
@@ -10,7 +10,7 @@
10
10
  </data>
11
11
  <key>Resources/Assets.car</key>
12
12
  <data>
13
- YZSYPnzkfPLVemp3jiRDnR5WhhQ=
13
+ naMXi4vqG99WTYshONwauong/wE=
14
14
  </data>
15
15
  </dict>
16
16
  <key>files2</key>
@@ -26,7 +26,7 @@
26
26
  <dict>
27
27
  <key>hash2</key>
28
28
  <data>
29
- zV9+zCqfvUhHrz90MuHUjqBvx93oA7g6BxgO8hDUlN8=
29
+ uTBb1swtYysiGXnkbPZAsxM01N0Fy1AUrpzAn1zAMvs=
30
30
  </data>
31
31
  </dict>
32
32
  </dict>
@@ -533,14 +533,15 @@ export class ControlChannelCore {
533
533
  }
534
534
  if (event.kind === "error" && sink.index !== sink.state.resultIndex)
535
535
  this.discardedErrors += 1;
536
- if (event.kind === "error" && sink.index === 0) {
536
+ if (event.kind === "error") {
537
+ // tmux drops the failed command's remaining group, so those replies never come.
537
538
  while (this.pending[0]?.kind === "command-list" && this.pending[0].state === sink.state)
538
539
  this.pending.shift();
539
540
  if (!sink.state.settled) {
540
541
  sink.state.settled = true;
541
542
  sink.state.onReply({
542
543
  ok: false,
543
- lines: sink.state.budget || sink.state.resultIndex === 0
544
+ lines: sink.index > 0 || sink.state.budget || sink.state.resultIndex === 0
544
545
  ? sink.state.lines
545
546
  : sink.state.leadingErrorLines,
546
547
  });
@@ -1,6 +1,8 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { setTimeout as waitForPublication } from "node:timers/promises";
2
3
  import { WindowSplitResizeTargetSchemaZ, } from "@tmux-ide/contracts";
3
4
  import { WindowSplitAuthority, WindowSplitLayoutUnavailable } from "./window-split-authority.js";
5
+ import { resizeStockSplit } from "../protocol/stock-split-resize.js";
4
6
  import { SharedWindowIndex } from "./shared-window-index.js";
5
7
  import { RegisteredWindowGuard } from "./registered-window-guard.js";
6
8
  import { accessSync, constants, realpathSync, statSync } from "node:fs";
@@ -237,9 +239,18 @@ export class MirrorService {
237
239
  catch {
238
240
  /* Unavailable owner. */
239
241
  }
240
- if (!ready || this.disposed || entry.retired || this.channels.get(session) !== entry)
242
+ if (!ready) {
243
+ // Anything but a positive "no such command" stays a refusal.
244
+ const stock = await this.#stockSplitServer();
245
+ if (!stock || this.disposed || entry.retired || this.channels.get(session) !== entry)
246
+ throw new WindowSplitLayoutUnavailable();
247
+ return this.#readStockSplitLayout(entry, target);
248
+ }
249
+ if (this.disposed || entry.retired || this.channels.get(session) !== entry)
241
250
  throw new WindowSplitLayoutUnavailable();
242
251
  }
252
+ if (entry.stockSplitEpoch)
253
+ throw new WindowSplitLayoutUnavailable();
243
254
  const epoch = this.opts.splitLayoutEpoch?.();
244
255
  let supported = false;
245
256
  try {
@@ -260,6 +271,25 @@ export class MirrorService {
260
271
  });
261
272
  return entry.splitAuthority.read(target);
262
273
  }
274
+ async #stockSplitServer() {
275
+ try {
276
+ return (await this.opts.splitLayoutStock?.()) === true;
277
+ }
278
+ catch {
279
+ return false;
280
+ }
281
+ }
282
+ #readStockSplitLayout(entry, target) {
283
+ if (entry.splitAuthority && !entry.stockSplitEpoch)
284
+ throw new WindowSplitLayoutUnavailable();
285
+ const epoch = (entry.stockSplitEpoch ??= randomUUID());
286
+ entry.splitAuthority ??= new WindowSplitAuthority({
287
+ describe: (window) => entry.channel.describeSplitLayout(window, true),
288
+ serverEpoch: () => epoch,
289
+ stock: true,
290
+ });
291
+ return entry.splitAuthority.read(target);
292
+ }
263
293
  /** Resolve only issued handles, then revalidate immediately at native dispatch. */
264
294
  async resizeWindowSplit(session, target, operationId, authorizeBeforeEffect, runNative) {
265
295
  const captured = WindowSplitResizeTargetSchemaZ.parse(target);
@@ -275,16 +305,22 @@ export class MirrorService {
275
305
  await entry.started;
276
306
  const resolved = current().resolve(captured);
277
307
  const successor = current().prepareSuccessor(captured);
278
- const result = await runNative(resolved.request, {
279
- operationId,
280
- serverEpoch: resolved.serverEpoch,
281
- session: resolved.session,
282
- anchor: resolved.anchor,
283
- authorizeBeforeEffect: () => {
284
- current().resolve(captured);
285
- authorizeBeforeEffect();
286
- },
287
- });
308
+ const authorize = () => {
309
+ current().resolve(captured);
310
+ authorizeBeforeEffect();
311
+ };
312
+ const result = entry.stockSplitEpoch
313
+ ? await resizeStockSplit(resolved.request, resolved.session.created, authorize, {
314
+ readOptions: (windowId) => entry.channel.stockSplitOptions(windowId),
315
+ send: (command) => entry.channel.stockSplitCommand(command),
316
+ })
317
+ : await runNative(resolved.request, {
318
+ operationId,
319
+ serverEpoch: resolved.serverEpoch,
320
+ session: resolved.session,
321
+ anchor: resolved.anchor,
322
+ authorizeBeforeEffect: authorize,
323
+ });
288
324
  if (result.status !== "applied")
289
325
  return result;
290
326
  // Native success is retained even if canonical publication is late or diverges.
@@ -1,3 +1,4 @@
1
+ import { STOCK_SPLIT_OPTIONS_FORMAT } from "../protocol/stock-split-resize.js";
1
2
  import { layoutContentRows } from "./layout-content-rows.js";
2
3
  import { decodeNativeAtomicSnapshot, decodeNativeAtomicDualSnapshot, nativeAtomicDualSnapshotPlan, nativeAtomicSnapshotPlan, } from "./native-atomic-snapshot.js";
3
4
  import { boundedTmuxInteractionAppendCommand } from "../../lib/tmux-interaction-retention.js";
@@ -557,7 +558,7 @@ export class SessionChannel {
557
558
  };
558
559
  }
559
560
  /** Exact native ancestry, never reconstructed from published pane rectangles. */
560
- describeSplitLayout(target) {
561
+ describeSplitLayout(target, stock = false) {
561
562
  const authority = this.windowLinkAuthority;
562
563
  const identity = this.attachedIdentity;
563
564
  const generation = this.attachedServerGeneration;
@@ -587,8 +588,7 @@ export class SessionChannel {
587
588
  pane.descriptor?.runtimeSessionId !== identity.runtimeSessionId ||
588
589
  pane.descriptor?.windowId !== resolved.runtimeWindowId ||
589
590
  this.panesBySemantic.get(pane.semanticId) !== pane ||
590
- !birth ||
591
- !/^[1-9]\d*$/u.test(birth) ||
591
+ (!stock && (!birth || !/^[1-9]\d*$/u.test(birth))) ||
592
592
  !layout.leaves.some((visible) => visible.id === leaf.id &&
593
593
  visible.left === leaf.left &&
594
594
  visible.top === leaf.top &&
@@ -598,7 +598,7 @@ export class SessionChannel {
598
598
  return Object.freeze({
599
599
  runtimePaneId: pane.runtimeId,
600
600
  semanticPaneId: pane.semanticId,
601
- nativePaneBirthId: birth,
601
+ nativePaneBirthId: stock ? "" : birth,
602
602
  });
603
603
  });
604
604
  return Object.freeze({
@@ -608,9 +608,24 @@ export class SessionChannel {
608
608
  runtimeWindowId: resolved.runtimeWindowId,
609
609
  semanticWindowId: window.semanticId,
610
610
  rawLayout: layout.rawLayout,
611
+ ...(stock ? { paneBorderStatus: window.paneBorderStatus } : {}),
611
612
  panes: Object.freeze(panes),
612
613
  });
613
614
  }
615
+ stockSplitOptions(windowId) {
616
+ return this.io.request(`display-message -p -t ${windowId} "${STOCK_SPLIT_OPTIONS_FORMAT}"`);
617
+ }
618
+ /** One guarded resize on this control connection, for a stock tmux server. */
619
+ stockSplitCommand(command) {
620
+ return new Promise((resolve, reject) => {
621
+ const onReply = (reply) => reply.ok ? resolve(reply.lines) : reject(new Error("Stock split command failed"));
622
+ const limits = { maxBytes: 16 * 1024, maxLines: 4 };
623
+ if (this.io.commandListBoundedInline)
624
+ this.io.commandListBoundedInline(command, 3, 2, limits, onReply);
625
+ else
626
+ this.io.commandListInline(command, 3, 2, onReply);
627
+ });
628
+ }
614
629
  async executeWindowLinkAction(request) {
615
630
  const authority = this.windowLinkAuthority;
616
631
  if (!authority || this.disposed)
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  import { NativeJournalUint64SchemaZ, WindowLinkTargetSchemaZ, WindowSplitLayoutResourceSchemaZ, WindowSplitResizeTargetSchemaZ, } from "@tmux-ide/contracts";
4
4
  import { supportsNativeSessionGuard } from "../../lib/native-operation-command.js";
5
5
  import { parseLayoutTree } from "../protocol/layout-parse.js";
6
+ import { stockSplitMovable } from "../protocol/stock-split-resize.js";
6
7
  import { SplitLayoutPublicationPending, } from "./session-channel.js";
7
8
  const MAX_RETAINED_WINDOWS = 32;
8
9
  export class WindowSplitLayoutUnavailable extends Error {
@@ -43,7 +44,8 @@ export class WindowSplitAuthority {
43
44
  snapshot.panes.forEach((pane) => {
44
45
  if (!/^%(0|[1-9][0-9]{0,9})$/u.test(pane.runtimePaneId) ||
45
46
  Number(pane.runtimePaneId.slice(1)) > 0xffffffff ||
46
- !NativeJournalUint64SchemaZ.refine((birth) => birth !== "0").safeParse(pane.nativePaneBirthId).success)
47
+ (!this.options.stock &&
48
+ !NativeJournalUint64SchemaZ.refine((birth) => birth !== "0").safeParse(pane.nativePaneBirthId).success))
47
49
  throw new WindowSplitLayoutUnavailable();
48
50
  });
49
51
  const mapping = new Map(snapshot.panes.map((pane) => [pane.runtimePaneId, pane]));
@@ -71,7 +73,12 @@ export class WindowSplitAuthority {
71
73
  }
72
74
  node.children.forEach((child, index) => {
73
75
  const childPath = [...path, index];
74
- if (index < node.children.length - 1) {
76
+ if (index < node.children.length - 1 &&
77
+ (!this.options.stock ||
78
+ stockSplitMovable(tree, childPath, node.axis, {
79
+ borderStatus: snapshot.paneBorderStatus ?? "off",
80
+ scrollbar: 0,
81
+ }))) {
75
82
  const splitId = randomUUID();
76
83
  paths.set(splitId, childPath);
77
84
  splits.push({
@@ -11,7 +11,7 @@ function json(text, limit) {
11
11
  throw new Error("Bounded native response required");
12
12
  return JSON.parse(text);
13
13
  }
14
- function capability(text) {
14
+ export function nativeSplitCapability(text) {
15
15
  const value = json(text, 1024);
16
16
  return (object(value, [
17
17
  "schemaVersion",
@@ -31,13 +31,13 @@ function capability(text) {
31
31
  /** Read-only, uncached probe; the caller pins and bounds the selected server. */
32
32
  export async function supportsNativeSplitResize(runTmux) {
33
33
  try {
34
- return capability(await runTmux(["tmux-ide-resize-split", "-V"]));
34
+ return nativeSplitCapability(await runTmux(["tmux-ide-resize-split", "-V"]));
35
35
  }
36
36
  catch {
37
37
  return false;
38
38
  }
39
39
  }
40
- function validTree(tree) {
40
+ export function validSplitTree(tree) {
41
41
  let budget = 5;
42
42
  const visit = (node) => {
43
43
  if (node.left + node.width > 4096 || node.top + node.height > 4096)
@@ -55,7 +55,7 @@ function validTree(tree) {
55
55
  };
56
56
  return visit(tree);
57
57
  }
58
- function locate(tree, path) {
58
+ export function locateSplit(tree, path) {
59
59
  let node = tree;
60
60
  let parent;
61
61
  for (const index of path) {
@@ -66,7 +66,7 @@ function locate(tree, path) {
66
66
  }
67
67
  return parent && path.at(-1) < parent.children.length - 1 ? { parent, node } : null;
68
68
  }
69
- function edge(node, axis) {
69
+ export function splitEdge(node, axis) {
70
70
  return axis === "cols" ? node.left + node.width : node.top + node.height;
71
71
  }
72
72
  function sameRect(a, b) {
@@ -75,7 +75,7 @@ function sameRect(a, b) {
75
75
  /** Only geometry inside the exact parent may change, along the requested axis.
76
76
  * Native redistribution can affect multiple siblings. This verifies convergence,
77
77
  * not exclusive causation or authentication of the returned layout. */
78
- function preservesTree(before, after, affected, axis, inside = false) {
78
+ export function preservesSplitTree(before, after, affected, axis, inside = false) {
79
79
  const begins = before === affected;
80
80
  if (before.kind !== after.kind || ((!inside || begins) && !sameRect(before, after)))
81
81
  return false;
@@ -90,7 +90,7 @@ function preservesTree(before, after, affected, axis, inside = false) {
90
90
  return (after.kind === "split" &&
91
91
  before.axis === after.axis &&
92
92
  before.children.length === after.children.length &&
93
- before.children.every((child, index) => preservesTree(child, after.children[index], affected, axis, inside)));
93
+ before.children.every((child, index) => preservesSplitTree(child, after.children[index], affected, axis, inside)));
94
94
  }
95
95
  /** Internal foundation only; no route or native capability is enabled here.
96
96
  * Capability is checked on every invocation, never cached across generations.
@@ -117,9 +117,9 @@ export async function resizeNativeSplit(request, runTmux) {
117
117
  request.boundary > 4096)
118
118
  return { status: "refused", reason: "invalid-request" };
119
119
  const tree = parseLayoutTree(request.expectedLayout);
120
- if (!tree || !validTree(tree))
120
+ if (!tree || !validSplitTree(tree))
121
121
  return { status: "refused", reason: "invalid-request" };
122
- const selected = locate(tree, request.path);
122
+ const selected = locateSplit(tree, request.path);
123
123
  if (!selected || selected.parent.axis !== request.axis)
124
124
  return { status: "refused", reason: "invalid-request" };
125
125
  before = tree;
@@ -130,7 +130,7 @@ export async function resizeNativeSplit(request, runTmux) {
130
130
  return { status: "refused", reason: "invalid-request" };
131
131
  }
132
132
  try {
133
- if (!capability(await runTmux(["tmux-ide-resize-split", "-V"])))
133
+ if (!nativeSplitCapability(await runTmux(["tmux-ide-resize-split", "-V"])))
134
134
  return { status: "refused", reason: "unsupported" };
135
135
  }
136
136
  catch {
@@ -168,14 +168,14 @@ export async function resizeNativeSplit(request, runTmux) {
168
168
  receipt.boundary > 4096)
169
169
  return { status: "uncertain", reason: "invalid-receipt" };
170
170
  const after = parseLayoutTree(receipt.layout);
171
- const original = locate(before, captured.path);
172
- const actual = after && locate(after, captured.path);
173
- const previous = edge(original.node, captured.axis);
171
+ const original = locateSplit(before, captured.path);
172
+ const actual = after && locateSplit(after, captured.path);
173
+ const previous = splitEdge(original.node, captured.axis);
174
174
  if (!after ||
175
- !validTree(after) ||
175
+ !validSplitTree(after) ||
176
176
  !actual ||
177
- !preservesTree(before, after, original.parent, captured.axis) ||
178
- receipt.boundary !== edge(actual.node, captured.axis) ||
177
+ !preservesSplitTree(before, after, original.parent, captured.axis) ||
178
+ receipt.boundary !== splitEdge(actual.node, captured.axis) ||
179
179
  receipt.boundary < Math.min(previous, captured.boundary) ||
180
180
  receipt.boundary > Math.max(previous, captured.boundary))
181
181
  return { status: "uncertain", reason: "invalid-receipt" };