Repository navigation
feat(web): learning view, jeopardy board, terminal embed, notifications #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { ChallengeBoard } from '@/components/ChallengeBoard'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Challenges' }; | ||
|
|
||
| export default function ChallengesPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-6xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <header> | ||
| <h1 className="m-0 text-2xl font-semibold tracking-tight sm:text-3xl">Challenges</h1> | ||
| <p className="mt-2 mb-0 max-w-[60ch] text-sm leading-relaxed text-muted"> | ||
| A jeopardy board of standalone puzzles. Points may decay as solves pile up on dynamic | ||
| challenges; submit flags from each challenge's detail view. | ||
| </p> | ||
| </header> | ||
| <ChallengeBoard /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { ModuleReader } from '@/components/ModuleReader'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Module' }; | ||
|
|
||
| interface Props { | ||
| params: Promise<{ pathSlug: string; moduleSlug: string }>; | ||
| } | ||
|
|
||
| export default async function ModulePage({ params }: Props) { | ||
| const { pathSlug, moduleSlug } = await params; | ||
| return ( | ||
| <div className="mx-auto max-w-3xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <ModuleReader pathSlug={pathSlug} moduleSlug={moduleSlug} /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { PathOutline } from '@/components/PathOutline'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Learning path' }; | ||
|
|
||
| interface Props { | ||
| params: Promise<{ pathSlug: string }>; | ||
| } | ||
|
|
||
| export default async function LearningPathPage({ params }: Props) { | ||
| const { pathSlug } = await params; | ||
| return ( | ||
| <div className="mx-auto max-w-4xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <PathOutline pathSlug={pathSlug} /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { LearnCatalog } from '@/components/LearnCatalog'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Learn' }; | ||
|
|
||
| export default function LearnPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-6xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <header> | ||
| <h1 className="m-0 text-2xl font-semibold tracking-tight sm:text-3xl">Learning paths</h1> | ||
| <p className="mt-2 mb-0 max-w-[60ch] text-sm leading-relaxed text-muted"> | ||
| Guided curricula that pair reading, quizzes, and live lab rooms. Enroll to track section | ||
| completion and earn a certificate when the required modules are done. | ||
| </p> | ||
| </header> | ||
| <LearnCatalog /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import type { Metadata } from 'next'; | ||
| import { NotificationsView } from '@/components/NotificationsView'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Notifications' }; | ||
|
|
||
| export default function NotificationsPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-3xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <header> | ||
| <h1 className="m-0 text-2xl font-semibold tracking-tight sm:text-3xl">Notifications</h1> | ||
| <p className="mt-2 mb-0 max-w-[60ch] text-sm leading-relaxed text-muted"> | ||
| Unread items first. Control channels and muted categories below the feed. | ||
| </p> | ||
| </header> | ||
| <div className="mt-8"> | ||
| <NotificationsView /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import type { Metadata } from 'next'; | ||
| import Link from 'next/link'; | ||
| import { redirect } from 'next/navigation'; | ||
| import { getCurrentUser, getServerApiClient } from '@/lib/api-server'; | ||
| import type { LabInstance } from '@openrange/contracts'; | ||
| import { TerminalClient } from '@/components/TerminalClient'; | ||
|
|
||
| export const metadata: Metadata = { title: 'Terminal' }; | ||
| export const dynamic = 'force-dynamic'; | ||
|
|
||
| export default async function TerminalPage() { | ||
| const user = await getCurrentUser(); | ||
| if (user === null) { | ||
| redirect('/login'); | ||
| } | ||
|
|
||
| let labs: LabInstance[] = []; | ||
| let apiError: string | null = null; | ||
| try { | ||
| labs = [...(await (await getServerApiClient()).labs.list())]; | ||
| } catch { | ||
| apiError = 'Could not load your labs. Is the API server running?'; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="mx-auto max-w-6xl px-4 py-10 sm:px-6 sm:py-14"> | ||
| <header> | ||
| <h1 className="m-0 text-2xl font-semibold tracking-tight sm:text-3xl">Terminal</h1> | ||
| <p className="mt-2 mb-0 max-w-[60ch] text-sm leading-relaxed text-muted"> | ||
| An SSH shell into one of your lab instances, bridged through the gateway. Pick a READY | ||
| lab; every keystroke stays inside that isolated session. | ||
| </p> | ||
| </header> | ||
|
|
||
| {apiError !== null ? ( | ||
| <p | ||
| role="alert" | ||
| className="mt-8 rounded-md border border-warning bg-panel px-4 py-3 text-sm text-warning" | ||
| > | ||
| {apiError} | ||
| </p> | ||
| ) : ( | ||
| <TerminalClient labs={labs} /> | ||
| )} | ||
|
|
||
| <p className="mb-0 mt-6 text-xs leading-relaxed text-muted"> | ||
| Need a target first?{' '} | ||
| <Link href="/catalog" className="text-accent underline underline-offset-4"> | ||
| Start a lab | ||
| </Link>{' '} | ||
| from any room page. | ||
| </p> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| 'use client'; | ||
|
|
||
| import { useCallback, useEffect, useState } from 'react'; | ||
| import { Skeleton } from '@openrange/ui'; | ||
| import type { ChallengeCategory, ChallengeSummary } from '@openrange/contracts'; | ||
| import { apiProxy, isAuthError, ProxyError } from '@/lib/api-browser'; | ||
| import { ChallengeModal } from './ChallengeModal'; | ||
| import { SignInPrompt } from './SignInPrompt'; | ||
|
|
||
| type Load = | ||
| | { kind: 'loading' } | ||
| | { kind: 'signedOut' } | ||
| | { kind: 'error'; message: string } | ||
| | { kind: 'ready'; challenges: ChallengeSummary[] }; | ||
|
|
||
| /** Display order for categories; unknown categories append in API order. */ | ||
| const CATEGORY_ORDER: readonly ChallengeCategory[] = [ | ||
| 'web', | ||
| 'crypto', | ||
| 'pwn', | ||
| 'rev', | ||
| 'forensics', | ||
| 'misc', | ||
| 'osint', | ||
| ]; | ||
|
|
||
| export function ChallengeBoard() { | ||
| const [load, setLoad] = useState<Load>({ kind: 'loading' }); | ||
| const [openSlug, setOpenSlug] = useState<string | null>(null); | ||
| const [solvedSlugs, setSolvedSlugs] = useState<readonly string[]>([]); | ||
|
|
||
| useEffect(() => { | ||
| let cancelled = false; | ||
| apiProxy<ChallengeSummary[]>('challenges').then( | ||
| (challenges) => { | ||
| if (!cancelled) { | ||
| setLoad({ kind: 'ready', challenges }); | ||
| } | ||
| }, | ||
| (error: unknown) => { | ||
| if (cancelled) { | ||
| return; | ||
| } | ||
| if (isAuthError(error)) { | ||
| setLoad({ kind: 'signedOut' }); | ||
| } else { | ||
| setLoad({ | ||
| kind: 'error', | ||
| message: error instanceof ProxyError ? error.message : 'Could not reach the server.', | ||
| }); | ||
| } | ||
| }, | ||
| ); | ||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, []); | ||
|
|
||
| // Modal callbacks must be stable: the detail loader depends on them. | ||
| const markSolved = useCallback((slug: string) => { | ||
| setSolvedSlugs((current) => (current.includes(slug) ? current : [...current, slug])); | ||
| }, []); | ||
|
|
||
| if (load.kind === 'loading') { | ||
| return ( | ||
| <div className="mt-8 grid gap-4 lg:grid-cols-3" aria-busy="true"> | ||
| {[0, 1, 2].map((slot) => ( | ||
| <Skeleton key={slot} label="Loading challenges" width="100%" height="16rem" /> | ||
| ))} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (load.kind === 'signedOut') { | ||
| return <SignInPrompt what="play challenges" />; | ||
| } | ||
|
|
||
| if (load.kind === 'error') { | ||
| return ( | ||
| <p | ||
| role="alert" | ||
| className="mt-8 rounded-md border border-warning bg-panel px-4 py-3 text-sm text-warning" | ||
| > | ||
| {load.message} | ||
| </p> | ||
| ); | ||
| } | ||
|
|
||
| const grouped = new Map<string, ChallengeSummary[]>(); | ||
| for (const challenge of load.challenges) { | ||
| const bucket = grouped.get(challenge.category) ?? []; | ||
| bucket.push(challenge); | ||
| grouped.set(challenge.category, bucket); | ||
| } | ||
| const categories = [...grouped.keys()].sort((a, b) => { | ||
| const ia = CATEGORY_ORDER.indexOf(a as ChallengeCategory); | ||
| const ib = CATEGORY_ORDER.indexOf(b as ChallengeCategory); | ||
| return (ia === -1 ? CATEGORY_ORDER.length : ia) - (ib === -1 ? CATEGORY_ORDER.length : ib); | ||
| }); | ||
|
|
||
| return ( | ||
| <> | ||
| <p | ||
| aria-live="polite" | ||
| className="mt-6 mb-4 font-mono text-xs uppercase tracking-wide text-muted" | ||
| > | ||
| {load.challenges.length} {load.challenges.length === 1 ? 'challenge' : 'challenges'} on the | ||
| board · {solvedSlugs.length} solved by you | ||
| </p> | ||
|
|
||
| {categories.map((category) => { | ||
| const items = grouped.get(category) ?? []; | ||
| return ( | ||
| <section key={category} aria-labelledby={`category-${category}`} className="mb-8"> | ||
| <h2 | ||
| id={`category-${category}`} | ||
| className="m-0 mb-3 font-mono text-sm font-semibold uppercase tracking-widest text-content" | ||
| > | ||
| {category} | ||
| <span className="ml-2 font-normal normal-case tracking-normal text-muted"> | ||
| {items.length} {items.length === 1 ? 'challenge' : 'challenges'} | ||
| </span> | ||
| </h2> | ||
| <ul className="grid list-none gap-2 p-0 sm:grid-cols-2 lg:grid-cols-4"> | ||
| {items.map((challenge) => { | ||
| const solved = solvedSlugs.includes(challenge.slug); | ||
| return ( | ||
| <li key={challenge.slug}> | ||
| <button | ||
| type="button" | ||
| onClick={() => setOpenSlug(challenge.slug)} | ||
| aria-label={`${challenge.name}, ${challenge.points} points, ${challenge.solve_count} solves${solved ? ', solved' : ''}`} | ||
| className={[ | ||
| 'flex h-full w-full flex-col items-start gap-1 rounded-lg border px-3 py-3 text-left transition-colors', | ||
| solved | ||
| ? 'border-accent/60 bg-panel' | ||
| : 'border-edge bg-panel hover:border-edge-strong', | ||
| ].join(' ')} | ||
| > | ||
| <span className="w-full break-words text-sm font-medium text-content"> | ||
| {challenge.name} | ||
| </span> | ||
| <span className="font-mono text-xs text-muted"> | ||
| {challenge.points} pts · {challenge.solve_count} solves | ||
| </span> | ||
| {solved ? ( | ||
| <span className="rounded bg-accent/15 px-1.5 py-0.5 font-mono text-[0.7rem] uppercase tracking-wide text-accent"> | ||
| Solved | ||
| </span> | ||
| ) : null} | ||
| </button> | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| </section> | ||
| ); | ||
| })} | ||
|
|
||
| {openSlug !== null ? ( | ||
| <ChallengeModal | ||
| key={openSlug} | ||
| slug={openSlug} | ||
| onClose={() => setOpenSlug(null)} | ||
| onSolved={markSolved} | ||
| /> | ||
| ) : null} | ||
| </> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not render challenges whose
stateishidden.Lines 90-94 add every API item to the board. A challenge with
state: 'hidden'becomes visible and can open its detail modal. Filter hidden challenges before grouping and use the filtered list for the board count.Proposed fix
Also applies to: 103-108
🤖 Prompt for AI Agents