From 4fe358423b298376abea23996addf6c3e0fc08ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Fri, 31 Jul 2026 23:24:46 +0100 Subject: [PATCH] fix: prevent GitHub settings refresh flash (#2118) --- .../components/github/github-status.test.tsx | 27 ++++++- apps/web/components/github/github-status.tsx | 13 +++- .../github-authentication.spec.ts | 41 ++++++++++ .../mobile-github-auth-settings.spec.ts | 50 ++++++++++++ .../domains/github/use-github-status.test.tsx | 46 +++++++++++ .../hooks/domains/github/use-github-status.ts | 3 +- .../github-settings-stable-refresh/plan.md | 74 ++++++++++++++++++ .../task-01-stabilize-refresh.md | 77 +++++++++++++++++++ .../integrations/github-authentication.md | 10 +++ 9 files changed, 332 insertions(+), 9 deletions(-) create mode 100644 docs/plans/github-settings-stable-refresh/plan.md create mode 100644 docs/plans/github-settings-stable-refresh/task-01-stabilize-refresh.md diff --git a/apps/web/components/github/github-status.test.tsx b/apps/web/components/github/github-status.test.tsx index ce3bfcac1c..9534ec0401 100644 --- a/apps/web/components/github/github-status.test.tsx +++ b/apps/web/components/github/github-status.test.tsx @@ -4,12 +4,24 @@ import { ToastProvider } from "@/components/toast-provider"; import type { GitHubStatus } from "@/lib/types/github"; import { GitHubPersonalSettings } from "./github-status"; -const mocks = vi.hoisted(() => ({ status: null as GitHubStatus | null })); +const mocks = vi.hoisted(() => ({ + status: null as GitHubStatus | null, + loading: false, +})); vi.mock("@/hooks/domains/github/use-github-status", () => ({ - useGitHubStatus: () => ({ status: mocks.status, loaded: true, loading: false, refresh: vi.fn() }), + useGitHubStatus: () => ({ + status: mocks.status, + loaded: true, + loading: mocks.loading, + refresh: vi.fn(), + }), })); -afterEach(() => cleanup()); +afterEach(() => { + cleanup(); + mocks.status = null; + mocks.loading = false; +}); function renderPersonal() { return render( @@ -61,4 +73,13 @@ describe("GitHubPersonalSettings", () => { expect(screen.getByRole("button", { name: /Connect identity/ })).toBeTruthy(); expect(screen.getByText(/never given to managed agents/)).toBeTruthy(); }); + + it("keeps the current identity visible while refreshing", () => { + mocks.status = status("github_app_installation"); + mocks.loading = true; + renderPersonal(); + + expect(screen.getByTestId("github-personal-identity")).toBeTruthy(); + expect(screen.getByText("octocat", { exact: true })).toBeTruthy(); + }); }); diff --git a/apps/web/components/github/github-status.tsx b/apps/web/components/github/github-status.tsx index edfc9603db..9d645c9156 100644 --- a/apps/web/components/github/github-status.tsx +++ b/apps/web/components/github/github-status.tsx @@ -189,6 +189,7 @@ function AutomationActions({ status, workspaceId, busy, + refreshing, onDisconnect, onRefresh, taskAccess, @@ -196,6 +197,7 @@ function AutomationActions({ status: GitHubStatus; workspaceId: string; busy: boolean; + refreshing: boolean; onDisconnect: () => void; onRefresh: () => void; taskAccess: TaskGitCredentialsState; @@ -213,10 +215,12 @@ function AutomationActions({ variant="outline" size="icon" onClick={onRefresh} + disabled={refreshing} + aria-busy={refreshing} className="h-11 w-11 cursor-pointer" aria-label="Refresh GitHub connection" > - + {status.automation && (