Skip to content

Spec: update download progress #393

Done
3 of 3 issues completed
Done

Description

@jtklein-agents

Problem Statement

When RAxML-GUI finds an update and the user clicks Yes in Found Updates, nothing visible happens until Install Updates appears. On a slow connection that can take minutes. The user can't tell whether the download is running, stuck, or broken. The user may start a run that dies when the app quits to install, or may quit the app and drop the download. Progress existed before the shell migration (through electron-progressbar). It was removed because that library needs Node in its window, and the standing rule keeps nodeIntegration off, context isolation on, and sandbox on.

Solution

During the Update download (the stretch from accepting Found Updates until Install Updates appears), the main page shows a small modal dialog titled Downloading update. It has a progress bar, a percent, and one status line. The Dock (macOS) or taskbar (Windows, Linux) icon shows the same progress. The dialog can't be dismissed. When the download finishes, the native Install Updates dialog takes over as it does today. If the download fails, the dialog closes, the Dock/taskbar bar clears, and the existing native error box appears. This works on all three packaged targets: macOS zip, Windows NSIS, and Linux AppImage. It covers both full and differential downloads.

User Stories

  1. As a user who clicked Yes in Found Updates, I want a dialog to appear at once, so that I know my choice was accepted.
  2. As a user waiting for the first bytes, I want an animated (indeterminate) bar with "Starting…" and "Connecting to the update server…", so that I know the app is working before any progress figures arrive.
  3. As a user downloading an update, I want a bar that fills with the download and a rounded percent beside it, so that I can judge how long is left.
  4. As a user downloading an update, I want the status line to say "RAxML-GUI will quit and install when the download finishes.", so that I'm not surprised when the app closes.
  5. As a user, I want the dialog to have no close button and to ignore Escape, so that I can't hide it and then start a run that dies when the app quits to install.
  6. As a user, I want the dialog titled Downloading update, so that I know what it is at a glance.
  7. As a user whose differential download falls back to a full one, I want the status line to read "Retrying with the full download…" when the bar jumps back, so that the backwards jump doesn't look like a bug.
  8. As a user whose download reaches 100%, I want the status line to read "Download complete. Preparing to install…", so that I know the next step is the install.
  9. As a user whose download is so fast that only the 100% event arrives, I want the dialog to go straight to the complete state, so that it never shows a misleading partial value.
  10. As a user, I want the native Install Updates dialog to appear after the download as it does today, so that the install flow I know is unchanged.
  11. As a user who switched to another app, I want the Dock or taskbar icon to show download progress, so that I can follow it without bringing RAxML-GUI to the front.
  12. As a user who minimised RAxML-GUI, I want the Dock/taskbar bar to keep updating, so that I can follow progress while the page is hidden.
  13. As a macOS or Windows user, I want the Dock/taskbar bar to be indeterminate while connecting, so that it matches the dialog's connecting state.
  14. As a Linux user, I want the taskbar bar to stay empty while connecting and then fill with the download, so that my desktop isn't sent a state it can't show.
  15. As a user whose download finishes, I want the Dock/taskbar bar to clear, so that no stale progress stays on the icon.
  16. As a user whose download fails, I want the dialog to close, so that I'm not left staring at a stuck bar.
  17. As a user whose download fails, I want the Dock/taskbar bar to clear, so that the icon doesn't suggest a download is still running.
  18. As a user whose download fails, I want the same native error box as today, so that I see what went wrong.
  19. As a macOS user who closed the main window during the download and then reopened it from the Dock, I want the reopened page to show the dialog at the current progress, so that I don't lose track of the download.
  20. As a macOS user who reopened the window, I want the Dock bar to show the current progress again, so that the icon and the dialog agree.
  21. As a macOS user with no window open during the download, I want the app to leave the window closed, so that a background download doesn't force a window on me.
  22. As a macOS user with no window open, I want Install Updates to still appear when the download finishes, so that the update still installs.
  23. As a Windows or Linux user who closes the main window during the download, I want the app to quit as it does today, with no prompt, so that closing behaves the way I expect. The next launch offers the update again.
  24. As a user whose page reloads mid-download (for example from the reload menu item), I want the dialog to come back at the current progress, so that a reload doesn't hide the download.
  25. As a user who clicked No in Found Updates, I want no dialog and no Dock/taskbar bar, so that declining changes nothing.
  26. As a user with no update available, I want no dialog and no bar, so that launch stays quiet.
  27. As a user, I want the dialog to show no byte counts, so that I'm not misled by differential totals that count only the bytes fetched.
  28. As a maintainer, I want one log line when the download starts and one when it finishes or fails, so that support logs show the outcome without one line per progress event.
  29. As a maintainer, I want the rejection from starting the download caught, so that a failed download doesn't also throw an unhandled rejection to Sentry. The error listener already reports it.
  30. As a maintainer, I want the page to stay free of Node (nodeIntegration off, context isolation on, sandbox on), so that the security rule holds.
  31. As a maintainer, I want progress to reach the page through rendererBridge like every other main-to-page event, so that there is one bridge pattern to learn.
  32. As a maintainer, I want no second window, renderer entry, or preload, so that packaging stays as it is.
  33. As a maintainer, I want the progress listener registered before the download starts, so that electron-updater attaches its progress reporting at all.
  34. As a maintainer, I want Vitest coverage of the main-side state and bar calls, so that the behaviour is pinned without an update server.
  35. As a maintainer, I want preload proofs for the new subscription and the one-shot call, so that the bridge contract is checked in a real Electron launch.
  36. As a maintainer, I want a page test of the dialog's four texts, so that the copy and the state handling are pinned.

Implementation Decisions

Update download state (main-held). The main process holds the current Update download state. It has five values, in this shape:

type UpdateDownload =
  | { status: 'idle' }                           // not started / reset after failure
  | { status: 'connecting' }                     // Yes clicked, no progress event yet
  | { status: 'downloading'; percent: number }
  | { status: 'restarted'; percent: number }     // differential fell back to full
  | { status: 'done' };                          // update-downloaded fired

The type lives where both sides can import it, beside the other rendererBridge types in common.

Transitions:

  • Yes in Found Updates: idle → connecting.
  • A download-progress event: the state becomes downloading with that event's percent. When the new percent is lower than the previous one, the state becomes restarted, which stays sticky for the rest of the download. A percent of 100 counts as downloading at 100 until update-downloaded fires.
  • update-downloaded: the state becomes done.
  • error while the state is not idle: the state goes back to idle.

The page shows 100% as the complete text even before update-downloaded fires. This covers user story 9.

Updates module (main). It keeps checkForUpdates as it is. listenForUpdates gains a third argument, a function that returns the current main window or null, because on macOS the window comes and goes. Each state change does three things: it updates the held state, sends the state to that window's page through a new event channel when a window exists, and applies the Dock/taskbar value to that window:

  • connecting: indeterminate (setProgressBar(2)).
  • downloading and restarted: percent / 100.
  • done and idle: clear (setProgressBar(-1)).
  • Linux: skip the indeterminate value, because Linux can't show it. The bar stays untouched until the first event.

The download-progress listener is registered inside listenForUpdates at setup time, before any download can start. The module also exposes a getter for the held state, which the one-shot handler uses.

On Yes: set the state to connecting, log one start line, then call downloadUpdate() and catch its rejection, swallowing it the way checkForUpdates does.

On error during a download, in this order:

  1. Set the state to idle.
  2. Send idle to the page, which closes the dialog. There is no separate failure event.
  3. Call setProgressBar(-1).
  4. Show the existing native error box, unchanged.

Log one line when the download ends, whether it finishes or fails. Keep the existing per-event logs (checking, available, not available, error, downloaded). Don't log progress events.

Main entry. It passes a window getter (the existing mainWindow variable) to listenForUpdates. When it creates a window, it applies the held state's Dock/taskbar value to the new window, so a reopened macOS window gets the bar back.

Renderer bridge, following docs/agents/renderer-bridge.md:

  • New subscription onUpdateDownload(listener) on a new channel, using the existing onEvent pattern. It returns an unsubscribe, allows more than one listener, and puts id on the payload. The payload is the UpdateDownload state.
  • New one-shot call getUpdateDownload() on a new channel (ipcMain.handle, like getVersion). It resolves the held state. The page calls it once when it starts, so a reloaded or reopened page shows the dialog at the current state.
  • Channel names go in the shared ipc constants and are imported by the preload and main. RendererBridge and the global Window typing gain both methods.

Page.

  • The store holds the latest UpdateDownload state, seeded once from getUpdateDownload() and updated by onUpdateDownload. Wire this up where the store already starts its other bridge listeners.
  • A new UpdateDownloadDialog component, rendered on the main page, reads that state. It is open whenever the status is not idle.
  • It uses an MUI Dialog with maxWidth="xs", disableEscapeKeyDown, no close button, and a backdrop click that does nothing. The title is Downloading update.

What the dialog shows (copy fixed by the prototype in #390):

State Bar Percent text Status line
connecting indeterminate LinearProgress "Starting…" "Connecting to the update server…"
downloading (<100) determinate, value=percent rounded percent, e.g. "42%" "RAxML-GUI will quit and install when the download finishes."
restarted (<100) determinate rounded percent "Retrying with the full download…"
percent 100, or done determinate at 100 "100%" "Download complete. Preparing to install…"

No bytes are shown anywhere.

Unchanged:

  • The Found Updates and Install Updates native dialogs and their copy.
  • autoDownload = false, autoInstallOnAppQuit = false, and the quitAndInstall hand-off.
  • Window close behaviour on every platform.
  • pageWindowPreferences.
  • No new dependency.

Testing Decisions

A good test drives the outside of a seam and asserts what the user or the next layer sees: the bar values sent to the window, the payloads sent to the page, the dialog's text. It doesn't assert internal variables or call order inside a component. All three seams already exist, and the spec adds none.

  • Vitest on the updates module. Use the existing fake updater, plus a fake window recording setProgressBar and webContents.send. Assert:

    • after Yes, the bar gets 2 (on a non-Linux platform) and the page gets connecting;
    • each download-progress event sets the bar to percent / 100 and sends downloading;
    • a lower percent sends restarted;
    • update-downloaded sends done and sets the bar to -1;
    • error mid-download sends idle, sets the bar to -1, then shows the error box, in that order;
    • a rejected downloadUpdate() produces no unhandled rejection;
    • with a getter returning null, nothing throws and the held state still advances;
    • on Linux the indeterminate 2 is never sent.

    Two existing tests must change. Rewrite "Yes downloads the update with no window, bar, or percent" into the behaviour above. Rewrite or delete the source-scan test "the shell opens no update progress window" (it forbids download-progress), keeping its electron-progressbar absence checks. Prior art: the existing tests in that file.

  • Preload proofs. Add one subscription proof file for onUpdateDownload (subscribe: true, with a downloading payload including id) and one one-shot proof for getUpdateDownload. The existing launch in the preload test walks them. Prior art: the onUnhandledError and getVersion proof files.

  • Page test. Render the page with installBridge stubbing onUpdateDownload and getUpdateDownload. Push connecting, downloading 42, restarted 10, and done, and assert the title, the percent text, and the status line for each. Push idle and assert the dialog is gone. Also cover the startup ask: a getUpdateDownload that resolves downloading opens the dialog without any event. Prior art: the unhandled error page test, and the version store test for the one-shot ask.

  • No e2e. There is no update server to point a built app at.

Out of Scope

  • Cancelling a download in flight. A started download keeps running.
  • A confirmation prompt when a Windows or Linux user closes the window mid-download.
  • Forcing a window open on macOS when none exists during a download.
  • Showing bytes, speed, or time remaining.
  • A separate update window, a second renderer entry, or a second preload.
  • A menu item to check for updates manually.
  • Any change to the Found Updates or Install Updates dialogs.
  • Logging individual progress events.

Further Notes

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions