Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
Add TruncatedText: only shows a tooltip when text is actually cut off
Anmol Kapile08d47894b4a
diff --git a/src/renderer/src/components/DevToolsPanel.tsx b/src/renderer/src/components/DevToolsPanel.tsxindex 50db738..650e979 100644--- a/src/renderer/src/components/DevToolsPanel.tsx+++ b/src/renderer/src/components/DevToolsPanel.tsx@@ -2,6 +2,7 @@ import type { NetworkInterfaceKind, SimulatedNetworkConfig } from '@shared/typesimport { useEffect, useRef, useState } from 'react'import { useAppStore } from '../store/useAppStore'import { describeError, toDisplayPath } from '../utils/format'+import { TruncatedText } from './TruncatedText'import { Button } from './ui/button'import { ToggleGroup, ToggleGroupItem } from './ui/toggle-group'import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'@@ -207,20 +208,18 @@ export function DevToolsPanel(): React.JSX.Element | null {<div className="flex flex-col gap-[5px]"><div className={fieldLabelClass}>SOURCE FILE</div><div className="flex gap-1.5">- <Tooltip>- <TooltipTrigger- render={- <div- className={`${rowInputClass} min-w-0 flex-1 truncate ${- sourceFilePath ? 'text-foreground' : 'text-muted-foreground'- }`}- >- {sourceFilePath ? toDisplayPath(sourceFilePath, homeDir) : 'No file chosen'}- </div>+ <div+ className={`${rowInputClass} min-w-0 flex-1 ${+ sourceFilePath ? 'text-foreground' : 'text-muted-foreground'+ }`}+ >+ <TruncatedText+ text={+ sourceFilePath ? toDisplayPath(sourceFilePath, homeDir) : 'No file chosen'}+ tooltipText={sourceFilePath ?? 'No file chosen'}/>- <TooltipContent>{sourceFilePath ?? 'No file chosen'}</TooltipContent>- </Tooltip>+ </div><Button type="button" variant="secondary" onClick={handleChooseFile}>Choose…</Button>@@ -230,16 +229,12 @@ export function DevToolsPanel(): React.JSX.Element | null {<div className="flex flex-col gap-[5px]"><div className={fieldLabelClass}>DESTINATION</div><div className="flex gap-1.5">- <Tooltip>- <TooltipTrigger- render={- <div className={`${rowInputClass} min-w-0 flex-1 truncate`}>- {toDisplayPath(effectiveDestinationDir, homeDir)}- </div>- }+ <div className={`${rowInputClass} min-w-0 flex-1`}>+ <TruncatedText+ text={toDisplayPath(effectiveDestinationDir, homeDir)}+ tooltipText={effectiveDestinationDir}/>- <TooltipContent>{effectiveDestinationDir}</TooltipContent>- </Tooltip>+ </div><Button type="button" variant="secondary" onClick={handleChooseDestination}>Browse…</Button>diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsxindex 794c6b0..dc7219d 100644--- a/src/renderer/src/components/NetworkRow.tsx+++ b/src/renderer/src/components/NetworkRow.tsx@@ -6,7 +6,7 @@ import type { NetworkGroup } from '../utils/format'import { formatBytes, formatSpeed } from '../utils/format'import { ColorBadge } from './ColorBadge'import { NetworkEditPopover } from './NetworkEditPopover'-import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'+import { TruncatedText } from './TruncatedText'interface NetworkRowProps {group: NetworkGroup@@ -48,16 +48,10 @@ export function NetworkRow({}}/><div className="flex min-w-0 items-center gap-[6px]">- <Tooltip>- <TooltipTrigger- render={- <span className="truncate font-sans text-[12.5px] leading-[1.2] font-semibold text-foreground">- {visual.name}- </span>- }- />- <TooltipContent>{visual.name}</TooltipContent>- </Tooltip>+ <TruncatedText+ text={visual.name}+ className="font-sans text-[12.5px] leading-[1.2] font-semibold text-foreground"+ /><NetworkEditPopoverinterfaceId={group.interfaceId}interfaceKind={group.interfaceKind}diff --git a/src/renderer/src/components/TruncatedText.tsx b/src/renderer/src/components/TruncatedText.tsxnew file mode 100644index 0000000..6563635--- /dev/null+++ b/src/renderer/src/components/TruncatedText.tsx@@ -0,0 +1,44 @@+import { useLayoutEffect, useState } from 'react'+import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'++/** Renders `text` truncated with an ellipsis, and only wires up a tooltip when it's actually cut+ * off — hovering text that already fits has nothing more to reveal. `tooltipText` lets the+ * tooltip show something fuller than what's on screen (e.g. an abbreviated path's real value)+ * when it defaults to `text` isn't enough. */+export function TruncatedText({+ text,+ tooltipText = text,+ className = ''+}: {+ text: string+ tooltipText?: string+ className?: string+}): React.JSX.Element {+ const [node, setNode] = useState<HTMLSpanElement | null>(null)+ const [isTruncated, setIsTruncated] = useState(false)++ useLayoutEffect(() => {+ if (!node) return+ const measure = (): void => setIsTruncated(node.scrollWidth > node.clientWidth)+ measure()+ const observer = new ResizeObserver(measure)+ observer.observe(node)+ return () => observer.disconnect()+ }, [node, text])++ return (+ <Tooltip open={isTruncated ? undefined : false}>+ <TooltipTrigger+ render={+ <span+ ref={setNode}+ className={`inline-block max-w-full truncate align-bottom ${className}`}+ >+ {text}+ </span>+ }+ />+ <TooltipContent>{tooltipText}</TooltipContent>+ </Tooltip>+ )+}diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsxindex d04b441..bd4ca86 100644--- a/src/renderer/src/screens/DownloadingScreen.tsx+++ b/src/renderer/src/screens/DownloadingScreen.tsx@@ -6,6 +6,7 @@ import { CombineDiagram } from '../components/CombineDiagram'import { CyclableChip } from '../components/CyclableChip'import { NetworkRow } from '../components/NetworkRow'import { ThroughputChart } from '../components/ThroughputChart'+import { TruncatedText } from '../components/TruncatedText'import { Button } from '../components/ui/button'import { Tooltip, TooltipContent, TooltipTrigger } from '../components/ui/tooltip'import { useNetworkPolling } from '../hooks/useNetworkPolling'@@ -299,16 +300,10 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re{fileExtensionBadge(download.fileName)}</div><div className="min-w-0 flex-1">- <Tooltip>- <TooltipTrigger- render={- <div className="max-w-full truncate font-sans text-[15px] leading-[1.3] font-semibold tracking-[-0.01em] text-foreground inline-block">- {download.fileName}- </div>- }- />- <TooltipContent>{download.fileName}</TooltipContent>- </Tooltip>+ <TruncatedText+ text={download.fileName}+ className="font-sans text-[15px] leading-[1.3] font-semibold tracking-[-0.01em] text-foreground"+ /><div className="mt-1 flex items-center gap-[7px] font-mono text-[12.5px] leading-[1.2] tabular-nums text-[var(--text-secondary)]"><span>{formatBytes(isAssembling ? assembledBytes : download.bytesDownloaded)}@@ -407,16 +402,10 @@ export function DownloadingScreen({ download }: { download: DownloadState }): Re<div className="flex items-center gap-3 border-t-[0.5px] border-t-[var(--footer-border)] bg-secondary px-5 py-[11px]"><div className="flex min-w-0 flex-1 items-center gap-[7px] overflow-hidden font-mono text-[11px] leading-[1.4] text-muted-foreground">- <Tooltip>- <TooltipTrigger- render={- <span className="truncate">- Saving to {toDisplayPath(dirnameOf(download.destinationPath), homeDir)}- </span>- }- />- <TooltipContent>Saving to: {download.destinationPath}</TooltipContent>- </Tooltip>+ <TruncatedText+ text={`Saving to ${toDisplayPath(dirnameOf(download.destinationPath), homeDir)}`}+ tooltipText={`Saving to: ${download.destinationPath}`}+ /><Dot shrink /><span className="shrink-0">Resumable</span>{totalRetries > 0 && (diff --git a/src/renderer/src/screens/ErrorScreen.tsx b/src/renderer/src/screens/ErrorScreen.tsxindex 0789b71..e3b3918 100644--- a/src/renderer/src/screens/ErrorScreen.tsx+++ b/src/renderer/src/screens/ErrorScreen.tsx@@ -1,7 +1,7 @@import type { DownloadState } from '@shared/types'import { useState } from 'react'+import { TruncatedText } from '../components/TruncatedText'import { Button } from '../components/ui/button'-import { Tooltip, TooltipContent, TooltipTrigger } from '../components/ui/tooltip'import { describeError, fileExtensionBadge, formatBytes } from '../utils/format'export function ErrorScreen({@@ -108,16 +108,10 @@ export function ErrorScreen({{fileExtensionBadge(download.fileName)}</div><div className="min-w-0 flex-1">- <Tooltip>- <TooltipTrigger- render={- <div className="inline-block max-w-full truncate font-sans text-[12.5px] leading-[1.3] font-semibold text-foreground">- {download.fileName}- </div>- }- />- <TooltipContent>{download.fileName}</TooltipContent>- </Tooltip>+ <TruncatedText+ text={download.fileName}+ className="font-sans text-[12.5px] leading-[1.3] font-semibold text-foreground"+ /><div className="mt-0.5 font-mono text-[11px] leading-none tabular-nums text-muted-foreground">{download.bytesDownloaded > 0 ? (<>@@ -147,17 +141,8 @@ export function ErrorScreen({{/* Footer with properly constrained, non-overflowing URL */}<div className="flex min-w-0 items-center gap-3 border-t-[0.5px] border-t-[var(--footer-border)] bg-secondary px-5 py-[11px]">- <div className="min-w-0 flex-1 truncate font-mono text-[11px] leading-none text-muted-foreground">- <Tooltip>- <TooltipTrigger- render={- <span className="inline-block max-w-full truncate align-bottom">- {download.url}- </span>- }- />- <TooltipContent>{download.url}</TooltipContent>- </Tooltip>+ <div className="min-w-0 flex-1 font-mono text-[11px] leading-none text-muted-foreground">+ <TruncatedText text={download.url} /></div><buttontype="button"