Skip to content

feat(setup): stream live native Gateway activity log and typed failure diagnosis - #1735

Merged
larroy merged 4 commits into
openclaw:mainfrom
larroy:native-setup-activity-log
Nov 3, 2026
Merged

larroy merged 4 commits into
openclaw:mainfrom
larroy:native-setup-activity-log

Conversation

@larroy

@larroy larroy commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Native Gateway setup currently fails with little to go on: a step turns red and a single message appears. This PR shows the user what setup is doing while it runs, and gives a structured explanation when it fails.

What changes for the user

  • Live activity log. The native setup page has a "Detailed activity" panel that streams the setup log as it is written (steps started, package registration, clawctl commands and their exit codes, Gateway status changes, listener verification). It keeps the last 300 lines and has an "Open log file" link.
  • Failure explanation. When a step fails, an error bar names the step and shows the cleaned-up error message plus specific facts: which port and what is listening on it for listener conflicts, the last reported Gateway status for startup timeouts, the Windows error code, and the error type. The activity panel opens automatically. Main's existing recovery actions (collect diagnostics, open terminal, view log) still appear below it.
  • Preview. OPENCLAW_SETUP_PREVIEW_PAGE=native-failed renders the failure state without a real Gateway.

How it works

  • One log per setup window. SetupWindow.NativeSetupLog owns the log (Logs/Setup/native-setup-*.jsonl). The page attaches to it and the setup host writes into it, so retries and helper processes all land in the same file. The page no longer creates or disposes its own log.
  • clawctl logging. NativeGatewayPackageClient accepts an IOpenClawLogger and logs each command, its exit code and duration. On failure it also logs the end of stderr, with secrets removed. Stderr is kept out of exception messages, because the tray displays those.
  • Gateway lifecycle logging. IsolatedGatewayRuntime logs status reads, pre-start port conflicts (naming the process holding the port, without claiming it is the Gateway), start, restart, stop, configuration repair, and listener verification.
  • Diagnosis. New NativeGatewaySetupDiagnostics.Describe(Exception) turns typed exceptions into display-safe lines, with every line cleaned up. It also handles AggregateException.
  • Logger safety. SetupLogger ignores writes after it is disposed, because the runtime and host can outlive the page.

Rebase onto main (#1787, #1918)

Main's startup timeout handling is kept as is: the phase and time-limit fields on the timeout error, the OPENCLAW_NATIVE_GATEWAY_START_TIMEOUT override, the status text format, the file-write failure handling and the recovery panel. This PR builds on them instead of its earlier versions. The timeout error's constructor is now public so the preview can create one. The validation numbers below predate the rebase. After the rebase: dotnet build (ARM64) succeeded. SetupEngine tests 2489 passed, 0 failed. Shared tests 4808 passed, 0 failed. Tray tests 4762 passed, 1 failed (BuildPrerequisiteTests.CheckOnly_UsesTheAppLocalRuntimeResolver). Connection tests 1699 passed, 3 failed (migration and PowerShell checker tests). The 4 failures are in code this PR does not touch and look like environment problems on the test machine. They have not been checked against a clean main. ./build.ps1 stopped at its documentation check because of unrelated untracked local files.


Required proof pools

  • windows-setup-ui (tray UX / setup wizard surface)
  • gateway-connection (IsolatedGatewayRuntime lifecycle logging, ownership detail)

Validation

Run on the rebased head (origin/main at 2dd1a64 + this PR):

  • ./build.ps1 - all builds succeeded. Docs gate required parking a pre-existing untracked file (docs/implementation/native-gateway-slow-start-fix.md, Mermaid + broken anchors, unrelated to this PR) outside the tree during validation; restored afterward.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore - 4312 passed, 0 failed
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore - 4077 passed, 0 failed (OPENCLAW_REPO_ROOT set)
  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore - 1584 passed, 0 failed
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore - 2336 passed, 0 failed

Real behavior proof

native-failed deterministic preview (OPENCLAW_SETUP_PREVIEW_PAGE=native-failed, OPENCLAW_FORCE_ONBOARDING=1, isolated data dir, Debug build):

  • Row 4 "Start and verify the Gateway" failed with Needs attention.
  • Red InfoBar: "Start and verify the Gateway did not complete", sanitized timeout message, "Last reported Gateway status: state starting, session running, readiness not-ready.", "Error type: NativeGatewayStartupTimeoutException."
  • "Detailed activity" expander opened automatically with the log area and "Open log file" link visible (UIA confirmed ExpandCollapseState: Expanded; AutomationId NativeGatewaySetupActivity found).

Proof capture: the interactive transcript shows the expanded page with the InfoBar above the auto-opened "Detailed activity" expander and the "Open log file" link.

Not verified / blocked

  • Success-path live Gateway stream (clawctl setup, Starting the package-managed Gateway on port N., Gateway status after ..., Verified the Gateway listener ...): not exercised on this host because no MXC/isolation-capable package Gateway is installed here. The same pipeline is proven by the native-failed preview, the unit tests (stderr tail, Gateway status after, squatter detail, LastStatus), and the recycled ProgressPage pattern.
  • No documented clawctl command exists for reading the package Gateway's own process logs (setup, status, companion prepare, gateway-service start/status/restart/stop only); adding a package-log command would be a follow-up in openclaw-windows-packaging.
  • Rubber-duck review: to be run before merge per repo policy.

@clawsweeper

clawsweeper Bot commented Oct 15, 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 P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR adds a live native Gateway setup activity panel, persistent setup logging, and typed failure details.

Example: The native Gateway remains starting until the three-minute startup deadline.

  • Before: Setup displays the exception message without the last reported Gateway status.
  • After: Setup displays the failed step and last status, expands Detailed activity, and offers the setup log file.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused implementation with no definite source defect; preview evidence covers failure presentation, while production log streaming remains unexercised.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate does not apply to this collaborator-authored PR; copied native-failed UI diagnostics support rendering, while the body explicitly leaves real package streaming unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Native Gateway setup provides little visible activity or diagnostic context when preparation or startup fails.
Reason: The collaborator-authored direction adds useful visibility without introducing another runtime owner, user setting, or package command.

Merge readiness

✅ Ready for maintainer review

Keep open: this collaborator-authored PR provides useful native setup diagnostics absent from main, and source review found no definite introduced defect.

Priority: P2
Reviewed head: be651c958e3ac4a9cb1c313ff63ecdc187592bab

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied preview exercises failure rendering, but no supplied run exercises real package events through the logger into the activity panel and file, and no base-fail/head-pass test run is shown.
Agent review details

How this fits together

The setup page calls the existing native setup service and package runtime; lifecycle events and command results flow through SetupLogger into local diagnostics and the activity panel.

flowchart TD
    A[Native setup page] --> B[Native setup service]
    B --> C[Package client and runtime]
    C --> D[Package qualified clawctl]
    C --> E[SetupLogger]
    E --> F[Activity panel]
    E --> G[Local JSONL log]
Loading

Technical review

Best possible solution:

Keep the existing setup and package owners, with one window-scoped logger supplying sanitized activity and failure diagnostics.

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

Current-main source confirms the limited status display and fileless native setup logging; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The implementation extends the shared package client and existing logger, reuses the established log launcher, and keeps lifecycle and authorization decisions with their current owners.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduction and current-main boundary: The pinned introduced diff adds the activity panel and logging plumbing. Current main still constructs a fileless setup logger and displays a single status field; unrelated Cron changes belong to base movement. (src/OpenClaw.SetupEngine.UI/Pages/NativeGatewaySetupPage.xaml.cs:150, be651c958e3a)
  • Author direction and discussion: REST reads confirm COLLABORATOR authorship, the unchanged reviewed head, no review comments, and only bot discussion comments; the keep-open guard applies. (be651c958e3a)
  • Supplied behavior evidence: The full PR body contains copied native-failed preview observations, including expanded activity and typed timeout details, and explicitly reports that the real package stream was not exercised. No screenshot or transcript artifact is linked. The supplied context sourceRevision is 7878a9ce752a370323d4a66f2f196c20cf126d6d3285d0e8472d76ac1d20e549. (be651c958e3a)
  • Credential handling: The package client logs command metadata and sanitized stderr while continuing to omit stdout and restore-token stdin; existing listener authorization and credential restoration decisions remain intact. (src/OpenClaw.Connection/NativeGateway/NativeGatewayPackageClient.cs:46, be651c958e3a)
  • Existing log-launch capability reused: The new link uses LogFileLauncher, retaining the physical-path resolution established by fix(local-ai): resolve physical CUDA and setup log paths #1670 (fix(local-ai): resolve physical CUDA and setup log paths). (src/OpenClaw.SetupEngine.UI/LogFileLauncher.cs:8, be651c958e3a)
  • Policy and read-only validation: Read the complete root and applicable WinUI AGENTS files, plus test-audit and proof guidance. No maintainer-notes directory exists. The explicit single-reviewer instruction overrides helper delegation; no helper, second reviewer, build, or test ran, and git status remained clean. (AGENTS.md:5, be651c958e3a)

Likely related people:

  • Paul Campbell: Raw commit 5abfabb adds src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:12 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)
  • Karen: Raw commit 3e6ac76 adds src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3e6ac7621eca; files: src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs)

Labels

Label changes:

  • add P2: This is a bounded setup-diagnostics improvement, with no demonstrated urgent regression or newly blocked user workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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: This is a bounded setup-diagnostics improvement, with no demonstrated urgent regression or newly blocked user workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture a real native setup run showing package lifecycle events reaching the activity panel and JSONL file, with private details redacted.

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 15, 2026, 3:06 AM ET / 07:06 UTC.

@karkarl

karkarl commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Global repo triage adversarial review

Decision: HOLD_FOR_AUTHOR
Take confidence: 60%
Recommendation confidence: 95%

Both independent reviewers completed against exact head be651c958e3ac4a9cb1c313ff63ecdc187592bab. Exact-head CI is green, but three verified behavioral findings and missing native package/UI proof block landing.

Severity Finding Location Fix confidence
MEDIUM Package stderr is emitted only after successful completion. Long commands have no intermediate stderr, and timeout/cancellation discards captured output. NativeGatewayPackageClient.cs:53-55,65-74,399-422 80%
MEDIUM (single-reviewer) File logging failures can escape before rollback stop, disposal stop, and failure/retry UI, preventing cleanup and recovery. IsolatedGatewayRuntime.cs:118; SetupLogger.cs:108-110; NativeGatewaySetupPage.xaml.cs:214 90%
MEDIUM Mixed verified/unverified listeners are rejected correctly but report listeners[0], potentially blaming the legitimate Gateway instead of the failing listener. IsolatedGatewayRuntime.cs:446-450 95%
Coverage gap Aggregate-failure, sanitization, and retry guards were removed without equivalent page-level failure coverage. NativeGatewaySetupUxContractTests.cs:136-139 95%
LOW Five locale resources contain introduced ======= separator residue. fr-fr, nl-nl, pt-br, zh-cn, zh-tw resources 99%

Required next action: make log-sink failures non-fatal, stream bounded sanitized stderr while preserving stdout credential isolation, report the actual failing listener, restore failure UI coverage, remove locale residue, and provide current-head windows-winui-interactive native package/UI proof. The PR's windows-setup-ui and gateway-connection declarations are not inventory proof-pool IDs.

No code changes or remote branch updates were made by this review.

@joelagnel

Copy link
Copy Markdown
Collaborator

Looks good overall to me. Have we seen how much logging this generates? I haven't looked at the log levels but if you could take a look and confirm; high frequency log spew should be kept at non default log levels.

It would be good to also have detailed logging for the setup flow as that seems flaky right now (especially with native gateway)

@karkarl

karkarl commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Hanselman review: #1735 (feat(setup): stream live native Gateway activity log and typed failure diagnosis)

Decision: HOLD_FOR_AUTHOR. Take confidence: 60%. Recommendation confidence: 95%. Code review is complete; merge readiness is not.

Reviewed head 2c9f1c824dff8c7211953d6da5331233000e748f against exact base and merge base a259c5668fe4658c26baff30940185c77e8f47a3. Both reviewers inspected the complete 24-file patch plus pinned callers/tests. Compared with reviewed predecessor be651c958e3ac4a9cb1c313ff63ecdc187592bab, the feature patch is unchanged: both have stable patch ID 4d3e5c1756c4e2e9bf4b1e9a48ddd46d0882db9f. Runtime release/handoff differences came from the new base, not an author repair.

Independent models: claude-opus-5.5 and gpt-6-astra, both launched with high reasoning, Astra with long_context. The supported read-only code-review agent type replaced rubber-duck. Runtime results confirm model IDs; agents cannot independently inspect effort/tier. No Codex CLI or isolated-helper attestation is claimed.

HIGH consensus

Agreement is about the defect, not necessarily severity.

Issue Opus 5.5 GPT-6 Astra Fix Confidence
Log-file failure blocks rollback and recovery UI MEDIUM MEDIUM 90%
Ownership diagnosis can name the legitimate listener LOW MEDIUM 95%
  1. Make diagnostic sink failures nonfatal. At IsolatedGatewayRuntime.cs:118-125, logging precedes rollback stop. Persistent disk-full/quota failure escapes SetupLogger.cs:108-111; subsequent stop invocation also logs first. ShowFailure:213-223 can then fail before showing the failure bar and Retry. Disable the failed file sink with explicit fallback notification, preserve sanitized in-memory events, and test that cleanup and recovery remain reachable.
  2. Report the listener that fails verification. IsolatedGatewayRuntime.cs:464-468 checks every listener but reports listeners[0]. With an attested IPv4 listener followed by an unattested IPv6 listener, this blames the Gateway. Retain the failing entry and test mixed listeners. Authorization still fails closed.

LOW consensus

Issue Opus 5.5 GPT-6 Astra Fix Confidence
Removed failure/sanitization/retry guards LOW not flagged 95%
Five locale separator remnants LOW not flagged 99%
Timeout/cancellation loses stderr: diagnostic gap, disputed regression attribution LOW not flagged 80%

Restore equivalent coverage around NativeGatewaySetupUxContractTests.cs:132-139. Remove bare ======= lines in the five non-English resources, for example fr-fr:7744. These are coverage/cleanup items, not demonstrated application failures.

Disputed/rejected rationale: Package stderr is buffered until completion and lost on cancellation, but that loss predates this PR. The new logger events are live. Unlike the predecessor review, this review does not classify it as a new MEDIUM regression or require raw stdout streaming. Bounded sanitized stderr retention remains useful follow-up. Arbitrary readiness-reason leakage was rejected against the pinned packaging producer's fixed enum mapping. No credential leak or authorization bypass was established. Debug is not opt-in in the tray logger; nominal Debug labels alone do not prove low default log volume.

Inspected validation, not locally executed: exact-head CI run 38983841532 succeeded. Downloaded TRX reports show Shared 4,385 passed, Tray 4,090, Connection 1,658 and SetupEngine 2,349, with zero failures. All 114 cases in the five affected test classes passed. No local build, test run, application or Gateway was launched for this review.

Missing proof: windows-winui-interactive current-head visible native setup activity, failure/retry, navigation/unload and log-file behavior, including a real package-backed success/timeout path on an authorized isolated host. The body still reports predecessor validation and an unlinked failure preview, and explicitly lacks real package-stream evidence. windows-setup-ui and gateway-connection are not inventory pool IDs. Correct the declaration; hosted WSL E2E does not prove native package behavior. No new system.run containment change was found, so this review does not invent a separate windows-wsl-mxc requirement.

Next action: author fixes the two verified behavioral defects, restores failure coverage, removes locale residue and supplies current-head native proof. Maintainer then revalidates the changed head. No source, branch, GitHub or shared-runtime changes were made by this review.

…e diagnosis

The native Gateway setup page previously showed a single status line and only
ex.Message on failure, while all native setup logging went to throwaway
SetupLogger instances and clawctl stderr was discarded.

- SetupLogger is now safe to write after Dispose, and the IOpenClawLogger
  adapter takes a configurable prefix instead of hard-coded "[WS] ".
- NativeGatewayPackageClient captures stderr, logs every clawctl call with
  exit code and sanitized stderr tail (never stdout, which carries the
  Gateway token), and names the failing command and exit code in parse
  errors without leaking stderr into user-facing messages.
- IsolatedGatewayRuntime logs lifecycle transitions (status summaries,
  start/stop, listener verification, rollback) and carries the last
  IsolatedGatewayStatus on startup timeout; unknown-listener details now
  name the squatting process without claiming its PID identity.
- New NativeGatewaySetupDiagnostics renders sanitized typed failure facts
  (port/verdict, last status, Win32 error code, error type), and the
  ownership failure now includes the provenance detail it previously
  dropped.
- The setup window owns a window-scoped native setup log at
  %APPDATA%\OpenClawTray\Logs\Setup\native-setup-*.jsonl, and the page gets
  a "Detailed activity" expander with live lines, an "Open log file" link,
  and a failure InfoBar that names the failed row and opens the expander
  automatically. Resources added in all six locales.
The rebase left a bare ======= merge-marker line between Onboarding_Native_Preview
and Onboarding_Native_Activity.Header in the fr-fr, nl-nl, pt-br, zh-cn and zh-tw
Resources.resw files. The files still parsed as XML because the line is a stray
text node under <root>, so existing localization tests did not catch it.

- Delete the five stray marker lines. Key parity with en-us is unchanged.
- Add LocalizationValidationTests.NoLocale_HasStrayTextOutsideResourceElements,
  which fails when a locale resw carries non-whitespace text directly under the
  root element.
The rebase merged two failure surfaces on the native Gateway setup page and
both kept a way to open the same log file: the recovery panel's "View setup
log" button and the activity expander's "Open log file" link. Keep the
expander link, which sits next to the log text it opens.

- Remove ViewLogButton from the recovery panel and its ViewLog_Click handler.
- ShowRecovery keeps the panel visible when no log file exists by checking
  _log?.FilePath directly instead of the deleted button's visibility.
- Remove Onboarding_Native_ViewLog.Content from all six locales.
InspectSnapshot checks every listener on the verified port but always
reported listeners[0] in the ownership-failure detail. With an attested
IPv4 listener beside an unverified IPv6 listener, the error blamed the
legitimate Gateway instead of the listener that actually failed.

- Report the first listener that fails the ownership check.
- Add a mixed-listeners test asserting the failing listener is named and
  the verified one is not blamed. Authorization still fails closed.
@larroy
larroy force-pushed the native-setup-activity-log branch from 4e62241 to 2e3b967 Compare November 3, 2026 21:04
@larroy
larroy merged commit f906460 into openclaw:main Nov 3, 2026
25 checks passed
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. 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