clawless icon indicating copy to clipboard operation
clawless copied to clipboard

User's input message inputs double characters

Open shreehari-lyzr opened this issue 8 months ago • 2 comments

for instance, If the user types "hi" the input is taken as "hhii"

shreehari-lyzr avatar Mar 20 '26 11:03 shreehari-lyzr

This has been reproduced and the root cause is confirmed: onData handlers accumulate across shell restarts in ContainerManager because the previous listener is never disposed before a new one is registered. Every restart stacks another handler, so each keystroke gets written to stdin N times where N is the number of restarts.

Two PRs are open that fix this:

  • PR #3 (bugfix/user-input by shreehari-lyzr) — disposes the previous onData disposable before each new registration in ContainerManager. Clean and explicit.
  • PR #10 (fix/terminal by tsj2003) — registers a single listener in TerminalManager constructor and routes through a swappable callback property.

Both work, but only one should merge to avoid a conflict. Recommend reviewing PR #3 first given it more directly targets the ContainerManager call sites where the stacking happens.

Assigning @shreyas-lyzr to follow through on closing this once the chosen PR lands.

shreyas-lyzr avatar May 24 '26 09:05 shreyas-lyzr

There are currently two open PRs addressing this bug with different approaches:

  • PR #3 (shreehari-lyzr): Tracks an onDataDisposable in ContainerManager and calls dispose() before each new terminal.onData() registration across startGitclaw, startShell, and startAgent.
  • PR #10 (tsj2003): Registers xterm.onData exactly once in TerminalManager's constructor and routes all input through a replaceable dataHandler property, so callers set dataHandler rather than registering new listeners.

PR #10's approach is slightly more defensive — it structurally prevents listener stacking rather than relying on callers to dispose correctly. However, both are valid fixes.

Recommendation: pick one approach and close the other with a comment explaining the decision, to avoid a double-fix or merge conflict in terminal.ts. If PR #10 is merged, PR #3's container.ts changes (the onDataDisposable per-restart pattern) may still be worth keeping as an extra safety layer, but the terminal.ts changes would conflict.

Assigned to @shreyas-lyzr to decide which PR to land.

shreyas-lyzr avatar May 25 '26 09:05 shreyas-lyzr