Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(views): prefetch IssuePeek neighbours, advance on delete, and align ProjectDetail skeleton (MUL-9882) (#11214)

Jiayuan Zhang9a65c407d1e5
diff --git a/packages/views/issues/components/issue-peek.test.tsx b/packages/views/issues/components/issue-peek.test.tsx
index eb52e92538..7cf725770d 100644
--- a/packages/views/issues/components/issue-peek.test.tsx
+++ b/packages/views/issues/components/issue-peek.test.tsx
@@ -1,7 +1,8 @@
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { useEffect, type ReactNode } from "react";
-import { beforeEach, describe, expect, it, vi } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { api } from "@multica/core/api";
import { issueKeys } from "@multica/core/issues/queries";
import type { Issue } from "@multica/core/types";
import { renderWithI18n } from "../../test/i18n";
@@ -13,12 +14,26 @@ import {
} from "../surface/peek-context";
import { IssuePeekHost } from "./issue-peek";
+const viewer = vi.hoisted(() => ({ guest: false }));
+
vi.mock("@multica/core/paths", () => ({
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}` }),
}));
vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));
+vi.mock("@multica/core/permissions", () => ({ useIsGuest: () => viewer.guest }));
+
+vi.mock("@multica/core/api", () => ({
+ api: {
+ getIssue: vi.fn(async (id: string) => ({ id, identifier: `MUL-${id}` })),
+ listTimeline: vi.fn(async () => []),
+ listTasksByIssue: vi.fn(async () => []),
+ listChildIssues: vi.fn(async () => ({ issues: [] })),
+ },
+ ApiError: class extends Error {},
+}));
+
// The panel's job is hosting; IssueDetail itself is covered by its own suite.
vi.mock("./issue-detail", () => ({
IssueDetail: ({
@@ -120,7 +135,10 @@ const openCard = (id: string) => fireEvent.click(screen.getByText(`card ${id}`))
describe("IssuePeekHost", () => {
beforeEach(() => {
vi.clearAllMocks();
- qc = new QueryClient();
+ viewer.guest = false;
+ qc = new QueryClient({
+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },
+ });
});
it("opens the peeked issue as a peek-variant detail and marks its card", () => {
@@ -204,14 +222,38 @@ describe("IssuePeekHost", () => {
editor.remove();
});
- it("closes from the close button and when the issue is deleted", async () => {
- renderHost();
+ it("closes from the close button, and advances or closes when the issue is deleted", async () => {
+ const { setColumns } = renderHost();
openCard("i-1");
fireEvent.click(screen.getByRole("button", { name: "Close preview" }));
await waitForClosed();
+ // Deleting an issue with a next neighbour lands on nextId.
openCard("i-1");
fireEvent.click(screen.getByRole("button", { name: "delete" }));
+ expect(screen.getByTestId("detail")).toHaveTextContent("i-2");
+
+ // Deleting the last issue in a column falls back to prevId.
+ openCard("i-3");
+ fireEvent.click(screen.getByRole("button", { name: "delete" }));
+ expect(screen.getByTestId("detail")).toHaveTextContent("i-2");
+
+ // Deleting the sole issue in a column closes the preview panel.
+ openCard("i-4");
+ fireEvent.click(screen.getByRole("button", { name: "delete" }));
+ await waitForClosed();
+
+ // Even if the list/board cache prunes the deleted row before onDelete fires,
+ // deletion still lands on the surviving nextId (or prevId if nextId is also gone).
+ openCard("i-2");
+ act(() => setColumns([["i-1", "i-3"], ["i-4"]]));
+ fireEvent.click(screen.getByRole("button", { name: "delete" }));
+ expect(screen.getByTestId("detail")).toHaveTextContent("i-3");
+
+ // When all previously known neighbours were also removed, the panel closes
+ // instead of opening a stale/deleted id.
+ act(() => setColumns([[], ["i-4"]]));
+ fireEvent.click(screen.getByRole("button", { name: "delete" }));
await waitForClosed();
});
@@ -349,3 +391,97 @@ describe("IssuePeekHost", () => {
expect(panel()).toBeNull();
});
});
+
+describe("IssuePeekHost adjacent prefetch", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.clearAllMocks();
+ viewer.guest = false;
+ qc = new QueryClient({
+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },
+ });
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ viewer.guest = false;
+ });
+
+ it("warms nextId then prevId once idle, and skips already-cached neighbours on J/K step", async () => {
+ renderHost([["i-1", "i-2", "i-3", "i-4"], ["i-5"]]);
+ openCard("i-2");
+ expect(api.getIssue).not.toHaveBeenCalled();
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+
+ expect(vi.mocked(api.getIssue).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(vi.mocked(api.listTimeline).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(vi.mocked(api.listTasksByIssue).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(vi.mocked(api.listChildIssues).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+
+ // Step to i-3: its prevId (i-2) is not yet cached, and its nextId (i-4) warms first.
+ // Pre-seed i-2 as already warm (as if IssueDetail loaded it) to verify no duplicate fetch.
+ qc.setQueryData(issueKeys.detail("ws-1", "i-2"), { id: "i-2", identifier: "MUL-i-2" } as Issue);
+ qc.setQueryData(issueKeys.timeline("i-2"), []);
+ qc.setQueryData(issueKeys.tasks("i-2"), []);
+ qc.setQueryData(issueKeys.children("ws-1", "i-2"), []);
+
+ vi.clearAllMocks();
+ fireEvent.keyDown(document.body, { key: "j" });
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+
+ expect(vi.mocked(api.getIssue).mock.calls.map(([id]) => id)).toEqual(["i-4"]);
+ expect(vi.mocked(api.listTimeline).mock.calls.map(([id]) => id)).toEqual(["i-4"]);
+ });
+
+ it("cancels pending prefetch when stepping quickly before idle", async () => {
+ renderHost([["i-1", "i-2", "i-3", "i-4"]]);
+ openCard("i-1");
+ fireEvent.keyDown(document.body, { key: "j" });
+ fireEvent.keyDown(document.body, { key: "j" });
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+
+ // Ended on i-3: warms i-4 (next) and i-2 (prev), never i-1.
+ expect(vi.mocked(api.getIssue).mock.calls.map(([id]) => id)).toEqual(["i-4", "i-2"]);
+ });
+
+ it("omits runs prefetch for guests", async () => {
+ viewer.guest = true;
+ renderHost([["i-1", "i-2", "i-3"]]);
+ openCard("i-2");
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+
+ expect(vi.mocked(api.getIssue).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(vi.mocked(api.listTimeline).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(vi.mocked(api.listChildIssues).mock.calls.map(([id]) => id)).toEqual(["i-3", "i-1"]);
+ expect(api.listTasksByIssue).not.toHaveBeenCalled();
+ });
+
+ it("does not re-run prefetch on unrelated column reorders that preserve neighbours", async () => {
+ const { setColumns } = renderHost([["i-1", "i-2", "i-3"], ["i-4", "i-5"]]);
+ openCard("i-2");
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+ expect(api.getIssue).toHaveBeenCalledTimes(2);
+
+ vi.clearAllMocks();
+ act(() => setColumns([["i-1", "i-2", "i-3"], ["i-5", "i-4"]]));
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(200);
+ });
+
+ expect(api.getIssue).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/views/issues/components/issue-peek.tsx b/packages/views/issues/components/issue-peek.tsx
index b29e48992d..55f64bf24d 100644
--- a/packages/views/issues/components/issue-peek.tsx
+++ b/packages/views/issues/components/issue-peek.tsx
@@ -1,6 +1,7 @@
"use client";
-import { memo, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
+import { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
+import { useQueryClient } from "@tanstack/react-query";
import { AnimatePresence, motion, useIsPresent } from "motion/react";
import { useReducedMotion } from "@multica/core/appearance";
import { ChevronDown, ChevronUp, Maximize2, X } from "@multica/ui/icons";
@@ -17,6 +18,8 @@ import { useModalStore } from "@multica/core/modals";
import { useWorkspacePaths } from "@multica/core/paths";
import { useWorkspaceId } from "@multica/core/hooks";
import { useIssueRouteRef } from "@multica/core/issues/canonical-id";
+import { prefetchIssuePage } from "@multica/core/issues/queries";
+import { useIsGuest } from "@multica/core/permissions";
import {
createShortcutChord,
isEditableShortcutTarget,
@@ -34,11 +37,13 @@ import {
IssuePeekIdContext,
IssuePeekPositionContext,
PEEK_TARGET_ATTR,
+ hasIssueInColumns,
locateInColumns,
useIssuePeekActions,
useIssuePeekPosition,
type IssuePeekActions,
type IssuePeekColumns,
+ type IssuePeekPosition,
} from "../surface/peek-context";
const NEXT_KEY = createShortcutChord("J");
@@ -84,6 +89,49 @@ export function IssuePeekHost({ children }: { children: ReactNode }) {
const openId = peekId;
const position = useMemo(() => locateInColumns(columns, openId), [columns, openId]);
+ // Keep the latest columns and last known neighbours for the open issue so
+ // deleting it can land on the next (or previous) surviving item even when
+ // the list/board cache prunes the deleted row before `onDelete` fires.
+ const columnsRef = useRef(columns);
+ columnsRef.current = columns;
+ const lastNeighboursRef = useRef<{
+ issueId: string;
+ nextId: string | null;
+ prevId: string | null;
+ } | null>(null);
+ if (!openId) {
+ lastNeighboursRef.current = null;
+ } else if (position) {
+ lastNeighboursRef.current = {
+ issueId: openId,
+ nextId: position.nextId,
+ prevId: position.prevId,
+ };
+ }
+
+ const handleDelete = useCallback((deletedId: string) => {
+ setPeekId((current) => {
+ if (current !== deletedId) return current;
+ const cols = columnsRef.current;
+ const pos = locateInColumns(cols, deletedId);
+ const fallback =
+ lastNeighboursRef.current?.issueId === deletedId
+ ? lastNeighboursRef.current
+ : null;
+ for (const candidate of [
+ pos?.nextId,
+ pos?.prevId,
+ fallback?.nextId,
+ fallback?.prevId,
+ ]) {
+ if (candidate && candidate !== deletedId && hasIssueInColumns(cols, candidate)) {
+ return candidate;
+ }
+ }
+ return null;
+ });
+ }, []);
+
// Tracked from pointer events rather than queried with `:hover`, so the
// card under a stationary pointer is known without a layout read.
const hoveredCardRef = useRef<string | null>(null);
@@ -125,7 +173,9 @@ export function IssuePeekHost({ children }: { children: ReactNode }) {
(J / K is keyboard navigation — it must not animate); only
opening and closing the panel does. */}
<AnimatePresence initial={false}>
- {openId && <IssuePeekPanel key="issue-peek" issueId={openId} />}
+ {openId && (
+ <IssuePeekPanel key="issue-peek" issueId={openId} onDelete={handleDelete} />
+ )}
</AnimatePresence>
</div>
</IssuePeekPositionContext.Provider>
@@ -137,14 +187,20 @@ export function IssuePeekHost({ children }: { children: ReactNode }) {
// Memoized, and blind to the column order: the host re-renders on every board
// reorder (a drag publishes columns on each hover), and none of that may reach
// IssueDetail. What does follow the order lives in IssuePeekFollow.
-const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: string }) {
+const IssuePeekPanel = memo(function IssuePeekPanel({
+ issueId,
+ onDelete,
+}: {
+ issueId: string;
+ onDelete: (issueId: string) => void;
+}) {
const { t } = useT("issues");
- const actions = useIssuePeekActions()!;
const panelRef = useRef<HTMLElement>(null);
// False while the exit animation plays: the closing panel no longer takes
// clicks or keys, so the board is usable the moment the peek is dismissed.
const isPresent = useIsPresent();
const reduceMotion = useReducedMotion();
+ const handleDelete = useCallback(() => onDelete(issueId), [onDelete, issueId]);
return (
<motion.aside
@@ -201,7 +257,7 @@ const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: stri
defaultSidebarOpen={false}
leadingAction={<IssuePeekNav />}
trailingActions={<IssuePeekTrailingActions issueId={issueId} />}
- onDelete={actions.close}
+ onDelete={handleDelete}
/>
</ErrorBoundary>
</WindowTitleBarProvider>
@@ -209,7 +265,7 @@ const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: stri
);
});
-/** The panel's keyboard (Esc, J / K / H / L, arrows) and keeping the peeked issue in view. */
+/** The panel's keyboard (Esc, J / K / H / L, arrows), neighbour prefetch, and keeping the peeked issue in view. */
function IssuePeekFollow({
issueId,
panelRef,
@@ -221,6 +277,8 @@ function IssuePeekFollow({
const position = useIssuePeekPosition();
const reduceMotion = useReducedMotion();
+ useIssuePeekPrefetch(issueId, position);
+
// Read through a ref so the listener is bound once, not on every step.
const positionRef = useRef(position);
positionRef.current = position;
@@ -299,6 +357,57 @@ function IssuePeekFollow({
return null;
}
+/**
+ * Warms the adjacent issues in the current column (`nextId`, then `prevId`)
+ * once the browser is idle, so stepping with J / K (or the prev/next arrows)
+ * renders from cache instead of flashing IssueDetailSkeleton.
+ */
+function useIssuePeekPrefetch(issueId: string, position: IssuePeekPosition | null) {
+ const qc = useQueryClient();
+ const wsId = useWorkspaceId();
+ // A guest's issue page shows no runs, and the server refuses them.
+ const guest = useIsGuest(wsId);
+ const nextId = position?.nextId ?? null;
+ const prevId = position?.prevId ?? null;
+ const targets = useMemo(() => {
+ const picked: string[] = [];
+ for (const candidate of [nextId, prevId]) {
+ if (candidate && candidate !== issueId && !picked.includes(candidate)) {
+ picked.push(candidate);
+ }
+ }
+ return picked;
+ }, [issueId, nextId, prevId]);
+ const targetKey = targets.join(",");
+
+ useEffect(() => {
+ if (!wsId || !targetKey) return;
+ let cancelled = false;
+ const run = async () => {
+ // One issue at a time: each fans out into up to four requests.
+ for (const targetId of targets) {
+ if (cancelled) return;
+ await prefetchIssuePage(qc, wsId, targetId, undefined, { runs: !guest }).catch(() => {
+ // A failed warm-up is retried when the user steps to that issue.
+ });
+ }
+ };
+ if (typeof window.requestIdleCallback === "function") {
+ const id = window.requestIdleCallback(() => void run(), { timeout: 150 });
+ return () => {
+ cancelled = true;
+ window.cancelIdleCallback(id);
+ };
+ }
+ const timer = window.setTimeout(() => void run(), 100);
+ return () => {
+ cancelled = true;
+ window.clearTimeout(timer);
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by target ids and viewer role
+ }, [qc, wsId, targetKey, guest]);
+}
+
function isArrowWidgetTarget(target: EventTarget | null) {
return (
target instanceof Element &&
diff --git a/packages/views/issues/surface/peek-context.test.ts b/packages/views/issues/surface/peek-context.test.ts
index cdd2796088..d2d2a69f60 100644
--- a/packages/views/issues/surface/peek-context.test.ts
+++ b/packages/views/issues/surface/peek-context.test.ts
@@ -1,6 +1,6 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
-import { locateInColumns, resolveIssueClick } from "./peek-context";
+import { hasIssueInColumns, locateInColumns, resolveIssueClick } from "./peek-context";
describe("locateInColumns", () => {
const columns = [["a", "b", "c"], [], ["d"]];
@@ -40,6 +40,18 @@ describe("locateInColumns", () => {
});
});
+describe("hasIssueInColumns", () => {
+ const columns = [["a", "b"], [], ["c"]];
+
+ it("checks whether an issue id exists in any column", () => {
+ expect(hasIssueInColumns(columns, "a")).toBe(true);
+ expect(hasIssueInColumns(columns, "c")).toBe(true);
+ expect(hasIssueInColumns(columns, "zzz")).toBe(false);
+ expect(hasIssueInColumns(null, "a")).toBe(false);
+ expect(hasIssueInColumns(columns, null)).toBe(false);
+ });
+});
+
describe("resolveIssueClick", () => {
const plain = { button: 0, shiftKey: false, metaKey: false, ctrlKey: false, altKey: false };
it("opens the preferred target on a plain click and the other one on Shift", () => {
diff --git a/packages/views/issues/surface/peek-context.tsx b/packages/views/issues/surface/peek-context.tsx
index dfd6c59642..ac0769dd4d 100644
--- a/packages/views/issues/surface/peek-context.tsx
+++ b/packages/views/issues/surface/peek-context.tsx
@@ -98,6 +98,15 @@ export function locateInColumns(
return null;
}
+/** Whether `issueId` currently exists in any published column. */
+export function hasIssueInColumns(
+ columns: IssuePeekColumns | null,
+ issueId: string | null,
+): boolean {
+ if (!columns || !issueId) return false;
+ return columns.some((column) => column.includes(issueId));
+}
+
/**
* What a click on an issue card or row opens: a plain click opens the preferred
* target (Settings → Preferences), Shift+Click the other one, so either is one
diff --git a/packages/views/projects/components/index.ts b/packages/views/projects/components/index.ts
index dcc12f8490..e69798ded4 100644
--- a/packages/views/projects/components/index.ts
+++ b/packages/views/projects/components/index.ts
@@ -1,5 +1,5 @@
export { ProjectsPage } from "./projects-page";
-export { ProjectDetail } from "./project-detail";
+export { ProjectDetail, ProjectDetailSkeleton } from "./project-detail";
export { ProjectPicker } from "./project-picker";
export { ProjectChip } from "./project-chip";
export { ProjectMentionCard } from "./project-mention-card";
diff --git a/packages/views/projects/components/project-detail.test.tsx b/packages/views/projects/components/project-detail.test.tsx
index 8cc5de2018..dea1f0fe34 100644
--- a/packages/views/projects/components/project-detail.test.tsx
+++ b/packages/views/projects/components/project-detail.test.tsx
@@ -16,6 +16,8 @@ import { ProjectDetail } from "./project-detail";
const mocks = vi.hoisted(() => ({
role: "admin",
+ isMobile: false,
+ defaultLayout: undefined as Record<string, number> | undefined,
copyText: vi.fn(),
copyTextAndHtml: vi.fn(),
deleteProject: vi.fn(),
@@ -87,7 +89,7 @@ vi.mock("sonner", () => ({
vi.mock("react-resizable-panels", () => ({
useDefaultLayout: () => ({
- defaultLayout: undefined,
+ defaultLayout: mocks.defaultLayout,
onLayoutChanged: vi.fn(),
}),
usePanelRef: () => ({
@@ -100,7 +102,7 @@ vi.mock("react-resizable-panels", () => ({
}));
vi.mock("@multica/ui/hooks/use-mobile", () => ({
- useIsMobile: () => false,
+ useIsMobile: () => mocks.isMobile,
}));
vi.mock("@multica/ui/components/common/emoji-picker", () => ({
@@ -231,12 +233,15 @@ vi.mock("../../layout/animated-right-sidebar", () => ({
AnimatedRightSidebar: ({ children }: { children: React.ReactNode }) => (
<aside>{children}</aside>
),
- getAnimatedRightSidebarInitialOpen: () => true,
+ getAnimatedRightSidebarInitialOpen: (
+ defaultOpen: boolean,
+ layout?: Record<string, number>,
+ ) => (typeof layout?.sidebar === "number" ? layout.sidebar > 0 : defaultOpen),
rightSidebarPanelMotionProps: {},
useRightSidebarShortcut: vi.fn(),
- useAnimatedRightSidebarState: () => ({
- open: true,
- visualOpen: true,
+ useAnimatedRightSidebarState: (initialOpen: boolean) => ({
+ open: initialOpen,
+ visualOpen: initialOpen,
motionEnabled: false,
beginToggle: vi.fn(),
handleResize: vi.fn(),
@@ -295,6 +300,8 @@ function renderProjectDetail(search = "") {
beforeEach(() => {
mocks.role = "admin";
+ mocks.isMobile = false;
+ mocks.defaultLayout = undefined;
qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });
qc.setQueryData(projectKeys.detail("workspace-1", PROJECT.id), PROJECT);
qc.setQueryData(["agents"], []);
@@ -672,3 +679,49 @@ describe("ProjectDetail project deletion", () => {
).not.toBeInTheDocument();
});
});
+
+describe("ProjectDetail loading skeleton", () => {
+ beforeEach(() => {
+ qc.removeQueries({ queryKey: projectKeys.detail("workspace-1", PROJECT.id) });
+ mocks.getProject.mockReturnValue(new Promise<never>(() => {}));
+ });
+
+ it("renders aligned page header, tab slots, body, and 320px desktop sidebar while loading", () => {
+ renderProjectDetail();
+
+ const skeleton = screen.getByTestId("project-detail-skeleton");
+ expect(skeleton).toHaveAttribute("data-mc", "object-page");
+ expect(skeleton).toHaveAttribute("data-type", "project");
+ expect(skeleton).toHaveAttribute("aria-busy", "true");
+ expect(skeleton.querySelector('header[data-mc="page-header"]')).not.toBeNull();
+ expect(screen.getByTestId("project-detail-skeleton-tabs").children).toHaveLength(3);
+
+ const sidebar = screen.getByTestId("project-detail-skeleton-sidebar");
+ expect(sidebar.className).toContain("w-80");
+ expect(sidebar.className).toContain("border-l");
+ });
+
+ it("omits the desktop sidebar placeholder when the saved layout collapsed it", () => {
+ mocks.defaultLayout = { content: 100, sidebar: 0 };
+ renderProjectDetail();
+
+ expect(screen.getByTestId("project-detail-skeleton")).toBeInTheDocument();
+ expect(screen.queryByTestId("project-detail-skeleton-sidebar")).not.toBeInTheDocument();
+ });
+
+ it("matches a saved custom sidebar width percentage during loading", () => {
+ mocks.defaultLayout = { content: 72, sidebar: 28 };
+ renderProjectDetail();
+
+ const sidebar = screen.getByTestId("project-detail-skeleton-sidebar");
+ expect(sidebar).toHaveStyle({ width: "28%" });
+ });
+
+ it("hides the desktop sidebar placeholder on mobile viewports", () => {
+ mocks.isMobile = true;
+ renderProjectDetail();
+
+ expect(screen.getByTestId("project-detail-skeleton")).toBeInTheDocument();
+ expect(screen.queryByTestId("project-detail-skeleton-sidebar")).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/views/projects/components/project-detail.tsx b/packages/views/projects/components/project-detail.tsx
index e2ce10609c..4659636a7e 100644
--- a/packages/views/projects/components/project-detail.tsx
+++ b/packages/views/projects/components/project-detail.tsx
@@ -82,7 +82,148 @@ import {
useOfferArchiveOnComplete,
useRestoreProjects,
} from "./project-archive";
-import { PAGE_GUTTER } from "../../layout/page-header";
+import { PageHeader, PAGE_GUTTER } from "../../layout/page-header";
+import { OBJECT_PAGE_BODY } from "../../layout/object-page";
+
+export const PROJECT_DETAIL_LAYOUT_ID = "multica_project_detail_layout";
+
+const PROJECT_SIDEBAR_PROPERTY_ROWS = 7;
+const PROJECT_SIDEBAR_ACTIVITY_ROWS = 3;
+
+/**
+ * Loading frame for ProjectDetail: mirrors the 48px header, tab slots, reading
+ * column, and saved desktop right-sidebar state so data landing causes no
+ * horizontal or vertical layout jump.
+ */
+export function ProjectDetailSkeleton({
+ sidebar = true,
+ layoutId = PROJECT_DETAIL_LAYOUT_ID,
+}: {
+ sidebar?: boolean;
+ layoutId?: string;
+} = {}) {
+ const isMobile = useIsMobile();
+ const { defaultLayout } = useDefaultLayout({ id: layoutId });
+ const sidebarOpen =
+ sidebar && !isMobile && getAnimatedRightSidebarInitialOpen(true, defaultLayout);
+ const restoredSidebarPercent =
+ typeof defaultLayout?.sidebar === "number" && defaultLayout.sidebar > 0
+ ? defaultLayout.sidebar
+ : undefined;
+
+ return (
+ <div
+ data-mc="object-page"
+ data-type="project"
+ data-testid="project-detail-skeleton"
+ aria-busy="true"
+ className="flex min-h-0 flex-1"
+ >
+ <div className="flex min-w-0 flex-1 flex-col">
+ <PageHeader>
+ <div className="flex min-w-0 flex-1 items-center gap-1 self-stretch">
+ <div className="flex h-7 items-center gap-2 px-2">
+ <Skeleton className="size-4 shrink-0 rounded-sm" />
+ <Skeleton className="h-4 w-28" />
+ </div>
+ <div
+ data-testid="project-detail-skeleton-tabs"
+ className="flex shrink-0 items-center self-stretch"
+ >
+ <div className="flex h-full items-center px-2.5">
+ <Skeleton className="h-3.5 w-14" />
+ </div>
+ <div className="flex h-full items-center px-2.5">
+ <Skeleton className="h-3.5 w-14" />
+ </div>
+ <div className="flex h-full items-center px-2.5">
+ <Skeleton className="h-3.5 w-12" />
+ </div>
+ </div>
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ <Skeleton className="size-7 rounded-md" />
+ </div>
+ </PageHeader>
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ <div className={cn(OBJECT_PAGE_BODY, "space-y-8")}>
+ <div className="flex items-center gap-3">
+ <Skeleton className="size-12 shrink-0 rounded-xl" />
+ <Skeleton className="h-7 w-56" />
+ </div>
+ <div className="space-y-2">
+ <div className="flex h-7 items-center">
+ <Skeleton className="h-4 w-24" />
+ </div>
+ <div className="space-y-2">
+ <Skeleton className="h-4 w-full" />
+ <Skeleton className="h-4 w-5/6" />
+ <Skeleton className="h-4 w-2/3" />
+ </div>
+ </div>
+ <div className="space-y-2">
+ <div className="flex h-7 items-center">
+ <Skeleton className="h-4 w-24" />
+ </div>
+ <Skeleton className="h-14 w-full rounded-lg" />
+ </div>
+ </div>
+ </div>
+ </div>
+ {sidebarOpen && (
+ <div
+ data-testid="project-detail-skeleton-sidebar"
+ className={cn(
+ "hidden shrink-0 overflow-hidden border-l p-4 [scrollbar-gutter:stable] md:block",
+ restoredSidebarPercent === undefined
+ ? "w-80"
+ : "min-w-[260px] max-w-[420px]",
+ )}
+ style={
+ restoredSidebarPercent !== undefined
+ ? { width: `${restoredSidebarPercent}%` }
+ : undefined
+ }
+ >
+ <div className="space-y-5">
+ <div>
+ <div className="mb-2 flex items-center px-2 py-1">
+ <Skeleton className="h-3.5 w-20" />
+ </div>
+ <div className="space-y-0.5 pl-2">
+ {Array.from({ length: PROJECT_SIDEBAR_PROPERTY_ROWS }, (_, i) => (
+ <div key={i} className="flex min-h-8 items-center gap-2">
+ <Skeleton className="h-3 w-16 shrink-0" />
+ <Skeleton className="h-4 w-24" />
+ </div>
+ ))}
+ </div>
+ </div>
+ <div>
+ <div className="mb-2 flex items-center px-2 py-1">
+ <Skeleton className="h-3.5 w-16" />
+ </div>
+ <div className="space-y-2 pl-2">
+ <Skeleton className="h-6 w-28" />
+ <Skeleton className="h-2 w-full rounded-full" />
+ </div>
+ </div>
+ <div>
+ <div className="mb-2 flex items-center px-2 py-1">
+ <Skeleton className="h-3.5 w-16" />
+ </div>
+ <div className="space-y-2.5 pl-2">
+ {Array.from({ length: PROJECT_SIDEBAR_ACTIVITY_ROWS }, (_, i) => (
+ <Skeleton key={i} className="h-8 w-full" />
+ ))}
+ </div>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
// ProjectDetail
@@ -181,7 +322,7 @@ export function ProjectDetail({ projectId }: { projectId: string }) {
// Sidebar panel
const { defaultLayout, onLayoutChanged } = useDefaultLayout({
- id: "multica_project_detail_layout",
+ id: PROJECT_DETAIL_LAYOUT_ID,
});
const sidebarRef = usePanelRef();
const rightSidebarShortcutTargetRef = useRef<HTMLDivElement | null>(null);
@@ -295,14 +436,7 @@ export function ProjectDetail({ projectId }: { projectId: string }) {
}, [project, deleteProject, router, wsPaths, t]);
if (isLoading || deleted) {
- return (
- <div className="mx-auto w-full max-w-4xl px-8 py-10 space-y-4">
- <Skeleton className="h-5 w-32" />
- <Skeleton className="h-8 w-64" />
- <Skeleton className="h-4 w-96" />
- <Skeleton className="h-40 w-full mt-8" />
- </div>
- );
+ return <ProjectDetailSkeleton sidebar={!isMobile && desktopSidebarOpen} />;
}
if (!project) {