diff --git a/src/app/store/RunList.ts b/src/app/store/RunList.ts
index 2b5998d7..9d58b6fc 100644
--- a/src/app/store/RunList.ts
+++ b/src/app/store/RunList.ts
@@ -99,6 +99,8 @@ class RunList extends AppStore {
listen = (): void => {
this.subscribe( runEvents.onUnhandledError, this.onUnhandledError );
this.subscribe( runEvents.onUpdateDownload, this.onUpdateDownload );
+ // A reloaded or reopened page starts mid-download; seed from main's held state.
+ window.rendererBridge.getUpdateDownload().then( this.onUpdateDownload );
this.subscribe( runEvents.onAddRun, this.addRun );
this.subscribe( runEvents.onRemoveRun, this.deleteActive );
this.subscribe( runEvents.onToggleBackboneConstraint, this.onBackboneConstraint );
diff --git a/src/app/updateDownload.test.tsx b/src/app/updateDownload.test.tsx
index 2a294af8..d2a3cde3 100644
--- a/src/app/updateDownload.test.tsx
+++ b/src/app/updateDownload.test.tsx
@@ -65,3 +65,24 @@ it( 'the page follows the update download in a dialog that cannot be dismissed',
} );
div.remove();
} );
+
+it( 'a page that starts mid-download shows the dialog with no event pushed', async () => {
+ installBridge( {
+ getUpdateDownload: () => Promise.resolve( { status: 'downloading', percent: 37 } ),
+ } );
+ store.listen();
+
+ const div = document.createElement( 'div' );
+ document.body.appendChild( div );
+ const root = createRoot( div );
+ await act( async () => {
+ root.render( );
+ } );
+ expect( title() ).toBe( 'Downloading update' );
+ expect( document.querySelector( '[role="dialog"]' ).textContent ).toContain( '37%' );
+
+ act( () => {
+ root.unmount();
+ } );
+ div.remove();
+} );
diff --git a/src/common/rendererBridge.ts b/src/common/rendererBridge.ts
index 51289b05..5eaf941d 100644
--- a/src/common/rendererBridge.ts
+++ b/src/common/rendererBridge.ts
@@ -79,6 +79,7 @@ export interface RendererBridge {
onToggleMultifurcatingConstraint: ( listener: Listener ) => Unsubscribe;
onUnhandledError: ( listener: Listener ) => Unsubscribe;
onUpdateDownload: ( listener: ( payload: UpdateDownloadPayload ) => void ) => Unsubscribe;
+ getUpdateDownload: () => Promise;
getPathForFile: ( file: File ) => string;
}
diff --git a/src/constants/ipc.ts b/src/constants/ipc.ts
index 2c2fe55c..4ced0c72 100644
--- a/src/constants/ipc.ts
+++ b/src/constants/ipc.ts
@@ -29,6 +29,7 @@ export const ALIGNMENT_MODEL_SELECTION_FAILURE =
'ALIGNMENT_MODEL_SELECTION_FAILURE' as const;
export const UNHANDLED_ERROR = 'UNHANDLED_ERROR' as const;
export const UPDATE_DOWNLOAD = 'UPDATE_DOWNLOAD' as const;
+export const GET_UPDATE_DOWNLOAD = 'GET_UPDATE_DOWNLOAD' as const;
export const TOGGLE_BACKBONE_CONSTRAINT = 'TOGGLE_BACKBONE_CONSTRAINT' as const;
export const TOGGLE_MULTIFURCATING_CONSTRAINT =
'TOGGLE_MULTIFURCATING_CONSTRAINT' as const;
diff --git a/src/main/api.ts b/src/main/api.ts
index c113d677..24549d18 100644
--- a/src/main/api.ts
+++ b/src/main/api.ts
@@ -16,6 +16,7 @@ import { selectAstralFile } from './selectAstralFile';
import { selectOutputDir } from './selectOutputDir';
import { checkOutput } from './checkOutput';
import { debugInfo } from './debugInfo';
+import { getUpdateDownload } from './updates';
import { selectPartitionFile } from './selectPartitionFile';
import { selectTree } from './selectTree';
import { appStore } from './appStore';
@@ -71,6 +72,7 @@ ipcMain.on( ipc.HOST, ( event: IpcMainEvent ) => {
};
} );
ipcMain.handle( ipc.GET_VERSION, (): string => app.getVersion() );
+ipcMain.handle( ipc.GET_UPDATE_DOWNLOAD, getUpdateDownload );
ipcMain.handle( ipc.GET_DARK_MODE, (): boolean => Boolean( appStore.get( 'darkMode' ) ) );
ipcMain.handle( ipc.SET_DARK_MODE, ( _event: IpcMainInvokeEvent, value: boolean ): void => {
appStore.set( 'darkMode', value );
diff --git a/src/preload-proofs/getUpdateDownload.json b/src/preload-proofs/getUpdateDownload.json
new file mode 100644
index 00000000..96a5ff18
--- /dev/null
+++ b/src/preload-proofs/getUpdateDownload.json
@@ -0,0 +1,10 @@
+{
+ "key": "heldUpdateDownload",
+ "method": "getUpdateDownload",
+ "args": [],
+ "channel": "GET_UPDATE_DOWNLOAD",
+ "result": {
+ "status": "downloading",
+ "percent": 42
+ }
+}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 5ac0aee6..ae5cc6e2 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -17,6 +17,7 @@ import {
FILE_SHOW_IN_FOLDER,
GET_DARK_MODE,
GET_VERSION,
+ GET_UPDATE_DOWNLOAD,
HOST,
SET_DARK_MODE,
LIGHT_MODE,
@@ -195,6 +196,9 @@ const rendererBridge = {
onUpdateDownload( listener: ( payload: UpdateDownloadPayload ) => void ) {
return onEvent( UPDATE_DOWNLOAD, listener );
},
+ getUpdateDownload() {
+ return ipcRenderer.invoke( GET_UPDATE_DOWNLOAD );
+ },
getPathForFile( file: File ): string {
return webUtils.getPathForFile( file );
},
diff --git a/src/test/setup.ts b/src/test/setup.ts
index 3c630b3e..ef5800d2 100644
--- a/src/test/setup.ts
+++ b/src/test/setup.ts
@@ -45,6 +45,10 @@ function withBridgeEvents( next: TestBridge ): TestBridge {
if ( typeof next.getVersion !== 'function' ) {
next.getVersion = () => Promise.resolve( undefined );
}
+ // The run list seeds the update download when it listens.
+ if ( typeof next.getUpdateDownload !== 'function' ) {
+ next.getUpdateDownload = () => Promise.resolve( { status: 'idle' } );
+ }
// The output panel checks the output name; MobX 6 re-renders it inside the render test when this rejects.
if ( typeof next.checkOutput !== 'function' ) {
next.checkOutput = ( { outputDir, outputName } ) =>