Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

fix: network rows use the app's tooltip, not a native title

Claude694d030e0ab9
diff --git a/e2e/ui.spec.ts b/e2e/ui.spec.ts
index 15f237c..49a08b8 100644
--- a/e2e/ui.spec.ts
+++ b/e2e/ui.spec.ts
@@ -1,7 +1,7 @@
import { writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import type { Page } from '@playwright/test'
-import { BLOCK, expect, interfacesEnv, NETWORKS, test } from './fixtures'
+import { BLOCK, expect, interfacesEnv, LAN_ADDRESS, 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
@@ -108,6 +108,52 @@ test.describe('UI journeys @smoke', () => {
})
// What a user sets is still set after they reload or restart — checked only through what they see.
+test.describe('network rows explain themselves @smoke', () => {
+ test('the last network in use says why it can’t be switched off', async ({ plexo, serve }) => {
+ const origin = await serve({ size: 64 * BLOCK, bytesPerSecond: 256 * 1024 })
+ await plexo.start(origin.url(), origin.sha256)
+ const checkbox = plexo.page.getByRole('checkbox', { name: /^Use /, checked: true })
+ await expect(checkbox).toBeDisabled()
+
+ // A disabled checkbox gets no hover of its own: what it sits in shows the tooltip.
+ await checkbox.locator('..').hover()
+ await expect(
+ plexo.page.getByText('The last network in use stays on. Pause to stop.')
+ ).toBeVisible()
+ })
+
+ test('a network that becomes the last one in use says so too', async ({ plexo, serve }) => {
+ test.skip(!LAN_ADDRESS, 'needs a LAN address to act as the second network')
+ const origin = await serve({ size: 64 * BLOCK, bytesPerSecond: 256 * 1024 })
+ const id = await plexo.start(origin.url(), origin.sha256, { networks: ['a', 'b'] })
+ const checked = plexo.page.getByRole('checkbox', { name: /^Use /, checked: true })
+ await expect(checked).toHaveCount(2)
+
+ await plexo.api.setDownloadNetwork(id, 'b', false)
+ await expect(checked).toBeDisabled()
+ await checked.locator('..').hover()
+ await expect(
+ plexo.page.getByText('The last network in use stays on. Pause to stop.')
+ ).toBeVisible()
+ })
+
+ test('a network that failed shows what went wrong', async ({ plexo, serve }) => {
+ test.skip(!LAN_ADDRESS, 'needs a LAN address to act as the second network')
+ const origin = await serve({ size: 64 * BLOCK, bytesPerSecond: 256 * 1024 })
+ // Everything over b is refused for good; a carries the download.
+ origin.setRule(({ from, range }) =>
+ from !== '127.0.0.1' && range && range.end !== 0 ? { status: 404 } : 'ok'
+ )
+ await plexo.start(origin.url(), origin.sha256, { networks: ['a', 'b'], connections: 2 })
+ await plexo.waitUntil(
+ (state) => state.networks.find((network) => network.id === 'b')?.status === 'failed'
+ )
+
+ await plexo.page.getByText('Failed', { exact: true }).hover()
+ await expect(plexo.page.getByText('Unexpected status 404 for range request')).toBeVisible()
+ })
+})
+
test.describe('settings @smoke', () => {
test.describe('with an update available', () => {
test.use({ appEnv: { PLEXO_FORCE_UPDATE_VERSION: '9.9.9' } })
diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsx
index f4db3bd..7537651 100644
--- a/src/renderer/src/components/NetworkRow.tsx
+++ b/src/renderer/src/components/NetworkRow.tsx
@@ -8,6 +8,7 @@ import { NetworkEditPopover } from './NetworkEditPopover'
import { TruncatedText } from './TruncatedText'
import { Button } from './ui/button'
import { Checkbox } from './ui/checkbox'
+import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'
interface NetworkRowProps {
group: NetworkGroup
@@ -119,21 +120,31 @@ export function NetworkRow({
}}
/>
<div role="cell" className="flex min-w-0 items-center gap-[6px]">
- <span
- className="flex shrink-0"
- title={canSwitch ? undefined : 'The last network in use stays on. Pause to stop.'}
- >
- <Checkbox
- checked={group.enabled}
- disabled={!canSwitch}
- onCheckedChange={(checked) => onSwitch(checked)}
- aria-label={`Use ${visual.name}`}
- className="data-checked:border-transparent"
- style={
- group.enabled ? { background: visual.solid, color: visual.onSolid } : undefined
+ {/* The wrapper is the trigger: a disabled checkbox gets no hover or focus of its own. */}
+ <Tooltip disabled={canSwitch}>
+ <TooltipTrigger
+ render={
+ <span
+ tabIndex={canSwitch ? undefined : 0}
+ className="flex shrink-0 rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
+ >
+ <Checkbox
+ checked={group.enabled}
+ disabled={!canSwitch}
+ onCheckedChange={(checked) => onSwitch(checked)}
+ aria-label={`Use ${visual.name}`}
+ className="data-checked:border-transparent"
+ style={
+ group.enabled
+ ? { background: visual.solid, color: visual.onSolid }
+ : undefined
+ }
+ />
+ </span>
}
/>
- </span>
+ <TooltipContent>The last network in use stays on. Pause to stop.</TooltipContent>
+ </Tooltip>
<TruncatedText
text={visual.name}
className={`font-sans text-[12.5px] leading-[1.2] font-semibold ${
@@ -161,14 +172,21 @@ export function NetworkRow({
</Button>
)}
{group.status !== 'on' && (
- <span
- title={group.error}
- className={`font-mono text-[10px] whitespace-nowrap ${
- hasError ? 'text-destructive' : 'text-muted-foreground'
- }`}
- >
- {STATUS_TEXT[group.status]}
- </span>
+ <Tooltip disabled={!group.error}>
+ <TooltipTrigger
+ render={
+ <span
+ tabIndex={group.error ? 0 : undefined}
+ className={`rounded-sm font-mono text-[10px] whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${
+ hasError ? 'text-destructive' : 'text-muted-foreground'
+ }`}
+ >
+ {STATUS_TEXT[group.status]}
+ </span>
+ }
+ />
+ <TooltipContent>{group.error}</TooltipContent>
+ </Tooltip>
)}
</div>
<ProgressBar