fix(torrent): harden lifecycle and properties state

- admit valid magnets immediately while keeping metadata refresh optional
- fence Torrent recovery, diagnostics, and allocation presentation by lifecycle
- avoid false peer-wait claims when telemetry is missing or malformed
- stabilize Properties metric label/value layout for narrow and RTL windows

Tests:
- npm test -- --run
- npm run build
- npm run check:i18n
- node --test scripts/*.node-test.js
- cargo test --all-targets
- npm run smoke:torrent
- npm run smoke:torrent:failure-paths
- git diff --check
This commit is contained in:
NimBold
2026-08-24 15:51:24 +03:30
parent a6b341f9e3
commit b5ee53140d
20 changed files with 452 additions and 84 deletions
+13 -1
View File
@@ -19,6 +19,7 @@ import {
resolveDownloadSizeDisplay,
resolveDownloadFraction
} from '../utils/downloadProgress';
import { isTorrentWaitingForPeers } from '../utils/torrentPresentation';
import {
COLUMN_ALIGNMENT_JUSTIFY,
getDownloadActionPosition,
@@ -84,7 +85,16 @@ export const DownloadItem = React.memo<DownloadItemProps>(({
const [isActionHovered, setIsActionHovered] = React.useState(false);
const [isActionFocused, setIsActionFocused] = React.useState(false);
const [actionPosition, setActionPosition] = React.useState<React.CSSProperties | undefined>();
const allocationVisible = isAllocationPhaseVisible(allocationPending, download.status);
const waitingForPeers = isTorrentWaitingForPeers({
isTorrent: download.isTorrent,
status: download.status,
downloadedBytes: liveProgress?.downloaded_bytes ?? download.downloadedBytes,
fraction: liveProgress?.fraction ?? download.fraction,
connectedPeers: liveProgress?.active_connections,
connectedSeeders: liveProgress?.num_seeders,
});
const allocationVisible = download.isTorrent !== true
&& isAllocationPhaseVisible(allocationPending, download.status);
const hasRowActions = download.status !== 'completed';
const isBulkSelection = isSelected && selectedDownloadCount > 1;
const pauseSelectionCount = isBulkSelection && selectedActionCounts.pause > 0
@@ -238,6 +248,8 @@ export const DownloadItem = React.memo<DownloadItemProps>(({
})();
const downloadStatusLabel = allocationVisible
? t($ => $.downloads.status.allocatingFiles)
: waitingForPeers
? t($ => $.downloads.status.waitingForPeers)
: t($ => $.downloads.status[download.status]);
const visibleErrorStatusLabel = download.credentialsRequired === true
? t($ => $.properties.credentialsRequired)