Skip to content

Move the MiroFish-inspired Swarm Lab into the admin dashboard - #16

Merged
sahajiscoding merged 1 commit into
mainfrom
arena/74ac6307-mun-ai-app
Oct 15, 2026
Merged

sahajiscoding merged 1 commit into
mainfrom
arena/74ac6307-mun-ai-app

Conversation

@sahajiscoding

@sahajiscoding sahajiscoding commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

User description

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.

Changes

app/c8f2x9/k7m3/page.tsx — now 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 the existing app/admin/analytics and app/admin/referrals pages. Auth is not weakened in any way.

components/admin-dashboard.tsx (new) — the former client page, moved verbatim and renamed AdminDashboard, 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-unused Network import, from both the desktop sidebar and the mobile nav.

components/mirofish-console.tsx — added an embedded prop 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

Check Result
pnpm typecheck pass
pnpm test 151 / 151 pass
pnpm build pass; /mirofish absent from the route list
pnpm lint 0 errors, 5 warnings (all pre-existing, in untouched files)

Runtime checks against the production build:

  • GET /c8f2x9/k7m3 unauthenticated → 307 → /c8f2x9 ✅
  • GET /c8f2x9/k7m3 with a forged admin_session cookie → 307 → /c8f2x9 (fails closed) ✅
  • GET /mirofish → 404 ✅
  • GET /c8f2x9 login 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

  • Swarm Lab is no longer available from the delegate workspace or at its standalone page; administrators can open it from a tab in the admin dashboard.
  • The dashboard now checks for a valid administrator session before showing its content and redirects visitors without one to the admin sign-in page.
  • The Swarm Lab appears within the dashboard’s normal page flow, while existing admin tools remain available in the Overview tab.

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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

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.
@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
mun-ai-app Ready Ready Preview Oct 15, 2026 6:52am UTC

@codeant-ai

codeant-ai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR ab20b9e Oct 15, 2026 · 06:52 07:00

@codeant-ai

codeant-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:XL This PR changes 500-999 lines, ignoring generated files label Oct 15, 2026
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -67 complexity · 0 duplication

Metric Results
Complexity -67
Duplication 0

View in Codacy

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.

@sahajiscoding
sahajiscoding merged commit 860682e into main Oct 15, 2026
36 checks passed
/** Fetches the admin user registry from the API. */
const fetchUsers = useCallback(async () => {
try {
const res = await fetch("/api/c8f2x9/users");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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" });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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 }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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-ai

codeant-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

4 code suggestions

1. Because responseMode is omitted, the endpoint defaults to quick; Thorough and Max therefore use quick behavior and its 4096-token ceiling.

Api mismatch · components/admin-dashboard.tsx:315-317


2. When NVIDIA emits an SSE error event, this callback ignores it and leaves the result blank, hiding provider failures from the administrator.

Api mismatch · components/admin-dashboard.tsx:326-330


3. The research route selects GLM for Quick and Thorough and Kimi for Max, so this provider-check label promises MiniMax M3 that no mode invokes.

Comment mismatch · components/admin-dashboard.tsx:448


4. This control is shown to every authenticated admin, but its endpoint requires the owner, so delegated admins get a 403 on each attempt.

Api mismatch · components/admin-dashboard.tsx:686

@sahajiscoding
sahajiscoding deleted the arena/74ac6307-mun-ai-app branch October 15, 2026 07:04

This branch was successfully deployed

1 active deployment
Preview — ab20b9ea Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant