From 8d9800afef722f0540a179719792c2407fca66ba Mon Sep 17 00:00:00 2001 From: elpidioassinaturas Date: Sun, 29 Nov 2026 20:22:08 -0300 Subject: [PATCH 1/2] fix(assistant): the web app doesn't list Ollama Cloud ollama.com refuses the browser's CORS preflight, so the preset could only fail there. works_in_browser names the providers a web page can reach (no sign-in, no Ollama Cloud) and the settings list uses it. Co-Authored-By: Claude Opus 5.5 --- crates/assistant/src/provider.rs | 6 ++++++ crates/assistant/src/tests.rs | 8 ++++++++ crates/ui-egui/src/assistantpane.rs | 5 +++-- docs/user-guide/assistant.md | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/assistant/src/provider.rs b/crates/assistant/src/provider.rs index 0817553e40..194ded83ef 100644 --- a/crates/assistant/src/provider.rs +++ b/crates/assistant/src/provider.rs @@ -356,6 +356,12 @@ pub fn first_keyed(config: impl Fn(&str) -> Config) -> Option<&'static str> { PRESETS.iter().find(|p| !p.login && p.id != "ollama-cloud" && !config(p.id).key.is_empty()).map(|p| p.id) } +/// Whether the web app can use the provider: a sign-in needs a server on this computer, and +/// ollama.com refuses requests from web pages (its CORS preflight). +pub fn works_in_browser(p: &Preset) -> bool { + !p.login && p.id != "ollama-cloud" +} + /// The provider a command-line run uses: the explicit choice, then the environment's choice, then /// the first provider with an environment key, then (only when `saved` has the desktop's /// preferences) the one the desktop app uses, else `ollama`. Environment credentials win over the diff --git a/crates/assistant/src/tests.rs b/crates/assistant/src/tests.rs index e3ad187523..ea43083db8 100644 --- a/crates/assistant/src/tests.rs +++ b/crates/assistant/src/tests.rs @@ -5626,6 +5626,14 @@ fn ollama_cloud_sends_chat_and_model_requests_to_ollama_com_with_a_bearer_key() assert_eq!(parse_models(Api::OpenAi, &listed.unwrap()), Ok(vec!["gemma4:31b".to_string(), "gpt-oss:120b".to_string()])); } +#[test] +fn the_web_app_offers_only_providers_a_web_page_can_reach() { + // ollama.com refuses the browser's CORS preflight, and a ChatGPT sign-in needs the desktop. + let offered: Vec<&str> = PRESETS.iter().filter(|p| works_in_browser(p)).map(|p| p.id).collect(); + assert!(!offered.contains(&"ollama-cloud") && !offered.contains(&"chatgpt"), "{offered:?}"); + assert!(["anthropic", "openai", "gemini", "openrouter", "ollama", "custom", "mistral"].iter().all(|id| offered.contains(id))); +} + #[test] fn ollama_cloud_runs_a_tool_call_and_answers() { let mut s = sample(); diff --git a/crates/ui-egui/src/assistantpane.rs b/crates/ui-egui/src/assistantpane.rs index 020f426f93..abdb9ce558 100644 --- a/crates/ui-egui/src/assistantpane.rs +++ b/crates/ui-egui/src/assistantpane.rs @@ -143,8 +143,9 @@ fn provider_settings(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, cfg: &mut Co .width(180.0) .show_ui(ui, |ui| { for p in PRESETS { - // Signing in needs the browser and a server on this computer: the desktop app. - if p.login && cfg!(target_arch = "wasm32") { + // Signing in needs the browser and a server on this computer, and ollama.com + // refuses web pages: the desktop app. + if cfg!(target_arch = "wasm32") && !provider::works_in_browser(p) { continue; } if ui.selectable_label(cfg.provider == p.id, tl!(p.label)).clicked() && cfg.provider != p.id { diff --git a/docs/user-guide/assistant.md b/docs/user-guide/assistant.md index 2293bd4f7a..662d184714 100644 --- a/docs/user-guide/assistant.md +++ b/docs/user-guide/assistant.md @@ -441,8 +441,8 @@ Plain HTTP is only used for servers on your computer or local network. In the web app, the browser calls the provider directly. Anthropic, OpenAI, Gemini, OpenRouter, Requesty, TrustedRouter, Opper and Mistral accept that; a local Ollama server must allow the page's origin (`OLLAMA_ORIGINS=https://web.rustgis.app ollama serve`). Ollama Cloud refuses requests from -web pages, so in the web app use its models through a local Ollama server signed in with -`ollama signin`. +web pages, so the web app doesn't list it: use its models there through a local Ollama server +signed in with `ollama signin`. ## Retries and long conversations From b9e0a0f1ad2ce19f951ae63abd5e4a1c16567979 Mon Sep 17 00:00:00 2001 From: elpidioassinaturas Date: Sun, 29 Nov 2026 20:30:03 -0300 Subject: [PATCH 2/2] fix(assistant): a saved Ollama Cloud choice falls back in the web app The web app saved its provider choice before it stopped listing Ollama Cloud, so the choice could come back with no entry in the list and requests that fail on CORS. usable_choice checks a saved or environment choice against what the web app can reach; the settings list uses the same rule. Co-Authored-By: Claude Opus 5.5 --- crates/assistant/src/provider.rs | 6 ++++++ crates/assistant/src/tests.rs | 9 +++++++++ crates/ui-egui/src/assistant.rs | 3 ++- crates/ui-egui/src/assistantpane.rs | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/assistant/src/provider.rs b/crates/assistant/src/provider.rs index 194ded83ef..3b7df60eaa 100644 --- a/crates/assistant/src/provider.rs +++ b/crates/assistant/src/provider.rs @@ -362,6 +362,12 @@ pub fn works_in_browser(p: &Preset) -> bool { !p.login && p.id != "ollama-cloud" } +/// Whether a saved or environment choice of provider can be used: one that exists and, in the web +/// app (`web`), [`works_in_browser`]. A choice that can't falls back to the default. +pub fn usable_choice(id: &str, web: bool) -> bool { + preset(id).is_some_and(|p| !web || works_in_browser(p)) +} + /// The provider a command-line run uses: the explicit choice, then the environment's choice, then /// the first provider with an environment key, then (only when `saved` has the desktop's /// preferences) the one the desktop app uses, else `ollama`. Environment credentials win over the diff --git a/crates/assistant/src/tests.rs b/crates/assistant/src/tests.rs index ea43083db8..20e811e291 100644 --- a/crates/assistant/src/tests.rs +++ b/crates/assistant/src/tests.rs @@ -5634,6 +5634,15 @@ fn the_web_app_offers_only_providers_a_web_page_can_reach() { assert!(["anthropic", "openai", "gemini", "openrouter", "ollama", "custom", "mistral"].iter().all(|id| offered.contains(id))); } +#[test] +fn a_saved_choice_the_web_app_cannot_use_is_not_restored_there() { + // Saved before the web app stopped listing it: the web app falls back instead. + assert!(!usable_choice("ollama-cloud", true) && !usable_choice("chatgpt", true)); + assert!(usable_choice("ollama-cloud", false) && usable_choice("chatgpt", false)); + assert!(usable_choice("mistral", true) && usable_choice("ollama", true)); + assert!(!usable_choice("retired", false) && !usable_choice("retired", true)); +} + #[test] fn ollama_cloud_runs_a_tool_call_and_answers() { let mut s = sample(); diff --git a/crates/ui-egui/src/assistant.rs b/crates/ui-egui/src/assistant.rs index d312c50772..6112c44590 100644 --- a/crates/ui-egui/src/assistant.rs +++ b/crates/ui-egui/src/assistant.rs @@ -296,7 +296,8 @@ pub(crate) fn ensure_loaded(app: &mut RustGisApp, ctx: &egui::Context) { app.assistant.remember_key = provider::remembers_keys(pref(app, provider::REMEMBER_KEY_PREF).as_deref()); let provider = pref(app, provider::PROVIDER_PREF) .or_else(|| std::env::var("RUSTGIS_ASSISTANT_PROVIDER").ok()) - .filter(|p| provider::preset(p).is_some()) + // One saved before the web app stopped offering it (Ollama Cloud) falls back there. + .filter(|p| provider::usable_choice(p, cfg!(target_arch = "wasm32"))) // The first provider with a key in the environment (a ChatGPT sign-in and Ollama Cloud are // chosen, not assumed). .or_else(|| provider::first_keyed(Config::from_env).map(str::to_string)) diff --git a/crates/ui-egui/src/assistantpane.rs b/crates/ui-egui/src/assistantpane.rs index abdb9ce558..2c13221779 100644 --- a/crates/ui-egui/src/assistantpane.rs +++ b/crates/ui-egui/src/assistantpane.rs @@ -145,7 +145,7 @@ fn provider_settings(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, cfg: &mut Co for p in PRESETS { // Signing in needs the browser and a server on this computer, and ollama.com // refuses web pages: the desktop app. - if cfg!(target_arch = "wasm32") && !provider::works_in_browser(p) { + if !provider::usable_choice(p.id, cfg!(target_arch = "wasm32")) { continue; } if ui.selectable_label(cfg.provider == p.id, tl!(p.label)).clicked() && cfg.provider != p.id {