assistant: Do not create new context on load (#29480)
Closes https://github.com/zed-industries/zed/issues/27673 Closes https://github.com/zed-industries/zed/issues/29344 Closes #29863 This PR fixes an issue where Zed was showing no language and `4:1` as a line/column value on startup, as described in the linked issues. You can actually see in the first issue that the user also experiences the same issue as described in the second one, as his line/column value is noticably also `4:1`. https://github.com/user-attachments/assets/bb60e387-f4b8-4e05-80b3-4dadf1a01262 This issue arises because on assistant panel load, a new context is created and its editor focused. However, the editor is not visible despite having focus. The content for the editor for a new context is `\n\n\n` and the cursor is inserted directly after that - this is where the line:column position `4:1` comes from. For the assistant panel editor, the language is intentionally hidden, this is why the language is not shown on workspace load. The issue is only present for as long as the user does not focus and edit another editor, then that instance is focused and everything starts to work properly again. As this issue only arises with the old assistant panel, some staff members were unable to reproduce in the linked issues. Once you set `export ZED_DISABLE_STAFF=1` in your environment, you should also be able to reproduce this issue consistently. --- This PR fixes the issue by not creating a new context on assistant panel load. This should not cause any regressions; every other code path I checked creates a new context if no context is yet present. Additionally, this also seems somewhat more reasonable, as users which have the assistant panel disabled will never need a new context anyway, so no context should be created. In the following video, you can see this fixes the issue when the assistant panel was not open the last time Zed was opened. If the panel was open before Zed was closed, we will still properly focus the panel and then the `4:1` will show again, which in that case is correct. The assistant panel editor is focused and the missing language as well as the line number then match what the user sees, experiences and expects. https://github.com/user-attachments/assets/224a786b-52c7-4212-bccb-dff6d9db62c3 Release Notes: - Fixed an issue where Zed would show no language and an incorrect line/column value on startup. Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
parent
ef31252ef8
commit
06794f35bc
1 changed files with 2 additions and 4 deletions
|
@ -320,7 +320,7 @@ impl AssistantPanel {
|
|||
|
||||
let watch_client_status = Self::watch_client_status(workspace.client().clone(), window, cx);
|
||||
|
||||
let mut this = Self {
|
||||
Self {
|
||||
pane,
|
||||
workspace: workspace.weak_handle(),
|
||||
width: None,
|
||||
|
@ -336,9 +336,7 @@ impl AssistantPanel {
|
|||
client_status: None,
|
||||
watch_client_status: Some(watch_client_status),
|
||||
show_zed_ai_notice: false,
|
||||
};
|
||||
this.new_context(window, cx);
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_focus(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue