summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-01-08 17:37:15 -0600
committerAdam <[email protected]>2026-01-08 17:51:30 -0600
commit3019b1f8253943f077c06c5b73ab9276326e33df (patch)
tree506556d666b9ce1c26eb80b1ab0fa23bcbc5ad8f
parent119cc8c79513aeab8e7359a228fe4a2f564644a8 (diff)
downloadopencode-3019b1f8253943f077c06c5b73ab9276326e33df.tar.gz
opencode-3019b1f8253943f077c06c5b73ab9276326e33df.zip
Revert "fix(desktop): open external links in default browser (#7221)"
This reverts commit 361a96267334fcfc524cc5377dbbfd7d92254f62.
-rw-r--r--packages/desktop/src-tauri/src/lib.rs77
1 files changed, 0 insertions, 77 deletions
diff --git a/packages/desktop/src-tauri/src/lib.rs b/packages/desktop/src-tauri/src/lib.rs
index c31c0df35..cb937401d 100644
--- a/packages/desktop/src-tauri/src/lib.rs
+++ b/packages/desktop/src-tauri/src/lib.rs
@@ -15,7 +15,6 @@ use tauri::{
};
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
use tauri_plugin_shell::ShellExt;
-use tauri_plugin_store::StoreExt;
use tokio::net::TcpSocket;
use crate::window_customizer::PinchZoomDisablePlugin;
@@ -46,65 +45,6 @@ impl ServerState {
struct LogState(Arc<Mutex<VecDeque<String>>>);
const MAX_LOG_ENTRIES: usize = 200;
-const GLOBAL_STORAGE: &str = "opencode.global.dat";
-
-/// Check if a URL's origin matches any configured server in the store.
-/// Returns true if the URL should be allowed for internal navigation.
-fn is_allowed_server(app: &AppHandle, url: &tauri::Url) -> bool {
- // Always allow localhost and 127.0.0.1
- if let Some(host) = url.host_str() {
- if host == "localhost" || host == "127.0.0.1" {
- return true;
- }
- }
-
- // Try to read the server list from the store
- let Ok(store) = app.store(GLOBAL_STORAGE) else {
- return false;
- };
-
- let Some(server_data) = store.get("server") else {
- return false;
- };
-
- // Parse the server list from the stored JSON
- let Some(list) = server_data.get("list").and_then(|v| v.as_array()) else {
- return false;
- };
-
- // Get the origin of the navigation URL (scheme + host + port)
- let url_origin = format!(
- "{}://{}{}",
- url.scheme(),
- url.host_str().unwrap_or(""),
- url.port().map(|p| format!(":{}", p)).unwrap_or_default()
- );
-
- // Check if any configured server matches the URL's origin
- for server in list {
- let Some(server_url) = server.as_str() else {
- continue;
- };
-
- // Parse the server URL to extract its origin
- let Ok(parsed) = tauri::Url::parse(server_url) else {
- continue;
- };
-
- let server_origin = format!(
- "{}://{}{}",
- parsed.scheme(),
- parsed.host_str().unwrap_or(""),
- parsed.port().map(|p| format!(":{}", p)).unwrap_or_default()
- );
-
- if url_origin == server_origin {
- return true;
- }
- }
-
- false
-}
#[tauri::command]
fn kill_sidecar(app: AppHandle) {
@@ -296,7 +236,6 @@ pub fn run() {
.unwrap_or(LogicalSize::new(1920, 1080));
// Create window immediately with serverReady = false
- let app_for_nav = app.clone();
let mut window_builder =
WebviewWindow::builder(&app, "main", WebviewUrl::App("/".into()))
.title("OpenCode")
@@ -304,22 +243,6 @@ pub fn run() {
.decorations(true)
.zoom_hotkeys_enabled(true)
.disable_drag_drop_handler()
- .on_navigation(move |url| {
- // Allow internal navigation (tauri:// scheme)
- if url.scheme() == "tauri" {
- return true;
- }
- // Allow navigation to configured servers (localhost, 127.0.0.1, or remote)
- if is_allowed_server(&app_for_nav, url) {
- return true;
- }
- // Open external http/https URLs in default browser
- if url.scheme() == "http" || url.scheme() == "https" {
- let _ = app_for_nav.shell().open(url.as_str(), None);
- return false; // Cancel internal navigation
- }
- true
- })
.initialization_script(format!(
r#"
window.__OPENCODE__ ??= {{}};