Skip to content

refactor: update active download criteria to account for paused, pausing, and resuming states#343

Merged
SuperCoolPencil merged 4 commits intomainfrom
pause-active-fix
Apr 10, 2026
Merged

refactor: update active download criteria to account for paused, pausing, and resuming states#343
SuperCoolPencil merged 4 commits intomainfrom
pause-active-fix

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 10, 2026

Close #329

Greptile Summary

This PR updates the TUI's active download criteria to correctly account for pausing, paused, and resuming states. Downloads in the pausing state now correctly appear in the Queued tab (not Active), with consistent logic applied across getFilteredDownloads(), ComputeViewStats(), UpdateListItems(), and the detail-view isActive check. Tests are added in filtering_test.go covering both the new pausing state and consistency between tab counts and the filter function.

Confidence Score: 5/5

Safe to merge; all filtering, stat-counting, and tab-assignment logic is mutually consistent and backed by targeted tests.

No P0 or P1 issues found. The single P2 finding (calcTotalSpeed briefly counting a pausing download's speed) is a transient UX glitch that resolves as soon as the download fully stops. All changed code paths are consistent with each other and well-covered by the new tests.

internal/tui/view.go — calcTotalSpeed (minor, P2 only)

Important Files Changed

Filename Overview
internal/tui/model.go Core change: getFilteredDownloads() updated to exclude pausing downloads from Active and include them in Queued; logic is consistent with ComputeViewStats and UpdateListItems.
internal/tui/view.go ComputeViewStats and isActive detail-view check correctly exclude pausing; however calcTotalSpeed still includes speed from pausing downloads, creating a brief inconsistency between the network graph and the Active tab.
internal/tui/list.go UpdateListItems tab-assignment logic updated to include !d.pausing condition, consistent with getFilteredDownloads.
internal/tui/filtering_test.go New test file with TestTabFiltering (including pausing cases) and TestComputeViewStatsConsistency validating count-filter agreement across all tabs.
internal/tui/view_test.go Updated to test getDownloadStatus for pausing and resuming states; existing layout/rendering tests unchanged.
internal/tui/constants.go Layout constants file; no functional changes related to this PR's state-filtering refactor.
internal/tui/layout_helpers.go Layout helper functions; no changes related to the download-state filtering refactor.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[DownloadModel] --> B{d.done?}
    B -- yes --> DONE[TabDone / DownloadedCount]
    B -- no --> C{d.paused OR d.pausing?}
    C -- yes --> QUEUED[TabQueued / QueuedCount]
    C -- no --> D{Speed > 0 OR Connections > 0 OR resuming?}
    D -- yes --> ACTIVE[TabActive / ActiveCount]
    D -- no --> QUEUED
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: internal/tui/view.go
Line: 1093-1103

Comment:
**`calcTotalSpeed` includes speed from `pausing` downloads**

Now that `pausing` downloads are moved to the Queued tab, a user can see the Active tab show 0 items while the network graph and header speed still register a non-zero value (from the in-flight `pausing` download). Before this PR, the download stayed in Active, so the inconsistency didn't arise. Adding a `!d.pausing` guard makes the graph consistent with the tab view:

```suggestion
func (m RootModel) calcTotalSpeed() float64 {
	total := 0.0
	for _, d := range m.downloads {
		// Skip completed and transitioning-to-pause downloads
		if d.done || d.pausing {
			continue
		}
		total += d.Speed
	}
	return total / float64(config.MB)
}
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "fix: update settings layout constants an..." | Re-trigger Greptile

Comment thread internal/tui/filtering_test.go
@SuperCoolPencil SuperCoolPencil merged commit cd95a58 into main Apr 10, 2026
15 checks passed
@SuperCoolPencil SuperCoolPencil deleted the pause-active-fix branch April 10, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paused downloads show up in both Active and Queued tabs

1 participant