Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Add dynamic badge to connection comparison view

Anmol Kapil5309ff2dfe55
diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css
index 3bda2f9..d47e0c5 100644
--- a/src/renderer/src/assets/main.css
+++ b/src/renderer/src/assets/main.css
@@ -161,7 +161,13 @@ body,
body {
overflow: hidden;
- font-family: 'Manrope', -apple-system, 'SF Pro Text', 'Helvetica Neue', Helvetica, sans-serif;
+ font-family:
+ 'Manrope',
+ -apple-system,
+ 'SF Pro Text',
+ 'Helvetica Neue',
+ Helvetica,
+ sans-serif;
-webkit-font-smoothing: antialiased;
background: var(--bg);
color: var(--text);
diff --git a/src/renderer/src/screens/CompleteScreen.tsx b/src/renderer/src/screens/CompleteScreen.tsx
index 175e262..4c78436 100644
--- a/src/renderer/src/screens/CompleteScreen.tsx
+++ b/src/renderer/src/screens/CompleteScreen.tsx
@@ -1,3 +1,4 @@
+import { useState } from 'react'
import type { DownloadState } from '@shared/types'
import { ThroughputChart } from '../components/ThroughputChart'
import { useAppStore } from '../store/useAppStore'
@@ -44,6 +45,7 @@ export function CompleteScreen({
download: DownloadState
onNewDownload: () => void
}): React.JSX.Element {
+ const [chipModeIndex, setChipModeIndex] = useState(0)
const homeDir = useAppStore((store) => store.homeDir)
const peakSpeedBytesPerSec = useAppStore((store) => store.peakSpeedBytesPerSec)
const speedHistoryByInterface = useAppStore((store) => store.speedHistoryByInterface)
@@ -67,18 +69,43 @@ export function CompleteScreen({
const totalRetries = download.chunks.reduce((sum, chunk) => sum + chunk.retryCount, 0)
// "Time saved" vs. what the download would have taken over its single best-performing
- // network alone, using that network's own realized average rate as the baseline — a
- // number we can actually stand behind, unlike a made-up multiplier.
- const fastestGroup = groups.reduce<(typeof groups)[number] | null>(
- (fastest, group) =>
- !fastest || group.bytesDownloaded > fastest.bytesDownloaded ? group : fastest,
- null
+ // network alone, using that network's own realized average rate as the baseline.
+ const fastestIndex = groups.reduce<number>(
+ (fastest, group, idx) =>
+ fastest === -1 || group.bytesDownloaded > groups[fastest].bytesDownloaded ? idx : fastest,
+ -1
)
+ const fastestGroup = fastestIndex === -1 ? null : groups[fastestIndex]
const fastestAvgSpeed =
fastestGroup && elapsedSeconds > 0 ? fastestGroup.bytesDownloaded / elapsedSeconds : 0
const soloBaselineSeconds = fastestAvgSpeed > 0 ? finalSize / fastestAvgSpeed : 0
const secondsSaved = soloBaselineSeconds - elapsedSeconds
- const showSavedChip = groups.length > 1 && secondsSaved > 1
+
+ const chipOptions: { label: string; tooltip: string }[] = []
+ if (groups.length > 1) {
+ if (secondsSaved > 1) {
+ chipOptions.push({
+ label: `SAVED ${formatDuration(secondsSaved)}`,
+ tooltip: `Saved ~${formatDuration(secondsSaved)} vs fastest network alone`
+ })
+ }
+ if (fastestIndex !== -1 && fastestAvgSpeed > 0 && avgSpeed > fastestAvgSpeed) {
+ const ratio = avgSpeed / fastestAvgSpeed
+ const name = visuals[fastestIndex].name.toUpperCase()
+ chipOptions.push({
+ label: `${ratio.toFixed(1)}× ${name} ALONE`,
+ tooltip: `${ratio.toFixed(1)}× faster than ${visuals[fastestIndex].name} alone`
+ })
+ const pct = Math.round(((avgSpeed - fastestAvgSpeed) / fastestAvgSpeed) * 100)
+ chipOptions.push({
+ label: `+${pct}% VS ${name}`,
+ tooltip: `+${pct}% throughput gain vs ${visuals[fastestIndex].name} alone`
+ })
+ }
+ }
+
+ const activeChipOption =
+ chipOptions.length > 0 ? chipOptions[chipModeIndex % chipOptions.length] : null
const handleReveal = (): void => void window.plexo.revealInFolder(download.destinationPath)
@@ -156,8 +183,26 @@ export function CompleteScreen({
</div>
<div style={{ font: `500 11px/1 ${FONT_MONO}`, color: '#8d9196' }}>MB/s</div>
</div>
- {showSavedChip && (
- <div style={accentChipStyle}>SAVED {formatDuration(secondsSaved)}</div>
+ {activeChipOption && (
+ <button
+ type="button"
+ onClick={() => setChipModeIndex((i) => (i + 1) % chipOptions.length)}
+ title={`${activeChipOption.tooltip} (click to toggle)`}
+ style={{
+ ...accentChipStyle,
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: 5,
+ cursor: 'pointer',
+ userSelect: 'none',
+ border: '0.5px solid var(--color-usb-border)',
+ background: 'var(--color-usb-bg)',
+ color: 'var(--color-usb-text)'
+ }}
+ >
+ <span>{activeChipOption.label}</span>
+ <span style={{ opacity: 0.55, fontSize: 8.5 }}>⇄</span>
+ </button>
)}
</div>
</div>
diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsx
index 564aecb..c905513 100644
--- a/src/renderer/src/screens/DownloadingScreen.tsx
+++ b/src/renderer/src/screens/DownloadingScreen.tsx
@@ -109,16 +109,92 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
-1
)
const fastestGroup = fastestIndex === -1 ? null : groups[fastestIndex]
- const speedupRatio =
- fastestGroup && fastestGroup.speedBytesPerSec > 0
- ? download.speedBytesPerSec / fastestGroup.speedBytesPerSec
- : 0
- const showSpeedupChip = groups.length > 1 && speedupRatio > 1.05
+ 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 }[] = []
+ if (groups.length > 1) {
+ const sortedIndices = groups
+ .map((_, i) => i)
+ .filter((i) =>
+ download.speedBytesPerSec > 0
+ ? groups[i].speedBytesPerSec > 0
+ : groups[i].bytesDownloaded > 0
+ )
+ .sort((a, b) => {
+ const valA =
+ download.speedBytesPerSec > 0 ? groups[a].speedBytesPerSec : groups[a].bytesDownloaded
+ const valB =
+ download.speedBytesPerSec > 0 ? groups[b].speedBytesPerSec : groups[b].bytesDownloaded
+ return valB - valA
+ })
+
+ for (const idx of sortedIndices) {
+ const g = groups[idx]
+ const name = visuals[idx].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`
+ })
+ }
+ } else if (download.bytesDownloaded > 0 && g.bytesDownloaded > 0) {
+ const ratio = download.bytesDownloaded / g.bytesDownloaded
+ 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`
+ })
+ }
+ }
+ }
+
+ 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 =
+ chipOptions.length > 0 ? chipOptions[chipModeIndex % chipOptions.length] : null
+
return (
<div
style={{ display: 'flex', flexDirection: 'column', height: '100%', background: 'var(--bg)' }}
@@ -150,10 +226,26 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re
{speed.unit}/s
</div>
</div>
- {showSpeedupChip && fastestIndex !== -1 && (
- <div style={accentChipStyle}>
- {speedupRatio.toFixed(1)}× {visuals[fastestIndex].name.toUpperCase()} ALONE
- </div>
+ {activeChipOption && (
+ <button
+ type="button"
+ onClick={() => setChipModeIndex((i) => (i + 1) % chipOptions.length)}
+ title={`${activeChipOption.tooltip} (click to toggle)`}
+ style={{
+ ...accentChipStyle,
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: 5,
+ cursor: 'pointer',
+ userSelect: 'none',
+ border: '0.5px solid var(--color-usb-border)',
+ background: 'var(--color-usb-bg)',
+ color: 'var(--color-usb-text)'
+ }}
+ >
+ <span>{activeChipOption.label}</span>
+ <span style={{ opacity: 0.55, fontSize: 8.5 }}>⇄</span>
+ </button>
)}
</div>