Skip to content

Commit e157ceb

Browse files
bkudiessCopilot
andauthored
Standardize onboarding gateway choice on ListView pill selector (#1048)
The Welcome step wrapped two accent-bordered cards in a RadioButtons group while also swapping the card border on selection, so each option showed two selection indicators (radio ellipse + highlighted card). Replace it with a single-select ListView whose built-in Fluent selection pill is the sole indicator, matching the ListView pattern already used by WizardPage. Vertically center the icon tiles so they align with the title/caption block. Delete the now-redundant UpdateCardSelection border-swap logic and its call sites, and enforce an always-one-selected invariant in the SelectionChanged handler (a single-select ListView can otherwise be cleared to no selection). Add AutomationProperties.HelpText for the choice group and harden the WelcomePage contract test to lock in single-select, disabled inner scroll, the wired handler, and absence of the old card chrome. Co-authored-by: Copilot App <[email protected]>
1 parent 4d09797 commit e157ceb

3 files changed

Lines changed: 91 additions & 93 deletions

File tree

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

Lines changed: 64 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -26,81 +26,72 @@
2626
IsTabStop="False"
2727
VerticalScrollBarVisibility="Auto"
2828
HorizontalScrollBarVisibility="Disabled">
29-
<RadioButtons x:Name="GatewayChoiceSelector"
30-
AutomationProperties.Name="Gateway setup method"
31-
MaxWidth="560"
32-
MaxColumns="1"
33-
HorizontalAlignment="Stretch"
34-
SelectionChanged="GatewayChoice_SelectionChanged">
35-
<RadioButton x:Name="InstallChoice"
36-
AutomationProperties.AutomationId="WelcomeInstallLocalGatewayChoice"
37-
AutomationProperties.Name="Install a local gateway (WSL), recommended"
38-
Margin="0,0,0,12"
39-
HorizontalAlignment="Stretch"
40-
HorizontalContentAlignment="Stretch">
41-
<Border x:Name="InstallCard"
42-
HorizontalAlignment="Stretch"
43-
Padding="16" CornerRadius="4"
44-
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
45-
BorderBrush="{ThemeResource AccentFillColorDefaultBrush}"
46-
BorderThickness="2">
47-
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="16">
48-
<Border Grid.Column="0" Width="44" Height="44" CornerRadius="6"
49-
Background="{ThemeResource AccentFillColorDefaultBrush}" VerticalAlignment="Top">
50-
<FontIcon Glyph="&#xE756;" FontSize="20" IsTextScaleFactorEnabled="False"
51-
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}" />
52-
</Border>
53-
<StackPanel Grid.Column="1" Spacing="3">
54-
<StackPanel Orientation="Horizontal" Spacing="8">
55-
<TextBlock x:Name="InstallTitle"
56-
Text="Install a local gateway (WSL)"
57-
Style="{StaticResource BodyStrongTextBlockStyle}"
58-
VerticalAlignment="Center" />
59-
<Border CornerRadius="4" Padding="7,1" VerticalAlignment="Center"
60-
BorderBrush="{ThemeResource AccentTextFillColorPrimaryBrush}" BorderThickness="1">
61-
<TextBlock Text="Recommended"
62-
Style="{StaticResource CaptionTextBlockStyle}"
63-
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
64-
</Border>
65-
</StackPanel>
66-
<TextBlock TextWrapping="Wrap"
67-
Style="{StaticResource CaptionTextBlockStyle}"
68-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
69-
Text="A private, self-hosted OpenClaw gateway in an isolated Ubuntu WSL instance. We'll show exactly what gets installed before anything runs." />
29+
<ListView x:Name="GatewayChoiceSelector"
30+
AutomationProperties.Name="Gateway setup method"
31+
AutomationProperties.HelpText="Choose one gateway setup method."
32+
MaxWidth="560"
33+
HorizontalAlignment="Stretch"
34+
HorizontalContentAlignment="Stretch"
35+
SelectionMode="Single"
36+
ScrollViewer.VerticalScrollMode="Disabled"
37+
ScrollViewer.VerticalScrollBarVisibility="Disabled"
38+
SelectionChanged="GatewayChoice_SelectionChanged">
39+
<ListViewItem x:Name="InstallChoice"
40+
AutomationProperties.AutomationId="WelcomeInstallLocalGatewayChoice"
41+
AutomationProperties.Name="Install a local gateway (WSL), recommended"
42+
HorizontalContentAlignment="Stretch"
43+
VerticalContentAlignment="Center"
44+
Padding="16,12">
45+
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="16">
46+
<Border Grid.Column="0" Width="44" Height="44" CornerRadius="6"
47+
Background="{ThemeResource AccentFillColorDefaultBrush}" VerticalAlignment="Center">
48+
<FontIcon Glyph="&#xE756;" FontSize="20" IsTextScaleFactorEnabled="False"
49+
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}" />
50+
</Border>
51+
<StackPanel Grid.Column="1" Spacing="3">
52+
<StackPanel Orientation="Horizontal" Spacing="8">
53+
<TextBlock x:Name="InstallTitle"
54+
Text="Install a local gateway (WSL)"
55+
Style="{StaticResource BodyStrongTextBlockStyle}"
56+
VerticalAlignment="Center" />
57+
<Border CornerRadius="4" Padding="7,1" VerticalAlignment="Center"
58+
BorderBrush="{ThemeResource AccentTextFillColorPrimaryBrush}" BorderThickness="1">
59+
<TextBlock Text="Recommended"
60+
Style="{StaticResource CaptionTextBlockStyle}"
61+
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
62+
</Border>
7063
</StackPanel>
71-
</Grid>
72-
</Border>
73-
</RadioButton>
64+
<TextBlock TextWrapping="Wrap"
65+
Style="{StaticResource CaptionTextBlockStyle}"
66+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
67+
Text="A private, self-hosted OpenClaw gateway in an isolated Ubuntu WSL instance. We'll show exactly what gets installed before anything runs." />
68+
</StackPanel>
69+
</Grid>
70+
</ListViewItem>
7471

75-
<RadioButton x:Name="ConnectChoice"
76-
AutomationProperties.AutomationId="WelcomeConnectExistingGatewayChoice"
77-
AutomationProperties.Name="Connect to an existing gateway"
78-
HorizontalAlignment="Stretch"
79-
HorizontalContentAlignment="Stretch">
80-
<Border x:Name="ConnectCard"
81-
HorizontalAlignment="Stretch"
82-
Padding="16" CornerRadius="4"
83-
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
84-
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
85-
BorderThickness="1">
86-
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="16">
87-
<Border Grid.Column="0" Width="44" Height="44" CornerRadius="6"
88-
Background="{ThemeResource SubtleFillColorSecondaryBrush}" VerticalAlignment="Top">
89-
<FontIcon Glyph="&#xE71B;" FontSize="20" IsTextScaleFactorEnabled="False"
90-
Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
91-
</Border>
92-
<StackPanel Grid.Column="1" Spacing="3">
93-
<TextBlock Text="Connect to an existing gateway"
94-
Style="{StaticResource BodyStrongTextBlockStyle}" />
95-
<TextBlock TextWrapping="Wrap"
96-
Style="{StaticResource CaptionTextBlockStyle}"
97-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
98-
Text="Already run an OpenClaw gateway: here, on another machine, or remote? Pair without installing anything." />
99-
</StackPanel>
100-
</Grid>
101-
</Border>
102-
</RadioButton>
103-
</RadioButtons>
72+
<ListViewItem x:Name="ConnectChoice"
73+
AutomationProperties.AutomationId="WelcomeConnectExistingGatewayChoice"
74+
AutomationProperties.Name="Connect to an existing gateway"
75+
HorizontalContentAlignment="Stretch"
76+
VerticalContentAlignment="Center"
77+
Padding="16,12">
78+
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="16">
79+
<Border Grid.Column="0" Width="44" Height="44" CornerRadius="6"
80+
Background="{ThemeResource SubtleFillColorSecondaryBrush}" VerticalAlignment="Center">
81+
<FontIcon Glyph="&#xE71B;" FontSize="20" IsTextScaleFactorEnabled="False"
82+
Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
83+
</Border>
84+
<StackPanel Grid.Column="1" Spacing="3">
85+
<TextBlock Text="Connect to an existing gateway"
86+
Style="{StaticResource BodyStrongTextBlockStyle}" />
87+
<TextBlock TextWrapping="Wrap"
88+
Style="{StaticResource CaptionTextBlockStyle}"
89+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
90+
Text="Already run an OpenClaw gateway: here, on another machine, or remote? Pair without installing anything." />
91+
</StackPanel>
92+
</Grid>
93+
</ListViewItem>
94+
</ListView>
10495
</ScrollViewer>
10596

10697
<Grid Grid.Row="2" ColumnDefinitions="*,Auto" Margin="0,16,0,0">

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Microsoft.UI.Xaml;
33
using Microsoft.UI.Xaml.Controls;
44
using Microsoft.UI.Xaml.Hosting;
5-
using Microsoft.UI.Xaml.Media;
65
using Microsoft.UI.Xaml.Navigation;
76
using OpenClaw.SetupEngine;
87
using OpenClaw.SetupEngine.UI;
@@ -23,8 +22,6 @@ public WelcomePage()
2322
{
2423
InitializeComponent();
2524
Loaded += OnLoaded;
26-
ActualThemeChanged += (_, _) => UpdateCardSelection();
27-
UpdateCardSelection();
2825
}
2926

3027
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -40,7 +37,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
4037
{
4138
_suppressSelectionWrite = false;
4239
}
43-
UpdateCardSelection();
4440
}
4541

4642
private void OnLoaded(object sender, RoutedEventArgs e)
@@ -68,28 +64,32 @@ private void StartMascotBreatheAnimation()
6864

6965
private void GatewayChoice_SelectionChanged(object sender, SelectionChangedEventArgs e)
7066
{
71-
if (!_suppressSelectionWrite && GatewayChoiceSelector.SelectedIndex is 0 or 1)
67+
// A single-select ListView can be cleared to no selection (Ctrl+click / automation).
68+
// The Welcome choice must always have exactly one option selected, so restore the last
69+
// known selection instead of leaving the persisted value stale behind an empty list.
70+
if (GatewayChoiceSelector.SelectedIndex is not (0 or 1))
71+
{
72+
_suppressSelectionWrite = true;
73+
try
74+
{
75+
GatewayChoiceSelector.SelectedIndex = _installSelected ? 0 : 1;
76+
}
77+
finally
78+
{
79+
_suppressSelectionWrite = false;
80+
}
81+
82+
return;
83+
}
84+
85+
if (!_suppressSelectionWrite)
7286
SetInstallSelected(GatewayChoiceSelector.SelectedIndex == 0);
7387
}
7488

7589
private void SetInstallSelected(bool installSelected)
7690
{
7791
_installSelected = installSelected;
7892
SetupWindow.Active?.SetWelcomeInstallSelected(installSelected);
79-
UpdateCardSelection();
80-
}
81-
82-
private void UpdateCardSelection()
83-
{
84-
InstallCard.BorderBrush = _installSelected
85-
? (Brush)Application.Current.Resources["AccentFillColorDefaultBrush"]
86-
: (Brush)Application.Current.Resources["CardStrokeColorDefaultBrush"];
87-
InstallCard.BorderThickness = new Thickness(_installSelected ? 2 : 1);
88-
89-
ConnectCard.BorderBrush = !_installSelected
90-
? (Brush)Application.Current.Resources["AccentFillColorDefaultBrush"]
91-
: (Brush)Application.Current.Resources["CardStrokeColorDefaultBrush"];
92-
ConnectCard.BorderThickness = new Thickness(!_installSelected ? 2 : 1);
9393
}
9494

9595
private void Back_Click(object sender, RoutedEventArgs e)

‎tests/OpenClaw.Tray.Tests/AppRefactorContractTests.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,17 @@ public void SetupWelcomePage_KeepsNavigationOutsideScrollableSemanticChoices()
825825

826826
Assert.Contains("<ScrollViewer Grid.Row=\"1\"", xaml);
827827
Assert.Contains("VerticalScrollBarVisibility=\"Auto\"", xaml);
828-
Assert.Contains("<RadioButtons x:Name=\"GatewayChoiceSelector\"", xaml);
828+
Assert.Contains("<ListView x:Name=\"GatewayChoiceSelector\"", xaml);
829+
Assert.Contains("SelectionMode=\"Single\"", xaml);
830+
Assert.Contains("ScrollViewer.VerticalScrollMode=\"Disabled\"", xaml);
831+
Assert.Contains("SelectionChanged=\"GatewayChoice_SelectionChanged\"", xaml);
829832
Assert.Contains("AutomationProperties.AutomationId=\"WelcomeInstallLocalGatewayChoice\"", xaml);
830833
Assert.Contains("AutomationProperties.AutomationId=\"WelcomeConnectExistingGatewayChoice\"", xaml);
831834
Assert.DoesNotContain("PointerPressed=", xaml);
835+
// The old duplicate card-selection chrome and its border-swap logic must not return.
836+
Assert.DoesNotContain("x:Name=\"InstallCard\"", xaml);
837+
Assert.DoesNotContain("x:Name=\"ConnectCard\"", xaml);
838+
Assert.DoesNotContain("UpdateCardSelection", welcomePage);
832839
AssertInOrder(xaml, "<ScrollViewer Grid.Row=\"1\"", "</ScrollViewer>", "<Grid Grid.Row=\"2\"");
833840
Assert.DoesNotContain("GatewayChoiceSelector.SelectedIndex = 0;", welcomePage);
834841
Assert.Contains("_suppressSelectionWrite = true", welcomePage);

0 commit comments

Comments
 (0)