Wait for agent2 feature flag before loading panel (#36583)

Antonio Scandurra created

Release Notes:

- N/A

Change summary

crates/agent_ui/src/agent_panel.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)

Detailed changes

crates/agent_ui/src/agent_panel.rs 🔗

@@ -523,6 +523,7 @@ impl AgentPanel {
             anyhow::Ok(())
         }));
     }
+
     pub fn load(
         workspace: WeakEntity<Workspace>,
         prompt_builder: Arc<PromptBuilder>,
@@ -572,6 +573,17 @@ impl AgentPanel {
                 None
             };
 
+            // Wait for the Gemini/Native feature flag to be available.
+            let client = workspace.read_with(cx, |workspace, _| workspace.client().clone())?;
+            if !client.status().borrow().is_signed_out() {
+                cx.update(|_, cx| {
+                    cx.wait_for_flag_or_timeout::<feature_flags::GeminiAndNativeFeatureFlag>(
+                        Duration::from_secs(2),
+                    )
+                })?
+                .await;
+            }
+
             let panel = workspace.update_in(cx, |workspace, window, cx| {
                 let panel = cx.new(|cx| {
                     Self::new(