Skip to content

[cueweb/docs] Add Allocations page (CueCommander parity)#2410

Open
ramonfigueiredo wants to merge 2 commits into
AcademySoftwareFoundation:masterfrom
ramonfigueiredo:cueweb-allocations-page
Open

[cueweb/docs] Add Allocations page (CueCommander parity)#2410
ramonfigueiredo wants to merge 2 commits into
AcademySoftwareFoundation:masterfrom
ramonfigueiredo:cueweb-allocations-page

Conversation

@ramonfigueiredo

@ramonfigueiredo ramonfigueiredo commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Related Issues

Main issue:

Issues related to this PR:

Summarize your change.

[cueweb] Add Allocations page (CueCommander parity)

Replicates the CueGUI CueCommander Allocations window at /allocations (the sidebar entry previously 404'd).

  • New proxy route app/api/allocation/getallocations -> facility.Allocation Interface/GetAll (unwraps the gateway's nested {allocations:{allocations}}).
  • get_utils: Allocation + AllocationStats types and getAllocations().
  • SimpleDataTable gains a read-only isAllocationsTable variant (no row context menu, allocation-specific filter/empty-state copy), mirroring isProcsTable.
  • allocation-columns.tsx matches CueGUI's columns: Name (links to /hosts?allocation=), Tag, a cores group (Cores, Idle, Locked, Down, Repair) and a hosts group (Hosts, Locked, Down, Repair). Numeric columns sort by value; cores render as integers.
  • allocation-utils.ts: the Down cores / Repair cores / Repair hosts columns are not in AllocationStats, so they are derived by aggregating the host list on allocName (computeAllocationHostStats / buildAllocationRows). The page fetches hosts once (best-effort - those columns fall back to 0 if it fails), not per allocation.
  • app/allocations/page.tsx: client page with 30s auto-refresh, loading skeletons, and an inline error + Retry state.
  • Tests: Jest coverage for getAllocations and the host-stat aggregation.

[cueweb/docs] Document the Allocations page

Documents CueWeb's CueCommander Allocations page across the CueWeb docs.

  • User guide (cueweb-user-guide.md): new Allocations section with the menu, page, Columns chooser, and filter screenshots, an Allocation columns table (Name, Tag, cores group, hosts group), and the click-through to the hosts list scoped to the allocation.
  • Overview (other-guides/cueweb.md): add an Allocations feature entry.
  • Reference (reference/cueweb.md): add an Allocations behavior section (data source, columns, the Down/Repair columns derived from the host list, read-only isAllocationsTable), list the GetAll RPC and the /api/allocation/getallocations proxy route, and mark the Allocations route implemented in the roadmap.
  • Developer guide (cueweb-development.md): note the SimpleDataTable isAllocationsTable flag.
  • Add Allocations screenshots (light + dark) for the page, columns, menu, and search.

LLM usage disclosure

Parts of this solution's implementation were developed with assistance from Claude Opus.

Replicates the CueGUI CueCommander Allocations window at /allocations (the sidebar entry previously 404'd).

- New proxy route app/api/allocation/getallocations -> facility.Allocation Interface/GetAll (unwraps the gateway's nested {allocations:{allocations}}).
- get_utils: Allocation + AllocationStats types and getAllocations().
- SimpleDataTable gains a read-only isAllocationsTable variant (no row context menu, allocation-specific filter/empty-state copy), mirroring isProcsTable.
- allocation-columns.tsx matches CueGUI's columns: Name (links to /hosts?allocation=<name>), Tag, a cores group (Cores, Idle, Locked, Down, Repair) and a hosts group (Hosts, Locked, Down, Repair). Numeric columns sort by value; cores render as integers.
- allocation-utils.ts: the Down cores / Repair cores / Repair hosts columns are not in AllocationStats, so they are derived by aggregating the host list on allocName (computeAllocationHostStats / buildAllocationRows). The page fetches hosts once (best-effort - those columns fall back to 0 if it fails), not per allocation.
- app/allocations/page.tsx: client page with 30s auto-refresh, loading skeletons, and an inline error + Retry state.
- Tests: Jest coverage for getAllocations and the host-stat aggregation.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a complete allocations listing page for the CueWeb UI, including a backend proxy, client fetch/types, host-derived row enrichment, table column definitions, a polling page component, SimpleDataTable integration, tests, and documentation.

Changes

Allocations Page Feature

Layer / File(s) Summary
Data layer: Allocation type and API fetching
cueweb/app/utils/get_utils.ts, cueweb/app/api/allocation/getallocations/route.ts, cueweb/app/__tests__/utils/allocation_get_utils.test.ts
Allocation type includes optional billable and stats fields. API route POST /api/allocation/getallocations forwards to the RPC /facility.AllocationInterface/GetAll and unwraps the nested response. getAllocations() fetches from the route and returns [] for non-array responses; tests validate the client request/response behavior.
Row enrichment: Host statistics aggregation
cueweb/app/allocations/allocation-utils.ts, cueweb/app/__tests__/allocations/allocation_utils.test.ts
AllocationRow extends Allocation with downCores, repairCores, and repairHosts. computeAllocationHostStats() aggregates hosts by allocName, summing DOWN/REPAIR cores and counting REPAIR hosts. buildAllocationRows() merges stats into allocations, defaulting missing stats to zeros; tests cover aggregation and merging edge cases.
Table columns: Allocation field definitions
cueweb/app/allocations/allocation-columns.tsx
allocationColumns defines TanStack table columns with a sortableHeader factory, asInt rounding helper, linkable allocation names (navigates to hosts filtered by allocation), and numeric accessors for cores and host counts.
Allocations page component: Loading and polling
cueweb/app/allocations/page.tsx
AllocationsPage fetches allocations on mount and polls periodically. It performs a required primary fetch via getAllocations() and a best-effort getHosts() fetch to compute derived stats, preserves prior rows on transient failures, guards against race conditions, and renders skeletons, an error banner with retry, or SimpleDataTable.
SimpleDataTable integration: Allocations variant
cueweb/components/ui/simple-data-table.tsx
Adds isAllocationsTable prop to enable allocations-specific UX: search placeholder/aria-label for allocation filtering, disables row context menus for allocations, and shows allocations-specific empty-state icon (PieChart), title, and description.

Sequence Diagram(s)

sequenceDiagram
  participant Client as AllocationsPage
  participant getAlloc as getAllocations()
  participant API as POST /api/allocation/getallocations
  participant RPC as facility.AllocationInterface/GetAll
  participant getHosts as getHosts()
  participant Compute as computeAllocationHostStats
  participant Build as buildAllocationRows

  Client->>getAlloc: request allocations
  getAlloc->>API: POST (empty body)
  API->>RPC: handleRoute -> GetAll
  RPC-->>API: RPC response
  API-->>getAlloc: flattened Allocation[]
  getAlloc-->>Client: allocations
  Client->>getHosts: best-effort hosts fetch
  getHosts-->>Client: hosts or error
  Client->>Compute: computeAllocationHostStats(hosts)
  Compute-->>Build: allocation stats
  Client->>Build: buildAllocationRows(allocations, stats)
  Build-->>Client: AllocationRow[]
  Client->>Client: render SimpleDataTable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #2298: Implements the /allocations page, API proxy, and client-side allocation row building that correspond to the issue's requested feature.

Possibly related PRs

Suggested reviewers

  • DiegoTavares
  • lithorus

Poem

🐰 I hopped through routes and rows today,
Collected cores where hosts decay—
Rows enriched, a pie icon gleams,
Polls and tests and docs in streams.
Hooray, the Allocations display!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references 'Add Allocations page' which is the primary feature across multiple files (page component, columns, utilities, API route), aligning with the main objective of implementing the Allocations feature for CueCommander parity.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ramonfigueiredo

Copy link
Copy Markdown
Collaborator Author
image

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
cueweb/app/api/allocation/getallocations/route.ts (1)

25-28: ⚡ Quick win

Redundant method validation in method-specific route handler.

The method check is unnecessary because Next.js App Router only invokes the POST export for POST requests. The method !== 'POST' branch can never execute.

♻️ Simplify by removing the dead check
 export async function POST(request: NextRequest) {
   const endpoint = "/facility.AllocationInterface/GetAll";
-  const method = request.method;
-  if (method !== 'POST') {
-    return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 });
-  }

   let parsed: unknown = {};
   try {
     parsed = await request.json();
   } catch {
     // Empty body is acceptable - GetAll takes no parameters.
   }
   const body = JSON.stringify(parsed ?? {});

-  const response = await handleRoute(method, endpoint, body);
+  const response = await handleRoute("POST", endpoint, body);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cueweb/app/api/allocation/getallocations/route.ts` around lines 25 - 28, The
method check using the local variable "method" and the if-block that checks
"method !== 'POST'" is dead code in this POST route handler; remove the const
method = request.method and the entire if (method !== 'POST') { ... } branch so
the handler relies on Next.js App Router calling the exported POST function only
for POST requests (locate and edit the exported POST handler in route.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cueweb/app/api/allocation/getallocations/route.ts`:
- Around line 25-28: The method check using the local variable "method" and the
if-block that checks "method !== 'POST'" is dead code in this POST route
handler; remove the const method = request.method and the entire if (method !==
'POST') { ... } branch so the handler relies on Next.js App Router calling the
exported POST function only for POST requests (locate and edit the exported POST
handler in route.ts).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 304ea9d5-6d7b-4068-98cb-4d1e49a23135

📥 Commits

Reviewing files that changed from the base of the PR and between de826ac and 2d38000.

📒 Files selected for processing (8)
  • cueweb/app/__tests__/allocations/allocation_utils.test.ts
  • cueweb/app/__tests__/utils/allocation_get_utils.test.ts
  • cueweb/app/allocations/allocation-columns.tsx
  • cueweb/app/allocations/allocation-utils.ts
  • cueweb/app/allocations/page.tsx
  • cueweb/app/api/allocation/getallocations/route.ts
  • cueweb/app/utils/get_utils.ts
  • cueweb/components/ui/simple-data-table.tsx

Documents CueWeb's CueCommander Allocations page across the CueWeb docs.

- User guide (cueweb-user-guide.md): new Allocations section with the menu, page, Columns chooser, and filter screenshots, an Allocation columns table (Name, Tag, cores group, hosts group), and the click-through to the hosts list scoped to the allocation.
- Overview (other-guides/cueweb.md): add an Allocations feature entry.
- Reference (reference/cueweb.md): add an Allocations behavior section (data source, columns, the Down/Repair columns derived from the host list, read-only isAllocationsTable), list the GetAll RPC and the /api/allocation/getallocations proxy route, and mark the Allocations route implemented in the roadmap.
- Developer guide (cueweb-development.md): note the SimpleDataTable isAllocationsTable flag.
- Add Allocations screenshots (light + dark) for the page, columns, menu, and search.
@ramonfigueiredo ramonfigueiredo changed the title [cueweb] Add Allocations page (CueCommander parity) [cueweb/docs] Add Allocations page (CueCommander parity) Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant