Skip to content

Comments

Fix process priority for logon startup task set to BelowNormal by default#4283

Merged
jjw24 merged 3 commits intodevfrom
copilot/fix-flow-launcher-responsiveness
Feb 24, 2026
Merged

Fix process priority for logon startup task set to BelowNormal by default#4283
jjw24 merged 3 commits intodevfrom
copilot/fix-flow-launcher-responsiveness

Conversation

@Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Feb 24, 2026

Follow on with #3218,

The default value of task.Definition.Settings.Priority seems to be BelowNormal which is used for background services.

Now we use normal for it.

Fix #4281.


Summary by cubic

Fixes sluggish responsiveness when Flow Launcher starts via the Windows logon task by setting the task’s process priority to Normal and auto-recreating it if the priority is wrong. This addresses Task Scheduler’s default BelowNormal/Low priority, fixes existing installs on next start, and closes #4281 (follow-up to #3218).

Written for commit fc3860c. Summary will update on new commits.

Copilot AI and others added 3 commits February 24, 2026 06:47
The default priority for Windows Task Scheduler tasks is Low (7),
which causes Flow Launcher to be sluggish when other processes are
consuming CPU. Explicitly set the task priority to Normal when
creating the logon startup task.

Also update CheckLogonTask() to recreate the task if the priority
is not Normal, so existing users with the incorrect priority get
automatically fixed on next startup.

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 24, 2026 07:10
@prlabeler prlabeler bot added the bug Something isn't working label Feb 24, 2026
@github-actions github-actions bot added this to the 2.1.0 milestone Feb 24, 2026
@gitstream-cm
Copy link

gitstream-cm bot commented Feb 24, 2026

🥷 Code experts: jjw24

jjw24 has most 👩‍💻 activity in the files.
jjw24 has most 🧠 knowledge in the files.

See details

Flow.Launcher/Helper/AutoStartup.cs

Activity based on git-commit:

jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link

gitstream-cm bot commented Feb 24, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the Scheduled Task configuration used for “logon task” auto-start so Flow Launcher runs at a normal process priority (avoiding sluggish behavior reported when the task defaults to BelowNormal).

Changes:

  • Set TaskDefinition.Settings.Priority to ProcessPriorityClass.Normal when creating the logon startup task.
  • Detect non-normal task priority during startup checks and recreate the logon task when needed.
Comments suppressed due to low confidence (1)

Flow.Launcher/Helper/AutoStartup.cs:74

  • When needsRecreation is true, the return values from UnscheduleLogonTask() / ScheduleLogonTask() are ignored, but ScheduleLogonTask() swallows exceptions and returns false on failure. This means task recreation can fail silently while CheckLogonTask() still returns true, so the UI may think auto-start is enabled and the app may keep retrying on every launch. Consider propagating failures here (e.g., throw when unschedule/schedule returns false, or return false from CheckLogonTask() so callers can surface the error and/or disable the setting).
                    var needsRecreation = !action.Equals(Constant.ExecutablePath, StringComparison.OrdinalIgnoreCase)
                        || task.Definition.Settings.Priority != ProcessPriorityClass.Normal;
                    if (needsRecreation)
                    {
                        UnscheduleLogonTask();
                        ScheduleLogonTask();
                    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

This change modifies the AutoStartup helper to explicitly set Normal priority for scheduled logon tasks and recreate the task if the priority is not Normal, addressing a performance regression where the process runs at Low priority by default.

Changes

Cohort / File(s) Summary
Task Priority Configuration
Flow.Launcher/Helper/AutoStartup.cs
Added System.Diagnostics using directive. Modified task refresh logic to check both executable path and task priority; now recreates task if priority is not Normal. Explicitly sets task priority to Normal when creating the scheduled logon task.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • jjw24
  • onesounds
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses issue #4281 by setting task priority to Normal and recreating the task if priority differs, which directly resolves the reported sluggishness when launched via logon task.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the logon task priority issue; the only unrelated addition is a System.Diagnostics using directive which is minor and commonly accepted.
Title check ✅ Passed The title accurately describes the main change: fixing process priority for the logon startup task by setting it to Normal instead of BelowNormal.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue with BelowNormal priority and the solution of setting Normal priority for the logon startup task.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-flow-launcher-responsiveness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Flow.Launcher/Helper/AutoStartup.cs (1)

68-74: needsRecreation logic is correct — minor note on unnecessary delete when only priority differs.

When the executable path matches but only the priority is stale, UnscheduleLogonTask() still deletes the task before ScheduleLogonTask() re-creates it. Since RegisterTaskDefinition overwrites an existing task by name, the initial unschedule is redundant in the priority-only-mismatch case and creates a brief window (milliseconds) where no startup task is registered. It's harmless in practice, but the delete step could be skipped and ScheduleLogonTask() called directly to update in-place.

♻️ Optional simplification
-                    var needsRecreation = !action.Equals(Constant.ExecutablePath, StringComparison.OrdinalIgnoreCase)
-                        || task.Definition.Settings.Priority != ProcessPriorityClass.Normal;
-                    if (needsRecreation)
-                    {
-                        UnscheduleLogonTask();
-                        ScheduleLogonTask();
-                    }
+                    var pathChanged = !action.Equals(Constant.ExecutablePath, StringComparison.OrdinalIgnoreCase);
+                    var priorityWrong = task.Definition.Settings.Priority != ProcessPriorityClass.Normal;
+                    if (pathChanged || priorityWrong)
+                    {
+                        if (pathChanged)
+                        {
+                            UnscheduleLogonTask();
+                        }
+                        ScheduleLogonTask();
+                    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Flow.Launcher/Helper/AutoStartup.cs` around lines 68 - 74, The current logic
computes needsRecreation and always calls UnscheduleLogonTask() before
ScheduleLogonTask(), which unnecessarily deletes the existing task when only
Priority differs; change the flow so that when needsRecreation is true but the
action equals Constant.ExecutablePath (i.e., only
task.Definition.Settings.Priority != ProcessPriorityClass.Normal) skip
UnscheduleLogonTask() and call ScheduleLogonTask() directly so
RegisterTaskDefinition can overwrite in-place; adjust the condition around
UnscheduleLogonTask() to only delete when action differs from
Constant.ExecutablePath.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Flow.Launcher/Helper/AutoStartup.cs`:
- Around line 68-74: The current logic computes needsRecreation and always calls
UnscheduleLogonTask() before ScheduleLogonTask(), which unnecessarily deletes
the existing task when only Priority differs; change the flow so that when
needsRecreation is true but the action equals Constant.ExecutablePath (i.e.,
only task.Definition.Settings.Priority != ProcessPriorityClass.Normal) skip
UnscheduleLogonTask() and call ScheduleLogonTask() directly so
RegisterTaskDefinition can overwrite in-place; adjust the condition around
UnscheduleLogonTask() to only delete when action differs from
Constant.ExecutablePath.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73f657f and fc3860c.

📒 Files selected for processing (1)
  • Flow.Launcher/Helper/AutoStartup.cs

@jjw24 jjw24 changed the title Fix: Set Normal process priority for logon startup task Fix process priority for logon startup task set to BelowNormal by default Feb 24, 2026
@jjw24 jjw24 enabled auto-merge (squash) February 24, 2026 10:17
@jjw24 jjw24 merged commit 3b3a59f into dev Feb 24, 2026
21 checks passed
@jjw24 jjw24 deleted the copilot/fix-flow-launcher-responsiveness branch February 24, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Process is less responsive than usual when run via logon startup task

3 participants