Skip to content

refactor(tray): extract TrayTooltipBuilder from App.xaml.cs - #376

Merged
shanselman merged 1 commit into
openclaw:masterfrom
AlexAlves87:refactor/extract-tray-tooltip-builder
May 14, 2026
Merged

shanselman merged 1 commit into
openclaw:masterfrom
AlexAlves87:refactor/extract-tray-tooltip-builder

Conversation

@AlexAlves87

Copy link
Copy Markdown
Contributor

Summary

BuildTrayTooltip in App.xaml.cs read eight fields directly to
assemble the tray icon tooltip string. This moves that logic into a
dedicated TrayTooltipBuilder, following the snapshot pattern
established by CommandCenterStateBuilder in PR #297.

What changed

  • Add TrayStateSnapshot — an 8-field record (status, activity,
    channels, nodes, local node fallback, auth failure message, last check
    time, settings) following the same structure as AppStateSnapshot.
    NodeService is not held in the snapshot; GetLocalNodeInfo() is
    called once at capture time and the result stored as LocalNodeFallback
  • Add TrayTooltipBuilder — receives a snapshot, contains the tooltip
    assembly logic, delegates to TrayTooltipFormatter.FitShellTooltip
    for the 127-char Windows shell limit
  • Replace BuildTrayTooltip body in App.xaml.cs with a two-line
    delegation; add CaptureTraySnapshot alongside it
  • Add 15 unit tests covering: standard format, activity override, idle
    activity (no override), warning count conditions, node counting,
    local node fallback, channel counting, truncation, and topology display

Testing

  • dotnet build src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj -r win-x64 --nologo
  • dotnet test tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --nologo — 15 new tests, all passing
  • Manual: hover over tray icon — tooltip shows status, topology, channel
    count, node count, warning count, and last check time as before; with
    active agent activity the activity text overrides the status line as expected

Notes

No observable behaviour change. The snapshot captures the same fields
that BuildTrayTooltip was reading directly, in the same call context
(UI thread).

Co-Authored-By: Claude Sonnet 4.6 [email protected]

BuildTrayTooltip read eight App fields to assemble the tray icon
tooltip string. This moves that logic into a dedicated
TrayTooltipBuilder, following the same snapshot pattern established
by CommandCenterStateBuilder.

- Add TrayStateSnapshot (8 fields: status, activity, channels, nodes,
  node service, auth failure, last check time, settings)
- Add TrayTooltipBuilder — receives a snapshot, delegates to
  TrayTooltipFormatter.FitShellTooltip for the 127-char shell limit
- Replace BuildTrayTooltip body in App with a two-line delegation;
  add CaptureTraySnapshot alongside it

No observable behaviour change: tooltip content, truncation, and all
three call sites (InitializeTrayIcon ×2, UpdateTrayIcon) are unchanged.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@shanselman
shanselman merged commit 9f76881 into openclaw:master May 14, 2026
18 checks passed
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