mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 02:17:31 +00:00
* feat(updater): let users delay updates until a release has been public for N days Adds an Update Delay setting (None/1/3/7/14/30 days) for supply-chain safety (#5259). Release age comes from GitHub's Atom feed timestamps and fails closed when unknown. Settings shows the held release with a countdown, a one-off Skip Delay Once, and the updater wakes when a held release clears instead of waiting a day. Co-Authored-By: Claude <noreply@anthropic.com> * fix(updater): satisfy cast, progress-restyle and wall-clock test gates Co-Authored-By: Claude <noreply@anthropic.com> * fix(updater): simplify delay UI and enforce release age across checks * fix(updater): retain ready updates and recheck changed delay settings --------- Co-authored-by: Claude <noreply@anthropic.com>
24 lines
740 B
TypeScript
24 lines
740 B
TypeScript
const DAY_MS = 24 * 60 * 60 * 1000
|
|
|
|
export const UPDATE_DELAY_DAY_OPTIONS: readonly number[] = [0, 1, 3, 7, 14, 30]
|
|
const MAX_UPDATE_DELAY_DAYS = 90
|
|
|
|
/** Settings may come from older/hand-edited profiles; anything invalid means no delay. */
|
|
export function normalizeUpdateDelayDays(value: unknown): number {
|
|
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
return 0
|
|
}
|
|
return Math.min(Math.round(value), MAX_UPDATE_DELAY_DAYS)
|
|
}
|
|
|
|
export function isDelayedUpdatePending(
|
|
delayedUpdate: { availableAt: string },
|
|
now: number
|
|
): boolean {
|
|
return Date.parse(delayedUpdate.availableAt) > now
|
|
}
|
|
|
|
export function updateDelayDaysToMs(days: number): number {
|
|
return normalizeUpdateDelayDays(days) * DAY_MS
|
|
}
|