Fix agent panel unexpectedly closing in zoom mode during scrolling #33737
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.
Closes #33430
Release Notes:
When the AI panel is zoomed and the user scrolls through content, the panel would unexpectedly close after a short delay. This was particularly disruptive during active AI conversations when users needed to scroll through responses.
Root Cause Analysis
Through debugging with logging, i discovered that the issue occurred due to overly aggressive zoom dismissal logic:
workspace.rs
was dismissing ALL zoomed panels whenever:The specific issue was that
dismiss_zoomed_items_to_reveal()
was being called unconditionally in these scenarios, which would hide any zoomed panel regardless of whether the user intended to change the zoom state.What we couldn't figure out
I tried to track down why the AI panel loses focus during scrolling but couldn't nail down the exact cause. The focus seems to jump to a center pane during scroll operations. I initially thought it might be related to lazy loading or virtual list updates - specifically that the virtual list might become empty during updates and the center panel would get focus "through" it, but debugging showed this wasn't the case. The only clue I found was that during this focus loss, the arena allocator in gpui tried to allocate more memory, suggesting some kind of component reconstruction or reallocation might be happening during scroll operations. This fix basically works around this focus issue instead of addressing the root cause.
Solution
Since I couldn't prevent the focus loss during scrolling, I modified the zoom handling logic in
workspace.rs
to be more conservative and user-intent focused:1. Center pane focus handling
2. Dock reveal handling
dismiss_zoomed_items_to_reveal()
Implementation Details
The key insight was to distinguish between intentional zoom changes (user explicitly zooming a panel) and incidental focus changes (temporary focus shifts during scrolling/updates). The fix ensures zoomed panels remain stable unless the user explicitly:
While this doesn't solve the underlying focus loss issue, it prevents that focus loss from having user-visible consequences.
Testing
The fix was verified by: