Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(apps): keep the loaded app catalog when a refresh fails (#11459)
pseudoyu5ffe85d8d786
diff --git a/packages/views/apps/components/apps-page.test.tsx b/packages/views/apps/components/apps-page.test.tsxindex a8c3acda12..70710f5c72 100644--- a/packages/views/apps/components/apps-page.test.tsx+++ b/packages/views/apps/components/apps-page.test.tsx@@ -276,6 +276,22 @@ describe("AppsPage", () => {expect(title.querySelector("[data-slot=skeleton]")).toBeNull();});+ it("keeps the loaded catalog when a later refresh fails", async () => {+ const user = userEvent.setup();+ nav.search = "tab=all";+ renderPage();+ await screen.findByRole("link", { name: "Linear" });+ vi.mocked(api.listAppCatalog).mockRejectedValue(new Error("upstream"));+ // Asking for a team account reloads everything under connected apps.+ await user.click(screen.getByRole("button", { name: "Ask an admin" }));+ await waitFor(() => expect(api.listAppCatalog).toHaveBeenCalledTimes(2));+ await act(() => new Promise((resolve) => setTimeout(resolve, 20)));+ expect(screen.queryByRole("alert")).not.toBeInTheDocument();+ expect(screen.getByRole("link", { name: "Linear" })).toBeInTheDocument();+ expect(navLink(/^All apps/)).toHaveTextContent(/4$/);+ expect(within(directoryNav()).getByRole("region", { name: "Categories" })).toBeInTheDocument();+ });+it("recovers an empty saved catalog only after an admin confirms", async () => {overview = { ...overview, catalog_mode: "custom", allowed_toolkits: [], can_manage: true };vi.mocked(api.updateAppSettings).mockImplementation(async () => {diff --git a/packages/views/apps/components/apps-page.tsx b/packages/views/apps/components/apps-page.tsxindex 9f18528d10..8346a2a3b3 100644--- a/packages/views/apps/components/apps-page.tsx+++ b/packages/views/apps/components/apps-page.tsx@@ -102,7 +102,8 @@ function AppsDirectory() {const accountRows = useAccountRows(viewerOverview, catalog.data?.apps ?? []);// Until the catalog arrives the directory only knows the apps in use, so// anything counted over the whole catalog would be wrong, not just early.- const catalogReady = catalog.isSuccess;+ // A failed refresh keeps the catalog already loaded.+ const catalogReady = !!catalog.data;const catalogPending = catalog.isPending;// The view lives in the URL so a connect flow started here comes back to it.@@ -275,7 +276,7 @@ function AppsDirectory() {content = <CardGridSkeleton count={6} />;} else if (tab === "accounts") {content = <AccountsList overview={loaded.viewerOverview} rows={accountRows} matches={matchesAccount} />;- } else if (tab === "all" && catalog.isError) {+ } else if (tab === "all" && catalog.isError && !catalogReady) {content = <CatalogFailed onRetry={() => catalog.refetch()} />;} else if (tab === "all" && !catalogReady) {content = <CardGridSkeleton count={12} />;