@volter/supercode-terminal 0.2.43 → 0.2.45

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/substrate/tmux.js +29 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-terminal",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "type": "module",
5
5
  "description": "Optional leak-safe terminal and tmux host adapter for Volter Harness frontends",
6
6
  "exports": {
package/substrate/tmux.js CHANGED
@@ -344,12 +344,15 @@ function sessionServerOptionArgs() {
344
344
  return [
345
345
  "set-option", "-g", "history-limit", "50000", ";",
346
346
  "set-option", "-g", "mouse", "on", ";",
347
- // The relay clients (tmux-stream attaches as screen-256color; a person's own
348
- // terminal attaches as something else) draw into the viewer's normal screen,
349
- // so lines that scroll off land in the viewer's own scrollback, and they
350
- // pass clipboard, focus and extended keys through. Indexed, so re-applying
351
- // on every create replaces one entry instead of appending.
352
- "set-option", "-s", "terminal-overrides[90]", "screen-256color:smcup@:rmcup@", ";",
347
+ // Every client draws into the viewer's normal screen, so lines that scroll
348
+ // off land in the viewer's own scrollback and the wheel scrolls it; on the
349
+ // alternate screen a terminal turns the wheel into up/down arrows. That is
350
+ // every client, not only the relay's screen-256color: a person's own
351
+ // terminal, or a window a daemon opened, attaches as whatever TERM it sets.
352
+ // The relay clients also pass clipboard, focus and extended keys through.
353
+ // Indexed, so re-applying on every create replaces one entry instead of
354
+ // appending.
355
+ "set-option", "-s", "terminal-overrides[90]", "*:smcup@:rmcup@", ";",
353
356
  "set-option", "-s", "terminal-features[90]", "screen-256color:clipboard:focus:extkeys:title", ";",
354
357
  // Harness TUIs (Claude Code) track focus; tmux forwards focus in/out only with this on.
355
358
  "set-option", "-s", "focus-events", "on", ";",
@@ -849,29 +852,32 @@ function terminalInputRunOptions(deadlineMs) {
849
852
  throw new Error("Terminal input expired before delivery.");
850
853
  return { timeoutMs };
851
854
  }
855
+ // The escape sequences a keystream carries for named keys, as tmux names them.
856
+ const ESCAPE_SEQUENCE_KEYS = [
857
+ ["\u001b[A", "Up"],
858
+ ["\u001b[B", "Down"],
859
+ ["\u001b[C", "Right"],
860
+ ["\u001b[D", "Left"],
861
+ ["\u001b[H", "Home"],
862
+ ["\u001b[F", "End"],
863
+ ["\u001b[Z", "BTab"],
864
+ ["\u001b[3~", "DC"],
865
+ ["\u001b[5~", "PPage"],
866
+ ["\u001b[6~", "NPage"],
867
+ ];
852
868
  function tokenizeTerminalInput(data) {
853
869
  const tokens = [];
854
870
  for (let i = 0; i < data.length; i += 1) {
855
871
  const char = data[i];
856
- const next3 = data.slice(i, i + 3);
857
- if (next3 === "\u001b[A") {
858
- tokens.push({ key: "Up" });
859
- i += 2;
860
- continue;
861
- }
862
- if (next3 === "\u001b[B") {
863
- tokens.push({ key: "Down" });
864
- i += 2;
865
- continue;
866
- }
867
- if (next3 === "\u001b[C") {
868
- tokens.push({ key: "Right" });
869
- i += 2;
872
+ const sequence = ESCAPE_SEQUENCE_KEYS.find(([bytes]) => data.startsWith(bytes, i));
873
+ if (sequence) {
874
+ tokens.push({ key: sequence[1] });
875
+ i += sequence[0].length - 1;
870
876
  continue;
871
877
  }
872
- if (next3 === "\u001b[D") {
873
- tokens.push({ key: "Left" });
874
- i += 2;
878
+ // A lone ESC (no sequence after it) is the Escape key.
879
+ if (char === "\u001b") {
880
+ tokens.push({ key: "Escape" });
875
881
  continue;
876
882
  }
877
883
  if (char === "\r" || char === "\n") {