Repository navigation
Move the MiroFish-inspired Swarm Lab into the admin dashboard - #16
Conversation
The Swarm Lab was reachable at the standalone /mirofish route and linked from the delegate workspace sidebar, which exposed an internal, synthetic scenario simulator to every signed-in delegate. It belongs in the private administrator control room. - Replace app/c8f2x9/k7m3/page.tsx with a server component that calls requireAdmin() and redirects to /c8f2x9 when the signed admin session cookie is missing or invalid. The guard runs before any client code is sent, matching app/admin/analytics and app/admin/referrals. - Move the existing client dashboard into components/admin-dashboard.tsx, renamed AdminDashboard, with an Overview / Swarm Lab tab switch. Every existing function is preserved: user management, weekly/monthly/custom passes, pass revocation, the AI provider test, and the Analytics and Referrals links. - Delete app/mirofish/page.tsx and drop the Swarm Lab entry plus its active-path special case from components/sidebar-nav.tsx. - Add an `embedded` prop to MirofishConsole so it renders in normal document flow instead of the workspace shell's fixed-height scroll column, and demote its inner <main> to a <div> so it does not nest a second landmark inside the dashboard's <main>. The simulator's synthetic and local-only caveats are unchanged and remain visible in every stage. Verified: typecheck, 151/151 tests, production build, and lint (0 errors, 5 pre-existing warnings in untouched files). Unauthenticated GET /c8f2x9/k7m3 returns 307 to /c8f2x9, /mirofish returns 404, and a forged admin_session cookie is still rejected.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -67 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
| /** Fetches the admin user registry from the API. */ | ||
| const fetchUsers = useCallback(async () => { | ||
| try { | ||
| const res = await fetch("/api/c8f2x9/users"); |
There was a problem hiding this comment.
Suggestion: This uses the endpoint's default 50-user page and never fetches later pages, making remaining users unavailable to search or manage.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Incomplete implementation
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** components/admin-dashboard.tsx
**Line:** 136:136
**Comment:**
*Incomplete Implementation: This uses the endpoint's default 50-user page and never fetches later pages, making remaining users unavailable to search or manage.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
|
||
| /** Signs out of the admin session and returns to the login gate. */ | ||
| async function handleLogout() { | ||
| await fetch("/api/c8f2x9/login", { method: "DELETE" }); |
There was a problem hiding this comment.
Suggestion: When the DELETE endpoint returns 503 because server-side revocation failed, this still redirects silently, leaving copied admin cookies usable without warning.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Security
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** components/admin-dashboard.tsx
**Line:** 200:200
**Comment:**
*Security: When the DELETE endpoint returns 503 because server-side revocation failed, this still redirects silently, leaving copied admin cookies usable without warning.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| const response = await fetch("/api/c8f2x9/grant-subscription", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ uid, expiresAt: customGrant.date }), |
There was a problem hiding this comment.
Suggestion: The endpoint floors the requested date to whole days before adding it, so this grant may expire almost 24 hours before the selected day's end.
Assessment: 🟠 Major · 🔁 Occurrence: Often · 🏷️ Logic error
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** components/admin-dashboard.tsx
**Line:** 241:241
**Comment:**
*Logic Error: The endpoint floors the requested date to whole days before adding it, so this grant may expire almost 24 hours before the selected day's end.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
CodeAnt Nitpicks4 code suggestions1. Because
|
User description
The Swarm Lab was reachable at the standalone
/mirofishroute and linked from the delegate workspace sidebar, which exposed an internal, synthetic scenario simulator to every signed-in delegate. It belongs in the private administrator control room.Changes
app/c8f2x9/k7m3/page.tsx— now a server component that callsrequireAdmin()and redirects to/c8f2x9when the signed admin session cookie is missing or invalid. The guard runs before any client code is sent, matching the existingapp/admin/analyticsandapp/admin/referralspages. Auth is not weakened in any way.components/admin-dashboard.tsx(new) — the former client page, moved verbatim and renamedAdminDashboard, plus an accessible Overview / Swarm Lab tab switch (role="tablist"/tab/tabpanel). Every existing function is preserved: user management, weekly / monthly / custom-date passes, pass revocation, referral-link copy, the AI provider test, and the Analytics and Referrals links.app/mirofish/page.tsx— deleted.components/sidebar-nav.tsx— removed the Swarm Lab entry, its active-path special case, and the now-unusedNetworkimport, from both the desktop sidebar and the mobile nav.components/mirofish-console.tsx— added anembeddedprop so the console renders in normal document flow instead of the workspace shell's fixed-height scroll column, and demoted its inner<main>to a<div>so it does not nest a second landmark inside the dashboard's<main>.The simulator's synthetic and local-only caveats are unchanged and still visible in every stage ("Synthetic scenario, not market evidence", "Rule-based local simulation · no live LLM, OASIS, Zep, or real delegate data", "Local-only", and the MiroFish workflow-reference footer).
Verification
pnpm typecheckpnpm testpnpm build/mirofishabsent from the route listpnpm lintRuntime checks against the production build:
GET /c8f2x9/k7m3unauthenticated → 307 →/c8f2x9✅GET /c8f2x9/k7m3with a forgedadmin_sessioncookie → 307 →/c8f2x9(fails closed) ✅GET /mirofish→ 404 ✅GET /c8f2x9login gate → 200 ✅Note: the preview environment has placeholder Supabase settings, so the admin login flow itself cannot be completed here. The redirect was verified without bypassing authentication; the dashboard UI was confirmed to render (both panels, all five Swarm Lab stages, all caveats) via a temporary local scratch route that was deleted before committing.
CodeAnt-AI Description
Restrict Swarm Lab to administrators and add it to the admin dashboard
What Changed
Impact
✅ Swarm Lab limited to administrator sessions✅ Internal simulator removed from delegate navigation✅ Swarm Lab available alongside administrator tools💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.