agent: Refresh UI when sending first message (#28180)
Release Notes: - Agent Beta: Fixed a delay when sending the first message in a new thread
This commit is contained in:
parent
ac9e2f30bb
commit
b1f7133a7b
2 changed files with 21 additions and 5 deletions
|
@ -170,6 +170,7 @@ pub struct AssistantPanel {
|
||||||
language_registry: Arc<LanguageRegistry>,
|
language_registry: Arc<LanguageRegistry>,
|
||||||
thread_store: Entity<ThreadStore>,
|
thread_store: Entity<ThreadStore>,
|
||||||
thread: Entity<ActiveThread>,
|
thread: Entity<ActiveThread>,
|
||||||
|
_thread_subscription: Subscription,
|
||||||
message_editor: Entity<MessageEditor>,
|
message_editor: Entity<MessageEditor>,
|
||||||
context_store: Entity<assistant_context_editor::ContextStore>,
|
context_store: Entity<assistant_context_editor::ContextStore>,
|
||||||
context_editor: Option<Entity<ContextEditor>>,
|
context_editor: Option<Entity<ContextEditor>>,
|
||||||
|
@ -253,6 +254,12 @@ impl AssistantPanel {
|
||||||
cx.new(|cx| HistoryStore::new(thread_store.clone(), context_store.clone(), cx));
|
cx.new(|cx| HistoryStore::new(thread_store.clone(), context_store.clone(), cx));
|
||||||
|
|
||||||
let active_view = ActiveView::thread(thread.clone(), window, cx);
|
let active_view = ActiveView::thread(thread.clone(), window, cx);
|
||||||
|
let thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {
|
||||||
|
if let ThreadEvent::MessageAdded(_) = &event {
|
||||||
|
// needed to leave empty state
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
});
|
||||||
let thread = cx.new(|cx| {
|
let thread = cx.new(|cx| {
|
||||||
ActiveThread::new(
|
ActiveThread::new(
|
||||||
thread.clone(),
|
thread.clone(),
|
||||||
|
@ -273,6 +280,7 @@ impl AssistantPanel {
|
||||||
language_registry,
|
language_registry,
|
||||||
thread_store: thread_store.clone(),
|
thread_store: thread_store.clone(),
|
||||||
thread,
|
thread,
|
||||||
|
_thread_subscription: thread_subscription,
|
||||||
message_editor,
|
message_editor,
|
||||||
context_store,
|
context_store,
|
||||||
context_editor: None,
|
context_editor: None,
|
||||||
|
@ -367,6 +375,14 @@ impl AssistantPanel {
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self._thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {
|
||||||
|
if let ThreadEvent::MessageAdded(_) = &event {
|
||||||
|
// needed to leave empty state
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
self.message_editor = cx.new(|cx| {
|
self.message_editor = cx.new(|cx| {
|
||||||
MessageEditor::new(
|
MessageEditor::new(
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
|
|
|
@ -240,14 +240,14 @@ impl MessageEditor {
|
||||||
cx.emit(ThreadEvent::ShowError(load_error));
|
cx.emit(ThreadEvent::ShowError(load_error));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.log_err();
|
||||||
|
|
||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
let context = context_store.read(cx).context().clone();
|
let context = context_store.read(cx).context().clone();
|
||||||
thread.insert_user_message(user_message, context, checkpoint, cx);
|
thread.insert_user_message(user_message, context, checkpoint, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.log_err();
|
||||||
|
|
||||||
if let Some(wait_for_summaries) = context_store
|
if let Some(wait_for_summaries) = context_store
|
||||||
.update(cx, |context_store, cx| context_store.wait_for_summaries(cx))
|
.update(cx, |context_store, cx| context_store.wait_for_summaries(cx))
|
||||||
|
@ -257,7 +257,7 @@ impl MessageEditor {
|
||||||
this.waiting_for_summaries_to_send = true;
|
this.waiting_for_summaries_to_send = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
.ok();
|
.log_err();
|
||||||
|
|
||||||
wait_for_summaries.await;
|
wait_for_summaries.await;
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ impl MessageEditor {
|
||||||
this.waiting_for_summaries_to_send = false;
|
this.waiting_for_summaries_to_send = false;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
.ok();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send to model after summaries are done
|
// Send to model after summaries are done
|
||||||
|
@ -273,7 +273,7 @@ impl MessageEditor {
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
thread.send_to_model(model, request_kind, cx);
|
thread.send_to_model(model, request_kind, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.log_err();
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue