first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+29 -41
View File
@@ -4,18 +4,16 @@ use galaxy_core::user_preferences::GetUserPreferences as _;
use galaxyui::SingletonEntity;
use galaxyui_extras::user_preferences;
use instant::Duration;
use settings::{
is_settings_file_enabled, set_settings_file_enabled, PrivatePreferences, PublicPreferences,
Setting, SettingsManager,
};
use settings::{PrivatePreferences, PublicPreferences, Setting, SettingsManager};
use settings_value::SettingsValue;
use crate::terminal::session_settings::{NotificationsMode, NotificationsSettings};
use galaxy_core::settings::macros::define_settings_group;
use galaxy_core::settings::{SupportedPlatforms, SyncToCloud};
use super::{
migrate_native_settings_to_settings_file, needs_settings_file_migration,
migrate_native_settings_to_settings_file, needs_settings_file_migration_for_path,
SETTINGS_FILE_MIGRATION_COMPLETE_KEY,
};
use crate::terminal::session_settings::{NotificationsMode, NotificationsSettings};
// A minimal settings group with one public and one private setting, used to
// verify that migration only copies public settings.
@@ -58,33 +56,12 @@ fn init_test_app(ctx: &mut galaxyui::AppContext) {
MigrationTestSettings::register(ctx);
}
struct SettingsFileEnabledGuard(bool);
impl SettingsFileEnabledGuard {
fn new(enabled: bool) -> Self {
let previous = is_settings_file_enabled();
set_settings_file_enabled(enabled);
Self(previous)
}
}
impl Drop for SettingsFileEnabledGuard {
fn drop(&mut self) {
set_settings_file_enabled(self.0);
}
}
// Only tests that toggle the process-global SettingsFile routing flag need to
// run serially.
#[test]
#[serial_test::serial]
fn test_migration_copies_public_settings_from_native_store() {
galaxyui::App::test((), |mut app| async move {
// Enable the settings file so `preferences_for_setting` routes
// public setting writes to the Model singleton (not the private store).
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let _settings_file_enabled = SettingsFileEnabledGuard::new(true);
app.update(init_test_app);
@@ -172,11 +149,9 @@ fn test_migration_writes_marker_to_native_store() {
}
#[test]
#[serial_test::serial]
fn test_migration_skips_settings_absent_from_native_store() {
galaxyui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let _settings_file_enabled = SettingsFileEnabledGuard::new(true);
app.update(init_test_app);
// Don't seed anything in the native store — all settings are absent.
@@ -247,6 +222,8 @@ fn test_migration_handles_string_setting() {
fn test_migration_does_not_rerun_when_marker_present() {
galaxyui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let temp_dir = tempfile::tempdir().unwrap();
let settings_file_path = temp_dir.path().join("settings.toml");
app.update(init_test_app);
@@ -261,7 +238,7 @@ fn test_migration_does_not_rerun_when_marker_present() {
// Before migration, the guard should allow migration.
app.read(|ctx| {
assert!(
needs_settings_file_migration(ctx),
needs_settings_file_migration_for_path(ctx, &settings_file_path),
"migration should be needed before first run"
);
});
@@ -274,7 +251,7 @@ fn test_migration_does_not_rerun_when_marker_present() {
// After migration, the marker should prevent re-migration.
app.read(|ctx| {
assert!(
!needs_settings_file_migration(ctx),
!needs_settings_file_migration_for_path(ctx, &settings_file_path),
"migration should not be needed after marker is written"
);
});
@@ -282,11 +259,28 @@ fn test_migration_does_not_rerun_when_marker_present() {
}
#[test]
#[serial_test::serial]
fn test_migration_not_needed_when_settings_file_exists() {
warpui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let temp_dir = tempfile::tempdir().unwrap();
let settings_file_path = temp_dir.path().join("settings.toml");
std::fs::write(&settings_file_path, "").unwrap();
app.update(init_test_app);
app.read(|ctx| {
assert!(
!needs_settings_file_migration_for_path(ctx, &settings_file_path),
"migration should not be needed when settings.toml exists"
);
});
});
}
#[test]
fn test_migration_with_multiple_setting_types() {
galaxyui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let _settings_file_enabled = SettingsFileEnabledGuard::new(true);
app.update(init_test_app);
@@ -379,8 +373,6 @@ fn test_migration_with_multiple_setting_types() {
// serde fallback is never reached and values are lost.
mod notifications_migration {
use galaxy_core::settings::{macros::define_settings_group, SupportedPlatforms, SyncToCloud};
use galaxyui_extras::user_preferences;
use settings::{PrivatePreferences, PublicPreferences, SettingsManager};
use crate::terminal::session_settings::NotificationsSettings;
@@ -422,7 +414,7 @@ use notifications_migration::{
fn test_notifications_from_file_value_rejects_serde_format_enum() {
// serde serializes NotificationsMode::Enabled as "Enabled" (PascalCase),
// but from_file_value expects "enabled" (snake_case). When the field is
// present but unparseable, from_file_value should return None — not
// present but unparsable, from_file_value should return None — not
// silently fall back to the #[serde(default)] value (Unset).
let serde_json_value = serde_json::to_value(NotificationsSettings {
mode: NotificationsMode::Enabled,
@@ -462,11 +454,9 @@ fn test_notifications_from_file_value_rejects_serde_format_duration() {
// -- Migration integration tests: these demonstrate end-to-end data loss -----
#[test]
#[serial_test::serial]
fn test_migration_preserves_notifications_mode() {
galaxyui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let _settings_file_enabled = SettingsFileEnabledGuard::new(true);
app.update(init_notifications_migration_test_app);
@@ -501,11 +491,9 @@ fn test_migration_preserves_notifications_mode() {
}
#[test]
#[serial_test::serial]
fn test_migration_preserves_custom_long_running_threshold() {
galaxyui::App::test((), |mut app| async move {
let _guard = FeatureFlag::SettingsFile.override_enabled(true);
let _settings_file_enabled = SettingsFileEnabledGuard::new(true);
app.update(init_notifications_migration_test_app);