kaizen-agent 1.34.0 → 1.34.2

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/web/term.ts CHANGED
@@ -42,12 +42,37 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
42
42
  onEnd?.();
43
43
  };
44
44
  const typed = term.onData((d) => send({ t: "i", d }));
45
+ // xterm.js has no touch scrolling, so on a phone a swipe did nothing. Each line's
46
+ // worth of swipe scrolls the buffer, or — when the agent tracks the mouse, as a
47
+ // full-screen Claude Code does — goes to it as a wheel report.
48
+ // ponytail: always the SGR (1006) encoding; an agent asking for X10 mouse would misread it.
49
+ let lastY: number | null = null;
50
+ const touchStart = (e: TouchEvent) => { lastY = e.touches.length === 1 ? e.touches[0].clientY : null; };
51
+ const touchMove = (e: TouchEvent) => {
52
+ if (lastY === null || e.touches.length !== 1) return;
53
+ const screen = el.querySelector<HTMLElement>(".xterm-screen");
54
+ const cell = (screen?.clientHeight || el.clientHeight) / term.rows;
55
+ const t = e.touches[0];
56
+ const lines = Math.trunc((lastY - t.clientY) / cell);
57
+ e.preventDefault();
58
+ if (!lines) return;
59
+ lastY -= lines * cell;
60
+ if (term.modes.mouseTrackingMode === "none") return term.scrollLines(lines);
61
+ const r = (screen ?? el).getBoundingClientRect();
62
+ const col = Math.min(term.cols, Math.max(1, Math.ceil((t.clientX - r.left) / (r.width / term.cols))));
63
+ const row = Math.min(term.rows, Math.max(1, Math.ceil((t.clientY - r.top) / cell)));
64
+ send({ t: "i", d: `\x1b[<${lines > 0 ? 65 : 64};${col};${row}M`.repeat(Math.abs(lines)) });
65
+ };
66
+ el.addEventListener("touchstart", touchStart, { passive: true });
67
+ el.addEventListener("touchmove", touchMove, { passive: false });
45
68
  const ro = new ResizeObserver(size);
46
69
  ro.observe(el);
47
70
  term.focus();
48
71
 
49
72
  return () => {
50
73
  ro.disconnect();
74
+ el.removeEventListener("touchstart", touchStart);
75
+ el.removeEventListener("touchmove", touchMove);
51
76
  typed.dispose();
52
77
  ws.onclose = null;
53
78
  ws.close();