Repository navigation
Description
Summary
When setup turns on Start with Windows in a session without elevation, the registration it falls back to has no --background. Companion then opens its window at every logon instead of starting quietly. A second defect in the same path makes setup report that startup registration could not be confirmed, even when the app's own task is in place.
Cause
Run key without the argument. A logon scheduled task needs elevation here, so schtasks /Create is refused and setup falls back to the Run key. The two writers in AutoStartManager disagree:
// ApplySetupPreferenceAsync, the setup path
key.SetValue(AppName, $"\"{exe}\"");
// SetUnpackagedAutoStart, the Settings path
key.SetValue(AppName, $"\"{exePath}\" --background");docs/CONNECTION_ARCHITECTURE.md says new autostart registrations pass --background to remain quiet, and ActivationRouterTests pins that an unpackaged launch with no arguments opens a window. installer.iss already migrates this exact argument-free value to --background, but only during an upgrade, and setup can write it again afterwards.
Strict check that rejects the app's own task. WindowsStartupTaskRegistration.MatchesExpectedTask requires empty arguments, while CreateRegisterProcessStartInfo always registers --background. InspectStrict therefore returns Different for a task the app created. It matters when schtasks times out or returns an unclassified error after creating the task: SetupStartupPolicy.ApplyUnpackaged throws "Windows startup registration could not be confirmed". The existing test fixture uses empty arguments, so it did not catch this.
Evidence
Windows 11 x64 build 26200, main a4dd026, standard session without elevation:
schtasks /Create /SC ONLOGON /HRESULT exit: 0x80070005
Tests against the baseline matcher, using a task description with the arguments the app really registers:
Failed OnlyExactEnabledStartupTaskCountsAsCompletedRegistration(changed: "expected", matches: True)
Failed OnlyExactEnabledStartupTaskCountsAsCompletedRegistration(changed: "no-arguments", matches: False)
Fix I have ready
One shared CreateBackgroundLaunchCommand for the scheduled task and both Run key writers, and MatchesExpectedTask now requires --background.
Not verified
- I did not complete the setup wizard and log on again, so the window at logon comes from the code and the router test, not from watching it happen.
- The strict check's failure path was tested through the matcher, because a logon task cannot be created on this machine without elevation. The new round-trip test exits early when Windows refuses the task, as it does here, so it only proves something on an elevated host.
I found no existing issue or PR for this. I will open a PR.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Oct 31, 2026
Codex review: this still needs some work.
Summary
Both reported defects remain on current main: setup writes an argument-free Run entry, and strict inspection rejects the background argument used by task creation.
Reproducibility: Current source establishes both defects through the setup writer, task matcher, failure policy, and activation router; no build, test, or Windows logon reproduction was run during this read-only review.
Regression provenance
Possible regression — suspected (reviewed change). No predecessor PR is attributed.
Next step
Align the setup fallback and strict matcher with background task creation, first establishing failing regressions for argument-free fallback and rejection of a correctly registered task.
Review details
Best possible solution:
Use one background-launch command across the existing registration writers and make strict inspection accept that exact command.
Do we have a high-confidence way to reproduce the issue?
Current source establishes both defects through the setup writer, task matcher, failure policy, and activation router; no build, test, or Windows logon reproduction was run during this read-only review.
Is this the best way to solve the issue?
The proposed shared command builder and aligned matcher address both inconsistencies without weakening strict task identity checks or fallback admission.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against a4dd026cc5f8.
Label changes
Label changes:
P2: The defects affect unpackaged startup preferences and conditional setup confirmation, with a limited blast radius and an existing Settings recovery path.impact:ux-friction: Users can receive an unwanted window at logon or a misleading startup-registration failure.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:queueable-fix: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P2: The defects affect unpackaged startup preferences and conditional setup confirmation, with a limited blast radius and an existing Settings recovery path.impact:ux-friction: Users can receive an unwanted window at logon or a misleading startup-registration failure.Evidence reviewed
Acceptance criteria:
SetupStartupPolicyTests|FullyQualifiedNameActivationRouterTests'What I checked:
src/OpenClaw.Tray.WinUI/Services/AutoStartManager.cs:92, a4dd026cc5f8)src/OpenClaw.Shared/WindowsStartupTaskRegistration.cs:141, a4dd026cc5f8)src/OpenClaw.Tray.WinUI/Services/SetupStartupPolicy.cs:16, a4dd026cc5f8)tests/OpenClaw.Shared.Tests/StartupTaskInspectionTests.cs:57, a4dd026cc5f8)tests/OpenClaw.Tray.Tests/ActivationRouterTests.cs:117, a4dd026cc5f8)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed October 31, 2026, 7:23 PM ET / 23:23 UTC.