Skip to content

Enable isolated demos alongside Supabase login - #4

Merged
sahajiscoding merged 2 commits into
mainfrom
arena/a6c3c531-schoolerp
Nov 5, 2026
Merged

sahajiscoding merged 2 commits into
mainfrom
arena/a6c3c531-schoolerp

Conversation

@sahajiscoding

@sahajiscoding sahajiscoding commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

  • Always show Try a demo with Admin, Teacher, and Student choices, including when Supabase is configured.
  • Isolate the showcase under /demo with no Supabase client, separate sample-data storage, and tab-local demo identity.
  • Preserve real login sessions; add a sample-data banner and an exit link to school login.
  • Add regression tests and run them in CI; document the isolation boundary.

Validation

  • 10 Vitest/jsdom regression tests passed.
  • Admin and shared typechecks passed.
  • Admin lint passed (3 existing fast-refresh warnings).
  • Production build passed (bundle-size warning only).
  • Demo entry and nested routes return HTTP 200 in the local preview.

No production environment variables, real accounts, or database policies changed.


CodeAnt-AI Description

Let visitors explore school demos without affecting real accounts or records

What Changed

  • The login page and signed-in header offer Admin, Teacher, and Student demos, even when Supabase is configured.
  • Demos open in a separate area with sample data; demo identity and edits stay separate from school login sessions and data.
  • A persistent demo notice explains that changes are local, with a link back to school sign-in.

Impact

✅ Demo access with Supabase configured
✅ School login sessions stay intact during demos
✅ Sample edits stay separate from school records

💡 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.

Summary by CodeRabbit

  • New Features
    • The demo is available even when school sign-in is configured, with role-specific entry for administrators, teachers, and students.
    • Demo activity uses separate browser storage and does not change school records or sign in to the school app. You can exit demo mode and return to school sign-in.
  • Documentation
    • Updated security guidance to explain how demo access, data, and sign-in are kept separate from the school app.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
schoolerp Ready Ready Preview Nov 5, 2026 3:24pm UTC

@codeant-ai

codeant-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #e566b Reviewed your PR d869b78 Nov 05, 2026 · 15:19 15:25

@codeant-ai

codeant-ai Bot commented Nov 5, 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

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The admin app adds an isolated /demo route that supports role-based entry and sample data without creating a Supabase client. The login page, authentication context, router, and storage behavior distinguish demo paths from school paths. Tests, CI, and documentation are updated.

Changes: Isolated demo showcase

Layer / File(s) Summary
Demo route and identity isolation
apps/admin/src/lib/demo.ts, apps/admin/src/App.tsx, apps/admin/src/contexts/AuthContext.tsx, apps/admin/src/lib/supabase.ts
The app detects /demo paths and uses /demo as the router base. On those paths, Supabase client creation is skipped. Demo roles are validated and stored separately from school authentication. Real sign-in is rejected on demo paths, and demo sign-out clears the saved demo role.
Demo entry and sample data
apps/admin/src/pages/Login.tsx, apps/admin/src/components/AppShell.tsx, apps/admin/src/lib/appData.tsx
The school login page provides role-specific demo links, while the demo login page provides role selection and a link back to school sign-in. The shell identifies demo mode, and demo paths use separate data storage without the legacy-data fallback.
Demo validation and documentation
apps/admin/tests/*, apps/admin/package.json, apps/admin/vitest.config.ts, .github/workflows/ci.yml, PROJECT_STATUS.md, docs/security/environment-variables.md, docs/superpowers/specs/2026-11-03-school-erp-design.md
Vitest and Testing Library coverage checks demo entry, role handling, storage failures, sign-out, and school password login. CI runs the admin tests. The project status and documentation describe the isolated demo flow.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Login
  participant BrowserRouter
  participant AuthProvider
  participant SessionStorage
  participant AppData
  Login->>BrowserRouter: Navigate to /demo/dashboard?role=admin
  BrowserRouter->>AuthProvider: Render app with /demo basename
  AuthProvider->>SessionStorage: Save validated demo role
  AuthProvider->>AppData: Load demo-path data
Loading

Possibly related PRs

Suggested labels: javascript, dependencies

Merge Risk: Low · up to d869b

A login timing race can misattribute local audit entries, and demo reset fails when browser storage is blocked. These bounded issues merit follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Nov 5, 2026
@codacy-production

codacy-production Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 53 complexity · 0 duplication

Metric Results
Complexity 53
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.

Comment thread apps/admin/src/App.tsx
const { loading, profile } = useAuth();
if (loading) return null;
// Demo entry must remain available while live auth is slow or offline.
if (loading) return <>{children}</>;

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: If school login is submitted before session restoration finishes, the initial session’s delayed profile lookup can complete after sign-in and replace the new user’s profile with the old one.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/admin/src/App.tsx
**Line:** 42:42
**Comment:**
	*Race Condition: If school login is submitted before session restoration finishes, the initial session’s delayed profile lookup can complete after sign-in and replace the new user’s profile with the old one.

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
👍 | 👎

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Comment thread apps/admin/src/contexts/AuthContext.tsx Outdated
.eq('id', session.user.id)
.single();
setProfile(prof ?? null);
if (mounted) setProfile(prof ?? null);

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 auth changes to another user or signs out before this query finishes, its late response overwrites the current profile and can leave the previous account active.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/admin/src/contexts/AuthContext.tsx
**Line:** 143:143
**Comment:**
	*Race Condition: When auth changes to another user or signs out before this query finishes, its late response overwrites the current profile and can leave the previous account active.

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 Nov 5, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟡  Medium Risk

  • The PR needs attention before merging because a delayed profile lookup can still restore a stale account after an auth change or sign-out.

Assessed commit: 02b75b1f0eea

@sahajiscoding
sahajiscoding merged commit 99de0ba into main Nov 5, 2026
25 checks passed
@sahajiscoding
sahajiscoding deleted the arena/a6c3c531-schoolerp branch November 7, 2026 06:38
@coderabbitai coderabbitai Bot mentioned this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant