fix(ui): fence stale allocation status

- keep paused and completed rows authoritative over transient allocation state

- preserve allocation feedback for failed-download retries

- expose the table allocation phase as an accessible indeterminate progressbar
This commit is contained in:
NimBold
2026-08-16 00:09:21 +03:30
parent 6aa07db5df
commit bdbc11ad94
4 changed files with 40 additions and 10 deletions
+11
View File
@@ -8,6 +8,7 @@ import {
canonicalizeDownloadFileName,
categoryForDownload,
categoryForFileName,
isAllocationPhaseVisible,
isValidTorrentExcludeTrackerList,
isValidTorrentTrackerList,
normalizeTorrentEncryptionPolicy,
@@ -107,6 +108,16 @@ describe('download persistence progress snapshots', () => {
});
});
describe('allocation phase visibility', () => {
it('does not override paused or completed statuses', () => {
expect(isAllocationPhaseVisible(true, 'ready')).toBe(true);
expect(isAllocationPhaseVisible(true, 'failed')).toBe(true);
expect(isAllocationPhaseVisible(true, 'paused')).toBe(false);
expect(isAllocationPhaseVisible(true, 'completed')).toBe(false);
expect(isAllocationPhaseVisible(false, 'downloading')).toBe(false);
});
});
describe('Torrent tracker input validation', () => {
it('accepts supported trackers separated by lines or commas', () => {
expect(isValidTorrentTrackerList(
+10
View File
@@ -45,6 +45,16 @@ export const isActiveDownloadStatus = (status: DownloadStatus): boolean =>
export const isTransferActiveStatus = (status: DownloadStatus): boolean =>
status === 'downloading' || status === 'processing' || status === 'verifying' || status === 'seeding' || status === 'retrying';
/**
* A transient allocation flag must never replace a terminal or user-paused
* status in the UI. Failed rows remain eligible because retry admission can
* begin from the failed state before the backend accepts the new lifecycle.
*/
export const isAllocationPhaseVisible = (
allocationPending: boolean,
status: DownloadStatus,
): boolean => allocationPending && status !== 'completed' && status !== 'paused';
export const DOWNLOAD_CONNECTIONS_MIN = 1;
export const DOWNLOAD_CONNECTIONS_MAX = 16;