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 CHANGED
@@ -658,10 +658,11 @@ async function killTmuxSession(name) {
658
658
  return { ok: false, error: msg };
659
659
  }
660
660
  }
661
- async function scrollTmux(name, direction) {
661
+ async function scrollTmux(name, direction, lines = 12) {
662
662
  const bin = resolveTmuxPath();
663
663
  if (!bin) return { inCopyMode: false };
664
- const target = `=${name}`;
664
+ const n = Math.max(1, Math.min(200, Math.round(lines)));
665
+ const target = name;
665
666
  const run = (args) => execFileAsync2(bin, args, { timeout: 4e3 }).catch(() => {
666
667
  });
667
668
  const inMode = async () => {
@@ -677,12 +678,12 @@ async function scrollTmux(name, direction) {
677
678
  return { inCopyMode: false };
678
679
  }
679
680
  if (direction === "up") {
680
- await run(["copy-mode", "-t", target]);
681
- await run(["send-keys", "-t", target, "-X", "halfpage-up"]);
681
+ if (!await inMode()) await run(["copy-mode", "-t", target]);
682
+ await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-up"]);
682
683
  return { inCopyMode: true };
683
684
  }
684
685
  if (!await inMode()) return { inCopyMode: false };
685
- await run(["send-keys", "-t", target, "-X", "halfpage-down"]);
686
+ await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-down"]);
686
687
  try {
687
688
  const { stdout } = await execFileAsync2(bin, ["display-message", "-t", target, "-p", "#{scroll_position}"], { timeout: 3e3 });
688
689
  if ((parseInt(stdout.trim(), 10) || 0) === 0) {
@@ -2000,10 +2001,10 @@ var init_index = __esm({
2000
2001
  socket.emit(TMUX_KILL_RESULT, { requestId, name, ok: result.ok, error: result.error });
2001
2002
  });
2002
2003
  socket.on(TMUX_SCROLL, async (payload) => {
2003
- const { sessionId, direction } = payload;
2004
+ const { sessionId, direction, lines } = payload;
2004
2005
  const name = sessionId && sessionTmuxName.get(sessionId);
2005
2006
  if (!name) return;
2006
- const { inCopyMode } = await scrollTmux(name, direction);
2007
+ const { inCopyMode } = await scrollTmux(name, direction, lines);
2007
2008
  sessionInCopyMode.set(sessionId, inCopyMode);
2008
2009
  });
2009
2010
  socket.on(TERMINAL_INPUT, (payload) => {