Skip to content

fix(macos): avoid Tailscale hydration config rewrites - #75982

Merged
BunsDev merged 5 commits into
mainfrom
meow/fix-macos-general-hydration
May 2, 2026
Merged

BunsDev merged 5 commits into
mainfrom
meow/fix-macos-general-hydration

Conversation

@BunsDev

@BunsDev BunsDev commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep General/Tailscale hydration from saving the loaded snapshot back into openclaw.json.
  • Track the normalized last-applied Tailscale settings and no-op save-on-change while UI state still matches hydration.
  • Add a regression proving opening General/Tailscale does not mutate gateway, gateway.auth, meta, or wizard.

Fixes #59545

Root Cause

TailscaleIntegrationSection.loadConfig() hydrates SwiftUI @State values, and the existing .onChange handlers can schedule applySettings() during that initial state change. Once hasLoaded is true, the pending apply path rewrites the config even though the user has not edited settings, normalizing unrelated gateway/auth/meta fields through the save path.

Fix

  • Record a GatewayTailscaleSettingsSnapshot after load, with password trimming normalized to match the save path.
  • Gate applySettings through applySettingsIfChanged; unchanged hydration state returns before validation, save, and status calls.
  • Clear transient validation/status messages on unchanged no-op applies, so reverting an invalid edit back to the loaded snapshot does not leave stale UI errors.
  • Keep the save owner path inside TailscaleIntegrationSection and the existing ConfigStore.save(... allowGatewayAuthMutation: true) flow.

Regression

The new test writes a config with gateway.bind = "auto", token auth, and existing meta/wizard, then simulates General/Tailscale hydration plus save-on-change. With the no-op guard removed, this test fails by rewriting bind to loopback, dropping auth mode, and touching meta.lastTouchedAt; with the guard restored it passes.

Verification

  • git diff --check origin/main...HEAD
  • swiftformat --lint apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift --config .swiftformat
  • swiftlint lint --config .swiftlint.yml apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests
  • swift test --package-path apps/macos --filter 'OpenClawIPCTests\.(TailscaleIntegrationSectionTests|SettingsViewSmokeTests|OpenClawConfigFileTests|ConfigStoreTests)'
  • OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changed
  • Exact-head GitHub Actions for aaf4db2450: Workflow Sanity, OpenGrep — PR Diff, and CI succeeded

@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: M maintainer Maintainer-authored PR labels May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds a macOS Tailscale settings snapshot/no-op apply guard, regression tests, and a changelog entry to prevent opening General settings from rewriting openclaw.json.

Reproducibility: yes. The linked issue gives a concrete Settings > General mtime/diff path, and current main still shows General mounting Tailscale settings plus hydration/onChange/apply code that can persist gateway, gateway.auth, and meta without an edit.

Next step before merge
This is an active protected maintainer-labeled PR with no narrow automated repair needed; the next action is normal maintainer review and landing or requested changes.

Security
Cleared: The diff touches macOS Swift config-handling code, macOS tests, and CHANGELOG.md; it adds no dependency, workflow, package, artifact download, secret handling, or permission surface.

Review details

Best possible solution:

Land the macOS-owned hydration no-op guard after maintainer review so #59545 closes through the merge, while leaving broader config mutation reports to their focused tracks.

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

Yes. The linked issue gives a concrete Settings > General mtime/diff path, and current main still shows General mounting Tailscale settings plus hydration/onChange/apply code that can persist gateway, gateway.auth, and meta without an edit.

Is this the best way to solve the issue?

Yes. The snapshot/dirty-check is the narrowest maintainable fix I found: it keeps initial UI hydration read-only without changing global config save semantics or removing the intentional Tailscale auth mutation path.

Acceptance criteria:

  • swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests
  • swift test --package-path apps/macos --filter 'OpenClawIPCTests.(TailscaleIntegrationSectionTests|SettingsViewSmokeTests|OpenClawConfigFileTests|ConfigStoreTests)'
  • swiftformat --lint apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift --config .swiftformat
  • swiftlint lint --config .swiftlint.yml apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift

What I checked:

Likely related people:

  • BunsDev: Current-main path history shows prior merged work preserving gateway auth and unrelated config keys across ConfigStore, OpenClawConfigFile, and the Tailscale save path directly adjacent to this PR. (role: recent adjacent maintainer; confidence: high; commits: 7c2802b21240; files: apps/macos/Sources/OpenClaw/ConfigStore.swift, apps/macos/Sources/OpenClaw/OpenClawConfigFile.swift, apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift)
  • steipete: GitHub path history shows repeated recent maintenance of the macOS settings/config files, including config write auditing and General settings work near the affected surface. (role: recent maintainer and adjacent owner; confidence: medium; commits: c5c96403748a, a290e91b1215, c72f8f357b55; files: apps/macos/Sources/OpenClaw/OpenClawConfigFile.swift, apps/macos/Sources/OpenClaw/GeneralSettings.swift, apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8731820ba276.

@BunsDev BunsDev self-assigned this May 2, 2026
@BunsDev
BunsDev force-pushed the meow/fix-macos-general-hydration branch from 8f6e9ca to efa8366 Compare May 2, 2026 07:13

BunsDev commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the review point in efa8366522.

  • The unchanged/no-op Tailscale apply path now clears transient validationMessage / statusMessage before returning, so reverting an invalid edit back to the loaded snapshot cannot leave a stale error visible.
  • Added regression coverage: unchanged tailscale apply clears stale messages.

Verification rerun:

  • swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests
  • swift test --package-path apps/macos --filter 'OpenClawIPCTests\.(TailscaleIntegrationSectionTests|SettingsViewSmokeTests|OpenClawConfigFileTests|ConfigStoreTests)'
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • swiftlint lint --config .swiftlint.yml apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changed
  • Post-rebase: git diff --check origin/main...HEAD
  • Post-rebase: swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests

Duplicate sweep result:

Outcome: #59545 remains the canonical issue and this PR remains linked with Fixes #59545; no duplicate issues were closed.

@BunsDev
BunsDev marked this pull request as ready for review May 2, 2026 07:17

BunsDev commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

CI follow-up pushed in bbf427ce01: applied repo SwiftFormat output to apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift, which addresses the current macos-swift / SwiftFormat failure.

Verification after the formatting fix:

  • swiftformat --lint apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift --config .swiftformat
  • swiftlint lint --config .swiftlint.yml apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests
  • swift test --package-path apps/macos --filter 'OpenClawIPCTests\.(TailscaleIntegrationSectionTests|SettingsViewSmokeTests|OpenClawConfigFileTests|ConfigStoreTests)'
  • git diff --check origin/main...HEAD
  • OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changed

@clawsweeper

clawsweeper Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

🦞🦞
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.

@BunsDev
BunsDev force-pushed the meow/fix-macos-general-hydration branch from bbf427c to aaf4db2 Compare May 2, 2026 07:30

BunsDev commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased the branch onto current origin/main and force-pushed a clean three-commit PR history. New head: aaf4db2450.

The PR diff remains scoped to:

  • CHANGELOG.md
  • apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift
  • apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift

Post-rebase verification:

  • git diff --check origin/main...HEAD
  • swiftformat --lint apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift --config .swiftformat
  • swiftlint lint --config .swiftlint.yml apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md apps/macos/Sources/OpenClaw/TailscaleIntegrationSection.swift apps/macos/Tests/OpenClawIPCTests/TailscaleIntegrationSectionTests.swift
  • swift test --package-path apps/macos --filter OpenClawIPCTests.TailscaleIntegrationSectionTests
  • swift test --package-path apps/macos --filter 'OpenClawIPCTests\.(TailscaleIntegrationSectionTests|SettingsViewSmokeTests|OpenClawConfigFileTests|ConfigStoreTests)'
  • OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changed

@clawsweeper

clawsweeper Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

🦞🦞
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.

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

Labels

app: macos App: macos maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS app General settings rewrites ~/.openclaw/openclaw.json without user changes

1 participant