Skip to content

Commit e228f4b

Browse files
shanselmanCopilot
andcommitted
Clear stale SSH fields for setup-code flow
Co-authored-by: Copilot <[email protected]>
1 parent 445076b commit e228f4b

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎src/OpenClaw.Tray.WinUI/Pages/ConnectionPage.xaml.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,7 @@ private void OnEnterAddGateway(object sender, RoutedEventArgs e)
16041604
{
16051605
_editingGatewayId = null;
16061606
_userIntent = UserIntent.AddingGateway;
1607+
ClearAddGatewaySshFields();
16071608
// Direct is default — make sure the selector is on Direct.
16081609
// Pre-fill the most common local gateway URL.
16091610
DirectUrlBox.Text = "ws://127.0.0.1:18789";
@@ -1619,6 +1620,7 @@ private void OnEnterAddGatewayDirect(object sender, RoutedEventArgs e)
16191620
{
16201621
_editingGatewayId = null;
16211622
_userIntent = UserIntent.AddingGateway;
1623+
ClearAddGatewaySshFields();
16221624
ShowAddPane("direct");
16231625
AddDirectItem.IsSelected = true;
16241626
RefreshFromSnapshot(_lastSnapshot);
@@ -1628,6 +1630,7 @@ private void OnEnterAddGatewaySetupCode(object sender, RoutedEventArgs e)
16281630
{
16291631
_editingGatewayId = null;
16301632
_userIntent = UserIntent.AddingGateway;
1633+
ClearAddGatewaySshFields();
16311634
ShowAddPane("setup");
16321635
AddSetupCodeItem.IsSelected = true;
16331636
RefreshFromSnapshot(_lastSnapshot);
@@ -1648,6 +1651,7 @@ private void OnAddBack(object sender, RoutedEventArgs e)
16481651
AddResultText.Text = "";
16491652
AddSetupCodeBox.Text = "";
16501653
AddSetupCodePreviewPanel.Visibility = Visibility.Collapsed;
1654+
ClearAddGatewaySshFields();
16511655
AddScanStatusText.Text = LocalizationHelper.GetString("ConnectionPage_PressScan");
16521656
AddScanProgressBar.Visibility = Visibility.Collapsed;
16531657
AddScanResultsPanel.Children.Clear();
@@ -1681,6 +1685,16 @@ private void ShowAddPane(string tag)
16811685
UpdateRemoteSetupAdvice();
16821686
}
16831687

1688+
private void ClearAddGatewaySshFields()
1689+
{
1690+
AddSshExpander.IsExpanded = false;
1691+
AddSshUserBox.Text = "";
1692+
AddSshHostBox.Text = "";
1693+
AddSshServerPortBox.Text = "";
1694+
AddSshRemotePortBox.Text = "";
1695+
AddSshLocalPortBox.Text = "";
1696+
}
1697+
16841698
private void OnRemoteHelpClick(object sender, RoutedEventArgs e)
16851699
{
16861700
AddRemoteHelpTip.IsOpen = !AddRemoteHelpTip.IsOpen;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ public void LocalNodeTrustPairListUpdate_RefreshesVisibleNodeList()
5555
Assert.Contains("Node list refresh failed after local node trust request", managerSource);
5656
}
5757

58+
[Fact]
59+
public void SetupCodeEntry_ClearsStaleSshTunnelFields()
60+
{
61+
var pageSource = ReadSource("src", "OpenClaw.Tray.WinUI", "Pages", "ConnectionPage.xaml.cs");
62+
63+
Assert.Contains("private void ClearAddGatewaySshFields()", pageSource);
64+
Assert.Contains("ClearAddGatewaySshFields();\r\n ShowAddPane(\"setup\");", pageSource);
65+
Assert.Contains("AddSshExpander.IsExpanded = false;", pageSource);
66+
Assert.Contains("AddSshUserBox.Text = \"\";", pageSource);
67+
Assert.Contains("AddSshHostBox.Text = \"\";", pageSource);
68+
}
69+
5870
private static string ReadSource(params string[] relativePathParts)
5971
{
6072
var root = TestRepositoryPaths.GetRepositoryRoot();

0 commit comments

Comments
 (0)