[PR #179] [MERGED] fix: hat display stuck on previous iteration's hat #181

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

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/179
Author: @The-Zona-Zoo
Created: 2/20/2026
Status: Merged
Merged: 2/20/2026
Merged by: @mikeyobrien

Base: mainHead: fix/hat-display-stuck-on-previous


📝 Commits (1)

  • 909a9b9 fix: hat display stuck on previous iteration's hat

📊 Changes

6 files changed (+169 additions, -25 deletions)

View changed files

📝 crates/ralph-cli/src/loop_runner.rs (+5 -6)
📝 crates/ralph-core/src/event_loop/mod.rs (+23 -4)
📝 crates/ralph-core/src/event_loop/tests.rs (+82 -8)
📝 crates/ralph-core/src/lib.rs (+1 -1)
📝 crates/ralph-core/tests/event_loop_ralph.rs (+5 -2)
📝 crates/ralph-tui/src/widgets/header.rs (+53 -4)

📄 Description

This was originally attempted to be fixed in #170, but was unsuccessful. Two bugs caused the TUI to show stale hat state:

  1. process_events_from_jsonl returned has_orphans (bool), but the caller in loop_runner.rs treated it as had_events via matches!(Ok(true)). For non-orphan events (topic matches a hat trigger), has_orphans=false caused the caller to think no events were written and inject default_publishes, corrupting hat state. Fix: return a ProcessedEvents struct with separate had_events and has_orphans fields.

  2. The TUI header always preferred the frozen IterationBuffer hat over the live pending_hat. After an iteration finishes (elapsed set) but before the next iteration starts, the stale frozen hat was displayed instead of the updated pending_hat. Fix: when iteration is finished and pending_hat is known, show pending_hat.

Both regression tests fail on old code, pass on fix.


🔄 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/179 **Author:** [@The-Zona-Zoo](https://github.com/The-Zona-Zoo) **Created:** 2/20/2026 **Status:** ✅ Merged **Merged:** 2/20/2026 **Merged by:** [@mikeyobrien](https://github.com/mikeyobrien) **Base:** `main` ← **Head:** `fix/hat-display-stuck-on-previous` --- ### 📝 Commits (1) - [`909a9b9`](https://github.com/mikeyobrien/ralph-orchestrator/commit/909a9b9dab1d50318fed2c546faa4231a8fbc3fd) fix: hat display stuck on previous iteration's hat ### 📊 Changes **6 files changed** (+169 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/ralph-cli/src/loop_runner.rs` (+5 -6) 📝 `crates/ralph-core/src/event_loop/mod.rs` (+23 -4) 📝 `crates/ralph-core/src/event_loop/tests.rs` (+82 -8) 📝 `crates/ralph-core/src/lib.rs` (+1 -1) 📝 `crates/ralph-core/tests/event_loop_ralph.rs` (+5 -2) 📝 `crates/ralph-tui/src/widgets/header.rs` (+53 -4) </details> ### 📄 Description This was originally attempted to be fixed in #170, but was unsuccessful. Two bugs caused the TUI to show stale hat state: 1. process_events_from_jsonl returned has_orphans (bool), but the caller in loop_runner.rs treated it as had_events via matches!(Ok(true)). For non-orphan events (topic matches a hat trigger), has_orphans=false caused the caller to think no events were written and inject default_publishes, corrupting hat state. Fix: return a ProcessedEvents struct with separate had_events and has_orphans fields. 2. The TUI header always preferred the frozen IterationBuffer hat over the live pending_hat. After an iteration finishes (elapsed set) but before the next iteration starts, the stale frozen hat was displayed instead of the updated pending_hat. Fix: when iteration is finished and pending_hat is known, show pending_hat. Both regression tests fail on old code, pass on fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:37 +03:00
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#181
No description provided.