Skip to content

Commit 4bbadb0

Browse files
karkarlCopilot
andcommitted
Fix onboarding wizard back navigation
Co-authored-by: Copilot App <[email protected]>
1 parent ccd64bb commit 4bbadb0

4 files changed

Lines changed: 20 additions & 28 deletions

File tree

‎docs/ONBOARDING_WIZARD.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ If the gateway doesn't support the wizard protocol or is unreachable, this scree
4747

4848
The wizard keeps recovery choices visible while setup steps are running so users can start the wizard again or skip it for now if an auth flow stalls. If the gateway restarts or the wizard connection is lost while setup is running, the same recovery choices are presented in the error state so the user is not trapped retrying a broken session.
4949

50+
Gateway-driven onboarding does not show a Back action. The Gateway wizard protocol has no rewind operation, so replaying an earlier Companion payload would display stale state while the authoritative Gateway session remained on a later step. Users can restart onboard or skip and exit from **More options** instead.
51+
5052
Exact Gateway 2026.7.1 has a terminal compatibility path for an app-managed local WSL gateway. When the final `model-check` answer produces WebSocket close 1012 before the gateway can return `done`, setup retries the temporary `NoListener` state and the typed snapshot-changed race that can occur while the listener is restarting. Other unknown or conflicting endpoint ownership fails immediately, and no credential is sent until the managed endpoint is verified again. A retryable startup close 1013 remains inside the existing reconnect timeout. Setup completes only after a fresh authenticated `hello-ok` handshake. Other versions and steps keep the normal managed-local wizard replay behavior with the same bounded ownership wait; remote gateways and other disconnects do not enter this recovery path.
5153

5254
The headless setup engine also treats one terminal wizard payload as completion instead of failure. When the answers applied by the wizard restart the gateway, the gateway can tear down its own hosted wizard TUI and return a terminal payload whose error is exactly `Error: TUI exited from signal SIGTERM`. Setup accepts that result only when the payload is terminal and the request it just sent answered the authoritative final step, so the wizard is not cancelled after it already finished. The final step must be a plain acknowledgement note with no options whose id or title normalizes to `done`, and when the gateway supplies step position metadata it must also be the last step. An earlier `SIGTERM`, a progress poll, a replayed wizard session, any answerable step, any other step id or title, a non-terminal payload, and any other message (different signal, extra text, or different casing) all keep the wizard failure. Only surrounding whitespace is tolerated in the message. Reload-mode restoration, the one-shot managed restart, health verification, and provenance checks are unchanged and still fail closed.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@
9292
<Border Width="8" Height="8" CornerRadius="4" VerticalAlignment="Center" Background="{ThemeResource SetupInactiveDotBrush}" />
9393
</StackPanel>
9494
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Spacing="8">
95-
<Button x:Name="WizardBackButton" Content="Back"
96-
MinWidth="100"
97-
Click="WizardBack_Click" />
9895
<DropDownButton x:Name="MoreOptionsButton"
9996
Content="More options"
10097
MinWidth="100"

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public sealed partial class WizardPage : Page
3535
private int _totalProgressPolls;
3636
private readonly Dictionary<string, int> _stepVisits = new(StringComparer.OrdinalIgnoreCase);
3737
private readonly List<WizardOptionValue> _options = [];
38-
private readonly Stack<JsonElement> _stepHistory = new();
3938
private volatile bool _expectedTerminalRestart;
4039
// "More ▾" overflow toggle lives as a sibling of SelectOptions, so track it to remove between steps.
4140
private Button? _moreOptionsButton;
@@ -378,16 +377,13 @@ private async Task ApplyPayloadAsync(JsonElement payload)
378377
}
379378

380379
ResetInputs();
381-
// Push current payload so Back can re-render this step
382-
_stepHistory.Push(payload);
383380
TitleText.Text = string.IsNullOrWhiteSpace(title) ? DisplayTitleFor(_stepType) : title;
384381
RenderMessage(message);
385382
StepCard.MinHeight = _stepType == "note" && string.IsNullOrWhiteSpace(message) ? 140 : 260;
386383
ErrorText.Visibility = Visibility.Collapsed;
387384
BusyRing.Visibility = Visibility.Collapsed;
388385
BusyRing.IsActive = false;
389386
ShowRecoveryActions();
390-
WizardBackButton.Visibility = Visibility.Visible;
391387
StatusText.Text = "A few quick questions to connect your agent";
392388
PrimaryButton.IsEnabled = !WizardSelection.RequiresAnswer(_stepType);
393389
SecondaryButton.IsEnabled = true;
@@ -443,7 +439,6 @@ private void RenderProgressStep(string title, string message)
443439
PrimaryButton.Content = "Continue";
444440
SecondaryButton.IsEnabled = false;
445441
SecondaryButton.Visibility = Visibility.Collapsed;
446-
WizardBackButton.Visibility = Visibility.Collapsed;
447442
ShowRecoveryActions();
448443
}
449444

@@ -465,7 +460,8 @@ private bool BuildOptions(JsonElement step, JsonElement initial)
465460
{
466461
SelectOptions.Visibility = Visibility.Visible;
467462

468-
// Reorder: skip options first, then non-more options, filter out "more" and "back" options
463+
// The Gateway contract has no rewind operation. Do not expose back options
464+
// as local navigation because that would desynchronize the active session.
469465
var skipOptions = _options.Where(IsSkipOption).ToList();
470466
var moreOptions = _options.Where(IsMoreOption).ToList();
471467
var normalOptions = _options.Where(o => !IsSkipOption(o) && !IsMoreOption(o) && !IsBackOption(o)).ToList();
@@ -754,9 +750,6 @@ private async Task ExpandMoreOptionsAsync(string moreValue, List<WizardOptionVal
754750
// Select first item by default
755751
if (SelectOptions.Items.Count > 0)
756752
SelectOptions.SelectedIndex = 0;
757-
758-
// Push this expanded payload to step history so Back works
759-
_stepHistory.Push(payload);
760753
}
761754
}
762755
catch (Exception ex)
@@ -766,21 +759,6 @@ private async Task ExpandMoreOptionsAsync(string moreValue, List<WizardOptionVal
766759
}
767760
}
768761

769-
private void WizardBack_Click(object sender, RoutedEventArgs e)
770-
{
771-
// Pop the current step (that's showing now), then re-render the previous one
772-
if (_stepHistory.Count > 1)
773-
{
774-
_stepHistory.Pop(); // discard current
775-
var previousPayload = _stepHistory.Pop(); // will be re-pushed by ApplyPayloadAsync
776-
_ = ApplyPayloadAsync(previousPayload);
777-
}
778-
else
779-
{
780-
SetupWindow.Active?.NavigateToWelcome(back: true);
781-
}
782-
}
783-
784762
private void StartOver_Click(object sender, RoutedEventArgs e) =>
785763
AsyncEventHandlerGuard.Run(
786764
StartOverAsync,
@@ -790,7 +768,6 @@ private void StartOver_Click(object sender, RoutedEventArgs e) =>
790768
private async Task StartOverAsync()
791769
{
792770
AdvanceOperationGeneration();
793-
_stepHistory.Clear();
794771
HideRecoveryActions();
795772
SetBusy("Starting over...");
796773
await CancelCurrentSessionAsync();

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,22 @@ public void WizardResetInputs_RemovesOverflowMoreButton()
14191419
Assert.Contains("_moreOptionsButton = null", reset);
14201420
}
14211421

1422+
[Fact]
1423+
public void WizardBack_IsUnavailableWithoutAuthoritativeGatewayRewind()
1424+
{
1425+
var root = TestRepositoryPaths.GetRepositoryRoot();
1426+
var source = File.ReadAllText(Path.Combine(root, "src", "OpenClaw.SetupEngine.UI", "Pages", "WizardPage.xaml.cs"));
1427+
var xaml = File.ReadAllText(Path.Combine(root, "src", "OpenClaw.SetupEngine.UI", "Pages", "WizardPage.xaml"));
1428+
1429+
Assert.DoesNotContain("WizardBackButton", xaml);
1430+
Assert.DoesNotContain("WizardBack_Click", source);
1431+
Assert.DoesNotContain("_stepHistory", source);
1432+
Assert.DoesNotContain("ApplyPayloadAsync(previousPayload)", source);
1433+
Assert.Contains("MoreOptionsButton", xaml);
1434+
Assert.Contains("StartOver_Click", xaml);
1435+
Assert.Contains("SkipWizard_Click", xaml);
1436+
}
1437+
14221438
[Fact]
14231439
public void WizardCompletion_AppliesWindowsNodeContextBeforeSummary()
14241440
{

0 commit comments

Comments
 (0)