Skip to content

Commit 977648c

Browse files
bkudiessCopilotCopilot
authored
Dedupe connection error bars into a single thin top banner (#865)
A connection/auth failure rendered two error bars: the global top-window InfoBar plus an in-page "Connection Error" InfoBar on the Connection page. The auth pipeline also published two global notifications for one failure, which forced the banner action to degrade to "Show more". Remove the in-page AuthErrorBar and consolidate to one top banner that: - carries the gateway/node error states the in-page bar covered - always routes the user to the Connection page via an "Open Connection" action (connection notifications are prioritized as the visible banner, preferring an actionable one over an action-less transient) - renders as a single thin line: bold headline + " - detail", with the action as a right-aligned hyperlink (Windows-aligned InfoBar) Other changes: - Stop publishing the duplicate connection:authentication-failed banner; the snapshot-driven connection:issue notification is the single source. - Re-home transient errors: WSL host-action failures use the inline card status (or a top notification when the card is hidden); connect/switch failures publish via ShowTransientConnectionError on the same banner id. - Remove now-dead resw strings (ConnectionPage_AuthGuidance*, ConnectionPage_ConnectFailed) across all five locales. Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 9ac8cfb commit 977648c

12 files changed

Lines changed: 218 additions & 255 deletions

File tree

‎src/OpenClaw.Tray.WinUI/App.xaml.cs‎

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ public IntPtr GetHubWindowHandle()
200200
private ToastService? _toastService;
201201
private AppNotificationService? _appNotificationService;
202202
internal AppNotificationService? AppNotifications => _appNotificationService;
203-
private string? _lastAuthFailureNotificationMessage;
204203
private string? _lastConnectionIssueNotificationKey;
205204
private readonly Dictionary<string, string> _reportedChannelIssueSignatures = new(StringComparer.OrdinalIgnoreCase);
206205
private string? _lastSandboxRiskNotificationKey;
@@ -2332,6 +2331,37 @@ private void ShowPairingRejectedAppNotification(string deviceId, string? detail)
23322331
id: BuildPairingRejectedNotificationId(deviceId));
23332332
}
23342333

2334+
/// <summary>
2335+
/// Publishes an immediate connection-error banner using the single
2336+
/// connection-issue notification identity. Used for transient, page-driven
2337+
/// failures (e.g. a manual gateway switch that throws) where the snapshot
2338+
/// may be briefly silent. Because it reuses the connection-issue id/dedupe
2339+
/// key it occupies the same banner slot — it cannot produce a second bar —
2340+
/// and the snapshot-driven path will replace or dismiss it on the next tick.
2341+
/// </summary>
2342+
internal void ShowTransientConnectionError(string message)
2343+
{
2344+
var body = string.IsNullOrWhiteSpace(message)
2345+
? LocalizationHelper.GetString("AppNotification_GatewayConnectionFailed_DefaultMessage")
2346+
: message;
2347+
2348+
// Keep the snapshot-driven publisher from immediately re-emitting a
2349+
// duplicate for the same underlying error.
2350+
_lastConnectionIssueNotificationKey = $"operator-error:{message}";
2351+
2352+
AppNotificationPublisher.Show(
2353+
_appNotificationService,
2354+
LocalizationHelper.GetString("AppNotification_GatewayConnectionFailed_Title"),
2355+
body,
2356+
"connection",
2357+
"lifecycle",
2358+
AppNotificationSeverity.Error,
2359+
ConnectionIssueNotificationDedupeKey,
2360+
"connection",
2361+
LocalizationHelper.GetString("AppNotification_ActionOpenConnection"),
2362+
id: ConnectionIssueNotificationId);
2363+
}
2364+
23352365
private void UpdateConnectionIssueNotification(GatewayConnectionSnapshot snapshot)
23362366
{
23372367
if (!TryBuildConnectionIssueNotification(snapshot, out var title, out var message, out var severity, out var category, out var key))
@@ -2375,9 +2405,12 @@ private static bool TryBuildConnectionIssueNotification(
23752405
if (snapshot.OverallState == OverallConnectionState.Error)
23762406
{
23772407
title = LocalizationHelper.GetString("AppNotification_GatewayConnectionFailed_Title");
2378-
message = snapshot.OperatorError ?? LocalizationHelper.GetString("AppNotification_GatewayConnectionFailed_DefaultMessage");
2408+
var rawError = snapshot.OperatorError;
2409+
message = string.IsNullOrWhiteSpace(rawError)
2410+
? LocalizationHelper.GetString("AppNotification_GatewayConnectionFailed_DefaultMessage")
2411+
: rawError;
23792412
severity = AppNotificationSeverity.Error;
2380-
key = $"operator-error:{message}";
2413+
key = $"operator-error:{rawError ?? "default"}";
23812414
return true;
23822415
}
23832416

@@ -2663,8 +2696,6 @@ private void OnGatewayConnectionStatusChanged(object? sender, ConnectionStatus s
26632696
if (status == ConnectionStatus.Connected && _appState != null)
26642697
{
26652698
_appState.AuthFailureMessage = null;
2666-
_lastAuthFailureNotificationMessage = null;
2667-
_appNotificationService?.Dismiss("connection:authentication-failed");
26682699
}
26692700

26702701
UpdateTrayIcon();
@@ -2714,27 +2745,18 @@ private void OnGatewayAuthenticationFailed(object? sender, string message)
27142745
{
27152746
UpdateTrayIcon();
27162747

2717-
// Store auth failure in AppState — HubWindow observes it via PropertyChanged
2748+
// Store auth failure in AppState — observed for tray tooltip / status.
27182749
if (_appState != null)
27192750
{
27202751
_appState.AuthFailureMessage = message;
27212752
}
27222753

2723-
if (!string.Equals(_lastAuthFailureNotificationMessage, message, StringComparison.Ordinal))
2724-
{
2725-
_lastAuthFailureNotificationMessage = message;
2726-
AppNotificationPublisher.Show(
2727-
_appNotificationService,
2728-
LocalizationHelper.GetString("AppNotification_GatewayAuthenticationFailed_Title"),
2729-
message,
2730-
"connection",
2731-
"authentication",
2732-
AppNotificationSeverity.Error,
2733-
"connection:authentication-failed",
2734-
"connection",
2735-
LocalizationHelper.GetString("AppNotification_ActionOpenConnection"),
2736-
id: "connection:authentication-failed");
2737-
}
2754+
// The user-facing banner is published by the single connection-issue
2755+
// notification (UpdateConnectionIssueNotification), driven off the
2756+
// snapshot's Error state + OperatorError (same string surfaced here).
2757+
// Publishing a second "authentication failed" banner here produced a
2758+
// duplicate top bar and forced the action button to degrade to
2759+
// "Show more", so it is intentionally not raised from this handler.
27382760
}
27392761

27402762
private void OnGatewaySessionCommandCompleted(object? sender, SessionCommandResult result)

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@
5959
PINNED MODIFIERS — render across every mode
6060
═════════════════════════════════════════════════════════ -->
6161

62-
<!-- Auth error (legacy, kept) -->
63-
<InfoBar x:Name="AuthErrorBar"
64-
x:Uid="AuthErrorBar"
65-
Title="Connection Error"
66-
Severity="Error" IsOpen="False" IsClosable="True"/>
67-
6862
<!-- Pending approvals (others waiting on the user's decision) -->
6963
<Border x:Name="PendingApprovalsBanner"
7064
Visibility="Collapsed"

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

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,6 @@ private void RefreshFromSnapshot(GatewayConnectionSnapshot snapshot)
299299
// background highlight reflects the live snapshot. Cheap — list is
300300
// typically < 10 entries and only re-runs on real state transitions.
301301
LoadSavedGateways();
302-
303-
// Bridge auth error (lives outside the plan as a transient modifier)
304-
var authError = CurrentApp.AppState?.AuthFailureMessage;
305-
if (!string.IsNullOrEmpty(authError))
306-
{
307-
AuthErrorBar.Message = GetAuthErrorGuidance(authError!);
308-
AuthErrorBar.IsOpen = true;
309-
}
310-
else
311-
{
312-
AuthErrorBar.IsOpen = false;
313-
}
314302
}
315303

316304
private void ApplyPlan(ConnectionPagePlan plan)
@@ -2001,10 +1989,23 @@ private void ShowGatewayHostFailure(string title, string message, bool preferInl
20011989
return;
20021990
}
20031991

2004-
AuthErrorBar.Title = title;
2005-
AuthErrorBar.Message = message;
2006-
AuthErrorBar.Severity = InfoBarSeverity.Error;
2007-
AuthErrorBar.IsOpen = true;
1992+
// No inline WSL-controls surface is available here (e.g. launching a
1993+
// terminal for a non-active saved gateway, where that card isn't shown).
1994+
// The in-page Connection Error bar was removed, so surface the failure as
1995+
// a transient top-bar notification rather than dropping it silently. This
1996+
// is a one-off action failure, not the persistent connection-issue banner,
1997+
// so it carries no "Open Connection" action.
1998+
AppNotificationPublisher.Show(
1999+
CurrentApp.AppNotifications,
2000+
title,
2001+
message,
2002+
"connection",
2003+
"gateway-host",
2004+
AppNotificationSeverity.Error,
2005+
$"gateway-host-action:{title}",
2006+
actionRoute: string.Empty,
2007+
actionLabel: string.Empty,
2008+
id: $"gateway-host-action:{title}");
20082009
}
20092010

20102011
private static string UppercaseFirst(string value)
@@ -2177,18 +2178,16 @@ private async Task OnConnectSavedGatewayAsync(object sender)
21772178
catch (Exception ex)
21782179
{
21792180
// Strip status will read the snapshot's terminal state next tick;
2180-
// surface the immediate error in the auth-error bar so the user
2181-
// gets feedback even if the snapshot is briefly silent.
2181+
// surface the immediate error in the single top connection banner so
2182+
// the user gets feedback (and an "Open Connection" action) even if
2183+
// the snapshot is briefly silent.
21822184
try
21832185
{
2184-
AuthErrorBar.Title = LocalizationHelper.GetString("ConnectionPage_ConnectFailed");
2185-
AuthErrorBar.Message = ex.Message;
2186-
AuthErrorBar.Severity = Microsoft.UI.Xaml.Controls.InfoBarSeverity.Error;
2187-
AuthErrorBar.IsOpen = true;
2186+
CurrentApp.ShowTransientConnectionError(ex.Message);
21882187
}
21892188
catch (Exception uiEx)
21902189
{
2191-
Logger.Warn($"ConnectionPage: Failed to surface connect failure in auth error bar: {uiEx.Message}");
2190+
Logger.Warn($"ConnectionPage: Failed to surface connect failure in connection banner: {uiEx.Message}");
21922191
}
21932192
}
21942193
finally
@@ -3540,21 +3539,6 @@ await RunPairingDecisionAsync(approveBtn, rejectBtn, isApprove: false, async cli
35403539
return card;
35413540
}
35423541

3543-
// ─── Auth error guidance (preserved) ─────────────────────────────
3544-
3545-
private static string GetAuthErrorGuidance(string error)
3546-
{
3547-
if (error.Contains("token", StringComparison.OrdinalIgnoreCase))
3548-
return string.Format(LocalizationHelper.GetString("ConnectionPage_AuthGuidanceToken"), error);
3549-
if (error.Contains("pairing", StringComparison.OrdinalIgnoreCase))
3550-
return string.Format(LocalizationHelper.GetString("ConnectionPage_AuthGuidancePairing"), error);
3551-
if (error.Contains("password", StringComparison.OrdinalIgnoreCase))
3552-
return string.Format(LocalizationHelper.GetString("ConnectionPage_AuthGuidancePassword"), error);
3553-
if (error.Contains("signature", StringComparison.OrdinalIgnoreCase))
3554-
return string.Format(LocalizationHelper.GetString("ConnectionPage_AuthGuidanceSignature"), error);
3555-
return string.Format(LocalizationHelper.GetString("ConnectionPage_AuthGuidanceDefault"), error);
3556-
}
3557-
35583542
private static string SanitizeUrl(string url)
35593543
{
35603544
try

‎src/OpenClaw.Tray.WinUI/Services/AppNotificationService.cs‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,48 @@ public static bool TryGetChatSessionKey(string? route, out string? sessionKey)
7070

7171
internal sealed class AppNotificationBannerState
7272
{
73+
private const string ConnectionSource = "connection";
7374
private readonly HashSet<string> _hiddenNotificationIds = new(StringComparer.Ordinal);
7475

7576
public AppNotification? SelectVisibleNotification(AppNotificationSnapshot snapshot, bool revealHiddenIfNeeded = false)
7677
{
7778
PruneRemovedNotifications(snapshot);
78-
var visible = snapshot.ActiveNotifications.FirstOrDefault(notification =>
79-
!_hiddenNotificationIds.Contains(notification.Id));
79+
80+
var visibleCandidates = snapshot.ActiveNotifications
81+
.Where(notification => !_hiddenNotificationIds.Contains(notification.Id))
82+
.ToList();
83+
84+
// Connection issues are the most actionable banner (they route the user
85+
// to the Connection page), so surface them ahead of any earlier,
86+
// unrelated notification that happens to be current. Without this, a
87+
// connection failure arriving while another notification is showing
88+
// would be queued behind it and the user couldn't reach Connection.
89+
// Among connection-source notifications, prefer one that actually has an
90+
// action: an action-less connection notification (e.g. a transient
91+
// gateway-host failure) must not mask a real connection error and
92+
// degrade the banner to "Show more".
93+
var visible = visibleCandidates.FirstOrDefault(IsActionableConnectionPriority)
94+
?? visibleCandidates.FirstOrDefault(IsConnectionPriority)
95+
?? visibleCandidates.FirstOrDefault();
8096
if (visible is not null || !revealHiddenIfNeeded)
8197
return visible;
8298

83-
var fallback = snapshot.ActiveNotifications.FirstOrDefault();
99+
var fallback = snapshot.ActiveNotifications.FirstOrDefault(IsActionableConnectionPriority)
100+
?? snapshot.ActiveNotifications.FirstOrDefault(IsConnectionPriority)
101+
?? snapshot.ActiveNotifications.FirstOrDefault();
84102
if (fallback is not null)
85103
_hiddenNotificationIds.Remove(fallback.Id);
86104
return fallback;
87105
}
88106

107+
private static bool IsConnectionPriority(AppNotification notification) =>
108+
string.Equals(notification.Source, ConnectionSource, StringComparison.OrdinalIgnoreCase);
109+
110+
private static bool IsActionableConnectionPriority(AppNotification notification) =>
111+
IsConnectionPriority(notification)
112+
&& !string.IsNullOrWhiteSpace(notification.ActionLabel)
113+
&& !string.IsNullOrWhiteSpace(notification.ActionRoute);
114+
89115
public void HideActiveNotifications(AppNotificationSnapshot snapshot)
90116
{
91117
PruneRemovedNotifications(snapshot);

‎src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,9 +1815,6 @@ On your gateway host (Mac/Linux), run:
18151815
<data name="ConnectionPage_TextBlock_11.Text" xml:space="preserve">
18161816
<value>Gateway endpoint used by both the operator client and node service.</value>
18171817
</data>
1818-
<data name="AuthErrorBar.Title" xml:space="preserve">
1819-
<value>Connection Error</value>
1820-
</data>
18211818
<data name="StatusText.Text" xml:space="preserve">
18221819
<value>Disconnected</value>
18231820
</data>
@@ -3276,9 +3273,6 @@ On your gateway host (Mac/Linux), run:
32763273
<data name="AppNotification_ActionOpenCron" xml:space="preserve">
32773274
<value>Open Cron</value>
32783275
</data>
3279-
<data name="AppNotification_GatewayAuthenticationFailed_Title" xml:space="preserve">
3280-
<value>Gateway authentication failed</value>
3281-
</data>
32823276
<data name="AppNotification_GatewayConnectionFailed_Title" xml:space="preserve">
32833277
<value>Gateway connection failed</value>
32843278
</data>
@@ -5599,9 +5593,6 @@ Make sure the gateway is running.</value>
55995593
<data name="ConnectionPage_CancelAction" xml:space="preserve">
56005594
<value>Cancel</value>
56015595
</data>
5602-
<data name="ConnectionPage_ConnectFailed" xml:space="preserve">
5603-
<value>Connect failed</value>
5604-
</data>
56055596
<data name="ConnectionPage_GatewayConnectionFailed" xml:space="preserve">
56065597
<value>Gateway connection failed.</value>
56075598
</data>
@@ -5632,31 +5623,6 @@ Make sure the gateway is running.</value>
56325623
<data name="ConnectionPage_DenyPairingRequest" xml:space="preserve">
56335624
<value>Deny pairing request</value>
56345625
</data>
5635-
<data name="ConnectionPage_AuthGuidanceToken" xml:space="preserve">
5636-
<value>{0}
5637-
5638-
Paste a new setup code from the Add Gateway flow.</value>
5639-
</data>
5640-
<data name="ConnectionPage_AuthGuidancePairing" xml:space="preserve">
5641-
<value>{0}
5642-
5643-
Your device needs approval on the gateway host.</value>
5644-
</data>
5645-
<data name="ConnectionPage_AuthGuidancePassword" xml:space="preserve">
5646-
<value>{0}
5647-
5648-
This gateway requires password authentication.</value>
5649-
</data>
5650-
<data name="ConnectionPage_AuthGuidanceSignature" xml:space="preserve">
5651-
<value>{0}
5652-
5653-
The gateway may require a different auth protocol version.</value>
5654-
</data>
5655-
<data name="ConnectionPage_AuthGuidanceDefault" xml:space="preserve">
5656-
<value>{0}
5657-
5658-
Check your connection settings and try again.</value>
5659-
</data>
56605626
<data name="ConnectionPage_AuthModeBootstrap" xml:space="preserve">
56615627
<value>bootstrap</value>
56625628
</data>

‎src/OpenClaw.Tray.WinUI/Strings/fr-fr/Resources.resw‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,9 +1767,6 @@ Sur votre hôte passerelle (Mac/Linux), exécutez :
17671767
<data name="ConnectionPage_TextBlock_11.Text" xml:space="preserve">
17681768
<value>Point de terminaison de passerelle utilisé par le client opérateur et le service de nœud.</value>
17691769
</data>
1770-
<data name="AuthErrorBar.Title" xml:space="preserve">
1771-
<value>Erreur de connexion</value>
1772-
</data>
17731770
<data name="StatusText.Text" xml:space="preserve">
17741771
<value>Déconnecté</value>
17751772
</data>
@@ -3204,9 +3201,6 @@ Sur votre hôte passerelle (Mac/Linux), exécutez :
32043201
<data name="AppNotification_ActionOpenCron" xml:space="preserve">
32053202
<value>Ouvrir Cron</value>
32063203
</data>
3207-
<data name="AppNotification_GatewayAuthenticationFailed_Title" xml:space="preserve">
3208-
<value>Échec de l'authentification de la passerelle</value>
3209-
</data>
32103204
<data name="AppNotification_GatewayConnectionFailed_Title" xml:space="preserve">
32113205
<value>Échec de la connexion à la passerelle</value>
32123206
</data>
@@ -5551,9 +5545,6 @@ Assurez-vous que la passerelle est en cours d'exécution.</value>
55515545
<data name="ConnectionPage_CancelAction" xml:space="preserve">
55525546
<value>Annuler</value>
55535547
</data>
5554-
<data name="ConnectionPage_ConnectFailed" xml:space="preserve">
5555-
<value>Échec de la connexion</value>
5556-
</data>
55575548
<data name="ConnectionPage_GatewayConnectionFailed" xml:space="preserve">
55585549
<value>Échec de la connexion à la passerelle.</value>
55595550
</data>
@@ -5584,31 +5575,6 @@ Assurez-vous que la passerelle est en cours d'exécution.</value>
55845575
<data name="ConnectionPage_DenyPairingRequest" xml:space="preserve">
55855576
<value>Refuser la demande d’appairage</value>
55865577
</data>
5587-
<data name="ConnectionPage_AuthGuidanceToken" xml:space="preserve">
5588-
<value>{0}
5589-
5590-
Collez un nouveau code de configuration depuis le flux Ajouter une passerelle.</value>
5591-
</data>
5592-
<data name="ConnectionPage_AuthGuidancePairing" xml:space="preserve">
5593-
<value>{0}
5594-
5595-
Votre appareil nécessite une approbation sur l’hôte de la passerelle.</value>
5596-
</data>
5597-
<data name="ConnectionPage_AuthGuidancePassword" xml:space="preserve">
5598-
<value>{0}
5599-
5600-
Cette passerelle nécessite une authentification par mot de passe.</value>
5601-
</data>
5602-
<data name="ConnectionPage_AuthGuidanceSignature" xml:space="preserve">
5603-
<value>{0}
5604-
5605-
La passerelle pourrait nécessiter une version différente du protocole d’authentification.</value>
5606-
</data>
5607-
<data name="ConnectionPage_AuthGuidanceDefault" xml:space="preserve">
5608-
<value>{0}
5609-
5610-
Vérifiez vos paramètres de connexion et réessayez.</value>
5611-
</data>
56125578
<data name="ConnectionPage_AuthModeBootstrap" xml:space="preserve">
56135579
<value>amorçage</value>
56145580
</data>

0 commit comments

Comments
 (0)