First revision: DeepSeek, numeric questions, background assistant, UI fixes
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m2s

Providers and pricing
- Add a DeepSeek provider: thinking mode with low/high/max effort, reasoning_content
  replayed between tool steps, cache-hit usage, /models discovery and catalog prices.
- Fix "does not support tool calling": a rejected forced tool_choice (DeepSeek thinking
  mode) now asks for the call in the prompt; only a genuine no-tools 400 is "unsupported".
- Seven reasoning-effort levels (Off to Max) mapped per adapter.
- Cached-input price per model, cache-write and DeepSeek off-peak aware cost estimates.
- Built-in bge-small embedding model (transformers.js) as the semantic search default.

Quizzes
- Numeric (type-the-answer) questions: units ignored, optional ± tolerance; editor,
  runner, importer, templates and generation prompts.
- Quiz start screen instead of showing answers; navigator ring no longer clipped and
  key legend removed; clock only for timed exams; 7-point letter grades.

Assistant and generation
- Assistant turns run on the server independently of the browser, with re-attach and
  an explicit stop; drafts tray shows generations in progress.
- Per-chat model switcher, @-tagging of class materials, full-width assistant page and
  a smaller assistant button.
- Editable generation instructions and built-in presets, separate from the chatbot
  import instructions.

Other
- Dialog footer padding, keyboard hints removed, copy buttons work over plain HTTP,
  class and folder shares include documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-15 12:48:17 -07:00
parent ccdad9728b
commit f0aabe4d5d
63 changed files with 3892 additions and 488 deletions

View file

@ -1,5 +1,5 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { MessageSquare, Trash2 } from 'lucide-react';
import { MessageSquare, Plus, Trash2 } from 'lucide-react';
import { useNavigate, useParams } from 'react-router';
import AssistantPanel from '@/features/AssistantPanel';
import { api } from '@/lib/api';
@ -12,7 +12,12 @@ export default function AssistantPage() {
const navigate = useNavigate();
const qc = useQueryClient();
const confirm = useConfirm();
const history = useQuery({ queryKey: ['ai', 'conversations'], queryFn: () => api.get<{ conversations: { id: string; title: string; updatedAt: number }[] }>('/api/ai/conversations').then((r) => r.conversations) });
const history = useQuery({
queryKey: ['ai', 'conversations'],
queryFn: () => api.get<{ conversations: { id: string; title: string; updatedAt: number; running?: boolean }[] }>('/api/ai/conversations').then((r) => r.conversations),
// Keep "Working…" labels current while an answer is being written in the background.
refetchInterval: (q) => (q.state.data?.some((c) => c.running) ? 3000 : false),
});
const remove = async (id: string) => {
if (!(await confirm({ title: 'Delete this conversation?', confirmLabel: 'Delete', danger: true, message: 'The messages are removed. Drafts and anything you saved are kept.' }))) return;
@ -22,9 +27,14 @@ export default function AssistantPage() {
};
return (
<div className="-mx-4 -mt-6 -mb-28 flex h-[calc(100dvh-52px-56px)] sm:-mx-8 lg:mx-0 lg:-mt-10 lg:-mb-16 lg:h-dvh lg:gap-6">
<aside className="hidden w-60 shrink-0 flex-col border-r border-line py-6 pr-3 lg:flex">
<div className="eyebrow mb-2 px-2">Conversations</div>
<div className="flex h-[calc(100dvh-52px-56px)] lg:h-dvh">
<aside className="hidden w-64 shrink-0 flex-col border-r border-line bg-paper px-3 py-5 lg:flex">
<div className="mb-2 flex items-center justify-between px-2">
<span className="eyebrow">Conversations</span>
<IconButton label="New chat" size="sm" className="-mr-1.5 size-7" onClick={() => navigate('/assistant')}>
<Plus />
</IconButton>
</div>
<div className="min-h-0 flex-1 space-y-0.5 overflow-y-auto">
{(history.data ?? []).length === 0 && <p className="px-2 text-[13px] text-ink-3">Your conversations will be listed here.</p>}
{(history.data ?? []).map((c) => (
@ -34,7 +44,7 @@ export default function AssistantPage() {
<MessageSquare className="size-3.5 shrink-0 text-ink-3" />
<span className="truncate text-sm">{c.title}</span>
</span>
<span className="pl-[22px] text-[11px] text-ink-3">{timeAgo(c.updatedAt)}</span>
<span className="pl-[22px] text-[11px] text-ink-3">{c.running ? 'Working…' : timeAgo(c.updatedAt)}</span>
</button>
<IconButton label="Delete conversation" size="sm" className="mr-1 opacity-0 group-hover:opacity-100 focus-visible:opacity-100" onClick={() => remove(c.id)}>
<Trash2 />
@ -43,7 +53,7 @@ export default function AssistantPage() {
))}
</div>
</aside>
<div className="flex min-w-0 flex-1 flex-col">
<div className="flex min-w-0 flex-1 flex-col bg-surface/40">
<AssistantPanel variant="page" conversationId={conversationId} onConversationChange={(id) => navigate(id ? `/assistant/${id}` : '/assistant', { replace: true })} />
</div>
</div>

View file

@ -43,6 +43,7 @@ import type { DeckItem, DocumentItem, Folder, Item, NoteItem, QuizItem } from '@
import { cx, downloadFile, formatBytes, gradeTone, plural, timeAgo, useDocumentTitle, useLocalStorage } from '@/lib/util';
import { SortableList, type SortableRenderProps } from '@/ui/Sortable';
import { Badge, Button, Dialog, EmptyState, ErrorState, Field, IconButton, Input, Menu, MenuItem, MenuSeparator, ProgressBar, Segmented, Skeleton, Textarea, useConfirm } from '@/ui';
import { letterGrade } from '@shared/content';
type Filter = 'all' | 'quiz' | 'deck' | 'document' | 'note';
@ -70,7 +71,7 @@ function itemMeta(item: Item): ReactNode {
<>
<span>{plural(q.questionCount, 'question')}</span>
{q.lastPercent !== null && (
<span className={cx('num font-medium', { good: 'text-good', warn: 'text-warn', bad: 'text-bad', none: '' }[gradeTone(q.lastPercent)])}>Last {q.lastPercent}%</span>
<span className={cx('num font-medium', { good: 'text-good', warn: 'text-warn', bad: 'text-bad', none: '' }[gradeTone(q.lastPercent)])}>Last {letterGrade(q.lastPercent ?? 0)} · {q.lastPercent}%</span>
)}
{q.lastStudiedAt && <span>{timeAgo(q.lastStudiedAt)}</span>}
</>

View file

@ -343,7 +343,6 @@ export default function DeckPage() {
</div>
<CardEditor value={fresh} onChange={setFresh} onSubmit={addCard} />
<div className="mt-4 flex items-center justify-end gap-3">
<span className="hidden text-xs text-ink-3 sm:block">Ctrl+Enter adds the card and starts the next one</span>
<Button variant="primary" icon={<Plus />} loading={adding} disabled={!fresh.front.trim() || !fresh.back.trim()} onClick={addCard}>
Add card
</Button>

View file

@ -149,7 +149,7 @@ export default function DraftPage() {
</p>
<ProgressBar value={Math.max(0.04, draft.progress)} className="mx-auto mt-6 h-2 max-w-sm" label="Generation progress" />
{draft.kind !== 'note' && partial > 0 && <p className="mt-3 text-sm text-ink-3">{plural(partial, draft.kind === 'quiz' ? 'question' : 'card')} so far</p>}
<p className="mt-6 text-[13px] text-ink-3">You can leave this page. The draft keeps generating and will be waiting here.</p>
<p className="mt-6 text-[13px] text-ink-3">You can leave this page. Generation continues on the server; follow it under Drafts in the sidebar (or on Today) and come back when it is ready.</p>
<Button
variant="ghost"
className="mt-4"

View file

@ -9,6 +9,8 @@ import { useAiStatus, useClasses, useOverview } from '@/lib/queries';
import type { AttemptSummary } from '@/lib/types';
import { cx, gradeTone, pct, plural, timeAgo, useDocumentTitle } from '@/lib/util';
import { Badge, Button, ClassDot, ErrorState, ProgressBar, Section, Skeleton } from '@/ui';
import { DraftsSection } from '@/features/DraftsTray';
import { letterGrade } from '@shared/content';
function greeting(): string {
const h = new Date().getHours();
@ -186,6 +188,8 @@ export default function Home() {
</div>
</div>
<DraftsSection />
{o.activeAttempts.length > 0 && (
<Section title="Pick up where you left off">
<div className="card divide-y divide-line overflow-hidden">
@ -247,7 +251,7 @@ export default function Home() {
const tone = gradeTone(p);
return (
<Link key={a.id} to={`/session/${a.id}`} className="flex items-center gap-3 px-4 py-3 hover:bg-ink/4">
<span className={cx('num grid h-9 w-12 shrink-0 place-items-center rounded-[10px] text-sm font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>{p === null ? '—' : `${p}%`}</span>
<span className={cx('num grid h-9 min-w-12 shrink-0 place-items-center rounded-[10px] px-1.5 text-[13px] font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>{p === null ? '—' : `${letterGrade(p)} ${p}%`}</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium">{a.title}</span>
<span className="text-xs text-ink-3">

View file

@ -10,6 +10,7 @@ import { useAiStatus, useClasses } from '@/lib/queries';
import type { Insights } from '@/lib/types';
import { cx, gradeTone, pct, plural, timeAgo, useDocumentTitle } from '@/lib/util';
import { Button, ClassDot, EmptyState, ErrorState, PageHeader, Section, Segmented, Select, Skeleton } from '@/ui';
import { letterGrade } from '@shared/content';
function Stat({ label, value, sub, tone }: { label: string; value: string; sub?: string; tone?: 'good' | 'warn' | 'bad' | 'none' }) {
return (
@ -184,7 +185,7 @@ export default function InsightsPage() {
const tone = gradeTone(p);
return (
<Link key={a.id} to={`/session/${a.id}`} className="flex items-center gap-3 px-4 py-2.5 hover:bg-ink/4">
<span className={cx('num grid h-8 w-12 shrink-0 place-items-center rounded-[9px] text-[13px] font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>{p === null ? '—' : `${p}%`}</span>
<span className={cx('num grid h-8 min-w-12 shrink-0 place-items-center rounded-[9px] px-1.5 text-[12.5px] font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>{p === null ? '—' : `${letterGrade(p)} ${p}%`}</span>
<span className="min-w-0 flex-1 truncate text-sm font-medium">{a.title}</span>
<span className="shrink-0 text-xs text-ink-3">
{a.mode === 'exam' ? 'Exam · ' : ''}

View file

@ -2,7 +2,7 @@ import { ArrowDown, ArrowUp, BookOpen, Check, ChevronRight, ClipboardList, Copy,
import { useEffect, useMemo, useRef, useState } from 'react';
import { Link, useNavigate, useParams, useSearchParams } from 'react-router';
import { toast } from 'sonner';
import { blankQuestion, optionLetter, QUESTION_TYPE_LABEL, questionToDraft, validateDraftQuestion, type DraftCard, type DraftQuestion, type Question } from '@shared/content';
import { blankQuestion, letterGrade, optionLetter, QUESTION_TYPE_LABEL, questionToDraft, validateDraftQuestion, type DraftCard, type DraftQuestion, type Question } from '@shared/content';
import { parseImport } from '@shared/importer';
import { MoveDialog, RenameDialog, ShareDialog } from '@/features/dialogs';
import { QuestionEditor } from '@/features/editors';
@ -22,19 +22,20 @@ interface StartPrefs {
shuffleOptions: boolean;
}
export function StartSessionDialog({ open, onClose, quizId, total, title }: { open: boolean; onClose: () => void; quizId: string; total: number; title: string }) {
/** Session options (mode, length, shuffling, exam time limit), shared by the start screen and the start dialog. */
function useStartOptions(quizId: string, total: number, active: boolean) {
const { start, starting } = useStartSession();
const [prefs, setPrefs] = useLocalStorage<StartPrefs>('sd.startPrefs', { mode: 'practice', shuffleQuestions: true, shuffleOptions: true });
const [count, setCount] = useState(total);
const [timed, setTimed] = useState(false);
const [minutes, setMinutes] = useState(30);
useEffect(() => {
if (open) {
if (active) {
setCount(total);
setMinutes(Math.max(5, Math.round(total * 1.2)));
setTimed(false);
}
}, [open, total]);
}, [active, total]);
const go = () =>
start({
mode: prefs.mode,
@ -42,25 +43,15 @@ export function StartSessionDialog({ open, onClose, quizId, total, title }: { op
shuffleQuestions: prefs.shuffleQuestions,
shuffleOptions: prefs.shuffleOptions,
count: count < total ? count : undefined,
// A time limit is an exam option only; practice sessions are never timed.
timeLimitMin: prefs.mode === 'exam' && timed ? minutes : null,
});
return { prefs, setPrefs, count, setCount, timed, setTimed, minutes, setMinutes, go, starting, total };
}
function StartOptionsFields({ o }: { o: ReturnType<typeof useStartOptions> }) {
const { prefs, setPrefs, count, setCount, timed, setTimed, minutes, setMinutes, total } = o;
return (
<Dialog
open={open}
onOpenChange={(o) => !o && onClose()}
title="Start a session"
description={title}
footer={
<>
<Button variant="ghost" onClick={onClose}>
Cancel
</Button>
<Button variant="primary" icon={<Play className="fill-current" />} loading={starting} onClick={go}>
Start
</Button>
</>
}
>
<div className="space-y-5">
<div className="grid grid-cols-2 gap-2" role="radiogroup" aria-label="Mode">
{(
@ -102,10 +93,75 @@ export function StartSessionDialog({ open, onClose, quizId, total, title }: { op
)}
</div>
</div>
);
}
export function StartSessionDialog({ open, onClose, quizId, total, title }: { open: boolean; onClose: () => void; quizId: string; total: number; title: string }) {
const o = useStartOptions(quizId, total, open);
return (
<Dialog
open={open}
onOpenChange={(v) => !v && onClose()}
title="Start a session"
description={title}
footer={
<>
<Button variant="ghost" onClick={onClose}>
Cancel
</Button>
<Button variant="primary" icon={<Play className="fill-current" />} loading={o.starting} onClick={o.go}>
Start
</Button>
</>
}
>
<StartOptionsFields o={o} />
</Dialog>
);
}
/** The quiz start screen: how to take it, without showing any questions or answers. */
function StartPanel({ quizId, total, resume, onShowQuestions }: { quizId: string; total: number; resume: { id: string; answeredCount: number; questionCount: number } | null; onShowQuestions: () => void }) {
const o = useStartOptions(quizId, total, true);
if (total === 0) {
return (
<div className="card border-dashed">
<EmptyState icon={<BookOpen />} title="No questions yet" action={<Button variant="primary" icon={<Plus />} onClick={onShowQuestions}>Add questions</Button>}>
Add questions to this quiz before taking it.
</EmptyState>
</div>
);
}
return (
<section className="card p-5 sm:p-6">
{resume && (
<Callout
tone="warn"
icon={<Play />}
className="mb-5"
title="You have a session in progress"
action={
<Button to={`/session/${resume.id}`} variant="marker" size="sm">
Resume ({resume.answeredCount}/{resume.questionCount})
</Button>
}
>
Pick up where you left off, or start a new session below.
</Callout>
)}
<StartOptionsFields o={o} />
<div className="mt-6 flex flex-wrap items-center gap-2 border-t border-line pt-5">
<Button variant="primary" size="lg" icon={<Play className="fill-current" />} loading={o.starting} onClick={o.go} className="min-w-40">
{resume ? 'Start new session' : 'Start'}
</Button>
<Button variant="ghost" size="lg" icon={<ClipboardList />} onClick={onShowQuestions} className="ml-auto">
View questions and answers
</Button>
</div>
</section>
);
}
/** Paste several questions (or cards) as text or JSON and add them to an existing item. */
export function BulkAddDialog({ open, onClose, kind, onAdd }: { open: boolean; onClose: () => void; kind: 'quiz' | 'deck'; onAdd: (items: unknown[]) => Promise<void> }) {
const [text, setText] = useState('');
@ -230,7 +286,8 @@ export default function QuizPage() {
useAssistantContext(data?.quiz.classId, data?.quiz.title);
const { start, starting } = useStartSession();
const [tab, setTab] = useState<'questions' | 'history'>('questions');
// The start screen comes first, so opening a quiz never reveals its answers.
const [tab, setTab] = useState<'start' | 'questions' | 'history'>(() => (params.get('q') || params.get('edit') ? 'questions' : 'start'));
const [editing, setEditing] = useState<string | 'new' | null>(null);
const [draft, setDraft] = useState<DraftQuestion>(blankQuestion());
const [saving, setSaving] = useState(false);
@ -252,8 +309,10 @@ export default function QuizPage() {
if (params.get('edit')) {
setDraft(blankQuestion());
setEditing('new');
setTab('questions');
}
const target = params.get('q');
if (target) setTab('questions');
if (target) setTimeout(() => document.getElementById(`q-${target}`)?.scrollIntoView({ block: 'center', behavior: 'smooth' }), 120);
if (params.get('start') || params.get('edit')) {
next.delete('start');
@ -299,6 +358,7 @@ export default function QuizPage() {
setEditing(question.id);
};
const beginNew = () => {
setTab('questions');
setDraft({ ...blankQuestion(), topic: questions[questions.length - 1]?.topic ?? '' });
setEditing('new');
setTimeout(() => newRef.current?.scrollIntoView({ block: 'center', behavior: 'smooth' }), 60);
@ -358,7 +418,7 @@ export default function QuizPage() {
const editorFooter = (isNew: boolean) => (
<div className="mt-5 flex flex-wrap items-center justify-end gap-2 border-t border-line pt-4">
<span className="mr-auto hidden text-xs text-ink-3 sm:block">Ctrl+Enter to save</span>
<span className="mr-auto" />
<Button variant="ghost" onClick={() => setEditing(null)}>
Cancel
</Button>
@ -393,10 +453,16 @@ export default function QuizPage() {
{full.length > 0 && (
<>
<span>
Last <strong className="num text-ink">{last}%</strong>
Last{' '}
<strong className="num text-ink">
{last !== null ? `${letterGrade(last)} · ${last}%` : '—'}
</strong>
</span>
<span>
Best <strong className="num text-ink">{best}%</strong>
Best{' '}
<strong className="num text-ink">
{best !== null ? `${letterGrade(best)} · ${best}%` : '—'}
</strong>
</span>
<span>{plural(history.length, 'attempt')}</span>
</>
@ -414,9 +480,11 @@ export default function QuizPage() {
Resume ({data.activeAttempt.answeredCount}/{data.activeAttempt.questionCount})
</Button>
) : null}
<Button variant={data.activeAttempt ? 'secondary' : 'primary'} size="lg" icon={<Play className="fill-current" />} disabled={questions.length === 0} onClick={() => setStartOpen(true)}>
{data.activeAttempt ? 'Start new' : 'Start'}
</Button>
{tab !== 'start' && (
<Button variant={data.activeAttempt ? 'secondary' : 'primary'} size="lg" icon={<Play className="fill-current" />} disabled={questions.length === 0} onClick={() => setStartOpen(true)}>
{data.activeAttempt ? 'Start new' : 'Start'}
</Button>
)}
<Menu
trigger={
<IconButton label="Quiz options" tooltip={false}>
@ -488,6 +556,7 @@ export default function QuizPage() {
onChange={setTab}
label="View"
options={[
{ value: 'start', label: 'Start', icon: <Play /> },
{ value: 'questions', label: `Questions`, icon: <ClipboardList /> },
{ value: 'history', label: `History${history.length ? ` (${history.length})` : ''}`, icon: <History /> },
]}
@ -509,7 +578,14 @@ export default function QuizPage() {
)}
</div>
{tab === 'questions' ? (
{tab === 'start' ? (
<StartPanel
quizId={quiz.id}
total={questions.length}
resume={data.activeAttempt ? { id: data.activeAttempt.id, answeredCount: data.activeAttempt.answeredCount, questionCount: data.activeAttempt.questionCount } : null}
onShowQuestions={() => (questions.length === 0 ? beginNew() : setTab('questions'))}
/>
) : tab === 'questions' ? (
<>
{questions.length === 0 && editing !== 'new' ? (
<div className="card border-dashed">
@ -634,7 +710,7 @@ export default function QuizPage() {
<>
{full.length >= 2 && (
<Callout className="mb-3" tone={last !== null && best !== null && last >= best ? 'good' : 'neutral'}>
{last !== null && best !== null && last >= best ? `Your latest attempt (${last}%) is your best so far.` : `Latest ${last}%, best ${best}% across ${plural(full.length, 'full attempt')}.`}
{last !== null && best !== null && last >= best ? `Your latest attempt (${letterGrade(last)}, ${last}%) is your best so far.` : `Latest ${last !== null ? `${letterGrade(last)} (${last}%)` : '—'}, best ${best !== null ? `${letterGrade(best)} (${best}%)` : '—'} across ${plural(full.length, 'full attempt')}.`}
</Callout>
)}
<ul className="card divide-y divide-line">
@ -644,7 +720,16 @@ export default function QuizPage() {
return (
<li key={h.id}>
<Link to={`/session/${h.id}`} className="flex items-center gap-3 px-4 py-3 hover:bg-ink/4">
<span className={cx('num grid h-10 w-14 shrink-0 place-items-center rounded-[10px] text-[15px] font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>{p === null ? '—' : `${p}%`}</span>
<span className={cx('num grid h-11 w-14 shrink-0 place-items-center rounded-[10px] leading-none font-semibold', tone === 'good' ? 'bg-good-soft text-good' : tone === 'warn' ? 'bg-warn-soft text-warn' : tone === 'bad' ? 'bg-bad-soft text-bad' : 'bg-sunken text-ink-3')}>
{p === null ? (
'—'
) : (
<span className="flex flex-col items-center gap-0.5">
<span className="text-[16px]">{letterGrade(p)}</span>
<span className="text-[11px] font-medium opacity-80">{p}%</span>
</span>
)}
</span>
<span className="min-w-0 flex-1">
<span className="block text-sm font-medium">
{h.completedAt ? formatDateTime(h.completedAt) : ''}

View file

@ -5,12 +5,12 @@ import { useNavigate, useSearchParams } from 'react-router';
import { toast } from 'sonner';
import { CardEditor } from '@/features/editors';
import { Explain } from '@/features/Explain';
import { FlipCard, KeyHints, StreakChip, StudyFooter, StudyTopBar, useStreak } from '@/features/flashcards';
import { FlipCard, StreakChip, StudyFooter, StudyTopBar, useStreak } from '@/features/flashcards';
import { api, errorMessage } from '@/lib/api';
import { useAiStatus, useRefresh } from '@/lib/queries';
import type { DueCounts, QueueCard } from '@/lib/types';
import { cx, formatMinutes, plural, useDocumentTitle, useHotkeys } from '@/lib/util';
import { Badge, Button, ClassDot, Dialog, ErrorState, IconButton, Kbd, Menu, MenuItem, PageLoading } from '@/ui';
import { Badge, Button, ClassDot, Dialog, ErrorState, IconButton, Menu, MenuItem, PageLoading } from '@/ui';
interface QueueResponse {
cards: QueueCard[];
@ -207,7 +207,7 @@ export default function ReviewPage() {
<Badge tone="good">{counts.review} due</Badge>
</div>
<span className="num text-[13px] font-medium text-ink-2 sm:hidden">{remaining} left</span>
<IconButton label="Undo last rating (U)" onClick={undo} disabled={!last || busy}>
<IconButton label="Undo last rating" onClick={undo} disabled={!last || busy}>
<Undo2 />
</IconButton>
{current && (
@ -220,7 +220,6 @@ export default function ReviewPage() {
>
<MenuItem
icon={<Pencil />}
hint="E"
onSelect={() => {
setDraft({ front: current.card.front, back: current.card.back, hint: current.card.hint, tags: current.card.tags });
setEditing(current);
@ -305,16 +304,6 @@ export default function ReviewPage() {
Show answer
</Button>
)}
<KeyHints
items={[
[<><Kbd>Space</Kbd><Kbd>↑</Kbd><Kbd>↓</Kbd></>, 'flip'],
[<Kbd>←</Kbd>, 'again'],
[<Kbd>→</Kbd>, 'good'],
[<><Kbd>1</Kbd>–<Kbd>4</Kbd></>, 'rate'],
[<Kbd>U</Kbd>, 'undo'],
[<Kbd>E</Kbd>, 'edit'],
]}
/>
</StudyFooter>
)}

View file

@ -4,6 +4,7 @@ import { lazy, Suspense, useEffect, useRef, useState, type ReactNode } from 'rea
import { NavLink, useNavigate, useParams } from 'react-router';
import { toast } from 'sonner';
import { shareUrl } from '@/features/dialogs';
import { TemplateSettings } from '@/features/TemplateSettings';
import { api, errorMessage } from '@/lib/api';
import { qk, useRefresh } from '@/lib/queries';
import type { AppSettings, ShareListItem, Template } from '@/lib/types';
@ -220,58 +221,6 @@ function SharingSettings() {
);
}
/* ------------------------------ templates ------------------------------ */
function TemplateSettings() {
const refresh = useRefresh();
const q = useQuery({ queryKey: qk.templates, queryFn: () => api.get<{ templates: Template[] }>('/api/templates').then((r) => r.templates) });
if (!q.data) return <Skeleton className="h-48" />;
const groups: { kind: Template['kind']; title: string; blurb: string }[] = [
{ kind: 'generation', title: 'AI generation presets', blurb: 'Appear under "Preset" when you generate with AI.' },
{ kind: 'quiz', title: 'Quiz templates', blurb: 'Appear under "Start from" when you create a quiz. Save any quiz as a template from its menu.' },
{ kind: 'deck', title: 'Flashcard templates', blurb: 'Appear under "Start from" when you create a deck.' },
];
return (
<>
{groups.map((g) => {
const list = q.data!.filter((t) => t.kind === g.kind);
return (
<Section key={g.kind} title={g.title}>
<ul className="card divide-y divide-line">
{list.map((t) => (
<li key={t.id} className="flex items-center gap-3 px-4 py-3">
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="truncate text-sm font-medium">{t.name}</span>
{t.builtin ? <Badge>Built in</Badge> : <Badge tone="accent">Yours</Badge>}
</div>
{t.description && <div className="mt-0.5 line-clamp-2 text-[13px] text-ink-2">{t.description}</div>}
{t.kind !== 'generation' && <div className="mt-0.5 text-xs text-ink-3">{t.kind === 'quiz' ? plural((t.payload.questions ?? []).length, 'question') : plural((t.payload.cards ?? []).length, 'card')}</div>}
</div>
{!t.builtin && (
<IconButton
label="Delete template"
size="sm"
onClick={async () => {
await api.del(`/api/templates/${t.id}`).catch((e) => toast.error(errorMessage(e)));
await refresh();
}}
>
<Trash2 />
</IconButton>
)}
</li>
))}
{list.length === 0 && <li className="px-4 py-4 text-[13px] text-ink-3">None yet.</li>}
</ul>
<p className="mt-2 text-xs text-ink-3">{g.blurb}</p>
</Section>
);
})}
</>
);
}
/* ------------------------------ data ------------------------------ */
interface V1Summary {

View file

@ -362,11 +362,11 @@ function SharedNote({ note, back }: { note: PublicNote; back?: { to: string; lab
);
}
function SharedDocument({ doc, token }: { doc: PublicDocument; token: string }) {
const url = `/api/public/${token}/file`;
function SharedDocument({ doc, token, nested, back }: { doc: PublicDocument; token: string; nested?: boolean; back?: { to: string; label: string } }) {
const url = nested ? `/api/public/${token}/items/document/${doc.id}/file` : `/api/public/${token}/file`;
const inline = doc.docKind === 'pdf' || doc.docKind === 'image';
return (
<Frame>
<Frame back={back}>
<div className="eyebrow mb-2 flex items-center gap-1.5">
<FileText className="size-3.5" /> Shared document
</div>
@ -384,7 +384,7 @@ function SharedDocument({ doc, token }: { doc: PublicDocument; token: string })
);
}
const ITEM_ICON = { quiz: <BookOpen />, deck: <Layers />, note: <NotebookPen /> };
const ITEM_ICON = { quiz: <BookOpen />, deck: <Layers />, note: <NotebookPen />, document: <FileText /> };
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);
@ -405,10 +405,10 @@ function SharedCollection({ data, token }: { data: PublicCollection; token: stri
{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' : 'bg-good-soft text-good')}>{ITEM_ICON[i.kind]}</span>
<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') : 'Note'}</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>
@ -464,7 +464,7 @@ export default function SharedPage() {
case 'note':
return <SharedNote note={data} back={back} />;
case 'document':
return <SharedDocument doc={data} token={token} />;
return <SharedDocument doc={data} token={token} nested={nested} back={back} />;
case 'collection':
return <SharedCollection data={data} token={token} />;
}