Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Stop the idle and no-connections screens remounting each other

Anmol Kapil7d30ea6c86bc
diff --git a/e2e/ui.spec.ts b/e2e/ui.spec.ts
index 6391c68..b908802 100644
--- a/e2e/ui.spec.ts
+++ b/e2e/ui.spec.ts
@@ -1,6 +1,6 @@
import { writeFile } from 'node:fs/promises'
import { join } from 'node:path'
-import { BLOCK, expect, test } from './fixtures'
+import { BLOCK, expect, interfacesEnv, NETWORKS, test } from './fixtures'
// G. A handful of journeys through the real UI, to prove the screens are wired to the main
// process. Download correctness is covered far more thoroughly by the API-level specs; these
@@ -144,10 +144,6 @@ test.describe('no networks', () => {
test.use({ appEnv: { PLEXO_E2E_INTERFACES: '' } })
test('shows the no-connections screen, and settles on it @smoke', async ({ plexo }) => {
- test.fail(
- true,
- 'known bug: Idle and NoConnections screens each re-scan on mount, the scan flips interfacesStatus to "loading", which swaps the screen back — an endless loop (~4000 scans/s) that freezes the renderer'
- )
await plexo.evaluateMain(({ ipcMain }) => {
const g = globalThis as unknown as Record<string, number>
g.__scans = 0
@@ -166,4 +162,16 @@ test.describe('no networks', () => {
expect(scans).toBeLessThan(10)
await expect(plexo.page.getByText('No networks to combine')).toBeVisible({ timeout: 5000 })
})
+
+ test('a network appearing takes you back to the start screen @smoke', async ({ plexo }) => {
+ await expect(plexo.page.getByText('No networks to combine')).toBeVisible()
+ await plexo.evaluateMain(
+ (_electron, value) => {
+ process.env['PLEXO_E2E_INTERFACES'] = value
+ },
+ interfacesEnv({ a: NETWORKS['a'] })
+ )
+ await plexo.page.getByRole('button', { name: 'Scan Again' }).click()
+ await expect(plexo.page.getByRole('textbox', { name: 'LINK' })).toBeVisible()
+ })
})
diff --git a/src/renderer/src/store/useAppStore.ts b/src/renderer/src/store/useAppStore.ts
index e5603ce..7bd9186 100644
--- a/src/renderer/src/store/useAppStore.ts
+++ b/src/renderer/src/store/useAppStore.ts
@@ -83,7 +83,11 @@ export const useAppStore = create<AppStore>((set, get) => ({
draftDestinationDir: '',
loadInterfaces: async () => {
- set({ interfacesStatus: 'loading', interfacesError: null })
+ // A re-scan keeps showing the last result. Dropping back to 'loading' would swap App off the
+ // no-connections screen, and every screen re-scans on mount — so with zero networks the
+ // two screens would remount each other in an endless loop.
+ if (get().interfacesStatus !== 'ready') set({ interfacesStatus: 'loading' })
+ set({ interfacesError: null })
try {
const interfaces = await window.plexo.listInterfaces()
set({ interfaces, interfacesStatus: 'ready' })