cancel in-progress stuff when cmd-k a conversation#12555
Conversation
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
MaggieShan
left a comment
There was a problem hiding this comment.
Had a few questions:
- Was testing this and can confirm the case for triggering
cmd-kwhile the agent is still generating the command is fixed, but I can still get into a weird state if Icmd-kafter the command is running https://www.loom.com/share/0377da7646b046f09530a6b91591108a - Is there a way we can add tests to prevent this from regressing?
- Product-wise: I wonder if it'd be a clearer to users if we require a double confirmation before starting a new conversation with
cmd-k(similarly to what's done forcmd-enterwhen already in a conversation) - for users used tocmd-ksimply clearing the buffer, it may not be as clear that this would also start a new conversation

d32f65a to
22e978e
Compare
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds a Cmd+K cancellation path for the active agent conversation, prevents requested shell commands from executing after another conversation becomes active, and adds regression coverage for agent-driving command states.
Concerns
- The Cmd+K cancellation path only runs for conversations whose status is
InProgress. Requested commands that are waiting for user confirmation transition the conversation toBlockedwhile still leaving the pending action live, so clearing into a new conversation can leave the old command/action uncancelled instead of satisfying the PR's intended invariant. - This changes user-facing Cmd+K/agent-view behavior, but the PR description only includes textual testing. For this user-facing change, please include screenshots or a screen recording demonstrating it working end to end.
Verdict
Found: 0 critical, 2 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| .agent_view_state() | ||
| .active_conversation_id() | ||
| { | ||
| let is_in_progress = BlocklistAIHistoryModel::as_ref(ctx) |
There was a problem hiding this comment.
Blocked for user confirmation. A requested command can be queued, fail auto-execution, set the conversation to Blocked, and then Cmd+K will start a new conversation without calling cancel_conversation_progress, leaving the old action live instead of canceling the work being left. Cancel unconditionally for the active conversation or also cover blocked/unfinished-action states.
There was a problem hiding this comment.
Actually that case behaves just fine. "blocked" is a fine state. Users can go back to that conversation and approve if they want.
Fixed! Needed to check for an additional state. I made sure this case matches the behavior when the command is running and the agent is monitoring it, i.e. it clears the running command's grid.
Added some unit tests, needed to add some new mocks for this.
Ah that's a good Q. My intuition would be not to require double confirmation. We do require it for cmd-enter and ctrl-c which I think makes sense. ctrl-c does a lot of other stuff, e.g. exiting a long-running command, exiting insert mode in Vim keybindings, clearing the input editor, etc. If we didn't require a double-press, it would be super easy to accidentally exit your conversation with ctrl-c. cmd-k is different b/c it isn't as overloaded with other functions. Also, cmd-k is already a pretty destructive action in a normal terminal + shell setup, e.g. in iTerm it deletes the whole screen+scrollback. If users are pressing cmd-k I think we have more confidence in their intent, and the way we handle it in the agent view, starting a new convo (or clearing the grid for the active running command), maps pretty cleanly to the idea of clearing in a normal terminal. That said, I don't think it's critical to make that change in this PR. I think this change is strictly better than the existing functionality. I'm very open to adding that if people find this too destructive. What do you think? |
That's a good point on user intent with |
MaggieShan
left a comment
There was a problem hiding this comment.
Thanks for iterating - approving to unblock!
| .block_list() | ||
| .active_block() | ||
| .is_agent_monitoring(); | ||
| let is_agent_driving_command = self |
There was a problem hiding this comment.
nit: can we combine the access to the model and active lock so that we're not acquiring it multiple times?
There was a problem hiding this comment.
borrow checker made it a tad awk but done!
Description
See here: https://warpdev.slack.com/archives/C08KTPNQN65/p1780700091713279?thread_ts=1780640536.267589&cid=C08KTPNQN65
The bug happens with the following scenario:
sleep 10. Let's call this conversation "A".sleep 10actually runs, press cmd-k to clear. This starts a new conversation, conversation "B".sleep 10runs in "B".sleep 10completes, the block goes back to "A".The
sleep 10command should never appear in "B" since it was requested from "A".This PR has a 2-layer approach to the fix. Either is sufficient for this bug, but implementing both is prudent for robustness.
Linked Issue
(partly) fixes #12483
Testing
On this branch, the same repro steps will cancel conversation "A" as soon as cmd-k is pressed.