From fa6a5afb0bfc1da748a978a6a868ef426904bcaa Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 16 Mar 2026 15:08:52 -0700 Subject: [PATCH] make clippy script pass --- crates/agent_ui/src/agent_panel.rs | 23 +++++++++++++++------ crates/zed/src/visual_test_runner.rs | 30 ++++++++++++++-------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 09a8750ff92c42bf599b06f1b751442e99f746cf..9bf2c4cbe869eb1a052825b09196f65880b98882 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -4998,6 +4998,15 @@ impl AgentPanel { pub fn close_start_thread_in_menu_for_tests(&mut self, cx: &mut Context) { self.start_thread_in_menu_handle.hide(cx); } + + /// Sets the panel width. + /// + /// This is a test-only helper for visual tests that need to control the + /// panel width without going through the `Panel` trait (which `AgentPanel` + /// no longer implements). + pub fn set_width_for_tests(&mut self, width: Option) { + self.width = width; + } } #[cfg(test)] @@ -5981,6 +5990,8 @@ mod tests { ); } + const CODEX_NAME: &str = "codex-acp"; + #[gpui::test] async fn test_worktree_creation_preserves_selected_agent(cx: &mut TestAppContext) { init_test(cx); @@ -6036,7 +6047,7 @@ mod tests { let panel = cx.new(|cx| { AgentPanel::new(workspace, text_thread_store, None, window, cx) }); - workspace.add_panel(panel, window, cx); + workspace.set_left_drawer(panel, cx); } }, ) @@ -6052,7 +6063,7 @@ mod tests { let text_thread_store = cx.new(|cx| TextThreadStore::fake(project.clone(), cx)); let panel = cx.new(|cx| AgentPanel::new(workspace, text_thread_store, None, window, cx)); - workspace.add_panel(panel.clone(), window, cx); + workspace.set_left_drawer(panel.clone(), cx); panel }); @@ -6074,7 +6085,7 @@ mod tests { // open_external_thread_with_server overrides selected_agent_type. panel.update(cx, |panel, cx| { panel.selected_agent_type = AgentType::Custom { - name: CODEX_NAME.into(), + id: CODEX_NAME.into(), }; panel.set_start_thread_in(&StartThreadIn::NewWorktree, cx); }); @@ -6084,7 +6095,7 @@ mod tests { assert_eq!( panel.selected_agent_type, AgentType::Custom { - name: CODEX_NAME.into() + id: CODEX_NAME.into() }, ); }); @@ -6119,7 +6130,7 @@ mod tests { .expect("should find the new workspace"); let new_panel = new_workspace .read(cx) - .panel::(cx) + .drawer::() .expect("new workspace should have an AgentPanel"); new_panel.read(cx).selected_agent_type.clone() @@ -6129,7 +6140,7 @@ mod tests { assert_eq!( found_codex, AgentType::Custom { - name: CODEX_NAME.into() + id: CODEX_NAME.into() }, "the new worktree workspace should use the same agent (Codex) that was selected in the original panel", ); diff --git a/crates/zed/src/visual_test_runner.rs b/crates/zed/src/visual_test_runner.rs index 197a7c6003737c486bc6adfb7190a1f23dbcf94b..5633ae41a5b553394cbecf7263d02848d6d68b72 100644 --- a/crates/zed/src/visual_test_runner.rs +++ b/crates/zed/src/visual_test_runner.rs @@ -119,7 +119,7 @@ use { time::Duration, }, util::ResultExt as _, - workspace::{AppState, MultiWorkspace, Panel as _, Workspace}, + workspace::{AppState, MultiWorkspace, Workspace}, zed_actions::OpenSettingsAt, }; @@ -2147,9 +2147,9 @@ fn run_agent_thread_view_test( cx.update_window(workspace_window.into(), |_, _window, cx| { workspace_window - .update(cx, |workspace, window, cx| { - workspace.add_panel(panel.clone(), window, cx); - workspace.open_panel::(window, cx); + .update(cx, |workspace, _window, cx| { + workspace.set_left_drawer(panel.clone(), cx); + workspace.open_drawer::(cx); }) .log_err(); })?; @@ -3268,8 +3268,8 @@ edition = "2021" // Register an observer so that workspaces created by the worktree creation // flow get AgentPanel and ProjectPanel loaded automatically. Without this, - // `workspace.panel::(cx)` returns None in the new workspace and - // the creation flow's `focus_panel::` call is a no-op. + // `workspace.drawer::()` returns None in the new workspace and + // the creation flow's drawer focus call is a no-op. let _workspace_observer = cx.update({ let prompt_builder = prompt_builder.clone(); |cx| { @@ -3287,10 +3287,10 @@ edition = "2021" }) .log_err(); } - if let Ok(panel) = agent_panel.await { + if let Ok(drawer) = agent_panel.await { workspace_handle - .update_in(cx, |workspace, window, cx| { - workspace.add_panel(panel, window, cx); + .update_in(cx, |workspace, _window, cx| { + workspace.set_left_drawer(drawer, cx); }) .log_err(); } @@ -3313,11 +3313,11 @@ edition = "2021" cx.background_executor.forbid_parking(); workspace_window - .update(cx, |multi_workspace, window, cx| { + .update(cx, |multi_workspace, _window, cx| { let workspace = &multi_workspace.workspaces()[0]; workspace.update(cx, |workspace, cx| { - workspace.add_panel(panel.clone(), window, cx); - workspace.open_panel::(window, cx); + workspace.set_left_drawer(panel.clone(), cx); + workspace.open_drawer::(cx); }); }) .context("Failed to add and open AgentPanel")?; @@ -3512,9 +3512,9 @@ edition = "2021" workspace_window.update(cx, |multi_workspace, window, cx| { let new_workspace = &multi_workspace.workspaces()[1]; new_workspace.update(cx, |workspace, cx| { - if let Some(new_panel) = workspace.panel::(cx) { + if let Some(new_panel) = workspace.drawer::() { new_panel.update(cx, |panel, cx| { - panel.set_size(Some(px(480.0)), window, cx); + panel.set_width_for_tests(Some(px(480.0))); panel.open_external_thread_with_server(stub_agent.clone(), window, cx); }); } @@ -3525,7 +3525,7 @@ edition = "2021" // Type and send a message so the thread target dropdown disappears. let new_panel = workspace_window.update(cx, |multi_workspace, _window, cx| { let new_workspace = &multi_workspace.workspaces()[1]; - new_workspace.read(cx).panel::(cx) + new_workspace.read(cx).drawer::() })?; if let Some(new_panel) = new_panel { let new_thread_view = cx.read(|cx| new_panel.read(cx).active_thread_view(cx));