Skip to content

Autostart turned on during setup opens the Companion window at logon #1957

Done

Description

@MertBasar0

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.

Activity

  1. added
    clawsweeper:intake:bug
    clawsweeper:intake:needs-repro
    P2
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    clawsweeper:source-repro
    impact:ux-friction
    issue-rating: 🦞 diamond lobster
    no-stale
    and removed
    clawsweeper:intake:bug
    clawsweeper:intake:needs-repro
    on Oct 31, 2026
  2. clawsweeper commented on Oct 31, 2026

    @clawsweeper

    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:

    • Actual setup-to-logon window behavior and elevated scheduled-task round-trip inspection remain unverified.

    Codex review notes: model internal, reasoning medium; reviewed against a4dd026cc5f8.

    Label changes

    Label changes:

    • add P2: The defects affect unpackaged startup preferences and conditional setup confirmation, with a limited blast radius and an existing Settings recovery path.
    • add impact:ux-friction: Users can receive an unwanted window at logon or a misleading startup-registration failure.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add 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:

    • ./build.ps1
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~StartupTaskInspectionTests
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --filter 'FullyQualifiedNameSetupStartupPolicyTests|FullyQualifiedNameActivationRouterTests'

    What I checked:

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 31, 2026, 7:23 PM ET / 23:23 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:ux-frictionissue-rating: 🦞 diamond lobsterno-stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions