Skip to content

Commit 0b287a0

Browse files
Check for updates on a timer, not only at startup
checkForUpdate() ran once in onMount, so an app left open for days would never notice a release until it was restarted. A setInterval re-checks every 6 hours while the app is running. The periodic check skips itself while a download/install is in flight (so it can't swap the update object out from under it), and clears a prior dismissal when it finds a version newer than the one on screen — dismissing v0.10.2 shouldn't hide v0.10.3. It stays silent otherwise: the existing banner is the only surfacing, and it appears only when check() returns an update. Folded into the v0.10.2 release alongside the updater-notes work. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3615bec commit 0b287a0

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The heading must be exactly `## vX.Y.Z`, matching the tag. Newest on top.
1717
version number; from here on it shows the actual list of what's new — the notes
1818
you're reading. (You're seeing this because you updated *to* the version that
1919
added it, so this is the first time it appears.)
20+
- **The app now checks for updates on its own while it's open**, every few hours,
21+
so a machine left running for days still finds out about a new version without
22+
being restarted. The check is silent — you'll only ever notice it when there's
23+
actually something new.
2024

2125
## v0.10.1
2226

ROADMAP.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ non-negotiables, each with a test:
136136
GitHub page after publishing (see `RELEASING.md`) so they don't clutter the
137137
in-app notes. Seeds the renderer: rich notes appear on the *next* update after
138138
this one, since the prompt belongs to the installed version.
139+
- **Update checks now run on a timer, not just at startup.** `checkForUpdate` was
140+
called once in `onMount`, so an app left open for days never noticed a release.
141+
A `setInterval` (6 h) re-checks while running; it skips a check that's mid-install
142+
and clears a prior dismissal when a genuinely newer version turns up, so
143+
dismissing one version doesn't hide the next. Silent — it only surfaces when
144+
`check()` returns something.
139145

140146
## Shipped in v0.10.1
141147

src/routes/+page.svelte

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@
274274
let updateBusy = $state(false);
275275
let updateMsg = $state("");
276276
let updateDismissed = $state(false);
277+
// Re-check on a timer so a machine that stays open for days still learns about
278+
// a release without being restarted. Six hours is often enough to catch a
279+
// release the same day without hammering GitHub.
280+
let updateTimer: ReturnType<typeof setInterval> | null = null;
281+
const UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000;
277282
278283
// companion
279284
let cMessages = $state<ChatMsg[]>([]);
@@ -356,6 +361,7 @@
356361
onMount(() => {
357362
interactionClasses().then((c) => (classesVocab = c));
358363
checkForUpdate();
364+
updateTimer = setInterval(checkForUpdate, UPDATE_CHECK_INTERVAL_MS);
359365
dontShowDisclaimer = localStorage.getItem(HIDE_DISCLAIMER_KEY) === "1";
360366
companionOff = localStorage.getItem(COMPANION_OFF_KEY) === "1";
361367
companionChoiceMade = localStorage.getItem(COMPANION_CHOICE_KEY) === "1";
@@ -373,6 +379,7 @@
373379
un.then((f) => f());
374380
unPaired.then((f) => f());
375381
if (lsTimer) clearInterval(lsTimer);
382+
if (updateTimer) clearInterval(updateTimer);
376383
};
377384
});
378385
@@ -391,8 +398,16 @@
391398
}
392399
393400
async function checkForUpdate() {
401+
// Leave a download/install alone — re-checking mid-flight would swap the
402+
// object out from under it.
403+
if (updateBusy) return;
394404
try {
395-
update = await check();
405+
const found = await check();
406+
// If a timer tick turns up a version newer than the one already on screen,
407+
// surface it even if the user dismissed the previous banner — dismissing
408+
// v0.10.2 shouldn't hide v0.10.3.
409+
if (found && found.version !== update?.version) updateDismissed = false;
410+
update = found;
396411
} catch (_) {
397412
// offline, or no published release with an updater manifest yet — ignore
398413
}

0 commit comments

Comments
 (0)