Skip to content

feat(updates): install new versions by themselves while you're away from the app, so students always run the latest - #380

Merged
pablonification merged 1 commit into
mainfrom
feat/update-while-away
Nov 16, 2026
Merged

pablonification merged 1 commit into
mainfrom
feat/update-while-away

Conversation

@pablonification

Copy link
Copy Markdown
Owner

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:

  • a hand-in on its way, including an open file picker
  • an answer typed or files attached and not saved yet (the page tells main with a new tasks.unsaved action)
  • an open sign-in, Edunex or SIX window, minimized ones included
  • the first-time tray question

The rule is one pure function, goodMomentToInstall, beside followAutoUpdates in src/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 with open -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.

Light Dark
Before Settings before, light Settings before, dark
After Settings after, light Settings after, dark

Verification

  • Unit tests for the rule (test/desktop/self-update.test.ts): tray, 10 minutes idle, locked, focused, busy; installAway goes once and not again at quit; whenAway respects the switch; the note is read only when fresh. Breaking each branch of goodMomentToInstall (focused, busy, idle, locked, hidden-vs-shown) makes a test fail.
  • Busy signals: test/desktop/hand-in-busy.test.ts (a hand-in in flight and the file picker). test/app/unsaved-answer-holds-update.test.tsx covers 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, and mobile/ typecheck passes. Tests: 4160 passed. The 4 that fail locally are in test/kit/drift-fix-guard.test.ts, because this machine's Node won't import a .ts file that test needs. The file is untouched here; CI's Node runs it.
  • A packaged AppImage on Linux (Xvfb): a build of this branch numbered alpha.34 downloaded the real alpha.35 by itself (only the changed parts). It did not install across a minute with its window on screen. Once the window was closed into the tray, it installed at the next minute, wrote the note <time> hidden, quit, and the new version started on its own; the AppImage's md5 then matched the release. Starting this build with the note hidden kept the window unmapped past the 6-second fallback, and a second launch brought it back. With behind, the window showed with document.hasFocus() false. With no note, it showed focused. The note was removed each time.
  • Not checked by hand: macOS (open -g, Cmd+H or minimized counting as shown, the Dock) and Windows (the installer's --force-run start 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).

  • Nothing personal: no real names, student numbers, emails, grades, meeting links, tokens or course content, pictures included.
  • New test data is made up, or comes from npm run fixtures:scrub and I read its diff.
  • Every new word on screen is in src/core/strings/, in Indonesian and English.
  • Any new saved field (in saved data or Settings) is optional with a default, so data saved by older versions still loads.

…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.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 39e9dc0 and 0461c37.

Files selected for processing: 15

  • docs/install.md
  • mobile/src/host/tasks.ts
  • src/app/screens/tasks.tsx
  • src/core/actions/tasks.ts
  • src/core/strings/updates.ts
  • src/desktop/hand-in.ts
  • src/desktop/handlers/context.ts
  • src/desktop/main.ts
  • src/desktop/self-update.ts
  • src/desktop/updater.ts
  • src/engine/updates.ts
  • test/app/unsaved-answer-holds-update.test.tsx
  • test/app/updates.test.tsx
  • test/desktop/hand-in-busy.test.ts
  • test/desktop/self-update.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions github-actions Bot added documentation Improvements or additions to documentation area:app The window: screens, words and look area:engine Reading Edunex, SIX and ITB; alerts; saved data area:desktop The desktop side: windows, sign-in, files, packaging tests Tests and test data security-sensitive Touches sessions, tokens, the window's locks, packaging or workflows: look carefully area:mobile The phone app, Android and iPhone size/M Under 500 changed lines labels Nov 16, 2026
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 67 complexity · 0 duplication

Metric Results
Complexity 67
Duplication 0

View in Codacy

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.

@pablonification
pablonification merged commit cd0ecb9 into main Nov 16, 2026
25 checks passed
@pablonification
pablonification deleted the feat/update-while-away branch November 16, 2026 08:27
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:app The window: screens, words and look area:desktop The desktop side: windows, sign-in, files, packaging area:engine Reading Edunex, SIX and ITB; alerts; saved data area:mobile The phone app, Android and iPhone documentation Improvements or additions to documentation security-sensitive Touches sessions, tokens, the window's locks, packaging or workflows: look carefully size/M Under 500 changed lines tests Tests and test data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant