blanchon commited on
Commit
e355be5
·
1 Parent(s): 637582a

Add evaluation mode: queue, flag bar, info dialog

Browse files

- src/lib/eval.ts: deterministic eval queue (per match-map: round 1, last,
+ 1 PRNG-picked middle), flag reasons, localStorage flag store
- src/lib/components/eval-bar.svelte: amber strip below the header with
position N/total, Flag dropdown (6 reasons w/ descriptions), Info button,
Next, Exit
- src/lib/components/eval-info-dialog.svelte: explains the policy and what
to flag (missing audio, AV misalignment, POV desync, uninteresting,
missing video, other)
- header.svelte: ListChecks toggle button — start eval (jump to candidate 0)
or exit; reads matches from page.data so any match page can launch eval
- match page: render <EvalBar /> when ?eval=1; route effect now also reacts
to URL round/player/view changes (so eval Next on the same map reloads
the new round); ?eval=1&i=N stays preserved by syncUrl()'s URL clone

Flags persist in localStorage (opencs2:eval:flags:v1) — export manually for
now, no backend round-tripping yet.

bun.lock CHANGED
@@ -12,6 +12,7 @@
12
  "devDependencies": {
13
  "@fontsource-variable/oxanium": "^5.2.8",
14
  "@fontsource-variable/roboto-slab": "^5.2.8",
 
15
  "@sveltejs/adapter-static": "latest",
16
  "@sveltejs/kit": "latest",
17
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
 
12
  "devDependencies": {
13
  "@fontsource-variable/oxanium": "^5.2.8",
14
  "@fontsource-variable/roboto-slab": "^5.2.8",
15
+ "@internationalized/date": "^3.12.0",
16
  "@sveltejs/adapter-static": "latest",
17
  "@sveltejs/kit": "latest",
18
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
package.json CHANGED
@@ -21,6 +21,7 @@
21
  "devDependencies": {
22
  "@fontsource-variable/oxanium": "^5.2.8",
23
  "@fontsource-variable/roboto-slab": "^5.2.8",
 
24
  "@sveltejs/adapter-static": "latest",
25
  "@sveltejs/kit": "latest",
26
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
 
21
  "devDependencies": {
22
  "@fontsource-variable/oxanium": "^5.2.8",
23
  "@fontsource-variable/roboto-slab": "^5.2.8",
24
+ "@internationalized/date": "^3.12.0",
25
  "@sveltejs/adapter-static": "latest",
26
  "@sveltejs/kit": "latest",
27
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
src/lib/components/eval-bar.svelte ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Button } from '$lib/components/ui/button';
3
+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
4
+ import * as Tooltip from '$lib/components/ui/tooltip';
5
+ import FlagIcon from 'phosphor-svelte/lib/FlagIcon';
6
+ import InfoIcon from 'phosphor-svelte/lib/InfoIcon';
7
+ import ArrowRightIcon from 'phosphor-svelte/lib/ArrowRightIcon';
8
+ import XIcon from 'phosphor-svelte/lib/XIcon';
9
+ import { goto } from '$app/navigation';
10
+ import { page } from '$app/state';
11
+ import { addFlag, FLAG_REASONS, evalUrl, type EvalCandidate, type FlagReason } from '$lib/eval';
12
+ import { toast } from 'svelte-sonner';
13
+ import EvalInfoDialog from './eval-info-dialog.svelte';
14
+
15
+ interface Props {
16
+ queue: EvalCandidate[];
17
+ index: number;
18
+ matchId: number;
19
+ mapName: string;
20
+ round: number;
21
+ }
22
+ let { queue, index, matchId, mapName, round }: Props = $props();
23
+
24
+ let infoOpen = $state(false);
25
+
26
+ function flag(reason: FlagReason, label: string) {
27
+ addFlag({ matchId, mapName, round, reason });
28
+ toast.success(`Flagged: ${label}`, {
29
+ description: `match ${matchId} · ${mapName} · round ${round}`
30
+ });
31
+ }
32
+
33
+ function next() {
34
+ const ni = index < 0 ? 0 : index + 1;
35
+ if (ni >= queue.length) {
36
+ toast.success('Evaluation complete', {
37
+ description: `Reached end of queue (${queue.length} candidates).`
38
+ });
39
+ return;
40
+ }
41
+ goto(evalUrl(queue[ni], ni));
42
+ }
43
+
44
+ function exitEval() {
45
+ const url = new URL(page.url);
46
+ url.searchParams.delete('eval');
47
+ url.searchParams.delete('i');
48
+ goto(url.pathname + (url.searchParams.size ? '?' + url.searchParams.toString() : ''));
49
+ }
50
+
51
+ const total = $derived(queue.length);
52
+ const positionLabel = $derived(index < 0 ? `— / ${total}` : `${index + 1} / ${total}`);
53
+ </script>
54
+
55
+ <div
56
+ class="border-b border-amber-500/30 bg-amber-500/10 dark:border-amber-500/25 dark:bg-amber-500/[0.07]"
57
+ >
58
+ <div class="mx-auto flex h-10 w-full max-w-[1600px] items-center gap-2 px-4 text-xs">
59
+ <span class="font-mono font-semibold tracking-wide text-amber-700 uppercase dark:text-amber-300"
60
+ >Eval</span
61
+ >
62
+ <span class="text-muted-foreground tabular-nums">{positionLabel}</span>
63
+
64
+ <div class="ml-auto flex items-center gap-1">
65
+ <DropdownMenu.Root>
66
+ <DropdownMenu.Trigger>
67
+ {#snippet child({ props })}
68
+ <Button {...props} variant="outline" size="sm">
69
+ <FlagIcon size={14} weight="fill" /> Flag
70
+ </Button>
71
+ {/snippet}
72
+ </DropdownMenu.Trigger>
73
+ <DropdownMenu.Content align="end" class="w-72">
74
+ <DropdownMenu.Label>Flag this candidate as…</DropdownMenu.Label>
75
+ <DropdownMenu.Separator />
76
+ {#each FLAG_REASONS as r (r.id)}
77
+ <DropdownMenu.Item
78
+ onclick={() => flag(r.id, r.label)}
79
+ class="flex-col items-start gap-0.5"
80
+ >
81
+ <span class="font-medium">{r.label}</span>
82
+ <span class="text-[10px] text-muted-foreground">{r.description}</span>
83
+ </DropdownMenu.Item>
84
+ {/each}
85
+ </DropdownMenu.Content>
86
+ </DropdownMenu.Root>
87
+
88
+ <Tooltip.Root>
89
+ <Tooltip.Trigger>
90
+ {#snippet child({ props })}
91
+ <Button
92
+ {...props}
93
+ variant="ghost"
94
+ size="icon-sm"
95
+ onclick={() => (infoOpen = true)}
96
+ aria-label="What to flag"
97
+ >
98
+ <InfoIcon size={14} weight="duotone" />
99
+ </Button>
100
+ {/snippet}
101
+ </Tooltip.Trigger>
102
+ <Tooltip.Content side="bottom">How to evaluate</Tooltip.Content>
103
+ </Tooltip.Root>
104
+
105
+ <Button onclick={next} size="sm" disabled={total === 0}>
106
+ Next <ArrowRightIcon size={14} weight="bold" />
107
+ </Button>
108
+
109
+ <Tooltip.Root>
110
+ <Tooltip.Trigger>
111
+ {#snippet child({ props })}
112
+ <Button
113
+ {...props}
114
+ variant="ghost"
115
+ size="icon-sm"
116
+ onclick={exitEval}
117
+ aria-label="Exit evaluation"
118
+ >
119
+ <XIcon size={14} weight="bold" />
120
+ </Button>
121
+ {/snippet}
122
+ </Tooltip.Trigger>
123
+ <Tooltip.Content side="bottom">Exit evaluation</Tooltip.Content>
124
+ </Tooltip.Root>
125
+ </div>
126
+ </div>
127
+ </div>
128
+
129
+ <EvalInfoDialog bind:open={infoOpen} />
src/lib/components/eval-info-dialog.svelte ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import * as Dialog from '$lib/components/ui/dialog';
3
+ import { FLAG_REASONS } from '$lib/eval';
4
+
5
+ interface Props {
6
+ open?: boolean;
7
+ }
8
+ let { open = $bindable(false) }: Props = $props();
9
+ </script>
10
+
11
+ <Dialog.Root bind:open>
12
+ <Dialog.Content class="max-w-xl">
13
+ <Dialog.Header>
14
+ <Dialog.Title>How to evaluate</Dialog.Title>
15
+ <Dialog.Description>
16
+ The queue samples 3 rounds per match — round 1, the last round, and one deterministic round
17
+ in the middle. Watch each candidate, flag any issue you spot, then click <span
18
+ class="font-medium text-foreground">Next</span
19
+ > to advance.
20
+ </Dialog.Description>
21
+ </Dialog.Header>
22
+
23
+ <div class="mt-3 space-y-3 text-sm">
24
+ <div>
25
+ <div class="font-semibold text-foreground">Flag if you see:</div>
26
+ <ul class="mt-1.5 space-y-1.5 text-xs/relaxed text-muted-foreground">
27
+ {#each FLAG_REASONS as r (r.id)}
28
+ <li class="flex flex-col gap-0.5">
29
+ <span class="font-medium text-foreground">{r.label}</span>
30
+ <span>{r.description}</span>
31
+ </li>
32
+ {/each}
33
+ </ul>
34
+ </div>
35
+
36
+ <p class="border-t pt-3 text-xs text-muted-foreground">
37
+ Flags are stored in your browser's <code class="font-mono">localStorage</code> under
38
+ <code class="font-mono">opencs2:eval:flags:v1</code>. Export them by copying that key from
39
+ devtools.
40
+ </p>
41
+ </div>
42
+ </Dialog.Content>
43
+ </Dialog.Root>
src/lib/components/header.svelte CHANGED
@@ -4,9 +4,30 @@
4
  import SunIcon from 'phosphor-svelte/lib/SunIcon';
5
  import MoonIcon from 'phosphor-svelte/lib/MoonIcon';
6
  import CaretLeftIcon from 'phosphor-svelte/lib/CaretLeftIcon';
 
7
  import { mode, toggleMode } from 'mode-watcher';
 
 
8
  import HfLogo from '$lib/components/hf-logo.svelte';
9
  import { site } from '$lib/site';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </script>
11
 
12
  <header class="border-b border-border/60">
@@ -21,6 +42,27 @@
21
  </a>
22
 
23
  <div class="ml-auto flex items-center gap-1">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  <Tooltip.Root>
25
  <Tooltip.Trigger>
26
  {#snippet child({ props })}
 
4
  import SunIcon from 'phosphor-svelte/lib/SunIcon';
5
  import MoonIcon from 'phosphor-svelte/lib/MoonIcon';
6
  import CaretLeftIcon from 'phosphor-svelte/lib/CaretLeftIcon';
7
+ import ListChecksIcon from 'phosphor-svelte/lib/ListChecksIcon';
8
  import { mode, toggleMode } from 'mode-watcher';
9
+ import { goto } from '$app/navigation';
10
+ import { page } from '$app/state';
11
  import HfLogo from '$lib/components/hf-logo.svelte';
12
  import { site } from '$lib/site';
13
+ import type { Match } from '$lib/types';
14
+ import { buildEvalQueue, evalUrl } from '$lib/eval';
15
+
16
+ const inEval = $derived(page.url.searchParams.get('eval') === '1');
17
+ const matches = $derived((page.data?.matches ?? []) as Match[]);
18
+
19
+ function toggleEval() {
20
+ if (inEval) {
21
+ const url = new URL(page.url);
22
+ url.searchParams.delete('eval');
23
+ url.searchParams.delete('i');
24
+ goto(url.pathname + (url.searchParams.size ? '?' + url.searchParams.toString() : ''));
25
+ return;
26
+ }
27
+ const queue = buildEvalQueue(matches);
28
+ if (!queue.length) return;
29
+ goto(evalUrl(queue[0], 0));
30
+ }
31
  </script>
32
 
33
  <header class="border-b border-border/60">
 
42
  </a>
43
 
44
  <div class="ml-auto flex items-center gap-1">
45
+ <Tooltip.Root>
46
+ <Tooltip.Trigger>
47
+ {#snippet child({ props })}
48
+ <Button
49
+ {...props}
50
+ variant="ghost"
51
+ size="icon-sm"
52
+ onclick={toggleEval}
53
+ disabled={!matches.length}
54
+ data-active={inEval || undefined}
55
+ class="data-active:bg-amber-500/15 data-active:text-amber-700 dark:data-active:text-amber-300"
56
+ aria-label={inEval ? 'Exit evaluation' : 'Start evaluation'}
57
+ >
58
+ <ListChecksIcon size={16} weight="duotone" />
59
+ </Button>
60
+ {/snippet}
61
+ </Tooltip.Trigger>
62
+ <Tooltip.Content side="bottom">
63
+ {inEval ? 'Exit evaluation' : 'Start evaluation'}
64
+ </Tooltip.Content>
65
+ </Tooltip.Root>
66
  <Tooltip.Root>
67
  <Tooltip.Trigger>
68
  {#snippet child({ props })}
src/lib/components/ui/dialog/dialog-close.svelte ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+
4
+ let {
5
+ ref = $bindable(null),
6
+ type = 'button',
7
+ ...restProps
8
+ }: DialogPrimitive.CloseProps = $props();
9
+ </script>
10
+
11
+ <DialogPrimitive.Close bind:ref data-slot="dialog-close" {type} {...restProps} />
src/lib/components/ui/dialog/dialog-content.svelte ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+ import DialogPortal from './dialog-portal.svelte';
4
+ import type { Snippet } from 'svelte';
5
+ import * as Dialog from './index.js';
6
+ import { cn, type WithoutChildrenOrChild } from '$lib/utils.js';
7
+ import type { ComponentProps } from 'svelte';
8
+ import { Button } from '$lib/components/ui/button/index.js';
9
+ import XIcon from 'phosphor-svelte/lib/X';
10
+
11
+ let {
12
+ ref = $bindable(null),
13
+ class: className,
14
+ portalProps,
15
+ children,
16
+ showCloseButton = true,
17
+ ...restProps
18
+ }: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
19
+ portalProps?: WithoutChildrenOrChild<ComponentProps<typeof DialogPortal>>;
20
+ children: Snippet;
21
+ showCloseButton?: boolean;
22
+ } = $props();
23
+ </script>
24
+
25
+ <DialogPortal {...portalProps}>
26
+ <Dialog.Overlay />
27
+ <DialogPrimitive.Content
28
+ bind:ref
29
+ data-slot="dialog-content"
30
+ class={cn(
31
+ 'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-xs/relaxed ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none',
32
+ className
33
+ )}
34
+ {...restProps}
35
+ >
36
+ {@render children?.()}
37
+ {#if showCloseButton}
38
+ <DialogPrimitive.Close data-slot="dialog-close">
39
+ {#snippet child({ props })}
40
+ <Button variant="ghost" class="absolute top-2 right-2" size="icon-sm" {...props}>
41
+ <XIcon />
42
+ <span class="sr-only">Close</span>
43
+ </Button>
44
+ {/snippet}
45
+ </DialogPrimitive.Close>
46
+ {/if}
47
+ </DialogPrimitive.Content>
48
+ </DialogPortal>
src/lib/components/ui/dialog/dialog-description.svelte ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+ import { cn } from '$lib/utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ ...restProps
9
+ }: DialogPrimitive.DescriptionProps = $props();
10
+ </script>
11
+
12
+ <DialogPrimitive.Description
13
+ bind:ref
14
+ data-slot="dialog-description"
15
+ class={cn(
16
+ 'text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed *:[a]:underline *:[a]:underline-offset-3',
17
+ className
18
+ )}
19
+ {...restProps}
20
+ />
src/lib/components/ui/dialog/dialog-footer.svelte ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '$lib/utils.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { Dialog as DialogPrimitive } from 'bits-ui';
5
+ import { Button } from '$lib/components/ui/button/index.js';
6
+
7
+ let {
8
+ ref = $bindable(null),
9
+ class: className,
10
+ children,
11
+ showCloseButton = false,
12
+ ...restProps
13
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
14
+ showCloseButton?: boolean;
15
+ } = $props();
16
+ </script>
17
+
18
+ <div
19
+ bind:this={ref}
20
+ data-slot="dialog-footer"
21
+ class={cn('gap-2 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
22
+ {...restProps}
23
+ >
24
+ {@render children?.()}
25
+ {#if showCloseButton}
26
+ <DialogPrimitive.Close>
27
+ {#snippet child({ props })}
28
+ <Button variant="outline" {...props}>Close</Button>
29
+ {/snippet}
30
+ </DialogPrimitive.Close>
31
+ {/if}
32
+ </div>
src/lib/components/ui/dialog/dialog-header.svelte ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '$lib/utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="dialog-header"
16
+ class={cn('gap-1 flex flex-col', className)}
17
+ {...restProps}
18
+ >
19
+ {@render children?.()}
20
+ </div>
src/lib/components/ui/dialog/dialog-overlay.svelte ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+ import { cn } from '$lib/utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ ...restProps
9
+ }: DialogPrimitive.OverlayProps = $props();
10
+ </script>
11
+
12
+ <DialogPrimitive.Overlay
13
+ bind:ref
14
+ data-slot="dialog-overlay"
15
+ class={cn(
16
+ 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50',
17
+ className
18
+ )}
19
+ {...restProps}
20
+ />
src/lib/components/ui/dialog/dialog-portal.svelte ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+
4
+ let { ...restProps }: DialogPrimitive.PortalProps = $props();
5
+ </script>
6
+
7
+ <DialogPrimitive.Portal {...restProps} />
src/lib/components/ui/dialog/dialog-title.svelte ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+ import { cn } from '$lib/utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ ...restProps
9
+ }: DialogPrimitive.TitleProps = $props();
10
+ </script>
11
+
12
+ <DialogPrimitive.Title
13
+ bind:ref
14
+ data-slot="dialog-title"
15
+ class={cn('font-heading text-sm font-medium', className)}
16
+ {...restProps}
17
+ />
src/lib/components/ui/dialog/dialog-trigger.svelte ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+
4
+ let {
5
+ ref = $bindable(null),
6
+ type = 'button',
7
+ ...restProps
8
+ }: DialogPrimitive.TriggerProps = $props();
9
+ </script>
10
+
11
+ <DialogPrimitive.Trigger bind:ref data-slot="dialog-trigger" {type} {...restProps} />
src/lib/components/ui/dialog/dialog.svelte ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from 'bits-ui';
3
+
4
+ let { open = $bindable(false), ...restProps }: DialogPrimitive.RootProps = $props();
5
+ </script>
6
+
7
+ <DialogPrimitive.Root bind:open {...restProps} />
src/lib/components/ui/dialog/index.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Root from './dialog.svelte';
2
+ import Portal from './dialog-portal.svelte';
3
+ import Title from './dialog-title.svelte';
4
+ import Footer from './dialog-footer.svelte';
5
+ import Header from './dialog-header.svelte';
6
+ import Overlay from './dialog-overlay.svelte';
7
+ import Content from './dialog-content.svelte';
8
+ import Description from './dialog-description.svelte';
9
+ import Trigger from './dialog-trigger.svelte';
10
+ import Close from './dialog-close.svelte';
11
+
12
+ export {
13
+ Root,
14
+ Title,
15
+ Portal,
16
+ Footer,
17
+ Header,
18
+ Trigger,
19
+ Overlay,
20
+ Content,
21
+ Description,
22
+ Close,
23
+ //
24
+ Root as Dialog,
25
+ Title as DialogTitle,
26
+ Portal as DialogPortal,
27
+ Footer as DialogFooter,
28
+ Header as DialogHeader,
29
+ Trigger as DialogTrigger,
30
+ Overlay as DialogOverlay,
31
+ Content as DialogContent,
32
+ Description as DialogDescription,
33
+ Close as DialogClose
34
+ };
src/lib/eval.ts ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { browser } from '$app/environment';
2
+ import type { Match } from '$lib/types';
3
+
4
+ export type EvalCandidate = {
5
+ matchId: number;
6
+ mapName: string;
7
+ round: number;
8
+ };
9
+
10
+ export type FlagReason =
11
+ | 'missing_audio'
12
+ | 'av_misaligned'
13
+ | 'pov_desync'
14
+ | 'uninteresting'
15
+ | 'missing_video'
16
+ | 'other';
17
+
18
+ export const FLAG_REASONS: { id: FlagReason; label: string; description: string }[] = [
19
+ {
20
+ id: 'missing_audio',
21
+ label: 'Missing audio',
22
+ description: 'No audio at all when there should be (gunfire, footsteps, callouts).'
23
+ },
24
+ {
25
+ id: 'av_misaligned',
26
+ label: 'Audio out of sync',
27
+ description: 'Audio is offset from on-screen action — gunshots before the muzzle flash, etc.'
28
+ },
29
+ {
30
+ id: 'pov_desync',
31
+ label: 'POVs out of sync',
32
+ description:
33
+ 'In grid mode, two players who should see the same moment are time-offset from each other.'
34
+ },
35
+ {
36
+ id: 'uninteresting',
37
+ label: 'Uninteresting gameplay',
38
+ description: 'Pure AFK, intentional griefing, or otherwise unusable footage.'
39
+ },
40
+ {
41
+ id: 'missing_video',
42
+ label: 'Missing video',
43
+ description:
44
+ 'A POV stream stays blank after the round has buffered (i.e. not just a slow-network hiccup).'
45
+ },
46
+ {
47
+ id: 'other',
48
+ label: 'Other',
49
+ description: 'Something else worth recording.'
50
+ }
51
+ ];
52
+
53
+ export type Flag = {
54
+ matchId: number;
55
+ mapName: string;
56
+ round: number;
57
+ reason: FlagReason;
58
+ ts: number;
59
+ };
60
+
61
+ const FLAGS_KEY = 'opencs2:eval:flags:v1';
62
+
63
+ export function loadFlags(): Flag[] {
64
+ if (!browser) return [];
65
+ try {
66
+ return JSON.parse(localStorage.getItem(FLAGS_KEY) ?? '[]') as Flag[];
67
+ } catch {
68
+ return [];
69
+ }
70
+ }
71
+
72
+ export function saveFlags(flags: Flag[]) {
73
+ if (!browser) return;
74
+ localStorage.setItem(FLAGS_KEY, JSON.stringify(flags));
75
+ }
76
+
77
+ export function addFlag(f: Omit<Flag, 'ts'>) {
78
+ const flags = loadFlags();
79
+ flags.push({ ...f, ts: Date.now() });
80
+ saveFlags(flags);
81
+ }
82
+
83
+ // Mulberry32 — small deterministic PRNG so the picked middle round is stable
84
+ // for a given (match_id, map_name) and the eval set doesn't shift between
85
+ // sessions.
86
+ function prng(seed: number): number {
87
+ let t = (seed + 0x6d2b79f5) | 0;
88
+ t = Math.imul(t ^ (t >>> 15), t | 1);
89
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
90
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
91
+ }
92
+
93
+ /**
94
+ * Evaluation policy: per (match, map), sample 3 rounds — first, last, and
95
+ * one deterministic random round in the middle. Sorted by match_id, then
96
+ * map_index to match the rest of the app's canonical order.
97
+ */
98
+ export function buildEvalQueue(matches: Match[]): EvalCandidate[] {
99
+ const sorted = matches
100
+ .slice()
101
+ .sort((a, b) => a.match_id - b.match_id || (a.map_index ?? 0) - (b.map_index ?? 0));
102
+
103
+ const out: EvalCandidate[] = [];
104
+ for (const m of sorted) {
105
+ const total = m.rounds_played;
106
+ if (!total || total < 1) continue;
107
+
108
+ const picks = new Set<number>([1, total]);
109
+ if (total > 2) {
110
+ const seed = m.match_id * 31 + m.map_name.length * 17 + (m.map_index ?? 0);
111
+ const span = total - 2; // pick from [2, total - 1]
112
+ picks.add(2 + Math.floor(prng(seed) * span));
113
+ }
114
+
115
+ for (const round of [...picks].sort((a, b) => a - b)) {
116
+ out.push({ matchId: m.match_id, mapName: m.map_name, round });
117
+ }
118
+ }
119
+ return out;
120
+ }
121
+
122
+ export function indexOfCandidate(
123
+ queue: EvalCandidate[],
124
+ matchId: number,
125
+ mapName: string,
126
+ round: number
127
+ ): number {
128
+ return queue.findIndex(
129
+ (c) => c.matchId === matchId && c.mapName === mapName && c.round === round
130
+ );
131
+ }
132
+
133
+ export function evalUrl(c: EvalCandidate, i: number): string {
134
+ const params = new URLSearchParams({
135
+ round: String(c.round),
136
+ player: '0',
137
+ view: 'grid',
138
+ eval: '1',
139
+ i: String(i)
140
+ });
141
+ return `/match/${encodeURIComponent(c.matchId)}/${encodeURIComponent(c.mapName)}?${params}`;
142
+ }
src/routes/match/[matchId]/[mapName]/+page.svelte CHANGED
@@ -3,6 +3,8 @@
3
  import { page } from '$app/state';
4
  import { goto } from '$app/navigation';
5
  import Header from '$lib/components/header.svelte';
 
 
6
  import RoundList from '$lib/components/round-list.svelte';
7
  import PlayerGrid from '$lib/components/player-grid.svelte';
8
  import VideoStage from '$lib/components/video-stage.svelte';
@@ -75,6 +77,17 @@
75
 
76
  let viewMode = $state<'single' | 'grid'>(readViewFromUrl());
77
 
 
 
 
 
 
 
 
 
 
 
 
78
  const playerChunks = $derived(
79
  previews.filter((p) => p.player === currentPlayer).sort((a, b) => a.chunk_index - b.chunk_index)
80
  );
@@ -340,34 +353,47 @@
340
  }
341
  }
342
 
343
- // React to (matchId, mapName) changes so navigating between maps via the
344
- // Select dropdown which only swaps the route param, not the component —
345
- // resets local state and reloads the new round previews.
 
346
  let prevRouteKey = '';
347
  $effect(() => {
348
  const routeKey = `${data.match.match_id}|${data.match.map_name}`;
349
- if (routeKey === prevRouteKey) return;
350
- prevRouteKey = routeKey;
351
-
352
- const newRound = readRoundFromUrl(data.rounds);
353
- const newPlayer = readPlayerFromUrl();
354
- const newView = readViewFromUrl();
355
 
356
  untrack(() => {
357
- currentRoundNum = newRound;
358
- currentPlayer = newPlayer;
359
- viewMode = newView;
360
- previews = [];
361
- previewsError = null;
362
- virtualTime = 0;
363
- initialVirtualTime = 0;
364
- activeVideoEnded = false;
365
- bufferedRanges = [];
366
- preloadedPlayers = new Set();
367
- preloadAllPlayers = false;
368
- masterPaused = false;
 
 
 
 
 
 
 
369
 
370
- loadRound(newRound);
 
 
 
 
 
 
 
 
371
  });
372
  });
373
  </script>
@@ -376,6 +402,16 @@
376
 
377
  <Header />
378
 
 
 
 
 
 
 
 
 
 
 
379
  <main
380
  data-view={viewMode}
381
  class="mx-auto w-full max-w-[1600px] px-4 py-6 data-[view=grid]:max-w-none"
 
3
  import { page } from '$app/state';
4
  import { goto } from '$app/navigation';
5
  import Header from '$lib/components/header.svelte';
6
+ import EvalBar from '$lib/components/eval-bar.svelte';
7
+ import { buildEvalQueue, indexOfCandidate } from '$lib/eval';
8
  import RoundList from '$lib/components/round-list.svelte';
9
  import PlayerGrid from '$lib/components/player-grid.svelte';
10
  import VideoStage from '$lib/components/video-stage.svelte';
 
77
 
78
  let viewMode = $state<'single' | 'grid'>(readViewFromUrl());
79
 
80
+ // Evaluation mode driven by ?eval=1&i=N. Queue is deterministic from the
81
+ // match list so reloading or sharing a URL still lands on the same item.
82
+ const inEvalMode = $derived(page.url.searchParams.get('eval') === '1');
83
+ const evalQueue = $derived(inEvalMode ? buildEvalQueue(data.matches) : []);
84
+ const evalIndex = $derived.by(() => {
85
+ if (!inEvalMode) return -1;
86
+ const i = Number(page.url.searchParams.get('i'));
87
+ if (Number.isFinite(i) && i >= 0 && i < evalQueue.length) return i;
88
+ return indexOfCandidate(evalQueue, data.match.match_id, data.match.map_name, currentRoundNum);
89
+ });
90
+
91
  const playerChunks = $derived(
92
  previews.filter((p) => p.player === currentPlayer).sort((a, b) => a.chunk_index - b.chunk_index)
93
  );
 
353
  }
354
  }
355
 
356
+ // React to navigations: a (matchId, mapName) change reuses the component
357
+ // (SvelteKit doesn't remount), so we reset state + reload. A change in
358
+ // just the round/player/view URL params (e.g. eval mode's Next button
359
+ // jumping to a new round in the same map) also needs to be picked up.
360
  let prevRouteKey = '';
361
  $effect(() => {
362
  const routeKey = `${data.match.match_id}|${data.match.map_name}`;
363
+ const urlRound = readRoundFromUrl(data.rounds);
364
+ const urlPlayer = readPlayerFromUrl();
365
+ const urlView = readViewFromUrl();
 
 
 
366
 
367
  untrack(() => {
368
+ const routeChanged = routeKey !== prevRouteKey;
369
+ prevRouteKey = routeKey;
370
+
371
+ if (routeChanged) {
372
+ currentRoundNum = urlRound;
373
+ currentPlayer = urlPlayer;
374
+ viewMode = urlView;
375
+ previews = [];
376
+ previewsError = null;
377
+ virtualTime = 0;
378
+ initialVirtualTime = 0;
379
+ activeVideoEnded = false;
380
+ bufferedRanges = [];
381
+ preloadedPlayers = new Set();
382
+ preloadAllPlayers = false;
383
+ masterPaused = false;
384
+ loadRound(urlRound);
385
+ return;
386
+ }
387
 
388
+ // Same match+map, but URL params may have shifted (eval Next, history
389
+ // nav, ...). Only act on actual differences so internal calls that
390
+ // already updated state via syncUrl don't re-trigger a load.
391
+ if (urlRound !== currentRoundNum) {
392
+ currentRoundNum = urlRound;
393
+ loadRound(urlRound);
394
+ }
395
+ if (urlPlayer !== currentPlayer) currentPlayer = urlPlayer;
396
+ if (urlView !== viewMode) viewMode = urlView;
397
  });
398
  });
399
  </script>
 
402
 
403
  <Header />
404
 
405
+ {#if inEvalMode}
406
+ <EvalBar
407
+ queue={evalQueue}
408
+ index={evalIndex}
409
+ matchId={data.match.match_id}
410
+ mapName={data.match.map_name}
411
+ round={currentRoundNum}
412
+ />
413
+ {/if}
414
+
415
  <main
416
  data-view={viewMode}
417
  class="mx-auto w-full max-w-[1600px] px-4 py-6 data-[view=grid]:max-w-none"