agent: Make token indicator not flash if last count tokens request failed (#29628)

Michael Sloan created

Release Notes:

- N/A

Change summary

crates/agent/src/message_editor.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

Detailed changes

crates/agent/src/message_editor.rs 🔗

@@ -1138,14 +1138,14 @@ impl MessageEditor {
                 Some(0)
             };
 
-            if let Some(token_count) = token_count {
-                this.update(cx, |this, cx| {
+            this.update(cx, |this, cx| {
+                if let Some(token_count) = token_count {
                     this.last_estimated_token_count = Some(token_count);
                     cx.emit(MessageEditorEvent::EstimatedTokenCount);
-                    this.update_token_count_task.take();
-                })
-                .ok();
-            }
+                }
+                this.update_token_count_task.take();
+            })
+            .ok();
         }));
     }
 }