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
|
@@ -2,10 +2,13 @@ import { requireSupportedTmuxVersion } from "./lib/tmux-version.js";
|
|
|
2
2
|
import { resolveTmuxExecutable } from "./lib/tmux-client-execution.js";
|
|
3
3
|
import { TMUX_SOCKET_PATH_ENV } from "./lib/runtime-namespace.js";
|
|
4
4
|
import { execSync, execFileSync } from "node:child_process";
|
|
5
|
-
import { accessSync, constants, existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
5
|
+
import { accessSync, constants, existsSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
|
-
import { resolve, dirname, join } from "node:path";
|
|
8
|
-
import {
|
|
7
|
+
import { delimiter, resolve, dirname, join } from "node:path";
|
|
8
|
+
import { resolveBundledTmux } from "./lib/bundled-tmux.js";
|
|
9
|
+
import { readSnapshot } from "./tui/chrome/snapshot.js";
|
|
10
|
+
import { isListableSession } from "./tui/team/sessions.js";
|
|
11
|
+
import { nativeCommands } from "./lib/tmux-server-features.js";
|
|
9
12
|
import { fileURLToPath } from "node:url";
|
|
10
13
|
import { getCurrentVersion, getUpdateStatus } from "./lib/update-check.js";
|
|
11
14
|
import { installedSkillVersion } from "./lib/skill-sync.js";
|
|
@@ -152,53 +155,21 @@ function check(label, fn, { optional = false } = {}) {
|
|
|
152
155
|
return { label, pass: false, detail: e.message, optional };
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
const UNKNOWN = (command) => new RegExp(`^unknown command: ${command}$`, "mu");
|
|
156
|
-
/** The same reading of the server as the mirror's: the stock resize when it refuses
|
|
157
|
-
* the split command 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")) {
|
|
175
|
-
if (refused(events, "tmux-ide-events"))
|
|
176
|
-
return "stock";
|
|
177
|
-
// The journal answers: a tmux-ide tmux built before the split command.
|
|
178
|
-
if (events.output !== undefined)
|
|
179
|
-
return "older";
|
|
180
|
-
return "unknown";
|
|
181
|
-
}
|
|
182
|
-
if (split.output !== undefined && events.output !== undefined) {
|
|
183
|
-
try {
|
|
184
|
-
return nativeSplitCapability(split.output) ? "full" : "partial";
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
return "partial";
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return failures.length === 2 ? "unknown" : "partial";
|
|
191
|
-
}
|
|
192
158
|
/** Reads the server a session would use. With none running, a throwaway private
|
|
193
159
|
* server shows what the resolved binary would start. */
|
|
194
160
|
export function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
195
161
|
let answer = nativeCommands(probeServer);
|
|
196
|
-
|
|
162
|
+
const running = answer !== "no-server";
|
|
163
|
+
if (!running)
|
|
197
164
|
answer = nativeCommands(probeBinary);
|
|
165
|
+
// Only a running server can be moved; the command restarts it and restores its sessions.
|
|
166
|
+
const upgrade = running
|
|
167
|
+
? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux"
|
|
168
|
+
: "";
|
|
198
169
|
const details = {
|
|
199
170
|
full: "bundled tmux: full features",
|
|
200
|
-
stock:
|
|
201
|
-
older:
|
|
171
|
+
stock: `stock tmux: reduced features${upgrade}`,
|
|
172
|
+
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
202
173
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
203
174
|
"no-server": "could not read the tmux server's features",
|
|
204
175
|
unknown: "could not read the tmux server's features",
|
|
@@ -210,6 +181,96 @@ export function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
210
181
|
optional: true,
|
|
211
182
|
};
|
|
212
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* PURE — what a plain `tmux` typed in a shell runs. Informational: when it is
|
|
186
|
+
* not tmux-ide's own tmux and it starts the server, features drop (#766).
|
|
187
|
+
*/
|
|
188
|
+
export function plainTmuxRow(pathTmux, bundled) {
|
|
189
|
+
const label = "plain `tmux` in your shell";
|
|
190
|
+
if (!pathTmux)
|
|
191
|
+
return {
|
|
192
|
+
label,
|
|
193
|
+
pass: true,
|
|
194
|
+
detail: "not on PATH (tmux-ide uses its own tmux)",
|
|
195
|
+
optional: true,
|
|
196
|
+
};
|
|
197
|
+
if (bundled && pathTmux === bundled)
|
|
198
|
+
return { label, pass: true, detail: `tmux-ide's own tmux (${pathTmux})`, optional: true };
|
|
199
|
+
return {
|
|
200
|
+
label,
|
|
201
|
+
pass: true,
|
|
202
|
+
detail: `${pathTmux}; if it starts the server, features drop (see docs: tmux upgrade)`,
|
|
203
|
+
optional: true,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
207
|
+
/**
|
|
208
|
+
* PURE — is the crash snapshot fresh enough to restore from? It fails when it
|
|
209
|
+
* is missing a live session, or is over a day old while sessions run. Only the
|
|
210
|
+
* chrome updater writes it, and that runs only while a session is adopted.
|
|
211
|
+
*/
|
|
212
|
+
export function snapshotRow(snapshot, liveSessions, nowMs) {
|
|
213
|
+
const label = "crash snapshot (restore)";
|
|
214
|
+
const hint = "Only the chrome updater writes it, while a session is adopted: `tmux-ide adopt --all` starts it";
|
|
215
|
+
if (!snapshot) {
|
|
216
|
+
return liveSessions?.length
|
|
217
|
+
? { label, pass: false, detail: `none yet. ${hint}`, optional: true }
|
|
218
|
+
: { label, pass: true, detail: "none yet (no sessions running)", optional: true };
|
|
219
|
+
}
|
|
220
|
+
const ageMs = nowMs - Date.parse(snapshot.savedAt);
|
|
221
|
+
const age = ageMs >= DAY_MS
|
|
222
|
+
? `${Math.floor(ageMs / DAY_MS)} days old`
|
|
223
|
+
: `${Math.max(0, Math.round(ageMs / 60_000))} min old`;
|
|
224
|
+
const saved = new Set(snapshot.sessions.map((session) => session.name));
|
|
225
|
+
const missing = (liveSessions ?? []).filter((name) => !saved.has(name));
|
|
226
|
+
if (missing.length)
|
|
227
|
+
return {
|
|
228
|
+
label,
|
|
229
|
+
pass: false,
|
|
230
|
+
detail: `${age}; misses ${missing.length} running session${missing.length === 1 ? "" : "s"} (${missing.slice(0, 5).join(", ")}${missing.length > 5 ? ", …" : ""}). ${hint}`,
|
|
231
|
+
optional: true,
|
|
232
|
+
};
|
|
233
|
+
return { label, pass: true, detail: `${age}, covers every running session`, optional: true };
|
|
234
|
+
}
|
|
235
|
+
function firstOnPath(name) {
|
|
236
|
+
for (const directory of (process.env.PATH ?? "").split(delimiter)) {
|
|
237
|
+
if (!directory)
|
|
238
|
+
continue;
|
|
239
|
+
const candidate = join(directory, name);
|
|
240
|
+
try {
|
|
241
|
+
accessSync(candidate, constants.X_OK);
|
|
242
|
+
return realpathSync(candidate);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// Try the next PATH entry.
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
function safeBundledTmux() {
|
|
251
|
+
try {
|
|
252
|
+
const bundled = resolveBundledTmux();
|
|
253
|
+
return bundled ? realpathSync(bundled) : null;
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** The sessions the snapshot should hold, on the server doctor reads; null when unreadable. */
|
|
260
|
+
function liveListableSessions() {
|
|
261
|
+
try {
|
|
262
|
+
const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
|
|
263
|
+
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
264
|
+
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
265
|
+
return execFileSync(resolveTmuxExecutable(), [...server, "list-sessions", "-F", "#{session_name}"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3000 })
|
|
266
|
+
.split("\n")
|
|
267
|
+
.filter((name) => name && isListableSession(name));
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
const text = String(error.stderr ?? "");
|
|
271
|
+
return /no server running|error connecting/u.test(text) ? [] : null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
213
274
|
function runTmuxFeatureProbes(executable) {
|
|
214
275
|
const run = (prefix) => (args) => execFileSync(executable, [...prefix, ...args], {
|
|
215
276
|
encoding: "utf8",
|
|
@@ -249,6 +310,46 @@ function runTmuxFeatureProbes(executable) {
|
|
|
249
310
|
cleanup();
|
|
250
311
|
}
|
|
251
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* PURE — which tmux server the daemon uses, and whether this shell's `tmux`
|
|
315
|
+
* means the same one.
|
|
316
|
+
*
|
|
317
|
+
* A daemon started outside tmux (launchd, systemd, `--headless` from a plain
|
|
318
|
+
* shell) addresses the socket named "default" and gives its tmux clients a
|
|
319
|
+
* scrubbed environment, so it always looks in /tmp/tmux-<uid>/ and ignores
|
|
320
|
+
* TMUX_TMPDIR. A shell that exports TMUX_TMPDIR, or sits in a tmux started
|
|
321
|
+
* with -S or -L, is then on a server that daemon cannot see. The explicit
|
|
322
|
+
* TMUX_IDE_TMUX_SOCKET_PATH / TMUX_IDE_TMUX_SOCKET_NAME settings apply to both.
|
|
323
|
+
*/
|
|
324
|
+
export function tmuxServerSocketRow(environment, uid) {
|
|
325
|
+
const defaultDirectory = join("/tmp", `tmux-${String(uid)}`);
|
|
326
|
+
const explicitPath = environment[TMUX_SOCKET_PATH_ENV];
|
|
327
|
+
const explicitName = environment.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
328
|
+
const daemonSocket = explicitPath
|
|
329
|
+
? explicitPath
|
|
330
|
+
: join(defaultDirectory, explicitName ? explicitName : "default");
|
|
331
|
+
const insideTmux = /^(.*),[0-9]+,[0-9]+$/u.exec(environment.TMUX ?? "")?.[1];
|
|
332
|
+
const shellSocket = insideTmux ?? join(environment.TMUX_TMPDIR || "/tmp", `tmux-${String(uid)}`, "default");
|
|
333
|
+
const same = (left, right) => left.replace(/^\/private\/tmp\//u, "/tmp/") === right.replace(/^\/private\/tmp\//u, "/tmp/");
|
|
334
|
+
if (explicitPath || explicitName || same(shellSocket, daemonSocket))
|
|
335
|
+
return {
|
|
336
|
+
label: "tmux server",
|
|
337
|
+
pass: true,
|
|
338
|
+
detail: `the daemon uses ${daemonSocket}${explicitPath || explicitName ? " (set explicitly)" : ""}`,
|
|
339
|
+
optional: true,
|
|
340
|
+
};
|
|
341
|
+
const why = insideTmux
|
|
342
|
+
? "this shell is inside a tmux on another socket"
|
|
343
|
+
: "TMUX_TMPDIR is set, and the daemon ignores it";
|
|
344
|
+
return {
|
|
345
|
+
label: "tmux server",
|
|
346
|
+
pass: false,
|
|
347
|
+
detail: `this shell's tmux uses ${shellSocket}, a background daemon uses ${daemonSocket} (${why}): ` +
|
|
348
|
+
`it will not see this shell's sessions. Set ${TMUX_SOCKET_PATH_ENV}=${shellSocket} in the daemon's environment` +
|
|
349
|
+
(insideTmux ? "" : ", or unset TMUX_TMPDIR"),
|
|
350
|
+
optional: true,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
252
353
|
export function nodeVersionRow(version) {
|
|
253
354
|
const major = Number(version.split(".")[0]);
|
|
254
355
|
const pass = Number.isInteger(major) && major >= 20;
|
|
@@ -296,6 +397,8 @@ export async function doctor({ json, } = {}) {
|
|
|
296
397
|
catch {
|
|
297
398
|
// The tmux version row above already reports a missing executable.
|
|
298
399
|
}
|
|
400
|
+
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
401
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
299
402
|
checks.push(nodeVersionRow(process.versions.node));
|
|
300
403
|
checks.push(check("256-color terminal", () => {
|
|
301
404
|
const term = process.env.TERM ?? "";
|
|
@@ -393,6 +496,7 @@ export async function doctor({ json, } = {}) {
|
|
|
393
496
|
}
|
|
394
497
|
return `in sync (v${installed})`;
|
|
395
498
|
}, { optional: true }));
|
|
499
|
+
checks.push(tmuxServerSocketRow(process.env, process.getuid?.() ?? 0));
|
|
396
500
|
// Canonical daemon identity + log provenance (credential-free), so a triage
|
|
397
501
|
// never chases a stale, manually redirected log file.
|
|
398
502
|
checks.push((() => {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { withBundledTmuxResources } from "./bundled-tmux.js";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
|
-
|
|
3
|
+
export const BOUNDED_TMUX_KILL_GRACE_MS = 250;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only child ownership: TERM at deadline/abort, KILL after grace; settle
|
|
6
|
+
* after close. "close" needs every holder of the pipes to let go, so once the
|
|
7
|
+
* child has been killed the read settles one more grace later regardless: a
|
|
8
|
+
* wrapper's lingering grandchild must not turn a deadline into a hang (#839).
|
|
9
|
+
*/
|
|
4
10
|
export function boundedTmuxRead(executable, args, options) {
|
|
5
11
|
if (options.signal?.aborted)
|
|
6
12
|
return Promise.reject(new Error("Tmux read cancelled"));
|
|
@@ -17,12 +23,37 @@ export function boundedTmuxRead(executable, args, options) {
|
|
|
17
23
|
failure ??= error;
|
|
18
24
|
output = stdout;
|
|
19
25
|
});
|
|
26
|
+
let abandon = null;
|
|
27
|
+
let settled = false;
|
|
28
|
+
const settle = () => {
|
|
29
|
+
if (settled)
|
|
30
|
+
return;
|
|
31
|
+
settled = true;
|
|
32
|
+
clearTimeout(deadline);
|
|
33
|
+
if (escalation)
|
|
34
|
+
clearTimeout(escalation);
|
|
35
|
+
if (abandon)
|
|
36
|
+
clearTimeout(abandon);
|
|
37
|
+
options.signal?.removeEventListener("abort", stop);
|
|
38
|
+
if (failure)
|
|
39
|
+
reject(failure);
|
|
40
|
+
else
|
|
41
|
+
resolve(output);
|
|
42
|
+
};
|
|
20
43
|
const stop = () => {
|
|
21
44
|
failure ??= new Error("Tmux read cancelled or deadline exceeded");
|
|
22
45
|
if (escalation)
|
|
23
46
|
return;
|
|
24
47
|
child.kill("SIGTERM");
|
|
25
|
-
escalation = setTimeout(() =>
|
|
48
|
+
escalation = setTimeout(() => {
|
|
49
|
+
child.kill("SIGKILL");
|
|
50
|
+
abandon = setTimeout(() => {
|
|
51
|
+
child.stdout?.destroy();
|
|
52
|
+
child.stderr?.destroy();
|
|
53
|
+
settle();
|
|
54
|
+
}, BOUNDED_TMUX_KILL_GRACE_MS);
|
|
55
|
+
abandon.unref?.();
|
|
56
|
+
}, BOUNDED_TMUX_KILL_GRACE_MS);
|
|
26
57
|
escalation.unref?.();
|
|
27
58
|
};
|
|
28
59
|
const deadline = setTimeout(stop, options.timeoutMs ?? 5000);
|
|
@@ -31,16 +62,7 @@ export function boundedTmuxRead(executable, args, options) {
|
|
|
31
62
|
child.once("error", (error) => {
|
|
32
63
|
failure ??= error;
|
|
33
64
|
});
|
|
34
|
-
child.once("close",
|
|
35
|
-
clearTimeout(deadline);
|
|
36
|
-
if (escalation)
|
|
37
|
-
clearTimeout(escalation);
|
|
38
|
-
options.signal?.removeEventListener("abort", stop);
|
|
39
|
-
if (failure)
|
|
40
|
-
reject(failure);
|
|
41
|
-
else
|
|
42
|
-
resolve(output);
|
|
43
|
-
});
|
|
65
|
+
child.once("close", settle);
|
|
44
66
|
if (options.signal?.aborted)
|
|
45
67
|
stop();
|
|
46
68
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
/**
|
|
4
|
+
* The argv prefix that runs this tmux-ide's CLI: the bundled `bin/cli.js`,
|
|
5
|
+
* or `bin/cli.ts` under the runtime's loader flags when run from source.
|
|
6
|
+
* `here` must sit two directories below `packages/daemon/src`'s parent.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveCliCommand(here = fileURLToPath(import.meta.url), runtime = process) {
|
|
9
|
+
if (basename(here) === "cli.js")
|
|
10
|
+
return [runtime.execPath, here];
|
|
11
|
+
const cli = join(dirname(here), "..", "..", "..", "..", "bin", `cli${extname(here)}`);
|
|
12
|
+
return [runtime.execPath, ...runtime.execArgv, cli];
|
|
13
|
+
}
|