Repository navigation
fix(setup): autostart from setup opens the window at logon - #1963
roboclaw-bot wants to merge 3 commits into
Conversation
Worked on by: - @MertBasar0 Co-authored-by: MertBasar0 <[email protected]> OpenClaw-Publication: 1f24c030-95c3-4ab0-95c7-0db0cc2ebe0a
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes unpackaged startup writers share the background launch command and aligns scheduled-task inspection with that command. Example: A standard Windows session enables Start with Windows during setup and task creation is denied.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes two source-confirmed startup inconsistencies still present on current main, with no introduced correctness defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSetup and Settings send startup preferences to AutoStartManager, which registers a scheduled task or an admitted HKCU Run fallback; Windows later launches Companion and ActivationRouter determines whether to open a window. flowchart TD
A[Setup and Settings] --> B[AutoStartManager]
B --> C[Shared background command]
C --> D[Scheduled task]
C --> E[HKCU Run fallback]
D --> F[Windows logon]
E --> F
F --> G[Companion activation]
Technical reviewBest possible solution: Land the shared background command and aligned strict matcher once the setup-written standard-user Run fallback is demonstrated at logon. Do we have a high-confidence way to reproduce the issue? Current-main writers, strict inspection, fallback policy, and activation tests establish both defects; contributor evidence also demonstrates the matcher difference on a real task. Is this the best way to solve the issue? The patch is the smallest complete repair using existing owners: share the quiet-launch command and align inspection while retaining exact task identity and duplicate-prevention checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 558960df22b2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed November 18, 2026, 4:28 PM ET / 21:28 UTC (Revision 5). |
Worked on by: - @MertBasar0 Co-authored-by: MertBasar0 <[email protected]> OpenClaw-Publication: c3f43654-073b-4718-aee9-3c89dfe214fa
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
PR cleanup reviewReviewed head: This remains a useful independent fix: main still writes an argument-free setup fallback while its task writer uses --background, and the strict matcher disagrees with that writer. The patch aligns all three paths without weakening fallback admission. CI is green, but the roundtrip test can return early on access denial and the actual setup-to-logon path is explicitly unverified. Please retain that proof gap until both the standard-user and task-registration paths are demonstrated on the candidate. Action in this cleanup pass: leaving this PR open. No branch changes or runtime-proof waiver. The findings above come from source, discussion and recorded-CI review; Windows validation was not rerun in this pass. |
|
Hi, I'm a Copilot triage agent working for the maintainers (not Scott himself), taking an overnight look at this one. I did not push anything or change labels. This is just a status note so the next person has the details. What I checked I merged this PR's head (
What looks right The fix lines all three writers up on one A small test gap (suggested, not pushed) The new tests cover the task command and the matcher. Nothing checks the two Run-key writers in Suggested test for SetupStartupPolicyTests.cs// also needs: using System.Text.RegularExpressions;
[Fact]
public void EveryRunKeyWriteUsesTheSharedBackgroundLaunchCommand()
{
var source = File.ReadAllText(Path.Combine(TestRepositoryPaths.GetRepositoryRoot(),
"src", "OpenClaw.Tray.WinUI", "Services", "AutoStartManager.cs"));
var writes = Regex.Matches(source, @"\.SetValue\(AppName,[^;]*;").Select(match => match.Value).ToList();
// A Run entry without --background opens a window at logon (#1957).
Assert.NotEmpty(writes);
Assert.All(writes, write =>
Assert.Contains("WindowsStartupTaskRegistration.CreateBackgroundLaunchCommand(", write));
}What I could not verify, and why I am not landing it overnight
Thanks to everyone who worked on this. It is a good, small fix, and it is close. |
Worked on by: - @MertBasar0 Co-authored-by: MertBasar0 <[email protected]> OpenClaw-Publication: deb07440-bd17-4aa6-9c41-4499ba4c2871
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
On the compatibility question from the triage note (a legacy scheduled task with no This case is already covered in the PR. The "Upgrade compatibility" table in the body has a row for it ("Task The strict result is deliberate. Before this change the matcher accepted exactly that task, and that task opens a window at logon, which is #1957. Accepting it again would keep the bug for those users. Writing the Run fallback next to it would start Companion twice at logon. So setup shows its existing "could not be confirmed" warning, creates no fallback entry, and an elevated retry replaces the task with the The affected group is narrow: the task must have been created from an elevated session, and setup must run later without elevation. If you would prefer a message specific to this case, I can add that as a follow-up. The suggested Run-key guard test is now in the PR (head |
|
Logon proof at Setup. Every install and launch below was run by a process outside the package.
After signing out and in:
What this shows. A What it does not show:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Latest-stable upgrade proof for the data-model compatibility item: How it was run.
T3 hang (pre-existing, not from this PR).
Correction to this PR's "Upgrade compatibility" table. The row for Run |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #1957
What Problem This Solves
Fixes: autostart turned on during setup opens the Companion window at logon when the session is not elevated, and setup can report that it could not confirm a task it did create.
User Impact
User impact: every autostart registration now starts quietly in the tray. Setup no longer rejects the app's own scheduled task.
Behavior to review:
MatchesExpectedTasknow requires--background. A legacy task with no arguments counts asDifferent, the same answer it gives for any other command line.Why This Change Was Made
Preserved invariant:
docs/CONNECTION_ARCHITECTURE.mdsays new autostart registrations pass--background. The Run key fallback inApplySetupPreferenceAsyncwas the one writer that did not, and that fallback is the normal path without elevation, becauseschtasks /Create /SC ONLOGONis refused.MatchesExpectedTaskrequired empty arguments whileCreateRegisterProcessStartInfoalways registers--background, and its test fixture used empty arguments, so nothing caught the mismatch.CreateBackgroundLaunchCommandis now the single owner of that command.Evidence
Windows 11 x64 build 26200, standard session without elevation:
The updated tests against the baseline matcher, with the arguments the app really registers:
They pass with this change.
ActivationRouterTestsalready pins that an unpackaged launch with no arguments opens a window and that--backgrounddoes not.Change Type
Scope
winnodeRequired proof pools
windows-wsl-gateway-e2e: the startup registration written by product setup changed. Not run here.Validation
Run on
a4dd026plus this change. Windows 11 x64 build 26200, tr-TR, .NET SDK 10.0.402../build.ps1: succeeded.ExecReusableCommandBinderTests.PinnedCarrier_IgnoresShadowInsertedAfterApproval(computer name longer than 15 characters) andMxcFolderAdmissionTests.OwnedJunctionAndSymbolicLinkAreRejectedWithoutFollowingTheirChildren(symbolic: True)(no symbolic link privilege).OPENCLAW_TRAY_*directories isolated: 4799 passed, 0 failed.Run-key writer regression guard
Mert-provided Windows 11 evidence at
a5f03d81917b46c1fa48dab10ed3c698f08d5843, whose source treeaa19cf9252e24cb0179e993ffb94c43efdb53c32is identical to published headfb0008158eaa2e6def19e901c79ed179d6f5b5e6. These Windows tests were not rerun in this Linux publication session.SetupStartupPolicyTests: 14 passed.EveryRunKeyWriteUsesTheSharedBackgroundLaunchCommand: GREEN with the shared background command in both Run-key writers.Real Behavior Proof
a4dd026plus this change. CI on the PR head is the current-head result.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --filter "FullyQualifiedName~StartupTaskInspectionTests", with and without the matcher change, plus a uniquely named transientschtasks /Create /SC ONLOGONprobe that was refused.Passed! - Failed: 0, Passed: 20, Skipped: 0, Total: 20.--backgroundtask atfb0008158e(MertBasar0, Windows 11 Home 26200, run outside the Claude desktop MSIX package): PASS. After signing out and in, the task ran at the logon second. It started one Dev process (parentsvchost.exe,--background, no main window) in MCP-only mode. No Run value existed. The task came from an earlier test run, not from setup in this run. ProofYes/No/N/A): N/ATaskRegisteredByTheAppMatchesTheStrictInspectionexits early on this host because Windows refuses the logon task, so its round trip throughInspectStrictis only proven on an elevated host.Security Impact
No)No)No)No)No)Yes, explain the risk and mitigation:Compatibility and Migration
Yes)No)No)Review Conversations
Upgrade compatibility: measured at
fb0008158eThe "Upgrade compatibility" table further down was written before the latest-stable upgrade proof (v2026.11.3 to this head, unsigned Dev-identity builds; see the upgrade-proof comment, #1963 (comment)). Two of its rows are superseded:
"<exe>"(setup fallback before this fix): not unchanged. Every upgrade already rewrites it through main'sMigrateLegacyBackgroundLaunch(logMigrated existing Run registration to background launch.), to the unquoted<exe> --background. This PR does not change that writer; fix(setup): Start with Windows cannot stop the installer startup shortcut #1964 makes it quote the path."<exe>"with no arguments (created before feat(workspace): add native Home and Sessions workspace #1541): the same migration runsschtasks /Changeon it. On the tested machine the silent upgrade hung atssPostInstalluntilschtasks.exewas ended; the task then stayed unchanged and settings were unchanged. This is pre-existing in v2026.11.3 and main, tracked in Installer upgrade hangs onschtasks /Changewhen an argument-free startup task exists #2320.The other rows matched the measurements: the Settings Run value and 11.3's own
--backgroundtask were unchanged, and this PR'sInspectStrictreportsExpectedEnabledfor that task.Worked on by
Upgrade compatibility
This change touches no stored settings.
settings.json,AutoStartand the gateway registry are read and written exactly as before. It changes only two things: the command a new autostart registration writes, and which existing scheduled task setup accepts as its own. Every registration an earlier release can leave behind:"<exe>" --background(Settings toggle)"<exe>"(setup fallback before this fix)IsAutoStartEnabledchecks only that the value exists).--background. Settings Off then On also rewrites it. #1964's installer migration also rewrites this exact value with--background(proven live at e4affd6)."<exe>" --background(created since #1541)InspectStrictreportedDifferentfor setup's own task, so setup could reject its own correct registration. NowExpectedEnabled. This is the fix."<exe>"with no arguments (created before #1541, needs elevation)Existsstill reports it, so the toggle reads On./Create /Freplaces it with the--backgroundtask whenever registration succeeds. If registration is rejected,InspectStrictnow reportsDifferentand setup shows its existing "could not be confirmed" warning instead of accepting a task that opens a window. No fallback Run value is created. Turning autostart off still unregisters it (Different!=Absent).Nothing stops loading or working. The only behavior difference for old data is that setup no longer silently accepts the pre-#1541 argument-free task.
Tests covering these rows:
StartupTaskInspectionTests.OnlyExactEnabledStartupTaskCountsAsCompletedRegistrationcovers--backgroundmatches, plus theno-argumentsandargumentscases.SetupStartupPolicyTests.ConfirmedRejectionStillRequiresExactTaskInspectionandAmbiguousRegistrationNeverCreatesRunKeycoverDifferent: a throw with no Run key.DisableRequiresBothRunKeyRemovalAndSuccessfulTaskRemovalcovers unregistering any present task.