diff --git a/crates/core/src/protocol.rs b/crates/core/src/protocol.rs index b76eba99..0cca36f1 100644 --- a/crates/core/src/protocol.rs +++ b/crates/core/src/protocol.rs @@ -85,11 +85,6 @@ pub enum Command { client: McpClient, added: bool, }, - /// Turn a feature flag on or off for the launcher and every Craft app (`ArtCraft/flags.toml`). - SetFlag { - id: String, - on: bool, - }, } /// Parent folders for new installs. Existing installations keep their recorded location. @@ -314,21 +309,6 @@ pub enum Event { McpError { message: String, }, - /// The feature flags and whether each is on. Sent with the MCP state and after a change. - Flags { - flags: Vec, - }, -} - -/// One feature flag as Settings shows it. -#[derive(Clone, Debug, PartialEq)] -pub struct FlagState { - pub id: String, - pub title: String, - pub description: String, - pub on: bool, - /// `CRAFT_FLAGS` decides it for this run, so the switch has no effect until that is gone. - pub forced: bool, } /// An MCP client the launcher can add the gateway entry to. diff --git a/crates/native/src/agents.rs b/crates/native/src/agents.rs index 81c04ee2..750c360b 100644 --- a/crates/native/src/agents.rs +++ b/crates/native/src/agents.rs @@ -12,7 +12,7 @@ use std::path::{Path, PathBuf}; use std::sync::{Mutex, MutexGuard, PoisonError}; -use artcraft_launcher_core::protocol::{FlagState, McpAgents, McpClient, McpClientState}; +use artcraft_launcher_core::protocol::{McpAgents, McpClient, McpClientState}; use serde_json::{Map, Value, json}; use artcraft_launcher_core::CraftApp; @@ -115,7 +115,7 @@ pub fn client_paths(client: McpClient) -> Option<(PathBuf, PathBuf)> { let home = dirs::home_dir()?; Some(match client { McpClient::ClaudeDesktop => { - let dir = dirs::config_dir()?.join("Claude"); + let dir = claude_desktop_dir(dirs::config_dir()?, std::env::var_os("LOCALAPPDATA").map(PathBuf::from).as_deref()); (dir.join("claude_desktop_config.json"), dir) } McpClient::ClaudeCode => (home.join(".claude.json"), home.join(".claude")), @@ -124,6 +124,29 @@ pub fn client_paths(client: McpClient) -> Option<(PathBuf, PathBuf)> { }) } +/// Claude Desktop's settings folder: `/Claude`, unless only the Microsoft Store package is +/// installed. Windows redirects a packaged app's `%APPDATA%` into its package, so that install +/// reads `%LOCALAPPDATA%\Packages\Claude_\LocalCache\Roaming\Claude` and never sees +/// `%APPDATA%\Claude`. `local_appdata` is `None` outside Windows. +fn claude_desktop_dir(config: PathBuf, local_appdata: Option<&Path>) -> PathBuf { + let classic = config.join("Claude"); + if classic.is_dir() { + return classic; + } + let packaged = local_appdata.and_then(|local| { + let mut found: Vec = std::fs::read_dir(local.join("Packages")) + .ok()? + .flatten() + .filter(|e| e.file_name().to_string_lossy().starts_with("Claude_")) + .map(|e| e.path().join("LocalCache").join("Roaming").join("Claude")) + .filter(|d| d.is_dir()) + .collect(); + found.sort(); + found.into_iter().next() + }); + packaged.unwrap_or(classic) +} + /// A client's display name. pub fn client_name(client: McpClient) -> &'static str { match client { @@ -340,33 +363,7 @@ pub fn flag_on() -> bool { craft_flags::load().enabled(&craft_flags::AI_MCP) } -const NO_FLAG: &str = "turn on \"AI agents (MCP)\" under Experimental features first"; - -/// Every feature flag, for Settings. -pub fn flags_state() -> Vec { - let flags = craft_flags::load(); - craft_flags::ALL - .iter() - .map(|f| FlagState { - id: f.id.to_string(), - title: f.title.to_string(), - description: f.description.to_string(), - on: flags.enabled(f), - forced: flags.forced(f.id).is_some(), - }) - .collect() -} - -/// Turn a feature flag on or off for the launcher and every app. Turning `AI-MCP` off also turns -/// agents off, so no client keeps an entry for a feature that is switched off. -pub fn set_flag(id: &str, on: bool, services: &[InstalledApp]) -> Result<(), String> { - let path = craft_flags::default_path().ok_or("couldn't find the per-user configuration folder")?; - // Clean up first: if that fails, the flag stays on and Settings keeps the controls to retry. - if id == craft_flags::AI_MCP.id && !on { - set_enabled(false, services)?; - } - craft_flags::set(&path, id, on).map_err(|e| e.to_string()) -} +const NO_FLAG: &str = "the AI-MCP feature flag is off (ArtCraft/flags.toml or CRAFT_FLAGS)"; const NO_GATEWAY: &str = "the Craft gateway (craft-ai-mcp) is not installed beside the launcher"; diff --git a/crates/native/src/agents_tests.rs b/crates/native/src/agents_tests.rs index 3f43308f..25d16063 100644 --- a/crates/native/src/agents_tests.rs +++ b/crates/native/src/agents_tests.rs @@ -60,6 +60,20 @@ fn apps_get_their_extra_mcp_arguments_only_where_the_cli_takes_them() { } } +#[test] +fn claude_desktop_from_the_microsoft_store_is_found_in_its_package() { + let dir = tempfile::tempdir().unwrap(); + let (config, local) = (dir.path().join("Roaming"), dir.path().join("Local")); + assert_eq!(claude_desktop_dir(config.clone(), Some(&local)), config.join("Claude"), "nothing installed: the usual place"); + let packaged = local.join("Packages").join("Claude_pzs8sxrjxfjjc").join("LocalCache").join("Roaming").join("Claude"); + std::fs::create_dir_all(&packaged).unwrap(); + std::fs::create_dir_all(local.join("Packages").join("Other_123")).unwrap(); + assert_eq!(claude_desktop_dir(config.clone(), Some(&local)), packaged, "only the Store package"); + std::fs::create_dir_all(config.join("Claude")).unwrap(); + assert_eq!(claude_desktop_dir(config.clone(), Some(&local)), config.join("Claude"), "the classic install wins"); + assert_eq!(claude_desktop_dir(config.clone(), None), config.join("Claude")); +} + #[test] fn the_help_text_must_name_the_argument_as_a_word() { let help = "Usage: photocraft-cli mcp [OPTIONS] diff --git a/crates/native/src/backend.rs b/crates/native/src/backend.rs index 2f915080..05d9e93c 100644 --- a/crates/native/src/backend.rs +++ b/crates/native/src/backend.rs @@ -360,7 +360,6 @@ impl NativeBackend { // Local MCP state: which installed apps can be exposed + the unified bridge. { let _mcp = MCP_WORK.lock().unwrap_or_else(PoisonError::into_inner); - shared.emit(Event::Flags { flags: crate::agents::flags_state() }); shared.emit(mcp_state(&shared)); } drop(busy); @@ -1609,7 +1608,7 @@ impl Backend for NativeBackend { self.check(true); } } - cmd @ (Command::McpState | Command::McpSetAgents { .. } | Command::McpSetClient { .. } | Command::SetFlag { .. }) => { + cmd @ (Command::McpState | Command::McpSetAgents { .. } | Command::McpSetClient { .. }) => { // Detection can run package-manager queries for seconds (flatpak on Linux): // never on the UI thread that sends commands. let shared = self.shared.clone(); @@ -1671,13 +1670,11 @@ fn run_mcp(shared: &Shared, cmd: Command) { let result = match cmd { Command::McpSetAgents { enabled } => crate::agents::set_enabled(enabled, &apps), Command::McpSetClient { client, added } => crate::agents::set_client(client, added), - Command::SetFlag { id, on } => crate::agents::set_flag(&id, on, &apps), _ => Ok(()), }; if let Err(message) = result { shared.emit(Event::McpError { message }); } - shared.emit(Event::Flags { flags: crate::agents::flags_state() }); shared.emit(mcp_state_for(&apps)); } diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 874c2ef0..fac6996c 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -3,8 +3,7 @@ use std::time::Duration; use artcraft_launcher_core::protocol::{ - Backend, BackendOptions, CANCELLED, Capabilities, Command, Event, FlagState, INSTALL_CANCELLED, JobPhase, LatestRelease, McpAgents, PAUSED, - Source, + Backend, BackendOptions, CANCELLED, Capabilities, Command, Event, INSTALL_CANCELLED, JobPhase, LatestRelease, McpAgents, PAUSED, Source, }; use artcraft_launcher_core::release::Release; use artcraft_launcher_core::status::AppStatus; @@ -145,8 +144,6 @@ pub struct LauncherUi { pub(crate) entries: Vec, /// AI agents: the gateway switch and the MCP clients. pub(crate) mcp_agents: McpAgents, - /// The feature flags (Settings › Experimental features). - pub(crate) flags: Vec, /// Whether we've asked for MCP state since the settings dialog last opened (reset when it closes). pub(crate) mcp_requested: bool, pub(crate) caps: Capabilities, @@ -275,7 +272,6 @@ impl LauncherUi { .map(AppEntry::new) .collect(), mcp_agents: McpAgents::default(), - flags: Vec::new(), mcp_requested: false, caps, platform, @@ -658,10 +654,6 @@ impl LauncherUi { self.mcp_agents = agents; false } - Event::Flags { flags } => { - self.flags = flags; - false - } Event::McpError { message } => { // A failed MCP write (e.g. a full disk or an unreadable config) is surfaced so the // user knows their toggle did not take effect. diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 25ddd1b8..22398eab 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -426,6 +426,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Přidáno Remove Odebrat Add Přidat - Experimental features Experimentální funkce - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Funkce, které se teprve vyvíjejí. Každá je vypnutá, dokud ji zde nezapnete, pro spouštěč i všechny aplikace Craft. - Set by CRAFT_FLAGS for this run. Pro toto spuštění nastaveno proměnnou CRAFT_FLAGS. diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index b7e28efb..74ec0f2a 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -458,6 +458,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Hinzugefügt Remove Entfernen Add Hinzufügen - Experimental features Experimentelle Funktionen - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Funktionen, die noch entstehen. Jede ist aus, bis du sie hier einschaltest, für den Launcher und jede Craft-App. - Set by CRAFT_FLAGS for this run. Für diesen Start durch CRAFT_FLAGS festgelegt. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index b13e440e..4a9c2247 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -439,6 +439,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Añadida Remove Quitar Add Añadir - Experimental features Funciones experimentales - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Funciones que aún se están creando. Cada una está desactivada hasta que la actives aquí, para el lanzador y todas las apps Craft. - Set by CRAFT_FLAGS for this run. Fijado por CRAFT_FLAGS para esta ejecución. diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 741afc45..58e70ae1 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -456,6 +456,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Ajoutée Remove Retirer Add Ajouter - Experimental features Fonctions expérimentales - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Des fonctions encore en cours de création. Chacune reste désactivée jusqu'à ce que vous l'activiez ici, pour le lanceur et toutes les apps Craft. - Set by CRAFT_FLAGS for this run. Fixé par CRAFT_FLAGS pour ce lancement. diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 98030e8f..4e0a6bb7 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -459,6 +459,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Hozzáadva Remove Eltávolítás Add Hozzáadás - Experimental features Kísérleti funkciók - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Még fejlesztés alatt álló funkciók. Mindegyik ki van kapcsolva, amíg itt be nem kapcsolja, az indítóban és minden Craft alkalmazásban. - Set by CRAFT_FLAGS for this run. Ehhez a futtatáshoz a CRAFT_FLAGS állítja be. diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 527a325f..4f1d1014 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -461,6 +461,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added 追加済み Remove 削除 Add 追加 - Experimental features 試験的な機能 - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. 開発中の機能です。ここでオンにするまで、ランチャーとすべての Craft アプリでオフのままです。 - Set by CRAFT_FLAGS for this run. この起動では CRAFT_FLAGS で設定されています。 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index cad02f78..f93d9c31 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -457,6 +457,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added დამატებულია Remove წაშლა Add დამატება - Experimental features ექსპერიმენტული ფუნქციები - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. ფუნქციები, რომლებიც ჯერ კიდევ მზადდება. თითოეული გამორთულია, სანამ აქ არ ჩართავთ, გამშვებისა და ყველა Craft აპისთვის. - Set by CRAFT_FLAGS for this run. ამ გაშვებისთვის დაყენებულია CRAFT_FLAGS-ით. diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 81ed3b3e..543dce51 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -460,6 +460,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Dodano Remove Usuń Add Dodaj - Experimental features Funkcje eksperymentalne - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Funkcje, które wciąż powstają. Każda jest wyłączona, dopóki jej tu nie włączysz, dla launchera i każdej aplikacji Craft. - Set by CRAFT_FLAGS for this run. Ustawione przez CRAFT_FLAGS na to uruchomienie. diff --git a/crates/ui-egui/src/i18n/pt-BR.tsv b/crates/ui-egui/src/i18n/pt-BR.tsv index 4c40d652..4efd4701 100644 --- a/crates/ui-egui/src/i18n/pt-BR.tsv +++ b/crates/ui-egui/src/i18n/pt-BR.tsv @@ -446,6 +446,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Adicionado Remove Remover Add Adicionar - Experimental features Recursos experimentais - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Recursos ainda em construção. Cada um fica desativado até você ativá-lo aqui, para o inicializador e todos os apps Craft. - Set by CRAFT_FLAGS for this run. Definido por CRAFT_FLAGS nesta execução. diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index f05ed2c3..52649086 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -454,6 +454,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added Добавлено Remove Удалить Add Добавить - Experimental features Экспериментальные функции - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. Функции, которые ещё в разработке. Каждая выключена, пока вы не включите её здесь, для лаунчера и всех приложений Craft. - Set by CRAFT_FLAGS for this run. Задано через CRAFT_FLAGS для этого запуска. diff --git a/crates/ui-egui/src/i18n/zh-CN.tsv b/crates/ui-egui/src/i18n/zh-CN.tsv index 85d0251d..bf8143ef 100644 --- a/crates/ui-egui/src/i18n/zh-CN.tsv +++ b/crates/ui-egui/src/i18n/zh-CN.tsv @@ -426,6 +426,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added 已添加 Remove 移除 Add 添加 - Experimental features 实验性功能 - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. 仍在开发中的功能。在此处开启前,它们在启动器和所有 Craft 应用中均处于关闭状态。 - Set by CRAFT_FLAGS for this run. 本次运行由 CRAFT_FLAGS 设定。 diff --git a/crates/ui-egui/src/i18n/zh-TW.tsv b/crates/ui-egui/src/i18n/zh-TW.tsv index abbf4898..ca40eedc 100644 --- a/crates/ui-egui/src/i18n/zh-TW.tsv +++ b/crates/ui-egui/src/i18n/zh-TW.tsv @@ -417,6 +417,3 @@ anicraft Classic tweens with eight easing presets and custom ease curves, plus s Added 已加入 Remove 移除 Add 加入 - Experimental features 實驗性功能 - Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app. 仍在開發中的功能。在此處開啟前,它們在啟動器和所有 Craft 應用程式中均為關閉。 - Set by CRAFT_FLAGS for this run. 本次執行由 CRAFT_FLAGS 設定。 diff --git a/crates/ui-egui/src/settings_dialog.rs b/crates/ui-egui/src/settings_dialog.rs index 0bfe2134..1584b1af 100644 --- a/crates/ui-egui/src/settings_dialog.rs +++ b/crates/ui-egui/src/settings_dialog.rs @@ -117,7 +117,6 @@ impl LauncherUi { this.settings_language(ui); this.settings_updates(ui); this.settings_appearance(ui); - this.settings_flags(ui); this.settings_agents(ui); }, |ui| { @@ -376,7 +375,7 @@ impl LauncherUi { /// AI agents: one switch that lets MCP clients reach every installed Craft app through the /// `craft-ai-mcp` gateway, and one Add/Remove button per MCP client found on this machine. fn settings_agents(&mut self, ui: &mut Ui) { - // Behind the `AI-MCP` feature flag (Experimental features). + // Behind the `AI-MCP` feature flag, set in `ArtCraft/flags.toml` or `CRAFT_FLAGS` only. if !self.caps.manage_apps || !self.mcp_agents.flag_on { return; } @@ -407,31 +406,6 @@ impl LauncherUi { }); } - /// Experimental features: a switch per feature flag, shared with every Craft app. - fn settings_flags(&mut self, ui: &mut Ui) { - if !self.caps.manage_apps || self.flags.is_empty() { - return; - } - let t = Tokens::get(ui.ctx()); - let flags = self.flags.clone(); - sheet::panel(ui, tl!("Experimental features"), |ui| { - note(ui, tl!("Features that are still being built. Each is off until you turn it on here, for the launcher and every Craft app.")); - ui.add_space(8.0); - for f in &flags { - let mut on = f.on; - let toggle = ui.add_enabled(!f.forced, egui::Checkbox::new(&mut on, f.title.as_str())); - if toggle.changed() && on != f.on { - self.act_command(Command::SetFlag { id: f.id.clone(), on }); - } - ui.label(RichText::new(f.description.as_str()).size(12.0).color(t.muted)); - if f.forced { - ui.label(RichText::new(tl!("Set by CRAFT_FLAGS for this run.")).size(12.0).color(t.muted)); - } - ui.add_space(6.0); - } - }); - } - /// One MCP client: its name, and Add or Remove (or "Not installed" when it isn't). Add is /// offered only while the gateway is there to add. fn draw_client_row(&mut self, ui: &mut Ui, t: &Tokens, c: &McpClientState, can_add: bool) { diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 696dc1f1..9755a049 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -4499,27 +4499,18 @@ fn ai_agents_left_on_without_the_gateway_can_still_be_turned_off() { assert!(sent.iter().any(|c| matches!(c, Command::McpSetAgents { enabled: false }))); } -/// With the `AI-MCP` flag off, Settings shows nothing about agents, only the flag to turn on. +/// With the `AI-MCP` flag off, Settings shows nothing about agents, and nothing to switch flags: +/// they are set in `ArtCraft/flags.toml` or `CRAFT_FLAGS` only. #[test] fn ai_agents_stay_hidden_until_their_flag_is_on() { - use artcraft_launcher_core::protocol::{FlagState, McpAgents}; - let flag = |id: &str, title: &str, on, forced| FlagState { id: id.into(), title: title.into(), description: "d".into(), on, forced }; + use artcraft_launcher_core::protocol::McpAgents; let mut evs = events(); - evs.push(Event::Flags { flags: vec![flag("AI-MCP", "AI agents (MCP)", false, false), flag("AI-MODELS", "AI models and services", false, true)] }); evs.push(Event::Mcp { agents: McpAgents { flag_on: false, gateway_found: true, enabled: true, apps: 3, clients: vec![] } }); - let (mut h, sent) = harness_with(evs, ViewMode::Grid, egui::Theme::Dark, true, 1.0); + let (mut h, _sent) = harness_with(evs, ViewMode::Grid, egui::Theme::Dark, true, 1.0); h.run_steps(6); h.get_by_label("Settings").click(); h.run_steps(4); assert!(h.query_by_label("Let AI agents use Craft apps").is_none(), "no agents box without the flag"); - h.get_by_label("AI agents (MCP)").scroll_to_me(); - h.run_steps(6); - h.get_by_label("Set by CRAFT_FLAGS for this run."); - h.get_by_label("AI agents (MCP)").click(); - h.run_steps(3); - h.get_by_label("AI models and services").click(); - h.run_steps(3); - let sent = sent.borrow(); - assert!(sent.iter().any(|c| matches!(c, Command::SetFlag { id, on: true } if id == "AI-MCP"))); - assert!(!sent.iter().any(|c| matches!(c, Command::SetFlag { id, .. } if id == "AI-MODELS")), "a flag CRAFT_FLAGS sets can't be switched"); + assert!(h.query_by_label("Experimental features").is_none(), "flags have no switches in Settings"); + assert!(h.query_by_label("AI agents (MCP)").is_none()); }