fix(runtime): unfreeze TUI after /compact and resume; observability sweep#190
Merged
Conversation
…weep Two root causes behind a frozen UI cluster (ESC dead, /compact stuck on "Streaming", resumed "continue" never consumed): - Bug A: view-state compact mutator usurped backend-authoritative status by flipping it to Running without restoring it. Status is now backend-only; the compact_banner alone conveys compacting. - Bug D (keystone): resume/cold-start with a User-tail history skipped the idle phase, so no turn record was opened and every append_step hit NoCurrentTurn. ensure_resume_turn_record() now opens the record before the turn runs, letting the loop return to idle and drain queued input (Bug C). - Bug B: post_compact now emits a reliable TokenUsage so the ctx counter refreshes; conversation_display defensively syncs tokens from Compacted. Observability: default log level -> debug; telemetry build_env_filter switches to global-default + third-party blacklist (was a whitelist that dropped tui/session/hub/view-state); empty-LLM-response warn; status-transition and user-message-routing debug anchors. Regression coverage (e2e): resume_then_followup_message_runs_second_turn, resume_user_tail_records_turn_with_llm_step, compact_token_sync, and compact_idle_e2e reproduce the exact frozen-UI event sequences.
The followup Envelope was pre-sent before run(), landing inside the resume turn's mid-turn inject_pending_messages drain window. Whether it was absorbed into turn 1 or ran as turn 2 depended on scheduling — flaky (failed ~70% on macOS CI, passed locally only when bundled in the full suite). Gate delivery on the agent's own AwaitingInput event: send "continue" only after the resume turn completes and the loop returns to idle, then close both mailbox + control senders on the second idle to end the Persistent loop. The helper now returns control_tx (5-tuple); existing tests drop both senders up front to keep their closed-channel break behavior. Deterministic 15/15.
4 tasks
yishuiliunian
added a commit
that referenced
this pull request
Jun 3, 2026
…191) * fix(tui): show "Compacting" status during compaction instead of Idle #190 made AgentStatus backend-only and declared compact_banner the sole signal for compacting, but the unified status line never consumed it. Manual /compact runs as a control command in the idle phase, so status stays WaitingForInput and the decision tree fell through to Idle with a frozen spinner — covering auto-compaction and resume-rehydrate too. Extract the status-label decision into a pure pick_label() and add a Compacting tier (after Thinking, before Streaming). Feed it compact_banner.is_some(), and add the same flag to is_agent_active so the spinner animates for the whole compaction rather than freezing after the 750ms activity grace. Presentation-layer only: no AgentStatus mutation, no protocol change, so it does not reintroduce the #189/#190 turn-lifecycle desync risk. * fix: address CI failure - rustfmt struct-update layout in tests rustfmt expands single-line `ActivityInputs { field: x, ..base() }` to multi-line; apply the canonical formatting.
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.
Summary
/compactstuck on "Streaming" with stalectx:, and post-resumecontinuenever consumed.Changes
loopal-runtime/agent_loop:ensure_resume_turn_recordopens a turn record before User-tail resume runs (turn_record.rs); recovery split intoturn_recover.rs;post_compactemits reliableTokenUsage; empty-response warn inllm_record.rs; status-transition debug.loopal-view-state: compact mutator no longer writes status;conversation_displaysyncs tokens fromCompacted.loopal-telemetry: newbuild_env_filter(global-default + third-party blacklist).loopal-tui: user-message routing debug log.src/logging.rs: default level → debug via shared filter builder.resume_then_followup_message_runs_second_turn,resume_user_tail_records_turn_with_llm_step,compact_token_sync_test,compact_idle_e2e_test, extended compact-banner mutator tests.Test plan
bazel test //...— 94/94 passbazel build //... --config=clippy— zero warningsbazel build //... --config=rustfmt— pass