Skip to content

fix(tui): reliable large-prompt paste + version-robust turn detection (#130)#131

Merged
dtzp555-max merged 1 commit into
mainfrom
fix/tui-readiness-paste-verify
Jun 1, 2026
Merged

fix(tui): reliable large-prompt paste + version-robust turn detection (#130)#131
dtzp555-max merged 1 commit into
mainfrom
fix/tui-readiness-paste-verify

Conversation

@dtzp555-max

Copy link
Copy Markdown
Owner

Fixes the TUI-mode "stuck typing" hang on real (large, multi-line) OpenClaw-agent prompts. Diagnosed live on PI231 + Oracle.

Three root causes, all fixed

  1. Terminal detection (transcript.mjs): only recognized turn_duration, which claude 2.1.114 doesn't emit → never detected completion → 120s wallclock. Now also accepts assistant + stop_reason ∈ {end_turn,stop_sequence,max_tokens} (version-robust; tool_use stays non-terminal).
  2. Paste (session.mjs): send-keys -l "$(cat file)" delivers a big multi-line prompt's newlines as separate Enters → never lands. Now load-buffer + paste-buffer -p (bracketed, atomic).
  3. Verify (session.mjs): the "placeholder-gone" heuristic false-positived on claude's empty curly-quote placeholder → fired Enter into an empty box (the actual hang). Now positive-signal-only ([Pasted text] / prompt text) + readiness-poll + paste-verify-poll + fast-fail (deterministic ~5s error instead of 120s hang).

Env delivered via an env-prefix on the pane command (tmux doesn't forward spawnSync's env; new-session -e needs tmux ≥3.2 but the cloud host is 2.7) — carries DISABLE_AUTOUPDATER + entrypoint labeling.

Validation (live, both hosts)

A 300-line / ~30KB prompt that previously hung → ~5-8s; small prompts ~4-5s. 192 tests pass (new: cross-schema terminal detection, positive-signal verify incl. the curly-quote false-positive guard).

Scope

A context-reduction attempt (strip claude's CLAUDE.md/auto-memory) was reverted — unproven through OCP + caused an off-response + separate concern (own measured branch later).

ALIGNMENT.md

TUI = ADR-0007 proxy-side bridge, not a forwarded Anthropic op → cli.js citation N/A (Rule 2). No blacklisted tokens / port literals. Independent opus reviewer: APPROVE WITH CHANGES (Iron Rule 10) — validated the fixes, caught that a per-session tmux socket would break the startup stale-session reaper + flagged the context-suppression scope-creep; both reverted per review.

Closes #130.

🤖 Generated with Claude Code

…#130)

TUI mode hung ("stuck typing") on the OpenClaw agent's real (large, multi-line) prompts.
Three root causes, all fixed:

1. transcript.mjs — terminal detection only recognized {system, turn_duration}, which
   claude 2.1.114 (the cloud host) does not emit → readTuiTranscript never saw completion
   and ran to the 120s wallclock even though claude had answered. Now also treats an
   {assistant} line with message.stop_reason ∈ {end_turn, stop_sequence, max_tokens} as
   terminal (version-robust; stop_reason "tool_use" stays non-terminal, so tool turns are
   not truncated — preserves the v3.17.1 narrowing).

2. session.mjs paste — send-keys -l "$(cat file)" delivers a large multi-line prompt's
   newlines as separate key events (≈repeated Enter), so the prompt never lands. Replaced
   with tmux load-buffer + paste-buffer -p (bracketed paste): atomic, no shell arg limit,
   claude ingests it as one "[Pasted text]".

3. session.mjs verify — the old "placeholder-gone" heuristic false-positived on claude's
   empty curly-quote placeholder, so Enter fired into an empty box (THE root cause of the
   hang). tuiPromptLanded now trusts only positive signals ([Pasted text] indicator or the
   prompt's own text); readiness-poll + paste-verify-poll + fast-fail (tui_paste_not_landed)
   turns a 120s wallclock hang into a deterministic ~5s error.

Also: env delivered to the pane via an `env`-prefix on the pane command (tmux does NOT
forward spawnSync's env, and new-session -e needs tmux ≥3.2 while the cloud host runs 2.7),
carrying DISABLE_AUTOUPDATER (version pin) + CLAUDE_CODE_ENTRYPOINT labeling.

Validated live on both hosts: a 300-line / ~30KB prompt that previously hung now returns
in ~5-8s; small prompts ~4-5s. 192 tests pass (new: terminal-detection across schemas,
positive-signal verify incl. the curly-quote false-positive guard, paste predicates).

Scope discipline: an attempt to also strip claude's CLAUDE.md/auto-memory injection (context
reduction) was REVERTED — it didn't measurably reduce context through OCP, caused an
off-response, and is a separate concern. It will be its own measured branch.

ALIGNMENT.md: TUI is the ADR-0007 proxy-side execution bridge, not a forwarded Anthropic
operation, so a cli.js citation is N/A under Rule 2. No blacklisted tokens / port literals.

Independent fresh-context reviewer (opus): APPROVE WITH CHANGES (Iron Rule 10) — validated
the three fixes, caught that a per-session tmux socket would break the startup stale-session
reaper, and flagged the context-suppression scope-creep; both were reverted per the review.

Closes #130.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dtzp555-max dtzp555-max merged commit 9568411 into main Jun 1, 2026
5 checks passed
@dtzp555-max dtzp555-max deleted the fix/tui-readiness-paste-verify branch June 1, 2026 11:26
dtzp555-max added a commit that referenced this pull request Jun 1, 2026
…-purity context (#4) (#134)

Release prep only: bump package.json 3.18.0 → 3.19.0, CHANGELOG entry, README TUI
"what changes / what doesn't" note that the host CLAUDE.md/auto-memory is never injected.

Bundles two already-merged, independently-reviewed TUI fixes:
- #130 (PR #131): reliable large multi-line paste + version-robust turn detection.
- #4   (PR #132): never inject host CLAUDE.md / auto-memory into proxied turns.

Both verified live on PI231 + Oracle; adversarial multi-host battery passed
(0 hangs / 0 crashes / 0 injection / 0 leaks). Follow-up: #133.

No server.mjs change in this PR (package.json + CHANGELOG + README only) → cli.js
citation N/A. release_kit (Iron Rule 5.5): version_source=package.json, changelog,
README docs all updated; no new env var / endpoint / subcommand.

Co-authored-by: dtzp555 <dtzp555@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TUI] Stuck-typing: blind send-keys race + claude auto-update splash → prompt never submitted

2 participants