Skip to content

feat(setup): set up the WSL gateway from a config file without the wizard - #1900

Open
larroy wants to merge 4 commits into
openclaw:mainfrom
larroy:feat/headless-setup-config
Open

larroy wants to merge 4 commits into
openclaw:mainfrom
larroy:feat/headless-setup-config

Conversation

@larroy

@larroy larroy commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Setting up a local WSL gateway always requires clicking through the setup wizard, so developers and scripts cannot reproduce a gateway install from a saved set of options.

User Impact

User impact: developers can run .\run-app-local.ps1 -SetupConfig .\my-setup.json (or OpenClaw.Tray.WinUI.exe --headless-setup --config <file>) to install and pair the WSL gateway with no UI, then start the tray already connected. Reruns skip setup when the data directory is already configured.

Setup refuses to replace an existing app-owned distro, its data, or a local gateway record unless --replace-existing (-ReplaceExisting) is passed. -Isolated and -DataDir do not isolate the WSL distro, so without that flag a fresh isolated profile could otherwise delete the distro used by the normal profile. The native MSIX gateway route stays interactive. No change to the normal tray launch or the setup window.

Why This Change Was Made

The headless SetupEngine pipeline already exists and is what the E2E tests use, but it has no executable of its own. This adds a --headless-setup CLI mode to the tray executable, modeled on the existing --uninstall mode, and wires it into run-app-local.ps1.

The mode reuses the interactive setup's app-identity distro, port and data directories, and StartupSetupState.RequiresSetup for the skip decision, so "skipped" means the same as "the tray will not open setup". It applies the same safety rules as interactive setup:

  • the replacement review for existing state;
  • a refusal while a tray holds the single-instance mutex for the same data directory;
  • the Inno completed-migration guard.
Behavior details
  • Accepted arguments: --headless-setup, --config <path>, --force-setup, --replace-existing. Anything else exits with code 2.
  • The config file is a full SetupEngine config (start from a copy of default-config.json). Its DistroName and GatewayPort are ignored, as in the setup window. Capabilities are set under Capabilities, which overwrites Settings.Node*Enabled.
  • The handler runs off the WinUI dispatcher, because a setup helper blocks on async work and deadlocks on the UI thread. Every failure path calls Environment.Exit, so the windowless process cannot linger.
  • run-app-local.ps1 waits on the setup process with Handle + WaitForExit() instead of Start-Process -Wait, because setup leaves a WSL keepalive descendant running.

Evidence

  • Real headless install on this machine (Dev identity, distro OpenClawGateway-Dev, port 18790): all 34 pipeline steps succeeded, operator and node pairing were auto-approved, and the run ended with SETUP COMPLETE.
  • Rerun printed Headless setup skipped: ... is already configured. and launched the tray. The tray log shows operator hello-ok, then Node registered successfully and Node status: Connected, with no setup window.
  • Safety gates were exercised against a private local data root: replacement refused, running-tray refused, unreadable registry exits with code 1 instead of hanging.
  • Full required validation passes.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-wsl-gateway-e2e: the change drives product WSL setup, bootstrap, and operator and node pairing through a new entry point.

Validation

Commit ca028205, worktree with OPENCLAW_REPO_ROOT set:

  • ./build.ps1: all builds succeeded; documentation validation passed (66 Markdown files).
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: Passed 4650, Skipped 24, Failed 0.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: Passed 4568, Failed 0. This includes the new CliSetupCommandLineTests and the existing startup-order tests (InnoMigrationContractTests, InstallerIssAssertionTests).
  • run-app-local.ps1 guards (manual):
    • -ForceSetup without -SetupConfig throws.
    • A missing config file throws Setup config not found: ....
    • -DryRun prints the setup config line and starts nothing.

Real Behavior Proof

  • Environment tested: Windows 11 10.0.26100 x64, WSL 2, Debug build, Dev app identity, isolated data dir %TEMP%\oc-headless, Store Gateway (no dev gateway packaging).
  • PR head or commit tested:
    • Full install, rerun skip and tray connection: commit eb247fcd.
    • Wait fix and the review fixes (replacement, running-tray, migration and exit-path gates): manually checked on the uncommitted source that became ca028205.
    • The full install was not repeated on ca028205.
  • Exact steps or command run:
    1. .\run-app-local.ps1 -Dev -DataDir $env:TEMP\oc-headless -UseStoreGateway -SetupConfig $env:TEMP\oc-setup.json (copy of default-config.json).
    2. Rerun the same command with -NoBuild.
    3. Cleanup with OpenClaw.Tray.WinUI.exe --uninstall --confirm-destructive (exit 0, distro unregistered).
  • Evidence after fix:
    [19:45:51.738] [Info] Pipeline completed successfully in 418.8s
    ═══ SETUP COMPLETE ═══
    Headless setup skipped: 'C:\Users\<user>\AppData\Local\Temp\oc-headless' is already configured. Pass --force-setup to run setup again.
    Started OpenClaw Tray (PID: 45788)
    [INFO] [HANDSHAKE] Received hello-ok!
    [INFO] Node registered successfully! ID: [REDACTED]
    [INFO] Node status: Connected
    
    Gates (on ca028205 source):
    ERROR: Setup would replace existing configuration:
    • Local gateway record will be replaced
    Pass --replace-existing to continue.                                          exit=2
    ERROR: OpenClaw is running for this data directory. Quit it before running headless setup.   exit=2
    ERROR: Headless setup failed: The process cannot access the file '...\gateways.json' because it is being used by another process.   exit=1
    ERROR: Unknown option '--bogus'.                                              exit=2
    
  • Observed result:
    • The gateway was installed and paired with no UI.
    • The rerun was idempotent, and the tray connected as operator and node without opening setup.
    • Each gate refused with the expected exit code.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A (terminal and log output only).
  • Not verified or blocked:
    • A full install has not been repeated on head ca028205. The first full run hung after SETUP COMPLETE in run-app-local.ps1 (Start-Process -Wait waiting on the keepalive). The fix was confirmed by the rerun path, not by a second full install.
    • While testing the gates, the first build of the fix deadlocked the dispatcher in ExistingConfigDetector.Detect. After the Task.Run fix, one gate test without a config file ran the pipeline against a private temp local root and created a temp OpenClawGateway distro. I verified its base path was the temp root, then unregistered it. The user's distros were not touched.
    • Inno completed-migration refusal was not exercised (needs a production migration build).
    • The windows-wsl-gateway-e2e pool has not run.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): Yes
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation:
    • Risk: the tray executable gains a CLI entry point that can create, and with consent replace, the app-owned WSL distro and gateway records without UI.
    • Mitigation: it runs only on explicit --headless-setup, uses the same distro ownership checks as the setup window, and refuses to replace existing state without --replace-existing. It also refuses while a tray for the same data dir is running, and honors the Inno completed-migration guard.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No. New optional CLI flags and script parameters only.
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge.

What this changes

Adds a tray CLI mode and launcher parameters that install and pair a WSL Gateway from a saved configuration without the wizard.

Example: Run .\run-app-local.ps1 -Dev -SetupConfig .\my-setup.json.

  • Before: Developers must use the setup wizard or invoke SetupEngine from a custom host.
  • After: The launcher runs headless setup for OpenClawGateway-Dev on port 18790, then starts Companion.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful and coherently scoped, with prior defects repaired and meaningful runtime evidence, but existing-installation compatibility remains unverified.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Developers cannot invoke the supported WSL setup pipeline from the shipped tray executable using saved options without the wizard.
Reason: Maintainer authorship establishes direction, and the implementation exposes an existing pipeline with explicit replacement consent and cross-profile serialization.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this useful, maintainer-authored PR open. The previous findings are addressed, and no definite introduced defect remains; saved-state compatibility still needs validation.

Priority: P2
Reviewed head: d0f63f7077852b9fdd78843877f2ade862a966c6

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Latest-stable upgrade preservation and current-head migration refusal are not demonstrated; red-to-green execution of the new regression tests is also not shown.
Agent review details

How this fits together

The tray executable translates CLI options into the existing SetupEngine pipeline, which manages WSL installation, Gateway pairing, registry records, and Companion settings.

flowchart TD
  A[Saved configuration] --> B[Launcher or tray CLI]
  B --> C[Startup and replacement admission]
  C --> D[Profile and shared target locks]
  D --> E[Existing SetupEngine pipeline]
  E --> F[WSL Gateway and paired Companion state]
Loading

Technical review

Best possible solution:

Retain the focused CLI adapter and shared safety owners, then establish that upgrading an existing installation preserves its saved state.

Do we have a high-confidence way to reproduce the issue?

This is a feature request implemented by the patch; main lacks the executable dispatch, while the author's terminal trace demonstrates the earlier implementation installing and pairing a real WSL Gateway.

Is this the best way to solve the issue?

The patch reuses SetupEngine, startup readiness, WSL ownership, and migration admission rather than creating another installer; the added parsing and presentation seams serve distinct CLI and noninteractive contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Setup pipeline hosting keeps the original intent (cefce39: Redesign local gateway setup as out-of-process SetupEngine #529 (Redesign local gateway setup as out-of-process SetupEngine) separated configuration-driven transactional installation from tray presentation.)
  • Setup exclusion changes intended behavior with a stated reason (cefce39: The existing per-profile lock prevents overlapping setup activity; the PR explains why shared WSL targets additionally require cross-profile exclusion.)
  • Migration startup admission keeps the original intent (244f684: feat(migration): ship the Inno-to-Store migration #1519 (feat(migration): ship the Inno-to-Store migration) preserves receipt-based retirement while allowing unavailable runtime locks to degrade; the extracted decision retains those branches.)
  • Automatic WSL cleanup keeps the original intent (fd8901d: Path-bound live-registration evidence prevents automatic removal of foreign WSL data; the PR adds a stricter nonreplacement guard before existing cleanup decisions.)
  • Console attachment and local launcher keeps the original intent (190a53f: The existing uninstall handler provides a windowless console entry point; sharing console attachment and waiting only for the setup process supports the additional CLI mode.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change verified: Reviewed the pinned merge-base-to-head diff across all 24 changed files; base-only voice changes were excluded from PR ownership. (d0f63f707785)
  • Distinct capability absent from main: Current main dispatches CLI uninstall but has no headless-setup dispatch; the existing SetupEngine remains the implementation reused by this PR. (src/OpenClaw.Tray.WinUI/App.xaml.cs:535, 12789b405719)
  • Previous findings addressed: Headless setup now obtains migration guidance without invoking MessageBoxW, rejects packaged execution before the interactive Store guard, and gives interactive or manual recovery instructions for unowned WSL state. (src/OpenClaw.Tray.WinUI/CliSetupHandler.cs:59, d0f63f707785)
  • Replacement admission serialized: SetupRunLock adds shared local-target exclusion, Program rechecks nonreplacement admission under the locks, and CleanupStaleDistroStep preserves registered and orphaned targets when PreserveExisting is set. (src/OpenClaw.SetupEngine/Program.cs:267, d0f63f707785)
  • Runtime and validation evidence credited: The author's body supplies a real Dev install, pairing, rerun, and connection trace. Discussion supplies shared-lock refusal output and rebased-head build and test results, but no latest-stable upgrade preservation run. (d0f63f707785)
  • Existing safety contract: fix(setup): require ownership before WSL cleanup #1229 (fix(setup): require ownership before WSL cleanup) established durable ownership checks and explicit destructive consent; this PR retains the shared cleanup owner. (src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs:119, 787db18f3874)

Likely related people:

  • Scott Hanselman: Raw commit fd8901d adds src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs:126 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fd8901d85f44; files: src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs)

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status no longer selects a status label.

Label justifications:

  • P2: A useful developer automation feature with bounded scope and no demonstrated urgent user regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-27T23:10:43.665Z sha ca02820 :: blocked before merge. :: [P1] Serialize replacement admission with the shared WSL operation | [P2] Return migration refusals without displaying a modal dialog | [P2] Provide a usable recovery instruction for unowned WSL state
  • reviewed 2026-11-03T19:57:54.684Z sha 10c0e92 :: blocked before merge. :: [P2] Return migration refusals without displaying a modal dialog | [P2] Provide a usable recovery instruction for unowned WSL state

Reviewed November 3, 2026, 6:46 PM ET / 23:46 UTC (Revision 3).

@larroy

larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed Serialize replacement admission with the shared WSL operation (P1) in 10c0e92.

  • SetupRunLock now also holds setup-target.lock in the shared local setup directory for the whole run, alongside the per-profile setup.lock. Profiles with different OPENCLAW_TRAY_DATA_DIR values share that directory, so setup, uninstall, and open setup windows are serialized across profiles. A second run exits with code 2 immediately.
  • Without --replace-existing, the headless handler passes a new engine flag, --preserve-existing. After acquiring both locks (before any log or journal is written), the engine re-runs ExistingConfigDetector.Detect and refuses with exit code 2 if a local gateway record, the distro, or its data directory appeared.
  • CleanupStaleDistroStep refuses to remove a registered distro or orphan distro directory when PreserveExisting is set, even with app-owned evidence.
  • The handler's existing pre-check stays as the fast path that names --replace-existing.

Tests: new SetupRunLockTests.TryAcquire_BlocksSecondProfileSharingLocalDataDir, CleanupStaleDistro_PreserveExistingRefusesAppOwnedRegisteredDistro, CleanupStaleDistro_PreserveExistingRefusesOwnedOrphanDirectory, and CliSetupCommandLineTests.BuildEngineArguments_PreservesExistingStateUnlessReplacementAuthorized.

Validation: ./build.ps1 passed; Shared 4650 passed / 24 skipped; Tray 4570 passed; SetupEngine 2482 passed / 1 skipped. The UI test project builds with -r win-x64 after the SetupRunLock signature change (UI tests not run).

Runtime proof:

  • Engine, via a throwaway test calling Program.Main (since deleted): a pre-seeded local gateway record was refused with exit 2 and no log directory was created; with the shared lock held by another profile, the run exited 2 with Another OpenClaw setup run is using the shared setup data in ....
  • Dev tray exe: with setup-target.lock held from PowerShell, --headless-setup --force-setup from a separate temp profile passed --preserve-existing to the engine and exited 2 at the shared lock. The WSL distro list was unchanged.

Still open: the two P2 items (migration modal dialog, recovery instruction for unowned WSL state) and the data-model compatibility proof.

@larroy

larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 3, 2026
@larroy
larroy force-pushed the feat/headless-setup-config branch from 343be69 to d0f63f7 Compare November 3, 2026 23:27
@larroy

larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto current origin/main (was 343be69e, now d0f63f70, 4 commits, force-pushed). Conflict resolutions: kept upstream's new Unreleased CHANGELOG CI entry alongside this PR's headless-setup entry; kept upstream's OpenClaw.GatewayCleanupHost architecture ledger row and this PR's extended Inno migration row adding InnoMigrationStartupAdmission.

Validation on the rebased head, worktree with OPENCLAW_REPO_ROOT set:

  • ./build.ps1: all projects built; documentation validation passed (72 Markdown files).
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: Passed 4811, Skipped 24, Failed 0.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: Passed 4822, Failed 0.
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj: Passed 2538, Skipped 4, Failed 0.
  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj: Passed 1713, Skipped 1, Failed 0.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 3, 2026
@larroy
larroy requested review from RomneyDa, karkarl and shanselman and removed request for karkarl and shanselman November 4, 2026 00:29
@larroy larroy added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Nov 4, 2026
@larroy
larroy force-pushed the feat/headless-setup-config branch from d0f63f7 to 634495e Compare November 4, 2026 00:56
if (PackageHelper.IsPackaged)
return Fail(2, "Headless setup is not available in the packaged (MSIX) app. Run setup from the app instead.");

if (IsTrayRunning())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copilot triage: Could headless setup hold per-profile single-instance admission for the whole run, rather than only checking here? TryOpenExisting can return false, after which a normal tray can create its mutex and start on the same profile while the setup pipeline, including --replace-existing, changes the Gateway and distro. The shared-target setup lock serializes setup and uninstall, but does not stop normal tray startup. A concurrent-start regression would protect the no-running-tray invariant.

@roboclaw-bot

Copy link
Copy Markdown
Contributor

PR cleanup review

Reviewed head: 634495e1c36b52b5eff1b588c7bad7fccfee78ac. Main comparison: e59374c064f43d68f5c72d070d4c89ef2d20ec3b.

Thanks for exposing the existing setup pipeline without creating a second installer. This still adds functionality that is absent from main, so I would keep it open rather than close it as superseded. The remaining startup race noted in the inline thread needs attention: headless setup checks for the tray mutex but does not hold admission, so normal startup can overlap a replacement run. Please retain admission for the run and cover both concurrent-start orders. After refreshing the branch, bind the full setup/pairing, migration refusal and existing-installation preservation evidence to the new head; the current reports reference earlier revisions. The current-head CI checks are green, which is useful evidence, but do not settle that race or the custom proof gaps.

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.

@shanselman

Copy link
Copy Markdown
Collaborator

Hi @larroy, this is a Copilot triage agent (not Scott), doing an overnight sweep for PRs that could land. I made no changes to this branch. Thank you for exposing the existing setup pipeline headlessly, and for the replacement guard rails (--replace-existing, the cross-profile lock, the Inno migration guard).

What I checked against current main (22c111d4):

  • A merge preview (git merge-tree) shows one conflict, in CHANGELOG.md (the Unreleased section). Everything else merges cleanly, so a rebase should be small.
  • The Gate on head 634495e1 is green, but from Nov 4, so it predates a week of changes on main. A refreshed head would give a current signal.
  • The cleanup review's open item still looks like the main blocker: headless setup checks the tray mutex but does not hold admission for the whole run, so a normal tray startup could overlap a replacement run. Because this path can replace an app-owned WSL distro, I would want that race closed, with both concurrent-start orders covered by tests, and the setup/pairing and migration-refusal evidence re-bound to the new head, before a maintainer lands it.

This PR already carries "status: 👀 ready for maintainer look", so I left the labels alone. No pressure on timing.

@larroy
larroy force-pushed the feat/headless-setup-config branch from 634495e to 396fb07 Compare November 13, 2026 18:15
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to inactivity.
Please update it or it will be closed.

@github-actions github-actions Bot added the stale label Nov 28, 2026
Add a --headless-setup [--config <file>] [--force-setup] CLI mode to the tray executable that runs the SetupEngine pipeline without UI, using the app identity's data dirs, distro name and port. Setup is skipped when StartupSetupState.RequiresSetup reports the data dir is already configured.

run-app-local.ps1 gains -SetupConfig and -ForceSetup to run that mode before launching the tray. It waits on the setup process only, because setup leaves a WSL keepalive running.
…consent

Require --replace-existing before replacing an existing app-owned distro, its data, or a local gateway record, matching the setup window's replacement review. Refuse while a tray holds the mutex for the same data dir, honor the Inno completed-migration guard, run off the WinUI dispatcher, and exit on every failure path.
…t at cleanup

SetupRunLock now also holds setup-target.lock in the shared local setup directory, so profiles with different OPENCLAW_TRAY_DATA_DIR values cannot run setup concurrently. Headless setup without --replace-existing passes --preserve-existing; the engine re-checks existing state under the lock, and CleanupStaleDistroStep refuses to remove any distro.
…SL state

Headless setup no longer opens the migration guidance dialog. The Inno migration decision moves to InnoMigrationStartupAdmission (OpenClaw.Connection), InnoMigrationStartupGuard.TryGetStopGuidance returns the guidance key without UI, and CliSetupHandler prints the localized text to stderr with exit code 2. Headless setup is refused in the packaged app and now dispatches before the window-presenting Store migration guard.

A distro or distro data not proven to be app-owned is never replaced headlessly, even with --replace-existing. The refusal says the target was preserved and points to interactive setup or manual removal.
@larroy
larroy force-pushed the feat/headless-setup-config branch from 396fb07 to de4e4ca Compare November 28, 2026 07:03

This branch has not been deployed

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. stale status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants