CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Build & Quality Checks (push) Canceled after 53s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
A friend's update failed ten times in a row ("Update check failed: error
sending request for url (…nsis.zip)") before the 11th went through, and
he didn't know what to do. The label was also wrong: the check had
worked; the download failed.
- Progress: "Downloading update… 28% (14.3 MB of 49.9 MB)", "The update
server didn't respond. Trying again in 3 s (attempt 2 of 4)…", from the
native `lotus-update-progress` events (cinny-desktop retries itself).
- Failures name the step (check / download / install, from the native
error prefix) in plain language, with Try again and a Download
installer button (Windows: the setup .exe; else the release page), and
the raw error under "Details".
- Installing from the update toast now shows a "Downloading update"
toast, and on failure a sticky "Update didn't install" toast that
retries on click and points at Settings → General → App Updates.
Before, the toast vanished and the failure was only visible in Settings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
50 lines
2.4 KiB
TypeScript
50 lines
2.4 KiB
TypeScript
/** Which step of the desktop update failed (the native side prefixes its errors). */
|
||
export type UpdatePhase = 'check' | 'download' | 'install';
|
||
|
||
/** Where to get the installer by hand when the in-app update keeps failing. */
|
||
export const MANUAL_DOWNLOAD_URL = {
|
||
windows:
|
||
'https://code.lotusguild.org/LotusGuild/cinny-desktop/releases/download/latest/LotusChat-x86_64-setup.exe',
|
||
other: 'https://code.lotusguild.org/LotusGuild/cinny-desktop/releases/tag/latest',
|
||
};
|
||
|
||
export const manualDownloadUrl = (userAgent: string): string =>
|
||
/Windows/i.test(userAgent) ? MANUAL_DOWNLOAD_URL.windows : MANUAL_DOWNLOAD_URL.other;
|
||
|
||
const NETWORK_PATTERN =
|
||
/error sending request|timed out|timeout|connection|connect|dns|network|reset|refused|unreachable|Could not fetch a valid release/i;
|
||
|
||
export const isNetworkUpdateError = (message: string): boolean => NETWORK_PATTERN.test(message);
|
||
|
||
/** Split `download: error sending request …` into its phase and the raw message. */
|
||
export const parseUpdateError = (
|
||
raw: string,
|
||
fallback: UpdatePhase,
|
||
): { phase: UpdatePhase; message: string } => {
|
||
const match = /^(check|download|install): ([\s\S]*)$/.exec(raw);
|
||
return match
|
||
? { phase: match[1] as UpdatePhase, message: match[2] }
|
||
: { phase: fallback, message: raw };
|
||
};
|
||
|
||
/**
|
||
* A plain-language sentence for an update failure. The raw error ("error
|
||
* sending request for url (…nsis.zip)") told users nothing about what to do.
|
||
*/
|
||
export const describeUpdateError = (phase: UpdatePhase, message: string): string => {
|
||
const network = isNetworkUpdateError(message);
|
||
if (phase === 'check') {
|
||
return network
|
||
? 'Couldn’t reach the update server. It may be busy, or your connection dropped. Lotus Chat still works; try again in a minute.'
|
||
: 'Couldn’t check for updates. Lotus Chat still works; try again later.';
|
||
}
|
||
if (phase === 'download') {
|
||
return network
|
||
? 'The update didn’t finish downloading after several tries. The update server may be busy. Try again in a minute, or download the installer yourself.'
|
||
: /signature|minisign|base64/i.test(message)
|
||
? 'The downloaded update didn’t pass its safety check, so it wasn’t installed. Try again, or download the installer yourself.'
|
||
: 'The update couldn’t be downloaded. Try again, or download the installer yourself.';
|
||
}
|
||
return 'The update downloaded but couldn’t be installed. Download the installer yourself and run it; your chats and settings are kept.';
|
||
};
|