cd427d218b
- Server tests on Windows no longer reach the user's real psmux: psmux
ignores TMUX_TMPDIR (and 3.3.x PSMUX_DATA_DIR), so quit.test.js's Quit and
the runner's kill-server ended every live lane pane — the pre-commit hook
included. scripts/test-server.js now takes tmux off the suites' PATH there.
- Wheel scrolling on Windows: psmux never turns mouse tracking on for its
client, so xterm.js never reported the wheel and a pane could not scroll.
A Windows attach is told {type:"wheel"} and the browser sends the SGR wheel
report itself; psmux scrolls or forwards it to the pane's app.
- tmux.upgradeAdvice(): the oldest tmux AgentHub asks for and how each
platform upgrades (psmux 3.4.0 -> winget upgrade marlocarlo.psmux; tmux 3.7
-> brew upgrade tmux / build the release on Linux). Used by the doctor,
GET /api/run/tmux ({available, version, upgrade}), `agenthub doctor`, and a
sticky toast on the Workspace page. Advice only: nothing installs tmux.
Committed with --no-verify (user's call): the pre-commit hook runs the full
backend suite, which has ~378 pre-existing failures on Windows (S3/Linux-only
tests: sudo, /proc, systemd, members). Every test touching this change passes:
pty-attach, tmux, run, plugin-doctor-tmux, TerminalView, Workspace, and the
client tests related to the changed files; tsc and the header audit are clean.
75 lines
2.9 KiB
JavaScript
75 lines
2.9 KiB
JavaScript
/**
|
|
* @file Tests the `tmux` row of scripts/plugin-doctor.js — the check that tells
|
|
* an install its browser run console cannot work, because every run the
|
|
* dashboard starts is a tmux session (server/lib/tmux.js). The row must WARN
|
|
* and never FAIL: sessions, analytics, lanes and the CLI all work without the
|
|
* binary, so failing a doctor run over it would cry wolf. A tmux older than its
|
|
* platform asks for (tmux.upgradeAdvice: psmux 3.4.0 on Windows, tmux 3.7
|
|
* elsewhere) also warns, as does a new binary still talking to an older
|
|
* running server. tmux is faked through the module's own exec seam, so
|
|
* the test never depends on the host having it.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
const { describe, it, after } = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const os = require("node:os");
|
|
const path = require("node:path");
|
|
|
|
const TMP_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "agenthub-doctor-tmux-"));
|
|
process.env.CLAUDE_HOME = TMP_HOME;
|
|
|
|
const tmux = require("../lib/tmux");
|
|
const { diagnose } = require("../../scripts/plugin-doctor");
|
|
|
|
after(() => {
|
|
tmux.__reset();
|
|
fs.rmSync(TMP_HOME, { recursive: true, force: true });
|
|
delete process.env.CLAUDE_HOME;
|
|
});
|
|
|
|
/** Fake the tmux binary (null = absent) and its running server (null = none),
|
|
* then read back the row. */
|
|
function rowWithTmux(client, server = null) {
|
|
tmux.__setExecImpl((args) => {
|
|
if (!client) throw new Error("spawnSync tmux ENOENT");
|
|
if (args[0] === "-V") return `tmux ${client}\n`;
|
|
if (!server) throw new Error("no server running");
|
|
return `${server}\n`;
|
|
});
|
|
const row = diagnose().find((r) => r.label === "tmux");
|
|
assert.ok(row, "the doctor must always emit a tmux row");
|
|
return row;
|
|
}
|
|
|
|
describe("plugin-doctor: tmux row", () => {
|
|
it("warns, never fails, when tmux is not on PATH", () => {
|
|
const row = rowWithTmux(null);
|
|
|
|
assert.equal(row.level, "warn", "a missing tmux must not fail the doctor run");
|
|
assert.match(row.detail, /workspace shell/, "the reader needs to know WHAT breaks");
|
|
assert.match(row.detail, /install/i, "and how to fix it");
|
|
});
|
|
|
|
it("passes when tmux has pane scrollbars (3.7+)", () => {
|
|
assert.equal(rowWithTmux("3.7c").level, "ok");
|
|
assert.equal(rowWithTmux("next-3.8", "3.8-rc3").level, "ok");
|
|
});
|
|
|
|
it("warns, with this platform's upgrade path, when tmux is older than it asks for", () => {
|
|
// 2.9 is too old everywhere; the advice (minimum, command) is per platform.
|
|
const row = rowWithTmux("2.9", "2.9");
|
|
|
|
assert.equal(row.level, "warn");
|
|
assert.ok(row.detail.includes(tmux.upgradeAdvice("2.9")), row.detail);
|
|
});
|
|
|
|
it("warns when a new tmux is still talking to an older running server", () => {
|
|
const row = rowWithTmux("3.7c", "2.9");
|
|
|
|
assert.equal(row.level, "warn");
|
|
assert.match(row.detail, /server is 2\.9/);
|
|
});
|
|
});
|