Skip to content

Fix agent panel unexpectedly closing in zoom mode during scrolling #33737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ribelo
Copy link

@ribelo ribelo commented Jul 1, 2025

Closes #33430

Release Notes:

  • Fixed agent panel unexpectedly closing in zoom mode during scrolling

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:

  1. When scrolling causes content updates in the AI panel, focus temporarily shifts between components
  2. The workspace's focus handling code in workspace.rs was dismissing ALL zoomed panels whenever:
    • Center pane gained focus
    • A dock was revealed for any reason

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

  • Before: When any center pane gained focus, it would dismiss all zoomed panels unconditionally
  • After: Only dismiss other zoomed panels when the focused pane is itself zoomed, preserving zoomed dock state when focusing a non-zoomed center pane. I have no idea if this is possible, but defensive strategy sounds reasonable.

2. Dock reveal handling

  • Before: Revealing any dock would dismiss all zoomed panels via dismiss_zoomed_items_to_reveal()
  • After: Simply revealing a dock no longer affects zoom state - removed the dismiss call entirely

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:

  • Toggles zoom on another panel
  • Unzooms the current panel
  • Closes the zoomed panel

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:

  1. Zooming the AI panel
  2. Scrolling through content to trigger lazy loading and focus changes
  3. Confirming the panel remains zoomed and visible
  4. Verifying that explicitly zooming another panel still correctly dismisses the previously zoomed panel

…industries#33430)

Modified zoom handling logic in workspace.rs to be more conservative:
- Only dismiss zoomed panels when the focused pane is itself zoomed
- Remove zoom dismissal when revealing docks

This prevents the AI panel from closing during scroll operations when
focus temporarily shifts between components.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jul 1, 2025
@maxdeviant maxdeviant changed the title Fix AI panel unexpectedly closing in zoom mode during scrolling (#33430) Fix AI panel unexpectedly closing in zoom mode during scrolling Jul 1, 2025
@maxdeviant maxdeviant changed the title Fix AI panel unexpectedly closing in zoom mode during scrolling Fix agent panel unexpectedly closing in zoom mode during scrolling Jul 1, 2025
@SomeoneToIgnore SomeoneToIgnore added the ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI: The AI chat panel closed unexpectedly in Zoom mode
2 participants