[PR #4908] [MERGED] Add startup task, setting to launch application on login #26023

Open
opened 2026-01-31 09:13:26 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4908
Author: @jelster
Created: 3/13/2020
Status: Merged
Merged: 6/1/2020
Merged by: @undefined

Base: masterHead: dev/jelster/enable-onstartup


📝 Commits (10+)

  • 724d08f Add uwp5 extensions, startup task to appx manifest
  • 273956a Add StartOnUserLogin setting to global settings
  • 72a0bc1 Pull Windows.ApplicationModel into project. Add logic to control start task status
  • 6423c97 Change startup task display name in manifest to pull from res
  • 35dcdb1 Add call to apply startup task setting on application load
  • 9a84eac Add settings schema entry for startOnUserLogin.
  • 59e964c Apply code formatting changes
  • db9d89c Merge branch 'master' into dev/jelster/enable-onstartup
  • c282610 Merge branch 'master' into dev/jelster/enable-onstartup
  • 99f7813 Merge branch 'master' of https://github.com/microsoft/terminal into dev/jelster/enable-onstartup

📊 Changes

11 files changed (+79 additions, -2 deletions)

View changed files

📝 doc/cascadia/SettingsSchema.md (+9 -0)
📝 src/cascadia/CascadiaPackage/Package-Dev.appxmanifest (+7 -0)
📝 src/cascadia/CascadiaPackage/Package-Pre.appxmanifest (+7 -1)
📝 src/cascadia/CascadiaPackage/Package.appxmanifest (+7 -0)
📝 src/cascadia/TerminalApp/App.cpp (+0 -1)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+41 -0)
📝 src/cascadia/TerminalApp/AppLogic.h (+1 -0)
📝 src/cascadia/TerminalApp/GlobalAppSettings.cpp (+3 -0)
📝 src/cascadia/TerminalApp/GlobalAppSettings.h (+2 -0)
📝 src/cascadia/TerminalApp/defaults.json (+1 -0)
📝 src/cascadia/TerminalApp/lib/pch.h (+1 -0)

📄 Description

Summary of the Pull Request

This PR adds a new boolean global setting, startOnUserLogin, along with associated AppLogic to request enabling or disabling of the StartupTask. Added UAP5 extensions to AppX manifests.

References

#2189

PR Checklist

  • Closes Animated backgrounds cause crashes for some people (#2189)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2189

Detailed Description of the Pull Request / Additional comments

Please note, I'm a non-practicing C++ developer, there are a number of things I wasn't sure how to handle in the appropriate fashion, mostly around error handling and what probably looks like an incredibly naive (and messy) way to implement the async co_await behavior.

Error handling-wise, I found (don't ask me how!) that if you somehow mismatch the startup task's ID between the manifest and the call to StartupTask::GetAsync(hstring taskId), you'll get a very opaque WinRT exception that boils down to a generic invalid argument message. This isn't likely to happen in the wild, but worth mentioning...

I had enough trouble getting myself familiarized with the project, environment, and C++/WinRT in general didn't want to try to tackle adding tests for this quite yet since (as I mentioned) I don't really know what I'm doing. I'm happy to give it a try with perhaps a bit of assistance in getting started 😃

Further work in this area of the application outside of this immediate PR might need to include adding an additional setting to contain launch args that the startup task can pass to the app so that users can specify a non-default profile to launch on start, window position (e.g., #653).

Validation Steps Performed

✔️ Default settings:
Given the user does not have the startOnUserLogin setting in their profile.json,
When the default settings are opened (via alt+click on Settings),
Then the global settings should contain the "startOnUserLogin": false token

✔️ Applying setting on application launch
Given the startOnUserLogin is true and
the Windows Terminal startup task is disabled and
the application is not running
When the application is launched
Then the Windows Terminal entry in the user's Startup list should be enabled

✔️ Applying setting on settings change
Given the startOnUserLogin is true and
the Windows Terminal startup task is enabled and
the application is running
When the startOnUserLogin setting is changed to false and
the settings file is saved to disk
Then the Windows Terminal startup task entry should be disabled

✔️ Setting is ignored when user has manually disabled startup
Given the startOnUserLogin is true and
the application is not running and
the Windows Terminal startup task has been set to disabled via user action
When the application is launched
Then the startup task should remain disabled and
the application should not throw an exception

note: Task Manager does not seem to re-scan startup task states after launch; the Settings -> Apps -> Startup page also requires closing or moving away to refresh the status of entries


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4908 **Author:** [@jelster](https://github.com/jelster) **Created:** 3/13/2020 **Status:** ✅ Merged **Merged:** 6/1/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/jelster/enable-onstartup` --- ### 📝 Commits (10+) - [`724d08f`](https://github.com/microsoft/terminal/commit/724d08f2c06a18f68f41ed7b0fa24a24617aa055) Add uwp5 extensions, startup task to appx manifest - [`273956a`](https://github.com/microsoft/terminal/commit/273956a6ffd6824998f72b779072d23b672b4a2b) Add StartOnUserLogin setting to global settings - [`72a0bc1`](https://github.com/microsoft/terminal/commit/72a0bc10a7889fb1057fec48b662361d43da1118) Pull Windows.ApplicationModel into project. Add logic to control start task status - [`6423c97`](https://github.com/microsoft/terminal/commit/6423c97bf71b2ad91d14085a5e8a6bd2bd0522a6) Change startup task display name in manifest to pull from res - [`35dcdb1`](https://github.com/microsoft/terminal/commit/35dcdb18301d70a914ba10e730950428716c27c9) Add call to apply startup task setting on application load - [`9a84eac`](https://github.com/microsoft/terminal/commit/9a84eac11c6a471ad3a5a965b23abaa2c894652e) Add settings schema entry for startOnUserLogin. - [`59e964c`](https://github.com/microsoft/terminal/commit/59e964cbf50abdf90349e8b0c653fee0ba85cdf5) Apply code formatting changes - [`db9d89c`](https://github.com/microsoft/terminal/commit/db9d89c44f8b1a58c225e300dd63580bb27730e5) Merge branch 'master' into dev/jelster/enable-onstartup - [`c282610`](https://github.com/microsoft/terminal/commit/c282610011b41a286f7b023c6b65cb64a817d979) Merge branch 'master' into dev/jelster/enable-onstartup - [`99f7813`](https://github.com/microsoft/terminal/commit/99f7813d4f7c2e4c44315d6d305c4167581d3cd3) Merge branch 'master' of https://github.com/microsoft/terminal into dev/jelster/enable-onstartup ### 📊 Changes **11 files changed** (+79 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/SettingsSchema.md` (+9 -0) 📝 `src/cascadia/CascadiaPackage/Package-Dev.appxmanifest` (+7 -0) 📝 `src/cascadia/CascadiaPackage/Package-Pre.appxmanifest` (+7 -1) 📝 `src/cascadia/CascadiaPackage/Package.appxmanifest` (+7 -0) 📝 `src/cascadia/TerminalApp/App.cpp` (+0 -1) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+41 -0) 📝 `src/cascadia/TerminalApp/AppLogic.h` (+1 -0) 📝 `src/cascadia/TerminalApp/GlobalAppSettings.cpp` (+3 -0) 📝 `src/cascadia/TerminalApp/GlobalAppSettings.h` (+2 -0) 📝 `src/cascadia/TerminalApp/defaults.json` (+1 -0) 📝 `src/cascadia/TerminalApp/lib/pch.h` (+1 -0) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR adds a new boolean global setting, startOnUserLogin, along with associated AppLogic to request enabling or disabling of the StartupTask. Added UAP5 extensions to AppX manifests. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #2189 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #2189 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [x] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2189 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Please note, I'm a non-practicing C++ developer, there are a number of things I wasn't sure how to handle in the appropriate fashion, mostly around error handling and what probably looks like an incredibly naive (and messy) way to implement the async co_await behavior. Error handling-wise, I found (don't ask me how!) that if you somehow mismatch the startup task's ID between the manifest and the call to `StartupTask::GetAsync(hstring taskId)`, you'll get a very opaque WinRT exception that boils down to a generic invalid argument message. This isn't likely to happen in the wild, but worth mentioning... I had enough trouble getting myself familiarized with the project, environment, and C++/WinRT in general didn't want to try to tackle adding tests for this quite yet since (as I mentioned) I don't really know what I'm doing. I'm happy to give it a try with perhaps a bit of assistance in getting started 😃 Further work in this area of the application outside of this immediate PR might need to include adding an additional setting to contain launch args that the startup task can pass to the app so that users can specify a non-default profile to launch on start, window position (e.g., #653). <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed ✔️ Default settings: Given the user does not have the `startOnUserLogin` setting in their profile.json, When the default settings are opened (via alt+click on Settings), Then the global settings should contain the `"startOnUserLogin": false` token ✔️ Applying setting on application launch Given the `startOnUserLogin` is `true` and the `Windows Terminal` startup task is `disabled` and the application is not running When the application is launched Then the `Windows Terminal` entry in the user's Startup list should be `enabled` ✔️ Applying setting on settings change Given the `startOnUserLogin` is `true` and the `Windows Terminal` startup task is `enabled` and the application is running When the `startOnUserLogin` setting is changed to `false` and the settings file is saved to disk Then the `Windows Terminal` startup task entry should be `disabled` ✔️ Setting is ignored when user has manually disabled startup Given the `startOnUserLogin` is `true` and the application is not running and the `Windows Terminal` startup task has been set to `disabled` via user action When the application is launched Then the startup task should remain disabled and the application should not throw an exception #### note: Task Manager does not seem to re-scan startup task states after launch; the Settings -> Apps -> Startup page also requires closing or moving away to refresh the status of entries --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:13:26 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26023