Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
fix(ui): pause combine diagram flow animation when network speed is zero (#155)
Aman Palf928dac131e8
diff --git a/src/renderer/src/components/CombineDiagram.tsx b/src/renderer/src/components/CombineDiagram.tsxindex 9e6f55d..27d4a8c 100644--- a/src/renderer/src/components/CombineDiagram.tsx+++ b/src/renderer/src/components/CombineDiagram.tsx@@ -20,7 +20,12 @@ const LABEL_EDGE_PAD = 4export interface CombineDiagramNetwork {solid: stringlabel: string+ /** The network's current speed, shown beside its label. `undefined` or zero reads as "—". */speedBytesPerSec?: number+ /** Whether the network is carrying bytes right now (an HTTP stream fetching, or a torrent peer+ * receiving). Drives the flow animation; derived from connection status rather than speed, so+ * the diagram agrees with the network rows. */+ active?: boolean}/** Draws the multiple-links-into-one-stream diagram: individual networks with their@@ -60,17 +65,22 @@ export function CombineDiagram({{networks.map((network, index) => {const y = (index + 0.5) * (height / networks.length)const color = muted ? 'var(--icon-muted)' : network.solid+ // Three deterministic states: paused (the whole download stopped), idle (the network+ // is on but fetching nothing), or flowing (the network is carrying bytes). Muted is a+ // static illustration — the empty-state diagram — so it never animates or dims.+ const flowing = !muted && !paused && network.active === true+ const opacity = muted ? 1 : paused ? 0.55 : flowing ? 1 : 0.35return (<pathkey={network.label + index}d={`M${CURVE_START_X},${y.toFixed(1)} C${CURVE_START_X + 36},${y.toFixed(1)} ${COMBINE_X - 26},${midY.toFixed(1)} ${COMBINE_X},${midY.toFixed(1)}`}stroke={color}strokeDasharray="6 8"- opacity={paused ? 0.55 : 1}+ opacity={opacity}style={- muted || paused- ? undefined- : { animation: `plexo-dash ${1.1 + index * 0.2}s linear infinite` }+ flowing+ ? { animation: `plexo-dash ${1.1 + index * 0.2}s linear infinite` }+ : undefined}/>)diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsxindex dc18bfb..35a1d12 100644--- a/src/renderer/src/components/NetworkRow.tsx+++ b/src/renderer/src/components/NetworkRow.tsx@@ -2,7 +2,7 @@ import type { HttpBlockState, HttpStreamState, NetworkStatus, SpeedUnit } from 'import { useState } from 'react'import { DANGER, type NetworkVisual } from '../theme'import type { HttpNetworkGroup, NetworkGroup, TorrentNetworkGroup } from '../utils/format'-import { describeError, formatBytes, formatSpeedOfLimit } from '../utils/format'+import { describeError, formatBytes, formatSpeedOfLimit, networkActive } from '../utils/format'import { useFormatSpeed } from '../hooks/useFormatSpeed'import { useAppStore } from '../store/useAppStore'import { ColorBadge } from './ColorBadge'@@ -378,10 +378,7 @@ export function NetworkRow({const speedLimit = useAppStore((store) => store.networkPreferences[group.id]?.speedLimit)const [expanded, setExpanded] = useState(false)const connections = group.transfer === 'http' ? group.streams : group.peers- const isActive =- group.transfer === 'http'- ? group.streams.some((stream) => stream.status === 'downloading')- : group.peers.some((peer) => peer.status === 'receiving')+ const isActive = networkActive(group)const hasError = group.status === 'failed'const rounded = Math.round(sharePercent)const shareLabel = group.bytesDownloaded === 0 ? '0%' : rounded === 0 ? '<1%' : `${rounded}%`diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsxindex e4224ae..f4daa0a 100644--- a/src/renderer/src/screens/DownloadingScreen.tsx+++ b/src/renderer/src/screens/DownloadingScreen.tsx@@ -28,6 +28,7 @@ import {formatPercent,groupByNetwork,isFolder,+ networkActive,networksInPlay,toDisplayPath,wantedBytes@@ -224,7 +225,8 @@ export const DownloadingScreen = memo(function DownloadingScreen({networks={groups.map((group, index) => ({solid: visuals[index].solid,label: visuals[index].name,- speedBytesPerSec: isPaused ? 0 : group.speedBytesPerSec+ speedBytesPerSec: isPaused ? 0 : group.speedBytesPerSec,+ active: networkActive(group)}))}paused={isPaused}/>diff --git a/src/renderer/src/utils/format.ts b/src/renderer/src/utils/format.tsindex 71819c3..12a8abb 100644--- a/src/renderer/src/utils/format.ts+++ b/src/renderer/src/utils/format.ts@@ -244,6 +244,15 @@ export function networksInPlay<T extends DownloadNetwork>(networks: T[]): T[] {return networks.filter((network) => network.enabled || network.bytesDownloaded > 0)}+/** Whether a network is carrying bytes right now: an HTTP stream fetching, or a torrent peer+ * receiving. Read from connection status rather than speed, so every view of a download agrees+ * on which networks are live even between speed samples. */+export function networkActive(group: NetworkGroup): boolean {+ return group.transfer === 'http'+ ? group.streams.some((stream) => stream.status === 'downloading')+ : group.peers.some((peer) => peer.status === 'receiving')+}+/** Shortens an absolute path under the user's home directory to a "~/..." form for display. */export function toDisplayPath(path: string, homeDir: string): string {const normalize = (value: string): string => {