Fix race condition between feature flag and deserialization (#37381)

Richard Feldman created

Right now if you open Zed, and we deserialize an agent that's behind a
feature flag (e.g. CC), we don't restore it because the feature flag
check hasn't happened yet at the time we're deserializing (due to auth
not having finished yet).

This is a simple fix: assume that if you had serialized it in the first
place, you must have had the feature flag enabled, so go ahead and
reopen it for you.

Release Notes:

- N/A

Change summary

crates/agent_ui/src/agent_panel.rs | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

Detailed changes

crates/agent_ui/src/agent_panel.rs 🔗

@@ -1911,13 +1911,17 @@ impl AgentPanel {
             AgentType::Gemini => {
                 self.external_thread(Some(crate::ExternalAgent::Gemini), None, None, window, cx)
             }
-            AgentType::ClaudeCode => self.external_thread(
-                Some(crate::ExternalAgent::ClaudeCode),
-                None,
-                None,
-                window,
-                cx,
-            ),
+            AgentType::ClaudeCode => {
+                self.selected_agent = AgentType::ClaudeCode;
+                self.serialize(cx);
+                self.external_thread(
+                    Some(crate::ExternalAgent::ClaudeCode),
+                    None,
+                    None,
+                    window,
+                    cx,
+                )
+            }
             AgentType::Custom { name, command } => self.external_thread(
                 Some(crate::ExternalAgent::Custom { name, command }),
                 None,