Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat: Jan bundle

Louis3db9fb96b294
diff --git a/Makefile b/Makefile
index ff7316999..5d2d11990 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,7 @@ install-ios-rust-targets:
dev: install-and-build
yarn download:bin
make build-mlx-server-if-exists
+ make build-cli-dev
yarn dev
# Web application targets
@@ -152,6 +153,7 @@ else
@echo "Skipping MLX server build (macOS only)"
endif
+
# Build MLX server only if not already present (for dev)
build-mlx-server-if-exists:
ifeq ($(shell uname -s),Darwin)
@@ -164,6 +166,41 @@ else
@echo "Skipping MLX server build (macOS only)"
endif
+# Build jan CLI (release, platform-aware) → src-tauri/resources/bin/jan[.exe]
+build-cli:
+ifeq ($(shell uname -s),Darwin)
+ @echo "Building jan CLI (universal macOS)..."
+ cd src-tauri && cargo build --release --features cli --bin jan --target aarch64-apple-darwin
+ cd src-tauri && cargo build --release --features cli --bin jan --target x86_64-apple-darwin
+ mkdir -p src-tauri/resources/bin
+ lipo -create \
+ src-tauri/target/aarch64-apple-darwin/release/jan \
+ src-tauri/target/x86_64-apple-darwin/release/jan \
+ -output src-tauri/resources/bin/jan
+ chmod +x src-tauri/resources/bin/jan
+ @echo "jan CLI (universal) → src-tauri/resources/bin/jan"
+else ifeq ($(OS),Windows_NT)
+ @echo "Building jan CLI (Windows)..."
+ cd src-tauri && cargo build --release --features cli --bin jan
+ mkdir -p src-tauri/resources/bin
+ cp src-tauri/target/release/jan.exe src-tauri/resources/bin/jan.exe
+ @echo "jan CLI → src-tauri/resources/bin/jan.exe"
+else
+ @echo "Building jan CLI (Linux)..."
+ cd src-tauri && cargo build --release --features cli --bin jan
+ mkdir -p src-tauri/resources/bin
+ cp src-tauri/target/release/jan src-tauri/resources/bin/jan
+ chmod +x src-tauri/resources/bin/jan
+ @echo "jan CLI → src-tauri/resources/bin/jan"
+endif
+
+# Debug build for local dev (faster, no lipo on macOS)
+build-cli-dev:
+ cd src-tauri && cargo build --features cli --bin jan
+ mkdir -p src-tauri/resources/bin
+ cp src-tauri/target/debug/jan src-tauri/resources/bin/jan
+ chmod +x src-tauri/resources/bin/jan
+
# Build
build: install-and-build install-rust-targets
yarn build
diff --git a/package.json b/package.json
index 3fce01cf1..1774e4d7e 100644
--- a/package.json
+++ b/package.json
@@ -31,9 +31,10 @@
"download:lib": "node ./scripts/download-lib.mjs",
"download:bin": "node ./scripts/download-bin.mjs",
"build:mlx-server": "make build-mlx-server",
- "build:tauri:win32": "yarn download:bin && yarn tauri build",
- "build:tauri:linux": "yarn download:bin && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
- "build:tauri:darwin": "yarn download:bin && yarn build:mlx-server && yarn tauri build --target universal-apple-darwin",
+ "build:cli": "make build-cli",
+ "build:tauri:win32": "yarn download:bin && yarn build:cli && yarn tauri build",
+ "build:tauri:linux": "yarn download:bin && yarn build:cli && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
+ "build:tauri:darwin": "yarn download:bin && yarn build:mlx-server && yarn build:cli && yarn tauri build --target universal-apple-darwin",
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
"build:tauri:plugin:api": "cd src-tauri/plugins && yarn install && yarn workspaces foreach -Apt run build",
"build:icon": "tauri icon ./src-tauri/icons/icon.png",
diff --git a/src-tauri/src/bin/jan.rs b/src-tauri/src/bin/jan.rs
index d8e245360..96a775fa4 100644
--- a/src-tauri/src/bin/jan.rs
+++ b/src-tauri/src/bin/jan.rs
@@ -576,7 +576,7 @@ fn select_model_interactively() -> String {
.interact()
.unwrap_or_else(|_| std::process::exit(1));
- all.remove(selection).0
+ all[selection].0.clone()
}
// ── Detached spawn ─────────────────────────────────────────────────────────
@@ -786,44 +786,7 @@ async fn handle_serve(args: ServeArgs) {
envs.insert("LLAMA_API_KEY".to_string(), api_key);
}
- let config = LlamacppConfig {
- version_backend: "cli/llama-server".to_string(),
- auto_update_engine: false,
- auto_unload: false,
- timeout: timeout as i32,
- llamacpp_env: String::new(),
- fit,
- fit_target: String::new(),
- fit_ctx: String::new(),
- chat_template: String::new(),
- n_gpu_layers,
- offload_mmproj: true,
- cpu_moe: false,
- n_cpu_moe: 0,
- override_tensor_buffer_t: String::new(),
- ctx_size,
- threads,
- threads_batch: 0,
- n_predict: -1,
- batch_size: 512,
- ubatch_size: 512,
- device: String::new(),
- split_mode: String::new(),
- main_gpu: 0,
- flash_attn: "auto".to_string(),
- cont_batching: true,
- no_mmap: false,
- mlock: false,
- no_kv_offload: false,
- cache_type_k: String::new(),
- cache_type_v: String::new(),
- defrag_thold: -1.0,
- rope_scaling: String::new(),
- rope_scale: 0.0,
- rope_freq_base: 0.0,
- rope_freq_scale: 0.0,
- ctx_shift: false,
- };
+ let config = build_llamacpp_config(n_gpu_layers, ctx_size, timeout as i32, fit, threads);
match load_llama_model_impl(
llama_state.llama_server_process.clone(),
@@ -864,12 +827,23 @@ async fn handle_serve(args: ServeArgs) {
async fn wait_for_shutdown(pid: i32) {
tokio::signal::ctrl_c().await.ok();
eprintln!("\nShutting down (pid {pid})...");
+ kill_process(pid);
+}
+
+/// Send a termination signal to a child process by PID.
+fn kill_process(pid: i32) {
#[cfg(unix)]
{
use nix::sys::signal::{kill, Signal};
use nix::unistd::Pid;
let _ = kill(Pid::from_raw(pid), Signal::SIGTERM);
}
+ #[cfg(windows)]
+ {
+ let _ = std::process::Command::new("taskkill")
+ .args(["/PID", &pid.to_string(), "/F"])
+ .status();
+ }
}
// ── Launch handler ─────────────────────────────────────────────────────────
@@ -908,6 +882,7 @@ async fn handle_launch(
eprintln!();
eprintln!(" OPENAI_BASE_URL={v1_url}");
eprintln!(" OPENAI_API_KEY={api_key}");
+ eprintln!(" OPENAI_MODEL={model_id}");
eprintln!(" ANTHROPIC_BASE_URL={base_url}");
eprintln!(" {anthropic_key_var}={api_key}");
eprintln!(" ANTHROPIC_DEFAULT_OPUS_MODEL={model_id}");
@@ -921,6 +896,7 @@ async fn handle_launch(
cmd.args(&program_args)
.env("OPENAI_BASE_URL", &v1_url)
.env("OPENAI_API_KEY", &api_key)
+ .env("OPENAI_MODEL", &model_id)
.env("ANTHROPIC_BASE_URL", &base_url)
.env(anthropic_key_var, &api_key)
.env("ANTHROPIC_DEFAULT_OPUS_MODEL", &model_id)
@@ -929,12 +905,7 @@ async fn handle_launch(
let status = cmd.status();
// Kill the model server when the program exits.
- #[cfg(unix)]
- {
- use nix::sys::signal::{kill, Signal};
- use nix::unistd::Pid;
- let _ = kill(Pid::from_raw(pid), Signal::SIGTERM);
- }
+ kill_process(pid);
match status {
Ok(s) => std::process::exit(s.code().unwrap_or(0)),
@@ -955,13 +926,15 @@ async fn start_model_server(
ctx_size: i32,
fit: bool,
) -> (i32, u16) {
- // Auto-download from HuggingFace if the model isn't installed locally.
- if resolve_model_engine(model_id).is_err() && looks_like_hf_repo(model_id) {
- auto_download_hf_model(model_id).await;
- }
-
let (engine, model_path, mmproj) = match resolve_model_engine(model_id) {
Ok(r) => r,
+ Err(_) if looks_like_hf_repo(model_id) => {
+ auto_download_hf_model(model_id).await;
+ match resolve_model_engine(model_id) {
+ Ok(r) => r,
+ Err(e) => { eprintln!("Error after download: {e}"); std::process::exit(1); }
+ }
+ }
Err(e) => { eprintln!("Error: {e}"); std::process::exit(1); }
};
let model_path = model_path.to_string_lossy().into_owned();
@@ -977,13 +950,14 @@ async fn start_model_server(
let mlx_state = Arc::new(init_mlx_state());
let mut envs = HashMap::new();
if !api_key.is_empty() { envs.insert("MLX_API_KEY".into(), api_key.clone()); }
+ let effective_ctx_size = if fit { 0 } else { ctx_size };
let info = load_mlx_model_impl(
mlx_state.mlx_server_process.clone(),
Path::new(&bin_path),
model_id.to_string(),
model_path,
port,
- MlxConfig { ctx_size },
+ MlxConfig { ctx_size: effective_ctx_size },
envs,
false,
120,
@@ -1007,21 +981,7 @@ async fn start_model_server(
if !api_key.is_empty() { envs.insert("LLAMA_API_KEY".into(), api_key.clone()); }
// When fit is on, let llama.cpp decide the context size automatically.
let effective_ctx_size = if fit { 0 } else { ctx_size };
- let config = LlamacppConfig {
- version_backend: "cli/llama-server".to_string(),
- auto_update_engine: false, auto_unload: false,
- timeout: 120, llamacpp_env: String::new(),
- fit, fit_target: String::new(), fit_ctx: String::new(),
- chat_template: String::new(), n_gpu_layers, offload_mmproj: true,
- cpu_moe: false, n_cpu_moe: 0, override_tensor_buffer_t: String::new(),
- ctx_size: effective_ctx_size, threads: 0, threads_batch: 0, n_predict: -1,
- batch_size: 512, ubatch_size: 512, device: String::new(),
- split_mode: String::new(), main_gpu: 0, flash_attn: "auto".into(),
- cont_batching: true, no_mmap: false, mlock: false, no_kv_offload: false,
- cache_type_k: String::new(), cache_type_v: String::new(),
- defrag_thold: -1.0, rope_scaling: String::new(),
- rope_scale: 0.0, rope_freq_base: 0.0, rope_freq_scale: 0.0, ctx_shift: false,
- };
+ let config = build_llamacpp_config(n_gpu_layers, effective_ctx_size, 120, fit, 0);
let info = load_llama_model_impl(
llama_state.llama_server_process.clone(),
&bin_path,
@@ -1044,6 +1004,51 @@ async fn start_model_server(
}
}
+// ── LlamaCPP config builder ────────────────────────────────────────────────
+
+/// Build a `LlamacppConfig` with the values the CLI controls; everything else
+/// stays at a sensible default.
+fn build_llamacpp_config(n_gpu_layers: i32, ctx_size: i32, timeout: i32, fit: bool, threads: i32) -> LlamacppConfig {
+ LlamacppConfig {
+ version_backend: "cli/llama-server".to_string(),
+ auto_update_engine: false,
+ auto_unload: false,
+ timeout,
+ llamacpp_env: String::new(),
+ fit,
+ fit_target: String::new(),
+ fit_ctx: String::new(),
+ chat_template: String::new(),
+ n_gpu_layers,
+ offload_mmproj: true,
+ cpu_moe: false,
+ n_cpu_moe: 0,
+ override_tensor_buffer_t: String::new(),
+ ctx_size,
+ threads,
+ threads_batch: 0,
+ n_predict: -1,
+ batch_size: 512,
+ ubatch_size: 512,
+ device: String::new(),
+ split_mode: String::new(),
+ main_gpu: 0,
+ flash_attn: "auto".to_string(),
+ cont_batching: true,
+ no_mmap: false,
+ mlock: false,
+ no_kv_offload: false,
+ cache_type_k: String::new(),
+ cache_type_v: String::new(),
+ defrag_thold: -1.0,
+ rope_scaling: String::new(),
+ rope_scale: 0.0,
+ rope_freq_base: 0.0,
+ rope_freq_scale: 0.0,
+ ctx_shift: false,
+ }
+}
+
// ── App handlers ───────────────────────────────────────────────────────────
fn handle_app(cmd: AppCommands) {
diff --git a/src-tauri/src/core/cli/mod.rs b/src-tauri/src/core/cli/mod.rs
index d73548b90..64a07d929 100644
--- a/src-tauri/src/core/cli/mod.rs
+++ b/src-tauri/src/core/cli/mod.rs
@@ -2,12 +2,9 @@
//!
//! This module is only compiled when the `cli` feature is enabled.
-use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
-use tokio::sync::Mutex;
-
use crate::core::app::commands::{resolve_config_file_path, resolve_jan_data_folder};
use crate::core::server::proxy;
use crate::core::state::AppState;
@@ -26,10 +23,6 @@ pub use tauri_plugin_mlx::state::SessionInfo;
// ── State constructors ─────────────────────────────────────────────────────
-pub fn init_app_state() -> AppState {
- AppState::default()
-}
-
pub fn init_llamacpp_state() -> LlamacppState {
LlamacppState::new()
}
@@ -225,7 +218,7 @@ pub fn resolve_model_engine(
}
Err(format!(
"Model '{}' not found for any engine. \
- Run `jan-cli models list` or `jan-cli models list --engine mlx` to see available models.",
+ Run `jan models list` to see available models.",
model_id
))
}
@@ -250,7 +243,7 @@ pub fn resolve_model_by_id(
if !yml_path.exists() {
return Err(format!(
"Model '{}' not found for engine '{}'. \
- Run `jan-cli models list` to see available models.",
+ Run `jan models list` to see available models.",
model_id, engine
));
}
diff --git a/src-tauri/src/core/server/proxy.rs b/src-tauri/src/core/server/proxy.rs
index 4decc9648..65daf1023 100644
--- a/src-tauri/src/core/server/proxy.rs
+++ b/src-tauri/src/core/server/proxy.rs
@@ -690,10 +690,10 @@ async fn proxy_request(
// Initialize variables that will be set in the match
let mut session_api_key: Option<String> = None;
+ #[allow(unused_assignments)]
let mut buffered_body: Option<Bytes> = None;
let mut target_base_url: Option<String> = None;
let mut is_anthropic_messages = false;
- let mut provider_name: Option<String> = None;
match (method.clone(), destination_path.as_str()) {
// Anthropic /messages endpoint - tries /messages first, falls back to /chat/completions on error
@@ -727,7 +727,7 @@ async fn proxy_request(
let pc = provider_configs.lock().await;
// Try to find a provider for this model
- provider_name = pc
+ let provider_name: Option<String> = pc
.iter()
.find(|(_, config)| config.models.iter().any(|m| m == model_id))
.map(|(_, config)| config.provider.clone())
diff --git a/src-tauri/src/core/setup.rs b/src-tauri/src/core/setup.rs
index f3274855c..d440a2eea 100644
--- a/src-tauri/src/core/setup.rs
+++ b/src-tauri/src/core/setup.rs
@@ -272,6 +272,45 @@ pub fn extract_extension_manifest<R: Read>(
Ok(None)
}
+/// Install/update the bundled `jan` CLI binary.
+///
+/// - `version_changed`: pass `true` whenever the app version has changed (i.e. after an update).
+/// When `true` the binary is always overwritten so the CLI stays in sync with the new app.
+/// When `false` only installs if the binary is not yet present on PATH.
+///
+/// Runs in a background task — never blocks startup.
+/// Errors are logged as warnings and never prevent the app from starting.
+pub fn setup_jan_cli<R: Runtime>(app_handle: tauri::AppHandle<R>, version_changed: bool) {
+ tauri::async_runtime::spawn(async move {
+ // On a normal launch where the version hasn't changed, skip reinstall if already on PATH.
+ if !version_changed {
+ let which_cmd = if cfg!(windows) { "where" } else { "which" };
+ if std::process::Command::new(which_cmd)
+ .arg("jan")
+ .output()
+ .map(|o| o.status.success())
+ .unwrap_or(false)
+ {
+ log::debug!("jan CLI already on PATH — skipping reinstall");
+ return;
+ }
+ }
+
+ match crate::core::system::commands::install_jan_cli_sync(&app_handle) {
+ Ok(status) => {
+ log::info!(
+ "jan CLI {} to {}",
+ if version_changed { "updated" } else { "installed" },
+ status.path.as_deref().unwrap_or("<unknown>")
+ );
+ }
+ Err(e) => {
+ log::warn!("jan CLI auto-install skipped: {e}");
+ }
+ }
+ });
+}
+
pub fn setup_mcp<R: Runtime>(app: &App<R>) {
let state = app.state::<AppState>();
let servers = state.mcp_servers.clone();
diff --git a/src-tauri/src/core/system/commands.rs b/src-tauri/src/core/system/commands.rs
index 4846ec983..a3cdaa164 100644
--- a/src-tauri/src/core/system/commands.rs
+++ b/src-tauri/src/core/system/commands.rs
@@ -332,3 +332,102 @@ pub fn launch_claude_code_with_config(
return Ok(());
}
}
+
+#[derive(serde::Serialize)]
+pub struct CliInstallStatus {
+ pub installed: bool,
+ pub path: Option<String>,
+}
+
+/// Check if the `jan` CLI binary is accessible on PATH.
+#[tauri::command]
+pub fn check_jan_cli_installed() -> CliInstallStatus {
+ let which_cmd = if cfg!(windows) { "where" } else { "which" };
+ match std::process::Command::new(which_cmd).arg("jan").output() {
+ Ok(out) if out.status.success() => CliInstallStatus {
+ installed: true,
+ path: Some(String::from_utf8_lossy(&out.stdout).trim().to_string()),
+ },
+ _ => CliInstallStatus { installed: false, path: None },
+ }
+}
+
+/// Core install logic — synchronous, no Tauri command overhead.
+///
+/// Copies the bundled `jan` binary to the best writable directory on PATH.
+/// Install order (Unix): `/usr/local/bin` (writable probe), then `~/.local/bin`.
+/// Windows: `%LOCALAPPDATA%\Programs\Jan\`
+pub fn install_jan_cli_sync<R: Runtime>(app_handle: &AppHandle<R>) -> Result<CliInstallStatus, String> {
+ let bin_name = if cfg!(windows) { "jan.exe" } else { "jan" };
+ let bundled = app_handle
+ .path()
+ .resource_dir()
+ .map_err(|e| e.to_string())?
+ .join("resources/bin")
+ .join(bin_name);
+
+ if !bundled.exists() {
+ return Err("Jan CLI binary not bundled with this version of Jan.".to_string());
+ }
+
+ let install_dir = jan_cli_install_dir()?;
+ std::fs::create_dir_all(&install_dir).map_err(|e| e.to_string())?;
+ let dest = install_dir.join(bin_name);
+
+ std::fs::copy(&bundled, &dest)
+ .map_err(|e| format!("Failed to copy jan to {}: {}", dest.display(), e))?;
+
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ std::fs::set_permissions(&dest, std::fs::Permissions::from_mode(0o755))
+ .map_err(|e| e.to_string())?;
+ }
+
+ Ok(CliInstallStatus {
+ installed: true,
+ path: Some(dest.to_string_lossy().into_owned()),
+ })
+}
+
+/// Copy the bundled `jan` binary to the system PATH (Tauri command wrapper).
+#[tauri::command]
+pub async fn install_jan_cli<R: Runtime>(app_handle: AppHandle<R>) -> Result<CliInstallStatus, String> {
+ install_jan_cli_sync(&app_handle)
+}
+
+/// Remove the installed `jan` CLI binary from the install directory.
+#[tauri::command]
+pub fn uninstall_jan_cli() -> Result<(), String> {
+ let bin_name = if cfg!(windows) { "jan.exe" } else { "jan" };
+ let dest = jan_cli_install_dir()?.join(bin_name);
+ if dest.exists() {
+ std::fs::remove_file(&dest)
+ .map_err(|e| format!("Failed to remove Jan CLI from {}: {}", dest.display(), e))?;
+ }
+ Ok(())
+}
+
+/// Determine the best writable directory for the Jan CLI install.
+fn jan_cli_install_dir() -> Result<PathBuf, String> {
+ #[cfg(unix)]
+ {
+ let usr_local_bin = PathBuf::from("/usr/local/bin");
+ if usr_local_bin.exists() {
+ let probe = usr_local_bin.join(".jan_write_probe");
+ if std::fs::write(&probe, b"").is_ok() {
+ let _ = std::fs::remove_file(&probe);
+ return Ok(usr_local_bin);
+ }
+ }
+ let home = std::env::var("HOME")
+ .map_err(|_| "Cannot determine home directory".to_string())?;
+ Ok(PathBuf::from(home).join(".local").join("bin"))
+ }
+ #[cfg(windows)]
+ {
+ let local_app_data = std::env::var("LOCALAPPDATA")
+ .map_err(|_| "Cannot determine LOCALAPPDATA".to_string())?;
+ Ok(PathBuf::from(local_app_data).join("Programs").join("Jan"))
+ }
+}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 128b6fb44..8d5682d77 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -101,6 +101,9 @@ pub fn run() {
core::system::commands::read_logs,
core::system::commands::is_library_available,
core::system::commands::launch_claude_code_with_config,
+ core::system::commands::check_jan_cli_installed,
+ core::system::commands::install_jan_cli,
+ core::system::commands::uninstall_jan_cli,
// Server commands
core::server::commands::start_server,
core::server::commands::stop_server,
@@ -259,6 +262,9 @@ pub fn run() {
core::system::commands::read_logs,
core::system::commands::is_library_available,
core::system::commands::launch_claude_code_with_config,
+ core::system::commands::check_jan_cli_installed,
+ core::system::commands::install_jan_cli,
+ core::system::commands::uninstall_jan_cli,
// Server commands
core::server::commands::start_server,
core::server::commands::stop_server,
@@ -384,6 +390,8 @@ pub fn run() {
}
setup_mcp(app);
+ #[cfg(desktop)]
+ setup::setup_jan_cli(app.handle().clone(), stored_version != app_version);
setup::setup_theme_listener(app)?;
Ok(())
})
diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json
index ba053d80a..0f5cb3fa0 100644
--- a/src-tauri/tauri.linux.conf.json
+++ b/src-tauri/tauri.linux.conf.json
@@ -30,7 +30,7 @@
},
"bundle": {
"targets": ["deb", "appimage"],
- "resources": ["resources/pre-install/**/*", "resources/LICENSE"],
+ "resources": ["resources/pre-install/**/*", "resources/LICENSE", "resources/bin/jan"],
"externalBin": ["resources/bin/uv"],
"linux": {
"appimage": {
diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json
index a512345a6..155888ea5 100644
--- a/src-tauri/tauri.macos.conf.json
+++ b/src-tauri/tauri.macos.conf.json
@@ -30,7 +30,7 @@
},
"bundle": {
"targets": ["app", "dmg"],
- "resources": ["resources/pre-install/**/*", "resources/LICENSE"],
+ "resources": ["resources/pre-install/**/*", "resources/LICENSE", "resources/bin/mlx-server", "resources/bin/mlx-swift_Cmlx.bundle", "resources/bin/jan"],
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
"macOS": {
"entitlements": "./Entitlements.plist"
diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json
index b5038fca5..2f4efcf18 100644
--- a/src-tauri/tauri.windows.conf.json
+++ b/src-tauri/tauri.windows.conf.json
@@ -30,7 +30,7 @@
},
"bundle": {
"targets": ["nsis", "msi"],
- "resources": ["resources/pre-install/**/*", "resources/LICENSE"],
+ "resources": ["resources/pre-install/**/*", "resources/LICENSE", "resources/bin/jan"],
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
"windows": {
"webviewInstallMode": {
diff --git a/src-tauri/utils/src/system.rs b/src-tauri/utils/src/system.rs
index 8e2e75cda..00e1091c9 100644
--- a/src-tauri/utils/src/system.rs
+++ b/src-tauri/utils/src/system.rs
@@ -90,12 +90,12 @@ pub fn setup_library_path(library_path: Option<&Path>, command: &mut tokio::proc
}
}
-pub fn binary_requires_cuda(bin_path: &Path) -> bool {
+pub fn binary_requires_cuda(_bin_path: &Path) -> bool {
#[cfg(target_os = "windows")]
- return binary_requires_cuda_windows(bin_path);
+ return binary_requires_cuda_windows(_bin_path);
#[cfg(target_os = "linux")]
- return binary_requires_cuda_linux(bin_path);
+ return binary_requires_cuda_linux(_bin_path);
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
false
@@ -147,12 +147,12 @@ fn binary_requires_cuda_linux(bin_path: &Path) -> bool {
}
/// Adds CUDA paths to the command's environment based on the OS.
-pub fn add_cuda_paths(command: &mut tokio::process::Command) -> bool {
+pub fn add_cuda_paths(_command: &mut tokio::process::Command) -> bool {
#[cfg(target_os = "windows")]
- return add_cuda_paths_windows(command);
+ return add_cuda_paths_windows(_command);
#[cfg(target_os = "linux")]
- return add_cuda_paths_linux(command);
+ return add_cuda_paths_linux(_command);
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
{
diff --git a/web-app/src/providers/DataProvider.tsx b/web-app/src/providers/DataProvider.tsx
index 28dc203b0..3648f1e6f 100644
--- a/web-app/src/providers/DataProvider.tsx
+++ b/web-app/src/providers/DataProvider.tsx
@@ -154,6 +154,7 @@ export function DataProvider() {
.then((unsub) => {
unsubscribe = unsub
})
+
return () => {
unsubscribe()
}
diff --git a/web-app/src/routes/settings/general.tsx b/web-app/src/routes/settings/general.tsx
index 1bad6a779..c56b5e771 100644
--- a/web-app/src/routes/settings/general.tsx
+++ b/web-app/src/routes/settings/general.tsx
@@ -1,4 +1,5 @@
import { createFileRoute } from '@tanstack/react-router'
+import { invoke } from '@tauri-apps/api/core'
import { route } from '@/constants/routes'
import SettingsMenu from '@/containers/SettingsMenu'
import HeaderPage from '@/containers/HeaderPage'
@@ -62,6 +63,9 @@ function General() {
const [isDialogOpen, setIsDialogOpen] = useState(false)
const [isCheckingUpdate, setIsCheckingUpdate] = useState(false)
const [isValidatingToken, setIsValidatingToken] = useState(false)
+ const [cliInstalled, setCliInstalled] = useState<boolean | null>(null)
+ const [cliPath, setCliPath] = useState<string | null>(null)
+ const [isCliLoading, setIsCliLoading] = useState(false)
useEffect(() => {
const fetchDataFolder = async () => {
@@ -72,6 +76,41 @@ function General() {
fetchDataFolder()
}, [serviceHub])
+ useEffect(() => {
+ if (!IS_TAURI) return
+ invoke<{ installed: boolean; path: string | null }>('check_jan_cli_installed')
+ .then((s) => { setCliInstalled(s.installed); setCliPath(s.path) })
+ .catch(() => setCliInstalled(false))
+ }, [])
+
+ const handleInstallCli = async () => {
+ setIsCliLoading(true)
+ try {
+ const s = await invoke<{ installed: boolean; path: string | null }>('install_jan_cli')
+ setCliInstalled(s.installed)
+ setCliPath(s.path)
+ toast.success(`Jan CLI installed to ${s.path}`)
+ } catch (e) {
+ toast.error('Install failed', { description: String(e) })
+ } finally {
+ setIsCliLoading(false)
+ }
+ }
+
+ const handleUninstallCli = async () => {
+ setIsCliLoading(true)
+ try {
+ await invoke('uninstall_jan_cli')
+ setCliInstalled(false)
+ setCliPath(null)
+ toast.success('Jan CLI uninstalled')
+ } catch (e) {
+ toast.error('Uninstall failed', { description: String(e) })
+ } finally {
+ setIsCliLoading(false)
+ }
+ }
+
const resetApp = async () => {
// Prevent resetting if data folder is root directory
if (isRootDir(janDataFolder ?? '/')) {
@@ -179,7 +218,7 @@ function General() {
<SettingsMenu />
<div className="p-4 pt-0 w-full overflow-y-auto">
<div className="flex flex-col justify-between gap-4 gap-y-3 w-full">
-
+
{/* General */}
<Card title={t('common:general')}>
<CardItem
@@ -347,9 +386,40 @@ function General() {
}
/>
</Card>
-
+
{/* Advanced - Desktop only */}
<Card title="Advanced">
+ {IS_TAURI && (
+ <CardItem
+ title="Jan CLI"
+ description={
+ cliInstalled && cliPath
+ ? `Installed at ${cliPath} — use jan from your terminal to serve models.`
+ : 'Use jan from your terminal to serve models without opening the app.'
+ }
+ actions={
+ cliInstalled ? (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleUninstallCli}
+ disabled={isCliLoading || cliInstalled === null}
+ >
+ {isCliLoading ? 'Uninstalling…' : 'Uninstall'}
+ </Button>
+ ) : (
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={handleInstallCli}
+ disabled={isCliLoading || cliInstalled === null}
+ >
+ {isCliLoading ? 'Installing…' : 'Install'}
+ </Button>
+ )
+ }
+ />
+ )}
<CardItem
title={t('settings:others.resetFactory', {
ns: 'settings',