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
feat(update): derselbe Knopf, auf Arch installiert LU sich eben selbst
David42d941ab34fb
diff --git a/src/components/layout/UpdateBadge.tsx b/src/components/layout/UpdateBadge.tsxindex 49796ee4..645bea25 100644--- a/src/components/layout/UpdateBadge.tsx+++ b/src/components/layout/UpdateBadge.tsx@@ -5,7 +5,6 @@ import { useUpdateStore, initUpdateChecker } from '../../stores/updateStore'import { formatBytes } from '../../lib/formatters'import { isTauri } from '../../api/backend'import { ICON_LG } from '../ui/icon-size'-import { HINWEIS_TEXT } from '../../lib/hinweis'export function UpdateBadge() {const {@@ -19,10 +18,10 @@ export function UpdateBadge() {downloadedBytes,totalBytes,errorMessage,+ progressNote,downloadUpdate,installAndRestart,dismissUpdate,- openReleasePage,} = useUpdateStore()const [open, setOpen] = useState(false)@@ -45,10 +44,6 @@ export function UpdateBadge() {const isDownloaded = downloadStatus === 'downloaded'const isInstalling = downloadStatus === 'installing'const isError = downloadStatus === 'error'- // The update exists and is fine; this copy is one LU must not replace by- // itself (pacman, an AppImage in a folder the user cannot write to, an- // install nothing claims). See updateStore for the sentences.- const isUnavailable = downloadStatus === 'unavailable'const canDownload = isTauri() && downloadStatus === 'idle'// A bare 20px icon in the corner is easy to never notice: on 2026-08-05 the@@ -64,9 +59,7 @@ export function UpdateBadge() {? 'Installing': isError? 'Update failed'- : isUnavailable- ? `Update v${latestVersion} by hand`- : `Update to v${latestVersion}`+ : `Update to v${latestVersion}`return (<div ref={ref} className="relative">@@ -179,7 +172,9 @@ export function UpdateBadge() {</div><div className="flex items-center justify-between mt-1"><span className="text-[0.55rem] text-gray-500">- {isDownloaded ? 'Download complete' : `${downloadProgress}%`}+ {/* The steps of LU's own install have a name instead of a+ percentage; the plugin's download has only the bar. */}+ {progressNote ?? (isDownloaded ? 'Download complete' : `${downloadProgress}%`)}</span>{totalBytes > 0 && (<span className="text-[0.55rem] text-gray-600">@@ -190,13 +185,6 @@ export function UpdateBadge() {</div>)}- {/* Why this copy cannot update itself */}- {isUnavailable && errorMessage && (- <div className="px-3 pb-2">- <p className={`text-[0.6rem] ${HINWEIS_TEXT.ruhig} leading-relaxed`}>{errorMessage}</p>- </div>- )}-{/* Error message */}{isError && errorMessage && (<div className="px-3 pb-2">@@ -287,25 +275,6 @@ export function UpdateBadge() {</>)}- {/* State: the in-app updater is not allowed here */}- {isUnavailable && (- <>- <button- onClick={() => { openReleasePage(); setOpen(false) }}- className="flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-md text-[0.65rem] font-medium bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 hover:bg-emerald-500/25 transition-colors"- >- <Download size={11} />- View Release- </button>- <button- onClick={() => { dismissUpdate(); setOpen(false) }}- className="px-2 py-1.5 rounded-md text-[0.65rem] text-gray-500 hover:text-gray-300 hover:bg-white/[0.04] transition-colors"- >- Later- </button>- </>- )}-{/* Dev mode: no in-app install, link to GitHub */}{!isTauri() && downloadStatus === 'idle' && (<>diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex 61408bab..d046abe4 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -46,7 +46,7 @@ import { PermissionSettings } from './PermissionSettings'import { MCPServerSettings } from './MCPServerSettings'import { WorkflowList } from '../agents/WorkflowList'import { WorkflowBuilder } from '../agents/WorkflowBuilder'-import { useUpdateStore, isNewerVersion, installPasswordNotice } from '../../stores/updateStore'+import { useUpdateStore, isNewerVersion } from '../../stores/updateStore'import { backendCall, isTauri, isMacOS, openExternal } from '../../api/backend'import { troubleshootHinweis, type TroubleshootHinweis } from './troubleshoot-message'import { isMlxImageHost } from '../../api/mlx-image'@@ -2250,11 +2250,7 @@ export function SettingsPage() {// ── Update Section ──────────────────────────────────────────────export function UpdateSection() {- const { currentVersion, latestVersion, updateAvailable, releaseNotes, dismissed, isChecking, autoDownload, downloadStatus, downloadProgress, downloadedBytes, totalBytes, errorMessage, installMethod, checkForUpdate, downloadUpdate, installAndRestart, clearDismiss, setAutoDownload, openReleasePage } = useUpdateStore()- // On a deb or rpm the install really is a package install, and polkit or- // sudo will ask for a password. Saying so first is the difference between- // "the system wants my password" and "the app is asking me to log in".- const passwordNotice = installPasswordNotice(installMethod)+ const { currentVersion, latestVersion, updateAvailable, releaseNotes, dismissed, isChecking, autoDownload, downloadStatus, downloadProgress, downloadedBytes, totalBytes, errorMessage, progressNote, checkForUpdate, downloadUpdate, installAndRestart, clearDismiss, setAutoDownload, openReleasePage } = useUpdateStore()// Defensive: only treat the persisted `latestVersion` as actually newer if a// semver compare confirms it. Otherwise the binary was updated out-of-band// and the persisted value is stale (e.g. localStorage still says 2.3.8 while@@ -2306,7 +2302,10 @@ export function UpdateSection() {</div><div className="flex items-center justify-between mt-1"><span className="text-[0.55rem] text-gray-500">- {downloadStatus === 'downloaded' ? 'Download complete' : `${downloadProgress}%`}+ {/* On the lane where LU installs itself the short steps+ after the download report a word instead of a+ percentage they do not have. */}+ {progressNote ?? (downloadStatus === 'downloaded' ? 'Download complete' : `${downloadProgress}%`)}</span>{totalBytes > 0 && (<span className="text-[0.55rem] text-gray-600">@@ -2321,28 +2320,9 @@ export function UpdateSection() {<p className="text-[0.6rem] text-red-400/80 leading-relaxed mb-2.5">{errorMessage}</p>)}- {/* Not a failure: the update is fine, this copy is just not one LU- may replace by itself (pacman, an AppImage in a read-only- folder, a repackaged install). The quiet tone, not the red one- (lib/hinweis.ts). */}- {downloadStatus === 'unavailable' && errorMessage && (- <p data-testid="update-unavailable" className={`text-[0.6rem] ${HINWEIS_TEXT.ruhig} leading-relaxed mb-2.5`}>{errorMessage}</p>- )}-- {/* The password prompt is about to arrive, so it gets announced. */}- {downloadStatus === 'downloaded' && passwordNotice && (- <p data-testid="update-password-notice" className={`text-[0.6rem] ${HINWEIS_TEXT.ruhig} leading-relaxed mb-2.5`}>{passwordNotice}</p>- )}<div className="flex gap-2">- {downloadStatus === 'unavailable' ? (- <button- onClick={openReleasePage}- className="flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[0.6rem] font-medium bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/30 transition-colors"- >- <Download size={11} /> View Release- </button>- ) : !isTauri() ? (+ {!isTauri() ? (<buttononClick={openReleasePage}className="flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[0.6rem] font-medium bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/30 transition-colors"diff --git a/src/components/settings/__tests__/das-update-sagt-warum-es-nicht-geht.test.ts b/src/components/settings/__tests__/das-update-sagt-warum-es-nicht-geht.test.tsdeleted file mode 100644index 3f13094f..00000000--- a/src/components/settings/__tests__/das-update-sagt-warum-es-nicht-geht.test.ts+++ /dev/null@@ -1,128 +0,0 @@-/**- * @vitest-environment jsdom- *- * Zen, Arch Linux, 06.09.2026: the update downloaded, asked for his password- * and then failed. He had installed LU from the AUR package- * locally-uncensored-bin, and the updater plugin cannot tell that apart from a- * Debian install (UPDATER-LINUX-BEFUND.md).- *- * The store refuses the update on those installs. This is about what he SEES- * while it refuses: a sentence naming his own package manager instead of a- * dead Download button, and, on the installs where the update does run a- * package install, a warning that the password prompt is his system's and not- * a login LU is asking for.- *- * Run: npx vitest run src/components/settings/__tests__/das-update-sagt-warum-es-nicht-geht.test.ts- */-import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'-import { createElement } from 'react'-import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'--const openExternal = vi.fn()--vi.mock('../../../api/backend', () => ({- backendCall: vi.fn(async () => ({})),- isTauri: () => true,- isMacOS: () => false,- isLinux: () => true,- isWindows: () => false,- openExternal,- secretGet: vi.fn().mockRejectedValue(new Error('no keychain here')),- secretSet: vi.fn(),- secretDelete: vi.fn(),-}))--const { UpdateSection } = await import('../SettingsPage')-const { useUpdateStore } = await import('../../../stores/updateStore')--const AUR_REFUSAL = 'This copy was installed with your package manager (AUR package '- + 'locally-uncensored-bin). Update it with your AUR helper, for example '- + 'yay -Syu locally-uncensored-bin. The AUR package is maintained by a '- + 'community member and can lag a few days behind the GitHub release.'--async function section(over: Record<string, unknown>) {- useUpdateStore.setState({- currentVersion: '2.6.7',- latestVersion: '2.6.8',- updateAvailable: true,- releaseNotes: null,- isChecking: false,- dismissed: null,- downloadStatus: 'idle',- downloadProgress: 0,- downloadedBytes: 0,- totalBytes: 0,- errorMessage: null,- installMethod: null,- ...over,- })- render(createElement(UpdateSection))- // The section starts folded, like every other one on the page.- fireEvent.click(screen.getByText('Updates'))- await act(async () => { await Promise.resolve() })-}--afterEach(cleanup)-beforeEach(() => { openExternal.mockReset() })--describe('an install LU may not replace', () => {- it('says which package manager owns it instead of offering a download', async () => {- await section({- downloadStatus: 'unavailable',- errorMessage: AUR_REFUSAL,- installMethod: { kind: 'pacman', exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' },- })-- expect(screen.getByTestId('update-unavailable').textContent).toContain('yay -Syu locally-uncensored-bin')- // No dead button: the one thing left to click leads to the release page.- expect(screen.queryByText('Download Update')).toBeNull()- expect(screen.queryByText('Retry')).toBeNull()- fireEvent.click(screen.getByText('View Release'))- expect(openExternal).toHaveBeenCalledTimes(1)- })-- it('names the folder when the AppImage cannot be replaced', async () => {- await section({- downloadStatus: 'unavailable',- errorMessage: 'The AppImage sits in a folder you cannot write to (/opt/LU.AppImage). '- + 'Move it to your home folder or download the new AppImage from the release page.',- installMethod: { kind: 'appimage', exePath: '/opt/LU.AppImage', writable: false, hint: '' },- })-- expect(screen.getByTestId('update-unavailable').textContent).toContain('/opt/LU.AppImage')- })-})--describe('an install LU may replace', () => {- it('warns that the system, not LU, is about to ask for a password', async () => {- await section({- downloadStatus: 'downloaded',- installMethod: { kind: 'deb', exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' },- })-- expect(screen.getByTestId('update-password-notice').textContent).toContain('not an LU login')- // And the install itself is still on offer.- expect(screen.getByText('Restart Now')).toBeTruthy()- })-- it('keeps quiet before there is anything to install', async () => {- await section({- downloadStatus: 'idle',- installMethod: { kind: 'deb', exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' },- })-- expect(screen.queryByTestId('update-password-notice')).toBeNull()- expect(screen.queryByTestId('update-unavailable')).toBeNull()- expect(screen.getByText('Download Update')).toBeTruthy()- })-- it('says nothing extra on a Windows or AppImage install', async () => {- await section({- downloadStatus: 'downloaded',- installMethod: { kind: 'msi', exePath: 'C:/Program Files/LU/LU.exe', writable: true, hint: '' },- })-- expect(screen.queryByTestId('update-password-notice')).toBeNull()- expect(screen.getByText('Restart Now')).toBeTruthy()- })-})diff --git a/src/components/settings/__tests__/das-update-zeigt-den-schritt-statt-eines-hinweises.test.ts b/src/components/settings/__tests__/das-update-zeigt-den-schritt-statt-eines-hinweises.test.tsnew file mode 100644index 00000000..afa57a36--- /dev/null+++ b/src/components/settings/__tests__/das-update-zeigt-den-schritt-statt-eines-hinweises.test.ts@@ -0,0 +1,138 @@+/**+ * @vitest-environment jsdom+ *+ * Zen, Arch Linux, 06.09.2026: the update downloaded, asked for his password+ * and then failed. He had installed LU from the AUR package+ * locally-uncensored-bin, and the updater plugin cannot tell that apart from a+ * Debian install (UPDATER-LINUX-BEFUND.md).+ *+ * The fix is not a sentence explaining that to him. On his install the same+ * two buttons now run LU's own install, and this is about what he SEES while+ * that happens: an ordinary Download button, an ordinary progress bar, and the+ * name of the step for the parts that have no percentage. Nothing that sends+ * him to a release page, nothing that warns him about a password.+ *+ * Run: npx vitest run src/components/settings/__tests__/das-update-zeigt-den-schritt-statt-eines-hinweises.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'++const openExternal = vi.fn()+const backendCall = vi.fn(async (_cmd: string, _args?: Record<string, unknown>) => ({}))++vi.mock('../../../api/backend', () => ({+ backendCall: (cmd: string, args?: Record<string, unknown>) => backendCall(cmd, args),+ isTauri: () => true,+ isMacOS: () => false,+ isLinux: () => true,+ isWindows: () => false,+ openExternal,+ secretGet: vi.fn().mockRejectedValue(new Error('no keychain here')),+ secretSet: vi.fn(),+ secretDelete: vi.fn(),+}))++const { UpdateSection } = await import('../SettingsPage')+const { useUpdateStore } = await import('../../../stores/updateStore')++/** The AUR install, as the Rust probe reports it. */+const AUR = { kind: 'pacman' as const, exePath: '/usr/bin/locally-uncensored', writable: false }++async function section(over: Record<string, unknown>) {+ useUpdateStore.setState({+ currentVersion: '2.6.7',+ latestVersion: '2.6.8',+ updateAvailable: true,+ releaseNotes: null,+ isChecking: false,+ dismissed: null,+ downloadStatus: 'idle',+ downloadProgress: 0,+ downloadedBytes: 0,+ totalBytes: 0,+ errorMessage: null,+ progressNote: null,+ installMethod: null,+ ...over,+ })+ render(createElement(UpdateSection))+ // The section starts folded, like every other one on the page.+ fireEvent.click(screen.getByText('Updates'))+ await act(async () => { await Promise.resolve() })+}++afterEach(cleanup)+beforeEach(() => { openExternal.mockReset(); backendCall.mockClear() })++describe('the install the plugin cannot serve', () => {+ it('offers the ordinary Download button and explains nothing', async () => {+ await section({ installMethod: AUR })++ expect(screen.getByText('Download Update')).toBeTruthy()+ // No dead end and no homework: the old build sent this user to the+ // release page with a paragraph about his AUR helper.+ expect(screen.queryByText('View Release')).toBeNull()+ expect(screen.queryByTestId('update-unavailable')).toBeNull()+ expect(screen.queryByTestId('update-password-notice')).toBeNull()+ })++ it('names the step while the percentage means nothing', async () => {+ await section({+ installMethod: AUR,+ downloadStatus: 'downloading',+ downloadProgress: 100,+ downloadedBytes: 118_000_000,+ totalBytes: 118_000_000,+ progressNote: 'Checking the signature',+ })++ expect(screen.getByText('Checking the signature')).toBeTruthy()+ // The step replaces the percentage rather than sitting next to it.+ expect(screen.queryByText('100%')).toBeNull()+ })++ it('shows bytes and percent while they are still the truth', async () => {+ await section({+ installMethod: AUR,+ downloadStatus: 'downloading',+ downloadProgress: 42,+ downloadedBytes: 50_000_000,+ totalBytes: 118_000_000,+ progressNote: null,+ })++ expect(screen.getByText('42%')).toBeTruthy()+ })++ it('ends on the same Restart button as every other install', async () => {+ await section({ installMethod: AUR, downloadStatus: 'downloaded', downloadProgress: 100 })++ expect(screen.getByText('Restart Now')).toBeTruthy()+ expect(screen.getByText('Download complete')).toBeTruthy()+ expect(screen.queryByTestId('update-password-notice')).toBeNull()+ })+})++describe('the installs that always worked', () => {+ it('says nothing extra on a Debian install either', async () => {+ await section({+ downloadStatus: 'downloaded',+ installMethod: { kind: 'deb', exePath: '/usr/bin/locally-uncensored', writable: false },+ })++ expect(screen.getByText('Restart Now')).toBeTruthy()+ expect(screen.queryByTestId('update-password-notice')).toBeNull()+ })++ it('still shows a failure as a failure, with a Retry', async () => {+ await section({+ installMethod: AUR,+ downloadStatus: 'error',+ errorMessage: 'The update could not be downloaded. the download broke off',+ })++ expect(screen.getByText(/could not be downloaded/)).toBeTruthy()+ expect(screen.getByText('Retry')).toBeTruthy()+ })+})diff --git a/src/components/settings/__tests__/settings-update-and-keys.test.ts b/src/components/settings/__tests__/settings-update-and-keys.test.tsindex 559e9f27..f48e4c76 100644--- a/src/components/settings/__tests__/settings-update-and-keys.test.ts+++ b/src/components/settings/__tests__/settings-update-and-keys.test.ts@@ -26,20 +26,17 @@ describe('Settings update section uses the in-app updater', () => {expect(updateSection).not.toMatch(/onClick=\{openReleasePage\}[\s\S]{0,300}Download Update/)})- it('keeps openReleasePage out of the working download lane', () => {- // Two uses, and neither is the CTA of an update that can install itself.- // The first belongs to a copy the updater is not allowed to replace (an- // AUR install, an AppImage in a folder the user cannot write to, a binary- // no package manager claims), where the release page is the only honest- // next step. The second is the browser fallback outside Tauri.+ it('keeps openReleasePage out of every lane that can install', () => {+ // One use left, and it is the browser fallback outside Tauri. The second+ // one belonged to the installs the updater refused to touch (an AUR+ // install, an AppImage in a folder the user cannot write to, a binary no+ // package manager claims); there LU now installs itself and the release+ // page is not an answer anybody needs.const uses = updateSection.match(/onClick=\{openReleasePage\}/g) ?? []- expect(uses).toHaveLength(2)- const refusalGate = updateSection.indexOf("downloadStatus === 'unavailable' ?")+ expect(uses).toHaveLength(1)const fallbackGate = updateSection.indexOf('!isTauri()')- expect(refusalGate).toBeGreaterThan(-1)- expect(fallbackGate).toBeGreaterThan(refusalGate)- expect(updateSection.indexOf('onClick={openReleasePage}')).toBeGreaterThan(refusalGate)- expect(updateSection.lastIndexOf('onClick={openReleasePage}')).toBeGreaterThan(fallbackGate)+ expect(fallbackGate).toBeGreaterThan(-1)+ expect(updateSection.indexOf('onClick={openReleasePage}')).toBeGreaterThan(fallbackGate)})it('renders download progress from the store', () => {diff --git a/src/stores/__tests__/update-installiert-sich-auf-arch-selbst.test.ts b/src/stores/__tests__/update-installiert-sich-auf-arch-selbst.test.tsnew file mode 100644index 00000000..c96618b8--- /dev/null+++ b/src/stores/__tests__/update-installiert-sich-auf-arch-selbst.test.ts@@ -0,0 +1,332 @@+/**+ * On an install the updater plugin cannot serve, LU installs itself.+ *+ * Zen, Arch Linux, 06.09.2026: "auto update downloads the update, then asks me+ * for a password, I type my user password, then it fails." He installed LU+ * from the AUR package locally-uncensored-bin, which unpacks our .deb into+ * /usr. The updater plugin decides between AppImage, deb and rpm by reading a+ * string the bundler patched into the binary rather than by looking at the+ * machine, so on Arch it picks linux-x86_64-deb out of latest.json, downloads+ * a Debian package and runs `pkexec dpkg -i` on a box with no dpkg. polkit+ * asks for the password first and the command fails afterwards, which is+ * exactly the order he described. Full trace with line numbers in+ * UPDATER-LINUX-BEFUND.md.+ *+ * What is pinned here is that he never has to know any of that: the same+ * Download button fetches the AppImage, the same Restart button puts it in his+ * home folder and starts it, and the plugin's own lane keeps working untouched+ * wherever it does work.+ *+ * Run: npx vitest run src/stores/__tests__/update-installiert-sich-auf-arch-selbst.test.ts+ */+import { describe, it, expect, vi } from 'vitest'++const backendCall = vi.fn()+const linux = { yes: true }++vi.mock('../../api/backend', () => ({+ isTauri: () => true,+ isLinux: () => linux.yes,+ openExternal: vi.fn(),+ backendCall: (cmd: string, args?: Record<string, unknown>) => backendCall(cmd, args),+}))++vi.mock('../../api/engine', () => ({+ stopBundledEngine: vi.fn(async () => {}),+ stopBundledEmbed: vi.fn(async () => {}),+}))++vi.mock('../../../package.json', () => ({ version: '2.6.7' }))++const handle = vi.hoisted(() => ({+ download: vi.fn(),+ install: vi.fn(),+}))++vi.mock('@tauri-apps/plugin-updater', () => ({+ check: vi.fn(async () => ({+ version: '2.6.8',+ body: 'notes',+ download: handle.download,+ install: handle.install,+ })),+}))++/** The progress events the Rust side emits while it installs LU itself. */+const events = vi.hoisted(() => ({+ listener: null as null | ((e: { payload: Record<string, unknown> }) => void),+ unlisten: vi.fn(),+}))++vi.mock('@tauri-apps/api/event', () => ({+ listen: vi.fn(async (_name: string, cb: (e: { payload: Record<string, unknown> }) => void) => {+ events.listener = cb+ return events.unlisten+ }),+}))++const {+ useUpdateStore,+ installsItself,+ parseInstallMethod,+ resetUpdateSession,+} = await import('../updateStore')++/** The answer the Rust command gives, in the shape it gives it. */+function method(over: Record<string, unknown> = {}) {+ return { kind: 'unknown', exe_path: '/usr/bin/locally-uncensored', writable: false, ...over }+}++function reset(kind: unknown) {+ resetUpdateSession()+ handle.download.mockReset()+ handle.install.mockReset()+ handle.download.mockImplementation(async (cb: (e: unknown) => void) => {+ cb({ event: 'Started', data: { contentLength: 100 } })+ cb({ event: 'Progress', data: { chunkLength: 100 } })+ cb({ event: 'Finished' })+ })+ events.listener = null+ events.unlisten.mockReset()+ backendCall.mockReset()+ backendCall.mockImplementation(async (cmd: string) => {+ if (cmd === 'install_method') {+ if (kind instanceof Error) throw kind+ return kind+ }+ if (cmd === 'self_migrate_stage') {+ // The real command reports its download through events on the way.+ events.listener?.({ payload: { phase: 'download', downloaded: 50, total: 100 } })+ events.listener?.({ payload: { phase: 'verify', downloaded: 100, total: 100 } })+ return { version: '2.6.8', bytes: 100, staged: '/home/zen/.local/share/locally-uncensored/x.part' }+ }+ return null+ })+ linux.yes = true+ useUpdateStore.setState({+ currentVersion: '2.6.7',+ latestVersion: null,+ updateAvailable: false,+ releaseNotes: null,+ isChecking: false,+ lastChecked: null,+ dismissed: null,+ autoDownload: true,+ downloadStatus: 'idle',+ downloadProgress: 0,+ downloadedBytes: 0,+ totalBytes: 0,+ errorMessage: null,+ progressNote: null,+ installMethod: null,+ })+}++/** checkForUpdate fires the download without awaiting it. */+const settle = () => new Promise((r) => setTimeout(r, 0))++const calls = (cmd: string) => backendCall.mock.calls.filter(([c]) => c === cmd)++// ── The rule, on its own ──────────────────────────────────────++describe('who installs the update', () => {+ it('takes over on an AUR install, where the plugin would run dpkg', () => {+ expect(installsItself({ kind: 'pacman', exePath: '/usr/bin/locally-uncensored', writable: false })).toBe(true)+ })++ it('takes over on a binary no package manager claims, but only on Linux', () => {+ const m = { kind: 'unknown' as const, exePath: '/usr/bin/locally-uncensored', writable: false }+ linux.yes = true+ expect(installsItself(m)).toBe(true)+ // On macOS an app in /Applications is 'unknown' too, and there the plugin+ // works. Migrating it would be a Linux fix breaking every Mac.+ linux.yes = false+ expect(installsItself(m)).toBe(false)+ linux.yes = true+ })++ it('takes over for an AppImage in a folder the user cannot write to', () => {+ // The plugin's first move there is a rename INSIDE that folder, which+ // fails with EACCES and no prompt at all (updater.rs:1003).+ expect(installsItself({ kind: 'appimage', exePath: '/opt/LU.AppImage', writable: false })).toBe(true)+ expect(installsItself({ kind: 'appimage', exePath: '/home/zen/LU.AppImage', writable: true })).toBe(false)+ })++ it('leaves the lanes that work to the plugin', () => {+ for (const kind of ['deb', 'rpm', 'msi'] as const) {+ expect(installsItself({ kind, exePath: '/usr/bin/locally-uncensored', writable: false })).toBe(false)+ }+ })++ it('treats a missing answer as no answer at all', () => {+ expect(installsItself(null)).toBe(false)+ expect(parseInstallMethod(null)).toBeNull()+ expect(parseInstallMethod({ kind: 'something-new' })).toBeNull()+ expect(parseInstallMethod({ kind: 'pacman' })).toEqual({+ kind: 'pacman', exePath: '', writable: false,+ })+ })+})++// ── The store, end to end ─────────────────────────────────────++describe('the store on an AUR install', () => {+ it('fetches LU s own AppImage instead of the Debian package', async () => {+ reset(method({ kind: 'pacman' }))++ await useUpdateStore.getState().checkForUpdate(true)+ await settle()++ // Not one byte through the plugin: that is the download that ends in+ // pkexec dpkg -i on a box with no dpkg.+ expect(handle.download).not.toHaveBeenCalled()+ expect(calls('self_migrate_stage')).toHaveLength(1)++ const s = useUpdateStore.getState()+ expect(s.updateAvailable).toBe(true)+ expect(s.downloadStatus).toBe('downloaded')+ expect(s.errorMessage).toBeNull()+ })++ it('shows the bytes while they land and names the step after them', async () => {+ reset(method({ kind: 'pacman' }))+ // Hold the command open after its events so the state can be read+ // mid-flight, the way the progress bar sees it.+ let release = () => {}+ backendCall.mockImplementation(async (cmd: string) => {+ if (cmd === 'install_method') return method({ kind: 'pacman' })+ if (cmd === 'self_migrate_stage') {+ events.listener?.({ payload: { phase: 'download', downloaded: 25, total: 100 } })+ events.listener?.({ payload: { phase: 'verify', downloaded: 100, total: 100 } })+ await new Promise<void>((r) => { release = r })+ return { version: '2.6.8', bytes: 100 }+ }+ return null+ })++ const running = useUpdateStore.getState().downloadUpdate()+ await settle()++ const mid = useUpdateStore.getState()+ expect(mid.downloadedBytes).toBe(25)+ expect(mid.totalBytes).toBe(100)+ expect(mid.downloadProgress).toBe(25)+ // The signature check has no length to show, so it says what it is doing.+ expect(mid.progressNote).toBe('Checking the signature')++ release()+ await running+ const done = useUpdateStore.getState()+ expect(done.downloadStatus).toBe('downloaded')+ expect(done.progressNote).toBeNull()+ // The listener is dropped again, or every retry would stack another one.+ expect(events.unlisten).toHaveBeenCalled()+ })++ it('installs and restarts through the backend, not through the plugin', async () => {+ reset(method({ kind: 'pacman' }))+ await useUpdateStore.getState().checkForUpdate(true)+ await settle()++ await useUpdateStore.getState().installAndRestart()++ expect(handle.install).not.toHaveBeenCalled()+ expect(calls('self_migrate_finish')).toHaveLength(1)+ // And the app goes down afterwards, so the new AppImage can take over.+ expect(calls('exit_app')).toHaveLength(1)+ })++ it('never restarts on its own, however far the auto-download got', async () => {+ reset(method({ kind: 'pacman' }))+ await useUpdateStore.getState().checkForUpdate(true)+ await settle()++ // Auto-download ran the whole staging step and stopped there.+ expect(calls('self_migrate_stage')).toHaveLength(1)+ expect(calls('self_migrate_finish')).toHaveLength(0)+ expect(calls('exit_app')).toHaveLength(0)+ })++ it('says so in English when the download fails, and keeps the button alive', async () => {+ reset(method({ kind: 'pacman' }))+ backendCall.mockImplementation(async (cmd: string) => {+ if (cmd === 'install_method') return method({ kind: 'pacman' })+ if (cmd === 'self_migrate_stage') throw new Error('the signature does not match the downloaded file')+ return null+ })++ await useUpdateStore.getState().downloadUpdate()++ const s = useUpdateStore.getState()+ expect(s.downloadStatus).toBe('error')+ expect(s.errorMessage).toContain('The update could not be downloaded.')+ expect(s.errorMessage).toContain('signature')+ expect(s.progressNote).toBeNull()++ // A failed staging leaves nothing to install: Restart must not pretend.+ await useUpdateStore.getState().installAndRestart()+ expect(calls('self_migrate_finish')).toHaveLength(0)+ expect(useUpdateStore.getState().errorMessage).toContain('Download it again.')+ })++ it('asks the backend once, not once per click', async () => {+ reset(method({ kind: 'pacman' }))+ await useUpdateStore.getState().checkForUpdate(true)+ await settle()+ await useUpdateStore.getState().downloadUpdate()++ expect(calls('install_method')).toHaveLength(1)+ })+})++describe('the store on the installs the plugin serves', () => {+ it('downloads and installs a deb exactly as before', async () => {+ reset(method({ kind: 'deb' }))++ await useUpdateStore.getState().checkForUpdate(true)+ await settle()+ expect(handle.download).toHaveBeenCalledTimes(1)+ expect(calls('self_migrate_stage')).toHaveLength(0)+ expect(useUpdateStore.getState().downloadStatus).toBe('downloaded')++ await useUpdateStore.getState().installAndRestart()+ expect(handle.install).toHaveBeenCalledTimes(1)+ expect(calls('self_migrate_finish')).toHaveLength(0)+ })++ it('carries on when the backend does not know the command', async () => {+ // An older backend, or a probe that threw. Not being able to ask is not a+ // reason to withhold an update from someone whose updater works.+ reset(new Error('unknown command install_method'))++ await useUpdateStore.getState().checkForUpdate(true)+ await settle()+ expect(handle.download).toHaveBeenCalledTimes(1)+ expect(useUpdateStore.getState().downloadStatus).toBe('downloaded')++ await useUpdateStore.getState().installAndRestart()+ expect(handle.install).toHaveBeenCalledTimes(1)+ })++ it('takes the AppImage in /opt off the plugin and onto our own install', async () => {+ reset(method({ kind: 'appimage', exe_path: '/opt/LU.AppImage', writable: false }))++ await useUpdateStore.getState().checkForUpdate(true)+ await settle()+ expect(handle.download).not.toHaveBeenCalled()+ expect(calls('self_migrate_stage')).toHaveLength(1)++ await useUpdateStore.getState().installAndRestart()+ expect(handle.install).not.toHaveBeenCalled()+ expect(calls('self_migrate_finish')).toHaveLength(1)+ })++ it('leaves an AppImage the user owns on the plugin s in place swap', async () => {+ reset(method({ kind: 'appimage', exe_path: '/home/zen/LU.AppImage', writable: true }))++ await useUpdateStore.getState().checkForUpdate(true)+ await settle()+ expect(handle.download).toHaveBeenCalledTimes(1)+ expect(calls('self_migrate_stage')).toHaveLength(0)+ })+})diff --git a/src/stores/__tests__/update-laesst-fremde-installationen-in-ruhe.test.ts b/src/stores/__tests__/update-laesst-fremde-installationen-in-ruhe.test.tsdeleted file mode 100644index 0b0736c0..00000000--- a/src/stores/__tests__/update-laesst-fremde-installationen-in-ruhe.test.ts+++ /dev/null@@ -1,250 +0,0 @@-/**- * The in-app updater must not touch a copy it did not install.- *- * Zen, Arch Linux, 06.09.2026: "auto update downloads the update, then asks me- * for a password, I type my user password, then it fails." He installed LU- * from the AUR package locally-uncensored-bin, which unpacks our .deb into- * /usr. The updater plugin decides between AppImage, deb and rpm by reading a- * string the bundler patched into the binary rather than by looking at the- * machine, so on Arch it picks linux-x86_64-deb out of latest.json, downloads- * a Debian package and runs `pkexec dpkg -i` on a box with no dpkg. polkit- * asks for the password first and the command fails afterwards, which is- * exactly the order he described. Full trace with line numbers in- * UPDATER-LINUX-BEFUND.md.- *- * What is pinned here is the refusal: on those installs nothing is downloaded- * and nothing is installed, and the reason is on screen instead. The two lanes- * where the updater does work keep working, deb included, because "be careful"- * that stops a working update is the more expensive bug.- *- * Run: npx vitest run src/stores/__tests__/update-laesst-fremde-installationen-in-ruhe.test.ts- */-import { describe, it, expect, vi } from 'vitest'--const backendCall = vi.fn()-const linux = { yes: true }--vi.mock('../../api/backend', () => ({- isTauri: () => true,- isLinux: () => linux.yes,- openExternal: vi.fn(),- backendCall: (cmd: string, args?: Record<string, unknown>) => backendCall(cmd, args),-}))--vi.mock('../../api/engine', () => ({- stopBundledEngine: vi.fn(async () => {}),- stopBundledEmbed: vi.fn(async () => {}),-}))--vi.mock('../../../package.json', () => ({ version: '2.6.7' }))--const handle = vi.hoisted(() => ({- download: vi.fn(),- install: vi.fn(),-}))--vi.mock('@tauri-apps/plugin-updater', () => ({- check: vi.fn(async () => ({- version: '2.6.8',- body: 'notes',- download: handle.download,- install: handle.install,- })),-}))--const {- useUpdateStore,- updateBlockedBecause,- installPasswordNotice,- parseInstallMethod,- resetInstallMethodProbe,-} = await import('../updateStore')--/** The answer the Rust command gives, in the shape it gives it. */-function method(over: Record<string, unknown> = {}) {- return { kind: 'unknown', exe_path: '/usr/bin/locally-uncensored', writable: false, hint: '', ...over }-}--function reset(kind: unknown) {- resetInstallMethodProbe()- handle.download.mockReset()- handle.install.mockReset()- handle.download.mockImplementation(async (cb: (e: unknown) => void) => {- cb({ event: 'Started', data: { contentLength: 100 } })- cb({ event: 'Progress', data: { chunkLength: 100 } })- cb({ event: 'Finished' })- })- backendCall.mockReset()- backendCall.mockImplementation(async (cmd: string) => {- if (cmd === 'install_method') {- if (kind instanceof Error) throw kind- return kind- }- return null- })- linux.yes = true- useUpdateStore.setState({- currentVersion: '2.6.7',- latestVersion: null,- updateAvailable: false,- releaseNotes: null,- isChecking: false,- lastChecked: null,- dismissed: null,- autoDownload: true,- downloadStatus: 'idle',- downloadProgress: 0,- downloadedBytes: 0,- totalBytes: 0,- errorMessage: null,- installMethod: null,- })-}--/** checkForUpdate fires the download without awaiting it. */-const settle = () => new Promise((r) => setTimeout(r, 0))--// ── The rule, on its own ──────────────────────────────────────--describe('who may be updated in place', () => {- it('refuses a pacman install and names the AUR package', () => {- const reason = updateBlockedBecause({ kind: 'pacman', exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' })- expect(reason).toContain('locally-uncensored-bin')- expect(reason).toContain('yay -Syu')- // The AUR package is somebody else's to publish, and it lagged 2.6.7- // behind 2.6.8 for days. Saying so is the difference between "LU is- // broken" and "the package has not caught up yet".- expect(reason).toContain('community member')- })-- it('lets a deb and an rpm through, and announces the password prompt', () => {- for (const kind of ['deb', 'rpm'] as const) {- const m = { kind, exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' }- expect(updateBlockedBecause(m)).toBeNull()- expect(installPasswordNotice(m)).toContain('not an LU login')- }- })-- it('says nothing about a password where there is none', () => {- for (const kind of ['appimage', 'pacman', 'msi', 'unknown'] as const) {- expect(installPasswordNotice({ kind, exePath: '', writable: true, hint: '' })).toBeNull()- }- })-- it('refuses an AppImage in a folder the user cannot write to, and names it', () => {- const reason = updateBlockedBecause({ kind: 'appimage', exePath: '/opt/LU.AppImage', writable: false, hint: '' })- expect(reason).toContain('/opt/LU.AppImage')- // The plugin's first move is a rename INSIDE that folder, so this fails- // with EACCES and no prompt at all (updater.rs:1003).- expect(reason).toContain('release page')- })-- it('lets an AppImage the user owns update itself', () => {- expect(updateBlockedBecause({ kind: 'appimage', exePath: '/home/zen/LU.AppImage', writable: true, hint: '' })).toBeNull()- })-- it('refuses an unclaimed binary on Linux and allows one everywhere else', () => {- const m = { kind: 'unknown' as const, exePath: '/usr/bin/locally-uncensored', writable: false, hint: '' }- linux.yes = true- expect(updateBlockedBecause(m)).toContain('does not recognise')- // On macOS an app in /Applications is 'unknown' too, and there the- // updater works. Blocking it would break every Mac.- linux.yes = false- expect(updateBlockedBecause(m)).toBeNull()- })-- it('treats a missing answer as no answer at all', () => {- expect(updateBlockedBecause(null)).toBeNull()- expect(parseInstallMethod(null)).toBeNull()- expect(parseInstallMethod({ kind: 'something-new' })).toBeNull()- expect(parseInstallMethod({ kind: 'pacman' })).toEqual({- kind: 'pacman', exePath: '', writable: false, hint: '',- })- })-})--// ── The store, end to end ─────────────────────────────────────--describe('the store on an AUR install', () => {- it('downloads nothing at all', async () => {- reset(method({ kind: 'pacman' }))-- await useUpdateStore.getState().checkForUpdate(true)- await settle()- // The auto-download would otherwise have started right here.- expect(handle.download).not.toHaveBeenCalled()-- await useUpdateStore.getState().downloadUpdate()- expect(handle.download).not.toHaveBeenCalled()-- const s = useUpdateStore.getState()- expect(s.updateAvailable).toBe(true)- expect(s.latestVersion).toBe('2.6.8')- expect(s.downloadStatus).toBe('unavailable')- expect(s.errorMessage).toContain('yay -Syu locally-uncensored-bin')- })-- it('installs nothing either, even when a download somehow finished', async () => {- reset(method({ kind: 'pacman' }))- await useUpdateStore.getState().checkForUpdate(true)- await settle()- useUpdateStore.setState({ downloadStatus: 'downloaded' })-- await useUpdateStore.getState().installAndRestart()- expect(handle.install).not.toHaveBeenCalled()- expect(useUpdateStore.getState().downloadStatus).toBe('unavailable')- })-- it('asks the backend once, not once per click', async () => {- reset(method({ kind: 'pacman' }))- await useUpdateStore.getState().checkForUpdate(true)- await settle()- await useUpdateStore.getState().downloadUpdate()- await useUpdateStore.getState().downloadUpdate()-- const probes = backendCall.mock.calls.filter(([cmd]) => cmd === 'install_method')- expect(probes).toHaveLength(1)- })-})--describe('the store on the installs that do work', () => {- it('downloads and installs a deb exactly as before', async () => {- reset(method({ kind: 'deb' }))-- await useUpdateStore.getState().checkForUpdate(true)- await settle()- expect(handle.download).toHaveBeenCalledTimes(1)- expect(useUpdateStore.getState().downloadStatus).toBe('downloaded')- expect(installPasswordNotice(useUpdateStore.getState().installMethod)).toContain('password')-- await useUpdateStore.getState().installAndRestart()- expect(handle.install).toHaveBeenCalledTimes(1)- })-- it('carries on when the backend does not know the command', async () => {- // An older backend, or a probe that threw. Not being able to ask is not a- // reason to withhold an update from someone whose updater works.- reset(new Error('unknown command install_method'))-- await useUpdateStore.getState().checkForUpdate(true)- await settle()- expect(handle.download).toHaveBeenCalledTimes(1)- expect(useUpdateStore.getState().downloadStatus).toBe('downloaded')-- await useUpdateStore.getState().installAndRestart()- expect(handle.install).toHaveBeenCalledTimes(1)- })-- it('stops the AppImage in /opt before install(), not after', async () => {- reset(method({ kind: 'appimage', exe_path: '/opt/LU.AppImage', writable: false }))-- await useUpdateStore.getState().checkForUpdate(true)- await settle()- expect(handle.download).not.toHaveBeenCalled()-- useUpdateStore.setState({ downloadStatus: 'downloaded' })- await useUpdateStore.getState().installAndRestart()- expect(handle.install).not.toHaveBeenCalled()- expect(useUpdateStore.getState().errorMessage).toContain('/opt/LU.AppImage')- })-})diff --git a/src/stores/updateStore.ts b/src/stores/updateStore.tsindex 46b4d3d4..b1b4b923 100644--- a/src/stores/updateStore.ts+++ b/src/stores/updateStore.ts@@ -45,9 +45,7 @@ export { settledOrTimedOut } from './durability'// ── Types ─────────────────────────────────────────────────────-/** 'unavailable' is not a failure: the update exists, it is fine, and this- * copy of LU is simply not one the in-app updater is allowed to replace. */-type DownloadStatus = 'idle' | 'downloading' | 'downloaded' | 'installing' | 'error' | 'unavailable'+type DownloadStatus = 'idle' | 'downloading' | 'downloaded' | 'installing' | 'error'// ── How this copy of LU was installed ─────────────────────────//@@ -62,7 +60,11 @@ type DownloadStatus = 'idle' | 'downloading' | 'downloaded' | 'installing' | 'er// exists for.//// The Rust command asks the package managers that are installed who owns the-// running file, and the answer decides whether the in-app updater may run.+// running file. Where the answer means the plugin cannot deliver, the same+// Download and Restart buttons run LU's own install instead: it fetches the+// AppImage, checks its signature, puts it in the user's own data folder with a+// start menu entry and starts it. Nothing to read, nothing to do by hand, and+// from the next update on the plugin's ordinary in place swap works.export type InstallKind =| 'appimage' | 'deb' | 'rpm' | 'pacman' | 'msi' | 'unknown'@@ -73,7 +75,6 @@ export interface InstallMethod {/** Whether the folder holding the executable can be written to. Only the* AppImage path cares: replacing it is a rename inside that folder. */writable: boolean- hint: string}const INSTALL_KINDS: readonly string[] = [@@ -89,47 +90,40 @@ export function parseInstallMethod(raw: unknown): InstallMethod | null {kind: kind as InstallKind,exePath: asString(prop(raw, 'exe_path')) ?? '',writable: asBoolean(prop(raw, 'writable')) ?? false,- hint: asString(prop(raw, 'hint')) ?? '',}}-/** Why the in-app updater must not touch this copy, or null when it may.+/** Whether the update runs through LU's own install instead of the plugin.*- * Kept as a plain function so the badge, the settings page and the tests all- * read the same sentence from the same place. */-export function updateBlockedBecause(method: InstallMethod | null): string | null {- if (!method) return null+ * The mirror of self_migrate::migrates_itself, plus the one question the Rust+ * side leaves to its caller: off Linux there is nothing to migrate to. A+ * macOS app in /Applications reports 'unknown' as well, and there the plugin+ * works. */+export function installsItself(method: InstallMethod | null): boolean {+ if (!method || !isLinux()) return falseswitch (method.kind) {+ // pacman owns the files; writing past its database is never allowed. And+ // a binary no package manager claims is our deb, hand unpacked.case 'pacman':- return 'This copy was installed with your package manager (AUR package '- + 'locally-uncensored-bin). Update it with your AUR helper, for example '- + 'yay -Syu locally-uncensored-bin. The AUR package is maintained by a '- + 'community member and can lag a few days behind the GitHub release.'- case 'appimage':- if (method.writable) return null- return `The AppImage sits in a folder you cannot write to (${method.exePath}). `- + 'Move it to your home folder or download the new AppImage from the release page.'case 'unknown':- // A .app in /Applications and a dev build both land here, and on those- // the updater is fine. On Linux it means the binary is somewhere no- // package manager claims it, which is the hand-unpacked install.- if (!isLinux()) return null- return 'This copy was installed by a package manager or script LU does not '- + 'recognise. Download the new version from the release page.'+ return true+ // The plugin replaces an AppImage with a rename INSIDE its folder.+ case 'appimage':+ return !method.writable+ // deb and rpm run a package install with the system's own password+ // prompt, and Windows has its installer. Both work.default:- return null+ return false}}-/** The sentence that has to stand next to the install button on deb and rpm,- * where the update really does run a package install. The password prompt- * comes from polkit or sudo, and a prompt nobody warned about reads like the- * app asking for an account password. */-export function installPasswordNotice(method: InstallMethod | null): string | null {- if (!method) return null- if (method.kind !== 'deb' && method.kind !== 'rpm') return null- return 'Your system will ask for your password to install the package. '- + 'That is the normal Linux package install, not an LU login.'+/** What the backend says while it is installing LU itself. The download half+ * fills the same progress bar the plugin does; the short steps after it get a+ * word instead of a percentage, because they have no length to show. */+const MIGRATION_NOTE: Record<string, string> = {+ verify: 'Checking the signature',+ install: 'Putting the new version in place',+ start: 'Starting the new version',}interface UpdateState {@@ -150,6 +144,10 @@ interface UpdateState {downloadedBytes: numbertotalBytes: numbererrorMessage: string | null+ /** The step LU is on while it installs itself, for the line that otherwise+ * shows a percentage. Null on the plugin's own lane, which has nothing but+ * a download to report. */+ progressNote: string | null/** How this copy got onto the machine. Null until the probe has answered,* and null forever on a build whose backend does not know the command:@@ -158,9 +156,6 @@ interface UpdateState {/** Reads the install method once and caches it. */refreshInstallMethod: () => Promise<InstallMethod | null>- /** Parks the badge on 'unavailable' when this copy must not be updated in- * place, and answers with the reason. Null means carry on. */- refuseUpdate: () => Promise<string | null>/** `force` skips the 6h cooldown — for a user-triggered check, and for* the download path when the Update handle is missing. */@@ -183,14 +178,23 @@ const INITIAL_DELAY = 5_000let _pendingUpdate: Update | null = null+/** The version LU downloaded for its own install, and the sign that the+ * staged AppImage from `self_migrate_stage` is still lying next to the app.+ * Module level for the same reason `_pendingUpdate` is: it does not survive+ * the process, and a rehydrated 'downloaded' would offer a Restart with+ * nothing behind it. */+let _stagedSelfInstall: string | null = null+/** In flight or already answered, so a startup check and a click on Download* do not run the same three subprocesses twice. Cleared again when the probe* came back empty, so a later attempt can still get an answer. */let _methodProbe: Promise<InstallMethod | null> | null = null-/** Test seam: drop the cached probe. */-export function resetInstallMethodProbe() {+/** Test seam: forget everything that only lives in this process, which is the+ * cached probe and the AppImage staged for LU's own install. */+export function resetUpdateSession() {_methodProbe = null+ _stagedSelfInstall = null}async function readInstallMethod(): Promise<InstallMethod | null> {@@ -236,6 +240,7 @@ export const useUpdateStore = create<UpdateState>()(downloadedBytes: 0,totalBytes: 0,errorMessage: null,+ progressNote: null,installMethod: null,refreshInstallMethod: async () => {@@ -248,19 +253,6 @@ export const useUpdateStore = create<UpdateState>()(return method},- refuseUpdate: async () => {- const reason = updateBlockedBecause(await get().refreshInstallMethod())- if (reason) {- set({- downloadStatus: 'unavailable',- errorMessage: reason,- downloadProgress: 0,- downloadedBytes: 0,- })- }- return reason- },-checkForUpdate: async (force = false) => {const state = get()if (state.isChecking) return@@ -295,16 +287,11 @@ export const useUpdateStore = create<UpdateState>()(downloadedBytes: 0,totalBytes: 0,errorMessage: null,+ progressNote: null,}: {}),})- // Ask who owns this copy before anything is fetched. On the- // installs where the updater would fail (or would have to walk- // past a package database) this parks the badge on a sentence- // that says what to do instead, and nothing is downloaded.- if (await get().refuseUpdate()) return-// Fetch it now rather than waiting for a click. Sign-ups in the// app were still arriving from 2.5.5 and 2.5.6 builds weeks after// 2.5.7 shipped: people were not refusing the update, they were@@ -359,9 +346,13 @@ export const useUpdateStore = create<UpdateState>()(},downloadUpdate: async () => {- // Nothing is fetched for a copy that must not be updated in place.- // 100 MB that can never be installed is worse than no download at all.- if (await get().refuseUpdate()) return+ // Where the plugin cannot deliver, LU fetches its own AppImage+ // instead. Same button, same progress bar, and nothing on screen says+ // which of the two lanes ran.+ if (installsItself(await get().refreshInstallMethod())) {+ await downloadOwnInstall(set)+ return+ }// The Update handle lives in this process only. `updateAvailable` is// persisted, so after a relaunch — or when the startup check has not@@ -411,15 +402,15 @@ export const useUpdateStore = create<UpdateState>()(},installAndRestart: async () => {- // Second gate, because a download that started before the probe- // answered must still not end in an install. This is the one that- // catches the AppImage in /opt: the plugin's first move there is a- // rename it has no right to make.- if (await get().refuseUpdate()) return-- if (!_pendingUpdate) {- // Nothing was downloaded in THIS process — same dead-button problem- // as above, and here a re-check would not help.+ // The install method decides the lane, not whichever handle happens to+ // be lying around. checkForUpdate fills `_pendingUpdate` on every+ // install, this one included, so asking it instead would send an Arch+ // box back into `pkexec dpkg -i` the moment our own download failed.+ const ownInstall = installsItself(await get().refreshInstallMethod())+ const handle = _pendingUpdate+ if (ownInstall ? _stagedSelfInstall === null : !handle) {+ // Nothing was downloaded in THIS process, same dead-button problem+ // as in downloadUpdate, and here a re-check would not help.set({downloadStatus: 'error',errorMessage: 'The downloaded update was lost when the app restarted. Download it again.',@@ -483,13 +474,27 @@ export const useUpdateStore = create<UpdateState>()(await new Promise((r) => setTimeout(r, UPDATE_SETTLE_MS))- await _pendingUpdate.install()+ if (ownInstall) {+ // Puts the checked AppImage in place, gives it a start menu entry+ // of its own and starts it. The new process waits for this one to+ // be gone before it opens a window, because single instance would+ // otherwise send it straight back here.+ const stop = await followMigration(set)+ try {+ await backendCall('self_migrate_finish')+ } finally {+ stop()+ }+ } else if (handle) {+ await handle.install()+ }// Exit so the installer can overwrite the binaryawait backendCall('exit_app')} catch (e) {set({downloadStatus: 'error',errorMessage: withDetail('The update could not be installed.', e),+ progressNote: null,})}},@@ -558,6 +563,73 @@ export const useUpdateStore = create<UpdateState>()(// ── Helpers ───────────────────────────────────────────────────+/** One patch of update state, the shape zustand's `set` takes. */+type Patch = (partial: Partial<UpdateState>) => void++/** Follow the backend while it installs LU itself.+ *+ * The plugin reports its download through a callback; this one reports the+ * same thing through an event, because the work happens in Rust. Everything+ * lands in the same three fields, so the progress bar does not know the+ * difference. Losing the events costs a moving bar and nothing else, which is+ * why nothing here can fail the update. */+async function followMigration(set: Patch): Promise<() => void> {+ if (!isTauri()) return () => {}+ try {+ const { listen } = await import('@tauri-apps/api/event')+ return await listen<{ phase: string; downloaded: number; total: number }>(+ 'update-migration',+ ({ payload }) => {+ if (payload.phase === 'download') {+ const total = payload.total ?? 0+ set({+ downloadedBytes: payload.downloaded ?? 0,+ totalBytes: total,+ downloadProgress: total > 0 ? Math.round(((payload.downloaded ?? 0) / total) * 100) : 0,+ progressNote: null,+ })+ return+ }+ set({ progressNote: MIGRATION_NOTE[payload.phase] ?? null })+ },+ )+ } catch (e) {+ log.warn('[update] the self install runs without progress events', { err: detailOf(e) })+ return () => {}+ }+}++/** Fetch and check the AppImage LU will install into the home folder.+ *+ * Stops at the checked file: installing it restarts the app, and nothing+ * restarts the app without a click, auto-download or not. */+async function downloadOwnInstall(set: Patch): Promise<void> {+ set({+ downloadStatus: 'downloading',+ downloadProgress: 0,+ downloadedBytes: 0,+ totalBytes: 0,+ errorMessage: null,+ progressNote: null,+ })+ const stop = await followMigration(set)+ try {+ const staged = await backendCall('self_migrate_stage')+ _stagedSelfInstall = asString(prop(staged, 'version')) ?? ''+ set({ downloadStatus: 'downloaded', downloadProgress: 100, progressNote: null })+ } catch (e) {+ _stagedSelfInstall = null+ set({+ downloadStatus: 'error',+ errorMessage: withDetail('The update could not be downloaded.', e),+ progressNote: null,+ })+ } finally {+ stop()+ }+}++function truncateNotes(notes: string): string {const lines = notes.split('\n').filter(l => l.trim()).slice(0, 5)const text = lines.join('\n')