Skip to content

feat(app): quit, sleep or shut down when downloads finish - #580

Merged
linroid merged 4 commits into
mainfrom
feat/when-downloads-finish
Oct 18, 2026
Merged

linroid merged 4 commits into
mainfrom
feat/when-downloads-finish

Conversation

@linroid

@linroid linroid commented Oct 17, 2026

Copy link
Copy Markdown
Owner

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.

  • Settings → General → Power gets a When downloads finish choice: Do nothing, Quit Ketch, Sleep, Shut down. It is in settings search too.
  • 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.
  • A sticky warning, also a system notification while the app is not in front, gives one minute with Cancel and a button to run it at once. Downloads that start again withdraw it until they finish too.
  • The choice is never saved and runs once, so a later launch or a wake from sleep never shuts the computer down unasked. A failure posts an error toast.
  • DesktopFinishActions quits through CloseBehavior.quitWithoutAsking. It runs pmset sleepnow and System Events' shut down on macOS (macOS asks once to let Ketch control System Events), SetSuspendState and shutdown /s /t 0 on Windows, and systemctl suspend/poweroff on Linux.
  • Strings are added in all ten languages. AGENTS.md and the READMEs move the feature from the roadmap to the features list.

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.

Before After
Light
Dark

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, failures
  • DesktopFinishActionsTest: the command for each system, quit, failures
  • LocalizationResourcesTest, HardcodedTextTest, the settings tests, DesignTokenUsageTest; desktop and Android compile
  • Manually: sleep and shut down on macOS, Windows and Linux

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T15:55:26.925883Z 730ccf1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 2 051 files  + 3   2 079 suites  +3   32m 28s ⏱️ +15s
13 744 tests +38  13 479 ✅ +36  265 💤 +3  0 ❌  - 1 
16 735 runs  +42  16 470 ✅ +40  265 💤 +3  0 ❌  - 1 

Results for commit 4b36756. ± Comparison against base commit 1ad0e33.

♻️ This comment has been updated with latest results.

…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.
@linroid
linroid merged commit 030d4eb into main Oct 18, 2026
14 checks passed
@linroid
linroid deleted the feat/when-downloads-finish branch October 18, 2026 00:08
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.

1 participant