Fourth revision: OpenRouter, live tool stages, Explain layout, share sections
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s

- Interactive blocks are encouraged by default; Explain gets a reduced library
  and never writes practice questions.
- Assistant tool steps breathe while running, show live stages from generation
  and the Python check, and read in the past tense when done.
- The assistant asks before searching the web when class materials do not
  cover a question; clarifying questions list every class's exams and never
  ask about format (always NCLEX).
- Explain opens beside the question from 900px wide, moving the question left
  while open and back on the next one.
- Generate dialog drops the practice set/exam switch (presets cover it) and the
  Generate buttons lose their icon.
- Python check notes are green when every check passed, applied fixes neutral.
- Share pages group by exam, then Quizzes, Flashcards, Notes, Class Materials,
  hiding empty groups; the class page uses the same order. "Documents" is now
  "Class Materials".
- OpenRouter provider replaces the Ollama type; migration 6 turns Ollama
  connections into OpenAI-compatible ones at /v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-15 21:54:39 -07:00
parent c595e0ff2c
commit 25bc03ea75
45 changed files with 663 additions and 329 deletions

View file

@ -61,7 +61,7 @@ export function ClassDialog({ open, onOpenChange, existing }: { open: boolean; o
open={open}
onOpenChange={onOpenChange}
title={existing ? 'Edit class' : 'New class'}
description={existing ? undefined : 'A class holds the quizzes, flashcards, documents and notes for one course.'}
description={existing ? undefined : 'A class holds the quizzes, flashcards, notes and class materials for one course.'}
footer={
<>
<Button variant="ghost" onClick={() => onOpenChange(false)}>
@ -91,7 +91,7 @@ export function ClassDialog({ open, onOpenChange, existing }: { open: boolean; o
<Field label="Description" optional>
<Textarea value={description} onChange={(e) => setDescription(e.target.value)} rows={2} maxLength={2000} />
</Field>
<Field label="Divided into" hint="Each one keeps its own documents, quizzes and flashcards, and generating uses only its material.">
<Field label="Divided into" hint="Each one keeps its own quizzes, flashcards and class materials, and generating uses only its material.">
<Select value={groupLabel} onChange={(e) => setGroupLabel(e.target.value)}>
{['Exam', 'Unit', 'Module', 'Week', 'Topic', 'Folder'].map((l) => (
<option key={l} value={l}>
@ -234,7 +234,7 @@ function CommandPalette({ open, onOpenChange, onNewClass }: { open: boolean; onO
rows[index]?.run();
}
}}
placeholder="Search questions, cards, documents, classes…"
placeholder="Search questions, cards, class materials, classes…"
aria-label="Search"
role="combobox"
aria-expanded

View file

@ -21,8 +21,8 @@ const KIND_BLURB: Record<ProviderKind, string> = {
anthropic: 'Claude models with an Anthropic API key.',
gemini: 'Gemini models with a Google AI Studio key.',
deepseek: 'DeepSeek Flash and Pro with a DeepSeek platform key.',
openai_compatible: 'OpenRouter, Groq, Together, LM Studio, vLLM and other compatible servers.',
ollama: 'Models running on your own machine or server.',
openrouter: 'Hundreds of models from many labs with one OpenRouter key.',
openai_compatible: 'Ollama, LM Studio, vLLM, Groq, Together and other servers with an OpenAI-style API.',
};
function useAiData() {
@ -60,7 +60,7 @@ function ProviderDialog({ open, onClose, adapters, existing, onSaved }: { open:
const a = adapters.find((x) => x.kind === k)!;
setKind(k);
setName(k === 'openai_compatible' ? '' : a.label);
setBaseUrl(k === 'ollama' ? (a.defaultBaseUrl ?? '') : '');
setBaseUrl('');
};
const save = async () => {
@ -120,7 +120,7 @@ function ProviderDialog({ open, onClose, adapters, existing, onSaved }: { open:
<div className="grid gap-2">
{adapters.map((a) => (
<button key={a.kind} type="button" onClick={() => pick(a.kind)} className="flex items-center gap-3 rounded-xl border border-line-strong p-3.5 text-left hover:border-ink-3 hover:bg-ink/3">
<span className="grid size-10 shrink-0 place-items-center rounded-[11px] bg-sunken text-ink-2">{a.kind === 'ollama' || a.kind === 'openai_compatible' ? <Server className="size-[18px]" /> : <Brain className="size-[18px]" />}</span>
<span className="grid size-10 shrink-0 place-items-center rounded-[11px] bg-sunken text-ink-2">{a.kind === 'openai_compatible' ? <Server className="size-[18px]" /> : <Brain className="size-[18px]" />}</span>
<span className="min-w-0 flex-1">
<span className="block font-semibold">{a.label}</span>
<span className="block text-[13px] text-ink-2">{KIND_BLURB[a.kind]}</span>
@ -138,10 +138,10 @@ function ProviderDialog({ open, onClose, adapters, existing, onSaved }: { open:
}}
>
<Field label="Name" hint="Shown in model pickers. Useful when you connect the same service with two keys.">
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder={adapter.kind === 'openai_compatible' ? 'OpenRouter' : adapter.label} maxLength={80} />
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder={adapter.kind === 'openai_compatible' ? 'Ollama' : adapter.label} maxLength={80} />
</Field>
{(needsUrl || adapter.kind === 'ollama') && (
<Field label="Server URL" hint={adapter.kind === 'ollama' ? 'From inside Docker, "localhost" is the container. Use your server address, for example http://192.168.1.10:11434.' : 'The API root, for example https://openrouter.ai/api/v1 or http://192.168.1.10:1234/v1.'}>
{needsUrl && (
<Field label="Server URL" hint='The API root, for example http://192.168.1.10:11434/v1 for Ollama or http://192.168.1.10:1234/v1 for LM Studio. From inside Docker, "localhost" is the container itself.'>
<Input value={baseUrl} onChange={(e) => setBaseUrl(e.target.value)} placeholder={adapter.defaultBaseUrl ?? 'https://…/v1'} inputMode="url" spellCheck={false} className="num text-[13px]" />
</Field>
)}
@ -164,7 +164,7 @@ function ProviderDialog({ open, onClose, adapters, existing, onSaved }: { open:
<details className="rounded-xl border border-line">
<summary className="px-3.5 py-2.5 text-sm font-medium text-ink-2 hover:text-ink">Advanced</summary>
<div className="space-y-4 border-t border-line p-3.5">
{!needsUrl && adapter.kind !== 'ollama' && (
{!needsUrl && (
<Field label="Custom endpoint" optional hint="Only for proxies and gateways. Leave blank for the official API.">
<Input value={baseUrl} onChange={(e) => setBaseUrl(e.target.value)} placeholder={adapter.defaultBaseUrl ?? ''} spellCheck={false} className="num text-[13px]" />
</Field>
@ -190,8 +190,8 @@ const CACHE_HINT: Record<ProviderKind, string> = {
anthropic: "Claude's cache-read rate (10% of input)",
gemini: "Gemini's cache rate (10% of input)",
deepseek: "DeepSeek's cache-hit rate",
openrouter: 'the normal input price unless OpenRouter lists a cache price',
openai_compatible: 'the normal input price',
ollama: 'the normal input price',
};
function cachedGuess(model: AiModel): string {
@ -357,7 +357,7 @@ function ProviderCard({ provider, models, adapter, onEdit, reload }: { provider:
return (
<div className={cx('card overflow-hidden', !provider.enabled && 'opacity-70')}>
<div className="flex flex-wrap items-center gap-3 px-4 py-3.5">
<span className="grid size-10 shrink-0 place-items-center rounded-[11px] bg-sunken text-ink-2">{provider.kind === 'ollama' || provider.kind === 'openai_compatible' ? <Server className="size-[18px]" /> : <Brain className="size-[18px]" />}</span>
<span className="grid size-10 shrink-0 place-items-center rounded-[11px] bg-sunken text-ink-2">{provider.kind === 'openai_compatible' ? <Server className="size-[18px]" /> : <Brain className="size-[18px]" />}</span>
<div className="min-w-0 flex-1 basis-40">
<div className="flex flex-wrap items-center gap-2">
<span className="font-semibold">{provider.name}</span>
@ -711,7 +711,7 @@ export default function AiSettings() {
</Button>
}
>
Study Desk works without AI. Connecting a model adds question and flashcard generation from your documents, explanations, and the assistant. You can connect several providers and use different models for different jobs.
Study Desk works without AI. Connecting a model adds question and flashcard generation from your class materials, explanations, and the assistant. You can connect several providers and use different models for different jobs.
</EmptyState>
</div>
) : (

View file

@ -11,7 +11,7 @@ import { cx, plural, timeAgo, useDebounced, useLocalStorage } from '@/lib/util';
import { citedSources, GenUiContext, Markdown, type Citation } from '@/ui/Markdown';
import { AskCard } from './AskCard';
import { ToolSteps } from './ToolSteps';
import { Badge, Button, Callout, IconButton, Input, Menu, MenuItem, MenuLabel, MenuSeparator, Popover, Spinner } from '@/ui';
import { Badge, Button, Callout, IconButton, Input, Menu, MenuItem, MenuLabel, MenuSeparator, Popover, Spinner, Thinking } from '@/ui';
/** Applies one streamed event to a message. Text after a tool step or a new model step starts a new paragraph. */
@ -222,9 +222,7 @@ function AssistantMessage({ message, onNavigate, onAction, onSend, answerable =
) : null,
)}
{thinking && (
<div className="flex items-center gap-2 text-[13px] text-ink-3" role="status">
<Spinner className="size-3.5" label="Thinking" /> {message.reasoning ? 'Thinking it through' : 'Thinking'}
</div>
<Thinking label={message.reasoning ? 'Thinking it through' : 'Thinking'} />
)}
{cited.length > 0 && (
<div className="flex flex-wrap gap-1.5 pt-0.5">
@ -659,7 +657,7 @@ export default function AssistantPanel({
return ['Summarise the key points of this document', 'Make flashcards from this, focusing on medications and adverse effects', 'Write 15 NCLEX-style questions from this', 'What are the most testable concepts here?'];
}
if (className) {
return [`Create a 20-question NCLEX-style quiz using the documents in ${className}`, 'Find the questions I frequently get wrong and create a new practice quiz covering those concepts', `What should I focus on in ${className} this week?`, 'Make a study guide from all the documents in this class'];
return [`Create a 20-question NCLEX-style quiz using the class materials in ${className}`, 'Find the questions I frequently get wrong and create a new practice quiz covering those concepts', `What should I focus on in ${className} this week?`, 'Make a study guide from all the class materials in this class'];
}
return ['What should I study today?', 'Find the questions I frequently get wrong and create a new practice quiz covering those concepts', 'Explain the difference between left-sided and right-sided heart failure', 'Start a practice session with the questions I miss most'];
}, [activeDocs.length, className]);
@ -801,7 +799,7 @@ export default function AssistantPanel({
) : messages.length === 0 ? (
<div className="mx-auto flex h-full max-w-md flex-col justify-center pb-6">
<h2 className="display text-[26px]">What are we working on?</h2>
<p className="mt-1.5 text-sm text-ink-2">I can read your documents, look at your results, and prepare quizzes, flashcards and study guides for you to review. Use + (or type @, or drag items in) to point me at a specific quiz, deck, note or document.</p>
<p className="mt-1.5 text-sm text-ink-2">I can read your class materials, look at your results, and prepare quizzes, flashcards and study guides for you to review. Use + (or type @, or drag items in) to point me at a specific quiz, deck, note or class material.</p>
<div className="mt-5 space-y-2">
{suggestions.map((s) => (
<button key={s} type="button" onClick={() => send(s)} className="group flex w-full items-center gap-3 rounded-[13px] border border-line bg-surface px-3.5 py-2.5 text-left text-sm shadow-1 hover:border-ink-3">

View file

@ -5,7 +5,7 @@ import { errorMessage, streamEvents } from '@/lib/api';
import type { ToolActivity } from '@/lib/types';
import { cx } from '@/lib/util';
import { GenUiContext, Markdown } from '@/ui/Markdown';
import { Button, Callout, IconButton, Spinner } from '@/ui';
import { Button, Callout, IconButton, Thinking } from '@/ui';
import { ToolSteps } from './ToolSteps';
type ExplainBody =
@ -25,22 +25,32 @@ interface Turn {
}
/**
* Set by the quiz runner: on wide screens the explanation opens in the empty space to the right
* of the question instead of below it.
* Set by the quiz runner: on larger screens the explanation opens beside the question instead of
* below it. When the free space right of the centred question is too narrow, the runner moves the
* question left by `reserve` pixels while the explanation is open.
*/
export const ExplainSideContext = createContext(false);
export const ExplainSideContext = createContext<{ reserve: (px: number) => void } | null>(null);
/** Width available beside a centred 48rem column, or 0 when there is not enough room. */
function useSideRoom(enabled: boolean): number {
const measure = () => (typeof window === 'undefined' ? 0 : Math.floor((window.innerWidth - 768) / 2 - 44));
const [room, setRoom] = useState(measure);
/** Below this width the explanation stays under the question. */
const SIDE_MIN_VIEWPORT = 900;
/**
* Where the explanation goes: `width` 0 means below the question. `shift` is how far the
* question column must make room on the right (0 when the space beside it is already enough).
*/
function useSideLayout(enabled: boolean): { width: number; shift: number } {
const [vw, setVw] = useState(() => (typeof window === 'undefined' ? 0 : window.innerWidth));
useEffect(() => {
if (!enabled) return;
const onResize = () => setRoom(measure());
const onResize = () => setVw(window.innerWidth);
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, [enabled]);
return enabled && room >= 300 ? Math.min(room, 520) : 0;
if (!enabled || vw < SIDE_MIN_VIEWPORT) return { width: 0, shift: 0 };
const room = Math.floor((vw - 768) / 2 - 44);
if (room >= 300) return { width: Math.min(room, 520), shift: 0 };
const width = Math.max(340, Math.min(480, Math.round(vw * 0.4)));
return { width, shift: width + 36 };
}
/** "Explain with AI": streams a short explanation and accepts follow-up questions. */
@ -52,7 +62,14 @@ export function Explain({ body, label = 'Explain with AI', className, url = '/ap
const [ask, setAsk] = useState('');
const abort = useRef<AbortController | null>(null);
const key = JSON.stringify(body);
const sideWidth = useSideRoom(useContext(ExplainSideContext));
const side = useContext(ExplainSideContext);
const { width: sideWidth, shift } = useSideLayout(Boolean(side));
// Smaller screens: push the question left while the explanation is open (back on close).
useEffect(() => {
if (!side || !open || !shift) return;
side.reserve(shift);
return () => side.reserve(0);
}, [side, open, shift]);
useEffect(() => {
// A different question: start over.
@ -121,7 +138,7 @@ export function Explain({ body, label = 'Explain with AI', className, url = '/ap
<div key={i} className="space-y-1.5">
{t.ask && <div className="mb-1 text-[13px] font-medium text-ink-2">{t.ask}</div>}
{t.tools.length > 0 && <ToolSteps tools={t.tools} compact />}
{t.text ? <Markdown className="text-[14.5px]">{t.text}</Markdown> : busy && i === turns.length - 1 && !t.tools.some((x) => x.status === 'running') ? <Spinner className="size-4" label="Thinking" /> : null}
{t.text ? <Markdown className="text-[14.5px]">{t.text}</Markdown> : busy && i === turns.length - 1 && !t.tools.some((x) => x.status === 'running') ? <Thinking /> : null}
</div>
))}
</div>

View file

@ -90,7 +90,8 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
const applyTemplate = (id: string) => {
setTemplateId(id);
const t = templates.data?.find((x) => x.id === id);
if (!t) return;
// Custom: an ordinary practice set. Full practice exams come from the "Practice exam" preset.
if (!t) return setFormat('practice');
const p = t.payload;
if (p.kind && !preset?.kind) setKind(p.kind);
if (typeof p.count === 'number') setCount(p.count);
@ -197,7 +198,7 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
<div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
{(
[
{ v: 'documents', label: 'Documents', icon: <FileText />, hint: docs.length ? `${docs.length} ready` : 'None yet' },
{ v: 'documents', label: 'Class Materials', icon: <FileText />, hint: docs.length ? `${docs.length} ready` : 'None yet' },
{ v: 'text', label: 'Pasted notes', icon: <NotebookPen />, hint: 'Paste text' },
{ v: 'topic', label: 'A topic', icon: <Sparkles />, hint: 'No source' },
{ v: 'weak', label: 'Weak areas', icon: <Target />, hint: 'From results' },
@ -243,7 +244,7 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
{mode === 'text' && <Textarea className="mt-3" rows={6} value={text} onChange={(e) => setText(e.target.value)} placeholder="Paste lecture notes, a chapter summary, or anything you want turned into study material." aria-label="Pasted notes" />}
{mode === 'weak' && (
<Callout className="mt-3" icon={<Target />}>
Uses the questions you have missed most in this class, plus matching passages from its documents, to write new {kind === 'deck' ? 'cards' : kind === 'note' ? 'review notes' : 'questions'} on the same concepts.
Uses the questions you have missed most in this class, plus matching passages from its class materials, to write new {kind === 'deck' ? 'cards' : kind === 'note' ? 'review notes' : 'questions'} on the same concepts.
</Callout>
)}
</div>
@ -273,21 +274,6 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
<Input type="number" min={1} max={100} value={count} onChange={(e) => setCount(Math.max(1, Math.min(100, Number(e.target.value) || 1)))} />
</Field>
)}
<Field label="Set" hint={format === 'exam' ? 'Like a unit exam: 50 questions, up to 5 calculations when the material has them.' : 'All questions are NCLEX style.'}>
<Segmented
label="Set"
value={format}
onChange={(f) => {
setFormat(f);
setCount(f === 'exam' ? 50 : 15);
}}
options={[
{ value: 'practice', label: 'Practice set' },
{ value: 'exam', label: 'Practice exam' },
]}
className="w-full"
/>
</Field>
<Field label="Difficulty">
<Select value={difficulty} onChange={(e) => setDifficulty(e.target.value as typeof difficulty)}>
<option value="mixed">Mixed</option>

View file

@ -65,7 +65,7 @@ export function SemanticSettings({ providers }: { providers: Provider[] }) {
setBusy('save');
try {
await api.put('/api/ai/embeddings', { providerId: providerId || null, model: providerId && !isLocal ? model.trim() : '', dimensions: dimensions && !isLocal ? Number(dimensions) : null });
toast.success(providerId ? 'Semantic search is on. Indexing your documents…' : 'Semantic search is off');
toast.success(providerId ? 'Semantic search is on. Indexing your class materials…' : 'Semantic search is off');
await reload();
} catch (e) {
toast.error(errorMessage(e));
@ -152,7 +152,7 @@ export function SemanticSettings({ providers }: { providers: Provider[] }) {
)}
{eligible.length === 0 && !isLocal && (
<Callout tone="accent" icon={<Sparkles />} className="mt-3" title="Cloud embeddings need a provider">
Use the built-in model, or connect OpenAI, Gemini, Ollama or an OpenAI-compatible server above. Anthropic and DeepSeek do not offer embeddings.
Use the built-in model, or connect OpenAI, Gemini or an OpenAI-compatible server (Ollama included) above. Anthropic, DeepSeek and OpenRouter connections are not used for embeddings.
</Callout>
)}
{(

View file

@ -4,7 +4,7 @@ import { errorMessage, streamEvents } from '@/lib/api';
import type { ToolActivity } from '@/lib/types';
import { cx } from '@/lib/util';
import { GenUiContext, Markdown } from '@/ui/Markdown';
import { Button, Callout, IconButton, Spinner, Tooltip } from '@/ui';
import { Button, Callout, IconButton, Thinking, Tooltip } from '@/ui';
import { ToolSteps } from './ToolSteps';
type Event = { type: 'text'; delta: string } | { type: 'tool'; tool: ToolActivity } | { type: 'error'; message: string } | { type: 'done' };
@ -112,7 +112,7 @@ export function SharedAssistant({ token, title, item, hidden }: { token: string;
{t.text ? (
<Markdown className="text-[14px]">{t.text}</Markdown>
) : busy && i === turns.length - 1 && !t.tools?.some((x) => x.status === 'running') ? (
<Spinner className="size-4" label="Thinking" />
<Thinking />
) : null}
</div>
),

View file

@ -1,6 +1,6 @@
/**
* Tool steps in a conversation: one quiet line per step with a status mark (spinner, check or
* cross) and a friendly name ("Searched the web for: sepsis bundle"). Clicking a line opens its
* Tool steps in a conversation: one quiet line per step with a status mark (a breathing icon
* while it runs, then a check or cross) and a friendly name ("Searched the web for: sepsis bundle"). Clicking a line opens its
* details: the pages it found, what it was asked and what it returned.
*/
import {
@ -15,7 +15,6 @@ import {
Globe,
Library,
ListChecks,
LoaderCircle,
PencilLine,
Play,
Plug,
@ -55,7 +54,7 @@ const BUILTIN_ICON: Record<string, ReactNode> = {
function iconFor(tool: ToolActivity): ReactNode {
switch (tool.kind) {
case 'web_search':
return <Globe className={cx(tool.status === 'running' && 'tool-spin-slow')} />;
return <Globe />;
case 'web_fetch':
return <FileText />;
case 'web_research':
@ -70,7 +69,8 @@ function iconFor(tool: ToolActivity): ReactNode {
/** The line's text: what is happening while it runs, what happened once it is done. */
export function toolTitle(tool: ToolActivity): ReactNode {
const subject = tool.subject ? <span className="text-ink-2">{tool.subject}</span> : null;
if (tool.status === 'running') return tool.label;
// While running, the current stage ("Checking the questions with Python") replaces the label.
if (tool.status === 'running') return tool.stage || tool.label;
const failed = tool.status === 'error';
switch (tool.kind) {
case 'web_search':
@ -130,11 +130,9 @@ function Details({ tool }: { tool: ToolActivity }) {
function Mark({ tool }: { tool: ToolActivity }) {
return (
<span className="relative grid size-[18px] shrink-0 place-items-center text-ink-3 [&>svg]:size-[15px]">
<span className={cx('relative grid size-[18px] shrink-0 place-items-center [&>svg]:size-[15px]', tool.status === 'running' ? 'animate-pulse text-accent' : 'text-ink-3')}>
{iconFor(tool)}
{tool.status === 'running' ? (
<LoaderCircle className="absolute -inset-[3px] !size-[24px] animate-spin text-accent/70" strokeWidth={1.5} />
) : (
{tool.status === 'running' ? null : (
<span className={cx('tool-pop absolute -right-1 -bottom-1 grid size-[11px] place-items-center rounded-full ring-2 ring-paper', tool.status === 'error' ? 'bg-bad text-white' : 'bg-good text-white')}>
{tool.status === 'error' ? <X className="!size-[8px]" strokeWidth={3.5} /> : <Check className="!size-[8px]" strokeWidth={3.5} />}
</span>

View file

@ -151,7 +151,7 @@ export function WebSearchSettings() {
</fieldset>
</div>
<Callout tone="neutral" className="mt-3 text-[13px]">
Only the search words and page addresses the AI writes are sent to Parallel, never your documents. You can switch web search off for a single conversation from the assistant's tools button.
Only the search words and page addresses the AI writes are sent to Parallel, never your class materials. You can switch web search off for a single conversation from the assistant's tools button.
</Callout>
</Section>
</>

View file

@ -280,8 +280,8 @@ const SHARE_BLURB: Record<ShareKind, string> = {
deck: 'Anyone with the link can study these flashcards. They cannot change them.',
note: 'Anyone with the link can read this note.',
document: 'Anyone with the link can view and download this file.',
folder: 'Anyone with the link can study the quizzes, decks and notes in this exam (or folder) and read or download its documents.',
class: 'Anyone with the link can study every quiz, deck and note in this class and view or download its documents.',
folder: 'Anyone with the link can study the quizzes, decks and notes in this exam (or folder) and view or download its class materials.',
class: 'Anyone with the link can study every quiz, deck and note in this class and view or download its class materials.',
};
export function ShareDialog({ target, onClose }: { target: { kind: ShareKind; id: string; title: string } | null; onClose: () => void }) {

View file

@ -214,6 +214,9 @@ export function QuizRunner(p: RunnerProps) {
const confirm = useConfirm();
const [elapsed, setElapsed] = useState(p.elapsedSec);
const [navOpen, setNavOpen] = useState(false);
// Room the Explain panel needs on the right on smaller screens (0 = question stays centred).
const [explainReserve, setExplainReserve] = useState(0);
const explainSide = useMemo(() => ({ reserve: setExplainReserve }), []);
const topRef = useRef<HTMLDivElement>(null);
const tick = useLatest(p.onTick);
const finish = useLatest(p.onFinish);
@ -367,7 +370,11 @@ export function QuizRunner(p: RunnerProps) {
<ProgressBar value={answeredCount / total} tone="ink" className="h-[3px] rounded-none" label="Progress" />
</header>
<main className="mx-auto w-full max-w-3xl flex-1 px-4 pt-6 pb-32 sm:px-5 sm:pt-9">
<main
className="mx-auto w-full max-w-3xl flex-1 px-4 pt-6 pb-32 transition-[transform,max-width] duration-300 ease-out motion-reduce:transition-none sm:px-5 sm:pt-9"
// Explain open on a smaller screen: the question moves left and narrows to make room.
style={explainReserve ? { maxWidth: Math.min(768, window.innerWidth - explainReserve - 40), transform: `translateX(-${explainReserve / 2}px)` } : undefined}
>
<div ref={topRef} className="scroll-mt-20" />
<div key={question.id} className="animate-in">
<div className="mb-3 flex flex-wrap items-center gap-2">
@ -398,7 +405,7 @@ export function QuizRunner(p: RunnerProps) {
<Markdown className="text-[15px]">{question.rationale}</Markdown>
</div>
)}
<ExplainSideContext.Provider value>{p.renderExtra?.(question, answerTexts(question, selected))}</ExplainSideContext.Provider>
<ExplainSideContext.Provider value={explainSide}>{p.renderExtra?.(question, answerTexts(question, selected))}</ExplainSideContext.Provider>
</div>
)}
</div>

View file

@ -348,7 +348,7 @@ export interface ShareListItem extends Share {
/* ------------------------------ AI ------------------------------ */
export type ProviderKind = 'openai' | 'anthropic' | 'gemini' | 'deepseek' | 'openai_compatible' | 'ollama';
export type ProviderKind = 'openai' | 'anthropic' | 'gemini' | 'deepseek' | 'openrouter' | 'openai_compatible';
export interface AdapterMeta {
kind: ProviderKind;
label: string;
@ -481,6 +481,8 @@ export interface ToolActivity {
name: string;
label: string;
status: 'running' | 'done' | 'error';
/** While running: what the step is doing right now. */
stage?: string;
summary?: string;
kind?: ToolKind;
server?: string;

View file

@ -418,8 +418,8 @@ export default function ClassPage() {
};
// Inside each section, items are grouped under a subheading per type.
const KIND_ORDER = ['quiz', 'deck', 'document', 'note'] as const;
const KIND_HEADING = { quiz: 'Quizzes', deck: 'Flashcards', document: 'Documents', note: 'Notes' } as const;
const KIND_ORDER = ['quiz', 'deck', 'note', 'document'] as const;
const KIND_HEADING = { quiz: 'Quizzes', deck: 'Flashcards', document: 'Class Materials', note: 'Notes' } as const;
const KIND_HEADING_ICON = { quiz: <BookOpen />, deck: <Layers />, document: <FileText />, note: <NotebookPen /> } as const;
const canSort = sort === 'manual' && !query.trim();
const persistOrder = (kind: Item['kind']) => async (ids: string[]) => {
@ -500,7 +500,7 @@ export default function ClassPage() {
</MenuItem>
<MenuSeparator />
<MenuItem icon={<Upload />} onSelect={() => fileRef.current?.click()}>
Upload documents
Upload class materials
</MenuItem>
<MenuItem icon={<FileText />} onSelect={() => setPasteOpen(true)}>
Paste text as a document
@ -555,7 +555,7 @@ export default function ClassPage() {
Review {data.due.total}
</Button>
)}
<Button icon={<Sparkles />} onClick={() => setGenerate({})}>
<Button onClick={() => setGenerate({})}>
Generate
</Button>
{addMenu}
@ -601,7 +601,7 @@ export default function ClassPage() {
action={
<>
<Button variant="primary" icon={<Upload />} onClick={() => fileRef.current?.click()}>
Upload documents
Upload class materials
</Button>
<Button icon={<FileUp />} onClick={() => setImportOpen(true)}>
Import
@ -643,8 +643,8 @@ export default function ClassPage() {
['all', 'All'],
['quiz', 'Quizzes'],
['deck', 'Flashcards'],
['document', 'Documents'],
['note', 'Notes'],
['document', 'Class Materials'],
] as const
).map(([v, label]) => (
<button
@ -706,9 +706,9 @@ export default function ClassPage() {
action={
<>
<Button variant="primary" icon={<Upload />} onClick={() => fileRef.current?.click()}>
Upload documents
Upload class materials
</Button>
<Button icon={<Sparkles />} onClick={() => setGenerate({})}>
<Button onClick={() => setGenerate({})}>
Generate
</Button>
</>
@ -917,7 +917,7 @@ function ExamTabs({
return (
<div className="mb-4 flex flex-wrap items-center gap-3 rounded-[14px] border border-dashed border-line-strong px-4 py-3 text-[13.5px] text-ink-2">
<FolderIcon className="size-4 shrink-0 text-tab" />
<span className="min-w-0 flex-1">Divide this class into {noun}s so each keeps its own documents, quizzes and flashcards, and generating uses only that {noun}'s material.</span>
<span className="min-w-0 flex-1">Divide this class into {noun}s so each keeps its own class materials, quizzes and flashcards, and generating uses only that {noun}'s material.</span>
<Button size="sm" icon={<Plus />} onClick={onNew}>
New {noun}
</Button>

View file

@ -335,7 +335,7 @@ export default function DeckPage() {
{cards.length === 0 ? (
<div className="card mb-3 border-dashed">
<EmptyState icon={<Layers />} title="No cards yet">
Add your first card below, paste a list, or generate cards from your class documents.
Add your first card below, paste a list, or generate cards from your class materials.
</EmptyState>
</div>
) : (

View file

@ -1,5 +1,5 @@
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
import { BookOpen, ChevronRight, Columns2, Download, FileText, FolderInput, Layers, MessageSquare, MoreHorizontal, NotebookPen, Pencil, RefreshCw, ScanText, Share2, Sparkles, Trash2, TriangleAlert } from 'lucide-react';
import { BookOpen, ChevronRight, Columns2, Download, FileText, FolderInput, Layers, MessageSquare, MoreHorizontal, NotebookPen, Pencil, RefreshCw, ScanText, Share2, Trash2, TriangleAlert } from 'lucide-react';
import { useEffect, useState } from 'react';
import { Link, useNavigate, useParams, useSearchParams } from 'react-router';
import { toast } from 'sonner';
@ -186,7 +186,7 @@ export default function DocumentPage() {
</div>
</div>
<div className="flex flex-wrap items-center gap-2">
<Button variant="primary" icon={<Sparkles />} disabled={!ready || doc.chunkCount === 0} onClick={() => setGenerate({ documentIds: [doc.id] })}>
<Button variant="primary" disabled={!ready || doc.chunkCount === 0} onClick={() => setGenerate({ documentIds: [doc.id] })}>
Generate
</Button>
<Button icon={<MessageSquare />} disabled={!ready || doc.chunkCount === 0} onClick={() => assistant.open({ documentIds: [doc.id], classId: doc.classId, newChat: true })}>

View file

@ -1,5 +1,5 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { BookOpen, Check, ChevronRight, CircleAlert, Eye, FileText, Layers, NotebookPen, Pencil, Plus, Sparkles, Trash2, TriangleAlert } from 'lucide-react';
import { BookOpen, Check, ChevronRight, CircleAlert, CircleCheck, Eye, FileText, Layers, NotebookPen, Pencil, Plus, Sparkles, Trash2, TriangleAlert, Wrench } from 'lucide-react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate, useParams } from 'react-router';
import { toast } from 'sonner';
@ -269,11 +269,14 @@ export default function DraftPage() {
{draft.error} What was written before that is below.
</Callout>
)}
{(draft.meta.notes ?? []).map((n, i) => (
<Callout key={i} tone="warn" icon={<TriangleAlert />} className="mb-4 py-2.5">
{n}
</Callout>
))}
{(draft.meta.notes ?? []).map((n, i) => {
const tone = noteTone(n);
return (
<Callout key={i} tone={tone} icon={tone === 'good' ? <CircleCheck /> : tone === 'neutral' ? <Wrench /> : <TriangleAlert />} className="mb-4 py-2.5">
{n}
</Callout>
);
})}
{badItems.size > 0 && (
<Callout
tone="bad"
@ -512,3 +515,14 @@ export default function DraftPage() {
</div>
);
}
/**
* Generation notes are plain strings. A clean Python check reads as good news, a fix that was
* applied as information, and everything else (failed checks, skipped batches) as a warning.
*/
function noteTone(note: string): 'good' | 'neutral' | 'warn' {
const checked = /^Checked with Python[^:]*: (\d+) of (\d+) checks passed/.exec(note);
if (checked) return checked[1] === checked[2] ? 'good' : 'warn';
if (/^Question \d+( removed|: (answer|type|topic))/.test(note) && !/not applied|incomplete|does not exist/.test(note)) return 'neutral';
return 'warn';
}

View file

@ -24,7 +24,7 @@ function Onboarding({ hasClass, aiReady, onNewClass }: { hasClass: boolean; aiRe
const steps = [
{ done: hasClass, title: 'Create a class', body: 'One for each course. Everything else lives inside it.', action: <Button size="sm" variant="primary" icon={<Plus />} onClick={onNewClass}>New class</Button> },
{ done: false, title: 'Add material', body: 'Import quizzes and flashcards, write your own, or upload lecture slides and notes.', action: hasClass ? <span className="text-[13px] text-ink-3">Open a class to add material</span> : null },
{ done: aiReady, title: 'Connect an AI model', body: 'Optional. Lets Study Desk write questions from your documents and explain answers.', action: <Link to="/settings/ai" className="text-[13px] font-medium text-accent hover:underline">Open AI settings</Link> },
{ done: aiReady, title: 'Connect an AI model', body: 'Optional. Lets Study Desk write questions from your class materials and explain answers.', action: <Link to="/settings/ai" className="text-[13px] font-medium text-accent hover:underline">Open AI settings</Link> },
];
return (
<div className="card overflow-hidden">

View file

@ -598,12 +598,12 @@ export default function QuizPage() {
Paste several
</Button>
<Button icon={<Sparkles />} onClick={() => navigate(`/classes/${quiz.classId}`)}>
Generate from documents
Generate from class materials
</Button>
</>
}
>
Write questions one at a time, paste a batch as text, or generate them from your class documents.
Write questions one at a time, paste a batch as text, or generate them from your class materials.
</EmptyState>
</div>
) : (

View file

@ -218,7 +218,7 @@ function SharingSettings() {
))}
</ul>
)}
<p className="mt-2.5 text-xs text-ink-3">Visitors can only read and study what a link points to. They cannot edit anything, see other content, or affect your progress. Uploaded documents are shared only when you share the document itself.</p>
<p className="mt-2.5 text-xs text-ink-3">Visitors can only read and study what a link points to. They cannot edit anything, see other content, or affect your progress. Class materials are shared only with the class or exam they belong to, or when you share the file itself.</p>
</Section>
);
}
@ -425,7 +425,7 @@ function DataSettings() {
['Classes', sys.counts.classes],
['Questions', sys.counts.questions],
['Flashcards', sys.counts.cards],
['Documents', sys.counts.documents],
['Class materials', sys.counts.documents],
].map(([k, v]) => (
<div key={k as string}>
<dt className="text-ink-3">{k}</dt>

View file

@ -480,8 +480,13 @@ function SharedDocument({ doc, token, nested, back }: { doc: PublicDocument; tok
const ITEM_ICON = { quiz: <BookOpen />, deck: <Layers />, note: <NotebookPen />, document: <FileText /> };
/** The same order and names as the owner's class page; a type with nothing in it is left out. */
const KIND_ORDER = ['quiz', 'deck', 'note', 'document'] as const;
const KIND_HEADING = { quiz: 'Quizzes', deck: 'Flashcards', note: 'Notes', document: 'Class Materials' } as const;
function SharedCollection({ data, token }: { data: PublicCollection; token: string }) {
const groups = [{ id: null as string | null, name: '' }, ...data.folders].map((f) => ({ ...f, items: data.items.filter((i) => (f.id === null ? !i.folderId || !data.folders.some((x) => x.id === i.folderId) : i.folderId === f.id)) })).filter((g) => g.items.length > 0);
// One section per exam in the class's order; material outside any exam comes last.
const groups = [...data.folders, { id: null as string | null, name: 'Other' }].map((f) => ({ ...f, items: data.items.filter((i) => (f.id === null ? !i.folderId || !data.folders.some((x) => x.id === i.folderId) : i.folderId === f.id)) })).filter((g) => g.items.length > 0);
return (
<Frame>
<div className={cx('border-l-[5px] border-tab pl-4', `tab-${data.color}`)}>
@ -493,22 +498,36 @@ function SharedCollection({ data, token }: { data: PublicCollection; token: stri
<div className="card mt-8 p-6 text-sm text-ink-2">Nothing has been added here yet.</div>
) : (
groups.map((g) => (
<section key={g.id ?? 'none'} className="mt-7">
{g.name && <h2 className="eyebrow mb-2.5">{g.name}</h2>}
<ul className="card divide-y divide-line overflow-hidden">
{g.items.map((i) => (
<li key={`${i.kind}:${i.id}`}>
<Link to={`/s/${token}/${i.kind}/${i.id}`} className="flex items-center gap-3 px-4 py-3.5 hover:bg-ink/4">
<span className={cx('grid size-10 shrink-0 place-items-center rounded-[11px] [&>svg]:size-[18px]', i.kind === 'quiz' ? 'bg-accent-soft text-accent' : i.kind === 'deck' ? 'bg-marker/45 text-ink dark:bg-marker/20 dark:text-marker' : i.kind === 'document' ? 'bg-sunken text-ink-2' : 'bg-good-soft text-good')}>{ITEM_ICON[i.kind]}</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[15px] font-medium">{i.title}</span>
<span className="text-xs text-ink-3">{i.kind === 'quiz' ? plural(i.count, 'question') : i.kind === 'deck' ? plural(i.count, 'card') : i.kind === 'document' ? `Document${i.count ? ` · ${plural(i.count, 'page')}` : ''}` : 'Note'}</span>
</span>
<ChevronRight className="size-4 text-ink-3" />
</Link>
</li>
))}
</ul>
<section key={g.id ?? 'none'} className="mt-7" aria-label={g.name || undefined}>
{g.name && groups.length > 1 && <h2 className="mb-2.5 text-[17px] font-semibold">{g.name}</h2>}
<div className="card overflow-hidden">
{KIND_ORDER.filter((k) => g.items.some((i) => i.kind === k)).map((k, n) => {
const items = g.items.filter((i) => i.kind === k);
return (
<section key={k} aria-label={KIND_HEADING[k]}>
<h3 className={cx('eyebrow flex items-center gap-2 border-b border-line bg-sunken/60 px-4 py-2 [&>svg]:size-3.5', n > 0 && 'border-t')}>
{ITEM_ICON[k]}
{KIND_HEADING[k]}
<span className="num font-normal">{items.length}</span>
</h3>
<ul className="divide-y divide-line">
{items.map((i) => (
<li key={`${i.kind}:${i.id}`}>
<Link to={`/s/${token}/${i.kind}/${i.id}`} className="flex items-center gap-3 px-4 py-3.5 hover:bg-ink/4">
<span className={cx('grid size-10 shrink-0 place-items-center rounded-[11px] [&>svg]:size-[18px]', i.kind === 'quiz' ? 'bg-accent-soft text-accent' : i.kind === 'deck' ? 'bg-marker/45 text-ink dark:bg-marker/20 dark:text-marker' : i.kind === 'document' ? 'bg-sunken text-ink-2' : 'bg-good-soft text-good')}>{ITEM_ICON[i.kind]}</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[15px] font-medium">{i.title}</span>
<span className="text-xs text-ink-3">{i.kind === 'quiz' ? plural(i.count, 'question') : i.kind === 'deck' ? plural(i.count, 'card') : i.kind === 'document' ? (i.count ? plural(i.count, 'page') : 'File') : 'Note'}</span>
</span>
<ChevronRight className="size-4 text-ink-3" />
</Link>
</li>
))}
</ul>
</section>
);
})}
</div>
</section>
))
)}

View file

@ -718,14 +718,6 @@
background-position: -120% 0;
}
}
@keyframes sd-globe {
to {
transform: rotate(360deg);
}
}
.tool-spin-slow {
animation: sd-globe 2.4s linear infinite;
}
@keyframes sd-tool-done {
0% {
transform: scale(0.4);
@ -769,7 +761,6 @@
@media (prefers-reduced-motion: reduce) {
.genui-draw,
.tool-shimmer,
.tool-spin-slow,
.tool-pop,
.score-spark,
.ring-rainbow {

View file

@ -1,4 +1,4 @@
import { CircleAlert, Inbox, LoaderCircle, X } from 'lucide-react';
import { CircleAlert, Inbox, LoaderCircle, Sparkles, X } from 'lucide-react';
import { AlertDialog, Dialog as RDialog, DropdownMenu, Popover as RPopover, Switch as RSwitch, Tooltip as RTooltip } from 'radix-ui';
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useRef, useState, type ButtonHTMLAttributes, type InputHTMLAttributes, type ReactNode, type SelectHTMLAttributes, type TextareaHTMLAttributes } from 'react';
import { Link } from 'react-router';
@ -237,6 +237,16 @@ export function Spinner({ className, label = 'Loading' }: { className?: string;
return <LoaderCircle role="status" aria-label={label} className={cx('size-5 animate-spin text-ink-3', className)} />;
}
/** The AI is working: a breathing sparkle, as on drafts that are being generated. */
export function Thinking({ label = 'Thinking', className }: { label?: ReactNode; className?: string }) {
return (
<span role="status" className={cx('flex items-center gap-2 text-[13px] text-ink-3', className)}>
<Sparkles className="size-3.5 shrink-0 animate-pulse text-accent" aria-hidden />
{label}
</span>
);
}
export function Badge({ children, tone = 'neutral', className }: { children: ReactNode; tone?: 'neutral' | 'accent' | 'good' | 'bad' | 'warn' | 'marker'; className?: string }) {
const tones = {
neutral: 'bg-ink/6 text-ink-2',