tmux-ide 2.9.22 → 2.9.24
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.
- package/bin/cli.js +3718 -7603
- package/package.json +3 -3
- package/packages/contracts/src/index.ts +1 -0
- package/packages/contracts/src/websocket-heartbeat.ts +41 -0
- package/packages/daemon/dist/command-center/automation.js +1 -1
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +37 -5
- package/packages/daemon/dist/command-center/discovery.js +28 -2
- package/packages/daemon/dist/command-center/server.js +8 -2
- package/packages/daemon/dist/command-center/tmux-servers.js +12 -1
- package/packages/daemon/dist/doctor.js +41 -0
- package/packages/daemon/dist/lib/bounded-tmux-read.js +34 -12
- package/packages/daemon/dist/lib/daemon-embed.js +127 -63
- package/packages/daemon/dist/lib/daemon-stop-progress.js +58 -0
- package/packages/daemon/dist/lib/embedded-daemon-lifecycle.js +11 -0
- package/packages/daemon/dist/lib/embedded-tmux-server-owners.js +88 -12
- package/packages/daemon/dist/lib/headless-daemon.js +177 -10
- package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
- package/packages/daemon/dist/lib/log.js +18 -1
- package/packages/daemon/dist/lib/machine-agents.js +18 -1
- package/packages/daemon/dist/lib/orphaned-control-clients.js +162 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +172 -28
- package/packages/daemon/dist/lib/tmux-native-browser.js +4 -2
- package/packages/daemon/dist/lib/tmux-pane-reader.js +4 -2
- package/packages/daemon/dist/lib/tmux-server-agent-admission.js +6 -1
- package/packages/daemon/dist/lib/tmux-server-owner-teardown.js +33 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +55 -41
- package/packages/daemon/dist/lib/tmux-server-owners.js +310 -20
- package/packages/daemon/dist/lib/tmux-server-registration.js +128 -9
- package/packages/daemon/dist/lib/unix-socket-authority.js +58 -3
- package/packages/daemon/dist/lib/workspace-pane-creation.js +10 -1
- package/packages/daemon/dist/lib/workspace-promotion.js +24 -3
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/plugins/cli.js +1 -2
- package/packages/daemon/dist/server/pane-stream-upgrade.js +5 -1
- package/packages/daemon/dist/server/websocket-heartbeat.js +103 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +49 -16
- package/packages/daemon/dist/terminal/mirror/layout-content-rows.js +11 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +61 -3
- package/packages/daemon/dist/terminal/mirror/session-channel.js +11 -12
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +119 -22
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +3 -2
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +23 -0
- package/packages/daemon/dist/terminal/protocol/stock-split-resize.js +4 -1
- package/packages/daemon/dist/terminal/session-runtime/registry.js +17 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +81 -3
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +60 -3
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +57 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +18 -7
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +4 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +55 -14
- package/packages/daemon/src/command-center/automation.ts +1 -1
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +49 -8
- package/packages/daemon/src/command-center/discovery.ts +35 -2
- package/packages/daemon/src/command-center/server.ts +22 -8
- package/packages/daemon/src/command-center/tmux-servers.ts +12 -1
- package/packages/daemon/src/doctor.ts +46 -0
- package/packages/daemon/src/lib/bounded-tmux-read.ts +29 -9
- package/packages/daemon/src/lib/daemon-embed.ts +211 -71
- package/packages/daemon/src/lib/daemon-stop-progress.ts +78 -0
- package/packages/daemon/src/lib/embedded-daemon-lifecycle.ts +12 -0
- package/packages/daemon/src/lib/embedded-tmux-server-owners.ts +115 -11
- package/packages/daemon/src/lib/headless-daemon.ts +205 -12
- package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
- package/packages/daemon/src/lib/log.ts +18 -1
- package/packages/daemon/src/lib/machine-agents.ts +25 -1
- package/packages/daemon/src/lib/orphaned-control-clients.ts +215 -0
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +195 -33
- package/packages/daemon/src/lib/tmux-native-browser.ts +4 -3
- package/packages/daemon/src/lib/tmux-pane-reader.ts +4 -3
- package/packages/daemon/src/lib/tmux-server-agent-admission.ts +6 -1
- package/packages/daemon/src/lib/tmux-server-owner-teardown.ts +54 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +60 -38
- package/packages/daemon/src/lib/tmux-server-owners.ts +427 -22
- package/packages/daemon/src/lib/tmux-server-registration.ts +155 -7
- package/packages/daemon/src/lib/unix-socket-authority.ts +72 -3
- package/packages/daemon/src/lib/workspace-pane-creation.ts +11 -1
- package/packages/daemon/src/lib/workspace-promotion.ts +26 -3
- package/packages/daemon/src/plugins/cli.ts +1 -2
- package/packages/daemon/src/server/pane-stream-upgrade.ts +6 -0
- package/packages/daemon/src/server/websocket-heartbeat.ts +135 -0
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +79 -16
- package/packages/daemon/src/terminal/mirror/layout-content-rows.ts +11 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +61 -2
- package/packages/daemon/src/terminal/mirror/session-channel.ts +11 -14
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +133 -21
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +4 -2
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +31 -0
- package/packages/daemon/src/terminal/protocol/stock-split-resize.ts +6 -1
- package/packages/daemon/src/terminal/session-runtime/registry.ts +23 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +2 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +100 -3
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +60 -3
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +69 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +30 -13
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +38 -1
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +7 -2
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +4 -4
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +71 -17
- package/packages/daemon-client/src/direct-application-shell-transport.ts +21 -3
- package/packages/daemon-client/src/workspace-event-supervisor.ts +63 -2
|
@@ -111,11 +111,17 @@ const ERROR_MESSAGES: Readonly<Record<NativeTerminalAttachmentRuntimeErrorCode,
|
|
|
111
111
|
|
|
112
112
|
export class NativeTerminalAttachmentRuntimeError extends Error {
|
|
113
113
|
readonly code: NativeTerminalAttachmentRuntimeErrorCode;
|
|
114
|
+
/**
|
|
115
|
+
* Which of the several origins of this code it was. For diagnostics only:
|
|
116
|
+
* the message a client sees stays the same.
|
|
117
|
+
*/
|
|
118
|
+
readonly detail: string | undefined;
|
|
114
119
|
|
|
115
|
-
constructor(code: NativeTerminalAttachmentRuntimeErrorCode) {
|
|
120
|
+
constructor(code: NativeTerminalAttachmentRuntimeErrorCode, detail?: string) {
|
|
116
121
|
super(ERROR_MESSAGES[code]);
|
|
117
122
|
this.name = "NativeTerminalAttachmentRuntimeError";
|
|
118
123
|
this.code = code;
|
|
124
|
+
this.detail = detail;
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
|
|
@@ -730,7 +736,10 @@ async function requiredTmuxResult(
|
|
|
730
736
|
const result = await runner.run({ executable: "tmux", argv }, signal);
|
|
731
737
|
if (result.status === "not-found") return null;
|
|
732
738
|
if (result.status !== "ok") {
|
|
733
|
-
throw new NativeTerminalAttachmentRuntimeError(
|
|
739
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
740
|
+
"discovery-failed",
|
|
741
|
+
`tmux-command-${result.status}`,
|
|
742
|
+
);
|
|
734
743
|
}
|
|
735
744
|
return result.stdout;
|
|
736
745
|
}
|
|
@@ -919,6 +928,18 @@ function parsePaneSnapshot(
|
|
|
919
928
|
* before any pane query, and a second identity/topology snapshot closes races.
|
|
920
929
|
*/
|
|
921
930
|
const INVENTORY_FENCE_ATTEMPTS = 4;
|
|
931
|
+
/**
|
|
932
|
+
* A read that was overtaken by an inventory invalidation is not a failed
|
|
933
|
+
* read: the answer it was computing is simply out of date, so it is read
|
|
934
|
+
* again. One retry was not enough while tmux topology is in motion: creating
|
|
935
|
+
* an agent pane invalidates the inventory several times within a few hundred
|
|
936
|
+
* milliseconds, a read overtaken twice failed with "discovery-failed", the
|
|
937
|
+
* inventory route answered 503, and a click on the new agent's row landed on
|
|
938
|
+
* "That agent changed or disappeared" until the client's backoff recovered
|
|
939
|
+
* seconds later (#764, journey soak 43257599866). Still bounded: a server
|
|
940
|
+
* whose topology never stops moving must not hold a reader for ever.
|
|
941
|
+
*/
|
|
942
|
+
export const INVENTORY_STALE_RETRIES = 4;
|
|
922
943
|
/** 25, 50, 100 ms: enough for a mutation's identity stamps, bounded for every reader. */
|
|
923
944
|
const settleDelay = (attempt: number) =>
|
|
924
945
|
new Promise<void>((resolve) => setTimeout(resolve, 25 * 2 ** (attempt - 1)));
|
|
@@ -977,12 +998,17 @@ export async function discoverWorkspaceRegistryTerminalInventory(
|
|
|
977
998
|
for (let attempt = 0; attempt < INVENTORY_FENCE_ATTEMPTS && !stable; attempt += 1) {
|
|
978
999
|
if (attempt > 0) await settleDelay(attempt);
|
|
979
1000
|
const after = await requiredTmuxResult(runner, argv, signal);
|
|
980
|
-
if (after === null)
|
|
1001
|
+
if (after === null)
|
|
1002
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1003
|
+
"discovery-failed",
|
|
1004
|
+
"session-vanished-mid-read",
|
|
1005
|
+
);
|
|
981
1006
|
const next = parsePaneSnapshot(after, identity);
|
|
982
1007
|
if (matches(previous, next)) stable = next;
|
|
983
1008
|
else previous = next;
|
|
984
1009
|
}
|
|
985
|
-
if (!stable)
|
|
1010
|
+
if (!stable)
|
|
1011
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed", "topology-not-settled");
|
|
986
1012
|
bySessionName.set(sessionName, stable.panes);
|
|
987
1013
|
}
|
|
988
1014
|
|
|
@@ -1602,6 +1628,25 @@ export class WorkspaceTerminalInventoryRuntime {
|
|
|
1602
1628
|
if (this.#disposed) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1603
1629
|
const epoch = this.#inventoryEpoch;
|
|
1604
1630
|
const nativeEpoch = this.#nativeServerEpoch?.() ?? null;
|
|
1631
|
+
// An invalidation can also land while the snapshot is being adopted. That
|
|
1632
|
+
// publication is refused, as before, and the inventory is read again: it
|
|
1633
|
+
// used to fail the caller, and at startup the caller is the daemon.
|
|
1634
|
+
const publish = async (
|
|
1635
|
+
value: NativeTerminalInventorySnapshot,
|
|
1636
|
+
publicationSignal: AbortSignal,
|
|
1637
|
+
): Promise<NativeTerminalInventorySnapshot> => {
|
|
1638
|
+
try {
|
|
1639
|
+
return await this.#publishInventory(value, nativeEpoch, publicationSignal, epoch);
|
|
1640
|
+
} catch (error) {
|
|
1641
|
+
if (this.#disposed || signal?.aborted || this.#inventoryEpoch === epoch) throw error;
|
|
1642
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1643
|
+
return this.#readInventory(signal, staleRetry + 1);
|
|
1644
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1645
|
+
"discovery-failed",
|
|
1646
|
+
"overtaken-by-invalidations",
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1605
1650
|
if (signal) {
|
|
1606
1651
|
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1607
1652
|
let snapshot: NativeTerminalInventorySnapshot;
|
|
@@ -1609,17 +1654,25 @@ export class WorkspaceTerminalInventoryRuntime {
|
|
|
1609
1654
|
snapshot = await this.#readInventoryAttempt(signal);
|
|
1610
1655
|
} catch (error) {
|
|
1611
1656
|
if (this.#inventoryEpoch !== epoch) {
|
|
1612
|
-
if (staleRetry <
|
|
1613
|
-
|
|
1657
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1658
|
+
return this.#readInventory(signal, staleRetry + 1);
|
|
1659
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1660
|
+
"discovery-failed",
|
|
1661
|
+
"overtaken-by-invalidations",
|
|
1662
|
+
);
|
|
1614
1663
|
}
|
|
1615
1664
|
throw error;
|
|
1616
1665
|
}
|
|
1617
1666
|
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1618
1667
|
if (this.#inventoryEpoch !== epoch) {
|
|
1619
|
-
if (staleRetry <
|
|
1620
|
-
|
|
1668
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1669
|
+
return this.#readInventory(signal, staleRetry + 1);
|
|
1670
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1671
|
+
"discovery-failed",
|
|
1672
|
+
"overtaken-by-invalidations",
|
|
1673
|
+
);
|
|
1621
1674
|
}
|
|
1622
|
-
return
|
|
1675
|
+
return publish(snapshot, signal);
|
|
1623
1676
|
}
|
|
1624
1677
|
if (this.#inventoryRead?.epoch === epoch) return this.#inventoryRead.promise;
|
|
1625
1678
|
const abort = new AbortController();
|
|
@@ -1629,16 +1682,24 @@ export class WorkspaceTerminalInventoryRuntime {
|
|
|
1629
1682
|
value = await this.#readInventoryAttempt(abort.signal);
|
|
1630
1683
|
} catch (error) {
|
|
1631
1684
|
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
1632
|
-
if (staleRetry <
|
|
1633
|
-
|
|
1685
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1686
|
+
return this.#readInventory(undefined, staleRetry + 1);
|
|
1687
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1688
|
+
"discovery-failed",
|
|
1689
|
+
"overtaken-by-invalidations",
|
|
1690
|
+
);
|
|
1634
1691
|
}
|
|
1635
1692
|
throw error;
|
|
1636
1693
|
}
|
|
1637
1694
|
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
1638
|
-
if (staleRetry <
|
|
1639
|
-
|
|
1695
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1696
|
+
return this.#readInventory(undefined, staleRetry + 1);
|
|
1697
|
+
throw new NativeTerminalAttachmentRuntimeError(
|
|
1698
|
+
"discovery-failed",
|
|
1699
|
+
"overtaken-by-invalidations",
|
|
1700
|
+
);
|
|
1640
1701
|
}
|
|
1641
|
-
return
|
|
1702
|
+
return publish(value, abort.signal);
|
|
1642
1703
|
})().finally(() => {
|
|
1643
1704
|
if (this.#inventoryRead?.promise === promise) this.#inventoryRead = null;
|
|
1644
1705
|
});
|
|
@@ -1703,9 +1764,11 @@ export class WorkspaceTerminalInventoryRuntime {
|
|
|
1703
1764
|
const retryIfReplaced = (): Promise<NativeTerminalRuntimeSessionSnapshot | null> | null => {
|
|
1704
1765
|
assertLive();
|
|
1705
1766
|
if (this.#inventoryEpoch === epoch) return null;
|
|
1706
|
-
if (staleRetry <
|
|
1767
|
+
if (staleRetry < INVENTORY_STALE_RETRIES)
|
|
1707
1768
|
return this.#discoverTerminalRuntimeSession(requestedSessionName, signal, staleRetry + 1);
|
|
1708
|
-
return Promise.reject(
|
|
1769
|
+
return Promise.reject(
|
|
1770
|
+
new NativeTerminalAttachmentRuntimeError("discovery-failed", "overtaken-by-invalidations"),
|
|
1771
|
+
);
|
|
1709
1772
|
};
|
|
1710
1773
|
assertLive();
|
|
1711
1774
|
const nativeEpoch = this.#nativeServerEpoch?.() ?? null;
|
|
@@ -11,3 +11,14 @@ export function layoutContentRows(
|
|
|
11
11
|
const touchesStatusEdge = border === "top" ? paneTop === 0 : paneTop + paneHeight === windowRows;
|
|
12
12
|
return paneHeight - (touchesStatusEdge ? 1 : 0);
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The status line a window's tiled panes have, from its `pane-border-status`.
|
|
17
|
+
* tmux 3.8's `top-floating` and `bottom-floating` put a status line on floating
|
|
18
|
+
* panes only (`window_get_pane_status`), so tiled panes are laid out as "off".
|
|
19
|
+
* Null for a value this daemon does not know.
|
|
20
|
+
*/
|
|
21
|
+
export function tiledPaneBorderStatus(option: string | undefined): "off" | "top" | "bottom" | null {
|
|
22
|
+
if (option === "off" || option === "top" || option === "bottom") return option;
|
|
23
|
+
return option === "top-floating" || option === "bottom-floating" ? "off" : null;
|
|
24
|
+
}
|
|
@@ -71,6 +71,8 @@ export interface MirrorServiceOptions {
|
|
|
71
71
|
/** True only when the server positively lacks the native commands: a stock tmux. */
|
|
72
72
|
splitLayoutStock?: () => Promise<boolean>;
|
|
73
73
|
onSharedWindowConflict?: (session: string, conflicted: boolean) => void;
|
|
74
|
+
/** #764 diagnostics: the registered-window guard's lifecycle and pushes. */
|
|
75
|
+
onWindowOwnershipDiagnostic?: (phase: string, details?: Record<string, unknown>) => void;
|
|
74
76
|
createOwnedViewerAdapter?: (session: string) => OwnedViewerAdapter | undefined;
|
|
75
77
|
nativeServerIdentity?: import("../../lib/tmux-server-generation-runner.ts").NativeTmuxServerIdentity;
|
|
76
78
|
resolveSocketPath?: () => string;
|
|
@@ -180,6 +182,9 @@ interface ChannelEntry {
|
|
|
180
182
|
retired: boolean;
|
|
181
183
|
}
|
|
182
184
|
|
|
185
|
+
/** Backoff for re-reading registered windows after a failed read (#764). */
|
|
186
|
+
const OWNERSHIP_RETRY_MS = [100, 250, 500, 1_000] as const;
|
|
187
|
+
|
|
183
188
|
export class MirrorService {
|
|
184
189
|
private readonly opts: MirrorServiceOptions;
|
|
185
190
|
private readonly channels = new Map<string, ChannelEntry>();
|
|
@@ -205,24 +210,71 @@ export class MirrorService {
|
|
|
205
210
|
}
|
|
206
211
|
|
|
207
212
|
private invalidateRegisteredWindows(): void {
|
|
213
|
+
this.opts.onWindowOwnershipDiagnostic?.("guard-invalidate", {
|
|
214
|
+
wasPending: this.registeredWindows?.pending() ?? null,
|
|
215
|
+
});
|
|
208
216
|
this.registeredWindows?.invalidate();
|
|
209
217
|
}
|
|
210
218
|
|
|
219
|
+
/**
|
|
220
|
+
* #764: a failed re-read must not leave every session "being verified"
|
|
221
|
+
* for good. Nothing else re-reads until the next operation, so retry with
|
|
222
|
+
* a short bounded backoff while a channel is retained; success pushes
|
|
223
|
+
* any conflict as usual.
|
|
224
|
+
*/
|
|
225
|
+
private ownershipRetries = 0;
|
|
226
|
+
private ownershipRetry: ReturnType<typeof setTimeout> | null = null;
|
|
227
|
+
private retryRegisteredWindows(guard: RegisteredWindowGuard): void {
|
|
228
|
+
if (this.ownershipRetry || this.disposed || guard !== this.registeredWindows) return;
|
|
229
|
+
if (this.channelSessions.size === 0) return;
|
|
230
|
+
const delay =
|
|
231
|
+
OWNERSHIP_RETRY_MS[Math.min(this.ownershipRetries, OWNERSHIP_RETRY_MS.length - 1)]!;
|
|
232
|
+
this.ownershipRetries += 1;
|
|
233
|
+
this.ownershipRetry = setTimeout(() => {
|
|
234
|
+
this.ownershipRetry = null;
|
|
235
|
+
if (this.disposed || guard !== this.registeredWindows || !guard.pending()) return;
|
|
236
|
+
void this.verifyRegisteredWindows().catch(() => {});
|
|
237
|
+
}, delay);
|
|
238
|
+
this.ownershipRetry.unref?.();
|
|
239
|
+
}
|
|
240
|
+
|
|
211
241
|
async verifyRegisteredWindows(): Promise<void> {
|
|
212
242
|
const guard = this.registeredWindows;
|
|
213
243
|
if (!guard) return;
|
|
214
|
-
|
|
244
|
+
const diagnostic = this.opts.onWindowOwnershipDiagnostic;
|
|
245
|
+
diagnostic?.("guard-verify-start", { pending: guard.pending() });
|
|
246
|
+
try {
|
|
247
|
+
await guard.verify();
|
|
248
|
+
} catch (error) {
|
|
249
|
+
const detail = (error as { detail?: unknown } | null)?.detail;
|
|
250
|
+
diagnostic?.("guard-verify-failed", {
|
|
251
|
+
reason: error instanceof Error ? error.message.slice(0, 200) : "unknown",
|
|
252
|
+
// Which origin of the failure it was, when the thrower said so.
|
|
253
|
+
...(typeof detail === "string" ? { detail: detail.slice(0, 80) } : {}),
|
|
254
|
+
});
|
|
255
|
+
this.retryRegisteredWindows(guard);
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
this.ownershipRetries = 0;
|
|
215
259
|
if (guard !== this.registeredWindows || this.disposed)
|
|
216
260
|
throw new Error("Window ownership changed during discovery");
|
|
261
|
+
const blocked: string[] = [];
|
|
217
262
|
for (const [channel, session] of this.channelSessions) {
|
|
218
263
|
if (guard.blocked(session)) {
|
|
264
|
+
blocked.push(session);
|
|
219
265
|
channel.setGeometryParticipation(false);
|
|
220
266
|
if (!this.registeredConflicts.has(session)) {
|
|
221
267
|
this.registeredConflicts.add(session);
|
|
268
|
+
diagnostic?.("guard-conflict-push", { session });
|
|
222
269
|
this.opts.onSharedWindowConflict?.(session, true);
|
|
223
270
|
}
|
|
224
|
-
} else this.registeredConflicts.delete(session)
|
|
271
|
+
} else if (this.registeredConflicts.delete(session)) {
|
|
272
|
+
// The registered-window conflict cleared: report it like a shared-window
|
|
273
|
+
// clear, so idle clients re-read the inventory (perf plan F13).
|
|
274
|
+
this.opts.onSharedWindowConflict?.(session, false);
|
|
275
|
+
}
|
|
225
276
|
}
|
|
277
|
+
diagnostic?.("guard-verify-ok", { blocked, channels: this.channelSessions.size });
|
|
226
278
|
}
|
|
227
279
|
private readonly pendingDisposals = new Set<Promise<void>>();
|
|
228
280
|
private readonly drainingChannels = new Map<string, Promise<void>>();
|
|
@@ -605,6 +657,7 @@ export class MirrorService {
|
|
|
605
657
|
const session = this.channelSessions.get(peer);
|
|
606
658
|
if (session === undefined) continue;
|
|
607
659
|
if (conflict) peer.setGeometryParticipation(false);
|
|
660
|
+
this.opts.onWindowOwnershipDiagnostic?.("membership-conflict-push", { session, conflict });
|
|
608
661
|
this.opts.onSharedWindowConflict?.(session, conflict);
|
|
609
662
|
}
|
|
610
663
|
}
|
|
@@ -729,6 +782,8 @@ export class MirrorService {
|
|
|
729
782
|
|
|
730
783
|
async dispose(): Promise<void> {
|
|
731
784
|
this.disposed = true;
|
|
785
|
+
if (this.ownershipRetry) clearTimeout(this.ownershipRetry);
|
|
786
|
+
this.ownershipRetry = null;
|
|
732
787
|
this.registeredWindows?.dispose();
|
|
733
788
|
this.sessionExitListeners.clear();
|
|
734
789
|
const entries = [...this.channels.values()];
|
|
@@ -793,6 +848,10 @@ export class MirrorService {
|
|
|
793
848
|
hasSharedWindowConflict: () => this.hasSharedWindowConflict(session),
|
|
794
849
|
beforeIdentityRepair: () => this.verifyRegisteredWindows(),
|
|
795
850
|
onWindowTopologyChanged: () => {
|
|
851
|
+
this.opts.onWindowOwnershipDiagnostic?.("topology-notification", {
|
|
852
|
+
session,
|
|
853
|
+
current: this.channelSessions.has(channel),
|
|
854
|
+
});
|
|
796
855
|
if (this.channelSessions.has(channel)) this.invalidateRegisteredWindows();
|
|
797
856
|
},
|
|
798
857
|
ownedViewer,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { STOCK_SPLIT_OPTIONS_FORMAT } from "../protocol/stock-split-resize.ts";
|
|
2
|
-
import { layoutContentRows } from "./layout-content-rows.ts";
|
|
2
|
+
import { layoutContentRows, tiledPaneBorderStatus } from "./layout-content-rows.ts";
|
|
3
3
|
import {
|
|
4
4
|
decodeNativeAtomicSnapshot,
|
|
5
5
|
decodeNativeAtomicDualSnapshot,
|
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
} from "../protocol/layout-parse.ts";
|
|
70
70
|
import {
|
|
71
71
|
SESSION_PANE_DESCRIPTOR_FORMAT,
|
|
72
|
+
sameSessionPaneInventory,
|
|
72
73
|
SessionDescriptorDiscovery,
|
|
73
74
|
decodeControlReplyUtf8,
|
|
74
75
|
decodeTmuxArgument,
|
|
@@ -2953,7 +2954,7 @@ export class SessionChannel {
|
|
|
2953
2954
|
}
|
|
2954
2955
|
const windowOptionHint =
|
|
2955
2956
|
name === "subscription-changed"
|
|
2956
|
-
? (/^tmux-ide-pane-borders\s+\$[0-9]+\s+(@[0-9]+)\s+[0-9]+\s+-\s*:\s*(?:top|bottom|off)\s*$/u.exec(
|
|
2957
|
+
? (/^tmux-ide-pane-borders\s+\$[0-9]+\s+(@[0-9]+)\s+[0-9]+\s+-\s*:\s*(?:top|bottom|off|top-floating|bottom-floating)\s*$/u.exec(
|
|
2957
2958
|
rest,
|
|
2958
2959
|
) ??
|
|
2959
2960
|
/^tmux-ide-copy-keys\s+\$[0-9]+\s+(@[0-9]+)\s+[0-9]+\s+-\s*:\s*(?:emacs|vi)\s*$/u.exec(
|
|
@@ -3112,13 +3113,9 @@ export class SessionChannel {
|
|
|
3112
3113
|
this.pendingLayoutOutput.get(change.windowId)?.layout !== pendingLayout
|
|
3113
3114
|
)
|
|
3114
3115
|
return;
|
|
3115
|
-
const border = reply.lines[0];
|
|
3116
|
+
const border = tiledPaneBorderStatus(reply.lines[0]);
|
|
3116
3117
|
const window = this.windowsByRuntime.get(change.windowId);
|
|
3117
|
-
if (
|
|
3118
|
-
!reply.ok ||
|
|
3119
|
-
!window ||
|
|
3120
|
-
(border !== "top" && border !== "bottom" && border !== "off")
|
|
3121
|
-
) {
|
|
3118
|
+
if (!reply.ok || !window || border === null) {
|
|
3122
3119
|
this.scheduleSync();
|
|
3123
3120
|
return;
|
|
3124
3121
|
}
|
|
@@ -3540,9 +3537,7 @@ export class SessionChannel {
|
|
|
3540
3537
|
`list-panes -s -t "${expectedRuntimeSessionId}" -F "${SESSION_PANE_DESCRIPTOR_FORMAT}"`,
|
|
3541
3538
|
);
|
|
3542
3539
|
const confirmedWindowStage = await this.stageWindows(expectedRuntimeSessionId);
|
|
3543
|
-
const coherent =
|
|
3544
|
-
beforeLines.length === afterLines.length &&
|
|
3545
|
-
beforeLines.every((line, index) => line === afterLines[index]);
|
|
3540
|
+
const coherent = sameSessionPaneInventory(beforeLines, afterLines);
|
|
3546
3541
|
if (
|
|
3547
3542
|
windowStage.repairedIdentity ||
|
|
3548
3543
|
confirmedWindowStage.repairedIdentity ||
|
|
@@ -3830,7 +3825,8 @@ export class SessionChannel {
|
|
|
3830
3825
|
!leftLayout ||
|
|
3831
3826
|
!rightLayout ||
|
|
3832
3827
|
leftWindow.semanticId !== rightWindow.semanticId ||
|
|
3833
|
-
|
|
3828
|
+
// Not the name: tmux derives it from the running command, and the
|
|
3829
|
+
// pane rows' own check ignores it too (sameSessionPaneInventory, #730).
|
|
3834
3830
|
leftWindow.paneBorderStatus !== rightWindow.paneBorderStatus ||
|
|
3835
3831
|
leftWindow.modeKeys !== rightWindow.modeKeys ||
|
|
3836
3832
|
!layoutIdentitiesEqual(leftLayout, rightLayout)
|
|
@@ -3876,12 +3872,13 @@ export class SessionChannel {
|
|
|
3876
3872
|
active = "",
|
|
3877
3873
|
visible = "",
|
|
3878
3874
|
zoomed = "",
|
|
3879
|
-
|
|
3875
|
+
borderStatusRaw = "off",
|
|
3880
3876
|
full = visible,
|
|
3881
3877
|
modeKeys,
|
|
3882
3878
|
indexRaw = "",
|
|
3883
3879
|
] = parts;
|
|
3884
3880
|
const index = Number(indexRaw);
|
|
3881
|
+
const borderStatus = tiledPaneBorderStatus(borderStatusRaw);
|
|
3885
3882
|
if (
|
|
3886
3883
|
!/^@[0-9]+$/u.test(runtimeId) ||
|
|
3887
3884
|
!/^(?:0|[1-9][0-9]*)$/u.test(indexRaw) ||
|
|
@@ -3889,7 +3886,7 @@ export class SessionChannel {
|
|
|
3889
3886
|
seenIndexes.has(index) ||
|
|
3890
3887
|
(active !== "0" && active !== "1") ||
|
|
3891
3888
|
(zoomed !== "0" && zoomed !== "1") ||
|
|
3892
|
-
|
|
3889
|
+
borderStatus === null ||
|
|
3893
3890
|
(modeKeys !== undefined && modeKeys !== "emacs" && modeKeys !== "vi")
|
|
3894
3891
|
) {
|
|
3895
3892
|
throw new Error(`window layout truth for ${this.opts.session} is malformed`);
|