agent_ui: Fix agent panel stealing focus from modals on workspace restore#49630
agent_ui: Fix agent panel stealing focus from modals on workspace restore#49630Dnreikronos wants to merge 5 commits intozed-industries:mainfrom
Conversation
MotivationIssue #49336 reported a focus-stealing regression on macOS. When a user had no active This was a regression of a previously fixed behavior (originally fixed in #43451 / Root cause: During workspace restoration, What the PR ChangesThe fix is surgical and contained entirely in
Impact
|
|
I'm looking for that erros on the tests now |
…tore When opening a modal (e.g. "Open Recent" via cmd-alt-o) with no active window, the AgentPanel async thread restoration would call set_active_view with focus: true, stealing keyboard focus from the modal. This is a regression of zed-industries#43180, where the focus guard was lost during subsequent refactoring. Thread a focus parameter through external_thread and _external_thread so that AgentPanel::load() passes false during startup restoration, while all user-initiated actions continue to pass true. Closes zed-industries#49336
3ea988d to
0b54d93
Compare
|
Hi, @SomeoneToIgnore, good morning! I adjusted all the errors that was happening on the CI pipeline. If you could take a look and analyze everything, I will appreciate it |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
The fix does not seem to work for me, when I try this?
Here's the video of what I do: start Zed off the current commit, then close the window with cmd-shift-w, then invoke the cmd-alt-o as requested in the issue.
I have failed to get anything useful out of this state, the focus is not on the modal:
broken_still.mov
Hmmm, that's strange! |
The previous fix only addressed the 'load' path (restoring a saved thread), but missed the 'set_active' path where dock restoration activates the panel and creates a new thread with focus: true.
|
Could you test again, @SomeoneToIgnore, please? I'm testing this on Arch Linux, so the flow is slightly different. I open the built binary with |
That box has to be in focus:
So you have to be abble to type there |
|
Now I cannot build it at all... |
The branch merged main which included commit f900340 that removed hardcoded Gemini variants from the AgentType and ExternalAgent enums (replacing them with the generic Custom { name } @SomeoneToIgnore, thanks for the patience. |
|
I've tested it another time with the same result — given the steps in #49336 , we do have to test the fix on macOS (or other OS with a patch that enables a similar behavior which does not quit the app after last window is closed). The steps from #49630 (comment) are not from mac, ergo do not capture the issue good enough. I think we can close the PR meanwhile, given the circumstances, but let me know if you're up to another try before. |
I'll give it another try. |
|
Last chance now, @SomeoneToIgnore. |
|
That's a huge breakthrough and things start to work! Yet, the next logical thing is to go test all agent interactions that were just altered: and there, it seems that we now can get into state where agent panel is not focused despite being just shown with My sequence of actions to reproduce this:
Expected: can type into an agent. Notice that consequent agent_focus_broken.movOverall, I feel 0 interest to do constant, repeated, work to test after each submission, this is counter-productive, so I'll close the PR after all. If you feel like fixing and testing things thoroughly more later, I can review and re-test again on another PR opened. |
Thanks for your time invested, @SomeoneToIgnore. |

When opening a modal (e.g. "Open Recent" via cmd-alt-o) with no active
window, the AgentPanel async thread restoration would call
set_active_view with focus: true, stealing keyboard focus from the
modal. This is a regression of #43180, where the focus guard was lost
during subsequent refactoring.
Thread a focus parameter through external_thread and _external_thread
so that AgentPanel::load() passes false during startup restoration,
while all user-initiated actions continue to pass true.
Closes #49336
Release Notes: