Update dialog now shows accumulated changes

This commit is contained in:
patben8 committed 2026-10-20 11:54:33 +02:00
1 parent 23a5cd72f4
commit 68128a123e
2 files changed
+75 -42

No files matched your search

+3 -2
View File
@@ -1268,8 +1268,9 @@ Two independent apps that talk over HTTP:
newest non-draft, non-prerelease `v…` tag — NOT `/releases/latest`, since the newest non-draft, non-prerelease `v…` tag — NOT `/releases/latest`, since the
stem engine publishes `engine-v*` releases in the same repo — and, stem engine publishes `engine-v*` releases in the same repo — and,
if its tag's **semver part** is newer than `__APP_VERSION__` — build-number if its tag's **semver part** is newer than `__APP_VERSION__` — build-number
`-b<N>` bumps don't count — shows an update dialog with the release's `-b<N>` bumps don't count — shows an update dialog with the "What's
"What's Changed" bullets; "Skip this version" persists Changed" bullets of EVERY release newer than the running version (paged,
one section per release, newest first); "Skip this version" persists
`skippedUpdateVersion` to userprefs via `/api/prefs`; check failures are `skippedUpdateVersion` to userprefs via `/api/prefs`; check failures are
silent. **In the desktop app, Update installs it** (decided 2026-10-16, silent. **In the desktop app, Update installs it** (decided 2026-10-16,
[the discussion](.claude/discussions/discuss-self-update-2026-10-16.md)): [the discussion](.claude/discussions/discuss-self-update-2026-10-16.md)):
+72 -40
View File
@@ -7,8 +7,10 @@ import { api } from '../api'
* Startup update check against GitHub Releases. * Startup update check against GitHub Releases.
* *
* Compares the running version (`__APP_VERSION__`, baked from package.json at * Compares the running version (`__APP_VERSION__`, baked from package.json at
* build time) with the latest release's tag (`v<version>-b<N>` — only the * build time) with release tags (`v<version>-b<N>` — only the semver part
* semver part counts, so a new build of the same version is NOT an update). * counts, so a new build of the same version is NOT an update). The dialog
* lists the notes of EVERY release newer than the running one, not just the
* latest's.
* Failures are silent: an update check must never nag about itself. * Failures are silent: an update check must never nag about itself.
* "Skip this version" persists `skippedUpdateVersion` to userprefs.json via * "Skip this version" persists `skippedUpdateVersion` to userprefs.json via
* the prefs API, keyed by the semver part, so a later version re-triggers. * the prefs API, keyed by the semver part, so a later version re-triggers.
@@ -36,22 +38,39 @@ interface GithubRelease {
prerelease?: boolean prerelease?: boolean
} }
const MAX_PAGES = 5
/** /**
* The newest APP release. Not `/releases/latest`: that is whichever release * Every APP release newer than the running version, newest first — the first
* GitHub flags "latest", and the same repo also publishes the stem engine on * is the one offered, and all of their notes are shown, so someone several
* its own `engine-v*` channel — one flagged latest by mistake would make this * versions behind sees everything they are getting. Not `/releases/latest`:
* check go quiet (its tag does not parse as an app version) with no error. So * that is whichever release GitHub flags "latest", and the same repo also
* list recent releases (newest first) and take the first app tag. * publishes the stem engine on its own `engine-v*` channel — one flagged
* latest by mistake would make this check go quiet (its tag does not parse as
* an app version) with no error. So list releases (newest first) and keep the
* app tags, paging until one is not newer than the running version.
*/ */
async function fetchLatestRelease(): Promise<GithubRelease> { async function fetchNewerReleases(): Promise<GithubRelease[]> {
const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=30`, { const current = parseVersion(__APP_VERSION__)
headers: { Accept: 'application/vnd.github+json' }, if (!current) return []
}) const newer: GithubRelease[] = []
if (!res.ok) throw new Error(`GitHub responded ${res.status}`) for (let page = 1; page <= MAX_PAGES; page++) {
const releases: GithubRelease[] = await res.json() const res = await fetch(
const app = releases.find((r) => !r.draft && !r.prerelease && /^v\d/.test(r.tag_name)) `https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}`,
if (!app) throw new Error('No app release found') { headers: { Accept: 'application/vnd.github+json' } },
return app )
if (!res.ok) throw new Error(`GitHub responded ${res.status}`)
const releases: GithubRelease[] = await res.json()
for (const r of releases) {
if (r.draft || r.prerelease) continue
const v = parseVersion(r.tag_name)
if (!v || !r.tag_name.startsWith('v')) continue
if (!isNewer(v, current)) return newer
newer.push(r)
}
if (releases.length < 100) break
}
return newer
} }
/** The semver triple at the start of a version/tag string ("v0.1.2-b7" → [0,1,2]). */ /** The semver triple at the start of a version/tag string ("v0.1.2-b7" → [0,1,2]). */
@@ -163,9 +182,9 @@ export function UpdateCheck() {
const [skipVersion, setSkipVersion] = useState(false) const [skipVersion, setSkipVersion] = useState(false)
const [phase, setPhase] = useState<Phase>({ kind: 'offer' }) const [phase, setPhase] = useState<Phase>({ kind: 'offer' })
const release = useQuery({ const releases = useQuery({
queryKey: ['latestRelease'], queryKey: ['newerReleases'],
queryFn: fetchLatestRelease, queryFn: fetchNewerReleases,
staleTime: Infinity, staleTime: Infinity,
retry: false, retry: false,
}) })
@@ -195,11 +214,10 @@ export function UpdateCheck() {
} }
}, [phase.kind]) }, [phase.kind])
const latest = release.data const newer = releases.data ?? []
const latestVer = latest ? parseVersion(latest.tag_name) : null const latest = newer[0]
const currentVer = parseVersion(__APP_VERSION__) const latestSemver = latest ? parseVersion(latest.tag_name)?.join('.') : undefined
const latestSemver = latestVer?.join('.') const updateAvailable = !!latest
const updateAvailable = !!(latestVer && currentVer && isNewer(latestVer, currentVer))
const skipped = !!latestSemver && prefs.data?.skippedUpdateVersion === latestSemver const skipped = !!latestSemver && prefs.data?.skippedUpdateVersion === latestSemver
const failedBefore = lastFailure.data ?? null const failedBefore = lastFailure.data ?? null
const releasePage = latest?.html_url ?? `https://github.com/${REPO}/releases` const releasePage = latest?.html_url ?? `https://github.com/${REPO}/releases`
@@ -262,7 +280,10 @@ export function UpdateCheck() {
? "Update didn't install" ? "Update didn't install"
: 'Update available' : 'Update available'
const changes = latest ? whatsChanged(latest.body) : [] // One section per release the user is skipping past, newest first; a heading
// only when there is more than one, so a one-step update reads as before.
const sections = newer.map((r) => ({ tag: r.tag_name, changes: whatsChanged(r.body) }))
const grouped = sections.length > 1
return createPortal( return createPortal(
<div <div
@@ -312,21 +333,32 @@ export function UpdateCheck() {
</div> </div>
) : ( ) : (
<> <>
<div className="mb-2 text-xs font-medium text-muted">What's changed</div> <div className="mb-2 text-xs font-medium text-muted">
{changes.length ? ( What's changed{grouped ? ` since v${__APP_VERSION__}` : ''}
<ul className="space-y-1.5"> </div>
{changes.map((line, i) => ( <div className="space-y-4">
<li key={i} className="flex gap-2 text-sm text-text"> {sections.map((s) => (
<span className="text-faint">•</span> <section key={s.tag}>
<span className="min-w-0 break-words"> {grouped && (
<ChangelogLine text={line} /> <div className="mb-1.5 text-xs font-semibold text-accent">{s.tag}</div>
</span> )}
</li> {s.changes.length ? (
))} <ul className="space-y-1.5">
</ul> {s.changes.map((line, i) => (
) : ( <li key={i} className="flex gap-2 text-sm text-text">
<div className="text-sm text-faint">No release notes.</div> <span className="text-faint">•</span>
)} <span className="min-w-0 break-words">
<ChangelogLine text={line} />
</span>
</li>
))}
</ul>
) : (
<div className="text-sm text-faint">No release notes.</div>
)}
</section>
))}
</div>
</> </>
)} )}
</div> </div>