using System.Runtime.InteropServices; namespace ClaudeDo.Ui.Services; internal static class ForegroundHelper { private const int ASFW_ANY = -1; [DllImport("user32.dll", SetLastError = true)] private static extern bool AllowSetForegroundWindow(int dwProcessId); // Grants any process the right to take foreground on next SetForegroundWindow call. // Used before RPCs that cause a helper process (e.g. wt.exe) to spawn a new window. public static void AllowAny() { if (!OperatingSystem.IsWindows()) return; try { AllowSetForegroundWindow(ASFW_ANY); } catch { } } }