Skip to content

add branch search with server-side filtering#3084

Merged
HarshMN2345 merged 30 commits into
mainfrom
fix/fetch-all-branches
Jun 11, 2026
Merged

add branch search with server-side filtering#3084
HarshMN2345 merged 30 commits into
mainfrom
fix/fetch-all-branches

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@appwrite

appwrite Bot commented Jun 11, 2026

Copy link
Copy Markdown

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

MCP server integration brings LLM superpowers to Claude Desktop and Cursor IDE

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a new BranchSelector component with server-side search and replaces the previous client-side Input.ComboBox branch dropdowns across functions, sites, and domain-add flows. Branch lists are now loaded lazily on dropdown open rather than eagerly during page load, and the connect() helpers in the settings pages gain a full pagination loop to handle repos with more than 100 branches.

  • BranchSelector (src/lib/components/git/branchSelector.svelte): new custom dropdown with debounced server-side search, a portal for z-index correctness inside dialogs, and reactive prop reset when installationId/repositoryId change.
  • Consumer updates: productionBranchFieldset, createGit, createGitDeploymentModal, updateRepository (functions + sites), and both add-domain pages all swap to BranchSelector; corresponding +page.ts load functions drop their eager branch fetches.
  • Database column files: minor as type casts added to satisfy TypeScript on getDefaultSpatialData return values.

Confidence Score: 4/5

Safe to merge after fixing the out-of-order search response race condition in BranchSelector.

The new BranchSelector component has a race condition in searchBranches: a slow earlier request can resolve after a faster later one and overwrite searchResults with stale data. The 300 ms debounce reduces but does not eliminate this window — on slow or variable-latency connections it is reproducible and shows users incorrect branch lists.

src/lib/components/git/branchSelector.svelte — specifically the searchBranches async function lacks response-ordering guards.

Important Files Changed

Filename Overview
src/lib/components/git/branchSelector.svelte New component implementing server-side branch search; contains a race condition in searchBranches where out-of-order responses can display stale results, and uses Svelte 4 syntax in a file that should use runes per AGENTS.md.
src/lib/components/git/productionBranchFieldset.svelte Replaced Input.ComboBox with BranchSelector; now only fetches the default branch on mount (lazy list load), removing the branch list skeleton in the process.
src/routes/(console)/project-[region]-[project]/functions/function-[function]/(modals)/createGit.svelte Switches from upfront branch list fetch to BranchSelector; initial branch defaults to providerBranch without existence validation, which is an acceptable trade-off.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte Same pattern as functions createGit.svelte — switches to BranchSelector and defaults branch to providerBranch.
src/routes/(console)/project-[region]-[project]/functions/function-[function]/settings/updateRepository.svelte Replaces ComboBox with BranchSelector; adds full pagination loop in connect() to handle repos with >100 branches.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateRepository.svelte Mirror of functions updateRepository — BranchSelector replaces ComboBox, connect() gains pagination loop.
src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/add-domain/+page.svelte Replaces static InputSelect with BranchSelector; removes the empty-branch helper message that previously guided users when no branches existed.
src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/add-domain/+page.ts Removes eager branch list fetch from the load function; branches are now loaded lazily by BranchSelector.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/domains/add-domain/+page.svelte Same pattern as functions add-domain — BranchSelector replaces ComboBox; removes branch fetch from load.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/domains/add-domain/+page.ts Removes eager branch list fetch from sites add-domain load function.
src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte Adds paginated branch fetching loop in connect() to handle repos with more than 100 branches.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/line.svelte Adds explicit type casts for getDefaultSpatialData return values to satisfy TypeScript.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/point.svelte Same type cast additions as line.svelte for point spatial data.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/polygon.svelte Same type cast additions as line.svelte for polygon spatial data.
src/lib/components/git/index.ts Exports the new BranchSelector component from the git barrel.

Reviews (5): Last reviewed commit: "fix portal class mismatch causing dropdo..." | Re-trigger Greptile

Comment thread src/lib/components/git/branchSelector.svelte
Comment thread src/lib/components/git/branchSelector.svelte
Comment thread src/lib/components/git/branchSelector.svelte
@HarshMN2345 HarshMN2345 changed the title Fix: fetch all branches add branch search with server-side filtering Jun 11, 2026
@HarshMN2345 HarshMN2345 requested a review from premtsd-code June 11, 2026 13:58
Comment thread src/lib/components/git/branchSelector.svelte
Comment on lines +76 to +96
async function searchBranches(query: string) {
if (!query) {
searchResults = [];
searching = false;
return;
}
searching = true;
try {
const { branches: results } = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositoryBranches({
installationId,
providerRepositoryId: repositoryId,
search: query,
queries: [Query.limit(100)]
});
searchResults = results.map((b) => b.name);
} finally {
searching = false;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Stale search results from out-of-order responses

The 300 ms debounce reduces but does not eliminate the race: if request A (for "mai") is still in flight when request B (for "main") starts and finishes first, A's finally block will overwrite searchResults with the wrong data after B has already completed. searching is false at that point, so the UI silently shows stale results for the old query while searchQuery displays the newer value.

Fix by tracking a sequence counter and discarding responses that arrive out of order — increment before each call, capture the value, and skip the assignment if the counter has advanced by the time the response arrives.

@HarshMN2345 HarshMN2345 merged commit 4fd965c into main Jun 11, 2026
4 checks passed
@HarshMN2345 HarshMN2345 deleted the fix/fetch-all-branches branch June 11, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants