Skip to content

Commit 1c6e75e

Browse files
nmetulevCopilot
andauthored
fix(ui): report ambiguity on partial process name match (#564)
When multiple processes match a partial `--app` query (e.g. `-a terminal` matching two `WindowsTerminal` instances) 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, process names, and window titles — consistent with the exact-name-match path: ``` Multiple processes matching 'terminal' found: PID 6816 (WindowsTerminal): ... PID 10516 (WindowsTerminal): Administrator: Windows PowerShell Use --app with a PID or a more specific window title. ``` Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1d02697 commit 1c6e75e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/winapp-CLI/WinApp.Cli/Services/UiSessionService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,19 @@ private static void RefreshWindowTitle(UiSessionInfo session)
355355
LogPartialMatch(app, result);
356356
return result;
357357
}
358+
359+
if (withWindow.Length > 1)
360+
{
361+
var listing = string.Join("\n ",
362+
withWindow.Select(p =>
363+
{
364+
try { return $"PID {p.Id} ({p.ProcessName}): \"{p.MainWindowTitle}\""; }
365+
catch { return $"PID {p.Id}"; }
366+
}));
367+
throw new InvalidOperationException(
368+
$"Multiple processes matching '{app}' found:\n {listing}\n" +
369+
"Use --app with a PID or a more specific window title.");
370+
}
358371
}
359372
}
360373
finally

0 commit comments

Comments
 (0)