Kolibri daemon should be restarted after installing updates
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
After a Flatpak update, a running kolibri-daemon keeps serving the old Kolibri until it exits, so the updated app can talk to an incompatible backend. A user who switches branches (e.g. stable to beta) and relaunches still gets the old version.
Complexity: High Target branch: develop
Context
- The app holds the daemon while any window is open (
kolibri_daemon_manager.py#L272), and each GNOME Shell search restarts its 30 s exit timer. - With no holder, the daemon stops Kolibri after
--stop-timeout(default 60 s, negative for never) and exits 30 s later (application.py#L323-L345). - The daemon publishes its running Kolibri version as the
kolibri_versionD-Bus property (kolibri_process.py#L102); the app'sPROJECT_VERSIONis derived from its bundled Kolibri (app-version.py). Nothing compares them. - The Flatpak portal can report an installed update (
UpdateMonitor) and start the updated app (SpawnwithLATEST_VERSION). It is on the session bus, which a system-service daemon (eos-kolibri) does not have. - The daemon's GApplication sets
ALLOW_REPLACEMENT(application.py#L396-L398), so a new instance started with--gapplication-replacetakes over its bus name. - The app has no in-window notification UI.
The Change
- After an update is installed, the next app launch should run the updated Kolibri, in both session-bus and system-bus mode.
- A window open when the update is installed should keep running on the old Kolibri and alert the user that a restart will switch to the update.
How to Get There
- Download the
org.learningequality.Kolibri.Devel.flatpakartifact from two runs ofpr_build_kolibri.ymlon different commits. - Install the older bundle with
flatpak install --user --bundle, launch the app, and open About from the window menu. - Close the app, install the newer bundle, and relaunch within 60 s.
- About still shows the older Kolibri version.
Out of Scope
- Installing updates from inside the app (the portal's
UpdateMonitor.Updatemethod).
Acceptance Criteria
General
- [ ] After an update is installed with the app closed, relaunching shows the new Kolibri version in About, in session-bus mode and in system-bus mode under eos-kolibri.
- [ ] After an update, GNOME Shell search is answered by a daemon whose
kolibri_versionis the new version. - [ ] A window open when the update is installed keeps working and shows the alert, with Restart Kolibri now as its primary action.
- [ ] Restart Kolibri now closes the app and reopens it, and About then shows the new Kolibri version.
- [ ] In system-bus mode, the daemon keeps the old Kolibri while another desktop user still has a window open.
- [ ] The alert's text is translatable through the app's gettext
_(). - [ ] The alert and its button can be reached by keyboard and are announced by screen readers.
Testing
- [ ]
kolibri_daemon_testscover the daemon switching to the updated Kolibri only once no client holds it. - [ ]
smoke_test.pyinstalls a newer commit of the app while it runs, relaunches it, and asserts that the running daemon comes from the newer commit.
AI usage
I set the scope, the alert's behaviour and the testing requirements; Claude Code checked the daemon's lifecycle on develop and drafted the sections.
@rtibbles Specified enough to proceed. Design:
Detection
- On update, flatpak writes
.updatedinto the old deployment (flatpak-dir.c#L11287-L11292), so running instances see/app/.updated. - Daemon and app each watch it with a
Gio.FileMonitor. No portal, so it works for eos-kolibri's system daemon (flatpak rununder aType=dbussystemd unit).
Daemon
- On
/app/.updated, snapshot the current holders; once they have all released or vanished, exit through the existingEXITEDpath, regardless of--stop-timeout. - Holders acquired after the update don't count: they are updated apps, and
KolibriDaemonManageralready re-activates the daemon when its name vanishes. This stops a restarted app'sHoldfrom pinning the stale daemon. - No holders at update time: exit at once, so relaunches and Shell search activate the new deployment.
App
- On
/app/.updated, each window reveals anAdw.Banner;_()title, button Restart Kolibri now, announced viaGtk.Accessible.announce. - Restart: portal
Spawnofkolibri-gnome --gapplication-replacewithLATEST_VERSION; the frontend gainsALLOW_REPLACEMENT, so the old instance quits on name loss and releases the daemon.
Tests
kolibri_daemon_tests: exits once pre-update holders are gone; stays while one remains; a post-update holder doesn't block it.smoke_test.py: import the bundle into a local repo,flatpak build-commit-froma new commit of the same ref, update to it while the app runs, relaunch, and compareapp-commitin the daemon's/proc/<pid>/root/.flatpak-info.
Assumptions
- An app launched after the update, while another user still holds the system daemon, shows no alert; it moves to the new daemon when the old one exits.
- In system-bus mode, Restart Kolibri now while another user holds the daemon reopens on the old Kolibri; AC 4 covers the sole-holder case.
Plan: After a Flatpak update, the next launch runs the updated Kolibri, and an open window offers Restart Kolibri now.
- [ ] Install from a local repo and add the update phase
- [ ] /simplify Phase 1
- [ ] Quit the superseded daemon
- [ ] /simplify Phase 2
- [ ] Reveal an update banner in every window
- [ ] Restart onto the latest deployment
- [ ] /simplify Phase 3
- [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
- Banner title "Kolibri has been updated. Restart it to use the new version."; if the maintainer wants other wording, it is a one-string edit.
- Each window announces its banner at MEDIUM priority; if duplicates annoy multi-window users, announce from the active window only.
- Restart reopens the default page, not the current one; if users expect the same page, pass the current URI in
Spawn's argv. - A failed
Spawnonly logs a warning and leaves the banner up; if users need feedback, add a toast. - The smoke test's relaunch activates
app.restartover D-Bus; if flatpak-portal can't activate on the runner'sdbus-launchbus, relaunch withkill_app()+launch_app()and AC 4 becomes manual-only. - The update phase runs only when
smoke_test.pyis given a bundle; if CI ever drops the argument, it skips silently. - The frontend is found with
pgrep -f 'kolibri_gnome\.main', as for the daemon; if setproctitle renames it in the flatpak, the smoke check fails until the pattern changes. - AC 2 holds once no pre-update window remains; while one is open, Shell search still reaches the old daemon.
- An app launched after the update while another user holds the system daemon shows no banner; if it should, the daemon must publish its outdatedness over D-Bus.
- Restart Kolibri now while another user holds the system daemon reopens on the old Kolibri; if unacceptable, system-bus mode needs a daemon-side takeover.
- An update during the modal setup wizard leaves the banner unreachable until setup ends; if restart must be reachable there, the dialog needs its own banner.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output