diff --git a/PolyPilot.Tests/RepoPickerConsistencyTests.cs b/PolyPilot.Tests/RepoPickerConsistencyTests.cs new file mode 100644 index 00000000..90cbb85d --- /dev/null +++ b/PolyPilot.Tests/RepoPickerConsistencyTests.cs @@ -0,0 +1,111 @@ +using System.Text.RegularExpressions; + +namespace PolyPilot.Tests; + +/// +/// Regression tests for the repo picker consistency bug: +/// "New Session" (CreateSessionForm.razor) used a <select> dropdown for repositories, +/// while "New Multi-Agent" (SessionSidebar.razor) used a list of clickable buttons. +/// Fix: both flows now use the same <select> dropdown pattern with the "ns-repo-select" CSS class, +/// and auto-advance to step 2 when there's only one repository. +/// +public class RepoPickerConsistencyTests +{ + private static string GetRepoRoot() + { + var dir = AppContext.BaseDirectory; + while (dir != null && !File.Exists(Path.Combine(dir, "PolyPilot.slnx"))) + dir = Directory.GetParent(dir)?.FullName; + return dir ?? throw new DirectoryNotFoundException("Could not find repo root (PolyPilot.slnx not found)"); + } + + private static string CreateSessionFormPath => + Path.Combine(GetRepoRoot(), "PolyPilot", "Components", "Layout", "CreateSessionForm.razor"); + + private static string SessionSidebarPath => + Path.Combine(GetRepoRoot(), "PolyPilot", "Components", "Layout", "SessionSidebar.razor"); + + // ── Both forms use for repo picker + Assert.Contains("ns-repo-select", content); + Assert.Matches(new Regex(@"]*class=""ns-repo-select"""), content); + } + + [Fact] + public void SessionSidebar_MultiAgent_UsesSelectDropdownForRepos() + { + var content = File.ReadAllText(SessionSidebarPath); + // The multi-agent flow should also use + + @foreach (var repo in RepoManager.Repositories) + { + + } + } - @if (!RepoManager.Repositories.Any()) + else if (RepoManager.Repositories.Count == 1) + { +
📦 @RepoManager.Repositories[0].Name
+ } + else {
No repositories available. Add a repository first.
} @@ -1970,6 +1976,10 @@ else isAddingGroup = false; isAddingMultiAgentGroup = true; pendingMultiAgentRepo = null; + + // Auto-advance when there's exactly 1 repo (matches CreateSessionForm behavior) + if (RepoManager.Repositories.Count == 1) + SelectRepoForGroup(RepoManager.Repositories[0]); } private void CancelMultiAgentCreation() @@ -1978,6 +1988,14 @@ else pendingMultiAgentRepo = null; } + private void OnMultiAgentRepoChanged(ChangeEventArgs e) + { + var repoId = e.Value?.ToString(); + if (string.IsNullOrEmpty(repoId)) return; + var repo = RepoManager.Repositories.FirstOrDefault(r => r.Id == repoId); + if (repo != null) SelectRepoForGroup(repo); + } + private void SelectRepoForGroup(RepositoryInfo repo) { // Repo selected — advance to step 2 (presets + custom name)