Repository navigation
feat(updates): install new versions by themselves while you're away from the app, so students always run the latest - #380
Merged
Conversation
…rom the app, so students always run the latest With "Perbarui otomatis" on, a downloaded update used to wait for the student to quit, and closing the window only hides the app in the tray, so many students never got it. Now it installs and restarts by itself once the window is in the tray, or the computer has sat idle ten minutes or is locked, never while the window is in front, a hand-in or sign-in is going on, or an answer isn't saved. The app comes back as it was: in the tray, or its window shown without taking focus.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 67 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
github-actions Bot
added a commit
that referenced
this pull request
Nov 17, 2026
- feat(updates): install new versions by themselves while you're away from the app, so students always run the latest (#380)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Outcome
With Perbarui otomatis on (the default), a new version now installs and restarts by itself once the student isn't using the app, so they always run the latest. It comes back as it was: in the tray if it was there, or with its window shown without taking focus.
Why
Updates already downloaded by themselves, but only went in when the student quit. Closing the window only hides the app in the tray, and many students never quit, so a ready update could wait for weeks.
Now main checks every minute, and installs a ready update when the window is closed into the tray, or the computer has sat idle for 10 minutes, or the screen is locked. It never does this while one of the app's windows is in front of an unlocked screen, nor while something the student started would be cut off:
tasks.unsavedaction)The rule is one pure function,
goodMomentToInstall, besidefollowAutoUpdatesinsrc/desktop/self-update.ts.Coming back as it was: just before quitting, the app leaves a short note (
start-quietly, good for 5 minutes) that the next start reads and removes. A note is used because Windows' installer can't pass the app an argument. On a Mac the swap script opens the app withopen -g.Out of scope: the phone (Android needs the student's tap for an APK, an iPhone can't install apps itself; it gets a no-op handler for the new action), how often the update check runs, and the public site. The site goes live as soon as this merges, before a release carries the change, and its sentence ("installs it when you quit") stays true.
Before and after
Settings › Pembaruan, from the demo. The hint now says new versions download and install by themselves when you're not using the app (English: "New versions download and install by themselves when you're not using the app."). The notice shown while an update is ready says the same: "Terpasang sendiri saat kamu tidak memakai aplikasi, atau mulai ulang sekarang." It serves visibility of system status and match with the real world: the switch now says what really happens.
Verification
test/desktop/self-update.test.ts): tray, 10 minutes idle, locked, focused, busy;installAwaygoes once and not again at quit;whenAwayrespects the switch; the note is read only when fresh. Breaking each branch ofgoodMomentToInstall(focused, busy, idle, locked, hidden-vs-shown) makes a test fail.test/desktop/hand-in-busy.test.ts(a hand-in in flight and the file picker).test/app/unsaved-answer-holds-update.test.tsxcovers an unsaved answer and attached files on the real screen, and it fails with the page's signal removed.npm run check: lint and types pass, andmobile/typecheck passes. Tests: 4160 passed. The 4 that fail locally are intest/kit/drift-fix-guard.test.ts, because this machine's Node won't import a.tsfile that test needs. The file is untouched here; CI's Node runs it.<time> hidden, quit, and the new version started on its own; the AppImage's md5 then matched the release. Starting this build with the notehiddenkept the window unmapped past the 6-second fallback, and a second launch brought it back. Withbehind, the window showed withdocument.hasFocus()false. With no note, it showed focused. The note was removed each time.open -g, Cmd+H or minimized counting as shown, the Dock) and Windows (the installer's--force-runstart reading the note,showInactive()). The 10-minute idle and locked paths were not run live either: Xvfb has no window manager or screen lock. Those are covered by the unit tests only.Risk
Medium: the app now restarts itself. If the rule misjudges a moment, a student could see the app reopen, or lose a page they had open in a sign-in window (minimized ones count as open). Turning Perbarui otomatis off stops it entirely.
Follow-ups, not done here: after a renderer crash, main can keep a stale "unsaved" flag and hold the restart until the next save or a quit (safe side). The site's update sentence can say "when you're not using the app" once a release carries this.
Made with
Proved with unit and screen tests,
npm run check, and a packaged AppImage run under Xvfb (above).Reviewed with review-loop: 3 rounds with Claude Fable 5.2 on high effort. Verdict: approved.
Made with Claude Opus 5.5 in Claude Code (in T3 Code).
npm run fixtures:scruband I read its diff.src/core/strings/, in Indonesian and English.