Spaces:
Sleeping
Sleeping
Improve instructor round navigation and analytics
Browse filesFiles changed (3)
128 unmodified lines12913013113213313410 unmodified lines1451461471481491509 unmodified lines1601611621631641655 unmodified lines171172173174175176128 unmodified linesexpect(mocks.instructorRoundAttempts).not.toHaveBeenCalled();await user.click(screen.getByRole("button", { name: "View attempts" }));expect(mocks.instructorRoundAttempts).toHaveBeenCalledWith("private-1", 0);await user.click(await screen.findByText("Attempt student"));expect(screen.getByText("Elapsed from start to submission")).toBeTruthy();expect(screen.getByText("1h 5m 12s")).toBeTruthy();10 unmodified linesawait user.click(screen.getByText("Student diff (before / after)"));expect(screen.getByText("- old + new")).toBeTruthy();expect(screen.queryByText("workspace-private")).toBeNull();});it("lets course admins view another instructor's attempts without management controls", async () => {9 unmodified linesexpect(mocks.instructorRoundAttempts).toHaveBeenCalledWith("other-private", 0);});it("paginates attempts and labels missing or partial test history and invalid elapsed dates", async () => {const user = userEvent.setup();mocks.session.mockResolvedValue({ authenticated: true, identity, role: "instructor", has_model_key: true, workspace_id: null });5 unmodified linesawait user.click(await screen.findByRole("button", { name: "Managed rounds" }));await user.click(await screen.findByRole("button", { name: "View attempts" }));await user.click(await screen.findByText("First learner"));expect(screen.getByText("History unavailable")).toBeTruthy();expect(screen.getByText("Chat history unavailable.")).toBeTruthy();expect(screen.getByText("Elapsed from start to last activity")).toBeTruthy();128 unmodified lines12913013113213313413513613713813910 unmodified lines1501511521531541551561571581599 unmodified lines1691701711721731741751761771781791801811821831841851861871881891901911921931941955 unmodified lines201202203204205206207128 unmodified linesexpect(mocks.instructorRoundAttempts).not.toHaveBeenCalled();await user.click(screen.getByRole("button", { name: "View attempts" }));expect(mocks.instructorRoundAttempts).toHaveBeenCalledWith("private-1", 0);expect(await screen.findByRole("dialog", { name: "private · Attempts" })).toBeTruthy();expect(screen.getByText("1 loaded attempt")).toBeTruthy();expect(screen.getByText("Latest score per attempt · 1 scored")).toBeTruthy();const scoreChart = screen.getByRole("region", { name: "Score distribution" });expect(within(scoreChart).getByText("80–100").closest("li")?.textContent).toBe("80–1001");await user.click(await screen.findByText("Attempt student"));expect(screen.getByText("Elapsed from start to submission")).toBeTruthy();expect(screen.getByText("1h 5m 12s")).toBeTruthy();10 unmodified linesawait user.click(screen.getByText("Student diff (before / after)"));expect(screen.getByText("- old + new")).toBeTruthy();expect(screen.queryByText("workspace-private")).toBeNull();await user.click(screen.getByRole("button", { name: "Back to rounds" }));expect(screen.queryByRole("dialog", { name: "private · Attempts" })).toBeNull();expect(screen.getByText("Summary student")).toBeTruthy();expect(document.activeElement).toBe(screen.getByRole("button", { name: "View attempts" }));});it("lets course admins view another instructor's attempts without management controls", async () => {9 unmodified linesexpect(mocks.instructorRoundAttempts).toHaveBeenCalledWith("other-private", 0);});it("returns from attempts to the open rounds panel without losing editor changes", async () => {const user = userEvent.setup();mocks.session.mockResolvedValue({ authenticated: true, identity, role: "instructor", has_model_key: true, workspace_id: "workspace-1" });mocks.instructorDashboard.mockResolvedValue({ rounds: [{ round_id: "private-draft", repo_url: null, target_file: null, status: "open", timer_minutes: 0, chat_messages_per_student: 5, visibility: "private", participants: [] }] });render(<App />);const editor = await screen.findByRole("textbox", { name: "Code editor" });await user.clear(editor);await user.type(editor, "unsaved draft");await user.click(screen.getByRole("button", { name: "Managed rounds" }));await user.click(await screen.findByRole("button", { name: "View attempts" }));expect(await screen.findByRole("dialog", { name: "Challenge round · Attempts" })).toBeTruthy();await user.keyboard("{Escape}");expect(screen.queryByRole("dialog")).toBeNull();expect(screen.getByRole("button", { name: "Managed rounds" }).getAttribute("aria-expanded")).toBe("true");expect((editor as HTMLTextAreaElement).value).toBe("unsaved draft");await user.click(screen.getByRole("button", { name: "Managed rounds" }));expect(screen.queryByRole("region", { name: "Managed rounds" })).toBeNull();expect((editor as HTMLTextAreaElement).value).toBe("unsaved draft");});it("paginates attempts and labels missing or partial test history and invalid elapsed dates", async () => {const user = userEvent.setup();mocks.session.mockResolvedValue({ authenticated: true, identity, role: "instructor", has_model_key: true, workspace_id: null });5 unmodified linesawait user.click(await screen.findByRole("button", { name: "Managed rounds" }));await user.click(await screen.findByRole("button", { name: "View attempts" }));await user.click(await screen.findByText("First learner"));expect(screen.getByText("1 loaded attempt · Partial results")).toBeTruthy();expect(screen.getByText("History unavailable")).toBeTruthy();expect(screen.getByText("Chat history unavailable.")).toBeTruthy();expect(screen.getByText("Elapsed from start to last activity")).toBeTruthy();
1 unmodified line23456710 unmodified lines18192021222372 unmodified lines969798991001011021031041051069 unmodified lines11611711811912012112212312412531 unmodified lines15715815916016116216316416516621 unmodified lines18818919019119219319419519619719837 unmodified lines236237238239240241625 unmodified lines867868869870871872873281 unmodified lines115511561157115811591160116113 unmodified lines11751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120743 unmodified lines125112521253125412551256125713 unmodified lines12711272127312741275127612779 unmodified lines128712881289129012911292129312941 unmodified lineimport Editor from "@monaco-editor/react";import {AlertCircle,Check,CheckCircle2,ChevronDown,10 unmodified linesLogOut,MessageSquareText,LogIn,Play,RefreshCw,RotateCcw,72 unmodified linesreturn passed == null || total == null ? "Unavailable" : `${passed}/${total}`;}function RoundAttempts({ roundId }: { roundId: string }) {const [open, setOpen] = useState(false);const [page, setPage] = useState<InstructorAttemptsPage | null>(null);const [loading, setLoading] = useState(false);const [error, setError] = useState("");async function load(offset: number) {setLoading(true);9 unmodified lines}return <div className="round-attempts"><button type="button" className="button button-secondary" aria-expanded={open} onClick={() => { setOpen(!open); if (!open && !page && !loading) void load(0); }}><History size={15} />{open ? "Hide attempts" : "View attempts"}</button>{open && <div className="attempt-list">{page?.attempts.map((attempt) => <details className="attempt-detail" key={attempt.workspace_id}><summary><strong>{attempt.student_name || "Student"}</strong><span>{attempt.status.replaceAll("_", " ")}</span><ChevronDown size={15} /></summary><div className="attempt-content">31 unmodified lines{loading && <p role="status">Loading attempts...</p>}{error && <div className="attempt-error"><p className="notice notice-error" role="alert">{error}</p><button type="button" className="button button-secondary" onClick={() => void load(page?.next_offset ?? 0)} disabled={loading}><RefreshCw size={15} />Retry</button></div>}{!loading && !error && page?.has_more && page.next_offset !== null && <button type="button" className="button button-secondary" onClick={() => void load(page.next_offset!)}>Load more attempts</button>}</div>}</div>;}function App() {const [config, setConfig] = useState<AppConfig | null>(null);const [session, setSession] = useState<SessionInfo | null>(null);21 unmodified linesconst [publicChallenges, setPublicChallenges] = useState<PublicChallengeRound[]>([]);const [publicChallengesLoading, setPublicChallengesLoading] = useState(false);const [historyLoading, setHistoryLoading] = useState(false);const [topbarSurface, setTopbarSurface] = useState<"public" | "history" | "requests" | null>(null);const [instructorDashboard, setInstructorDashboard] = useState<InstructorDashboard | null>(null);const [roundSettingsDrafts, setRoundSettingsDrafts] = useState<Record<string, RoundSettingsDraft>>({});const [editingRoundId, setEditingRoundId] = useState<string | null>(null);const [managedRoundsOpen, setManagedRoundsOpen] = useState(false);const [dashboardLoading, setDashboardLoading] = useState(false);const [copiedManagedRoundId, setCopiedManagedRoundId] = useState<string | null>(null);const [courseAccess, setCourseAccess] = useState<CourseAccessStatus | null>(null);37 unmodified linesconst chatMessageCount = challenge?.chat_messages_used ?? 0;const chatMessageLimit = challenge?.chat_messages_per_student ?? 5;const chatLimitReached = chatMessageCount >= chatMessageLimit && !challenge?.confirmation_pending;function formatTestActual(actual: unknown): string {if (actual === undefined) return "—";625 unmodified linesawait loadStudentHistorySummary();}function toggleTopbarSurface(surface: "public" | "history" | "requests") {setTopbarSurface((current) => current === surface ? null : surface);}281 unmodified lines<header className="topbar"><div className="brand-lockup"><span className="brand-mark"><Code2 size={18} /></span><span>FIELDNOTES <i>/ CODE LAB</i></span></div><div className="topbar-context"><span>DEBUGGING WORKSHOP</span>{challenge && <><ChevronRight size={14} /><span className="context-repo">{challenge.repo_url.split("/").slice(-1)[0]}</span></>}</div><div className="user-menu"><button className="icon-button topbar-badge-button" onClick={() => { toggleTopbarSurface("public"); void handleLoadPublicChallenges(); }} aria-label="Open public challenges" title="Public challenges"><Globe2 size={17} /></button>{session.is_course_admin && <button className="icon-button topbar-badge-button" onClick={() => { toggleTopbarSurface("requests"); void handleLoadCourseAccess(); }} aria-label="Instructor access requests" title="Instructor access requests"><UserPlus size={17} />{courseAccessRequests.length > 0 && <span className="topbar-badge">{courseAccessRequests.length}</span>}</button>}<span className="user-avatar">{(identity.display_name || identity.username).charAt(0).toUpperCase()}</span><span className="user-name">{identity.display_name || identity.username}</span><button className="icon-button" onClick={() => void handleLoadHistory()} aria-label="Challenge history" title="Challenge history"><History size={17} /></button><button className="icon-button" onClick={() => void handleLogout()} aria-label="Sign out" title="Sign out"><LogOut size={17} /></button></div></header>{error && <div className="global-notice notice-error" role="alert"><AlertCircle size={17} />{error}<button className="notice-dismiss" onClick={() => setError("")} aria-label="Dismiss"><XCircle size={16} /></button></div>}13 unmodified lines{topbarSurface === "history" && renderHistoryPanel()}{topbarSurface === "requests" && session.is_course_admin && renderInstructorRequestsPanel()}{page === "setup" && (<main className="setup-layout"><div className="setup-intro"><p className="eyebrow">NEW DEBUGGING SESSION</p><h1>Choose your challenge.</h1><p>Each run starts from a fresh repository copy. Your work and results stay attached to this session.</p></div>{(() => { const resumableAttempt = studentHistory?.attempts.find((attempt) => attempt.resumable && attempt.status === "in_progress"); return resumableAttempt ? <section className="continue-challenge-panel" aria-label="Continue started challenge"><div className="continue-challenge-copy"><p className="eyebrow">IN PROGRESS</p><h2>Continue your challenge</h2><p><strong>{resumableAttempt.target_file || "Challenge workspace"}</strong>{resumableAttempt.repo_url ? ` · ${resumableAttempt.repo_url.replace(/^https?:\/\//, "")}` : ""}</p>{resumableAttempt.hints_used > 0 && <small>{resumableAttempt.hints_used} hints used</small>}</div><button className="button button-primary" onClick={() => void handleResumeAttempt(resumableAttempt.workspace_id)} disabled={busy}><History size={16} />Continue challenge</button></section> : historyLoading ? <p className="continue-challenge-loading" role="status">Checking for an unfinished challenge…</p> : null; })()}{config.course_mode && session.role === "student" && <section className="instructor-dashboard course-access-panel"><div className="panel-heading"><div><p className="eyebrow">COURSE ACCESS</p><h2>Instructor access</h2></div><button className="button button-secondary" onClick={() => void handleLoadCourseAccess()} disabled={courseAccessLoading}>{courseAccessLoading ? <LoaderCircle className="spin" size={15} /> : <RefreshCw size={15} />}Refresh access</button></div>{courseAccessError && <p className="notice notice-error" role="alert">{courseAccessError}</p>}{courseAccess?.request?.status === "pending" ? <p role="status">Your instructor access request is pending review.</p> : courseAccess?.request?.status === "approved" ? <p role="status">Your request was approved. Refresh access to activate instructor tools.</p> : <><label>Why do you need instructor access?<textarea value={accessRequestReason} onChange={(event) => setAccessRequestReason(event.target.value)} maxLength={1000} rows={2} placeholder="Optional note for the course administrator." /></label><button className="button button-secondary" onClick={() => void handleRequestInstructorAccess()} disabled={courseAccessLoading}><UserPlus size={16} />Request instructor access</button></>}</section>}{session.role === "instructor" && (<section className="instructor-dashboard"><div className="panel-heading"><div><p className="eyebrow">COURSE ACTIVITY</p><h2 className="managed-round-title"><buttontype="button"className={`managed-round-toggle ${managedRoundsOpen ? "is-open" : ""}`}aria-expanded={managedRoundsOpen}aria-controls="managed-rounds-content"onClick={() => setManagedRoundsOpen((open) => !open)}>Managed rounds<ChevronDown size={15} aria-hidden="true" /></button></h2></div><button className="button button-secondary" onClick={() => void handleLoadInstructorDashboard()} disabled={dashboardLoading}>{dashboardLoading ? <LoaderCircle className="spin" size={15} /> : <RefreshCw size={15} />}Refresh</button></div>{managedRoundsOpen && (<div id="managed-rounds-content">{dashboardLoading ? <p role="status">Loading course activity…</p> : instructorDashboard?.rounds.length ? (<div className="managed-round-list">43 unmodified lines<strong>{participant.latest_score == null ? "—" : `${participant.latest_score}/100`}</strong></div>))}{round.visibility === "private" && <RoundAttempts roundId={round.round_id} />}<div className="managed-round-actions">{round.can_manage !== false && round.status === "prepared" && <button className="button button-secondary" onClick={() => setEditingRoundId(isEditing ? null : round.round_id)} disabled={busy}>{isEditing ? "Cancel settings" : "Edit settings"}</button>}{round.can_manage !== false && round.status === "prepared" && <button className="button button-secondary" onClick={() => void handleRoundTransition(round.round_id, "open")} disabled={busy}><Play size={15} />Open round</button>}13 unmodified lines)}</section>)}<form className="setup-panel" onSubmit={handleStartChallenge}><div className="round-join-row"><label>Join a shared class challenge<input value={roundCode} onChange={(event) => setRoundCode(event.target.value)} placeholder="Paste round code" /></label>{joinedRoundIds.has(roundCode.trim()) ? <button type="button" className="button button-secondary" disabled><Check size={16} />Already joined</button> : <button type="button" className="button button-secondary" onClick={() => void handleJoinRound()} disabled={busy || !roundCode.trim()}>{busy ? <LoaderCircle className="spin" size={16} /> : <LogIn size={16} />}Join round</button>}</div><p className="muted-copy">For private rounds, the publisher and course admin may view your full chat.</p>{!hasModelAccess && <p className="muted-copy" role="status">Without a model key, you can join existing challenges, run tests, and submit. Challenge creation, AI chat/hints, and AI review are disabled.</p>}9 unmodified lines<button className="button button-primary start-button" disabled={busy}>{busy ? <LoaderCircle className="spin" size={17} /> : <Sparkles size={17} />}Start challenge<ChevronRight size={17} /></button>{busy && <div className="progress-copy" role="status"><div className="progress-label"><span>{status || "Preparing challenge"}</span><strong>{progress}%</strong></div><div className="progress-track" role="progressbar" aria-label="Challenge setup progress" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress}><span style={{ width: `${progress}%` }} /></div><small>Progress updates as each generation step starts.</small></div>}</>}</form></main>)}{page === "challenge" && challenge && (1 unmodified line234567810 unmodified lines1920212223242572 unmodified lines98991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431449 unmodified lines15415515615715815916016116216316416516616731 unmodified lines19920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323421 unmodified lines25625725825926026126226326426537 unmodified lines303304305306307308309625 unmodified lines935936937938939940941281 unmodified lines122312241225122612271228122913 unmodified lines124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126743 unmodified lines131113121313131413151316131713 unmodified lines13311332133313341335133613379 unmodified lines134713481349135013511352135313541 unmodified lineimport Editor from "@monaco-editor/react";import {AlertCircle,ArrowLeft,Check,CheckCircle2,ChevronDown,10 unmodified linesLogOut,MessageSquareText,LogIn,ListChecks,Play,RefreshCw,RotateCcw,72 unmodified linesreturn passed == null || total == null ? "Unavailable" : `${passed}/${total}`;}function RoundAttempts({ roundId, roundName }: { roundId: string; roundName: string }) {const [open, setOpen] = useState(false);const [page, setPage] = useState<InstructorAttemptsPage | null>(null);const [loading, setLoading] = useState(false);const [error, setError] = useState("");const triggerRef = useRef<HTMLButtonElement>(null);const backRef = useRef<HTMLButtonElement>(null);const windowRef = useRef<HTMLDivElement>(null);useEffect(() => {if (!open) return;const previousOverflow = document.body.style.overflow;document.body.style.overflow = "hidden";backRef.current?.focus();function onKeyDown(event: KeyboardEvent) {if (event.key === "Escape") {event.preventDefault();setOpen(false);} else if (event.key === "Tab") {const focusable = Array.from(windowRef.current?.querySelectorAll<HTMLElement>('button:not([disabled]), summary, [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',) ?? []).filter((element) => element.getClientRects().length > 0);if (!focusable.length) return;const first = focusable[0];const last = focusable[focusable.length - 1];if (event.shiftKey && document.activeElement === first) {event.preventDefault();last.focus();} else if (!event.shiftKey && document.activeElement === last) {event.preventDefault();first.focus();}}}document.addEventListener("keydown", onKeyDown);return () => {document.body.style.overflow = previousOverflow;document.removeEventListener("keydown", onKeyDown);triggerRef.current?.focus();};}, [open]);async function load(offset: number) {setLoading(true);9 unmodified lines}return <div className="round-attempts"><button ref={triggerRef} type="button" className="button button-secondary" onClick={() => { setOpen(true); if (!page && !loading) void load(0); }}><History size={15} />View attempts</button>{open && <div ref={windowRef} className="attempt-window" role="dialog" aria-modal="true" aria-labelledby="attempt-window-title"><div className="attempt-window-inner"><div className="attempt-window-heading"><button ref={backRef} type="button" className="button button-secondary" onClick={() => setOpen(false)}><ArrowLeft size={15} />Back to rounds</button><div><p className="eyebrow">PRIVATE ROUND</p><h2 id="attempt-window-title">{roundName} · Attempts</h2></div></div>{page && page.attempts.length > 0 && <AttemptCharts attempts={page.attempts} hasMore={page.has_more} />}<div className="attempt-list">{page?.attempts.map((attempt) => <details className="attempt-detail" key={attempt.workspace_id}><summary><strong>{attempt.student_name || "Student"}</strong><span>{attempt.status.replaceAll("_", " ")}</span><ChevronDown size={15} /></summary><div className="attempt-content">31 unmodified lines{loading && <p role="status">Loading attempts...</p>}{error && <div className="attempt-error"><p className="notice notice-error" role="alert">{error}</p><button type="button" className="button button-secondary" onClick={() => void load(page?.next_offset ?? 0)} disabled={loading}><RefreshCw size={15} />Retry</button></div>}{!loading && !error && page?.has_more && page.next_offset !== null && <button type="button" className="button button-secondary" onClick={() => void load(page.next_offset!)}>Load more attempts</button>}</div></div></div>}</div>;}function AttemptCharts({ attempts, hasMore }: { attempts: InstructorAttempt[]; hasMore: boolean }) {const scores = attempts.map((attempt) => attempt.submissions[0]?.total_score).filter((score): score is number => typeof score === "number" && Number.isFinite(score) && score >= 0 && score <= 100);const ranges = [{ label: "0–19", minimum: 0, maximum: 20 },{ label: "20–39", minimum: 20, maximum: 40 },{ label: "40–59", minimum: 40, maximum: 60 },{ label: "60–79", minimum: 60, maximum: 80 },{ label: "80–100", minimum: 80, maximum: 101 },].map((range) => ({ ...range, count: scores.filter((score) => score >= range.minimum && score < range.maximum).length }));const maximumCount = Math.max(1, ...ranges.map((range) => range.count));const submitted = attempts.filter((attempt) => attempt.status === "submitted").length;const inProgress = attempts.filter((attempt) => attempt.status === "in_progress").length;const other = attempts.length - submitted - inProgress;return <section className="attempt-overview" aria-label="Attempt overview"><div className="attempt-overview-header"><div><p className="eyebrow">ROUND OVERVIEW</p><h3>Activity at a glance</h3></div><span>{attempts.length} loaded {attempts.length === 1 ? "attempt" : "attempts"}{hasMore ? " · Partial results" : ""}</span></div><div className="attempt-overview-grid"><section className="attempt-chart" aria-label="Attempt status"><h4>Attempt status</h4><div className="attempt-status-bar" aria-hidden="true"><span className="status-submitted" style={{ width: `${submitted / attempts.length * 100}%` }} /><span className="status-progress" style={{ width: `${inProgress / attempts.length * 100}%` }} /><span className="status-other" style={{ width: `${other / attempts.length * 100}%` }} /></div><ul className="attempt-status-legend"><li><span className="status-dot status-submitted" />Submitted <strong>{submitted}</strong></li><li><span className="status-dot status-progress" />In progress <strong>{inProgress}</strong></li>{other > 0 && <li><span className="status-dot status-other" />Other <strong>{other}</strong></li>}</ul></section><section className="attempt-chart" aria-label="Score distribution"><h4>Score distribution</h4>{scores.length ? <><p className="attempt-chart-caption">Latest score per attempt · {scores.length} scored</p><ul className="score-bars">{ranges.map((range) => <li key={range.label}><span>{range.label}</span><div className="score-bar-track" aria-hidden="true"><span style={{ width: `${range.count / maximumCount * 100}%` }} /></div><strong>{range.count}</strong></li>)}</ul></> : <p className="attempt-chart-caption">No scores available.</p>}</section></div></section>;}function App() {const [config, setConfig] = useState<AppConfig | null>(null);const [session, setSession] = useState<SessionInfo | null>(null);21 unmodified linesconst [publicChallenges, setPublicChallenges] = useState<PublicChallengeRound[]>([]);const [publicChallengesLoading, setPublicChallengesLoading] = useState(false);const [historyLoading, setHistoryLoading] = useState(false);const [topbarSurface, setTopbarSurface] = useState<"public" | "history" | "requests" | "rounds" | null>(null);const [instructorDashboard, setInstructorDashboard] = useState<InstructorDashboard | null>(null);const [roundSettingsDrafts, setRoundSettingsDrafts] = useState<Record<string, RoundSettingsDraft>>({});const [editingRoundId, setEditingRoundId] = useState<string | null>(null);const [dashboardLoading, setDashboardLoading] = useState(false);const [copiedManagedRoundId, setCopiedManagedRoundId] = useState<string | null>(null);const [courseAccess, setCourseAccess] = useState<CourseAccessStatus | null>(null);37 unmodified linesconst chatMessageCount = challenge?.chat_messages_used ?? 0;const chatMessageLimit = challenge?.chat_messages_per_student ?? 5;const chatLimitReached = chatMessageCount >= chatMessageLimit && !challenge?.confirmation_pending;const SetupContainer = page === "setup" ? "main" : "div";function formatTestActual(actual: unknown): string {if (actual === undefined) return "—";625 unmodified linesawait loadStudentHistorySummary();}function toggleTopbarSurface(surface: "public" | "history" | "requests" | "rounds") {setTopbarSurface((current) => current === surface ? null : surface);}281 unmodified lines<header className="topbar"><div className="brand-lockup"><span className="brand-mark"><Code2 size={18} /></span><span>FIELDNOTES <i>/ CODE LAB</i></span></div><div className="topbar-context"><span>DEBUGGING WORKSHOP</span>{challenge && <><ChevronRight size={14} /><span className="context-repo">{challenge.repo_url.split("/").slice(-1)[0]}</span></>}</div><div className="user-menu"><button className="icon-button topbar-badge-button" onClick={() => { toggleTopbarSurface("public"); void handleLoadPublicChallenges(); }} aria-label="Open public challenges" title="Public challenges"><Globe2 size={17} /></button>{session.role === "instructor" && <button className="icon-button" onClick={() => { toggleTopbarSurface("rounds"); if (topbarSurface !== "rounds") void handleLoadInstructorDashboard(); }} aria-label="Managed rounds" title="Managed rounds" aria-expanded={topbarSurface === "rounds"}><ListChecks size={17} /></button>}{session.is_course_admin && <button className="icon-button topbar-badge-button" onClick={() => { toggleTopbarSurface("requests"); void handleLoadCourseAccess(); }} aria-label="Instructor access requests" title="Instructor access requests"><UserPlus size={17} />{courseAccessRequests.length > 0 && <span className="topbar-badge">{courseAccessRequests.length}</span>}</button>}<span className="user-avatar">{(identity.display_name || identity.username).charAt(0).toUpperCase()}</span><span className="user-name">{identity.display_name || identity.username}</span><button className="icon-button" onClick={() => void handleLoadHistory()} aria-label="Challenge history" title="Challenge history"><History size={17} /></button><button className="icon-button" onClick={() => void handleLogout()} aria-label="Sign out" title="Sign out"><LogOut size={17} /></button></div></header>{error && <div className="global-notice notice-error" role="alert"><AlertCircle size={17} />{error}<button className="notice-dismiss" onClick={() => setError("")} aria-label="Dismiss"><XCircle size={16} /></button></div>}13 unmodified lines{topbarSurface === "history" && renderHistoryPanel()}{topbarSurface === "requests" && session.is_course_admin && renderInstructorRequestsPanel()}{(page === "setup" || (session.role === "instructor" && topbarSurface === "rounds")) && (<SetupContainer className={page === "setup" ? "setup-layout" : "managed-rounds-host"}>{page === "setup" && <><div className="setup-intro"><p className="eyebrow">NEW DEBUGGING SESSION</p><h1>Choose your challenge.</h1><p>Each run starts from a fresh repository copy. Your work and results stay attached to this session.</p></div>{(() => { const resumableAttempt = studentHistory?.attempts.find((attempt) => attempt.resumable && attempt.status === "in_progress"); return resumableAttempt ? <section className="continue-challenge-panel" aria-label="Continue started challenge"><div className="continue-challenge-copy"><p className="eyebrow">IN PROGRESS</p><h2>Continue your challenge</h2><p><strong>{resumableAttempt.target_file || "Challenge workspace"}</strong>{resumableAttempt.repo_url ? ` · ${resumableAttempt.repo_url.replace(/^https?:\/\//, "")}` : ""}</p>{resumableAttempt.hints_used > 0 && <small>{resumableAttempt.hints_used} hints used</small>}</div><button className="button button-primary" onClick={() => void handleResumeAttempt(resumableAttempt.workspace_id)} disabled={busy}><History size={16} />Continue challenge</button></section> : historyLoading ? <p className="continue-challenge-loading" role="status">Checking for an unfinished challenge…</p> : null; })()}{config.course_mode && session.role === "student" && <section className="instructor-dashboard course-access-panel"><div className="panel-heading"><div><p className="eyebrow">COURSE ACCESS</p><h2>Instructor access</h2></div><button className="button button-secondary" onClick={() => void handleLoadCourseAccess()} disabled={courseAccessLoading}>{courseAccessLoading ? <LoaderCircle className="spin" size={15} /> : <RefreshCw size={15} />}Refresh access</button></div>{courseAccessError && <p className="notice notice-error" role="alert">{courseAccessError}</p>}{courseAccess?.request?.status === "pending" ? <p role="status">Your instructor access request is pending review.</p> : courseAccess?.request?.status === "approved" ? <p role="status">Your request was approved. Refresh access to activate instructor tools.</p> : <><label>Why do you need instructor access?<textarea value={accessRequestReason} onChange={(event) => setAccessRequestReason(event.target.value)} maxLength={1000} rows={2} placeholder="Optional note for the course administrator." /></label><button className="button button-secondary" onClick={() => void handleRequestInstructorAccess()} disabled={courseAccessLoading}><UserPlus size={16} />Request instructor access</button></>}</section>}</>}{session.role === "instructor" && topbarSurface === "rounds" && (<section className="history-panel instructor-rounds-panel" aria-label="Managed rounds"><div className="panel-heading"><div><p className="eyebrow">COURSE ACTIVITY</p><h2>Managed rounds</h2></div><button className="button button-secondary" onClick={() => void handleLoadInstructorDashboard()} disabled={dashboardLoading}>{dashboardLoading ? <LoaderCircle className="spin" size={15} /> : <RefreshCw size={15} />}Refresh</button></div>{(<div id="managed-rounds-content">{dashboardLoading ? <p role="status">Loading course activity…</p> : instructorDashboard?.rounds.length ? (<div className="managed-round-list">43 unmodified lines<strong>{participant.latest_score == null ? "—" : `${participant.latest_score}/100`}</strong></div>))}{round.visibility === "private" && <RoundAttempts roundId={round.round_id} roundName={round.repo_url?.split("/").slice(-1)[0] || "Challenge round"} />}<div className="managed-round-actions">{round.can_manage !== false && round.status === "prepared" && <button className="button button-secondary" onClick={() => setEditingRoundId(isEditing ? null : round.round_id)} disabled={busy}>{isEditing ? "Cancel settings" : "Edit settings"}</button>}{round.can_manage !== false && round.status === "prepared" && <button className="button button-secondary" onClick={() => void handleRoundTransition(round.round_id, "open")} disabled={busy}><Play size={15} />Open round</button>}13 unmodified lines)}</section>)}{page === "setup" && <form className="setup-panel" onSubmit={handleStartChallenge}><div className="round-join-row"><label>Join a shared class challenge<input value={roundCode} onChange={(event) => setRoundCode(event.target.value)} placeholder="Paste round code" /></label>{joinedRoundIds.has(roundCode.trim()) ? <button type="button" className="button button-secondary" disabled><Check size={16} />Already joined</button> : <button type="button" className="button button-secondary" onClick={() => void handleJoinRound()} disabled={busy || !roundCode.trim()}>{busy ? <LoaderCircle className="spin" size={16} /> : <LogIn size={16} />}Join round</button>}</div><p className="muted-copy">For private rounds, the publisher and course admin may view your full chat.</p>{!hasModelAccess && <p className="muted-copy" role="status">Without a model key, you can join existing challenges, run tests, and submit. Challenge creation, AI chat/hints, and AI review are disabled.</p>}9 unmodified lines<button className="button button-primary start-button" disabled={busy}>{busy ? <LoaderCircle className="spin" size={17} /> : <Sparkles size={17} />}Start challenge<ChevronRight size={17} /></button>{busy && <div className="progress-copy" role="status"><div className="progress-label"><span>{status || "Preparing challenge"}</span><strong>{progress}%</strong></div><div className="progress-track" role="progressbar" aria-label="Challenge setup progress" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress}><span style={{ width: `${progress}%` }} /></div><small>Progress updates as each generation step starts.</small></div>}</>}</form>}</SetupContainer>)}{page === "challenge" && challenge && (
119 unmodified lines12012112212312412512612712812911 unmodified lines141142143144145146243 unmodified lines39039139239339439539628 unmodified lines425426427428429430119 unmodified lines.history-entry > .button { justify-self: start; }.instructor-dashboard { display: grid; gap: 12px; margin: 0 0 28px; border-top: 1px solid var(--line); padding-top: 20px; }.instructor-dashboard h2 { margin: 0; font-size: 17px; }.managed-round-title { display: flex; }.managed-round-toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 2px 0; color: var(--ink); background: transparent; font: inherit; text-align: left; }.managed-round-toggle svg { color: var(--muted); transition: transform .16s ease; }.managed-round-toggle.is-open svg { transform: rotate(180deg); }.instructor-dashboard > p { margin: 0; color: var(--muted); font-size: 13px; }.managed-round-list { display: grid; }.managed-round { display: grid; gap: 12px; border-top: 1px solid var(--line); padding: 16px 0; }11 unmodified lines.participant-row strong { color: var(--ink); text-align: right; }.managed-round-actions { display: flex; flex-wrap: wrap; gap: 10px; }.round-attempts, .attempt-list, .attempt-content { display: grid; gap: 12px; min-width: 0; }.round-attempts > .button, .attempt-list > .button { justify-self: start; }.attempt-detail { min-width: 0; border-top: 1px solid var(--line); padding-top: 12px; }.attempt-detail > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }243 unmodified lines.challenge-layout { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .85fr); gap: 14px; }}@media (max-width: 760px) {.history-panel { top: 60px; right: 8px; width: calc(100vw - 16px); max-height: calc(100vh - 70px); }.participant-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }.participant-row strong { text-align: left; }.auth-shell { display: block; background: var(--page); }28 unmodified lines.app-footer { width: calc(100% - 24px); font-size: 8px; }}@media (max-width: 520px) {.keyless-notice { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px; }.keyless-notice-icon { width: 34px; height: 34px; }.keyless-connect-button { grid-column: 2; justify-self: start; }119 unmodified lines12012112212312412512612712811 unmodified lines140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171243 unmodified lines41541641741841942042128 unmodified lines450451452453454455456457119 unmodified lines.history-entry > .button { justify-self: start; }.instructor-dashboard { display: grid; gap: 12px; margin: 0 0 28px; border-top: 1px solid var(--line); padding-top: 20px; }.instructor-dashboard h2 { margin: 0; font-size: 17px; }.managed-rounds-host { display: contents; }.instructor-rounds-panel { display: grid; width: min(520px, calc(100% - 24px)); gap: 12px; }.instructor-rounds-panel h2 { margin: 0; font-size: 17px; }.instructor-dashboard > p { margin: 0; color: var(--muted); font-size: 13px; }.managed-round-list { display: grid; }.managed-round { display: grid; gap: 12px; border-top: 1px solid var(--line); padding: 16px 0; }11 unmodified lines.participant-row strong { color: var(--ink); text-align: right; }.managed-round-actions { display: flex; flex-wrap: wrap; gap: 10px; }.round-attempts, .attempt-list, .attempt-content { display: grid; gap: 12px; min-width: 0; }.attempt-window { position: fixed; z-index: 50; inset: 0; overflow-y: auto; background: var(--page); }.attempt-window-inner { width: min(100% - 40px, 1050px); margin: 32px auto 80px; }.attempt-window-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }.attempt-window-heading h2 { margin: 0; font-size: 22px; }.attempt-window-heading .eyebrow { margin-bottom: 4px; }.attempt-overview { margin-bottom: 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 18px 0 22px; }.attempt-overview-header { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.attempt-overview-header h3 { margin: 0; font-size: 17px; }.attempt-overview-header > span, .attempt-chart-caption { color: var(--muted); font-size: 12px; }.attempt-overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin-top: 20px; }.attempt-chart { min-width: 0; }.attempt-chart h4 { margin: 0 0 10px; font-size: 13px; }.attempt-chart-caption { margin: 0 0 12px; }.attempt-status-bar { display: flex; height: 12px; overflow: hidden; border-radius: 2px; background: #e2e8eb; }.status-submitted { background: #137b72; }.status-progress { background: #d29d3f; }.status-other { background: #8d999e; }.attempt-status-legend, .score-bars { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 12px; }.attempt-status-legend li { display: flex; align-items: center; gap: 8px; }.attempt-status-legend strong { margin-left: auto; }.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 2px; }.score-bars li { display: grid; grid-template-columns: 58px minmax(0, 1fr) 22px; align-items: center; gap: 8px; }.score-bars strong { text-align: right; }.score-bar-track { height: 8px; background: #e4eaec; }.score-bar-track span { display: block; height: 100%; background: #d16d58; }@media (max-width: 600px) { .attempt-window-heading { align-items: flex-start; flex-direction: column; gap: 14px; } .attempt-overview-header { align-items: flex-start; flex-direction: column; gap: 8px; } .attempt-overview-grid { grid-template-columns: 1fr; gap: 24px; } }.round-attempts > .button, .attempt-list > .button { justify-self: start; }.attempt-detail { min-width: 0; border-top: 1px solid var(--line); padding-top: 12px; }.attempt-detail > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }243 unmodified lines.challenge-layout { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .85fr); gap: 14px; }}@media (max-width: 760px) {.history-panel { top: 60px; right: 8px; width: calc(100% - 16px); max-height: calc(100vh - 70px); }.participant-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }.participant-row strong { text-align: left; }.auth-shell { display: block; background: var(--page); }28 unmodified lines.app-footer { width: calc(100% - 24px); font-size: 8px; }}@media (max-width: 520px) {.topbar .brand-lockup > span:not(.brand-mark), .user-name { display: none; }.user-menu { gap: 3px; }.keyless-notice { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px; }.keyless-notice-icon { width: 34px; height: 34px; }.keyless-connect-button { grid-column: 2; justify-self: start; }
frontend/src/App.test.tsx+31
frontend/src/App.tsx+88-28
frontend/src/styles.css+32-5