Skip to content

Commit

Permalink
assistant2: Persist model selector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdeviant committed Dec 16, 2024
1 parent 1932c04 commit c1cfc03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 10 additions & 2 deletions crates/assistant2/src/assistant_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl AssistantPanel {
Self {
active_view: ActiveView::Thread,
workspace: workspace.clone(),
fs,
fs: fs.clone(),
language_registry: language_registry.clone(),
thread_store: thread_store.clone(),
thread: cx.new_view(|cx| {
Expand All @@ -103,7 +103,13 @@ impl AssistantPanel {
)
}),
message_editor: cx.new_view(|cx| {
MessageEditor::new(workspace, thread_store.downgrade(), thread.clone(), cx)
MessageEditor::new(
fs.clone(),
workspace,
thread_store.downgrade(),
thread.clone(),
cx,
)
}),
tools,
local_timezone: UtcOffset::from_whole_seconds(
Expand Down Expand Up @@ -141,6 +147,7 @@ impl AssistantPanel {
});
self.message_editor = cx.new_view(|cx| {
MessageEditor::new(
self.fs.clone(),
self.workspace.clone(),
self.thread_store.downgrade(),
thread,
Expand Down Expand Up @@ -170,6 +177,7 @@ impl AssistantPanel {
});
self.message_editor = cx.new_view(|cx| {
MessageEditor::new(
self.fs.clone(),
self.workspace.clone(),
self.thread_store.downgrade(),
thread,
Expand Down
16 changes: 13 additions & 3 deletions crates/assistant2/src/message_editor.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use std::sync::Arc;

use editor::{Editor, EditorElement, EditorStyle};
use fs::Fs;
use gpui::{AppContext, FocusableView, Model, TextStyle, View, WeakModel, WeakView};
use language_model::{LanguageModelRegistry, LanguageModelRequestTool};
use language_model_selector::{LanguageModelSelector, LanguageModelSelectorPopoverMenu};
use settings::Settings;
use settings::{update_settings_file, Settings};
use theme::ThemeSettings;
use ui::{prelude::*, ButtonLike, CheckboxWithLabel, ElevationIndex, KeyBinding, Tooltip};
use workspace::Workspace;

use crate::assistant_settings::AssistantSettings;
use crate::context_store::ContextStore;
use crate::context_strip::ContextStrip;
use crate::thread::{RequestKind, Thread};
Expand All @@ -24,6 +28,7 @@ pub struct MessageEditor {

impl MessageEditor {
pub fn new(
fs: Arc<dyn Fs>,
workspace: WeakView<Workspace>,
thread_store: WeakModel<ThreadStore>,
thread: Model<Thread>,
Expand All @@ -50,9 +55,14 @@ impl MessageEditor {
)
}),
language_model_selector: cx.new_view(|cx| {
let fs = fs.clone();
LanguageModelSelector::new(
|model, _cx| {
println!("Selected {:?}", model.name());
move |model, cx| {
update_settings_file::<AssistantSettings>(
fs.clone(),
cx,
move |settings, _cx| settings.set_model(model.clone()),
);
},
cx,
)
Expand Down

0 comments on commit c1cfc03

Please sign in to comment.