Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: cannot switch project (#20216)

ecmadaoc631886934aa
diff --git a/frontend/src/react/pages/project/ProjectLandingPage.test.tsx b/frontend/src/react/pages/project/ProjectLandingPage.test.tsx
deleted file mode 100644
index c642ab57f4..0000000000
--- a/frontend/src/react/pages/project/ProjectLandingPage.test.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { act } from "react";
-import { createRoot } from "react-dom/client";
-import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
-
-(
- globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
-).IS_REACT_ACT_ENVIRONMENT = true;
-
-const mocks = vi.hoisted(() => ({
- replace: vi.fn(),
-}));
-
-vi.mock("@/router", () => ({
- router: {
- replace: mocks.replace,
- },
-}));
-
-vi.mock("@/router/dashboard/projectV1", () => ({
- PROJECT_V1_ROUTE_ISSUES: "project.issues",
-}));
-
-import { ProjectLandingPage } from "./ProjectLandingPage";
-
-let container: HTMLDivElement;
-let root: ReturnType<typeof createRoot>;
-
-beforeEach(() => {
- mocks.replace.mockClear();
- container = document.createElement("div");
- document.body.appendChild(container);
- root = createRoot(container);
-});
-
-afterEach(() => {
- act(() => {
- root.unmount();
- });
- document.body.removeChild(container);
-});
-
-describe("ProjectLandingPage", () => {
- test("redirects project landing to issues", async () => {
- await act(async () => {
- root.render(<ProjectLandingPage projectId="prod" />);
- });
-
- expect(mocks.replace).toHaveBeenCalledWith({
- name: "project.issues",
- params: { projectId: "prod" },
- });
- });
-});
diff --git a/frontend/src/react/pages/project/ProjectLandingPage.tsx b/frontend/src/react/pages/project/ProjectLandingPage.tsx
deleted file mode 100644
index 232c4daf07..0000000000
--- a/frontend/src/react/pages/project/ProjectLandingPage.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { useEffect } from "react";
-import { router } from "@/router";
-import { PROJECT_V1_ROUTE_ISSUES } from "@/router/dashboard/projectV1";
-
-export function ProjectLandingPage({ projectId }: { projectId: string }) {
- useEffect(() => {
- router.replace({
- name: PROJECT_V1_ROUTE_ISSUES,
- params: { projectId },
- });
- }, [projectId]);
-
- return <div />;
-}
diff --git a/frontend/src/react/stores/app/auth.ts b/frontend/src/react/stores/app/auth.ts
index d4393278ee..1d2d9ff724 100644
--- a/frontend/src/react/stores/app/auth.ts
+++ b/frontend/src/react/stores/app/auth.ts
@@ -15,7 +15,10 @@ export const createAuthSlice: AppSliceCreator<AuthSlice> = (set, get) => ({
return user;
})
.catch(() => {
- set({ currentUserRequest: undefined });
+ // Don't cache failures — the next call (e.g., after login) should
+ // retry. Without this, a pre-login failure permanently prevents
+ // the React store from loading the authenticated user.
+ set({ currentUser: undefined, currentUserRequest: undefined });
return undefined;
});
set({ currentUserRequest: request });
diff --git a/frontend/src/react/stores/app/workspace.ts b/frontend/src/react/stores/app/workspace.ts
index 652689ac88..d618c29c2b 100644
--- a/frontend/src/react/stores/app/workspace.ts
+++ b/frontend/src/react/stores/app/workspace.ts
@@ -6,6 +6,7 @@ import {
authServiceClientConnect,
settingServiceClientConnect,
subscriptionServiceClientConnect,
+ userServiceClientConnect,
workspaceServiceClientConnect,
} from "@/connect";
import {
@@ -137,15 +138,24 @@ export const createWorkspaceSlice: AppSliceCreator<WorkspaceSlice> = (
},
loadWorkspace: async () => {
- const existing = get().workspace;
- if (existing) return existing;
- const pending = get().workspaceRequest;
- if (pending) return pending;
- await Promise.all([get().loadCurrentUser(), get().loadServerInfo()]);
+ // Always re-fetch currentUser to get the latest auth context.
+ // The cached currentUser may be from before login (undefined or stale).
+ const user = await userServiceClientConnect
+ .getCurrentUser({})
+ .catch(() => undefined);
+ if (user) {
+ set({ currentUser: user });
+ }
const name =
- get().serverInfo?.workspace ||
+ user?.workspace ||
get().currentUser?.workspace ||
+ get().serverInfo?.workspace ||
`${workspaceNamePrefix}-`;
+ // Return cached workspace if it matches the current auth context.
+ const existing = get().workspace;
+ if (existing?.name === name) return existing;
+ const pending = get().workspaceRequest;
+ if (pending) return pending;
const request = workspaceServiceClientConnect
.getWorkspace({ name })
.then((workspace) => {
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index a23d98aa6e..1461d5c983 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -164,11 +164,12 @@ const projectV1Routes: RouteRecordRaw[] = [
{
path: "",
name: PROJECT_V1_ROUTE_DETAIL,
- // We will check user's permission to decide the redirect page.
- component: () => import("@/react/ReactPageMount.vue"),
- props: (route: RouteLocationNormalized) => ({
- page: "ProjectLandingPage",
- ...route.params,
+ // Redirect to the issues page synchronously via beforeEnter instead
+ // of rendering ProjectLandingPage (which did an async useEffect →
+ // router.replace that raced with ReactPageMount's render queue).
+ redirect: (to) => ({
+ name: PROJECT_V1_ROUTE_ISSUES,
+ params: to.params,
}),
},
{