kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Kolibri daemon should be restarted after installing updates

Open dylanmccall opened this issue 3 years ago • 2 comments

❌ 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_version D-Bus property (kolibri_process.py#L102); the app's PROJECT_VERSION is 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 (Spawn with LATEST_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-replace takes 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

  1. Download the org.learningequality.Kolibri.Devel.flatpak artifact from two runs of pr_build_kolibri.yml on different commits.
  2. Install the older bundle with flatpak install --user --bundle, launch the app, and open About from the window menu.
  3. Close the app, install the newer bundle, and relaunch within 60 s.
  4. About still shows the older Kolibri version.

Out of Scope

  • Installing updates from inside the app (the portal's UpdateMonitor.Update method).

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_version is 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_tests cover the daemon switching to the updated Kolibri only once no client holds it.
  • [ ] smoke_test.py installs 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.

dylanmccall avatar Dec 12 '22 18:12 dylanmccall

@rtibbles Specified enough to proceed. Design:

Detection

  • On update, flatpak writes .updated into 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 run under a Type=dbus systemd unit).

Daemon

  • On /app/.updated, snapshot the current holders; once they have all released or vanished, exit through the existing EXITED path, regardless of --stop-timeout.
  • Holders acquired after the update don't count: they are updated apps, and KolibriDaemonManager already re-activates the daemon when its name vanishes. This stops a restarted app's Hold from 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 an Adw.Banner; _() title, button Restart Kolibri now, announced via Gtk.Accessible.announce.
  • Restart: portal Spawn of kolibri-gnome --gapplication-replace with LATEST_VERSION; the frontend gains ALLOW_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-from a new commit of the same ref, update to it while the app runs, relaunch, and compare app-commit in 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.

rtibblesbot avatar Sep 26 '26 03:09 rtibblesbot

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 Spawn only logs a warning and leaves the banner up; if users need feedback, add a toast.
  • The smoke test's relaunch activates app.restart over D-Bus; if flatpak-portal can't activate on the runner's dbus-launch bus, relaunch with kill_app() + launch_app() and AC 4 becomes manual-only.
  • The update phase runs only when smoke_test.py is 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

rtibblesbot avatar Sep 26 '26 03:09 rtibblesbot