WIP dismiss agent panel onboarding panel when typing

Anthony created

Change summary

crates/agent_ui/src/agent_panel.rs    | 12 ++++++++++++
crates/agent_ui/src/message_editor.rs |  3 +++
2 files changed, 15 insertions(+)

Detailed changes

crates/agent_ui/src/agent_panel.rs 🔗

@@ -300,6 +300,7 @@ impl ActiveView {
                 MessageEditorEvent::Changed | MessageEditorEvent::EstimatedTokenCount => {
                     cx.notify();
                 }
+                MessageEditorEvent::DismissOnboarding => {}
                 MessageEditorEvent::ScrollThreadToBottom => match &this.active_view {
                     ActiveView::Thread { thread, .. } => {
                         thread.update(cx, |thread, cx| {
@@ -670,6 +671,17 @@ impl AgentPanel {
             )
         });
 
+        cx.subscribe(&message_editor, |_, _, event, cx| match event {
+            // todo!: I don't like how this is writing to the db everything time the user types
+            //this also doens't work for text threads and newly openned threads??
+            MessageEditorEvent::DismissOnboarding => {
+                OnboardingUpsell::set_dismissed(true, cx);
+                cx.notify();
+            }
+            _ => {}
+        })
+        .detach();
+
         let acp_history_store = cx.new(|cx| agent2::HistoryStore::new(context_store.clone(), cx));
         let acp_history = cx.new(|cx| AcpThreadHistory::new(acp_history_store.clone(), window, cx));
         cx.subscribe_in(

crates/agent_ui/src/message_editor.rs 🔗

@@ -217,6 +217,7 @@ impl MessageEditor {
             cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event),
             cx.subscribe(&editor, |this, _, event: &EditorEvent, cx| {
                 if event == &EditorEvent::BufferEdited {
+                    cx.emit(MessageEditorEvent::DismissOnboarding);
                     this.handle_message_changed(cx)
                 }
             }),
@@ -1416,6 +1417,7 @@ impl MessageEditor {
     }
 
     fn message_or_context_changed(&mut self, debounce: bool, cx: &mut Context<Self>) {
+        // todo! Might want to use this instead of dismiss onboarding event
         cx.emit(MessageEditorEvent::Changed);
         self.update_token_count_task.take();
 
@@ -1639,6 +1641,7 @@ pub enum MessageEditorEvent {
     EstimatedTokenCount,
     Changed,
     ScrollThreadToBottom,
+    DismissOnboarding,
 }
 
 impl Focusable for MessageEditor {