tmux-ide 2.9.21 → 2.9.23
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 +6235 -8473
- package/package.json +3 -3
- package/packages/contracts/src/index.ts +2 -0
- package/packages/contracts/src/pane-reader.ts +121 -0
- package/packages/contracts/src/pane-stream.ts +18 -0
- package/packages/contracts/src/visual-theme-presets.ts +58 -2
- 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-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +7 -1
- package/packages/daemon/dist/doctor.js +147 -43
- package/packages/daemon/dist/lib/bounded-tmux-read.js +34 -12
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +126 -55
- 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/log.js +18 -1
- package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
- package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
- package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +140 -19
- package/packages/daemon/dist/lib/tmux-native-browser.js +4 -2
- package/packages/daemon/dist/lib/tmux-pane-reader.js +107 -0
- package/packages/daemon/dist/lib/tmux-server-agent-admission.js +6 -1
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner-teardown.js +33 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +38 -37
- 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/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/open-browser.js +26 -12
- package/packages/daemon/dist/open-reader.js +84 -0
- package/packages/daemon/dist/plugins/cli.js +1 -2
- package/packages/daemon/dist/plugins/daemon-plugins.js +2 -10
- package/packages/daemon/dist/restore.js +57 -40
- 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 +32 -14
- 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 +13 -12
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +123 -25
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +3 -2
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +30 -2
- 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/tmux-upgrade/cli.js +106 -0
- package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
- package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
- package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +35 -5
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
- 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-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +7 -1
- package/packages/daemon/src/doctor.ts +164 -45
- package/packages/daemon/src/lib/bounded-tmux-read.ts +29 -9
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +176 -64
- 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/log.ts +18 -1
- package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
- package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
- package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +163 -25
- package/packages/daemon/src/lib/tmux-native-browser.ts +4 -3
- package/packages/daemon/src/lib/tmux-pane-reader.ts +145 -0
- package/packages/daemon/src/lib/tmux-server-agent-admission.ts +6 -1
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner-teardown.ts +54 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +41 -35
- 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/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/cli.ts +1 -2
- package/packages/daemon/src/plugins/daemon-plugins.ts +2 -12
- package/packages/daemon/src/restore.ts +80 -44
- 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 +58 -14
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- 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 +15 -14
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +140 -23
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +4 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +41 -1
- 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/tmux-upgrade/cli.ts +118 -0
- package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
- package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
- package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
- package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +58 -6
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
- package/packages/daemon-client/src/direct-application-shell-transport.ts +21 -3
- package/packages/daemon-client/src/workspace-event-supervisor.ts +63 -2
- package/packages/tmux-bridge/src/runner.ts +3 -1
|
@@ -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,
|
|
@@ -753,6 +754,7 @@ export class SessionChannel {
|
|
|
753
754
|
await this.io.start();
|
|
754
755
|
await this.captureAttachedSessionIdentity();
|
|
755
756
|
this.io.send("refresh-client -B 'tmux-ide-browser-icon:%*:#{@tmux_ide_browser_icon}'");
|
|
757
|
+
this.io.send("refresh-client -B 'tmux-ide-reader:%*:#{@tmux_ide_reader}'");
|
|
756
758
|
// Changing border placement can resize PTYs without changing the layout
|
|
757
759
|
// string, so tmux emits no layout-change. Subscribe to this window option.
|
|
758
760
|
this.io.send("refresh-client -B 'tmux-ide-pane-borders:@*:#{pane-border-status}'");
|
|
@@ -2904,7 +2906,10 @@ export class SessionChannel {
|
|
|
2904
2906
|
name === "sessions-changed"
|
|
2905
2907
|
)
|
|
2906
2908
|
this.opts.onWindowTopologyChanged?.();
|
|
2907
|
-
if (
|
|
2909
|
+
if (
|
|
2910
|
+
name === "subscription-changed" &&
|
|
2911
|
+
(rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader "))
|
|
2912
|
+
) {
|
|
2908
2913
|
this.scheduleSync();
|
|
2909
2914
|
return;
|
|
2910
2915
|
}
|
|
@@ -2949,7 +2954,7 @@ export class SessionChannel {
|
|
|
2949
2954
|
}
|
|
2950
2955
|
const windowOptionHint =
|
|
2951
2956
|
name === "subscription-changed"
|
|
2952
|
-
? (/^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(
|
|
2953
2958
|
rest,
|
|
2954
2959
|
) ??
|
|
2955
2960
|
/^tmux-ide-copy-keys\s+\$[0-9]+\s+(@[0-9]+)\s+[0-9]+\s+-\s*:\s*(?:emacs|vi)\s*$/u.exec(
|
|
@@ -3108,13 +3113,9 @@ export class SessionChannel {
|
|
|
3108
3113
|
this.pendingLayoutOutput.get(change.windowId)?.layout !== pendingLayout
|
|
3109
3114
|
)
|
|
3110
3115
|
return;
|
|
3111
|
-
const border = reply.lines[0];
|
|
3116
|
+
const border = tiledPaneBorderStatus(reply.lines[0]);
|
|
3112
3117
|
const window = this.windowsByRuntime.get(change.windowId);
|
|
3113
|
-
if (
|
|
3114
|
-
!reply.ok ||
|
|
3115
|
-
!window ||
|
|
3116
|
-
(border !== "top" && border !== "bottom" && border !== "off")
|
|
3117
|
-
) {
|
|
3118
|
+
if (!reply.ok || !window || border === null) {
|
|
3118
3119
|
this.scheduleSync();
|
|
3119
3120
|
return;
|
|
3120
3121
|
}
|
|
@@ -3325,6 +3326,7 @@ export class SessionChannel {
|
|
|
3325
3326
|
displayName: display?.name ?? null,
|
|
3326
3327
|
displayNameSource: display?.source ?? null,
|
|
3327
3328
|
browserIcon: pane?.descriptor?.browserIcon ?? null,
|
|
3329
|
+
reader: pane?.descriptor?.reader ?? null,
|
|
3328
3330
|
left: leaf.left,
|
|
3329
3331
|
top: leaf.top,
|
|
3330
3332
|
width: leaf.width,
|
|
@@ -3535,9 +3537,7 @@ export class SessionChannel {
|
|
|
3535
3537
|
`list-panes -s -t "${expectedRuntimeSessionId}" -F "${SESSION_PANE_DESCRIPTOR_FORMAT}"`,
|
|
3536
3538
|
);
|
|
3537
3539
|
const confirmedWindowStage = await this.stageWindows(expectedRuntimeSessionId);
|
|
3538
|
-
const coherent =
|
|
3539
|
-
beforeLines.length === afterLines.length &&
|
|
3540
|
-
beforeLines.every((line, index) => line === afterLines[index]);
|
|
3540
|
+
const coherent = sameSessionPaneInventory(beforeLines, afterLines);
|
|
3541
3541
|
if (
|
|
3542
3542
|
windowStage.repairedIdentity ||
|
|
3543
3543
|
confirmedWindowStage.repairedIdentity ||
|
|
@@ -3871,12 +3871,13 @@ export class SessionChannel {
|
|
|
3871
3871
|
active = "",
|
|
3872
3872
|
visible = "",
|
|
3873
3873
|
zoomed = "",
|
|
3874
|
-
|
|
3874
|
+
borderStatusRaw = "off",
|
|
3875
3875
|
full = visible,
|
|
3876
3876
|
modeKeys,
|
|
3877
3877
|
indexRaw = "",
|
|
3878
3878
|
] = parts;
|
|
3879
3879
|
const index = Number(indexRaw);
|
|
3880
|
+
const borderStatus = tiledPaneBorderStatus(borderStatusRaw);
|
|
3880
3881
|
if (
|
|
3881
3882
|
!/^@[0-9]+$/u.test(runtimeId) ||
|
|
3882
3883
|
!/^(?:0|[1-9][0-9]*)$/u.test(indexRaw) ||
|
|
@@ -3884,7 +3885,7 @@ export class SessionChannel {
|
|
|
3884
3885
|
seenIndexes.has(index) ||
|
|
3885
3886
|
(active !== "0" && active !== "1") ||
|
|
3886
3887
|
(zoomed !== "0" && zoomed !== "1") ||
|
|
3887
|
-
|
|
3888
|
+
borderStatus === null ||
|
|
3888
3889
|
(modeKeys !== undefined && modeKeys !== "emacs" && modeKeys !== "vi")
|
|
3889
3890
|
) {
|
|
3890
3891
|
throw new Error(`window layout truth for ${this.opts.session} is malformed`);
|
|
@@ -22,6 +22,8 @@ import type { LocalImageOwner } from "../graphics/local-image-owner.ts";
|
|
|
22
22
|
import {
|
|
23
23
|
PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION,
|
|
24
24
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION,
|
|
25
|
+
PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION,
|
|
26
|
+
PANE_STREAM_READER_CAPABILITY_VERSION,
|
|
25
27
|
type PaneStreamInputLifetime,
|
|
26
28
|
} from "@tmux-ide/contracts";
|
|
27
29
|
import { inflateSync } from "node:zlib";
|
|
@@ -29,6 +31,7 @@ import { PaneStreamLayoutSnapshotFrameSchemaZ, type WindowLinkTopology } from "@
|
|
|
29
31
|
import type { TerminalDeliveryGraphics } from "../session-runtime/terminal-delivery-hub.ts";
|
|
30
32
|
import { z } from "zod";
|
|
31
33
|
import { logger } from "../../lib/log.ts";
|
|
34
|
+
import type { TmuxServerOwnerRetirement } from "../../lib/tmux-server-owners.ts";
|
|
32
35
|
import {
|
|
33
36
|
PANE_STREAM_MAX_HELD_DELTAS,
|
|
34
37
|
PANE_STREAM_MAX_OUTPUT_BYTES,
|
|
@@ -130,6 +133,44 @@ import {
|
|
|
130
133
|
export { PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL };
|
|
131
134
|
export const PANE_STREAM_MAX_REDEMPTION_BYTES = 4 * 1024;
|
|
132
135
|
export const PANE_STREAM_MAX_CONTROL_BYTES = 4 * 1024;
|
|
136
|
+
|
|
137
|
+
export interface PaneStreamShutdownClose {
|
|
138
|
+
readonly code: number;
|
|
139
|
+
readonly reason: "daemon-shutdown" | "tmux-server-retired" | "daemon-restarting";
|
|
140
|
+
}
|
|
141
|
+
/** The daemon process (or its whole generation) is going away. */
|
|
142
|
+
export const PANE_STREAM_DAEMON_SHUTDOWN_CLOSE: PaneStreamShutdownClose = Object.freeze({
|
|
143
|
+
code: 1001,
|
|
144
|
+
reason: "daemon-shutdown",
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Only this tmux server owner was retired; the daemon is still up. 1012
|
|
148
|
+
* (service restart) asks the client to list the servers again and reconnect
|
|
149
|
+
* now, without the backoff a vanished daemon deserves (#840).
|
|
150
|
+
*/
|
|
151
|
+
export const PANE_STREAM_OWNER_RETIRED_CLOSE: PaneStreamShutdownClose = Object.freeze({
|
|
152
|
+
code: 1012,
|
|
153
|
+
reason: "tmux-server-retired",
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* The process restarts its daemon generation in place (tmux server replaced,
|
|
157
|
+
* settings restart). A new generation follows at once, possibly on another
|
|
158
|
+
* port: read daemon.json again and reconnect now.
|
|
159
|
+
*/
|
|
160
|
+
export const PANE_STREAM_DAEMON_RESTARTING_CLOSE: PaneStreamShutdownClose = Object.freeze({
|
|
161
|
+
code: 1012,
|
|
162
|
+
reason: "daemon-restarting",
|
|
163
|
+
});
|
|
164
|
+
/** What an owner's streams are told when it is disposed for this reason. */
|
|
165
|
+
export function paneStreamCloseForRetirement(
|
|
166
|
+
retirement: TmuxServerOwnerRetirement | undefined,
|
|
167
|
+
): PaneStreamShutdownClose {
|
|
168
|
+
if (retirement === undefined || retirement === "shutdown")
|
|
169
|
+
return PANE_STREAM_DAEMON_SHUTDOWN_CLOSE;
|
|
170
|
+
return retirement === "generation-restart"
|
|
171
|
+
? PANE_STREAM_DAEMON_RESTARTING_CLOSE
|
|
172
|
+
: PANE_STREAM_OWNER_RETIRED_CLOSE;
|
|
173
|
+
}
|
|
133
174
|
export const PANE_STREAM_MAX_REDEMPTION_MS = 1_000;
|
|
134
175
|
|
|
135
176
|
const WS_OPEN = 1;
|
|
@@ -729,17 +770,33 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
729
770
|
return this.#ledger.snapshot();
|
|
730
771
|
}
|
|
731
772
|
|
|
732
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Close every stream and refuse new ones. The first caller decides what the
|
|
775
|
+
* clients are told: the daemon going away, or only this tmux server owner
|
|
776
|
+
* being retired while the daemon stays up (reconnect now).
|
|
777
|
+
*/
|
|
778
|
+
shutdown(close: PaneStreamShutdownClose = PANE_STREAM_DAEMON_SHUTDOWN_CLOSE): Promise<void> {
|
|
733
779
|
if (this.#shutdownPromise) return this.#shutdownPromise;
|
|
734
780
|
this.#shuttingDown = true;
|
|
735
|
-
|
|
781
|
+
// An idle daemon stopping is routine and stays out of the default log:
|
|
782
|
+
// `--headless --json` promises one status line on stdout. Streams that
|
|
783
|
+
// are actually closed, or an owner retired under a live daemon, are not.
|
|
784
|
+
const routine =
|
|
785
|
+
close.reason === "daemon-shutdown" && this.#live.size === 0 && this.#preAuth.size === 0;
|
|
786
|
+
logger[routine ? "debug" : "info"]("pane-stream", "coordinator shutdown", {
|
|
787
|
+
code: close.code,
|
|
788
|
+
reason: close.reason,
|
|
789
|
+
liveStreams: this.#live.size,
|
|
790
|
+
unredeemed: this.#preAuth.size,
|
|
791
|
+
});
|
|
792
|
+
this.#shutdownPromise = this.#finishShutdown(close);
|
|
736
793
|
return this.#shutdownPromise;
|
|
737
794
|
}
|
|
738
795
|
|
|
739
|
-
async #finishShutdown(): Promise<void> {
|
|
740
|
-
for (const admission of [...this.#preAuth]) admission.close(
|
|
796
|
+
async #finishShutdown(close: PaneStreamShutdownClose): Promise<void> {
|
|
797
|
+
for (const admission of [...this.#preAuth]) admission.close(close.code, close.reason);
|
|
741
798
|
await this.#exclusive(async () => {
|
|
742
|
-
for (const connection of [...this.#live]) connection.close(
|
|
799
|
+
for (const connection of [...this.#live]) connection.close(close.code, close.reason);
|
|
743
800
|
for (const pending of [...this.#pending.values()]) await this.#retirePending(pending);
|
|
744
801
|
});
|
|
745
802
|
await Promise.all([...this.#retiringReleases]);
|
|
@@ -1203,6 +1260,8 @@ export class PaneStreamLiveConnection {
|
|
|
1203
1260
|
#legacyInputActivated = false;
|
|
1204
1261
|
#legacyGeometryActivated = false;
|
|
1205
1262
|
#closed = false;
|
|
1263
|
+
#closeCause: { readonly cause: string; readonly error?: string } | null = null;
|
|
1264
|
+
#heldInput: boolean | null = null;
|
|
1206
1265
|
#releasePromise: Promise<unknown> | null = null;
|
|
1207
1266
|
#stopAuthoritySnapshots: (() => void) | null = null;
|
|
1208
1267
|
#sharedClockOriginMicros: number | null = null;
|
|
@@ -1239,6 +1298,8 @@ export class PaneStreamLiveConnection {
|
|
|
1239
1298
|
"panes-closed",
|
|
1240
1299
|
"peer-closed",
|
|
1241
1300
|
"daemon-shutdown",
|
|
1301
|
+
"tmux-server-retired",
|
|
1302
|
+
"daemon-restarting",
|
|
1242
1303
|
"redemption-rejected",
|
|
1243
1304
|
"unknown",
|
|
1244
1305
|
]).has(closeReason ?? "")
|
|
@@ -1256,6 +1317,8 @@ export class PaneStreamLiveConnection {
|
|
|
1256
1317
|
| "panes-closed"
|
|
1257
1318
|
| "peer-closed"
|
|
1258
1319
|
| "daemon-shutdown"
|
|
1320
|
+
| "tmux-server-retired"
|
|
1321
|
+
| "daemon-restarting"
|
|
1259
1322
|
| "redemption-rejected"
|
|
1260
1323
|
| "unknown";
|
|
1261
1324
|
this.#observability.recordSpan(
|
|
@@ -1389,14 +1452,34 @@ export class PaneStreamLiveConnection {
|
|
|
1389
1452
|
void this.#subscribeAll();
|
|
1390
1453
|
}
|
|
1391
1454
|
|
|
1455
|
+
/**
|
|
1456
|
+
* 1011 "stream-unavailable" has ten different origins and the client is told
|
|
1457
|
+
* none of them. The log says which one, with the error text, so a stream
|
|
1458
|
+
* that "just closed" can be traced without a reproduction.
|
|
1459
|
+
*/
|
|
1460
|
+
#fail(cause: string, error?: unknown): void {
|
|
1461
|
+
if (this.#closed) return;
|
|
1462
|
+
this.#closeCause = {
|
|
1463
|
+
cause,
|
|
1464
|
+
...(error === undefined
|
|
1465
|
+
? {}
|
|
1466
|
+
: { error: (error instanceof Error ? error.message : String(error)).slice(0, 300) }),
|
|
1467
|
+
};
|
|
1468
|
+
this.close(1011, "stream-unavailable");
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1392
1471
|
close(code = 1000, reason = "stream-closed"): void {
|
|
1393
1472
|
if (this.#closed) return;
|
|
1394
1473
|
this.#recordDiagnosticLifecycle("pane-stream-terminal", code, reason);
|
|
1395
1474
|
logger.info("pane-stream", "stream closed", {
|
|
1396
1475
|
code,
|
|
1397
1476
|
reason,
|
|
1477
|
+
...(this.#closeCause ?? {}),
|
|
1398
1478
|
session: this.#descriptor.sessionName,
|
|
1399
1479
|
clientId: this.#clientId,
|
|
1480
|
+
// Whether this connection held input when it went: the next stream of
|
|
1481
|
+
// the same client can only be granted input once that is released.
|
|
1482
|
+
...(this.#heldInput === null ? {} : { heldInput: this.#heldInput }),
|
|
1400
1483
|
});
|
|
1401
1484
|
this.#closed = true;
|
|
1402
1485
|
for (const demand of this.#surfaceDemands.values()) demand.close();
|
|
@@ -1466,8 +1549,8 @@ export class PaneStreamLiveConnection {
|
|
|
1466
1549
|
let described: MirrorSessionDescription;
|
|
1467
1550
|
try {
|
|
1468
1551
|
described = await this.#mirror.describeSession(this.#descriptor.sessionName);
|
|
1469
|
-
} catch {
|
|
1470
|
-
this
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
this.#fail("describe-session-failed", error);
|
|
1471
1554
|
return;
|
|
1472
1555
|
}
|
|
1473
1556
|
if (this.#closed) return;
|
|
@@ -1487,8 +1570,8 @@ export class PaneStreamLiveConnection {
|
|
|
1487
1570
|
return;
|
|
1488
1571
|
}
|
|
1489
1572
|
this.#layoutSubscription = layoutSubscription;
|
|
1490
|
-
} catch {
|
|
1491
|
-
this
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
this.#fail("layout-subscribe-failed", error);
|
|
1492
1575
|
return;
|
|
1493
1576
|
}
|
|
1494
1577
|
}
|
|
@@ -1512,8 +1595,8 @@ export class PaneStreamLiveConnection {
|
|
|
1512
1595
|
continue;
|
|
1513
1596
|
}
|
|
1514
1597
|
channel.sub = sub;
|
|
1515
|
-
} catch {
|
|
1516
|
-
this
|
|
1598
|
+
} catch (error) {
|
|
1599
|
+
this.#fail("pane-subscribe-failed", error);
|
|
1517
1600
|
return;
|
|
1518
1601
|
}
|
|
1519
1602
|
}
|
|
@@ -1524,7 +1607,7 @@ export class PaneStreamLiveConnection {
|
|
|
1524
1607
|
const binding = this.#sessionRuntimeBinding;
|
|
1525
1608
|
const offer = this.#descriptor.terminalDelivery;
|
|
1526
1609
|
if (!binding || !offer) {
|
|
1527
|
-
this
|
|
1610
|
+
this.#fail("no-session-runtime-binding");
|
|
1528
1611
|
return;
|
|
1529
1612
|
}
|
|
1530
1613
|
// Layout authority covers the whole session, while content leases may select
|
|
@@ -1592,7 +1675,7 @@ export class PaneStreamLiveConnection {
|
|
|
1592
1675
|
this.#failTopologyChanged();
|
|
1593
1676
|
return;
|
|
1594
1677
|
}
|
|
1595
|
-
this
|
|
1678
|
+
this.#fail("semantic-layout-subscribe-failed", cause);
|
|
1596
1679
|
return;
|
|
1597
1680
|
}
|
|
1598
1681
|
|
|
@@ -1650,7 +1733,13 @@ export class PaneStreamLiveConnection {
|
|
|
1650
1733
|
)
|
|
1651
1734
|
) {
|
|
1652
1735
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => undefined)));
|
|
1653
|
-
if (!this.#closed)
|
|
1736
|
+
if (!this.#closed) {
|
|
1737
|
+
const rejected = settled.find((result) => result.status === "rejected");
|
|
1738
|
+
this.#fail(
|
|
1739
|
+
"delivery-negotiation-failed",
|
|
1740
|
+
rejected?.status === "rejected" ? rejected.reason : "a pane's delivery offer was refused",
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1654
1743
|
return;
|
|
1655
1744
|
}
|
|
1656
1745
|
|
|
@@ -1933,7 +2022,10 @@ export class PaneStreamLiveConnection {
|
|
|
1933
2022
|
// when served.
|
|
1934
2023
|
const zlib =
|
|
1935
2024
|
this.#descriptor.terminalDelivery?.protocolVersions.some(
|
|
1936
|
-
(version) =>
|
|
2025
|
+
(version) =>
|
|
2026
|
+
version === TERMINAL_GRAPHICS_ZLIB_CAPABILITY_VERSION ||
|
|
2027
|
+
version === PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION ||
|
|
2028
|
+
version === PANE_STREAM_READER_CAPABILITY_VERSION,
|
|
1937
2029
|
) === true;
|
|
1938
2030
|
channel.graphicsZlib = zlib;
|
|
1939
2031
|
channel.graphicsLocal =
|
|
@@ -2414,6 +2506,10 @@ export class PaneStreamLiveConnection {
|
|
|
2414
2506
|
this.#sendFrame(null, frame);
|
|
2415
2507
|
}
|
|
2416
2508
|
|
|
2509
|
+
#offers(version: number): boolean {
|
|
2510
|
+
return this.#descriptor.terminalDelivery?.protocolVersions.includes(version) === true;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2417
2513
|
#layoutFrame(event: MirrorLayoutEvent): PaneStreamServerFrame | null {
|
|
2418
2514
|
const frame = {
|
|
2419
2515
|
type: "layout",
|
|
@@ -2429,9 +2525,13 @@ export class PaneStreamLiveConnection {
|
|
|
2429
2525
|
pane: pane.semanticPaneId,
|
|
2430
2526
|
displayName: pane.displayName,
|
|
2431
2527
|
displayNameSource: pane.displayNameSource,
|
|
2432
|
-
...(this.#
|
|
2528
|
+
...(this.#offers(PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION) ||
|
|
2529
|
+
this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION)
|
|
2433
2530
|
? { browserIcon: pane.browserIcon ?? null }
|
|
2434
2531
|
: {}),
|
|
2532
|
+
...(this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION)
|
|
2533
|
+
? { reader: pane.reader ? { name: pane.reader.name } : null }
|
|
2534
|
+
: {}),
|
|
2435
2535
|
left: pane.left,
|
|
2436
2536
|
top: pane.top,
|
|
2437
2537
|
width: pane.width,
|
|
@@ -2523,8 +2623,8 @@ export class PaneStreamLiveConnection {
|
|
|
2523
2623
|
this.#sentBytesTotal += bytes;
|
|
2524
2624
|
try {
|
|
2525
2625
|
this.#socket.send(encoded, { binary });
|
|
2526
|
-
} catch {
|
|
2527
|
-
this
|
|
2626
|
+
} catch (error) {
|
|
2627
|
+
this.#fail("socket-send-failed", error);
|
|
2528
2628
|
return;
|
|
2529
2629
|
}
|
|
2530
2630
|
// Stall is judged on the drain tick, never synchronously at send: the
|
|
@@ -2566,7 +2666,7 @@ export class PaneStreamLiveConnection {
|
|
|
2566
2666
|
if (this.#closed) return;
|
|
2567
2667
|
const buffered = this.#socket.bufferedAmount ?? 0;
|
|
2568
2668
|
if (!Number.isSafeInteger(buffered) || buffered < 0) {
|
|
2569
|
-
this
|
|
2669
|
+
this.#fail("socket-buffer-invalid");
|
|
2570
2670
|
return;
|
|
2571
2671
|
}
|
|
2572
2672
|
if (buffered > this.#maxSocketBufferedBytes) {
|
|
@@ -3026,6 +3126,23 @@ export class PaneStreamLiveConnection {
|
|
|
3026
3126
|
}
|
|
3027
3127
|
|
|
3028
3128
|
#sendAuthoritySnapshot(snapshot: SessionRuntimeAuthoritySnapshot): void {
|
|
3129
|
+
// One line when this connection gains or loses input, and one for its
|
|
3130
|
+
// first snapshot: a stream that paints but never accepts keys shows up
|
|
3131
|
+
// here as "holdsInput false" with the client that holds it instead.
|
|
3132
|
+
const self = this.#sessionRuntimeBinding?.clientId ?? null;
|
|
3133
|
+
const holdsInput = self !== null && snapshot.owners.input === self;
|
|
3134
|
+
if (this.#heldInput !== holdsInput) {
|
|
3135
|
+
logger.info("pane-stream", "stream input authority", {
|
|
3136
|
+
session: this.#descriptor.sessionName,
|
|
3137
|
+
clientId: this.#clientId,
|
|
3138
|
+
connectionClientId: self,
|
|
3139
|
+
holdsInput,
|
|
3140
|
+
inputOwner: snapshot.owners.input,
|
|
3141
|
+
clients: snapshot.clients.length,
|
|
3142
|
+
revision: snapshot.revision,
|
|
3143
|
+
});
|
|
3144
|
+
this.#heldInput = holdsInput;
|
|
3145
|
+
}
|
|
3029
3146
|
this.#sendFrame(null, { type: "authority-snapshot", snapshot });
|
|
3030
3147
|
}
|
|
3031
3148
|
|
|
@@ -3364,8 +3481,8 @@ export class PaneStreamLiveConnection {
|
|
|
3364
3481
|
}
|
|
3365
3482
|
}
|
|
3366
3483
|
}
|
|
3367
|
-
} catch {
|
|
3368
|
-
this
|
|
3484
|
+
} catch (error) {
|
|
3485
|
+
this.#fail("control-frame-handler-failed", error);
|
|
3369
3486
|
}
|
|
3370
3487
|
}
|
|
3371
3488
|
|
|
@@ -3377,8 +3494,8 @@ export class PaneStreamLiveConnection {
|
|
|
3377
3494
|
code,
|
|
3378
3495
|
retryable: false,
|
|
3379
3496
|
});
|
|
3380
|
-
} catch {
|
|
3381
|
-
this
|
|
3497
|
+
} catch (error) {
|
|
3498
|
+
this.#fail("error-frame-send-failed", error);
|
|
3382
3499
|
return;
|
|
3383
3500
|
}
|
|
3384
3501
|
this.close(1008, code);
|
|
@@ -8,6 +8,7 @@ import { PaneStreamLeaseManager } from "./lease-manager.ts";
|
|
|
8
8
|
import {
|
|
9
9
|
PaneStreamAdmissionCoordinator,
|
|
10
10
|
type PaneStreamAdmissionCoordinatorOptions,
|
|
11
|
+
type PaneStreamShutdownClose,
|
|
11
12
|
} from "./pane-stream-websocket.ts";
|
|
12
13
|
|
|
13
14
|
export interface PaneStreamRuntimeOptions {
|
|
@@ -75,11 +76,12 @@ export class PaneStreamRuntime {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
/** `close` says what the streams are told; the default is a daemon shutdown. */
|
|
80
|
+
dispose(close?: PaneStreamShutdownClose): Promise<void> {
|
|
79
81
|
if (!this.#disposePromise) {
|
|
80
82
|
this.#disposePromise = (async () => {
|
|
81
83
|
this.nativeSurfaces?.close();
|
|
82
|
-
await this.coordinator.shutdown();
|
|
84
|
+
await this.coordinator.shutdown(close);
|
|
83
85
|
})();
|
|
84
86
|
}
|
|
85
87
|
return this.#disposePromise;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { basename, isAbsolute } from "node:path";
|
|
2
|
+
import { hasControlCharacter } from "@tmux-ide/contracts";
|
|
3
|
+
|
|
4
|
+
export interface ReaderOption {
|
|
5
|
+
/** The file name shown in the pane header. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Absolute real path; daemon-only, never sent to clients. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** The reader process: the pane's own process. */
|
|
10
|
+
pid: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const MARKDOWN = /\.(?:md|markdown)$/iu;
|
|
14
|
+
|
|
15
|
+
export function isMarkdownPath(path: string): boolean {
|
|
16
|
+
const name = basename(path);
|
|
17
|
+
return MARKDOWN.test(name) && !/^\.(?:md|markdown)$/iu.test(name);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Parse `@tmux_ide_reader`: `{"version":1,"pid":N,"path":"/abs/notes.md"}`.
|
|
22
|
+
* A reader exists only while the process that set the option is alive, and
|
|
23
|
+
* only on the pane whose own process it is: `panePid` is that pane's
|
|
24
|
+
* `#{pane_pid}`. The CLI starts `tmux-ide show` with tmux's direct exec (no
|
|
25
|
+
* shell), so the pane's process is the reader itself and records exactly that
|
|
26
|
+
* pid. Equality rather than "a descendant of" needs no process-tree walk.
|
|
27
|
+
*
|
|
28
|
+
* What the tie rules out: an option left behind by a reader that has exited,
|
|
29
|
+
* and a later process that happens to reuse its pid. What it does not: the
|
|
30
|
+
* option is not proof that `tmux-ide show` set it. In a shell pane the shell
|
|
31
|
+
* is the pane's process, so the shell can set an option naming its own pid,
|
|
32
|
+
* and any process that can talk to the tmux server can read another pane's
|
|
33
|
+
* pid and set that pane's option. Both are the same user, who can already
|
|
34
|
+
* read the file; the reader grants no access they do not have.
|
|
35
|
+
*/
|
|
36
|
+
export function readerOption(
|
|
37
|
+
value: string,
|
|
38
|
+
panePid: string,
|
|
39
|
+
alive = processAlive,
|
|
40
|
+
): ReaderOption | null {
|
|
41
|
+
if (!value || value.length > 8192) return null;
|
|
42
|
+
let parsed: unknown;
|
|
43
|
+
try {
|
|
44
|
+
parsed = JSON.parse(value);
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
49
|
+
const record = parsed as Record<string, unknown>;
|
|
50
|
+
if (Object.keys(record).sort().join(",") !== "path,pid,version") return null;
|
|
51
|
+
const { version, pid, path } = record;
|
|
52
|
+
if (version !== 1 || typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
53
|
+
return null;
|
|
54
|
+
if (!/^[1-9][0-9]*$/u.test(panePid) || String(pid) !== panePid) return null;
|
|
55
|
+
if (
|
|
56
|
+
typeof path !== "string" ||
|
|
57
|
+
path.length > 4096 ||
|
|
58
|
+
!isAbsolute(path) ||
|
|
59
|
+
hasControlCharacter(path) ||
|
|
60
|
+
!isMarkdownPath(path)
|
|
61
|
+
)
|
|
62
|
+
return null;
|
|
63
|
+
const name = basename(path);
|
|
64
|
+
if (name.length > 255) return null;
|
|
65
|
+
if (!alive(pid)) return null;
|
|
66
|
+
return { name, path, pid };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function processAlive(pid: number): boolean {
|
|
70
|
+
try {
|
|
71
|
+
process.kill(pid, 0);
|
|
72
|
+
return true;
|
|
73
|
+
} catch {
|
|
74
|
+
// Including EPERM: a pid now owned by another user is not our reader.
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { browserIcon } from "./browser-icon.ts";
|
|
2
|
+
import { readerOption, type ReaderOption } from "./reader-option.ts";
|
|
2
3
|
|
|
3
4
|
export interface SessionPaneDescriptor {
|
|
4
5
|
browserIcon?: string | null;
|
|
6
|
+
/** A live `tmux-ide open file.md` reader; the path stays daemon-side. */
|
|
7
|
+
reader?: ReaderOption | null;
|
|
5
8
|
nativePaneBirthId?: string | null;
|
|
6
9
|
sessionName: string;
|
|
7
10
|
runtimePaneId: string;
|
|
@@ -56,8 +59,42 @@ export const SESSION_PANE_DESCRIPTOR_FORMAT = [
|
|
|
56
59
|
"#{pane_birth_id}",
|
|
57
60
|
"#{qa:@tmux_ide_name_source}",
|
|
58
61
|
"#{qa:@tmux_ide_browser_icon}",
|
|
62
|
+
"#{qa:@tmux_ide_reader}",
|
|
63
|
+
// The reader option belongs to the pane only when its own process set it.
|
|
64
|
+
"#{pane_pid}",
|
|
59
65
|
].join("\t");
|
|
60
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Descriptor fields the program in a pane changes whenever it likes: its
|
|
69
|
+
* command name, the window name tmux derives from it, and its title.
|
|
70
|
+
*/
|
|
71
|
+
const VOLATILE_DESCRIPTOR_FIELDS: ReadonlySet<number> = new Set([
|
|
72
|
+
4, // pane_current_command
|
|
73
|
+
7, // window_name
|
|
74
|
+
9, // pane_title
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Whether two `list-panes` replies in SESSION_PANE_DESCRIPTOR_FORMAT describe
|
|
79
|
+
* the same panes. A busy pane changes its command and title between any two
|
|
80
|
+
* reads, which is not a pane set that is still changing: those fields are
|
|
81
|
+
* display text, read again on the next refresh (#730).
|
|
82
|
+
*/
|
|
83
|
+
export function sameSessionPaneInventory(
|
|
84
|
+
before: readonly string[],
|
|
85
|
+
after: readonly string[],
|
|
86
|
+
): boolean {
|
|
87
|
+
const stable = (line: string) =>
|
|
88
|
+
line
|
|
89
|
+
.split("\t")
|
|
90
|
+
.map((field, index) => (VOLATILE_DESCRIPTOR_FIELDS.has(index) ? "" : field))
|
|
91
|
+
.join("\t");
|
|
92
|
+
return (
|
|
93
|
+
before.length === after.length &&
|
|
94
|
+
before.every((line, index) => line === after[index] || stable(line) === stable(after[index]!))
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
61
98
|
/** Decode the escapes emitted by tmux's `qa` format modifier. */
|
|
62
99
|
export function decodeTmuxArgument(value: string): string {
|
|
63
100
|
const encoded =
|
|
@@ -135,7 +172,7 @@ export function parseSessionPaneDescriptorReply(
|
|
|
135
172
|
continue;
|
|
136
173
|
}
|
|
137
174
|
const encoded = utf8Line.split("\t");
|
|
138
|
-
if (encoded.length
|
|
175
|
+
if (encoded.length < 21 || encoded.length > 25) continue;
|
|
139
176
|
const [
|
|
140
177
|
runtimePaneId = "",
|
|
141
178
|
semanticPaneId = "",
|
|
@@ -160,6 +197,8 @@ export function parseSessionPaneDescriptorReply(
|
|
|
160
197
|
nativePaneBirthId = "",
|
|
161
198
|
nameSource = "",
|
|
162
199
|
browserIconRaw = "",
|
|
200
|
+
readerRaw = "",
|
|
201
|
+
panePidRaw = "",
|
|
163
202
|
] = encoded.map(decodeTmuxArgument);
|
|
164
203
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32) continue;
|
|
165
204
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32) continue;
|
|
@@ -200,6 +239,7 @@ export function parseSessionPaneDescriptorReply(
|
|
|
200
239
|
}
|
|
201
240
|
descriptors.push({
|
|
202
241
|
browserIcon: browserIcon(browserIconRaw),
|
|
242
|
+
reader: readerOption(readerRaw, panePidRaw),
|
|
203
243
|
sessionName,
|
|
204
244
|
runtimePaneId,
|
|
205
245
|
runtimeSessionId,
|
|
@@ -175,7 +175,12 @@ export interface StockSplitOptions extends StockSplitSizes {
|
|
|
175
175
|
}
|
|
176
176
|
export function parseStockSplitOptions(line: string | undefined): StockSplitOptions | null {
|
|
177
177
|
const [borderStatus, scrollbars, style] = (line ?? "").split("\t");
|
|
178
|
-
|
|
178
|
+
// The raw value stays: the guarded command compares it with the option. A
|
|
179
|
+
// floating value leaves tiled panes without a status line, like "off".
|
|
180
|
+
if (
|
|
181
|
+
!/^(off|top|bottom|top-floating|bottom-floating)$/u.test(borderStatus ?? "") ||
|
|
182
|
+
!/^[a-z]+$/u.test(scrollbars ?? "")
|
|
183
|
+
)
|
|
179
184
|
return null;
|
|
180
185
|
const field = (name: string) =>
|
|
181
186
|
Number(new RegExp(`\\b${name}=(\\d+)`, "u").exec(style ?? "")?.[1] ?? 0);
|
|
@@ -115,6 +115,14 @@ export interface SessionRuntimeRegistryOptions {
|
|
|
115
115
|
readonly observability?: SessionRuntimeObservability;
|
|
116
116
|
/** Deterministic qualification seam; never invoked while observability is disabled. */
|
|
117
117
|
readonly createTraceCorrelator?: (scheduler: SessionRuntimeScheduler) => RuntimeTraceCorrelator;
|
|
118
|
+
/**
|
|
119
|
+
* A session's terminal inventory may be readable again: a shared-window or
|
|
120
|
+
* registered-window conflict cleared, or its trusted inventory became
|
|
121
|
+
* qualified after it was not. The daemon publishes a
|
|
122
|
+
* terminal-runtime-inventory change so an idle client that met the 503
|
|
123
|
+
* re-reads at once; that read re-qualifies the session (perf plan F13, #764).
|
|
124
|
+
*/
|
|
125
|
+
readonly onInventoryRecovered?: (session: string) => void;
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
/** Opaque daemon-internal proof that an inventory came from one exact runtime owner. */
|
|
@@ -324,6 +332,15 @@ export class SessionRuntimeRegistry implements PaneStreamMirror {
|
|
|
324
332
|
readonly #scheduler: SessionRuntimeScheduler;
|
|
325
333
|
readonly #observability: SessionRuntimeObservability;
|
|
326
334
|
readonly #createTraceCorrelator: (scheduler: SessionRuntimeScheduler) => RuntimeTraceCorrelator;
|
|
335
|
+
readonly #onInventoryRecovered: ((session: string) => void) | null;
|
|
336
|
+
|
|
337
|
+
#announceInventory(session: string): void {
|
|
338
|
+
try {
|
|
339
|
+
this.#onInventoryRecovered?.(session);
|
|
340
|
+
} catch {
|
|
341
|
+
// A publication failure never changes qualification.
|
|
342
|
+
}
|
|
343
|
+
}
|
|
327
344
|
readonly #sessions = new Map<string, SessionRuntime>();
|
|
328
345
|
#listenerDisposal: ListenerDisposalSummary | null = null;
|
|
329
346
|
readonly #proofPrewarmOwnership = new Map<SessionRuntime, { owned: boolean; claims: number }>();
|
|
@@ -342,6 +359,7 @@ export class SessionRuntimeRegistry implements PaneStreamMirror {
|
|
|
342
359
|
this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
|
|
343
360
|
this.#createTraceCorrelator =
|
|
344
361
|
options.createTraceCorrelator ?? ((scheduler) => new RuntimeTraceCorrelator(scheduler));
|
|
362
|
+
this.#onInventoryRecovered = options.onInventoryRecovered ?? null;
|
|
345
363
|
const diagnosticMirrorOptions: Partial<MirrorServiceOptions> = {
|
|
346
364
|
onInputAccepted: (session, action, acceptedAtMicros, ok) => {
|
|
347
365
|
for (const traceId of action.traceIds ?? []) {
|
|
@@ -474,6 +492,9 @@ export class SessionRuntimeRegistry implements PaneStreamMirror {
|
|
|
474
492
|
onSharedWindowConflict: (session, conflict) => {
|
|
475
493
|
options.mirror?.onSharedWindowConflict?.(session, conflict);
|
|
476
494
|
if (conflict) this.#sessions.get(session)?.invalidateSharedWindowAuthority();
|
|
495
|
+
// A cleared conflict is the trigger an idle client needs: nobody else
|
|
496
|
+
// may read the inventory, and the client's re-read re-qualifies it.
|
|
497
|
+
else if (!this.#mirror.hasSharedWindowConflict(session)) this.#announceInventory(session);
|
|
477
498
|
},
|
|
478
499
|
onNativeClientActivity: (session) => {
|
|
479
500
|
options.mirror?.onNativeClientActivity?.(session);
|
|
@@ -573,7 +594,9 @@ export class SessionRuntimeRegistry implements PaneStreamMirror {
|
|
|
573
594
|
}
|
|
574
595
|
signal?.throwIfAborted();
|
|
575
596
|
await abortable(this.#mirror.verifyRegisteredWindows(), signal);
|
|
597
|
+
const wasQualified = runtime.trustedInventoryQualified();
|
|
576
598
|
runtime.qualifyTrustedInventory(runtimeSessionId);
|
|
599
|
+
if (!wasQualified && runtime.trustedInventoryQualified()) this.#announceInventory(session);
|
|
577
600
|
} finally {
|
|
578
601
|
this.#releaseProofPrewarmRuntime(runtime);
|
|
579
602
|
}
|