diff --git a/Cargo.toml b/Cargo.toml index dc885b2..b6d0701 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = ["crates/coa-core", "crates/coa-release", "crates/coa-registry-proto", "crates/coa-control-proto", "src-tauri"] exclude = ["services/coa-registry", "services/coa-registry-e2e", "services/coa-coordinator", "services/coa-relay"] - [workspace.package] version = "0.6.7" edition = "2021" diff --git a/changelog.d/20261010-headless-world-startup.md b/changelog.d/20261010-headless-world-startup.md new file mode 100644 index 0000000..4eb616c --- /dev/null +++ b/changelog.d/20261010-headless-world-startup.md @@ -0,0 +1,7 @@ +--- +area: manager +type: fixed +audience: admins +title: Background world servers no longer stop because the local console is closed +--- +The Manager automatically disables the local interactive console before starting the world server. Its remote console remains available, and no manual configuration changes are needed. diff --git a/changelog.d/20261010-settings-blank-window.md b/changelog.d/20261010-settings-blank-window.md new file mode 100644 index 0000000..870c869 --- /dev/null +++ b/changelog.d/20261010-settings-blank-window.md @@ -0,0 +1,7 @@ +--- +area: manager +type: fixed +audience: admins +title: Server and Bots settings open without a blank window +--- +Opening settings no longer crashes the interface after loading. Unsaved changes can still be saved or discarded before leaving the page. diff --git a/crates/coa-core/src/allsettings.rs b/crates/coa-core/src/allsettings.rs index b7c2afe..f9ab932 100644 --- a/crates/coa-core/src/allsettings.rs +++ b/crates/coa-core/src/allsettings.rs @@ -31,6 +31,7 @@ fn hidden(key: &str) -> bool { k.contains("password") || k.contains("databaseinfo") || k.ends_with("port") + || k == "console.enable" || k.starts_with("ra.") || k.starts_with("logger.") || k.starts_with("appender.") @@ -328,6 +329,8 @@ mod tests { "BindIP", "Ra.Enable", "Ra.Password", + "Console.Enable", + "console.enable", "Logger.root", "Appender.Console", "DataDir", diff --git a/crates/coa-core/src/driver.rs b/crates/coa-core/src/driver.rs index 40ab58c..12adce7 100644 --- a/crates/coa-core/src/driver.rs +++ b/crates/coa-core/src/driver.rs @@ -133,6 +133,7 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result Result Result Result<()> { + if !matches!(verb, Verb::StartAll | Verb::StartWorld) { return Ok(()); } + for relative in ["Settings/worldserver.conf.template", "Core/configs/worldserver.conf"] { + let path = root.join(relative); + let bytes = match std::fs::read(&path) { + Ok(bytes) => bytes, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => continue, + Err(e) => return Err(e.into()), + }; + let mut config = crate::config::parser::ConfFile::parse_bytes(&bytes)?; + config.set("Console.Enable", "0", &["Local console is disabled for background startup; the Manager uses remote access."]); + let text = config.to_text(); + if text.as_bytes() != bytes { + fsx::atomic_write(&path, text.as_bytes())?; + } + } + Ok(()) +} + /// The launcher keeps one JSON record per service in `.state`. A crash or power loss while it writes one can leave /// a file of the right length that holds only zero bytes (NTFS keeps the length but not the data), and the launcher /// then dies on every start with an unreadable record. Such a file carries no information, so remove it: the @@ -363,6 +386,55 @@ pub(crate) fn startup_failure(root: &Path, started: &DriverOutcome) -> String { mod tests { use super::*; + #[test] + fn background_start_disables_cli_in_template_and_rendered_config() { + let folder = tempfile::tempdir().unwrap(); + let root = folder.path(); + std::fs::create_dir_all(root.join("Settings")).unwrap(); + std::fs::create_dir_all(root.join("Core/configs")).unwrap(); + let template = root.join("Settings/worldserver.conf.template"); + let rendered = root.join("Core/configs/worldserver.conf"); + let original = "\u{feff}# Custom settings\r\nConsole.Enable = 1\r\nRa.Enable = 1\r\nPlayerLimit = 42\r\n"; + std::fs::write(&template, original).unwrap(); + std::fs::write(&rendered, original).unwrap(); + let auth = root.join("Core/configs/authserver.conf"); + std::fs::write(&auth, "custom auth config").unwrap(); + for verb in [Verb::StartMysql, Verb::StopAll] { + prepare_headless_world(root, verb).unwrap(); + assert_eq!(std::fs::read_to_string(&template).unwrap(), original); + assert_eq!(std::fs::read_to_string(&rendered).unwrap(), original); + } + for verb in [Verb::StartAll, Verb::StartWorld] { + std::fs::write(&template, original).unwrap(); + std::fs::write(&rendered, original).unwrap(); + prepare_headless_world(root, verb).unwrap(); + let expected = original.replace("Console.Enable = 1", "Console.Enable = 0"); + assert_eq!(std::fs::read_to_string(&template).unwrap(), expected); + assert_eq!(std::fs::read_to_string(&rendered).unwrap(), expected); + prepare_headless_world(root, verb).unwrap(); + assert_eq!(std::fs::read_to_string(&template).unwrap(), expected); + } + assert_eq!(std::fs::read_to_string(auth).unwrap(), "custom auth config"); + } + + #[test] + fn background_start_overrides_an_absent_or_duplicate_console_setting() { + let folder = tempfile::tempdir().unwrap(); + let root = folder.path(); + prepare_headless_world(root, Verb::StartAll).unwrap(); + std::fs::create_dir_all(root.join("Core/configs")).unwrap(); + let path = root.join("Core/configs/worldserver.conf"); + for original in ["Ra.Enable = 1\n", "Console.Enable = 0\nConsole.Enable = 1\n"] { + std::fs::write(&path, original).unwrap(); + prepare_headless_world(root, Verb::StartAll).unwrap(); + let bytes = std::fs::read(&path).unwrap(); + let config = crate::config::parser::ConfFile::parse_bytes(&bytes).unwrap(); + assert_eq!(config.get("Console.Enable"), Some("0")); + prepare_headless_world(root, Verb::StartAll).unwrap(); + assert_eq!(std::fs::read(&path).unwrap(), bytes); + } + } + #[test] fn large_squid_provisioning_has_time_to_finish_without_extending_shutdown() { let folder = tempfile::tempdir().unwrap(); diff --git a/package-lock.json b/package-lock.json index a8f15aa..0956d7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coa-server-manager", - "version": "0.6.10", + "version": "0.6.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coa-server-manager", - "version": "0.6.10", + "version": "0.6.12", "dependencies": { "@tauri-apps/api": "^2.12.0", "@tauri-apps/plugin-dialog": "^2.8.0", diff --git a/src/screens/SettingsPage.tsx b/src/screens/SettingsPage.tsx index ceb2172..76f6bc2 100644 --- a/src/screens/SettingsPage.tsx +++ b/src/screens/SettingsPage.tsx @@ -243,6 +243,24 @@ export function SettingsPage(props: { }); const pending = dirtyKeys.length + Object.keys(rawEdits).length + Object.keys(colEdits).length; + useEffect(() => { + if (pending > 0) { + props.onRegisterGuard?.({ + isDirty: () => pending > 0, + save: () => saveEverything(), + discard: () => { + setDraft({}); + setErrors({}); + setRawEdits({}); + setColEdits({}); + }, + }); + } else { + props.onRegisterGuard?.(null); + } + return () => props.onRegisterGuard?.(null); + }, [pending, props.onRegisterGuard]); + if (fatal) { return (
@@ -354,24 +372,6 @@ export function SettingsPage(props: { } } - useEffect(() => { - if (pending > 0) { - props.onRegisterGuard?.({ - isDirty: () => pending > 0, - save: () => saveEverything(), - discard: () => { - setDraft({}); - setErrors({}); - setRawEdits({}); - setColEdits({}); - }, - }); - } else { - props.onRegisterGuard?.(null); - } - return () => props.onRegisterGuard?.(null); - }, [pending, props.onRegisterGuard]); - async function openPreset(id: string) { setSaved(null); if (squid) {