feat(update): tell sideloaded installs that a newer version exists (#179)

AGE-110: 64% of 30d-active users sit on v0.4.10 and 0.2% on the newest
build, so a client-side fix (the AGE-105 Sentry noise gate) reaches almost
nobody. Play hygiene fixes one channel; the direct APK, the self-hosted
F-Droid repo and third-party mirrors have no update mechanism at all — a
device installed from a downloaded APK has literally no way to learn a newer
version exists.

- src/lib/update-check-policy.ts: pure, node --test'able decision logic —
  numeric version compare (a string compare puts 0.4.10 BEFORE 0.4.9, i.e.
  it would have told the largest stale cohort it was current), a 24h check
  throttle that survives a backwards clock, per-version dismissal, and a
  cached last-known-latest so the affordance survives between checks
- src/lib/update-check.ts: Android-only runtime wiring. One unauthenticated
  GET per 24h to the GitHub releases API (every non-Play channel is
  downstream of a GitHub release; expo-updates cannot replace a native
  binary, which is what this cohort needs). Never throws.
- UpdateBanner on the sessions list: one dismissible strip, no modal.
  "Not now" sticks for that version only.
- Settings "Version" row showed a hard-coded "1.0.0" for every build ever
  shipped. It now shows the real version, plus "0.4.10 -> 0.4.14" when an
  update exists (ignoreDismissed: dismissal silences the banner, not the
  place a user goes to check).
- en/zh-Hans strings, catalog parity kept.

Tests: 19 new cases in update-check-policy.test.ts; full suite 300 pass,
tsc --noEmit clean.

Co-authored-by: engineer <engineer@macbookpro.lan>
Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Den
2026-08-14 09:45:54 -07:00
committed by GitHub
parent dde4553016
commit 54ddc64c74
8 changed files with 724 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import type BottomSheet from "@gorhom/bottom-sheet"
import type { Session, Project } from "../../src/lib/sdk"
import { DirectorySwitcher, DirectoryBrowserSheet } from "../../src/components/chat"
import { groupByDirectory } from "../../src/lib/session-grouping"
import { UpdateBanner } from "../../src/components/UpdateBanner"
import { nameOf } from "../../src/lib/path-utils"
import { SETUP_GUIDE_URL } from "../../src/lib/links"
@@ -548,6 +549,8 @@ export default function SessionsScreen() {
</View>
)}
<UpdateBanner isDark={isDark} />
<FlatList
data={rows}
keyExtractor={(row) => (row.type === "header" ? `dir:${row.directory}` : row.session.id)}

View File

@@ -1,4 +1,4 @@
import { useCallback, useState } from "react"
import { useCallback, useEffect, useState } from "react"
import {
View,
Text,
@@ -23,6 +23,7 @@ import {
import type { Category } from "../../src/lib/notifications"
import { hasTelemetryConsent, setTelemetryConsent } from "../../src/lib/telemetry"
import { PRIVACY_POLICY_URL } from "../../src/lib/links"
import { CURRENT_VERSION, checkForUpdate, type AvailableUpdate } from "../../src/lib/update-check"
import type { LocalePreference } from "../../src/lib/i18n/locale-resolve"
function SettingRow({
@@ -79,6 +80,23 @@ export default function SettingsScreen() {
const [osGranted, setOsGranted] = useState<boolean | null>(null)
const [telemetryUpdating, setTelemetryUpdating] = useState(false)
// Settings is where a user goes to ask "what am I running?". Answer it, and if
// a newer build exists say so here too — the banner on the sessions list is
// dismissible, this row is not (AGE-110). Uses the same 24h-throttled check,
// so opening Settings repeatedly costs no extra requests.
const [updateAvailable, setUpdateAvailable] = useState<AvailableUpdate | null>(null)
useEffect(() => {
let cancelled = false
checkForUpdate({ ignoreDismissed: true })
.then((result) => {
if (!cancelled) setUpdateAvailable(result)
})
.catch(() => undefined)
return () => {
cancelled = true
}
}, [])
// Telemetry consent: hasTelemetryConsent() returns null (unknown), true, or false.
// We initialise local state from in-memory value; updates call setTelemetryConsent().
const [crashReporting, setCrashReporting] = useState<boolean>(hasTelemetryConsent() ?? false)
@@ -247,7 +265,25 @@ export default function SettingsScreen() {
onPress={handleLanguagePress}
right={<Ionicons name="chevron-forward" size={20} color={isDark ? "#666666" : "#999999"} />}
/>
<SettingRow icon="information-circle" label={t("settings.about.version")} description="1.0.0" isDark={isDark} />
<SettingRow
icon="information-circle"
label={t("settings.about.version")}
// Was hard-coded "1.0.0" — wrong for every build ever shipped, and the
// one place a user could have checked what they are running while 64%
// of the base sat on a four-week-old build (AGE-110).
description={
updateAvailable
? `${CURRENT_VERSION} → ${updateAvailable.version}`
: `${CURRENT_VERSION} · ${t("update.upToDate")}`
}
isDark={isDark}
onPress={updateAvailable ? () => Linking.openURL(updateAvailable.url) : undefined}
right={
updateAvailable ? (
<Ionicons name="arrow-up-circle" size={20} color={isDark ? "#7dd3fc" : "#0369a1"} />
) : undefined
}
/>
<SettingRow
icon="logo-github"
label={t("settings.about.github.label")}