[PR #206] fix(tui): accumulate Pi text deltas for flowing paragraph rendering #200

Open
opened 2026-02-27 10:22:41 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/206
Author: @mikeyobrien
Created: 2/27/2026
Status: 🔄 Open

Base: mainHead: feat/pi-tui-text-accumulation


📝 Commits (3)

  • 32a3371 feat: Pi TUI streaming fix, hat scope enforcement, and event chain validation
  • f576682 chore: remove upstream-PRs folder from branch
  • 2c94643 fix(clippy): add reasons to #[ignore] attributes

📊 Changes

23 files changed (+2313 additions, -50 deletions)

View changed files

.claude/skills/tui-debug-in-pane/SKILL.md (+89 -0)
📝 crates/ralph-adapters/src/json_rpc_handler.rs (+68 -0)
📝 crates/ralph-adapters/tests/pty_executor_integration.rs (+372 -0)
📝 crates/ralph-bench/src/main.rs (+2 -0)
📝 crates/ralph-cli/src/display.rs (+2 -0)
📝 crates/ralph-cli/src/doctor.rs (+1 -0)
📝 crates/ralph-cli/src/loop_runner.rs (+177 -6)
📝 crates/ralph-cli/src/main.rs (+14 -2)
📝 crates/ralph-core/src/config.rs (+29 -0)
📝 crates/ralph-core/src/diagnostics/log_rotation.rs (+3 -2)
📝 crates/ralph-core/src/event_loop/loop_state.rs (+38 -0)
📝 crates/ralph-core/src/event_loop/mod.rs (+218 -4)
📝 crates/ralph-core/src/event_loop/tests.rs (+598 -0)
📝 crates/ralph-core/src/hat_registry.rs (+79 -0)
📝 crates/ralph-core/src/hatless_ralph.rs (+23 -0)
📝 crates/ralph-core/src/summary_writer.rs (+6 -0)
📝 crates/ralph-tui/src/lib.rs (+13 -1)
📝 crates/ralph-tui/src/rpc_source.rs (+309 -4)
📝 crates/ralph-tui/src/state.rs (+33 -0)
📝 crates/ralph-tui/src/widgets/content.rs (+20 -5)

...and 3 more files

📄 Description

Summary

  • Fix garbled Pi TUI output: Pi streams text as small deltas (5-50 chars each). The RPC event handler was rendering each delta independently as a separate line, producing one-word-per-line garbled output. Now accumulates deltas in a buffer and re-renders the full text on each chunk, freezing when non-text events arrive (tool calls, errors, iteration end).
  • Hat scope enforcement & event chain validation: Opt-in hat scope enforcement drops out-of-scope events; event chain validation rejects LOOP_COMPLETE if required topics are unseen; graceful cancellation via loop.cancel; stale loop detection on 3+ consecutive same-topic emissions.
  • Pi streaming hardening: Wide PTY columns in autonomous mode prevent NDJSON line wrapping; broken pipe cascade defense; subprocess stderr redirected to log files.

Test plan

  • New tests: test_small_text_deltas_form_flowing_paragraph_not_one_per_line and test_text_deltas_frozen_by_tool_call_preserve_order
  • All existing tests pass (cargo test --all)
  • Live verification with Pi/kiro backend confirmed flowing paragraph text in TUI
  • cargo fmt and cargo clippy clean

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/206 **Author:** [@mikeyobrien](https://github.com/mikeyobrien) **Created:** 2/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/pi-tui-text-accumulation` --- ### 📝 Commits (3) - [`32a3371`](https://github.com/mikeyobrien/ralph-orchestrator/commit/32a337133b4f65af69946660bc5b2453ad95481f) feat: Pi TUI streaming fix, hat scope enforcement, and event chain validation - [`f576682`](https://github.com/mikeyobrien/ralph-orchestrator/commit/f5766829b5bf1ed2c319c7f2bfc83f3a32dcd07d) chore: remove upstream-PRs folder from branch - [`2c94643`](https://github.com/mikeyobrien/ralph-orchestrator/commit/2c94643f3100de697c2a6d0062642555ddc27872) fix(clippy): add reasons to #[ignore] attributes ### 📊 Changes **23 files changed** (+2313 additions, -50 deletions) <details> <summary>View changed files</summary> ➕ `.claude/skills/tui-debug-in-pane/SKILL.md` (+89 -0) 📝 `crates/ralph-adapters/src/json_rpc_handler.rs` (+68 -0) 📝 `crates/ralph-adapters/tests/pty_executor_integration.rs` (+372 -0) 📝 `crates/ralph-bench/src/main.rs` (+2 -0) 📝 `crates/ralph-cli/src/display.rs` (+2 -0) 📝 `crates/ralph-cli/src/doctor.rs` (+1 -0) 📝 `crates/ralph-cli/src/loop_runner.rs` (+177 -6) 📝 `crates/ralph-cli/src/main.rs` (+14 -2) 📝 `crates/ralph-core/src/config.rs` (+29 -0) 📝 `crates/ralph-core/src/diagnostics/log_rotation.rs` (+3 -2) 📝 `crates/ralph-core/src/event_loop/loop_state.rs` (+38 -0) 📝 `crates/ralph-core/src/event_loop/mod.rs` (+218 -4) 📝 `crates/ralph-core/src/event_loop/tests.rs` (+598 -0) 📝 `crates/ralph-core/src/hat_registry.rs` (+79 -0) 📝 `crates/ralph-core/src/hatless_ralph.rs` (+23 -0) 📝 `crates/ralph-core/src/summary_writer.rs` (+6 -0) 📝 `crates/ralph-tui/src/lib.rs` (+13 -1) 📝 `crates/ralph-tui/src/rpc_source.rs` (+309 -4) 📝 `crates/ralph-tui/src/state.rs` (+33 -0) 📝 `crates/ralph-tui/src/widgets/content.rs` (+20 -5) _...and 3 more files_ </details> ### 📄 Description ## Summary - **Fix garbled Pi TUI output**: Pi streams text as small deltas (5-50 chars each). The RPC event handler was rendering each delta independently as a separate line, producing one-word-per-line garbled output. Now accumulates deltas in a buffer and re-renders the full text on each chunk, freezing when non-text events arrive (tool calls, errors, iteration end). - **Hat scope enforcement & event chain validation**: Opt-in hat scope enforcement drops out-of-scope events; event chain validation rejects LOOP_COMPLETE if required topics are unseen; graceful cancellation via loop.cancel; stale loop detection on 3+ consecutive same-topic emissions. - **Pi streaming hardening**: Wide PTY columns in autonomous mode prevent NDJSON line wrapping; broken pipe cascade defense; subprocess stderr redirected to log files. ## Test plan - [x] New tests: `test_small_text_deltas_form_flowing_paragraph_not_one_per_line` and `test_text_deltas_frozen_by_tool_call_preserve_order` - [x] All existing tests pass (`cargo test --all`) - [x] Live verification with Pi/kiro backend confirmed flowing paragraph text in TUI - [x] `cargo fmt` and `cargo clippy` clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#200
No description provided.