Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/staged/src/lib/features/projects/AddRepoModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
const normalizedBranch = branchName.trim() || undefined;
const prNumber = matchedPr?.number ?? undefined;

if (excludeRepos?.has(`${selectedRepo}\x00${normalizedSubpath ?? ''}`)) {
error = 'This repo + subpath is already in the project';
saving = false;
return;
}

onAdded({
nameWithOwner: selectedRepo,
branchName: normalizedBranch,
Expand Down
2 changes: 1 addition & 1 deletion apps/staged/src/lib/features/projects/ProjectHome.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@
excludeRepos={new Set(
[...reposById.values()]
.filter((r) => r.projectId === project.id)
.map((r) => r.githubRepo)
.map((r) => `${r.githubRepo}\x00${r.subpath ?? ''}`)
)}
onRepoSelected={(selection) => handleRepoSelected(project.id, selection)}
onRetryWorktree={(branchId) => setupBranchWorktree(branchId, project.id)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@
});

let filteredRecentRepos = $derived(
excludeRepos ? recentRepos.filter((r) => !excludeRepos.has(r.githubRepo)) : recentRepos
excludeRepos
? recentRepos.filter((r) => !excludeRepos.has(`${r.githubRepo}\x00${r.subpath ?? ''}`))
: recentRepos
);

const dark = $derived(darkMode.value);
Expand Down
17 changes: 12 additions & 5 deletions apps/staged/src/lib/features/projects/RepoSearchInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
const seen = new Set<string>();
const result: Array<{ type: 'recent' | 'repo'; data: RecentRepo | GitHubRepo }> = [];

if (directFetchRepo && !excludeRepos.has(directFetchRepo.nameWithOwner)) {
if (directFetchRepo) {
result.push({ type: 'repo', data: directFetchRepo });
seen.add(directFetchRepo.nameWithOwner);
}

for (const r of searchResults) {
if (!seen.has(r.nameWithOwner) && !excludeRepos.has(r.nameWithOwner)) {
if (!seen.has(r.nameWithOwner)) {
result.push({ type: 'repo', data: r });
seen.add(r.nameWithOwner);
}
Expand All @@ -94,7 +94,7 @@
: repos;

for (const r of filtered) {
if (!seen.has(r.nameWithOwner) && !excludeRepos.has(r.nameWithOwner)) {
if (!seen.has(r.nameWithOwner)) {
result.push({ type: 'repo', data: r });
seen.add(r.nameWithOwner);
}
Expand All @@ -105,7 +105,9 @@

let filteredRecentRepos = $derived.by(() => {
const q = query.toLowerCase().trim();
const base = recentRepos.filter((r) => !excludeRepos.has(r.githubRepo));
const base = recentRepos.filter(
(r) => !excludeRepos.has(`${r.githubRepo}\x00${r.subpath ?? ''}`)
);
return q ? base.filter((r) => r.githubRepo.toLowerCase().includes(q)) : base;
});

Expand All @@ -125,7 +127,11 @@

onMount(async () => {
if (autofocus) {
inputEl?.focus();
// Defer so the click that opened our parent modal finishes bubbling
// before we open the dropdown. Otherwise the trailing window-level
// handleClickOutside (registered when this component mounted) sees a
// target outside our wrapper and closes the dropdown we just opened.
setTimeout(() => inputEl?.focus(), 0);
}
try {
recentRepos = await commands.listRecentRepos(10);
Expand All @@ -148,6 +154,7 @@
}

async function handleInput() {
dropdownOpen = true;
const trimmed = query.trim();

const parsed = parseGitHubUrl(trimmed);
Expand Down