From 6bfb3a1f7cca748f9c61435b3ccc918c350e5072 Mon Sep 17 00:00:00 2001 From: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:56:44 -0700 Subject: [PATCH] fix(ui): report ambiguity on partial process name match When multiple processes match a partial --app query and all have visible windows, the code silently fell through to title search which then failed with a misleading 'No running app found' error. Now it throws a clear error listing the matching PIDs and titles, consistent with the exact-name-match path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../WinApp.Cli/Services/UiSessionService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/winapp-CLI/WinApp.Cli/Services/UiSessionService.cs b/src/winapp-CLI/WinApp.Cli/Services/UiSessionService.cs index 6facc932..3759b266 100644 --- a/src/winapp-CLI/WinApp.Cli/Services/UiSessionService.cs +++ b/src/winapp-CLI/WinApp.Cli/Services/UiSessionService.cs @@ -355,6 +355,19 @@ private static void RefreshWindowTitle(UiSessionInfo session) LogPartialMatch(app, result); return result; } + + if (withWindow.Length > 1) + { + var listing = string.Join("\n ", + withWindow.Select(p => + { + try { return $"PID {p.Id} ({p.ProcessName}): \"{p.MainWindowTitle}\""; } + catch { return $"PID {p.Id}"; } + })); + throw new InvalidOperationException( + $"Multiple processes matching '{app}' found:\n {listing}\n" + + "Use --app with a PID or a more specific window title."); + } } } finally