codeam-cli 1.2.1 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ var import_picocolors = __toESM(require("picocolors"));
110
110
  // package.json
111
111
  var package_default = {
112
112
  name: "codeam-cli",
113
- version: "1.2.1",
113
+ version: "1.2.2",
114
114
  description: "Remote control Claude Code from your mobile device",
115
115
  main: "dist/index.js",
116
116
  bin: {
@@ -681,26 +681,30 @@ var ClaudeService = class {
681
681
  /**
682
682
  * Navigate a React Ink selector to the given 0-based index and confirm.
683
683
  *
684
- * Why not just sendCommand(arrows)? When all arrow keys + Enter arrive in one
685
- * write() call, Node's readline splits them into individual keypress events that
686
- * all fire in the same synchronous run. React Ink's SelectInput captures
687
- * selectedIndex in a closure because React hasn't re-rendered between the
688
- * arrows and the Enter, the closure still sees the initial index (0) when Enter
689
- * fires, so it always submits option 0.
684
+ * Why not sendCommand(arrows + Enter) in one write()?
685
+ * All bytes arrive as one chunk readline fires all keypress events in the
686
+ * same synchronous runReact Ink batches the state updates → each arrow
687
+ * sees selectedIndex=0 final state is still 0 or 1 wrong option selected.
690
688
  *
691
- * Fix: send the arrows first, then wait 150 ms for React to process + re-render,
692
- * then send the confirming Enter.
689
+ * Fix: send each down-arrow in a separate write(), ARROW_MS apart, so React
690
+ * has time to process and re-render between each keystroke. Enter is sent
691
+ * ENTER_MS after the last arrow.
693
692
  */
694
693
  selectOption(index) {
695
- const arrows = "\x1B[B".repeat(Math.max(0, index));
696
- if (arrows) {
697
- this.proc?.stdin?.write(arrows);
698
- setTimeout(() => {
699
- this.proc?.stdin?.write("\r");
700
- }, 150);
701
- } else {
694
+ if (index <= 0) {
702
695
  this.proc?.stdin?.write("\r");
696
+ return;
703
697
  }
698
+ const ARROW_MS = 80;
699
+ const ENTER_MS = 200;
700
+ for (let i = 0; i < index; i++) {
701
+ setTimeout(() => {
702
+ this.proc?.stdin?.write("\x1B[B");
703
+ }, i * ARROW_MS);
704
+ }
705
+ setTimeout(() => {
706
+ this.proc?.stdin?.write("\r");
707
+ }, index * ARROW_MS + ENTER_MS);
704
708
  }
705
709
  /** Send Ctrl+C to Claude. */
706
710
  interrupt() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Remote control Claude Code from your mobile device",
5
5
  "main": "dist/index.js",
6
6
  "bin": {