Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
Make the network table's columns share tracks via CSS subgrid
prashantgeek4457892f89ed
diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsxindex 4290516..4850c29 100644--- a/src/renderer/src/components/NetworkRow.tsx+++ b/src/renderer/src/components/NetworkRow.tsx@@ -44,145 +44,148 @@ export function NetworkRow({: `${Math.round(sharePercent)}%`return (- <div>+ // A subgrid, not its own independent grid — it inherits the exact column tracks the parent+ // (networkTableGridStyle in DownloadingScreen) computed for the header and every other row,+ // rather than recomputing its own from the same column list and hoping they match.+ <div+ style={{+ display: 'grid',+ gridTemplateColumns: 'subgrid',+ gridColumn: '1 / -1',+ gap: 12,+ alignItems: 'center',+ padding: '11px 20px',+ borderTop: '0.5px solid var(--border-subtle)'+ }}+ ><divstyle={{- display: 'grid',- gridTemplateColumns: NETWORK_ROW_GRID_COLUMNS,- gap: 12,- alignItems: 'center',- padding: '11px 20px',- borderTop: '0.5px solid var(--border-subtle)'+ width: 8,+ height: 8,+ borderRadius: '50%',+ background: hasError ? DANGER : visual.solid,+ animation: isActive ? 'plexo-glow 1.8s infinite' : undefined,+ opacity: isActive || hasError ? 1 : 0.65}}- >- <div+ />+ <div style={{ minWidth: 0, display: 'flex', alignItems: 'center', gap: 6 }}>+ <spanstyle={{- width: 8,- height: 8,- borderRadius: '50%',- background: hasError ? DANGER : visual.solid,- animation: isActive ? 'plexo-glow 1.8s infinite' : undefined,- opacity: isActive || hasError ? 1 : 0.65+ // A fixed basis rather than letting the name take its natural width — otherwise+ // the streams pill and "⋯" button (and everything after them, all the way out to+ // the Progress column) shift left or right by however long each network's name+ // happens to be, so the gap before the progress bar looks different on every row.+ flex: '0 0 100px',+ font: `600 12.5px/1.2 ${FONT_UI}`,+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ color: 'var(--text)'}}- />- <div style={{ minWidth: 0, display: 'flex', alignItems: 'center', gap: 6 }}>- <span- style={{- // A fixed basis rather than letting the name take its natural width — otherwise- // the streams pill and "⋯" button (and everything after them, all the way out to- // the Progress column) shift left or right by however long each network's name- // happens to be, so the gap before the progress bar looks different on every row.- flex: '0 0 100px',- 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- ref={buttonRef}- type="button"- onClick={() => setEditing((value) => !value)}- title="Rename or recolor this network"- style={{- border: 'none',- background: 'none',- color: 'var(--text-tertiary)',- font: `700 12px/1 ${FONT_UI}`,- cursor: 'pointer',- padding: '2px 4px',- flexShrink: 0- }}- >- ⋯- </button>- </div>- <div style={{ display: 'flex', alignItems: 'center', minWidth: 0 }}>- <div- style={{- flex: 1,- height: 6,- borderRadius: 999,- background: 'var(--track-bg)',- border: '0.5px solid var(--border-strong)',- overflow: 'hidden'- }}- >- <div- style={{- height: '100%',- width:- totalBytes && totalBytes > 0- ? `${Math.min(100, Math.max(0, (group.bytesDownloaded / totalBytes) * 100))}%`- : '0%',- background: visual.solid,- borderRadius: 999,- transition: 'width 0.25s ease-out'- }}- />- </div>- </div>- <div+ title={visual.name}+ >+ {visual.name}+ </span>+ <button+ type="button"+ onClick={() => setExpanded((v) => !v)}+ title={expanded ? 'Collapse streams' : 'Expand streams'}style={{- textAlign: 'right',- font: `500 11.5px/1 ${FONT_MONO}`,- color: sharePercent > 0 ? 'var(--text)' : 'var(--text-tertiary)',- fontVariantNumeric: 'tabular-nums'+ 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}}>- {groupShareDisplay}- </div>- <div+ <span>{group.chunks.length} streams</span>+ <span style={{ fontSize: 7.5, opacity: 0.75 }}>{expanded ? '▲' : '▼'}</span>+ </button>+ <button+ ref={buttonRef}+ type="button"+ onClick={() => setEditing((value) => !value)}+ title="Rename or recolor this network"style={{- textAlign: 'right',- font: `600 12.5px/1 ${FONT_MONO}`,- color: isActive ? visual.text : 'var(--text-tertiary)',- fontVariantNumeric: 'tabular-nums'+ border: 'none',+ background: 'none',+ color: 'var(--text-tertiary)',+ font: `700 12px/1 ${FONT_UI}`,+ cursor: 'pointer',+ padding: '2px 4px',+ flexShrink: 0}}>- {isActive ? formatSpeed(group.speedBytesPerSec) : '—'}- </div>+ ⋯+ </button>+ </div>+ <div style={{ display: 'flex', alignItems: 'center', minWidth: 0 }}><divstyle={{- textAlign: 'right',- font: `11.5px/1 ${FONT_MONO}`,- color: 'var(--text-secondary)',- fontVariantNumeric: 'tabular-nums'+ flex: 1,+ height: 6,+ borderRadius: 999,+ background: 'var(--track-bg)',+ border: '0.5px solid var(--border-strong)',+ overflow: 'hidden'}}>- {formatBytes(group.bytesDownloaded)}+ <div+ style={{+ height: '100%',+ width:+ totalBytes && totalBytes > 0+ ? `${Math.min(100, Math.max(0, (group.bytesDownloaded / totalBytes) * 100))}%`+ : '0%',+ background: visual.solid,+ borderRadius: 999,+ transition: 'width 0.25s ease-out'+ }}+ /></div></div>+ <div+ style={{+ textAlign: 'right',+ font: `500 11.5px/1 ${FONT_MONO}`,+ color: sharePercent > 0 ? 'var(--text)' : 'var(--text-tertiary)',+ fontVariantNumeric: 'tabular-nums'+ }}+ >+ {groupShareDisplay}+ </div>+ <div+ style={{+ textAlign: 'right',+ font: `600 12.5px/1 ${FONT_MONO}`,+ color: isActive ? visual.text : 'var(--text-tertiary)',+ fontVariantNumeric: 'tabular-nums'+ }}+ >+ {isActive ? formatSpeed(group.speedBytesPerSec) : '—'}+ </div>+ <div+ style={{+ textAlign: 'right',+ font: `11.5px/1 ${FONT_MONO}`,+ color: 'var(--text-secondary)',+ fontVariantNumeric: 'tabular-nums'+ }}+ >+ {formatBytes(group.bytesDownloaded)}+ </div>{expanded && group.chunks.length > 0 && (<divstyle={{+ gridColumn: '1 / -1',padding: '6px 20px 10px',display: 'flex',flexDirection: 'column',diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsxindex 0cfdd66..8a4bfec 100644--- a/src/renderer/src/screens/DownloadingScreen.tsx+++ b/src/renderer/src/screens/DownloadingScreen.tsx@@ -13,6 +13,7 @@ import {dangerButtonStyle,footerStyle,footerTextStyle,+ networkTableGridStyle,networkTableHeaderStyle,primaryButtonStyle,resolveNetworkVisual,@@ -494,30 +495,32 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re{isAssembling ? 'assembling' : isPaused ? 'paused' : `${activeGroups.length} active`}</div></div>- <div style={networkTableHeaderStyle}>- <div />- <div>Network</div>- <div>Progress</div>- <div style={{ textAlign: 'right' }}>Share</div>- <div style={{ textAlign: 'right' }}>Speed</div>- <div style={{ textAlign: 'right' }}>Downloaded</div>+ <div style={networkTableGridStyle}>+ <div style={networkTableHeaderStyle}>+ <div />+ <div>Network</div>+ <div>Progress</div>+ <div style={{ textAlign: 'right' }}>Share</div>+ <div style={{ textAlign: 'right' }}>Speed</div>+ <div style={{ textAlign: 'right' }}>Downloaded</div>+ </div>+ {groups.map((group) => {+ const sharePercent =+ totalDownloadedByNetworks > 0+ ? (group.bytesDownloaded / totalDownloadedByNetworks) * 100+ : 0+ return (+ <NetworkRow+ key={group.interfaceId}+ group={group}+ sharePercent={sharePercent}+ totalBytes={download.totalBytes}+ totalDownloaded={totalDownloadedByNetworks}+ blocks={download.blocks}+ />+ )+ })}</div>- {groups.map((group) => {- const sharePercent =- totalDownloadedByNetworks > 0- ? (group.bytesDownloaded / totalDownloadedByNetworks) * 100- : 0- return (- <NetworkRow- key={group.interfaceId}- group={group}- sharePercent={sharePercent}- totalBytes={download.totalBytes}- totalDownloaded={totalDownloadedByNetworks}- blocks={download.blocks}- />- )- })}</div><div style={footerStyle}>diff --git a/src/renderer/src/theme.ts b/src/renderer/src/theme.tsindex e5b9993..dc56b03 100644--- a/src/renderer/src/theme.ts+++ b/src/renderer/src/theme.ts@@ -205,9 +205,22 @@ export const statValueStyle: React.CSSProperties = {// keep both usable at the narrowest supported width.export const NETWORK_ROW_GRID_COLUMNS = '10px minmax(190px, 1fr) minmax(160px, 2fr) 48px 78px 90px'+// The header and every NetworkRow used to each be their own independent CSS grid with this same+// column template — which happened to compute matching track widths most of the time, but wasn't+// actually *guaranteed* to, since each grid resolves its own tracks independently. The real fix+// is structural: one grid (this style, wrapping the header and every row) owns the column tracks,+// and the header/rows below opt into those exact tracks via `gridTemplateColumns: 'subgrid'`+// rather than each declaring the column list a second time — so "the columns line up" stops being+// a coincidence of matching inputs and becomes a property the browser enforces.+export const networkTableGridStyle: React.CSSProperties = {+ display: 'grid',+ gridTemplateColumns: NETWORK_ROW_GRID_COLUMNS+}+export const networkTableHeaderStyle: React.CSSProperties = {display: 'grid',- gridTemplateColumns: NETWORK_ROW_GRID_COLUMNS,+ gridTemplateColumns: 'subgrid',+ gridColumn: '1 / -1',gap: 12,padding: '10px 20px 7px',font: `400 9.5px/1 ${FONT_MONO}`,