assistant2: Stream in completion text (#21182)

This PR makes it so that the completion text streams into the message
list rather than being buffered until the end.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-11-25 16:13:27 -05:00 committed by GitHub
parent 91a565f5fa
commit 9ee1aba80a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 75 additions and 51 deletions

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use gpui::{
prelude::*, px, Action, AppContext, AsyncWindowContext, EventEmitter, FocusHandle,
FocusableView, Model, Pixels, Task, View, ViewContext, WeakView, WindowContext,
FocusableView, Model, Pixels, Subscription, Task, View, ViewContext, WeakView, WindowContext,
};
use language_model::LanguageModelRegistry;
use language_model_selector::LanguageModelSelector;
@ -28,6 +28,7 @@ pub struct AssistantPanel {
pane: View<Pane>,
thread: Model<Thread>,
message_editor: View<MessageEditor>,
_subscriptions: Vec<Subscription>,
}
impl AssistantPanel {
@ -59,11 +60,13 @@ impl AssistantPanel {
});
let thread = cx.new_model(Thread::new);
let subscriptions = vec![cx.observe(&thread, |_, _, cx| cx.notify())];
Self {
pane,
thread: thread.clone(),
message_editor: cx.new_view(|cx| MessageEditor::new(thread, cx)),
_subscriptions: subscriptions,
}
}
}