fix: ACP improvements - single-line retry, variable name, and cancel optimization #2864
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
This PR includes several ACP-related fixes and improvements:
cancel_sessioninstead of stopping ACP clientProblems Fixed
1. Single-line retry/edit broken
When a user message is a single line,
get_current_user_request_block()returns empty content because line 755 unconditionally removes the last element:For single-line messages, this results in an empty table.
ACP client stop not working
cancel_inflight_request() calls get_registered_acp_clients() which returns M._acp_clients, but register_acp_client() stores clients in M.acp_clients. This mismatch causes the stop function to never find any clients.
Full client stop causes reconnection delay
Previously, cancellation would stop the entire ACP client process, requiring a new connection for subsequent requests.
UI stuck in "generating" state after cancel
After cancelling, the sidebar state was not properly reset.
Solution
Only slice content_lines when there are multiple lines
Use acp_clients consistently (not _acp_clients)
Use cancel_session() to cancel the current session while keeping the connection alive
Reset current_state, scroll, and clear state extmarks after cancellation
Testing
Send a single-line message → retry/edit now works
Cancel during generation → UI properly resets
Send new message after cancel → responds without reconnection delay