Add /pause command to toggle the runtime loop#2605
Open
dgageot wants to merge 2 commits intodocker:mainfrom
Open
Add /pause command to toggle the runtime loop#2605dgageot wants to merge 2 commits intodocker:mainfrom
dgageot wants to merge 2 commits intodocker:mainfrom
Conversation
Adds a /pause slash command that pauses the agent loop at iteration boundaries — i.e. as soon as the in-flight LLM request and its tool calls complete. Running /pause again resumes the loop. The pause is implemented in LocalRuntime as a single channel that is open while paused and closed on resume; runStreamLoop calls waitIfPaused at the top of each iteration. Assisted-By: docker-agent
App.TogglePause now returns (paused, supported) so the TUI can show a clear "Pause is not supported with remote runtimes" message instead of the misleading "Runtime resumed" toast that the silent fallback used to produce. Adds pause_test.go covering the toggle cycle, the not-paused fast path, block-until-resumed, ctx cancellation while paused, broadcast to multiple waiters, and a -race stress run with concurrent togglers and waiters. Assisted-By: docker-agent
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The pause/resume implementation is clean and correct. The channel-based broadcast design (close channel to wake all waiters in O(1)) is idiomatic Go. The mutex correctly guards the channel pointer without holding it during the blocking select, avoiding potential deadlocks. Context cancellation is properly handled. Test coverage is thorough, including race detection.
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.
What
Adds a
/pauseslash command that pauses the agent runtime loop at iteration boundaries — i.e. as soon as the in-flight LLM request and any tool calls for the current turn complete. Running/pauseagain resumes the loop.How
pkg/runtime/pause.go(new):LocalRuntime.TogglePause()andwaitIfPaused(ctx). The pause state is a single channel that is open while paused and closed on resume; closing broadcasts the wake-up to every blocked caller in O(1).pkg/runtime/loop.go:runStreamLoopcallsr.waitIfPaused(ctx)at the top of its iteration loop. Respects context cancellation (returnsctx.Err()if cancelled while paused).pkg/app/app.go:App.TogglePause()returns(paused, supported bool); the second return isfalsefor runtimes that don't expose the method (e.g. remote runtimes), letting the TUI render an explicit "not supported" message.TogglePauseMsg,/pausecommand in the palette, andhandleTogglePauseshowing a notification on each toggle ("Runtime paused — /pause again to resume" / "Runtime resumed" / "Pause is not supported with remote runtimes").Tests
pkg/runtime/pause_test.gocovers:-raceAll pass under
go test -race -count=5 -run Pause ./pkg/runtime/. Fullmise lintandmise testare green.Assisted-By: docker-agent