Lazy-load GitHub picker queries

This commit is contained in:
Mohamed Boudra
2026-04-22 20:00:43 +07:00
parent 8e63274ce6
commit 368ce0339a
5 changed files with 27 additions and 4 deletions
@@ -834,6 +834,23 @@ describe("Composer attachments", () => {
expect(combobox.dataset.anchor).toBe("attached");
});
it("lazily searches GitHub only after the GitHub combobox opens", async () => {
renderComposer();
await flushAsyncWork();
expect(mockClient.searchGitHub).not.toHaveBeenCalled();
click(queryByTestId("message-input-attach-button")!);
click(queryByTestId("message-input-attachment-menu-item-github")!);
await findByTestId("composer-github-combobox");
expect(mockClient.searchGitHub).toHaveBeenCalledWith({
cwd: "/repo",
query: "",
limit: 20,
});
});
it("closes the GitHub combobox after selecting an item", async () => {
renderComposer();
+1 -1
View File
@@ -790,7 +790,7 @@ export function Composer({
limit: 20,
});
},
enabled: isConnected && !!client && cwd.trim().length > 0,
enabled: isGithubPickerOpen && isConnected && !!client && cwd.trim().length > 0,
staleTime: 30_000,
});
@@ -465,6 +465,7 @@ function DraftAgentScreenContent({
},
enabled:
isCreateWorktree &&
isBranchOpen &&
isGitDirectory &&
!isNonGitDirectory &&
Boolean(trimmedWorkingDir) &&
@@ -586,10 +586,15 @@ describe("NewWorkspaceScreen picker payload", () => {
expect(pickerRow.style.transform).toBe("translateY(-216px)");
});
it("searches only GitHub PRs for the picker", async () => {
it("lazily searches only GitHub PRs when the picker opens", async () => {
renderScreen();
await flush();
expect(mockClient.searchGitHub).not.toHaveBeenCalled();
click(await findByTestId("new-workspace-ref-picker-trigger"));
await flush();
expect(mockClient.searchGitHub).toHaveBeenCalledWith({
cwd: "/repo",
query: "",
@@ -183,7 +183,7 @@ export function NewWorkspaceScreen({
limit: 20,
});
},
enabled: isConnected && !!client,
enabled: pickerOpen && isConnected && !!client,
staleTime: 15_000,
});
@@ -198,7 +198,7 @@ export function NewWorkspaceScreen({
kinds: ["github-pr"],
});
},
enabled: isConnected && !!client,
enabled: pickerOpen && isConnected && !!client,
staleTime: 30_000,
});