Fix native agent thread history notify refresh (#47733)

Joseph T. Lyons created

Release Notes:

- N/A

Change summary

crates/agent/src/agent.rs | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

Detailed changes

crates/agent/src/agent.rs 🔗

@@ -1399,6 +1399,7 @@ impl acp_thread::AgentTelemetry for NativeAgentConnection {
 
 pub struct NativeAgentSessionList {
     thread_store: Entity<ThreadStore>,
+    updates_tx: smol::channel::Sender<acp_thread::SessionListUpdate>,
     updates_rx: smol::channel::Receiver<acp_thread::SessionListUpdate>,
     _subscription: Subscription,
 }
@@ -1406,11 +1407,15 @@ pub struct NativeAgentSessionList {
 impl NativeAgentSessionList {
     fn new(thread_store: Entity<ThreadStore>, cx: &mut App) -> Self {
         let (tx, rx) = smol::channel::unbounded();
+        let this_tx = tx.clone();
         let subscription = cx.observe(&thread_store, move |_, _| {
-            tx.try_send(acp_thread::SessionListUpdate::Refresh).ok();
+            this_tx
+                .try_send(acp_thread::SessionListUpdate::Refresh)
+                .ok();
         });
         Self {
             thread_store,
+            updates_tx: tx,
             updates_rx: rx,
             _subscription: subscription,
         }
@@ -1467,6 +1472,12 @@ impl AgentSessionList for NativeAgentSessionList {
         Some(self.updates_rx.clone())
     }
 
+    fn notify_refresh(&self) {
+        self.updates_tx
+            .try_send(acp_thread::SessionListUpdate::Refresh)
+            .ok();
+    }
+
     fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
         self
     }