[cueweb/docs] Add Allocations page (CueCommander parity)#2410
[cueweb/docs] Add Allocations page (CueCommander parity)#2410ramonfigueiredo wants to merge 2 commits into
Conversation
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.
📝 WalkthroughWalkthroughThis 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. ChangesAllocations Page Feature
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cueweb/app/api/allocation/getallocations/route.ts (1)
25-28: ⚡ Quick winRedundant method validation in method-specific route handler.
The method check is unnecessary because Next.js App Router only invokes the
POSTexport for POST requests. Themethod !== '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
📒 Files selected for processing (8)
cueweb/app/__tests__/allocations/allocation_utils.test.tscueweb/app/__tests__/utils/allocation_get_utils.test.tscueweb/app/allocations/allocation-columns.tsxcueweb/app/allocations/allocation-utils.tscueweb/app/allocations/page.tsxcueweb/app/api/allocation/getallocations/route.tscueweb/app/utils/get_utils.tscueweb/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.

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).
[cueweb/docs] Document the Allocations page
Documents CueWeb's CueCommander Allocations page across the CueWeb docs.
LLM usage disclosure
Parts of this solution's implementation were developed with assistance from Claude Opus.