Repository navigation
fix(tui): keep the TUI responsive while supervised turns and actions run - #655
Merged
Merged
Conversation
Supervised UI actions awaited command completion while an actor held its session lock for an entire turn, so choosing a model, stopping a turn, or cancelling a background task could freeze input and rendering; Stop itself became unreachable. - Queue supervisor commands without awaiting execution: SupervisorHandle::submit returns the completion receiver, the TUI applies CommandFollowUp results on the application tick, and every former send_session_command caller is migrated with success, rollback, and quit semantics preserved. - Mirror each live background task's cancellation token and subagent approval sender into an Arc-shared BackgroundControl kept in sync by BackgroundTaskRegistry. SessionActor holds a clone, so CancelBackgroundTask and ResolveBackgroundApproval reach a busy actor and publish immediately only when the session lock is free. - Make the final stream drain observe cancellation instead of waiting on a channel a sender-retaining provider never closes. - Walk the explorer's loaded directories on a blocking worker with generation and coalescing tracking; expand/collapse invalidate an in-flight snapshot so a stale result cannot overwrite it. - AGENTS.md: targeted tests only, never the full workspace suite. Regression tests cover the gated supervised turn, lock-free background signalling, the leaky stream sender, and async explorer refresh. Validated: forge-core 272, forge-session 71, forge-tui targeted modules, fmt, clippy -D warnings, and release build.
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.
Problem
Supervised UI actions awaited supervisor command completion while an actor held its session lock for a whole turn. Choosing a model, stopping a turn, or cancelling a background task could freeze input and rendering until the turn ended — Stop itself became unreachable from that UI.
Changes
SupervisorHandle::submitqueues a command and returns its completion receiver. The TUI submits viasubmit_session_command/submit_session_command_trackedand appliesCommandFollowUpresults on the application tick. All formersend_session_commandcallers migrated; success, rollback, and quit semantics stay truthful.forge_core::BackgroundControlmirrors each live task's cancellation token and subagent approval sender into anArc-shared map kept in sync byBackgroundTaskRegistry(spawn, token replace, terminal, remove).SessionActorholds a clone, soCancelBackgroundTask/ResolveBackgroundApprovalreach a busy actor and publish immediately only when the session lock is free.run_model_step_with_streamobserves cancellation instead of waiting on a channel a sender-retaining provider never closes.FileExplorerwalks loaded directories on aspawn_blockingworker with generation and coalescing tracking, installing only while still current. Expand/collapse invalidate an in-flight snapshot so a stale result cannot overwrite it.AGENTS.md— targeted tests only, never the full workspace suite.Tests
tracked_command_applies_after_a_busy_turn_without_blocking_input— gated supervised turn keeps input live and applies the queued model change later (forge-tui).control_signals_cancel_and_hitl_without_a_session(forge-core) and extendedunrelated_session_commands_progress_while_another_turn_holds_its_actor, which now asserts both controls answer while a gated turn still holds its actor (forge-session).final_drain_observes_turn_cancel_when_provider_retains_sender(forge-core).Validation
app::tests::tasks6,app::tests::multi_task28,app::tests::commands66,file_explorer::37,watch::12,responsiveness_tests5cargo fmt --all -- --check,cargo clippy --workspace --all-targets --locked -- -D warningscleancargo build --release --locked --package forge-cli+forge --versionOK