Skip to content

Commit 11f239f

Browse files
committed
fix(tray): align browser.proxy missing-token UX across live session surfaces
Use manager NodeState for remediation, and share topology-aware remote/SSH endpoint guidance across Connection pill tooltips, Command Center, and app.connection diagnostics so token-only copy does not overpromise.
1 parent b210d8d commit 11f239f

13 files changed

Lines changed: 687 additions & 90 deletions

‎docs/WINDOWS_NODE_TESTING.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ Local MCP clients also see MCP-only `app.*` commands such as `app.navigate`, `ap
146146

147147
### Browser control stays enabled but never declares `browser`
148148
- Setup-code / QR pairing can connect with a device token and leave `GatewayRecord.SharedGatewayToken` empty. Browser control will not declare `browser` / `browser.proxy` until a shared gateway token is saved for that gateway.
149-
- Expect Connection capability pills to say **Needs gateway shared token** (not "Enabled, not active yet"), Command Center to warn, and tray logs to include `browser capability not declared: active gateway has no shared gateway token`.
149+
- Expect Connection capability pills to say **Needs gateway shared token** (not "Enabled, not active yet") only while the node WebSocket session is live and the shared token is missing. Disconnected or attached-but-disconnected states should ask for reconnect, not a token paste. The pill keeps that short label; its tooltip matches Command Center remediation detail.
150+
- Command Center, Connection pill tooltips, and `app.connection.status` / `app.connection.gateways` use the same live-session rule for the shared-token caveat. For a remote (non-loopback) gateway without an explicit `BrowserControlPort` or SSH browser-proxy forward — including SSH tunnels whose effective URL is `127.0.0.1` — that caveat also mentions the endpoint/forward requirement; the shared token alone is not enough for usable remote browser.proxy.
150151
- Enter the gateway shared token in Settings, save, and reconnect node mode. Bootstrap tokens are not the shared gateway token.
151152

152153
### `browser.proxy` reports no browser-control host

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,16 @@ private void WireAppCapabilityHandlers()
256256
};
257257

258258
connection.GatewaysHandler = () =>
259-
Task.FromResult<object?>(ConnectionDiagnosticsProjection.BuildGateways(
259+
{
260+
var nodeSessionLive = BrowserProxyActivation.IsNodeSessionLive(
261+
_connectionManager?.CurrentSnapshot.NodeState
262+
?? OpenClaw.Connection.RoleConnectionState.Idle);
263+
return Task.FromResult<object?>(ConnectionDiagnosticsProjection.BuildGateways(
260264
_gatewayRegistry?.GetAll() ?? [],
261265
_gatewayRegistry?.ActiveGatewayId,
262-
nodeBrowserProxyEnabled: _settings?.NodeBrowserProxyEnabled != false));
266+
nodeBrowserProxyEnabled: _settings?.NodeBrowserProxyEnabled != false,
267+
nodeSessionLive: nodeSessionLive));
268+
};
263269

264270
connection.ApplySetupCodeHandler = async setupCode =>
265271
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,8 @@ private AppStateSnapshot CaptureSnapshot()
38453845
EffectiveBrowserControlPort = activeGateway?.BrowserControlPort,
38463846
HasActiveGatewayRecord = activeGateway != null,
38473847
ActiveGatewayHasSharedToken = !string.IsNullOrWhiteSpace(activeGateway?.SharedGatewayToken),
3848+
NodeConnectionState = _connectionManager?.CurrentSnapshot.NodeState
3849+
?? OpenClaw.Connection.RoleConnectionState.Idle,
38483850
ActiveGatewaySshTunnel = activeGateway?.SshTunnel
38493851
};
38503852
}

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

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -930,17 +930,27 @@ or NodeCardState.OnNodeRateLimited
930930

931931
if (showSurfaces && settings is not null)
932932
{
933+
var activeGateway = _gatewayRegistry?.GetActive();
933934
var hasSharedGatewayToken = !string.IsNullOrWhiteSpace(
934-
_gatewayRegistry?.GetActive()?.SharedGatewayToken);
935-
// Same attach signal NodeService uses for RegistrationBlock.
936-
var hasGatewayClient = CurrentApp.ActiveNodeService?.HasAttachedGatewayClient == true;
935+
activeGateway?.SharedGatewayToken);
936+
// Same manager NodeState signal as app.connection.* / Command Center.
937+
var nodeSessionLive = BrowserProxyActivation.IsNodeSessionLive(
938+
_connectionManager?.CurrentSnapshot.NodeState
939+
?? OpenClaw.Connection.RoleConnectionState.Idle);
940+
// Match Command Center CaptureSnapshot: active record URL, else settings.
941+
var requiresRemoteBrowserEndpoint =
942+
BrowserProxyActivation.RequiresRemoteBrowserEndpoint(
943+
gatewayUrl: activeGateway?.Url ?? settings.GatewayUrl,
944+
browserControlPort: activeGateway?.BrowserControlPort,
945+
sshTunnel: activeGateway?.SshTunnel);
937946
var pillFp = BuildCapabilityPillFingerprint(
938947
plan.NodeCard,
939948
plan.NodeEffectiveCapabilities,
940949
plan.NodePendingDeclaredCapabilities,
941950
settings,
942951
hasSharedGatewayToken,
943-
hasGatewayClient);
952+
nodeSessionLive,
953+
requiresRemoteBrowserEndpoint);
944954
if (_capabilityPillsFingerprint != pillFp)
945955
{
946956
_capabilityPillsFingerprint = pillFp;
@@ -949,7 +959,8 @@ or NodeCardState.OnNodeRateLimited
949959
plan.NodePendingDeclaredCapabilities,
950960
settings,
951961
hasSharedGatewayToken,
952-
hasGatewayClient);
962+
nodeSessionLive,
963+
requiresRemoteBrowserEndpoint);
953964
}
954965

955966
NodeCapabilityPillsHost.Visibility =
@@ -1209,7 +1220,8 @@ private WrapPanel BuildCapabilityPills(
12091220
IReadOnlyList<string> pendingDeclared,
12101221
SettingsManager settings,
12111222
bool hasSharedGatewayToken,
1212-
bool hasGatewayClient)
1223+
bool nodeSessionLive,
1224+
bool requiresRemoteBrowserEndpoint)
12131225
{
12141226
var panel = new WrapPanel { HorizontalSpacing = 6, VerticalSpacing = 6 };
12151227
var effectiveSet = new HashSet<string>(
@@ -1240,7 +1252,7 @@ private WrapPanel BuildCapabilityPills(
12401252
effective: effectiveSet.Contains(name),
12411253
pendingDeclared: pendingSet.Contains(name),
12421254
hasSharedGatewayToken: hasSharedGatewayToken,
1243-
hasGatewayClient: hasGatewayClient)
1255+
nodeSessionLive: nodeSessionLive)
12441256
: effectiveSet.Contains(name)
12451257
? BrowserProxyActivation.CapabilityPillKind.Active
12461258
: (pendingSet.Contains(name) || enabled)
@@ -1253,7 +1265,17 @@ private WrapPanel BuildCapabilityPills(
12531265
BrowserProxyActivation.CapabilityPillKind.PendingApproval => CapabilityPillState.Pending,
12541266
_ => CapabilityPillState.Off,
12551267
};
1256-
panel.Children.Add(MakeCapabilityPill(LocalizationHelper.GetString(labelKey), glyph, state, isHighContrast));
1268+
var remoteForPill = name.Equals("browser", StringComparison.OrdinalIgnoreCase) &&
1269+
kind == BrowserProxyActivation.CapabilityPillKind.NeedsSharedToken
1270+
? requiresRemoteBrowserEndpoint
1271+
: false;
1272+
panel.Children.Add(MakeCapabilityPill(
1273+
LocalizationHelper.GetString(labelKey),
1274+
glyph,
1275+
state,
1276+
isHighContrast,
1277+
kind,
1278+
remoteForPill));
12571279
shown.Add(name);
12581280
}
12591281

@@ -1269,15 +1291,29 @@ private WrapPanel BuildCapabilityPills(
12691291
"system" => (LocalizationHelper.GetString("ConnectionPage_NodeCap_System"), FluentIconCatalog.System),
12701292
_ => (HumanizeNodeToken(name), FluentIconCatalog.System),
12711293
};
1272-
panel.Children.Add(MakeCapabilityPill(label, glyph, state, isHighContrast));
1294+
panel.Children.Add(MakeCapabilityPill(
1295+
label,
1296+
glyph,
1297+
state,
1298+
isHighContrast,
1299+
kind: state == CapabilityPillState.Active
1300+
? BrowserProxyActivation.CapabilityPillKind.Active
1301+
: BrowserProxyActivation.CapabilityPillKind.PendingApproval,
1302+
requiresRemoteBrowserEndpoint: false));
12731303
}
12741304

12751305
return panel;
12761306
}
12771307

12781308
private const double CapabilityPillFillOpacity = 0.14;
12791309

1280-
private Border MakeCapabilityPill(string label, string glyph, CapabilityPillState state, bool isHighContrast)
1310+
private Border MakeCapabilityPill(
1311+
string label,
1312+
string glyph,
1313+
CapabilityPillState state,
1314+
bool isHighContrast,
1315+
BrowserProxyActivation.CapabilityPillKind kind,
1316+
bool requiresRemoteBrowserEndpoint)
12811317
{
12821318
var (fillBrush, iconBrush, textBrush, stateKey, stateGlyph) = state switch
12831319
{
@@ -1337,14 +1373,18 @@ private Border MakeCapabilityPill(string label, string glyph, CapabilityPillStat
13371373
content.Children.Add(capabilityIcon);
13381374

13391375
var stateText = LocalizationHelper.GetString(stateKey);
1376+
var detailText = BrowserProxyActivation.ResolveCapabilityPillTooltip(
1377+
kind,
1378+
stateText,
1379+
requiresRemoteBrowserEndpoint);
13401380
var labelText = new TextBlock
13411381
{
13421382
Text = label,
13431383
FontSize = 12,
13441384
Foreground = textBrush,
13451385
VerticalAlignment = VerticalAlignment.Center,
13461386
};
1347-
AutomationProperties.SetName(labelText, $"{label}: {stateText}");
1387+
AutomationProperties.SetName(labelText, $"{label}: {detailText}");
13481388
content.Children.Add(labelText);
13491389

13501390
if (stateGlyph != null)
@@ -1368,7 +1408,7 @@ private Border MakeCapabilityPill(string label, string glyph, CapabilityPillStat
13681408
Background = fillBrush,
13691409
Child = content,
13701410
};
1371-
ToolTipService.SetToolTip(pill, stateText);
1411+
ToolTipService.SetToolTip(pill, detailText);
13721412
return pill;
13731413
}
13741414

@@ -1402,7 +1442,8 @@ private static string BuildCapabilityPillFingerprint(
14021442
IReadOnlyList<string> pendingDeclared,
14031443
SettingsManager settings,
14041444
bool hasSharedGatewayToken,
1405-
bool hasGatewayClient)
1445+
bool nodeSessionLive,
1446+
bool requiresRemoteBrowserEndpoint)
14061447
{
14071448
var eff = string.Join(
14081449
",",
@@ -1420,7 +1461,7 @@ private static string BuildCapabilityPillFingerprint(
14201461
settings.NodeLocationEnabled ? '1' : '0',
14211462
settings.NodeTtsEnabled ? '1' : '0',
14221463
settings.NodeSttEnabled ? '1' : '0');
1423-
return $"{state}|{eff}|{pend}|{toggles}|{(hasSharedGatewayToken ? '1' : '0')}|{(hasGatewayClient ? '1' : '0')}";
1464+
return $"{state}|{eff}|{pend}|{toggles}|{(hasSharedGatewayToken ? '1' : '0')}|{(nodeSessionLive ? '1' : '0')}|{(requiresRemoteBrowserEndpoint ? '1' : '0')}";
14241465
}
14251466

14261467
/// <summary>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ internal sealed record AppStateSnapshot
3939
public bool HasActiveGatewayRecord { get; init; }
4040
public bool ActiveGatewayHasSharedToken { get; init; }
4141

42+
/// <summary>
43+
/// Manager-owned node role state. Shared-token browser remediation uses
44+
/// <see cref="BrowserProxyActivation.IsNodeSessionLive"/> on this value so
45+
/// Command Center matches <c>app.connection.*</c> diagnostics.
46+
/// </summary>
47+
public OpenClaw.Connection.RoleConnectionState NodeConnectionState { get; init; }
48+
4249
/// <summary>SSH tunnel config from the active GatewayRecord. Null means this gateway is
4350
/// direct (no tunnel), NOT "unknown". Only meaningful when HasActiveGatewayRecord is true.</summary>
4451
public SshTunnelConfig? ActiveGatewaySshTunnel { get; init; }

0 commit comments

Comments
 (0)