The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(installer): the update stops our own engine instead of tripping over it
purple237969489c36
diff --git a/src-tauri/windows/installer-hooks.nsh b/src-tauri/windows/installer-hooks.nshindex 43c439b4..9b04d269 100644--- a/src-tauri/windows/installer-hooks.nsh+++ b/src-tauri/windows/installer-hooks.nsh@@ -73,7 +73,53 @@${EndIf}!macroend+; Free the bundled engine before the new files land. Live in EVERY build.+;+; aldrich_ironhart, 2026-08-10: the update stopped at "Error opening file for+; writing: D:\Locally Uncensored\llama-server.exe" with Abort, Retry, Ignore.+; llama-server.exe is our own sidecar (externalBin), and Windows locks a running+; image against writes, so the copy cannot succeed while it lives. Rust kills it+; on every orderly exit (state.rs shutdown_subprocesses), which is exactly why+; the installer never accounted for the cases that are left: the app still open+; during a manual install, or a sidecar orphaned by a crash. Retry then loops on+; the same lock and Ignore is worse than it looks, it leaves the new app running+; last release's engine.+;+; The test is the write itself, not a process list: if the file opens for+; writing, nothing holds it and we touch nothing.+!macro LU_FREE_SIDECAR+ Push $R3+ Push $R4+ Push $R9+ StrCpy $R4 0+ ${Do}+ ${IfNot} ${FileExists} "$INSTDIR\llama-server.exe"+ ${ExitDo}+ ${EndIf}+ ClearErrors+ FileOpen $R3 "$INSTDIR\llama-server.exe" a+ ${IfNot} ${Errors}+ FileClose $R3+ ${ExitDo}+ ${EndIf}+ ${If} $R4 >= 4+ ; Still locked after four rounds. Fall through and let the stock error+ ; dialog appear rather than spin here forever.+ ${ExitDo}+ ${EndIf}+ IntOp $R4 $R4 + 1+ nsExec::Exec '"$SYSDIR\taskkill.exe" /F /T /IM "llama-server.exe"'+ Pop $R9+ Sleep 800+ ${Loop}+ Pop $R9+ Pop $R4+ Pop $R3+!macroend+!macro NSIS_HOOK_PREINSTALL+ !insertmacro LU_FREE_SIDECAR+!if "${PRODUCTNAME}" != "Locally Uncensored"!insertmacro LU_REMOVE_OLD_NSIS HKCU!insertmacro LU_REMOVE_OLD_NSIS HKLMdiff --git a/src/lib/__tests__/installer-frees-sidecar.test.ts b/src/lib/__tests__/installer-frees-sidecar.test.tsnew file mode 100644index 00000000..bf031504--- /dev/null+++ b/src/lib/__tests__/installer-frees-sidecar.test.ts@@ -0,0 +1,55 @@+/**+ * The Windows installer has to free our own engine before it copies over it.+ *+ * aldrich_ironhart, 2026-08-10: the update died on "Error opening file for+ * writing: D:\Locally Uncensored\llama-server.exe". Windows locks a running+ * image, and the hook that kills our processes was compiled away in every+ * normal build (it sat behind a productName check that is false today), so+ * nothing ever stopped the sidecar.+ *+ * The name is the fragile part: it appears in the bundle config, in Rust, and+ * in the installer, and a rename in one of them makes the hook silently do+ * nothing again. So all three are compared here, not just the hook.+ *+ * Run: npx vitest run src/lib/__tests__/installer-frees-sidecar.test.ts+ */+import { describe, it, expect } from 'vitest'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { dirname, resolve } from 'node:path'++const here = dirname(fileURLToPath(import.meta.url))+const root = resolve(here, '../../..')+const read = (rel: string) => readFileSync(resolve(root, rel), 'utf8')++const hooks = read('src-tauri/windows/installer-hooks.nsh')+const engineRs = read('src-tauri/src/commands/engine.rs')+const conf = JSON.parse(read('src-tauri/tauri.conf.json')) as {+ bundle?: { externalBin?: string[] }+}++describe('the installer frees the bundled engine', () => {+ it('runs the unlock on every build, not only on a product rename', () => {+ const preinstall = hooks.slice(hooks.indexOf('!macro NSIS_HOOK_PREINSTALL'))+ const insert = preinstall.indexOf('!insertmacro LU_FREE_SIDECAR')+ const rename = preinstall.indexOf('!if "${PRODUCTNAME}"')+ expect(insert).toBeGreaterThan(-1)+ // Before the compile-time rename switch, otherwise it is dead code again.+ expect(insert).toBeLessThan(rename)+ })++ it('asks the only question that matters, can the file be written', () => {+ expect(hooks).toMatch(/FileOpen \$R3 "\$INSTDIR\\llama-server\.exe" a/)+ expect(hooks).toMatch(/taskkill\.exe" \/F \/T \/IM "llama-server\.exe"/)+ // Bounded: a locked file must not spin the installer forever.+ expect(hooks).toMatch(/\$R4 >= 4/)+ })++ it('kills the name the bundle actually ships and Rust actually starts', () => {+ const external = conf.bundle?.externalBin ?? []+ expect(external).toContain('bin/llama-server')+ expect(engineRs).toMatch(/"llama-server\.exe"/)+ const killed = hooks.match(/\/IM "([^"]+)"/g) ?? []+ expect(killed).toContain('/IM "llama-server.exe"')+ })+})