-
Notifications
You must be signed in to change notification settings - Fork 0
Windows port — Phase 6: scheduling, autostart & notifications #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c7f09f3
docs(win): Phase 6 implementation plan (scheduling, autostart, notifi…
c587c4b
feat(windows): autostart via HKCU Run key (replaces Phase 6 no-op stub)
64c9243
feat(windows): weekly cleanup via schtasks targeting %LOCALAPPDATA%\Temp
bdaabdc
feat(windows): WinRT toast notifications for scheduled cleanup + low-…
ab5d870
fix(win): idempotent schedule disable (deleting an absent schtasks ta…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
710 changes: 710 additions & 0 deletions
710
docs/superpowers/plans/2026-06-26-windows-port-phase-6-scheduling-ux.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
| //! Windows desktop notifications via the WinRT `ToastNotificationManager`, | ||
| //! driven through PowerShell. No extra crate, no `unsafe`. Best-effort: any | ||
| //! failure is swallowed — a missing toast must never break a cleanup or the | ||
| //! low-space monitor. | ||
|
|
||
| /// Show a Windows toast with the given title and body. Best-effort (errors are | ||
| /// ignored). | ||
| pub(crate) fn show(title: &str, body: &str) { | ||
| const PS: &str = r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"; | ||
| const APP_ID: &str = | ||
| r"{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe"; | ||
|
|
||
| let script = format!( | ||
| "[Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType=WindowsRuntime]|Out-Null;\ | ||
| $x=[Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02);\ | ||
| $t=$x.GetElementsByTagName('text');\ | ||
| $t.Item(0).AppendChild($x.CreateTextNode('{title}'))|Out-Null;\ | ||
| $t.Item(1).AppendChild($x.CreateTextNode('{body}'))|Out-Null;\ | ||
| $n=[Windows.UI.Notifications.ToastNotification]::new($x);\ | ||
| [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('{app}').Show($n)", | ||
| title = escape_ps_literal(title), | ||
| body = escape_ps_literal(body), | ||
| app = APP_ID, | ||
| ); | ||
|
|
||
| let _ = std::process::Command::new(PS) | ||
| .args(["-NoProfile", "-NonInteractive", "-Command", &script]) | ||
| .status(); | ||
| } | ||
|
|
||
| /// Double single quotes so a string is safe inside a PowerShell single-quoted | ||
| /// literal (`'...'`) — the only escaping such literals require. | ||
| fn escape_ps_literal(s: &str) -> String { | ||
| s.replace('\'', "''") | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::escape_ps_literal; | ||
|
|
||
| #[test] | ||
| fn doubles_single_quotes() { | ||
| assert_eq!(escape_ps_literal("it's a 'test'"), "it''s a ''test''"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn leaves_plain_text_unchanged() { | ||
| assert_eq!(escape_ps_literal("12.3 GB freed"), "12.3 GB freed"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the Windows scheduled task runs with
--apply, this path scans%LOCALAPPDATA%\TempthroughTempService::scan(), whose directory branch adds every non-empty immediate child directory without applying themin_age_dayscutoff (only loose files are age-filtered). With a fresh installer/app temp directory present at the weekly run,clean_rootwill pass that directory toto_trash, so the scheduled cleanup can remove active recent temp trees rather than only stale files.Useful? React with 👍 / 👎.