Repository navigation
feat(app): quit, sleep or shut down when downloads finish - #580
Conversation
Settings → General → Power gets a When downloads finish choice on desktop: do nothing, quit Ketch, put the computer to sleep or shut it down once the embedded device's downloads finish. A one-minute sticky warning (also a system notification) offers Cancel or running it at once; downloads that start again put it off. The choice is never saved and runs once.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 730ccf1594
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… changes pmset sleepnow needs root, so macOS sleeps through System Events like shut down. The finish action follows ForegroundPolicy.statuses, which is not sampled, so a download that starts and ends within a second still counts and one started during the grace period puts the action off at once; the action also checks it is still idle before it runs.
…ds first A peer that dials us replaces our dial to it and inherits whether that dial brought payload when it takes over. Payload that arrived after the takeover, or results that reached the swarm in the other order, left the kept connection looking empty, so the endpoint was redialed as one that never delivered and given up after three dials. The replaced dial's payload now marks the endpoint delivered, rescheduling a redial already queued. Fixes the flaky TorrentSwarmRedialTest.peerKeptOverOurDial_isDialedThereAgainUntilItIsBack.
Summary
Implements the roadmap's "When downloads finish": the desktop app can quit Ketch, put the computer to sleep or shut it down once its downloads finish.
WhenDownloadsFinish(app/shared,AppState.whenDownloadsFinish) waits for the embedded device to go from downloading, starting or queueing (ForegroundStatus.keepsAwake) to idle. A choice made while idle waits for downloads to run and finish. Paused and failed tasks don't hold it back.DesktopFinishActionsquits throughCloseBehavior.quitWithoutAsking. It runspmset sleepnowand System Events'shut downon macOS (macOS asks once to let Ketch control System Events),SetSuspendStateandshutdown /s /t 0on Windows, andsystemctl suspend/poweroffon Linux.Phones can't be put to sleep or shut down this way, so Android and iOS don't show the row.
Snapshots
Settings → General. "Before" renders the same scenario without the host's finish actions, which is what main shows.
Test plan
WhenDownloadsFinishTest: the warning and grace period, runs once, a choice made while idle or while busy, Cancel, run now, downloads starting again, server-only activity, failuresDesktopFinishActionsTest: the command for each system, quit, failuresLocalizationResourcesTest,HardcodedTextTest, the settings tests,DesignTokenUsageTest; desktop and Android compile