Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Clean up UI design

Anmol Kapil726c45d9331f
diff --git a/src/renderer/src/components/MergeDiagram.tsx b/src/renderer/src/components/MergeDiagram.tsx
index 9d2601f..cd7ddbd 100644
--- a/src/renderer/src/components/MergeDiagram.tsx
+++ b/src/renderer/src/components/MergeDiagram.tsx
@@ -1,10 +1,14 @@
import { FONT_MONO } from '../theme'
const ROW_HEIGHT = 30
-const MERGE_X = 150
-const WIDTH = 232
+const WIDTH = 236
+const LABEL_X = 66
+const DOT_X = 74
+const CURVE_START_X = 80
+const MERGE_X = 168
+const STREAM_END_X = WIDTH - 6
-/** Draws the bonded-links-into-one-stream diagram from design v2: one dashed, flowing line
+/** Draws the bonded-links-into-one-stream diagram: one dashed, flowing line
* per active physical network, converging into a single solid stream. */
export function MergeDiagram({
networks,
@@ -28,7 +32,7 @@ export function MergeDiagram({
return (
<path
key={network.label + index}
- d={`M4,${y.toFixed(1)} C70,${y.toFixed(1)} 84,${midY.toFixed(1)} ${MERGE_X},${midY.toFixed(1)}`}
+ d={`M${CURVE_START_X},${y.toFixed(1)} C${CURVE_START_X + 42},${y.toFixed(1)} ${MERGE_X - 32},${midY.toFixed(1)} ${MERGE_X},${midY.toFixed(1)}`}
stroke={color}
strokeDasharray="6 8"
style={
@@ -40,50 +44,52 @@ export function MergeDiagram({
)
})}
<path
- d={`M${MERGE_X},${midY} L${WIDTH - 10},${midY}`}
+ d={`M${MERGE_X},${midY} L${STREAM_END_X},${midY}`}
stroke={muted ? 'var(--icon-muted)' : 'var(--text)'}
- strokeWidth={8}
+ strokeWidth={7}
/>
</g>
<circle
cx={MERGE_X}
cy={midY}
- r={11}
+ r={10}
fill="none"
stroke={muted ? 'var(--icon-muted)' : 'var(--text)'}
strokeOpacity={muted ? 1 : 0.25}
strokeWidth={1.5}
strokeDasharray={muted ? '3 4' : undefined}
/>
- <circle cx={MERGE_X} cy={midY} r={4.5} fill={muted ? 'var(--icon-muted)' : 'var(--text)'} />
+ <circle cx={MERGE_X} cy={midY} r={4} fill={muted ? 'var(--icon-muted)' : 'var(--text)'} />
{networks.map((network, index) => {
const y = (index + 0.5) * (height / networks.length)
const color = muted ? 'var(--icon-muted)' : network.solid
- return <circle key={`dot-${index}`} cx={4} cy={y} r={4} fill={color} />
+ return <circle key={`dot-${index}`} cx={DOT_X} cy={y} r={3.5} fill={color} />
+ })}
+ {networks.map((network, index) => {
+ const y = (index + 0.5) * (height / networks.length)
+ const label =
+ network.label.trim().length > 11
+ ? `${network.label.trim().slice(0, 10).toUpperCase()}…`
+ : network.label.trim().toUpperCase()
+ return (
+ <text
+ key={`label-${index}`}
+ x={LABEL_X}
+ y={y}
+ dominantBaseline="central"
+ textAnchor="end"
+ fill={muted ? 'var(--icon-muted)' : 'var(--text-secondary)'}
+ style={{ font: `500 9px ${FONT_MONO}`, letterSpacing: '0.08em' }}
+ >
+ <title>{network.label}</title>
+ {label}
+ </text>
+ )
})}
- {!muted &&
- networks.map((network, index) => {
- const y = (index + 0.5) * (height / networks.length)
- const label =
- network.label.trim().length > 16
- ? `${network.label.trim().slice(0, 15).toUpperCase()}…`
- : network.label.trim().toUpperCase()
- return (
- <text
- key={`label-${index}`}
- x={14}
- y={y - 6}
- fill="var(--text-tertiary)"
- style={{ font: `500 9px ${FONT_MONO}`, letterSpacing: '0.1em' }}
- >
- {label}
- </text>
- )
- })}
{!muted && (
<text
- x={WIDTH - 10}
- y={midY - 16}
+ x={STREAM_END_X}
+ y={midY - 12}
textAnchor="end"
fill="var(--text-tertiary)"
style={{ font: `500 9px ${FONT_MONO}`, letterSpacing: '0.1em' }}
diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsx
index bb54cd8..d8a332e 100644
--- a/src/renderer/src/components/NetworkRow.tsx
+++ b/src/renderer/src/components/NetworkRow.tsx
@@ -15,16 +15,14 @@ import { NetworkEditorFields } from './NetworkEditorFields'
export function NetworkRow({
group,
totalBytes,
- sharePercent,
- latencyMs
+ sharePercent
}: {
group: NetworkGroup
totalBytes: number
sharePercent: number
- latencyMs?: number | null
}): React.JSX.Element {
const [editing, setEditing] = useState(false)
- const [expanded, setExpanded] = useState(true)
+ const [expanded, setExpanded] = useState(false)
const preference = useAppStore((store) => store.networkPreferences[group.interfaceId])
const setNetworkPreference = useAppStore((store) => store.setNetworkPreference)
const visual = resolveNetworkVisual(group.interfaceKind, group.interfaceLabel, preference)
@@ -54,40 +52,41 @@ export function NetworkRow({
}}
/>
<div style={{ minWidth: 0, display: 'flex', alignItems: 'center', gap: 6 }}>
- <div style={{ minWidth: 0 }}>
- <div
- style={{
- font: `600 12.5px/1.3 ${FONT_UI}`,
- whiteSpace: 'nowrap',
- overflow: 'hidden',
- textOverflow: 'ellipsis'
- }}
- >
- {visual.name}
- </div>
- <button
- type="button"
- onClick={() => setExpanded((v) => !v)}
- title={expanded ? 'Collapse stream details' : 'Expand stream details'}
- style={{
- marginTop: 3,
- display: 'inline-flex',
- alignItems: 'center',
- gap: 4,
- border: 'none',
- background: 'none',
- padding: 0,
- font: `500 10px/1 ${FONT_MONO}`,
- color: 'var(--text-tertiary)',
- cursor: 'pointer'
- }}
- >
- <span>
- {group.chunks.length} parallel stream{group.chunks.length === 1 ? '' : 's'}
- </span>
- <span style={{ fontSize: 8 }}>{expanded ? '▲' : '▼'}</span>
- </button>
- </div>
+ <span
+ style={{
+ font: `600 12.5px/1.2 ${FONT_UI}`,
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ color: 'var(--text)'
+ }}
+ title={visual.name}
+ >
+ {visual.name}
+ </span>
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ title={expanded ? 'Collapse streams' : 'Expand streams'}
+ style={{
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: 3,
+ padding: '2px 6px',
+ borderRadius: 4,
+ background: expanded ? 'var(--bg-tertiary)' : 'var(--bg-secondary)',
+ border: '0.5px solid var(--border)',
+ font: `500 10px/1 ${FONT_MONO}`,
+ color: expanded ? 'var(--text)' : 'var(--text-secondary)',
+ cursor: 'pointer',
+ flexShrink: 0,
+ userSelect: 'none',
+ lineHeight: 1
+ }}
+ >
+ <span>{group.chunks.length} streams</span>
+ <span style={{ fontSize: 7.5, opacity: 0.75 }}>{expanded ? '▲' : '▼'}</span>
+ </button>
<button
type="button"
onClick={() => setEditing((value) => !value)}
@@ -177,15 +176,6 @@ export function NetworkRow({
>
{formatBytes(group.bytesDownloaded)}
</div>
- <div
- style={{
- textAlign: 'right',
- font: `11.5px/1 ${FONT_MONO}`,
- color: 'var(--text-tertiary)'
- }}
- >
- {latencyMs != null ? `${latencyMs} ms` : '—'}
- </div>
</div>
{expanded && group.chunks.length > 0 && (
<div
diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsx
index c905513..02701bf 100644
--- a/src/renderer/src/screens/DownloadingScreen.tsx
+++ b/src/renderer/src/screens/DownloadingScreen.tsx
@@ -58,7 +58,6 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
const speedHistory = useAppStore((store) => store.speedHistory)
const speedHistoryByInterface = useAppStore((store) => store.speedHistoryByInterface)
const peakSpeedBytesPerSec = useAppStore((store) => store.peakSpeedBytesPerSec)
- const latencies = useAppStore((store) => store.latencies)
const networkPreferences = useAppStore((store) => store.networkPreferences)
const [now, setNow] = useState(() => Date.now())
@@ -103,20 +102,23 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
)
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0) || 1
- const fastestIndex = groups.reduce<number>(
- (fastest, group, index) =>
- fastest === -1 || group.speedBytesPerSec > groups[fastest].speedBytesPerSec ? index : fastest,
- -1
- )
- const fastestGroup = fastestIndex === -1 ? null : groups[fastestIndex]
const [chipModeIndex, setChipModeIndex] = useState(0)
const completedChunks = download.chunks.filter((chunk) => chunk.status === 'completed').length
const totalRetries = download.chunks.reduce((sum, chunk) => sum + chunk.retryCount, 0)
const remainingBytes = knownSize ? Math.max(0, download.totalBytes - download.bytesDownloaded) : 0
- // Build list of toggleable comparison metrics for active networks
- const chipOptions: { label: string; tooltip: string }[] = []
+ const avgSpeedBytesPerSec = elapsedSeconds > 0 ? download.bytesDownloaded / elapsedSeconds : 0
+
+ // Build list of toggleable comparison metrics for active networks (only "X× [NETWORK] ALONE")
+ interface SpeedChipOption {
+ label: string
+ tooltip: string
+ color: string
+ bg: string
+ border: string
+ }
+ const chipOptions: SpeedChipOption[] = []
if (groups.length > 1) {
const sortedIndices = groups
.map((_, i) => i)
@@ -135,20 +137,17 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
for (const idx of sortedIndices) {
const g = groups[idx]
- const name = visuals[idx].name.toUpperCase()
+ const visual = visuals[idx]
+ const name = visual.name.toUpperCase()
if (download.speedBytesPerSec > 0 && g.speedBytesPerSec > 0) {
const ratio = download.speedBytesPerSec / g.speedBytesPerSec
if (ratio >= 1.05) {
chipOptions.push({
label: `${ratio.toFixed(1)}× ${name} ALONE`,
- tooltip: `Total speed is ${ratio.toFixed(1)}× faster than ${visuals[idx].name} alone`
- })
- const pct = Math.round(
- ((download.speedBytesPerSec - g.speedBytesPerSec) / g.speedBytesPerSec) * 100
- )
- chipOptions.push({
- label: `+${pct}% VS ${name}`,
- tooltip: `+${pct}% throughput gain compared to ${visuals[idx].name} alone`
+ tooltip: `Total speed is ${ratio.toFixed(1)}× faster than ${visual.name} alone`,
+ color: visual.text,
+ bg: visual.bg,
+ border: visual.border
})
}
} else if (download.bytesDownloaded > 0 && g.bytesDownloaded > 0) {
@@ -156,40 +155,14 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
if (ratio >= 1.05) {
chipOptions.push({
label: `${ratio.toFixed(1)}× ${name} ALONE`,
- tooltip: `Total downloaded is ${ratio.toFixed(1)}× compared to ${visuals[idx].name} alone`
+ tooltip: `Total downloaded is ${ratio.toFixed(1)}× compared to ${visual.name} alone`,
+ color: visual.text,
+ bg: visual.bg,
+ border: visual.border
})
}
}
}
-
- if (
- fastestGroup &&
- download.speedBytesPerSec > fastestGroup.speedBytesPerSec &&
- fastestGroup.speedBytesPerSec > 0
- ) {
- const addedSpeed = download.speedBytesPerSec - fastestGroup.speedBytesPerSec
- chipOptions.push({
- label: `+${formatSpeed(addedSpeed).toUpperCase()} MERGED`,
- tooltip: `${formatSpeed(addedSpeed)} gained by bonding networks`
- })
- }
-
- if (
- knownSize &&
- fastestGroup &&
- fastestGroup.speedBytesPerSec > 0 &&
- download.speedBytesPerSec > 0
- ) {
- const soloRemainingSecs = remainingBytes / fastestGroup.speedBytesPerSec
- const actualRemainingSecs = remainingBytes / download.speedBytesPerSec
- const savedSecs = soloRemainingSecs - actualRemainingSecs
- if (savedSecs > 1) {
- chipOptions.push({
- label: `~${formatDuration(savedSecs).toUpperCase()} SAVED`,
- tooltip: `Estimated ~${formatDuration(savedSecs)} saved on remaining download`
- })
- }
- }
}
const activeChipOption =
@@ -201,7 +174,7 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
>
<div style={heroScopeStyle}>
<div style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
- <div style={{ display: 'flex', flexDirection: 'column', gap: 8, minWidth: 122 }}>
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 7, minWidth: 130 }}>
<div
style={{
font: `500 10px/1 ${FONT_MONO}`,
@@ -214,7 +187,7 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
<div style={{ display: 'flex', alignItems: 'baseline', gap: 7 }}>
<div
style={{
- font: `600 40px/0.88 ${FONT_MONO}`,
+ font: `600 38px/0.88 ${FONT_MONO}`,
letterSpacing: '-0.03em',
color: '#f5f2ed',
fontVariantNumeric: 'tabular-nums'
@@ -226,25 +199,50 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
{speed.unit}/s
</div>
</div>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: 8,
+ font: `500 10px/1 ${FONT_MONO}`,
+ color: '#8d9196',
+ fontVariantNumeric: 'tabular-nums'
+ }}
+ >
+ <span>
+ AVG{' '}
+ <span style={{ color: '#f5f2ed', fontWeight: 600 }}>
+ {formatSpeed(avgSpeedBytesPerSec)}
+ </span>
+ </span>
+ <span style={{ opacity: 0.35 }}>·</span>
+ <span>
+ PEAK{' '}
+ <span style={{ color: '#f5f2ed', fontWeight: 600 }}>
+ {formatSpeed(peakSpeedBytesPerSec)}
+ </span>
+ </span>
+ </div>
{activeChipOption && (
<button
type="button"
onClick={() => setChipModeIndex((i) => (i + 1) % chipOptions.length)}
- title={`${activeChipOption.tooltip} (click to toggle)`}
+ title={`${activeChipOption.tooltip}${chipOptions.length > 1 ? ' (click to toggle)' : ''}`}
style={{
...accentChipStyle,
display: 'inline-flex',
alignItems: 'center',
gap: 5,
- cursor: 'pointer',
+ cursor: chipOptions.length > 1 ? 'pointer' : 'default',
userSelect: 'none',
- border: '0.5px solid var(--color-usb-border)',
- background: 'var(--color-usb-bg)',
- color: 'var(--color-usb-text)'
+ border: `0.5px solid ${activeChipOption.border}`,
+ background: activeChipOption.bg,
+ color: activeChipOption.color,
+ width: 'fit-content'
}}
>
<span>{activeChipOption.label}</span>
- <span style={{ opacity: 0.55, fontSize: 8.5 }}>⇄</span>
+ {chipOptions.length > 1 && <span style={{ opacity: 0.55, fontSize: 8.5 }}>⇄</span>}
</button>
)}
</div>
@@ -352,7 +350,7 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
style={{
margin: '0 20px 14px',
...statGridStyle,
- gridTemplateColumns: 'repeat(6, minmax(0, 1fr))'
+ gridTemplateColumns: 'repeat(5, minmax(0, 1fr))'
}}
>
{[
@@ -364,7 +362,6 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
!isPaused && knownSize ? formatEta(remainingBytes, download.speedBytesPerSec) : '—'
},
{ label: 'Elapsed', value: formatDuration(elapsedSeconds) },
- { label: 'Peak', value: formatSpeed(peakSpeedBytesPerSec) },
{ label: 'Chunks', value: `${completedChunks} / ${download.chunks.length}` }
].map((stat, index) => (
<div
@@ -413,8 +410,7 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
<div>Chunks</div>
<div style={{ textAlign: 'right' }}>Share</div>
<div style={{ textAlign: 'right' }}>Speed</div>
- <div style={{ textAlign: 'right' }}>Moved</div>
- <div style={{ textAlign: 'right' }}>Ping</div>
+ <div style={{ textAlign: 'right' }}>Downloaded</div>
</div>
{groups.map((group, index) => (
<NetworkRow
@@ -422,7 +418,6 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
group={group}
totalBytes={download.totalBytes}
sharePercent={(weights[index] / totalWeight) * 100}
- latencyMs={latencies[group.interfaceId]}
/>
))}
</div>
diff --git a/src/renderer/src/theme.ts b/src/renderer/src/theme.ts
index 2b257bd..d8b2a7d 100644
--- a/src/renderer/src/theme.ts
+++ b/src/renderer/src/theme.ts
@@ -184,7 +184,7 @@ export const statValueStyle: React.CSSProperties = {
fontVariantNumeric: 'tabular-nums'
}
-export const NETWORK_ROW_GRID_COLUMNS = '10px 160px 1fr 40px 82px 68px 52px'
+export const NETWORK_ROW_GRID_COLUMNS = '10px 190px 1fr 44px 82px 82px'
export const networkTableHeaderStyle: React.CSSProperties = {
display: 'grid',