diff --git a/tests/OpenClaw.Tray.UITests/UIThreadFixture.cs b/tests/OpenClaw.Tray.UITests/UIThreadFixture.cs index ae1f91e33..63970bc88 100644 --- a/tests/OpenClaw.Tray.UITests/UIThreadFixture.cs +++ b/tests/OpenClaw.Tray.UITests/UIThreadFixture.cs @@ -226,9 +226,9 @@ private void UIThreadProc() if (!IsSlow) { - // Default: hide the window so CI runs are silent. - _startupPhase = "hiding test window"; - TryHide(TestWindow); + // Default: keep the window live but off-screen so CI runs are silent. + _startupPhase = "moving test window off-screen"; + MoveOffScreen(TestWindow); } _startupPhase = "ready"; @@ -248,17 +248,14 @@ private void UIThreadProc() } } - private static void TryHide(Window w) + private static void MoveOffScreen(Window w) { try { - // WindowsAppSDK 1.5+ supports AppWindow.Hide via WinUIEx, but to keep - // deps minimal we just move the window off-screen. It's still a real - // Window — XamlRoot is attached, the visual tree lays out — but the - // user never sees it during tests. - var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(w); - // SW_HIDE = 0 - ShowWindow(hwnd, 0); + // Move off-screen so CI runs are silent while keeping the window + // live in the WinUI compositor. XamlRoot stays attached, the visual + // tree lays out, but the user never sees it during tests. + w.AppWindow.MoveAndResize(new Windows.Graphics.RectInt32(-32000, -32000, 1, 1)); } // slopwatch-ignore: SW003 Test cleanup or fixture teardown is best-effort and must not hide the test outcome. catch @@ -267,10 +264,6 @@ private static void TryHide(Window w) } } - [System.Runtime.InteropServices.DllImport("user32.dll")] - [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)] - private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); - public void Dispose() { try