Files
orca/src/main/updater-fallback.ts
T
8cd9751963 fix(updater): keep macOS Orca open when background instances block updates (#24952)
* fix(updater): guard macOS installs against running app instances

* fix(updater): match native app blockers and preserve quit lifecycle

* fix(updater): keep ordinary macOS quit on Squirrel's install-on-exit path

Converting every quit with a staged update into quitAndInstall made Cmd+Q
relaunch Orca, refused the quit when background instances existed, and
hijacked app.relaunch()+app.quit() restart flows (profile switch, admin
restart) into an update install racing the relaunched old app. Only
Update & Restart runs the running-instance preflight now; the
quit-without-install allowance is no longer reachable and is removed.

* fix(updater): preserve quit intent through macOS staging

* test(native-chat): explicitly model legacy published tab ownership

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
2026-10-03 16:27:02 -07:00

108 lines
4.0 KiB
TypeScript

import type { UpdateStatus } from '../shared/update-status-types'
import {
compareAppVersions,
isPrereleaseAppVersion,
isValidAppVersion
} from '../shared/app-version'
export const compareVersions = compareAppVersions
export const isPrereleaseVersion = isPrereleaseAppVersion
export const isValidVersion = isValidAppVersion
export function statusesEqual(left: UpdateStatus, right: UpdateStatus): boolean {
if (left.source !== right.source) {
return false
}
switch (left.state) {
case 'idle':
return right.state === 'idle'
case 'checking':
return right.state === 'checking' && left.userInitiated === right.userInitiated
case 'not-available':
return right.state === 'not-available' && left.userInitiated === right.userInitiated
case 'available':
return (
right.state === 'available' &&
left.version === right.version &&
left.activeNudgeId === right.activeNudgeId &&
left.releaseUrl === right.releaseUrl &&
// Why: fetchChangelog creates a fresh object each time, so reference
// equality is always false. Compare by presence — since update-available
// fires at most once per check cycle, this is sufficient.
Boolean(left.changelog) === Boolean(right.changelog)
)
case 'downloading':
return (
right.state === 'downloading' &&
left.version === right.version &&
left.activeNudgeId === right.activeNudgeId &&
left.percent === right.percent
)
case 'downloaded':
return (
right.state === 'downloaded' &&
left.version === right.version &&
left.activeNudgeId === right.activeNudgeId &&
left.releaseUrl === right.releaseUrl
)
case 'error':
return (
right.state === 'error' &&
left.message === right.message &&
left.version === right.version &&
left.retryable === right.retryable &&
left.retryAction === right.retryAction &&
left.userInitiated === right.userInitiated &&
left.activeNudgeId === right.activeNudgeId &&
// Recovery identity fences async actions, so same-valued recaptures must reach the renderer.
left.recovery === right.recovery
)
}
}
export function isGitHubReleaseTransitionFailure(normalizedMessage: string): boolean {
return (
normalizedMessage.includes('unable to find latest version on github') ||
normalizedMessage.includes('cannot find channel') ||
normalizedMessage.includes('latest.yml') ||
normalizedMessage.includes('latest-mac.yml') ||
normalizedMessage.includes('no published versions on github')
)
}
export function isMissingUpdateManifestFailure(message: string): boolean {
const normalizedMessage = message.toLowerCase()
return (
normalizedMessage.includes('404') &&
(normalizedMessage.includes('cannot find channel') ||
normalizedMessage.includes('latest.yml') ||
normalizedMessage.includes('latest-mac.yml') ||
normalizedMessage.includes('latest-linux.yml'))
)
}
export function isReleaseAssetsPublishingFailure(message: string): boolean {
return message.toLowerCase().includes('latest release assets are still publishing')
}
/** Identifies update-check failures that are transient or infrastructure-related
* (e.g. network blips, GitHub release transitions) and should NOT be surfaced
* to the user as errors. */
export function isBenignCheckFailure(message: string): boolean {
const normalizedMessage = message.toLowerCase()
if (normalizedMessage.includes('net::err_failed')) {
return true
}
// GitHub releases can briefly be in a half-published state while the
// release workflow is creating a draft and uploading update metadata.
// During that window electron-updater may fail the check even though
// nothing is wrong on the client side.
return (
isReleaseAssetsPublishingFailure(message) ||
isGitHubReleaseTransitionFailure(normalizedMessage) ||
normalizedMessage.includes('no published versions on github')
)
}