Skip to content

fix(setup): Companion shows Disconnected for a minute after native onboarding finishes - #1747

Merged
larroy merged 1 commit into
mainfrom
fix/post-setup-gateway-gap
Oct 16, 2026
Merged

larroy merged 1 commit into
mainfrom
fix/post-setup-gateway-gap

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: Companion shows "Disconnected / Connect to gateway to start chatting" with no agents for about 60–90 seconds right after native Gateway onboarding finishes.

User Impact

User impact: after finishing onboarding with an isolated (package-managed) Gateway, the restarted Companion connects to the Gateway that setup just verified instead of waiting through another cold start. Legacy same-user Gateways keep the existing stop-before-publish behavior.

Why This Change Was Made

Verified isolated completion restarted the Gateway, verified it, then stopped it before publishing the profile. The post-setup Companion restart then had to start it again, and an isolated cold start currently takes 50–90 seconds. During that window the startup credential handoff is denied and the Home page shows the disconnected empty state.

Setup now keeps a verified isolated Gateway running through publication and calls a new INativeGatewayRuntime.ReleaseAsync afterward. The isolated runtime implements it by dropping its owned-start and proof state without stopping the package service, so the next owner adopts it through its own fresh status and listener-ownership proof. The default implementation still stops, so runtimes whose Gateway cannot outlive their owner are unchanged. If publication fails, the Gateway is still owned and is stopped by the existing finally.

Evidence

Redacted timeline from a fresh install (Gateway 2026.9.900.0, Companion 2026.9.905.0, Windows 11 ARM64):

11:25:50  setup RestartAsync -> gateway-service start
11:27:19  Gateway running on its port; setup verification succeeds
11:27:51  setup stops the Gateway before publication
11:27:52  "Started post-setup tray restart process"
11:28:00  "Native Gateway HTTP credential handoff denied: UnknownListener"  (UI: Disconnected)
11:28:02  Companion starts the Gateway again
11:29:17  Gateway running
11:29:28  Companion handshake complete (hello-ok)

With this change the 11:27:51 stop and the 11:28:02 cold start no longer happen for verified isolated completion.

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-clean-installer-upgrade: clean native install through onboarding completion should show Companion connected right after the post-setup restart.
  • windows-11-arm64: the slow isolated cold start was observed on ARM64.

Validation

Run with -p:DisableGitVersionTask=true (GitVersion cannot read the partial clone used) and OPENCLAW_REPO_ROOT set to the repo root:

  • dotnet test ./tests/OpenClaw.Connection.Tests: Passed 1583, Skipped 5, Failed 0 (includes new ReleasedServiceKeepsRunningForItsNextOwner)
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests: Passed 2333, Skipped 1, Failed 0 (extended FocusedAi_AllDestinationsReverifyAfterNativeRestartBeforePublication)
  • dotnet test ./tests/OpenClaw.Shared.Tests: Passed 4313, Skipped 36, Failed 0
  • dotnet test ./tests/OpenClaw.Tray.Tests: Passed 4083, Failed 0
  • dotnet build ./tests/OpenClaw.Tray.UITests -p:Platform=ARM64: compiles; a later provider-icon asset copy step fails in this partial clone (unrelated)
  • ./build.ps1 not run locally; relying on CI.

Real Behavior Proof

  • Environment tested: unit and integration tests (Windows 11 ARM64 dev machine).
  • PR head or commit tested: 7f9029a
  • Exact steps or command run: see Validation.
  • Evidence after fix: ReleasedServiceKeepsRunningForItsNextOwner shows release, stop and dispose issue no gateway-service stop; FocusedAi_AllDestinationsReverifyAfterNativeRestartBeforePublication asserts isolated completion releases only after publication and legacy completion never releases.
  • Observed result: tests pass.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A
  • Not verified or blocked: a packaged end-to-end onboarding on this head was not run; covered by the declared proof pools.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No. Credentials are still sent only after the next owner's fresh listener-ownership proof.
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • 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.

🤖 Generated with Claude Code

…boarding finishes

Verified isolated completion restarted and verified the Gateway, then
stopped it before publishing the profile, so the post-setup Companion
restart had to cold-start it again. Keep the verified isolated Gateway
running through publication and release ownership afterward through a
new INativeGatewayRuntime.ReleaseAsync. The isolated runtime drops its
owned-start and proof state without stopping the package service; the
default still stops, so legacy runtimes are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 16, 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:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR keeps a verified isolated Gateway running after setup publishes its connection, avoiding another cold start when Companion restarts.

Example: Complete native onboarding on Windows 11 ARM64 with Gateway 2026.9.900.0.

  • Before: Setup stops the verified Gateway, and Companion shows Disconnected while starting it again for roughly 60–90 seconds.
  • After: Setup leaves the Gateway running, and restarted Companion verifies and adopts its listener.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has no identified blocking defect, but its supplied evidence does not satisfy the repository's native behavior gate.
Proof confidence 🧂 unranked krab (1/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: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Companion presents an empty disconnected Home page for roughly a minute after native onboarding has already verified the Gateway.
Reason: Avoiding a redundant isolated-service restart has clear first-use value, and the maintainer-authored change establishes direction without adding settings or changing legacy behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses an onboarding delay still present on main, and source review found no introduced correctness defect.

Priority: P2
Reviewed head: 7f9029a6fe062f7600eb09106356cc3a8937c7ae

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Packaged native onboarding through restarted Companion adoption, existing-profile upgrade behavior, and a demonstrated base-fail/head-pass regression run are not supplied.
Agent review details

How this fits together

NativeGatewaySetupSession verifies and publishes the staged Gateway record; IsolatedGatewayRuntime manages package-service ownership, and GatewayConnectionManager independently authorizes subsequent credential handoffs.

flowchart LR
    A[Native onboarding] --> B[Restart and verify Gateway]
    B --> C[Publish Gateway record]
    C --> D[Release setup ownership]
    D --> E[Restart Companion]
    E --> F[Fresh listener verification]
    F --> G[Connect to running Gateway]
Loading

Technical review

Best possible solution:

Retain the verified package service through successful publication while preserving failure cleanup, legacy stopping and fresh successor authorization.

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

Main visibly stops the just-verified setup-owned service before publication, matching the supplied Windows ARM64 timeline; this read-only review ran no application, build or tests.

Is this the best way to solve the issue?

The repair addresses the unnecessary stop at its lifecycle owner and preserves independent listener verification rather than weakening credential checks or adding retries.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Main still stops the verified service: The pinned main implementation calls StopAsync after final verification and before registry publication, establishing the unnecessary cold-start path described by the report. (src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:363, 9ac0169aa0f1)
  • Publication precedes release: Only verified isolated completion skips the pre-publication stop; release follows successful registry saving, while the existing finally block retains failure cleanup. (src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:365, 7f9029a6fe06)
  • Credential authorization remains independent: Release clears cached proofs and stop ownership; the successor still performs EnsureRunningAsync and fresh InspectAsync before credential authorization. (src/OpenClaw.Connection/NativeGatewayEndpointSecurity.cs:24, 7f9029a6fe06)
  • Supplied validation and discussion: The complete PR body reports passing Connection, SetupEngine, Shared and Tray suites, explicitly excludes packaged end-to-end onboarding on this head, and supplies only a pre-fix runtime timeline; discussion contains no additional behavior evidence. (7f9029a6fe06)
  • History and original lifecycle intent: Merged history identifies native setup, isolated-runtime and focused-completion contributors. Original setup deliberately stopped its temporary runtime before publication. Local follow traversal encounters an unavailable historical object; supplied provenance and available commit history still establish the relevant lifecycle decisions. (src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:363, 9ac0169aa0f1)
  • Affirmative package-runtime dependency: The changed handoff relies on this repository's gateway-service lifetime contract: Companion executes its package-qualified lifecycle commands, and SessionGatewayClient launches the Gateway in Detached mode. Its root policy and relevant runtime documentation were inspected. (src/OpenClaw.Launcher/Gateway/SessionGatewayClient.cs:138, 19d7cc0aab65)

Likely related people:

  • Karen: Raw commit dba8121 adds src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:193 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dba81213371c; files: src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs)
  • Paul Campbell: Raw commit 5abfabb adds src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:75 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5abfabb38e12; files: src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs)
  • Dallin Romney: Raw commit 5a8830e adds src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:75 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a8830e6bc4c; files: src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs)

Labels

Label changes:

  • add P2: An unnecessary cold start temporarily delays first use after native onboarding, with automatic recovery and limited scope.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: An unnecessary cold start temporarily delays first use after native onboarding, with automatic recovery and limited scope.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 16, 2026, 3:06 PM ET / 19:06 UTC.

@larroy
larroy merged commit 7cd646b into main Oct 16, 2026
30 checks passed
@larroy
larroy deleted the fix/post-setup-gateway-gap branch October 16, 2026 19:38
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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants