Refactor tray voice code into OpenClaw.Tray.Shared#5
Merged
NichUK merged 4 commits intofeature/voice-modefrom Apr 3, 2026
Merged
Refactor tray voice code into OpenClaw.Tray.Shared#5NichUK merged 4 commits intofeature/voice-modefrom
NichUK merged 4 commits intofeature/voice-modefrom
Conversation
Move voice-mode test-targeted logic out of the WinUI app and into a dedicated shared project so tray tests no longer need to reference OpenClaw.Tray.WinUI directly. This restores the original CI assumption that the tray test project can be built on its own without transitively building a Windows App SDK application with an implicit architecture. It also keeps the voice/chat extraction scoped away from the broader OpenClaw.Shared library, which remains general-purpose and non-tray-specific. The new OpenClaw.Tray.Shared project now contains the shared voice/chat surface used by both the tray app and tray tests, including voice transport helpers, provider catalog loading, cloud TTS support, chat coordination, and the web chat DOM bridge. The WinUI app retains the UI shell pieces, including DispatcherQueueAdapter and the app-level icon path helper. As a follow-up cleanup during the extraction, split the previous IconHelper into AppIconHelper in the WinUI project and VoiceTrayIconHelper in the shared tray project so the new shared library stays focused on voice-related behavior rather than wider tray infrastructure.
There was a problem hiding this comment.
Pull request overview
Refactors tray voice/chat functionality into a new OpenClaw.Tray.Shared project so the tray test project can build/run without referencing the WinUI (Windows App SDK) application, while keeping WinUI-specific UI shell concerns in OpenClaw.Tray.WinUI.
Changes:
- Introduced
OpenClaw.Tray.Sharedand moved/shared voice transport logic, voice capture math, voice provider route resolution, conversation event contracts, and web chat DOM bridge into it. - Updated tray tests to call shared logic directly (removing reflection-based access to WinUI internals) and updated project references accordingly.
- Split icon helpers into
AppIconHelper(WinUI app/status icons) andVoiceTrayIconHelper(voice tray state icons) and updated WinUI windows to use the new helper.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/OpenClaw.Tray.Tests/VoiceServiceTransportTests.cs | Switches tests from reflection into direct calls to shared transport/capture helpers. |
| tests/OpenClaw.Tray.Tests/VoiceProviderCatalogServiceTests.cs | Updates tests to use VoiceTrayIconHelper and shared catalog service. |
| tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj | Replaces WinUI project reference with OpenClaw.Tray.Shared. |
| src/OpenClaw.Tray.WinUI/Windows/WebChatWindow.xaml.cs | Uses AppIconHelper for window icon; uses shared DOM bridge. |
| src/OpenClaw.Tray.WinUI/Windows/VoiceRepeaterWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Windows/VoiceModeWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Windows/StatusDetailWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Windows/SettingsWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Windows/NotificationHistoryWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Windows/ActivityStreamWindow.xaml.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/Services/Voice/VoiceSpeechToTextRouteFactory.cs | Delegates STT route selection to shared resolver. |
| src/OpenClaw.Tray.WinUI/Services/Voice/VoiceService.cs | Delegates transport decision helpers to shared logic; moves conversation events out. |
| src/OpenClaw.Tray.WinUI/Services/Voice/VoiceCaptureService.cs | Delegates math helpers to shared VoiceCaptureMath. |
| src/OpenClaw.Tray.WinUI/Services/Voice/DispatcherQueueAdapter.cs | Adds WinUI-specific IUiDispatcher implementation in WinUI project. |
| src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj | References new OpenClaw.Tray.Shared project. |
| src/OpenClaw.Tray.WinUI/Helpers/AppIconHelper.cs | New WinUI-only helper for status/app icon path resolution. |
| src/OpenClaw.Tray.WinUI/Dialogs/QuickSendDialog.cs | Uses AppIconHelper for window icon. |
| src/OpenClaw.Tray.WinUI/App.xaml.cs | Uses AppIconHelper and VoiceTrayIconHelper for tray icon selection. |
| src/OpenClaw.Tray.Shared/Windows/WebChatVoiceDomBridge.cs | Makes DOM bridge public for shared consumption. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceSpeechToTextRouteResolver.cs | New shared STT route resolver. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceSpeechToTextRouteKind.cs | Exposes route kind enum publicly from shared. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceServiceTransportLogic.cs | New shared transport/decision helpers previously tested via reflection. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceProviderCatalogService.cs | Uses shared STT route resolver; removes WinUI factory dependency. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceConversationEvents.cs | New shared conversation/transcript event args and direction enum. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceCloudTextToSpeechClient.cs | Minor using reorder while moving into shared. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceChatCoordinator.cs | Ensures cloned turns include Mode after event args extraction. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceChatContracts.cs | Removes WinUI-specific dispatcher adapter from shared contracts. |
| src/OpenClaw.Tray.Shared/Services/Voice/VoiceCaptureMath.cs | New shared capture math utilities used by WinUI + tests. |
| src/OpenClaw.Tray.Shared/OpenClaw.Tray.Shared.csproj | Adds new shared project definition and dependencies. |
| src/OpenClaw.Tray.Shared/Helpers/VoiceTrayIconHelper.cs | Renames/splits icon helper to voice-only tray icon generation. |
| moltbot-windows-hub.slnx | Adds OpenClaw.Tray.Shared to the solution. |
Comments suppressed due to low confidence (1)
src/OpenClaw.Tray.Shared/Helpers/VoiceTrayIconHelper.cs:75
GetBaseAppIconPath()always returns anopenclaw.icopath without checking that it exists, andCreateVoiceTrayBitmapimmediately constructsnew Icon(GetBaseAppIconPath(), ...)which will throw if the icon file can't be found. To avoid runtime failures in environments where Assets aren't present (or during mispackaged builds), add an existence check and a fallback strategy before constructing the Icon.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move voice-mode test-targeted logic out of the WinUI app and into a dedicated shared project so tray tests no longer need to reference OpenClaw.Tray.WinUI directly.
This restores the original CI assumption that the tray test project can be built on its own without transitively building a Windows App SDK application with an implicit architecture. It also keeps the voice/chat extraction scoped away from the broader OpenClaw.Shared library, which remains general-purpose and non-tray-specific.
The new OpenClaw.Tray.Shared project now contains the shared voice/chat surface used by both the tray app and tray tests, including voice transport helpers, provider catalog loading, cloud TTS support, chat coordination, and the web chat DOM bridge. The WinUI app retains the UI shell pieces, including DispatcherQueueAdapter and the app-level icon path helper.
As a follow-up cleanup during the extraction, split the previous IconHelper into AppIconHelper in the WinUI project and VoiceTrayIconHelper in the shared tray project so the new shared library stays focused on voice-related behavior rather than wider tray infrastructure.