Avoid GitHub self-heal polling without remote

This commit is contained in:
Mohamed Boudra
2026-04-22 11:21:37 +07:00
parent 184902dd0d
commit 6503245493
2 changed files with 32 additions and 2 deletions
@@ -631,6 +631,30 @@ describe("WorkspaceGitServiceImpl primitive refresh entrypoint", () => {
github.dispose?.();
});
test("subscription skips GitHub self-heal polling when the checkout has no GitHub remote", async () => {
const retainCurrentPullRequestStatusPoll = vi.fn(() => ({ unsubscribe: vi.fn() }));
const github = {
...createGitHubServiceStub(),
retainCurrentPullRequestStatusPoll,
};
const getCheckoutStatus = vi.fn(async (cwd: string) =>
createCheckoutStatus(cwd, {
hasRemote: false,
remoteUrl: null,
}),
);
const service = createService({
getCheckoutStatus,
github,
});
const subscription = await service.subscribe({ cwd: "/tmp/repo" }, vi.fn());
expect(retainCurrentPullRequestStatusPoll).not.toHaveBeenCalled();
subscription.unsubscribe();
service.dispose();
});
test("multiple subscribers on the same target share one self-heal timer", async () => {
let nowMs = 0;
const getCheckoutStatus = vi.fn(async (cwd: string) => createCheckoutStatus(cwd));
@@ -945,8 +945,14 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
return;
}
const headRef = target.latestSnapshot?.git.currentBranch ?? null;
if (!headRef || !this.deps.github.retainCurrentPullRequestStatusPoll) {
const snapshot = target.latestSnapshot;
if (!snapshot || !this.deps.github.retainCurrentPullRequestStatusPoll) {
this.stopGitHubPollForTarget(target);
return;
}
const headRef = snapshot.git.currentBranch;
if (!headRef || !hasGitHubRemoteUrl(snapshot.git.remoteUrl)) {
this.stopGitHubPollForTarget(target);
return;
}