Skip to content

Rebuild Connection page (replaces Home) - #418

Merged
shanselman merged 7 commits into
openclaw:masterfrom
bkudiess:feat/home-page-recap
May 16, 2026
Merged

shanselman merged 7 commits into
openclaw:masterfrom
bkudiess:feat/home-page-recap

Conversation

@bkudiess

@bkudiess bkudiess commented May 16, 2026 •

Copy link
Copy Markdown
Collaborator

Rebuild of the Connection page from scratch — Home is gone, Connection is the new landing surface and absorbs the gateway/operator/node status that used to live across Home banners and Permissions.

what's in it

  • 4 modes from a pure projection: Welcome / Cockpit / Recovery / AddGateway.
  • Status strip with merged gateway+operator headline (Connected, Connecting…, Can't reach gateway, etc.) + glance chips (topology, hostname, clients, channels, ``) + dashboard launcher when connected.
  • Operator + Node cards with Permissions-style icon + state-mapped status glyphs. Node card tints red when Node mode is off.
  • Saved gateways always visible. Active row shows inline OK Connected; inactive rows get [Connect]; never an unsafe Disconnect on the wrong record.
  • Discovery moved into the Gateways header; per-row [Add] pre-fills the Direct pane.
  • SSH tunnel is per-gateway now (legacy global expander gone, UseSshTunnel still honored for back-compat).

hard constraint

UI/UX only — no changes to OpenClaw.Connection, GatewayRegistry, SettingsManager save logic, pairing/auth, or token storage. The regression test pinning ConnectAndWaitForDirectConnectOutcomeAsync / Task.Delay(15s) / RollbackDirectConnect still passes.

design system

  • All Segoe Fluent glyphs through FluentIconCatalog (15 new constants).
  • CDR-0001 applied: System → PC1 (\uE839).
  • Status vocabulary aligned with naming.md.

validation

./build.ps1 green · Tray tests 990 / 990 · Shared tests 1620 / 1620 (28 pre-existing skipped) · Manual smoke OK.

image image

bkudiess and others added 6 commits May 15, 2026 21:27
Replace the WIP HomePage with a single mode-aware Connection page that
serves as the app's landing surface and absorbs the gateway/operator/node
status that used to live across Home + Permissions banners.

Page modes
- Welcome: no gateways saved -> add tiles + inline scan + discovered list
- Cockpit: at least one saved gateway -> status strip + Operator + Node + saved list
- Recovery: error -> typed body (Auth / Pairing / Tunnel / Server / Network)
- AddGateway: focused form with Direct or Setup-code panes (SSH per-gateway)

Status strip
- Merged gateway+operator headline ("Gateway connected", "Connecting...",
  "Can't reach gateway", "Authentication failed", "Awaiting approval")
- Glance chips: topology, hostname, clients,
- Active-sessions caption
- Dashboard launcher (top-right) when connected

Operator + Node cards
- Permissions-style icon + status row with state-mapped FontIcon glyphs
  (CheckMark / Warning / Lock / ErrorBadge / Sync / RemoveFrom) instead
  of identical green dots
- Canonical capability list per design naming.md

Saved gateways
- Always-visible list with neutral row chrome
- Active row shows inline "OK Connected" (checkmark glyph + text), no
  green tint on the row itself
- Inactive rows get [Connect] (or [Connect] if active but currently
  disconnected); never an unsafe Disconnect on an inactive row
- Scan button moved into Gateways header, pre-fills Direct on add

Discovery
- DiscoveredGateways sub-section under saved list and on Welcome
- Per-row [Add] pre-fills the Direct pane in AddGateway mode

Constraint preserved
- No changes to OpenClaw.Connection.* / GatewayRegistry / SettingsManager
  save logic / pairing flow / token storage. UI/UX only.

Design system
- All Segoe Fluent glyphs routed through FluentIconCatalog (no XAML/code
  literals)
- CDR-0001 applied: System icon -> PC1 (\uE839)
- Status vocabulary lowered to canonical "Disconnected" / "Reconnecting..."
- Removed AccentButtonStyle from Save & connect (avoids picking up the
  user's red Windows accent on the primary action)

HubWindow
- Aliased home/general -> connection in NavigateTo + TagToPageType
- Added OnGlanceDataChanged() pump for sessions/channels/usage cost
- Subscribes to ActivityStreamService for live cockpit updates

Validation
- ./build.ps1 (all projects)
- Tray tests: 990 passed / 0 failed
- Shared tests: 1620 passed / 28 skipped
- Manual launch verified, no XamlParseException in tray log

Co-authored-by: Copilot <[email protected]>
Adversarial code review (Opus + Codex) surfaced 11 issues across the
ConnectionPage rebuild; all addressed here. Plus two follow-ups for
the node-toggle flicker the user reported.

## Review fixes

1. Token-clear safety + rollback restore (Critical, both models)
   - DoDirectConnectFromAddFormAsync only clears device tokens when the
     user supplied a new shared token. Renames or SSH-only edits no
     longer wipe paired credentials.
   - Snapshot the identity JSON before clearing; RollbackDirectConnect
     restores it on failure so a bad URL/token cannot permanently
     destroy a previously paired device.

2. Delete duplicate UpdatePairingRequests in HubWindow (lines 684+686
   were identical, causing every node pairing card to render twice).

3. Remove Error from ConnectionToggle.IsOn set so the toggle reads OFF
   in terminal failure states instead of lying.

4. Move literal "\uEC05" channel-tower glyph behind a new Channels
   constant in FluentIconCatalog.

5. Add 14 missing constants + Channels to FluentIconCatalogTests
   ExpectedConstants so the test guards the full catalog.

6. Pairing approve/deny use req.RequestId ?? req.DeviceId/NodeId
   parity with UpdatePairingGuidance, and disable the buttons when
   neither id is present so legacy gateways do not silently no-op.

7. OnSavedRowRemove calls _connectionManager.DisconnectAsync() first
   when removing the active gateway. Prevents the manager from
   chasing a record that no longer exists.

8. Drop the redundant LoadSavedGateways() in Initialize — the
   following RefreshFromSnapshot already calls it with the correct
   snapshot. Eliminates the disconnect → connect flicker on app open.

9. Track _editingGatewayId via OnSavedRowEdit/OnEditTunnelSettings,
   cleared by all "fresh add" entry points. URL-change-while-editing
   now updates the original record instead of orphaning it as a
   duplicate.

10. OnGlanceDataChanged derives chip visibility from
    _lastSnapshot.OverallState instead of ConnectionToggle.IsOn so
    chips stay in sync with the authoritative state.

11. OnScanGatewaysClicked sets _scanInProgress synchronously before
    awaiting RunScanForGatewaysAsync to close a narrow double-click
    race window.

## Node-toggle flicker fixes

Toggling Node mode forces the connection manager to tear down the
gateway WS and reconnect. The page was rendering every snapshot
transition (Connected → Disconnecting → Idle → Connecting → Connected),
which read as the entire gateway/operator going offline.

A. Reconnect mask. RefreshFromSnapshot caches the last "stable"
   (Connected/Ready/Degraded) snapshot. After a Node toggle, gateway
   and operator visuals derive from that cached snapshot for up to 8
   seconds or until the connection re-stabilizes — whichever is
   sooner. Node-related fields pass through so the Node card itself
   still reflects reality.

B. ItemsSource fingerprint dedupe. SavedGatewaysList,
   GlanceChipsHost and NodeCapabilityChipsHost now compute a string
   fingerprint of their inputs and skip the swap when nothing
   observable changed. ItemsSource swaps were re-templating items
   on every snapshot tick even when the rendered output was
   identical, which caused the visible flash users saw during the
   reconnect window.

C. Subtle red hint on Node Off state. The Node card status icon and
   "Node mode disabled" label use SystemFillColorCriticalBrush in
   the Off state to give a visual cue that this PC is not sharing
   capabilities. Other Node states keep their existing colors.

## Validation

- ./build.ps1 — all projects green
- Tray tests: 990 / 990 passed
- Shared tests: 1620 / 1648 (28 skipped)
- Manual: launched, toggled Node mode many times, no flicker on the
  gateway strip, no XamlParseException, app stable.

Co-authored-by: Copilot <[email protected]>
Second adversarial review (Opus + Codex) on the full delta against
origin/master surfaced 7 more issues, including one critical: the
reconnect mask landed in the previous commit never actually engaged.

## Critical

Reconnect mask was disarmed before any transient snapshot could
arrive. OnNodeModeToggled called BeginReconnectMask() and then
RefreshFromSnapshot(_lastSnapshot) — and _lastSnapshot was still the
pre-toggle stable Connected snapshot, so the stable-state branch in
RefreshFromSnapshot reset _suppressReconnectVisualsUntilUtc to
DateTime.MinValue and stopped the timer. The flicker fix never ran.

Fix: added _maskHasObservedTransient. RefreshFromSnapshot only drops
the mask when this flag is true (i.e. we have actually seen a
transient state since the mask was armed). BeginReconnectMask and
OnReconnectMaskTimeout reset the flag.

## Stale-cache fingerprint bugs

- Capability chip fingerprint only included 4 of 7 settings.
  Toggling Location, TTS, or STT would not invalidate the cache.
  Added NodeLocationEnabled, NodeTtsEnabled, NodeSttEnabled.

- Glance fingerprint stored todayAmount as the only cost signal.
  cost?.Daily appearing/disappearing at .00 would not invalidate
  the cache. Added dailyCount.

- Saved-gateway-list fingerprint omitted r.Url. Editing a URL
  without changing the friendly name left the stale URL visible
  in the row sub-line. Added Url to the per-row fingerprint.

## Other findings

- OnConnectSavedGateway fire-and-forgot SwitchGatewayAsync, so any
  exception became silent. Made async void with try/catch surfacing
  failures into AuthErrorBar with Error severity; disables the
  button during the call.

- Identity backup/restore in RollbackDirectConnect now captures
  FileInfo.Length + LastWriteTimeUtc at backup time and only
  restores if the file is unchanged (or absent post-clear). A
  late-arriving valid token from a successful pairing therefore
  wins over our stale backup.

- Pairing approve/deny with the RequestId fallback could be
  ambiguous if a legacy gateway sent multiple requests with the
  same DeviceId / NodeId. Added ComputeAmbiguousFallbackIds which
  builds the set of fallback ids that collide across requests with
  no RequestId; cards in that set are rendered with canPair=false
  so the user must approve via the gateway-host CLI.

## UX nit

Strip headline renamed from "Gateway connected" to "Connected".

## Validation

- ./build.ps1 — all projects green
- Tray tests: 990 / 990 passed
- Shared tests: 1620 / 1648 (28 skipped)
- Manual: launched, no XamlParseException, app stable.

Co-authored-by: Copilot <[email protected]>
Resolves conflicts in ConnectionPage.xaml and ConnectionPage.xaml.cs:
- Took our version of both files (master's edits operated on the old
  page which this branch replaces wholesale, so a line-level merge
  was not meaningful).
- Re-added the entry point master introduced via the new
  `LocalWslSetupCard` and `OnInstallNewWslGateway` handler. In the
  rebuilt page the same affordance surfaces as two cards driven by
  `hub.OpenSetupAction`:
  * `WelcomeLocalWslSetupCard` — on the Welcome screen below the
    Direct/Setup-code tiles and inline Scan, for first-run users
    with no saved gateway.
  * `CockpitLocalWslSetupCard` — inside the Gateways section card
    in Cockpit, for users with existing gateways who want to add a
    local WSL one.
  Both cards hide when `OpenSetupAction` is null (no WSL tooling).
- Wired both cards to a single `OnInstallLocalWslGateway` handler
  that invokes `_hub.OpenSetupAction`, matching the legacy
  behavior of `OnInstallNewWslGateway`.

App.xaml.cs and HubWindow.xaml.cs auto-merged cleanly:
- Master's earlier `_gatewayRegistry` initialization (now before
  the first-run check, since V2 onboarding needs registry access via
  `StartupSetupState.RequiresSetup`) and the `RequiresSetup`
  signature change preserved.
- Our `home`/`general` → `connection` aliasing and
  `OnGlanceDataChanged` wiring preserved; master's stray HomePage
  references were dropped (HomePage is deleted on this branch).

Validation:
- `./build.ps1` — all projects green
- Tray tests: 953 / 953 passed (line count dropped from 990 because
  master removed legacy onboarding tests; no regressions in our set)
- Shared tests: 1620 / 1620 (28 pre-existing skipped)
- Manual smoke: launched, no XamlParseException, app stable.

Co-authored-by: Copilot <[email protected]>
Post-merge UX iterations:

- **WSL install moved into Add Gateway form.** The cockpit-section
  WSL card is gone; "Local WSL" is now a third tab in the Add
  Gateway selector (alongside Direct / Setup code). The Local-WSL
  pane has its own "Install local gateway" button and hides the
  SSH expander + Save & connect since the install wizard owns the
  flow.
- **Welcome leads with WSL install when empty.** First-run users
  with no saved gateway and nothing discovered now see the
  `WelcomeLocalWslSetupCard` at the top of the Welcome card as
  the leading "Get started" CTA, followed by "Or connect to an
  existing one:" → Direct / Setup-code tiles.
- All entry points hide together when `hub.OpenSetupAction` is
  null (no WSL tooling on this machine).

- **XamlParseException crash fix.** Welcome card used
  `{ThemeResource AccentControlBorderBrush}` which doesn't
  exist in WinUI 3. Replaced with `AccentFillColorDefaultBrush`.

- **Strip primary button no longer duplicates the toggle.** Cancel
  / Retry / Connect / Reconnect actions are reachable by tapping
  the connection toggle, so the redundant button is suppressed for
  those four actions. The strip button still shows for
  `CopyApproveCommand` (pairing/recovery copy-to-clipboard) and
  `Rep` (re-pair → setup code), since the toggle can't do those.

Validation:
- `./build.ps1` — all projects green
- Tray tests: 953 / 953
- Manual: launched, no XamlParseException, Welcome and Add Gateway
  surfaces render correctly.

Co-authored-by: Copilot <[email protected]>
The custom accent-tinted Border for the Welcome get-started CTA was
off-catalog — tokens.md doesn't define an accent-banner brush and
explicitly says "Never hardcode colors... If a value is missing from
the table below, ask before introducing it."

Replaced with a WinUI `InfoBar` (`Severity="Informational"`,
`IsClosable="False"`) and the install button surfaced via
`InfoBar.ActionButton`. This is the canonical WinUI featured-callout
surface — theme-aware soft blue tint + built-in info icon — and uses
zero custom brushes, fully on-spec.

Validation: build green, app launches, no XamlParseException.

Co-authored-by: Copilot <[email protected]>
@bkudiess
bkudiess marked this pull request as ready for review May 16, 2026 06:21
Clean auto-merge — master added TrayMenuStateBuilder extraction (~1300
lines lifted out of App.xaml.cs) plus tray VarB polish. No conflicts in
the Connection page surface; FluentIconCatalog + tests merged cleanly.

Validation:
- ./build.ps1 — all projects green
- Tray tests: 953 / 953
- Shared tests: 1620 / 1620 (28 pre-existing skipped)
- Manual smoke: launched, no XamlParseException.

Co-authored-by: Copilot <[email protected]>
@shanselman
shanselman merged commit 672aadc into openclaw:master May 16, 2026
11 checks passed
@shanselman

Copy link
Copy Markdown
Collaborator

Thank you @bkudiess — this looks great. I validated the updated branch locally, confirmed the app runs and connects, and merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants