fix(tui): reliable large-prompt paste + version-robust turn detection (#130)#131
Merged
Merged
Conversation
…#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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
transcript.mjs): only recognizedturn_duration, which claude 2.1.114 doesn't emit → never detected completion → 120s wallclock. Now also acceptsassistant+stop_reason ∈ {end_turn,stop_sequence,max_tokens}(version-robust;tool_usestays non-terminal).session.mjs):send-keys -l "$(cat file)"delivers a big multi-line prompt's newlines as separate Enters → never lands. Nowload-buffer+paste-buffer -p(bracketed, atomic).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 -eneeds tmux ≥3.2 but the cloud host is 2.7) — carriesDISABLE_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