This commit is contained in:
@@ -124,37 +124,6 @@ impl MainEditor {
|
||||
}
|
||||
|
||||
pub fn render_ui(&mut self, project: &mut ProjectSettings, ui: &mut egui::Ui) {
|
||||
if let Some(dialog) = &mut self.dialog {
|
||||
dialog.ui(ui, project);
|
||||
|
||||
match dialog {
|
||||
ContentAI::Summarise { ready, result, .. } => {
|
||||
if *ready.lock().unwrap() == ReadyState::Ready {
|
||||
self.content.content.push_str(&result.lock().unwrap());
|
||||
self.content.saved = false;
|
||||
*ready.lock().unwrap() = ReadyState::Idle;
|
||||
} else if *ready.lock().unwrap() == ReadyState::Halted {
|
||||
*ready.lock().unwrap() = ReadyState::Idle;
|
||||
}
|
||||
}
|
||||
ContentAI::Continue {
|
||||
ready,
|
||||
result,
|
||||
content,
|
||||
..
|
||||
} => {
|
||||
*content = self.content.content.clone();
|
||||
if *ready.lock().unwrap() == ReadyState::Ready {
|
||||
self.content.content.push_str(&result.lock().unwrap());
|
||||
self.content.saved = false;
|
||||
*ready.lock().unwrap() = ReadyState::Idle;
|
||||
} else if *ready.lock().unwrap() == ReadyState::Halted {
|
||||
*ready.lock().unwrap() = ReadyState::Idle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui.vertical(|ui| {
|
||||
// check for Ctrl+S to save
|
||||
if ui.input(|i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl) {
|
||||
@@ -253,6 +222,21 @@ impl MainEditor {
|
||||
|
||||
ui.separator();
|
||||
|
||||
if let Some(dialog) = &mut self.dialog {
|
||||
dialog.ui(ui, project);
|
||||
|
||||
dialog.content = self.content.content.clone();
|
||||
if *dialog.ready.lock().unwrap() == ReadyState::Ready {
|
||||
self.content
|
||||
.content
|
||||
.push_str(&dialog.result.lock().unwrap());
|
||||
self.content.saved = false;
|
||||
*dialog.ready.lock().unwrap() = ReadyState::Idle;
|
||||
} else if *dialog.ready.lock().unwrap() == ReadyState::Halted {
|
||||
*dialog.ready.lock().unwrap() = ReadyState::Idle;
|
||||
}
|
||||
}
|
||||
|
||||
if self.show_preview {
|
||||
self.preview_ui(ui);
|
||||
}
|
||||
@@ -356,17 +340,8 @@ impl MainEditor {
|
||||
|
||||
ui.menu_button("AI Actions", |ui| {
|
||||
ui.add_enabled_ui(project.ai_enabled(), |ui| {
|
||||
if ui.button("Summarise").clicked() {
|
||||
self.dialog = Some(ContentAI::Summarise {
|
||||
result: Arc::new(Mutex::new(String::new())),
|
||||
content: self.content.content.clone(),
|
||||
open: true,
|
||||
ready: Arc::new(Mutex::new(ReadyState::Idle)),
|
||||
});
|
||||
}
|
||||
|
||||
if ui.button("Continue").clicked() {
|
||||
self.dialog = Some(ContentAI::Continue {
|
||||
if ui.button("AI Assistant").clicked() {
|
||||
self.dialog = Some(ContentAI {
|
||||
content: self.content.content.clone(),
|
||||
instruction: String::new(),
|
||||
max_tokens: 1024,
|
||||
|
||||
Reference in New Issue
Block a user