Skip to content

feat(shutdown): added functionality to shutdown surge when all downloads are done - #538

Merged
junaid2005p merged 5 commits into
mainfrom
shutdown
Jul 15, 2026
Merged

feat(shutdown): added functionality to shutdown surge when all downloads are done#538
junaid2005p merged 5 commits into
mainfrom
shutdown

Conversation

@junaid2005p

@junaid2005p junaid2005p commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

…ads are done

Greptile Summary

This PR adds automatic system shutdown after all downloads finish. The main changes are:

  • A configurable auto-shutdown setting and TUI status indicator.
  • Cross-platform shutdown and sleep-inhibitor controllers.
  • Download-state reconciliation for completion, deletion, purge, and enqueue events.
  • Delayed shutdown retries with sleep prevention during backoff.
  • Tests for completion, paused downloads, deletion, settings, and retries.

Confidence Score: 5/5

This looks safe to merge.

The Windows inhibitor now releases execution state on the thread that acquired it. Download removal paths now refresh auto-shutdown state. Failed shutdowns retain sleep prevention and retry after a delay.

No blocking issues remain in the changed paths.

T-Rex T-Rex Logs

What T-Rex did

  • The baseline focused test run for TestAutoShutdown completed successfully (exit code 0).
  • The race-enabled test run for TestAutoShutdown completed successfully (exit code 0).
  • A separate captured command enumerated the fake Shutdown/AcquireInhibitor seam with counter assertions and all six tests executed.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
internal/power/power_windows.go Keeps Windows execution-state acquisition and release on the same locked OS thread.
internal/tui/power.go Manages auto-shutdown arming, inhibition, shutdown execution, and delayed retries.
internal/tui/update_events.go Reconciles auto-shutdown after download events and handles shutdown retry messages.
internal/tui/update_dashboard.go Reconciles auto-shutdown after downloads are removed from the dashboard.
internal/tui/update_modals.go Releases the power inhibitor on quit or restart and reconciles purge actions.
internal/tui/power_test.go Tests shutdown triggering, blocking states, setting changes, deletion, and retry behavior.

Reviews (5): Last reviewed commit: "tui: keep power inhibitor during auto-sh..." | Re-trigger Greptile

@junaid2005p junaid2005p changed the title feat(shutdown): added functionality to shutdown surge when all downlo… feat(shutdown): added functionality to shutdown surge when all downloads are done Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Binary Size Analysis

⚠️ Size Increased

Version Human Readable Raw Bytes
Main 17.06 MB 17887524
PR 17.57 MB 18428196
Difference 528.00 KB 540672

Comment thread internal/power/power_windows.go Outdated
Comment thread internal/tui/update_events.go
Comment thread internal/tui/power.go Outdated
…threads locked it toso the set and release happen in one OS thread only
Comment thread internal/tui/power.go
@SuperCoolPencil

Copy link
Copy Markdown
Member
image

icon not centered :(

@junaid2005p

Copy link
Copy Markdown
Collaborator Author

icon not centered :(

noted. will fix.

Comment thread internal/tui/power.go
@junaid2005p
junaid2005p merged commit 18f3b7d into main Jul 15, 2026
14 checks passed
@junaid2005p
junaid2005p deleted the shutdown branch July 15, 2026 12:39
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.

2 participants