Add confirmation popup for removing downloads#539
Conversation
… a message saying progress will be lost
| if !d.done { | ||
| m.removeTargetID = d.ID | ||
| m.quitConfirmFocused = 1 // default focus on "Cancel" | ||
| m.state = RemoveConfirmState | ||
| return m, nil | ||
| } |
There was a problem hiding this comment.
Errored Downloads Bypass Confirmation
done is also set for failed downloads, including downloads with partial progress. Pressing remove on such an entry skips the new confirmation and immediately deletes its resumable state, even though it has the same progress-loss risk as an active or paused download.
| if !d.done { | |
| m.removeTargetID = d.ID | |
| m.quitConfirmFocused = 1 // default focus on "Cancel" | |
| m.state = RemoveConfirmState | |
| return m, nil | |
| } | |
| if !d.done || d.err != nil { | |
| m.removeTargetID = d.ID | |
| m.quitConfirmFocused = 1 // default focus on "Cancel" | |
| m.state = RemoveConfirmState | |
| return m, nil | |
| } |
Rule Used: What: All code changes must include tests for edge... (source)
Artifacts
Repro: focused Go test exercising the real TUI delete state transition
- Contains supporting evidence from the run (text/x-go; charset=utf-8).
Repro: verbose failing test output showing immediate deletion without confirmation
- Keeps the command output available without making the summary code-heavy.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/tui/update_dashboard.go
Line: 146-151
Comment:
**Errored Downloads Bypass Confirmation**
`done` is also set for failed downloads, including downloads with partial progress. Pressing remove on such an entry skips the new confirmation and immediately deletes its resumable state, even though it has the same progress-loss risk as an active or paused download.
```suggestion
if !d.done || d.err != nil {
m.removeTargetID = d.ID
m.quitConfirmFocused = 1 // default focus on "Cancel"
m.state = RemoveConfirmState
return m, nil
}
```
**Rule Used:** What: All code changes must include tests for edge... ([source](https://app.greptile.com/surge-org-3/-/custom-context?memory=2b22782d-3452-4d55-b059-e631b2540ce8))
How can I resolve this? If you propose a fix, please make it concise.| } else if len(filename) > 30 { | ||
| filename = filename[:27] + "..." |
There was a problem hiding this comment.
When a filename contains multibyte characters, byte 27 can fall inside a UTF-8 sequence. The confirmation modal then displays malformed text or replacement characters instead of the target filename.
Rule Used: What: All code changes must include tests for edge... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/tui/view.go
Line: 952-953
Comment:
**Byte Slice Corrupts UTF-8**
When a filename contains multibyte characters, byte 27 can fall inside a UTF-8 sequence. The confirmation modal then displays malformed text or replacement characters instead of the target filename.
**Rule Used:** What: All code changes must include tests for edge... ([source](https://app.greptile.com/surge-org-3/-/custom-context?memory=2b22782d-3452-4d55-b059-e631b2540ce8))
How can I resolve this? If you propose a fix, please make it concise.| if !d.done { | ||
| m.removeTargetID = d.ID | ||
| m.quitConfirmFocused = 1 // default focus on "Cancel" | ||
| m.state = RemoveConfirmState |
There was a problem hiding this comment.
Incoming Requests Replace Modal State
RemoveConfirmState is not included in the busy states that queue incoming download requests. If an extension or API request triggers another confirmation while this modal is open, that state replaces the removal modal and leaves removeTargetID pending, so the original confirmation cannot be completed or cancelled normally.
Rule Used: What: All code changes must include tests for edge... (source)
Artifacts
Repro: focused in-process TUI state-machine test
- Contains supporting evidence from the run (text/x-go; charset=utf-8).
Repro: verbose failing test output showing modal replacement and orphaned removal target
- Keeps the command output available without making the summary code-heavy.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/tui/update_dashboard.go
Line: 149
Comment:
**Incoming Requests Replace Modal State**
`RemoveConfirmState` is not included in the busy states that queue incoming download requests. If an extension or API request triggers another confirmation while this modal is open, that state replaces the removal modal and leaves `removeTargetID` pending, so the original confirmation cannot be completed or cancelled normally.
**Rule Used:** What: All code changes must include tests for edge... ([source](https://app.greptile.com/surge-org-3/-/custom-context?memory=2b22782d-3452-4d55-b059-e631b2540ce8))
How can I resolve this? If you propose a fix, please make it concise.
Greptile Summary
This PR adds confirmation before removing unfinished downloads. The main changes are:
Confidence Score: 4/5
Errored downloads can still be removed without confirmation, and incoming requests can interrupt the new modal state.
Target IDs remain stable across list updates. Confirmation and cancellation clear their pending state. Failed downloads are misclassified as completed for removal. External requests can replace the removal modal before a decision.
internal/tui/update_dashboard.go and internal/tui/view.go
What T-Rex did
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat(tui): added a popup before removing..." | Re-trigger Greptile