You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2026/07/09 20:33:12 UTC

(airavata-custos) 07/08: Add allocation history tab and fix sign-out for CILogon

This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch web-changes
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit e54fdb27d8f09a651675b26d8058a66081000d2c
Author: lahiruj <la...@gmail.com>
AuthorDate: Wed Jul 8 16:36:23 2026 -0400

    Add allocation history tab and fix sign-out for CILogon
---
 .../api/auth/end-session/__tests__/route.test.ts   |  82 ++++++++++++++++
 web/src/app/api/auth/end-session/route.ts          |  36 +++++--
 .../core/allocations/__fixtures__/diffs.json       |  59 ++++++++++++
 .../core/allocations/__fixtures__/usage.json       |  34 +++++++
 .../__tests__/AllocationHistoryTab.test.tsx        |  93 ++++++++++++++++++
 .../__tests__/AllocationMembersTab.test.tsx        |  80 +++++++++++++++
 .../__tests__/AllocationOverviewTab.test.tsx       |  93 ++++++++++++++++++
 .../__tests__/AllocationUsageTab.test.tsx          |  94 ++++++++++++++++++
 .../components/AllocationHistoryTab.tsx            | 107 +++++++++++++++++++++
 .../projects/__tests__/ProjectMembersTab.test.tsx  |  69 +++++++++++++
 10 files changed, 738 insertions(+), 9 deletions(-)

diff --git a/web/src/app/api/auth/end-session/__tests__/route.test.ts b/web/src/app/api/auth/end-session/__tests__/route.test.ts
new file mode 100644
index 000000000..b8da9d4a5
--- /dev/null
+++ b/web/src/app/api/auth/end-session/__tests__/route.test.ts
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { NextRequest } from "next/server";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("@/shared/auth/auth", () => ({
+  auth: vi.fn(async () => ({ idToken: "id-token-abc" })),
+}));
+
+vi.mock("@/lib/env", () => ({
+  serverEnv: {
+    OIDC_ISSUER_URL: "https://idp.example.org",
+    OIDC_CLIENT_ID: "client-123",
+  },
+}));
+
+import { GET } from "../route";
+
+const fetchMock = vi.fn();
+vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
+
+function discoveryResponse(body: unknown, ok = true): Response {
+  return new Response(JSON.stringify(body), { status: ok ? 200 : 500 });
+}
+
+function request() {
+  return new NextRequest("https://portal.example.org/api/auth/end-session?callbackUrl=/sign-in");
+}
+
+afterEach(() => {
+  fetchMock.mockReset();
+});
+
+describe("end-session route", () => {
+  it("round-trips through the IdP when discovery advertises end_session_endpoint", async () => {
+    fetchMock.mockResolvedValueOnce(
+      discoveryResponse({ end_session_endpoint: "https://idp.example.org/logout" }),
+    );
+    const res = await GET(request());
+    const location = new URL(res.headers.get("location") as string);
+    expect(location.origin + location.pathname).toBe("https://idp.example.org/logout");
+    expect(location.searchParams.get("id_token_hint")).toBe("id-token-abc");
+    expect(location.searchParams.get("post_logout_redirect_uri")).toBe(
+      "https://portal.example.org/sign-in",
+    );
+  });
+
+  it("redirects straight to the callback when the issuer has no end_session_endpoint", async () => {
+    fetchMock.mockResolvedValueOnce(discoveryResponse({}));
+    const res = await GET(request());
+    expect(res.headers.get("location")).toBe("https://portal.example.org/sign-in");
+  });
+
+  it("redirects locally when discovery fails", async () => {
+    fetchMock.mockRejectedValueOnce(new Error("network"));
+    const res = await GET(request());
+    expect(res.headers.get("location")).toBe("https://portal.example.org/sign-in");
+  });
+
+  it("clears the session cookie regardless of the redirect target", async () => {
+    fetchMock.mockResolvedValueOnce(discoveryResponse({}));
+    const res = await GET(request());
+    const cookie = res.cookies.get("custos.session-token");
+    expect(cookie?.value).toBe("");
+    expect(cookie?.maxAge).toBe(0);
+  });
+});
diff --git a/web/src/app/api/auth/end-session/route.ts b/web/src/app/api/auth/end-session/route.ts
index ff8451b70..4b01045d6 100644
--- a/web/src/app/api/auth/end-session/route.ts
+++ b/web/src/app/api/auth/end-session/route.ts
@@ -34,6 +34,20 @@ function clearAuthCookies(res: NextResponse) {
   }
 }
 
+// Discover the end-session endpoint; some issuers (CILogon) don't have one.
+async function discoverEndSessionEndpoint(issuer: string): Promise<string | null> {
+  try {
+    const res = await fetch(`${issuer.replace(/\/$/, "")}/.well-known/openid-configuration`, {
+      cache: "no-store",
+    });
+    if (!res.ok) return null;
+    const doc = (await res.json()) as { end_session_endpoint?: unknown };
+    return typeof doc.end_session_endpoint === "string" ? doc.end_session_endpoint : null;
+  } catch {
+    return null;
+  }
+}
+
 export async function GET(request: NextRequest) {
   const callbackUrl = request.nextUrl.searchParams.get("callbackUrl") ?? "/sign-in";
   const origin = request.nextUrl.origin;
@@ -41,17 +55,21 @@ export async function GET(request: NextRequest) {
 
   const session = await auth();
   const idToken = session?.idToken ?? null;
-  const endSession = new URL(
-    `${serverEnv.OIDC_ISSUER_URL.replace(/\/$/, "")}/protocol/openid-connect/logout`,
-  );
-  endSession.searchParams.set("post_logout_redirect_uri", postLogout);
-  if (idToken) {
-    endSession.searchParams.set("id_token_hint", idToken);
-  } else {
-    endSession.searchParams.set("client_id", serverEnv.OIDC_CLIENT_ID);
+  const endpoint = await discoverEndSessionEndpoint(serverEnv.OIDC_ISSUER_URL);
+
+  let redirectTo = postLogout;
+  if (endpoint) {
+    const url = new URL(endpoint);
+    url.searchParams.set("post_logout_redirect_uri", postLogout);
+    if (idToken) {
+      url.searchParams.set("id_token_hint", idToken);
+    } else {
+      url.searchParams.set("client_id", serverEnv.OIDC_CLIENT_ID);
+    }
+    redirectTo = url.toString();
   }
 
-  const res = NextResponse.redirect(endSession.toString());
+  const res = NextResponse.redirect(redirectTo);
   clearAuthCookies(res);
   return res;
 }
diff --git a/web/src/features/core/allocations/__fixtures__/diffs.json b/web/src/features/core/allocations/__fixtures__/diffs.json
new file mode 100644
index 000000000..566f5e2da
--- /dev/null
+++ b/web/src/features/core/allocations/__fixtures__/diffs.json
@@ -0,0 +1,59 @@
+{
+  "alloc-001": [
+    {
+      "id": "diff-001",
+      "compute_allocation_id": "alloc-001",
+      "diff_type": "ALLOCATION_STATUS_CHANGE",
+      "new_su_amount": 250000,
+      "status": "ACTIVE",
+      "timestamp": "2026-04-01T00:00:00.000Z",
+      "description": "Allocation activated for the funding period."
+    },
+    {
+      "id": "diff-002",
+      "compute_allocation_id": "alloc-001",
+      "diff_type": "USAGE_UPDATE",
+      "new_su_amount": 250000,
+      "status": "ACTIVE",
+      "timestamp": "2026-05-15T08:30:00.000Z",
+      "description": "Recorded usage from a batch of GPU jobs."
+    },
+    {
+      "id": "diff-003",
+      "compute_allocation_id": "alloc-001",
+      "diff_type": "USAGE_UPDATE",
+      "new_su_amount": 250000,
+      "status": "ACTIVE",
+      "timestamp": "2026-06-20T14:05:00.000Z"
+    }
+  ],
+  "alloc-003": [
+    {
+      "id": "diff-101",
+      "compute_allocation_id": "alloc-003",
+      "diff_type": "ALLOCATION_STATUS_CHANGE",
+      "new_su_amount": 150000,
+      "status": "ACTIVE",
+      "timestamp": "2026-04-12T00:00:00.000Z",
+      "description": "Allocation activated."
+    },
+    {
+      "id": "diff-102",
+      "compute_allocation_id": "alloc-003",
+      "diff_type": "USAGE_UPDATE",
+      "new_su_amount": 350000,
+      "status": "ACTIVE",
+      "timestamp": "2026-05-20T09:15:00.000Z",
+      "description": "SU amount raised after an approved change request."
+    },
+    {
+      "id": "diff-103",
+      "compute_allocation_id": "alloc-003",
+      "diff_type": "ALLOCATION_STATUS_CHANGE",
+      "new_su_amount": 350000,
+      "status": "INACTIVE",
+      "timestamp": "2026-06-25T16:40:00.000Z",
+      "description": "Paused pending end-of-quarter review."
+    }
+  ]
+}
diff --git a/web/src/features/core/allocations/__fixtures__/usage.json b/web/src/features/core/allocations/__fixtures__/usage.json
new file mode 100644
index 000000000..0a6102a4a
--- /dev/null
+++ b/web/src/features/core/allocations/__fixtures__/usage.json
@@ -0,0 +1,34 @@
+{
+  "alloc-003": [
+    {
+      "id": "use-001",
+      "compute_allocation_id": "alloc-003",
+      "used_raw_amount": 1200,
+      "used_su_amount": 60000,
+      "last_updated": "2026-05-18T11:00:00.000Z",
+      "user_id": "user-pi-002",
+      "job_id": "job-5501",
+      "compute_allocation_resource_id": "res-a-gpu"
+    },
+    {
+      "id": "use-002",
+      "compute_allocation_id": "alloc-003",
+      "used_raw_amount": 800,
+      "used_su_amount": 20000,
+      "last_updated": "2026-05-22T09:30:00.000Z",
+      "user_id": "user-pi-002",
+      "job_id": "job-5502",
+      "compute_allocation_resource_id": "res-a-gpu"
+    },
+    {
+      "id": "use-003",
+      "compute_allocation_id": "alloc-003",
+      "used_raw_amount": 4000,
+      "used_su_amount": 24000,
+      "last_updated": "2026-06-01T15:45:00.000Z",
+      "user_id": "user-collab-009",
+      "job_id": "job-5510",
+      "compute_allocation_resource_id": "res-c-cpu"
+    }
+  ]
+}
diff --git a/web/src/features/core/allocations/__tests__/AllocationHistoryTab.test.tsx b/web/src/features/core/allocations/__tests__/AllocationHistoryTab.test.tsx
new file mode 100644
index 000000000..76e3fcdb5
--- /dev/null
+++ b/web/src/features/core/allocations/__tests__/AllocationHistoryTab.test.tsx
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { render, screen, within } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import type { AllocationDiff, ComputeAllocation } from "../schemas";
+
+let diffs: AllocationDiff[] = [];
+
+vi.mock("../queries", () => ({
+  useAllocationDiffs: () => ({ data: diffs, isLoading: false, error: null, refetch: vi.fn() }),
+}));
+
+import { AllocationHistoryTab } from "../components/AllocationHistoryTab";
+
+const allocation: ComputeAllocation = {
+  id: "alloc-001",
+  project_id: "project-001",
+  name: "Genomic GPU Pool",
+  status: "ACTIVE",
+  compute_cluster_id: "cluster-a",
+  initial_su_amount: 250000,
+  start_time: "2026-04-01T00:00:00.000Z",
+  end_time: "2027-03-31T00:00:00.000Z",
+};
+
+beforeEach(() => {
+  diffs = [
+    {
+      id: "diff-a",
+      compute_allocation_id: "alloc-001",
+      diff_type: "ALLOCATION_STATUS_CHANGE",
+      new_su_amount: 250000,
+      status: "ACTIVE",
+      timestamp: "2026-04-01T00:00:00.000Z",
+      description: "Activated for the funding period.",
+    },
+    {
+      id: "diff-b",
+      compute_allocation_id: "alloc-001",
+      diff_type: "USAGE_UPDATE",
+      new_su_amount: 250000,
+      status: "ACTIVE",
+      timestamp: "2026-06-20T14:05:00.000Z",
+    },
+    {
+      id: "diff-c",
+      compute_allocation_id: "alloc-001",
+      diff_type: "RESOURCE_ATTACHED",
+      status: "INACTIVE",
+      timestamp: "2026-05-15T08:30:00.000Z",
+    },
+  ];
+});
+
+describe("<AllocationHistoryTab />", () => {
+  it("lists diffs newest first", () => {
+    render(<AllocationHistoryTab allocation={allocation} />);
+    const rows = screen.getAllByRole("row").slice(1); // drop the header row
+    expect(within(rows[0] as HTMLElement).getByText("USAGE_UPDATE")).toBeInTheDocument();
+    expect(within(rows[1] as HTMLElement).getByText("RESOURCE_ATTACHED")).toBeInTheDocument();
+    expect(within(rows[2] as HTMLElement).getByText("ALLOCATION_STATUS_CHANGE")).toBeInTheDocument();
+  });
+
+  it("renders the status badge and a placeholder for a missing SU amount", () => {
+    render(<AllocationHistoryTab allocation={allocation} />);
+    expect(screen.getByText("INACTIVE")).toBeInTheDocument();
+    const resourceRow = screen.getByText("RESOURCE_ATTACHED").closest("tr");
+    expect(within(resourceRow as HTMLElement).getByText("-")).toBeInTheDocument();
+  });
+
+  it("shows the empty state when there is no history", () => {
+    diffs = [];
+    render(<AllocationHistoryTab allocation={allocation} />);
+    expect(
+      screen.getByRole("heading", { name: /no history recorded for this allocation/i }),
+    ).toBeInTheDocument();
+  });
+});
diff --git a/web/src/features/core/allocations/__tests__/AllocationMembersTab.test.tsx b/web/src/features/core/allocations/__tests__/AllocationMembersTab.test.tsx
new file mode 100644
index 000000000..c9b8eff55
--- /dev/null
+++ b/web/src/features/core/allocations/__tests__/AllocationMembersTab.test.tsx
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { render, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import type { ComputeAllocation } from "../schemas";
+
+const members = [
+  {
+    id: "m-1",
+    compute_allocation_id: "alloc-001",
+    user_id: "u-1",
+    display_name: "Paula Ivey",
+    email: "paula@sample.example.edu",
+    role: "PI",
+    membership_status: "ACTIVE",
+  },
+  {
+    id: "m-2",
+    compute_allocation_id: "alloc-001",
+    user_id: "u-2",
+    display_name: "Carl Osei",
+    email: "carl@sample.example.edu",
+    role: "CO_PI",
+    membership_status: "ACTIVE",
+  },
+  {
+    id: "m-3",
+    compute_allocation_id: "alloc-001",
+    user_id: "u-3",
+    display_name: "Mina Frey",
+    email: "mina@sample.example.edu",
+    role: "MEMBER",
+    membership_status: "ACTIVE",
+  },
+];
+
+const mutation = { mutate: vi.fn(), isPending: false };
+vi.mock("../queries", () => ({
+  useAllocationMembers: () => ({ data: members, isLoading: false, error: null, refetch: vi.fn() }),
+  useAddMember: () => mutation,
+  useUpdateMember: () => mutation,
+  useRemoveMember: () => mutation,
+}));
+
+import { AllocationMembersTab } from "../components/AllocationMembersTab";
+
+const allocation = { id: "alloc-001", name: "Test Allocation" } as ComputeAllocation;
+
+describe("<AllocationMembersTab />", () => {
+  it("offers no Edit or Remove for PI or Co-PI members", () => {
+    render(<AllocationMembersTab allocation={allocation} canManage={true} />);
+    for (const name of ["Paula Ivey", "Carl Osei"]) {
+      expect(screen.queryByRole("button", { name: `Edit ${name}` })).not.toBeInTheDocument();
+      expect(screen.queryByRole("button", { name: `Remove ${name}` })).not.toBeInTheDocument();
+    }
+    expect(screen.getByRole("button", { name: "Edit Mina Frey" })).toBeInTheDocument();
+    expect(screen.getByRole("button", { name: "Remove Mina Frey" })).toBeInTheDocument();
+  });
+
+  it("offers no actions without manage permission", () => {
+    render(<AllocationMembersTab allocation={allocation} canManage={false} />);
+    expect(screen.queryByRole("button", { name: /^Remove / })).not.toBeInTheDocument();
+    expect(screen.queryByRole("button", { name: /^Edit / })).not.toBeInTheDocument();
+  });
+});
diff --git a/web/src/features/core/allocations/__tests__/AllocationOverviewTab.test.tsx b/web/src/features/core/allocations/__tests__/AllocationOverviewTab.test.tsx
new file mode 100644
index 000000000..3113d278f
--- /dev/null
+++ b/web/src/features/core/allocations/__tests__/AllocationOverviewTab.test.tsx
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import type { AttachedResource, ComputeAllocation } from "../schemas";
+
+let attached: AttachedResource[] = [];
+
+vi.mock("../queries", () => ({
+  useAllocationResources: () => ({
+    data: attached,
+    isLoading: false,
+    error: null,
+    refetch: vi.fn(),
+  }),
+}));
+
+vi.mock("@/features/core/resources/queries", () => ({
+  // res-a-gpu has an effective rate; res-b-gpu 404s (query error, no data).
+  useEffectiveRate: (id: string) =>
+    id === "res-a-gpu"
+      ? { data: { rate: 0.5 }, isError: false }
+      : { data: undefined, isError: true },
+}));
+
+import { AllocationOverviewTab } from "../components/AllocationOverviewTab";
+
+const allocation: ComputeAllocation = {
+  id: "alloc-001",
+  project_id: "project-001",
+  name: "Genomic GPU Pool",
+  status: "ACTIVE",
+  compute_cluster_id: "cluster-a",
+  initial_su_amount: 250000,
+  start_time: "2026-04-01T00:00:00.000Z",
+  end_time: "2027-03-31T00:00:00.000Z",
+};
+
+beforeEach(() => {
+  attached = [
+    {
+      id: "res-a-gpu",
+      name: "ClusterA GPU",
+      resource_type: "GPU",
+      resource_amount: 50000,
+      compute_cluster_id: "cluster-a",
+    },
+    {
+      id: "res-b-gpu",
+      name: "ClusterB GPU A100",
+      resource_type: "GPU",
+      resource_amount: 16000,
+      compute_cluster_id: "cluster-b",
+    },
+  ];
+});
+
+describe("<AllocationOverviewTab />", () => {
+  it("renders attached resource names, types, and amounts", () => {
+    render(<AllocationOverviewTab allocation={allocation} />);
+    expect(screen.getByText("ClusterA GPU")).toBeInTheDocument();
+    expect(screen.getByText("ClusterB GPU A100")).toBeInTheDocument();
+    expect(screen.getByText("50,000")).toBeInTheDocument();
+  });
+
+  it("renders the effective rate, omitting it when the lookup 404s", () => {
+    render(<AllocationOverviewTab allocation={allocation} />);
+    expect(screen.getByText("0.5 SU/unit")).toBeInTheDocument();
+    // res-b-gpu has no effective rate, so only one rate line shows.
+    expect(screen.getAllByText(/SU\/unit/)).toHaveLength(1);
+  });
+
+  it("shows the empty state when nothing is attached", () => {
+    attached = [];
+    render(<AllocationOverviewTab allocation={allocation} />);
+    expect(screen.getByText(/no resources attached/i)).toBeInTheDocument();
+  });
+});
diff --git a/web/src/features/core/allocations/__tests__/AllocationUsageTab.test.tsx b/web/src/features/core/allocations/__tests__/AllocationUsageTab.test.tsx
new file mode 100644
index 000000000..11da594e5
--- /dev/null
+++ b/web/src/features/core/allocations/__tests__/AllocationUsageTab.test.tsx
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import type { AllocationUsage, ComputeAllocation } from "../schemas";
+
+let usage: AllocationUsage[] = [];
+
+vi.mock("../queries", () => ({
+  useAllocationUsage: () => ({ data: usage, isLoading: false, error: null, refetch: vi.fn() }),
+}));
+
+vi.mock("@/features/core/resources/queries", () => ({
+  useResourceSummaries: () => ({
+    data: [
+      { id: "res-a-gpu", name: "ClusterA GPU" },
+      { id: "res-c-cpu", name: "ClusterC RM" },
+    ],
+    isLoading: false,
+    error: null,
+    refetch: vi.fn(),
+  }),
+}));
+
+import { AllocationUsageTab } from "../components/AllocationUsageTab";
+
+const allocation: ComputeAllocation = {
+  id: "alloc-003",
+  project_id: "project-002",
+  name: "Plasma GPU",
+  status: "ACTIVE",
+  compute_cluster_id: "cluster-a",
+  initial_su_amount: 250000,
+  start_time: "2026-04-12T00:00:00.000Z",
+  end_time: "2027-04-11T00:00:00.000Z",
+};
+
+function usageRow(overrides: Partial<AllocationUsage>): AllocationUsage {
+  return {
+    id: "use-x",
+    compute_allocation_id: "alloc-003",
+    used_raw_amount: 0,
+    used_su_amount: 0,
+    last_updated: "2026-05-18T11:00:00.000Z",
+    user_id: "user-pi-002",
+    job_id: "job-1",
+    compute_allocation_resource_id: "res-a-gpu",
+    ...overrides,
+  };
+}
+
+beforeEach(() => {
+  usage = [
+    usageRow({ id: "use-001", used_su_amount: 60000, compute_allocation_resource_id: "res-a-gpu" }),
+    usageRow({ id: "use-002", used_su_amount: 20000, compute_allocation_resource_id: "res-a-gpu" }),
+    usageRow({ id: "use-003", used_su_amount: 24000, compute_allocation_resource_id: "res-c-cpu" }),
+  ];
+});
+
+describe("<AllocationUsageTab />", () => {
+  it("renders a per-resource bar with summed SU, one per resource", () => {
+    render(<AllocationUsageTab allocation={allocation} />);
+    expect(screen.getByText("ClusterA GPU")).toBeInTheDocument();
+    expect(screen.getByText("80,000 SU")).toBeInTheDocument();
+    expect(screen.getByText("ClusterC RM")).toBeInTheDocument();
+    expect(screen.getByText("24,000 SU")).toBeInTheDocument();
+  });
+
+  it("keeps the total usage bar", () => {
+    render(<AllocationUsageTab allocation={allocation} />);
+    expect(screen.getByText("104,000 / 250,000 SUs")).toBeInTheDocument();
+  });
+
+  it("shows the empty state when there is no usage", () => {
+    usage = [];
+    render(<AllocationUsageTab allocation={allocation} />);
+    expect(screen.getByRole("heading", { name: /no usage recorded/i })).toBeInTheDocument();
+  });
+});
diff --git a/web/src/features/core/allocations/components/AllocationHistoryTab.tsx b/web/src/features/core/allocations/components/AllocationHistoryTab.tsx
new file mode 100644
index 000000000..f94b17012
--- /dev/null
+++ b/web/src/features/core/allocations/components/AllocationHistoryTab.tsx
@@ -0,0 +1,107 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+"use client";
+
+import { DataTable, type DataTableColumn } from "@/shared/ui/DataTable";
+import { EmptyState } from "@/shared/ui/EmptyState";
+import { ErrorState } from "@/shared/ui/ErrorState";
+import { TableSkeleton } from "@/shared/ui/Loading";
+import { StatusBadge, statusBadgeVariantFromAllocationStatus } from "@/shared/ui/StatusBadge";
+import { useAllocationDiffs } from "../queries";
+import type { AllocationDiff, ComputeAllocation } from "../schemas";
+
+export type AllocationHistoryTabProps = {
+  allocation: ComputeAllocation;
+};
+
+function formatDateTime(iso: string): string {
+  try {
+    return new Date(iso).toLocaleString(undefined, {
+      year: "numeric",
+      month: "short",
+      day: "numeric",
+      hour: "2-digit",
+      minute: "2-digit",
+    });
+  } catch {
+    return iso;
+  }
+}
+
+export function AllocationHistoryTab({ allocation }: AllocationHistoryTabProps) {
+  const query = useAllocationDiffs(allocation.id);
+
+  if (query.isLoading) return <TableSkeleton rows={3} columns={5} />;
+  if (query.error) {
+    return <ErrorState message={(query.error as Error).message} onRetry={() => query.refetch()} />;
+  }
+  const rows = [...(query.data ?? [])].sort(
+    (a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
+  );
+
+  if (rows.length === 0) {
+    return <EmptyState heading="No history recorded for this allocation." />;
+  }
+
+  const columns: Array<DataTableColumn<AllocationDiff>> = [
+    {
+      key: "when",
+      header: "When",
+      cell: (row) => (
+        <span className="text-sm text-muted-foreground">{formatDateTime(row.timestamp)}</span>
+      ),
+    },
+    {
+      key: "type",
+      header: "Type",
+      cell: (row) => <span className="text-sm">{row.diff_type}</span>,
+    },
+    {
+      key: "su",
+      header: "New SU amount",
+      align: "right",
+      cell: (row) => (
+        <span className="tabular-nums">
+          {typeof row.new_su_amount === "number"
+            ? new Intl.NumberFormat().format(row.new_su_amount)
+            : "-"}
+        </span>
+      ),
+    },
+    {
+      key: "status",
+      header: "Status",
+      cell: (row) => (
+        <StatusBadge
+          variant={statusBadgeVariantFromAllocationStatus(row.status)}
+          label={row.status}
+        />
+      ),
+    },
+    {
+      key: "description",
+      header: "Description",
+      cell: (row) =>
+        row.description ? (
+          <span className="text-sm text-muted-foreground">{row.description}</span>
+        ) : null,
+    },
+  ];
+
+  return <DataTable columns={columns} rows={rows} rowKey={(row) => row.id} />;
+}
diff --git a/web/src/features/core/projects/__tests__/ProjectMembersTab.test.tsx b/web/src/features/core/projects/__tests__/ProjectMembersTab.test.tsx
new file mode 100644
index 000000000..39a2a44d6
--- /dev/null
+++ b/web/src/features/core/projects/__tests__/ProjectMembersTab.test.tsx
@@ -0,0 +1,69 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { fireEvent, render, screen, within } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+
+function member(over: Record<string, unknown>) {
+  return {
+    id: "pm-x",
+    project_id: "p-1",
+    user_id: "u-x",
+    email: "x@sample.example.edu",
+    display_name: "Member X",
+    role: "MEMBER",
+    status: "ACTIVE",
+    added_time: "2026-01-01T00:00:00.000Z",
+    allocations: [],
+    ...over,
+  };
+}
+
+const members = [
+  member({ id: "pm-1", display_name: "Ada Pi", role: "PI" }),
+  member({ id: "pm-2", display_name: "Ben Copi", role: "CO_PI" }),
+  member({ id: "pm-3", display_name: "Cira Member", role: "MEMBER" }),
+];
+
+const mutation = { mutate: vi.fn(), isPending: false };
+vi.mock("../queries", () => ({
+  useProjectMembers: () => ({ data: members, isLoading: false, error: null, refetch: vi.fn() }),
+  useUpdateProjectMember: () => mutation,
+  useRemoveProjectMember: () => mutation,
+}));
+
+import { ProjectMembersTab } from "../components/ProjectMembersTab";
+
+describe("<ProjectMembersTab />", () => {
+  it("offers no Edit or Remove for PI or Co-PI members", () => {
+    render(<ProjectMembersTab projectId="p-1" canManage={true} />);
+    for (const name of ["Ada Pi", "Ben Copi"]) {
+      expect(screen.queryByRole("button", { name: `Edit ${name}` })).not.toBeInTheDocument();
+      expect(screen.queryByRole("button", { name: `Remove ${name}` })).not.toBeInTheDocument();
+    }
+    expect(screen.getByRole("button", { name: "Edit Cira Member" })).toBeInTheDocument();
+    expect(screen.getByRole("button", { name: "Remove Cira Member" })).toBeInTheDocument();
+  });
+
+  it("limits the edit role picker to Member and Allocation Manager", () => {
+    render(<ProjectMembersTab projectId="p-1" canManage={true} />);
+    fireEvent.click(screen.getByRole("button", { name: "Edit Cira Member" }));
+    const select = screen.getByLabelText("Role");
+    const options = within(select).getAllByRole("option").map((o) => o.textContent);
+    expect(options).toEqual(["Allocation Manager", "Member"]);
+  });
+});