AI Assistant
A ChatGPT-style sidebar inside the admin panel. Admins ask plain-English questions ("how many students are in Class 8?", "what's this week's attendance rate?", "find any teacher with no class assigned"), and the assistant streams back markdown answers — sometimes after running tools that read the school's data. It is not the same as the student-facing AI Tutor, which is for studying.
At a glance
| Who can do this | Admins (school-scoped answers) and Super admins (cross-school answers) |
| Where it lives | Admin panel → AI Assistant (full-page conversation surface) |
| Related features | AI Usage (monitors what this consumes) · AI Tutor (the student-facing counterpart) |
How it flows
Page anatomy
A two-pane layout, takes the full dashboard height (100vh - 64px):
Left: conversations sidebar (280 px, collapsible)
- New Chat primary button at the top.
- A list of past conversations with their titles. Each row has a hover-revealed Edit (rename inline) and Delete (with confirm).
- Active conversation is highlighted in light-blue.
- Hamburger toggle at the top of the chat pane collapses/expands this sidebar.
Right: chat surface
- Top bar: AI Assistant title + status text (
Online/Responding...). - Empty state (no conversation selected): big robot avatar, a personalized
Hi, {firstName}!greeting, and four suggestion cards that pre-fill the input when clicked. - Message list: user bubbles in blue (right), assistant bubbles in light-grey (left, with a robot avatar). Assistant messages render markdown (lists, bold, code blocks, etc.).
- Thinking indicator: while the assistant is mid-reasoning, a status line ("Looking up classes…", "Counting students…") appears in italics inside an assistant bubble. Once tokens start flowing, the status is replaced by the streamed answer.
- Input: auto-sizing textarea, Enter to send, Shift+Enter for newline. Send button is a paper-plane icon.
Suggestion cards
The cards differ by role.
Super admin sees:
- Schools overview — Summary of all schools
- Attendance trends — Check attendance patterns
- Platform stats — Users, AI usage, system health
- Teacher coverage — Check assignment gaps
Admin sees:
- My school overview — School stats summary
- Student performance — Class-wise analysis
- Attendance today — Today's attendance status
- Search users — Find students or teachers
What kinds of questions it can answer
Roughly, anything that maps to the school's structured data:
- Student counts ("how many students are in Class 8?")
- Attendance summaries ("attendance rate for this week", "absentees today in Section B")
- Teacher coverage ("which sections have no class teacher?", "subjects without a teacher")
- Lookups ("find Riya in Class 7", "all teachers in the science department")
- Cross-cutting metrics for super admins ("which school has the highest AI usage this month?")
It is not a free-form encyclopedia — it doesn't help with curriculum content, doesn't write homework, and shouldn't be relied on for legal/medical/financial advice.
Step-by-step
1. Start a conversation
- Click New Chat or just type into the input box of an empty state.
- The first message creates a conversation; the assistant suggests a title automatically and the row appears in the sidebar.
2. Continue or revisit
- Click any row in the sidebar to reload that conversation's full history.
- Hover the row → pencil icon to rename, trash icon to delete (with a confirm dialog).
3. Permission prompts
If the assistant wants to run a sensitive tool, the chat pauses with a Confirm Action modal showing the tool's name (humanized — manage_users → "Manage Users") and a one-line description. Two buttons: Deny or Allow. Denying makes the assistant continue with the data it already has; allowing lets the tool run.
This is also how mutating actions (if any are exposed to the assistant) are gated.
4. Read the answer
Markdown rendering covers headings, lists, tables, inline code, and code blocks. The bottom-right of each bubble shows the time it was sent.
Surfaces it appears on
The AI Assistant is its own dashboard page reachable from the main admin sidebar. It does not currently embed inside other pages (no inline "ask AI about this student" widget yet).
Limits & caveats
- The assistant's scope is the schools the admin can see: a regular admin gets answers about their own school; a super admin gets cross-school answers.
- Responses are streamed; closing the tab mid-stream cancels delivery but the partial assistant message is still saved (so conversation continuity holds).
- Every interaction shows up in the AI Usage tab as
chatandchat_titlefeatures. - Long conversations may eventually be truncated by context — start a new chat for unrelated topics.
Edge cases & things to test
- Send while a previous message is still streaming — the input should be disabled with the placeholder "AI is responding..."; verify Enter does nothing.
- Empty / whitespace-only message — Send button should be disabled; Enter should be a no-op.
- Switch conversations mid-stream — clicking another row while a response is streaming. Confirm the in-flight stream is properly canceled and the destination conversation loads cleanly.
- Rename inline — Esc cancels editing without saving; Enter saves; clicking the green check also saves.
- Delete the active conversation — the chat pane should reset to the empty state.
- Permission modal "Deny" — the assistant should continue with a graceful "I can't do that without permission" message rather than hang.
- Network drop mid-stream — the
onErrorpath should append a redError: ...message into the conversation, not lose state. - Markdown injection attempts — try
<script>in a question; the renderer must escape/sanitize, not execute. - Suggestion card click — should fill the input but not auto-send; the admin still has to hit Enter / Send.
- Sidebar collapse — collapse, send a message, expand. The new conversation should be present.
- Long sidebar list — 50+ conversations should scroll inside the sidebar without pushing the New Chat button off-screen.
- Role mismatch — a regular admin should not see super-admin-style suggestion cards even if their browser cache had them previously.
- Pasting into the textarea — pasting a multi-line block should auto-grow up to
maxRows: 4, then become scrollable inside the textarea.
Related
- AI Usage (Super Admin) — what this assistant costs in tokens and money
- AI Tutor — the student-facing AI surface (different model behavior, gated by AI Coins)
- Admin Panel Overview