mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 08:03:37 +00:00
* fix(updater): recover Linux .deb/.rpm installs that fail escalation A `.deb` install fails with `No authentication agent found` when the session has no polkit agent. Orca reported "Quit and reopen Orca, then try again" — wrong advice — and its only action was Retry Download, discarding a verified 160 MB package that was still in the updater cache. Keep the one-click install path, but make a failed root-package install recoverable without downloading again: - Retain the downloaded package and its expected SHA-512 from the `update-downloaded` event, mirroring electron-updater's cache-name rule. - Capture the child stderr that BaseUpdater logs but drops from the `error` event, redact it (ANSI, control bytes, `<home>`, `<package>`, `<user>`, 1 KiB cap), and classify the failure. Classification reads the original text — redaction can rewrite a matched phrase. - Send a structured `linux-package-install` recovery status and render a dedicated card: Copy Install Command / Try Automatic Install Again / Show Package. - Revalidate on every action: cache containment, lstat, streamed SHA-512, timingSafeEqual. Concurrent requests coalesce into one hash pass. - Build the command from fixed tokens plus one POSIX-single-quoted absolute path, resolving sudo and the package manager only from /usr/bin, /bin, /usr/sbin, /sbin. Orca never runs it. - Disable `autoInstallOnAppQuit` for .deb/.rpm so an ordinary quit cannot trigger the same failing escalation after the UI is gone. Extracts the error-card presentation into UpdateErrorCardContent so UpdateCard does not absorb another stateful surface. Lifecycle breadcrumbs carry package type, reason, exit code and version — never a path, command, username or raw child output. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Improve Linux package install recovery diagnostics - Distinguish invalid-package-path errors from missing package manager - Expand ANSI escape sequence stripping to handle OSC hyperlinks and DCS - Prevent generic error logs from overwriting specific diagnostic verdicts - Add error handling for shell.openUrl in update UI - Fix test isolation with proper afterEach hooks --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
108 lines
4.0 KiB
TypeScript
108 lines
4.0 KiB
TypeScript
import type { UpdateStatus } from '../shared/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.userInitiated === right.userInitiated &&
|
|
left.activeNudgeId === right.activeNudgeId &&
|
|
// Why: clearing recovery must reach the renderer even when the message is unchanged, or dead actions stay enabled.
|
|
left.recovery?.kind === right.recovery?.kind &&
|
|
left.recovery?.packageType === right.recovery?.packageType &&
|
|
left.recovery?.reason === right.recovery?.reason &&
|
|
left.recovery?.version === right.recovery?.version
|
|
)
|
|
}
|
|
}
|
|
|
|
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')
|
|
)
|
|
}
|