Skip to content

Commit 70b5648

Browse files
shanselmanCopilot
andcommitted
Fix setup review truth and capability persistence
Derive the setup install review and completion summary from the live setup configuration so custom distro, port, bind, and installer values are shown truthfully. Sync runtime Node capability settings from SetupConfig.Capabilities inside the setup engine settings writer so headless/config-driven runs do not persist default-on capability gates. Co-authored-by: Copilot App <[email protected]>
1 parent 2bd70cf commit 70b5648

9 files changed

Lines changed: 165 additions & 13 deletions

File tree

‎src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
<Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="14">
100100
<FontIcon Grid.Column="0" Glyph="&#xE756;" FontSize="18" VerticalAlignment="Center" />
101101
<StackPanel Grid.Column="1" Spacing="2">
102-
<TextBlock Text="Install an isolated Ubuntu 24.04 instance" Style="{StaticResource BodyStrongTextBlockStyle}" />
103-
<TextBlock TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="WSL distro &quot;OpenClawGateway&quot; in your AppData. Separate from any Ubuntu you already have." />
102+
<TextBlock x:Name="InstallDistroTitleText" Text="Install an isolated Ubuntu 24.04 instance" Style="{StaticResource BodyStrongTextBlockStyle}" />
103+
<TextBlock x:Name="InstallDistroDetailText" TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="WSL distro &quot;OpenClawGateway&quot; in your AppData. Separate from any Ubuntu you already have." />
104104
</StackPanel>
105105
<TextBlock Grid.Column="2" Text="~200 MB" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}" FontFamily="Cascadia Mono, Consolas" VerticalAlignment="Center" />
106106
</Grid>
@@ -110,19 +110,19 @@
110110
<FontIcon Grid.Column="0" Glyph="&#xE896;" FontSize="18" VerticalAlignment="Center" />
111111
<StackPanel Grid.Column="1" Spacing="2">
112112
<TextBlock Text="Download &amp; install the OpenClaw CLI" Style="{StaticResource BodyStrongTextBlockStyle}" />
113-
<TextBlock TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Fetched over HTTPS; runs as a non-root openclaw user inside the instance." />
113+
<TextBlock x:Name="InstallCliDetailText" TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Fetched over HTTPS; runs as a non-root openclaw user inside the instance." />
114114
</StackPanel>
115-
<TextBlock Grid.Column="2" Text="HTTPS" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}" FontFamily="Cascadia Mono, Consolas" VerticalAlignment="Center" />
115+
<TextBlock x:Name="InstallCliBadgeText" Grid.Column="2" Text="HTTPS" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}" FontFamily="Cascadia Mono, Consolas" VerticalAlignment="Center" />
116116
</Grid>
117117
</Border>
118118
<Border Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="4" Padding="14,12">
119119
<Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="14">
120120
<FontIcon Grid.Column="0" Glyph="&#xE968;" FontSize="18" VerticalAlignment="Center" />
121121
<StackPanel Grid.Column="1" Spacing="2">
122122
<TextBlock Text="Run a local gateway service" Style="{StaticResource BodyStrongTextBlockStyle}" />
123-
<TextBlock TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Loopback only — not reachable from your network or the internet." />
123+
<TextBlock x:Name="GatewayServiceDetailText" TextWrapping="Wrap" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Loopback only — not reachable from your network or the internet." />
124124
</StackPanel>
125-
<TextBlock Grid.Column="2" Text="127.0.0.1:18789" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}" FontFamily="Cascadia Mono, Consolas" VerticalAlignment="Center" />
125+
<TextBlock x:Name="GatewayEndpointText" Grid.Column="2" Text="127.0.0.1:18789" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}" FontFamily="Cascadia Mono, Consolas" VerticalAlignment="Center" />
126126
</Grid>
127127
</Border>
128128
<Border Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="4" Padding="14,12">
@@ -138,7 +138,7 @@
138138

139139
<Expander Margin="0,8,0,0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
140140
Header="Show the exact commands &amp; files">
141-
<TextBlock FontFamily="Cascadia Mono, Consolas" FontSize="12" TextWrapping="Wrap"
141+
<TextBlock x:Name="ExactCommandsText" FontFamily="Cascadia Mono, Consolas" FontSize="12" TextWrapping="Wrap"
142142
Foreground="{ThemeResource TextFillColorSecondaryBrush}" Margin="0,4,0,4"
143143
Text="wsl --install -d Ubuntu-24.04 --name OpenClawGateway --no-launch&#x0a;curl -fsSL --proto '=https' --tlsv1.2 &lt;install-url&gt; | bash&#x0a;openclaw config set gateway.bind loopback · port 18789&#x0a;openclaw gateway install --force (systemd --user service)&#x0a;writes -&gt; %LOCALAPPDATA%\OpenClawTray\wsl\OpenClawGateway\&#x0a;writes -&gt; %APPDATA%\OpenClawTray\gateways.json + identity" />
144144
</Expander>

‎src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
7070
// Only probe OS permissions when the permissions step will actually be shown.
7171
if (!_skipPermissions)
7272
_permissionsTask = BuildPermissionRows();
73+
ApplySetupReviewSummary(_config);
7374
GoToStep(1);
7475
}
7576

@@ -165,6 +166,18 @@ private void WriteCapabilities()
165166
config.Settings.ApplyCapabilities(caps);
166167
}
167168

169+
private void ApplySetupReviewSummary(SetupConfig config)
170+
{
171+
var summary = SetupReviewSummaryBuilder.Build(config);
172+
InstallDistroTitleText.Text = summary.DistroTitle;
173+
InstallDistroDetailText.Text = summary.DistroDescription;
174+
InstallCliDetailText.Text = summary.InstallerDescription;
175+
InstallCliBadgeText.Text = summary.InstallerBadge;
176+
GatewayServiceDetailText.Text = summary.GatewayDescription;
177+
GatewayEndpointText.Text = summary.GatewayEndpoint;
178+
ExactCommandsText.Text = summary.ExactCommands;
179+
}
180+
168181
private string ProfileSummary()
169182
{
170183
if (MatchesProfile(ProfileReadOnly)) return "Read-only";

‎src/OpenClaw.SetupEngine.UI/Pages/CompletePage.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<FontIcon Grid.Column="0" Glyph="&#xE756;" FontSize="18" VerticalAlignment="Center" />
5959
<StackPanel Grid.Column="1" Spacing="2">
6060
<TextBlock Text="Local gateway running" Style="{StaticResource BodyStrongTextBlockStyle}" />
61-
<TextBlock Text="OpenClawGateway · 127.0.0.1:18789" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
61+
<TextBlock x:Name="GatewaySummaryText" Text="OpenClawGateway · 127.0.0.1:18789" Style="{StaticResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
6262
</StackPanel>
6363
<FontIcon Grid.Column="2" Glyph="&#xE73E;" FontSize="16" Foreground="{ThemeResource SystemFillColorSuccessBrush}" VerticalAlignment="Center" />
6464
</Grid>

‎src/OpenClaw.SetupEngine.UI/Pages/CompletePage.xaml.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
3131
FailureIcon.Visibility = Visibility.Collapsed;
3232
StartupToggle.IsOn = args.DefaultAutoStart;
3333
StartupRow.Visibility = args.ShowStartupPreference ? Visibility.Visible : Visibility.Collapsed;
34+
GatewaySummaryText.Text = (args.ReviewSummary ?? SetupReviewSummaryBuilder.Build(new SetupConfig())).CompletionGatewaySummary;
3435
TitleText.Text = "All set!";
3536
SubtitleText.Text = "OpenClaw is ready to go";
3637
ErrorCard.Visibility = Visibility.Collapsed;

‎src/OpenClaw.SetupEngine.UI/SetupWindow.xaml.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ public void NavigateToComplete(bool success, TimeSpan elapsed, string? logPath,
151151
logPath,
152152
errorMessage,
153153
DefaultAutoStart: true,
154-
ShowStartupPreference: _showStartupPreferenceOnComplete));
154+
ShowStartupPreference: _showStartupPreferenceOnComplete,
155+
ReviewSummary: SetupReviewSummaryBuilder.Build(_config)));
155156

156157
// Directional page transition: forward steps slide in from the right, Back from the left.
157158
private void NavigateTo(Type page, object? parameter, bool back = false) =>
@@ -301,5 +302,6 @@ public sealed record CompletePageArgs(
301302
string? LogPath,
302303
string? ErrorMessage = null,
303304
bool DefaultAutoStart = true,
304-
bool ShowStartupPreference = true);
305+
bool ShowStartupPreference = true,
306+
SetupReviewSummary? ReviewSummary = null);
305307
public sealed record SetupCompletedEventArgs(bool EnableAutoStart);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
namespace OpenClaw.SetupEngine;
2+
3+
public sealed record SetupReviewSummary(
4+
string DistroTitle,
5+
string DistroDescription,
6+
string InstallerDescription,
7+
string InstallerBadge,
8+
string GatewayDescription,
9+
string GatewayEndpoint,
10+
string ExactCommands,
11+
string CompletionGatewaySummary);
12+
13+
public static class SetupReviewSummaryBuilder
14+
{
15+
public static SetupReviewSummary Build(SetupConfig config)
16+
{
17+
var distroName = Display(config.DistroName, "OpenClawGateway");
18+
var baseDistro = Display(config.BaseDistro, "Ubuntu-24.04");
19+
var gatewayBind = Display(config.Gateway.Bind, "loopback");
20+
var gatewayPort = config.GatewayPort;
21+
var installPath = Path.Combine(SetupContext.ResolveLocalDataDir(), "wsl", distroName);
22+
var gatewayDataPath = Path.Combine(SetupContext.ResolveDataDir(), "gateways.json");
23+
var installUrl = config.Gateway.InstallUrl ?? GatewayLkgVersion.DefaultInstallUrl;
24+
var installerHost = TryGetHttpsHost(installUrl);
25+
var installerDescription = installerHost is null
26+
? "Installer URL is not HTTPS; setup will stop before downloading anything."
27+
: $"Fetched over HTTPS from {installerHost}; runs as a non-root {Display(config.Wsl.User, "openclaw")} user inside the instance.";
28+
var installerBadge = installerHost is null ? "Invalid URL" : "HTTPS";
29+
var isLanBind = gatewayBind.Equals("lan", StringComparison.OrdinalIgnoreCase);
30+
var gatewayDescription = isLanBind
31+
? "LAN bind enabled — reachable from this PC and your local network according to Windows firewall/routing."
32+
: "Loopback only — not reachable from your network or the internet.";
33+
var gatewayEndpoint = isLanBind ? $"LAN:{gatewayPort}" : $"127.0.0.1:{gatewayPort}";
34+
var wslCommand = "wsl " + string.Join(' ', WslInstallSupport.BuildDirectInstallArgs(baseDistro, distroName, installPath));
35+
var installCommand = string.IsNullOrWhiteSpace(config.Gateway.Version)
36+
? "curl -fsSL --proto '=https' --tlsv1.2 <install-url> | bash"
37+
: $"curl -fsSL --proto '=https' --tlsv1.2 <install-url> | bash -s -- --version {config.Gateway.Version.Trim()}";
38+
39+
return new SetupReviewSummary(
40+
DistroTitle: $"Install an isolated {baseDistro} instance",
41+
DistroDescription: $"WSL distro \"{distroName}\" at {installPath}. Separate from any Linux distributions you already have.",
42+
InstallerDescription: installerDescription,
43+
InstallerBadge: installerBadge,
44+
GatewayDescription: gatewayDescription,
45+
GatewayEndpoint: gatewayEndpoint,
46+
ExactCommands: string.Join(
47+
Environment.NewLine,
48+
wslCommand,
49+
installCommand,
50+
$"openclaw config set gateway.bind {gatewayBind} · port {gatewayPort}",
51+
"openclaw gateway install --force (systemd --user service)",
52+
$"writes -> {installPath}",
53+
$"writes -> {gatewayDataPath} + identity"),
54+
CompletionGatewaySummary: $"{distroName} · {gatewayEndpoint}");
55+
}
56+
57+
private static string Display(string? value, string fallback)
58+
=> string.IsNullOrWhiteSpace(value) ? fallback : value.Trim();
59+
60+
private static string? TryGetHttpsHost(string installUrl)
61+
=> Uri.TryCreate(installUrl, UriKind.Absolute, out var uri)
62+
&& uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)
63+
? uri.Host
64+
: null;
65+
}

‎src/OpenClaw.SetupEngine/SetupSteps.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2672,9 +2672,10 @@ private static async Task<StepResult> DrainPendingApprovalsAsync(SetupContext ct
26722672
return StepResult.Ok("Pending approvals drained");
26732673
}
26742674

2675-
private static void WriteSettingsJson(SetupContext ctx)
2675+
internal static void WriteSettingsJson(SetupContext ctx)
26762676
{
26772677
var settingsPath = Path.Combine(ctx.DataDir, "settings.json");
2678+
ctx.Config.Settings.ApplyCapabilities(ctx.Config.Capabilities);
26782679
ctx.Config.Settings.MergeIntoSettingsFile(settingsPath);
26792680
ctx.Logger.Info($"Wrote settings.json: EnableNodeMode={ctx.Config.Settings.EnableNodeMode}");
26802681
}

‎tests/OpenClaw.SetupEngine.Tests/SetupConfigTests.cs‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace OpenClaw.SetupEngine.Tests;
55

6+
[Collection(EnvironmentVariableCollection.Name)]
67
public class SetupConfigTests : IDisposable
78
{
89
private readonly string _tempDir;
@@ -205,13 +206,13 @@ public void TraySettingsConfig_MergesIntoFile_OverwritesSetupKeysAndPreservesUnk
205206
var settingsPath = Path.Combine(_tempDir, "settings.json");
206207
File.WriteAllText(settingsPath, """{"CustomKey": "custom_value", "EnableNodeMode": false, "AutoStart": true, "NodeCameraEnabled": false}""");
207208

208-
var traySettings = new TraySettingsConfig { EnableNodeMode = true, AutoStart = false };
209+
var traySettings = new TraySettingsConfig { EnableNodeMode = true, AutoStart = false, NodeCameraEnabled = false };
209210
traySettings.MergeIntoSettingsFile(settingsPath);
210211

211212
var result = JsonDocument.Parse(File.ReadAllText(settingsPath));
212213
Assert.True(result.RootElement.GetProperty("EnableNodeMode").GetBoolean());
213214
Assert.False(result.RootElement.GetProperty("AutoStart").GetBoolean());
214-
Assert.True(result.RootElement.GetProperty("NodeCameraEnabled").GetBoolean());
215+
Assert.False(result.RootElement.GetProperty("NodeCameraEnabled").GetBoolean());
215216
Assert.Equal("custom_value", result.RootElement.GetProperty("CustomKey").GetString());
216217
}
217218

@@ -244,6 +245,41 @@ public void TraySettingsConfig_ApplyCapabilities_MapsSetupCapabilitiesToRuntimeN
244245
Assert.False(traySettings.NodeSttEnabled);
245246
}
246247

248+
[Fact]
249+
public void SetupReviewSummary_UsesActiveSetupConfig()
250+
{
251+
var oldData = Environment.GetEnvironmentVariable("OPENCLAW_TRAY_DATA_DIR");
252+
var oldLocalData = Environment.GetEnvironmentVariable("OPENCLAW_TRAY_LOCAL_DATA_DIR");
253+
try
254+
{
255+
Environment.SetEnvironmentVariable("OPENCLAW_TRAY_DATA_DIR", Path.Combine(_tempDir, "roaming"));
256+
Environment.SetEnvironmentVariable("OPENCLAW_TRAY_LOCAL_DATA_DIR", Path.Combine(_tempDir, "local"));
257+
var config = new SetupConfig
258+
{
259+
DistroName = "CustomClaw",
260+
BaseDistro = "Debian",
261+
GatewayPort = 19999,
262+
Gateway = { Bind = "lan", InstallUrl = "https://example.test/install.sh" }
263+
};
264+
265+
var summary = SetupReviewSummaryBuilder.Build(config);
266+
267+
Assert.Contains("Debian", summary.DistroTitle);
268+
Assert.Contains("CustomClaw", summary.DistroDescription);
269+
Assert.Contains("19999", summary.GatewayEndpoint);
270+
Assert.Contains("LAN bind enabled", summary.GatewayDescription);
271+
Assert.Contains("example.test", summary.InstallerDescription);
272+
Assert.Contains("CustomClaw", summary.ExactCommands);
273+
Assert.Contains("19999", summary.ExactCommands);
274+
Assert.Equal("CustomClaw · LAN:19999", summary.CompletionGatewaySummary);
275+
}
276+
finally
277+
{
278+
Environment.SetEnvironmentVariable("OPENCLAW_TRAY_DATA_DIR", oldData);
279+
Environment.SetEnvironmentVariable("OPENCLAW_TRAY_LOCAL_DATA_DIR", oldLocalData);
280+
}
281+
}
282+
247283
[Fact]
248284
public void SetupConfig_UsesBundledDefaultConfig_IsRuntimeOnly()
249285
{

‎tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Net;
33
using System.Net.Sockets;
44
using System.Runtime.InteropServices;
5+
using System.Text.Json;
56

67
namespace OpenClaw.SetupEngine.Tests;
78

@@ -45,6 +46,39 @@ private SetupContext CreateContext(SetupConfig? config = null, ICommandRunner? c
4546
return new SetupContext(cfg, logger, journal, commands ?? new CommandRunner(logger), CancellationToken.None);
4647
}
4748

49+
[Fact]
50+
public void WriteSettingsJson_AppliesConfiguredCapabilitiesBeforePersisting()
51+
{
52+
var config = new SetupConfig
53+
{
54+
Capabilities = new CapabilitiesConfig
55+
{
56+
System = false,
57+
Canvas = true,
58+
Screen = true,
59+
Camera = false,
60+
Location = false,
61+
Browser = false,
62+
Device = true,
63+
Tts = true,
64+
Stt = false,
65+
},
66+
};
67+
var ctx = CreateContext(config);
68+
69+
VerifyEndToEndStep.WriteSettingsJson(ctx);
70+
71+
using var result = JsonDocument.Parse(File.ReadAllText(Path.Combine(_tempDir, "settings.json")));
72+
Assert.False(result.RootElement.GetProperty("NodeSystemRunEnabled").GetBoolean());
73+
Assert.True(result.RootElement.GetProperty("NodeCanvasEnabled").GetBoolean());
74+
Assert.True(result.RootElement.GetProperty("NodeScreenEnabled").GetBoolean());
75+
Assert.False(result.RootElement.GetProperty("NodeCameraEnabled").GetBoolean());
76+
Assert.False(result.RootElement.GetProperty("NodeLocationEnabled").GetBoolean());
77+
Assert.False(result.RootElement.GetProperty("NodeBrowserProxyEnabled").GetBoolean());
78+
Assert.True(result.RootElement.GetProperty("NodeTtsEnabled").GetBoolean());
79+
Assert.False(result.RootElement.GetProperty("NodeSttEnabled").GetBoolean());
80+
}
81+
4882
// ─── CleanupStaleGatewayStep: Preserve non-local records ───
4983

5084
[Fact]

0 commit comments

Comments
 (0)