Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix(windows): retarget shortcuts when the main binary is renamed on update (#9126)
Akarshan Biswasd59782867d00
diff --git a/docs/src/pages/changelog/2026-09-22-jan-v0.8.5.mdx b/docs/src/pages/changelog/2026-09-22-jan-v0.8.5.mdxindex 168927bc7..a66db6545 100644--- a/docs/src/pages/changelog/2026-09-22-jan-v0.8.5.mdx+++ b/docs/src/pages/changelog/2026-09-22-jan-v0.8.5.mdx@@ -19,6 +19,8 @@ No new features are announced in v0.8.5. Work in progress stays in the nightly cOne thing a first launch will notice: the first-run setup is now a guided wizard - welcome, engine setup, a first model, and the consent page - instead of a single screen. It is onboarding rather than a new capability, so it is not a headline; it is written down here so a new install is not a surprise.+The desktop app no longer installs the `jan` command-line agent or adds it to your `PATH`. On Windows, updating from v0.8.4 removes the `jan.exe` it put in the app's `resources\bin` folder, but leaves that folder's entry in your user `PATH`; you can delete the entry. The CLI is now a separate download; see the [agent quickstart](https://jan.ai/docs/agent/quickstart) to install it.+---# Bug Fixes@@ -42,6 +44,7 @@ One thing a first launch will notice: the first-run setup is now a guided wizard- Zoom shortcuts are scoped to chat message text, so zooming a message no longer rescales the whole app.- Hub search ranks exact model id matches first.- The Windows installer template substitutes `jan_workspace` correctly.+- On Windows, the Start-menu and desktop shortcuts keep working after the in-app update renames the app executable.**Agent & Tooling**diff --git a/docs/src/pages/docs/desktop/troubleshooting.mdx b/docs/src/pages/docs/desktop/troubleshooting.mdxindex 3acf64ae9..4aa1c4840 100644--- a/docs/src/pages/docs/desktop/troubleshooting.mdx+++ b/docs/src/pages/docs/desktop/troubleshooting.mdx@@ -496,20 +496,19 @@ The "Unexpected token" error usually relates to OpenAI API authentication or reg## Jan CLI-### Windows: running `jan` opens the Jan application window+### `jan` is not recognized after updating the desktop app-If typing `jan` in a terminal opens the Jan desktop app instead of the CLI, your system is resolving the `jan` command to the app launcher rather than the CLI binary.+Since v0.8.5 the desktop app no longer includes the `jan` CLI or adds it to your `Path`. Updating from an earlier version removes the CLI that was bundled with the app. Install the CLI separately by following the [agent quickstart](/docs/agent/quickstart).-To fix this, add the CLI binary directory to your `Path` environment variable:+On Windows, the update leaves an old entry in your user `Path` that points at a folder with no CLI in it any more. You can remove it:1. Open **System Properties** → **Advanced** → **Environment Variables**-2. Under **System variables** (or **User variables**), select **Path** and click **Edit**-3. Click **New** and add:+2. Under **User variables**, select **Path** and click **Edit**+3. Select this entry and click **Delete**:```C:\Users\<username>\AppData\Local\Programs\Jan\resources\bin```- Replace `<username>` with your Windows username.-4. Click **OK** to save, then open a new terminal window and try `jan` again. The CLI binary is installed as `jan.exe` inside that directory.+4. Click **OK** to save, then open a new terminal window.## Need Further Support?diff --git a/src-tauri/tauri.bundle.windows.nsis.template b/src-tauri/tauri.bundle.windows.nsis.templateindex b231a186f..e85e6120d 100644--- a/src-tauri/tauri.bundle.windows.nsis.template+++ b/src-tauri/tauri.bundle.windows.nsis.template@@ -724,6 +724,13 @@ Function .onInit!if "${INSTALLMODE}" == "both"!insertmacro MULTIUSER_INIT!endif++ ; Captured here rather than in Section Install, where stock Tauri reads it: a+ ; passive upgrade runs the previous uninstaller from PageLeaveReinstall, and+ ; that deletes UNINSTKEY. Read any later, the name is gone, so a renamed main+ ; binary (jan.exe -> Jan-Desktop.exe in 0.8.5) leaves every shortcut pointing+ ; at the deleted exe.+ ReadRegStr $OldMainBinaryName SHCTX "${UNINSTKEY}" "MainBinaryName"FunctionEnd@@ -958,7 +965,6 @@ Section Install!endif; Remove old main binary if it doesn't match new main binary name- ReadRegStr $OldMainBinaryName SHCTX "${UNINSTKEY}" "MainBinaryName"${If} $OldMainBinaryName != ""${AndIf} $OldMainBinaryName != "${MAINBINARYNAME}.exe"Delete "$INSTDIR\$OldMainBinaryName"diff --git a/src-tauri/tests/windows_installer_resources.rs b/src-tauri/tests/windows_installer_resources.rsindex 2e58c1a41..37356be2c 100644--- a/src-tauri/tests/windows_installer_resources.rs+++ b/src-tauri/tests/windows_installer_resources.rs@@ -15,6 +15,65 @@use std::path::PathBuf;+/// The body of `Function <name>` or `Section <name>` up to its terminator.+///+/// Located by byte search rather than by summing line lengths: a Windows+/// checkout has CRLF endings, which `lines()` strips without saying how many+/// bytes it dropped.+fn nsis_block<'a>(template: &'a str, opener: &str, end: &str) -> &'a str {+ let offset = template+ .match_indices(opener)+ .map(|(i, _)| i)+ .find(|&i| {+ let at_line_start = i == 0 || template.as_bytes()[i - 1] == b'\n';+ let after = &template[i + opener.len()..];+ at_line_start && after.trim_start_matches([' ', '\t']).starts_with(['\r', '\n'])+ })+ .unwrap_or_else(|| panic!("`{opener}` not found in the NSIS template"));+ let rest = &template[offset..];+ let stop = rest+ .find(end)+ .unwrap_or_else(|| panic!("`{opener}` has no `{end}`"));+ &rest[..stop]+}++/// The shortcut retarget on a main-binary rename (`jan.exe` -> `Jan-Desktop.exe`+/// in 0.8.5, #9125) needs the previous name from the uninstall key. A passive+/// upgrade runs the old uninstaller from `PageLeaveReinstall`, which deletes that+/// key before `Section Install` runs, so the name has to be captured in+/// `.onInit`, while the key still exists. Reading it in `Section Install` finds+/// nothing and leaves every shortcut pointing at the deleted exe.+#[test]+fn the_previous_main_binary_name_is_read_before_the_old_uninstaller_runs() {+ let template = repo_file("tauri.bundle.windows.nsis.template");+ let read = "ReadRegStr $OldMainBinaryName SHCTX \"${UNINSTKEY}\" \"MainBinaryName\"";++ let on_init = nsis_block(&template, "Function .onInit", "FunctionEnd");+ let read_at = on_init+ .find(read)+ .expect("`.onInit` must read MainBinaryName into $OldMainBinaryName");+ // SHCTX names a hive only once MULTIUSER_INIT has picked the install mode+ // (INSTALLMODE "both"); read before it, the lookup can hit the wrong hive.+ let context_at = on_init+ .find("!insertmacro MULTIUSER_INIT")+ .expect("`.onInit` no longer calls MULTIUSER_INIT; re-check where SHCTX is set");+ assert!(+ read_at > context_at,+ "`.onInit` must read MainBinaryName after MULTIUSER_INIT sets SHCTX"+ );++ let install = nsis_block(&template, "Section Install", "SectionEnd");+ assert!(+ !install.contains("ReadRegStr $OldMainBinaryName"),+ "`Section Install` must not re-read MainBinaryName: by then a passive \+ upgrade has run the old uninstaller, which deleted the key"+ );+ assert!(+ install.contains("WriteRegStr SHCTX \"${UNINSTKEY}\" \"MainBinaryName\""),+ "`Section Install` must still record MainBinaryName for the next update"+ );+}+fn repo_file(rel: &str) -> String {let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(rel);std::fs::read_to_string(&path)