cli-remote-agent 1.0.11 → 1.0.13
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/dist/cli.js +8 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -470,10 +470,11 @@ async function killTmuxSession(name) {
|
|
|
470
470
|
return { ok: false, error: msg };
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
async function scrollTmux(name, direction) {
|
|
473
|
+
async function scrollTmux(name, direction, lines = 12) {
|
|
474
474
|
const bin = resolveTmuxPath();
|
|
475
475
|
if (!bin) return { inCopyMode: false };
|
|
476
|
-
const
|
|
476
|
+
const n = Math.max(1, Math.min(200, Math.round(lines)));
|
|
477
|
+
const target = name;
|
|
477
478
|
const run = (args) => execFileAsync2(bin, args, { timeout: 4e3 }).catch(() => {
|
|
478
479
|
});
|
|
479
480
|
const inMode = async () => {
|
|
@@ -489,12 +490,12 @@ async function scrollTmux(name, direction) {
|
|
|
489
490
|
return { inCopyMode: false };
|
|
490
491
|
}
|
|
491
492
|
if (direction === "up") {
|
|
492
|
-
await run(["copy-mode", "-t", target]);
|
|
493
|
-
await run(["send-keys", "-t", target, "-X", "
|
|
493
|
+
if (!await inMode()) await run(["copy-mode", "-t", target]);
|
|
494
|
+
await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-up"]);
|
|
494
495
|
return { inCopyMode: true };
|
|
495
496
|
}
|
|
496
497
|
if (!await inMode()) return { inCopyMode: false };
|
|
497
|
-
await run(["send-keys", "-t", target, "-X", "
|
|
498
|
+
await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-down"]);
|
|
498
499
|
try {
|
|
499
500
|
const { stdout } = await execFileAsync2(bin, ["display-message", "-t", target, "-p", "#{scroll_position}"], { timeout: 3e3 });
|
|
500
501
|
if ((parseInt(stdout.trim(), 10) || 0) === 0) {
|
|
@@ -1719,10 +1720,10 @@ socket.on(TMUX_KILL, async (payload) => {
|
|
|
1719
1720
|
socket.emit(TMUX_KILL_RESULT, { requestId, name, ok: result.ok, error: result.error });
|
|
1720
1721
|
});
|
|
1721
1722
|
socket.on(TMUX_SCROLL, async (payload) => {
|
|
1722
|
-
const { sessionId, direction } = payload;
|
|
1723
|
+
const { sessionId, direction, lines } = payload;
|
|
1723
1724
|
const name = sessionId && sessionTmuxName.get(sessionId);
|
|
1724
1725
|
if (!name) return;
|
|
1725
|
-
const { inCopyMode } = await scrollTmux(name, direction);
|
|
1726
|
+
const { inCopyMode } = await scrollTmux(name, direction, lines);
|
|
1726
1727
|
sessionInCopyMode.set(sessionId, inCopyMode);
|
|
1727
1728
|
});
|
|
1728
1729
|
socket.on(TERMINAL_INPUT, (payload) => {
|