chore: refactorings for more code reorganizing
This commit is contained in:
42
src/app.rs
42
src/app.rs
@@ -24,7 +24,7 @@ use crate::engine::ChatTurn;
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::metrics::WorkSource;
|
||||
use crate::metrics::{KvCacheReport, Metrics, MetricsSnapshot};
|
||||
use crate::model::{self, DownloadOutcome, DownloadProgress, ManagedArtifactId, ModelChoice};
|
||||
use crate::model::{DownloadOutcome, DownloadProgress, ManagedArtifactId, ModelChoice};
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::runtime::{
|
||||
ActiveGeneration, CheckpointTarget, CompactionInput, GenerationEvent, GenerationService,
|
||||
@@ -950,6 +950,10 @@ impl App {
|
||||
Ok(message) => message,
|
||||
Err(task) => return task,
|
||||
};
|
||||
let message = match self.update_model_manager_message(message) {
|
||||
Ok(message) => message,
|
||||
Err(task) => return task,
|
||||
};
|
||||
match message {
|
||||
Message::Noop => {
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -973,7 +977,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
Message::ScrollPreferences(section) => return scroll_preferences_to(section),
|
||||
Message::OpenModelManager => return self.open_model_manager(),
|
||||
Message::OpenHelp => return self.open_help(),
|
||||
Message::HelpOpened(id) => {
|
||||
if self.help_window == Some(id) {
|
||||
@@ -1012,11 +1015,6 @@ impl App {
|
||||
self.error = Some(format!("Could not export the chat: {error}"));
|
||||
}
|
||||
}
|
||||
Message::ModelManagerOpened(id) => {
|
||||
if self.model_manager_window == Some(id) {
|
||||
return window::gain_focus(id);
|
||||
}
|
||||
}
|
||||
Message::WindowOpened(id) => {
|
||||
if id == self.main_window {
|
||||
self.refresh_git_state();
|
||||
@@ -1144,34 +1142,6 @@ impl App {
|
||||
self.sync_native_menu();
|
||||
}
|
||||
Message::MetricsTick => self.sample_metrics(),
|
||||
Message::DownloadArtifact(artifact) => {
|
||||
self.start_model_operation(artifact, ModelOperation::Download)
|
||||
}
|
||||
Message::ValidateArtifact(artifact) => {
|
||||
self.start_model_operation(artifact, ModelOperation::Validate)
|
||||
}
|
||||
Message::DeleteArtifact(artifact) => self.pending_model_delete = Some(artifact),
|
||||
Message::ConfirmDeleteArtifact => {
|
||||
if let Some(artifact) = self.pending_model_delete.take() {
|
||||
match model::delete_managed_artifact(artifact, &models_path()) {
|
||||
Ok(()) => {
|
||||
self.model_download = ModelDownload::Idle;
|
||||
self.error = None;
|
||||
}
|
||||
Err(error) => {
|
||||
self.error = Some(format!("Could not delete {artifact}: {error}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::CancelDeleteArtifact => self.pending_model_delete = None,
|
||||
Message::StopModelDownload => {
|
||||
if let ModelDownload::Active(download) = &mut self.model_download {
|
||||
download.stopping = true;
|
||||
download.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
Message::DownloadProgressTick => self.update_download_progress(),
|
||||
Message::ComposerAction(action) => self.composer.perform(action),
|
||||
Message::TranscriptAction(index, action) => {
|
||||
if !action.is_edit()
|
||||
@@ -1833,7 +1803,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!("preference messages are dispatched before the main update"),
|
||||
_ => unreachable!("domain messages are dispatched before the main update"),
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user