@anthusai/papyrus 1.19.1 → 2.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,24 @@
1
1
  "use client";
2
2
 
3
- import {
4
- BookOpenIcon,
5
- ClipboardListIcon,
6
- FileTextIcon,
7
- LayoutGridIcon,
8
- MenuIcon,
9
- SearchIcon,
10
- TagsIcon,
11
- } from "lucide-react";
12
- import Link from "next/link";
13
- import type { ReactNode } from "react";
14
- import { useMemo, useState } from "react";
15
- import { Badge } from "./ui/badge";
16
- import { Button, buttonVariants } from "./ui/button";
17
- import { ScrollArea } from "./ui/scroll-area";
3
+ import { SearchIcon } from "lucide-react";
4
+ import { Button } from "./ui/button";
18
5
  import { Separator } from "./ui/separator";
19
- import {
20
- Sheet,
21
- SheetContent,
22
- SheetHeader,
23
- SheetTitle,
24
- SheetTrigger,
25
- } from "./ui/sheet";
26
- import {
27
- getNewsroomNavHref,
28
- NEWSROOM_MOBILE_PRIMARY_NAV,
29
- NEWSROOM_OPS_NAV,
30
- type NewsroomNavTabId,
31
- } from "../lib/newsroom-nav";
32
- import {
33
- NEWSROOM_SIDEBAR_NAV_ACTIVE,
34
- NEWSROOM_SIDEBAR_NAV_INACTIVE,
35
- } from "../lib/newsroom-list-selection";
36
6
  import { cn } from "../lib/utils";
7
+
8
+ import { useEffect, useId, useState, type ReactNode } from "react";
9
+ import Link from "next/link";
10
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
11
+ import { BookOpen, ClipboardList, Menu, Search, MessagesSquare, PanelLeftClose, PanelLeftOpen, Settings, UserRound, LogIn, LogOut } from "lucide-react";
12
+ import { ORGANIZER_NAV_GROUPS, ORGANIZER_PRIMARY_NAV, ORGANIZER_SETTINGS_DESTINATION } from "../lib/newsroom-organizer-nav";
13
+ import { browserPathToInternalNewsroomPath } from "../lib/newsroom-base-path";
14
+ import { getNewsroomNavHref } from "../lib/newsroom-nav";
37
15
  import { SITE_BRAND } from "../lib/site-brand";
38
- import { NewsroomOrganizerShell } from "./newsroom-organizer-shell";
16
+ import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
17
+ import { ReaderAuthControl } from "./reader-auth-control";
18
+ import { ProspectusAccountChooser, useProspectusAccountSummary } from "./prospectus-account-chooser";
19
+ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetTrigger } from "./ui/sheet";
20
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuSeparator } from "./ui/dropdown-menu";
21
+ import "./newsroom-organizer.css";
39
22
 
40
23
  export type NewsroomNavCount = {
41
24
  count: number | null;
@@ -44,7 +27,7 @@ export type NewsroomNavCount = {
44
27
  };
45
28
 
46
29
  export type NewsroomOpsShellProps = {
47
- activeTab: NewsroomNavTabId | string;
30
+ activeTab: string;
48
31
  appTitle: string;
49
32
  backHref?: string;
50
33
  backLabel: string;
@@ -56,215 +39,140 @@ export type NewsroomOpsShellProps = {
56
39
  tabCounts?: Partial<Record<string, NewsroomNavCount>>;
57
40
  };
58
41
 
59
- const MOBILE_TAB_ICONS: Record<string, typeof LayoutGridIcon> = {
60
- overview: LayoutGridIcon,
61
- articles: FileTextIcon,
62
- assignments: ClipboardListIcon,
63
- references: BookOpenIcon,
64
- topics: TagsIcon,
65
- };
66
-
67
- function formatCountLabel(count: number | null, missing?: boolean): string {
68
- if (missing) return "?";
69
- if (count == null) return "…";
70
- if (count >= 1000) return `${Math.round(count / 100) / 10}k`;
71
- return String(count);
42
+ /** The standard place to search the knowledge base; the Search page is the results page. */
43
+ function OrganizerSearch({ demo }: { demo: boolean }) {
44
+ const router = useRouter();
45
+ const searchParams = useSearchParams();
46
+ const [text, setText] = useState(searchParams.get("q") ?? "");
47
+ return <form className="organizer-search" role="search" onSubmit={event => {
48
+ event.preventDefault();
49
+ const query = text.trim();
50
+ if (query) router.push(getNewsroomNavHref(`/newsroom/search?q=${encodeURIComponent(query)}`, demo));
51
+ }}>
52
+ <Search size={14} aria-hidden="true" />
53
+ <input aria-label="Search the knowledge base" data-newsroom-search type="search" onChange={event => setText(event.target.value)} placeholder="Search" value={text} />
54
+ </form>;
72
55
  }
73
56
 
74
- function NavCountBadge({
75
- countState,
76
- }: {
77
- countState?: NewsroomNavCount;
78
- }) {
79
- if (!countState || countState.visible === false) return null;
80
- return (
81
- <Badge
82
- className="newsroom-nav-count min-w-7 px-1.5"
83
- data-newsroom-nav-count
84
- variant={countState.missing ? "outline" : "secondary"}
85
- >
86
- {formatCountLabel(countState.count, countState.missing)}
87
- </Badge>
88
- );
57
+ const ICONS = { articles: ClipboardList, references: BookOpen, messages: MessagesSquare };
58
+
59
+ /** Navigation is a presentation layer; existing route and server authorization still own access. */
60
+ function Navigation({ activePath, demo, admin, surface, onNavigate }: { activePath: string; demo: boolean; admin: boolean; surface: string; onNavigate?: () => void }) {
61
+ const id = useId();
62
+ const all = ORGANIZER_NAV_GROUPS.flatMap(group => group.items);
63
+ const active = all.filter(item => [item.path, ...(item.alsoActiveOnPaths ?? [])].some(candidate => activePath === candidate || (candidate !== "/newsroom" && activePath.startsWith(candidate + "/")))).sort((a, b) => b.path.length - a.path.length)[0]?.key;
64
+ return <nav className="organizer-destinations" aria-label={surface === "sidebar" ? "Newsroom" : "All workspaces"}>
65
+ {ORGANIZER_NAV_GROUPS.map((group, index) => <section key={group.title} aria-labelledby={`${id}-${index}`}>
66
+ <h3 id={`${id}-${index}`}>{group.title}</h3>
67
+ {group.items.filter(item => item.access !== "admin" || admin).map(item => <Link key={item.key}
68
+ href={getNewsroomNavHref(item.path, demo)} onClick={onNavigate} aria-label={item.label}
69
+ aria-current={active === item.key ? "page" : undefined} aria-describedby={`${id}-${item.key}`}
70
+ data-news-desk-tab={item.key}>
71
+ <strong>{item.label}</strong><small id={`${id}-${item.key}`}>{item.description}</small>
72
+ </Link>)}
73
+ </section>)}
74
+ </nav>;
89
75
  }
90
76
 
91
- function SidebarNavLink({
92
- active,
93
- countState,
94
- demo,
95
- item,
96
- onNavigate,
97
- }: {
98
- active: boolean;
99
- countState?: NewsroomNavCount;
100
- demo?: boolean;
101
- item: (typeof NEWSROOM_OPS_NAV)[number];
102
- onNavigate?: () => void;
103
- }) {
104
- return (
105
- <Link
106
- aria-current={active ? "page" : undefined}
107
- className={cn(
108
- buttonVariants({ variant: "ghost", size: "default" }),
109
- "h-auto min-h-11 w-full justify-start gap-3 px-3 py-2.5 text-left font-normal",
110
- active ? NEWSROOM_SIDEBAR_NAV_ACTIVE : NEWSROOM_SIDEBAR_NAV_INACTIVE,
111
- )}
112
- data-news-desk-tab={item.id}
113
- href={getNewsroomNavHref(item.href, demo)}
114
- onClick={onNavigate}
115
- >
116
- <NavCountBadge countState={countState} />
117
- <span className="min-w-0 flex-1">
118
- <span className="block text-sm font-medium">{item.label}</span>
119
- <span className={cn("block text-xs", active ? "text-foreground/70" : "text-muted-foreground")}>{item.detail}</span>
120
- </span>
121
- </Link>
122
- );
77
+ function Account({ placement }: { placement: "sidebar" | "header" }) {
78
+ const session = useOptionalNewsDeskClient();
79
+ const auth = session?.shell.auth ?? { status: "loading" as const, label: "Checking sign-in" };
80
+ const [open, setOpen] = useState(false);
81
+ const accountSummary = useProspectusAccountSummary();
82
+ useEffect(() => {
83
+ const media = matchMedia("(max-width: 900px)");
84
+ const close = () => setOpen(false);
85
+ media.addEventListener("change", close);
86
+ return () => media.removeEventListener("change", close);
87
+ }, []);
88
+ return <DropdownMenu open={open} onOpenChange={setOpen}>
89
+ <DropdownMenuTrigger id={`organizer-account-trigger-${placement}`} className={`organizer-account organizer-account-${placement}`} aria-label="Account menu" title="Account menu">
90
+ <UserRound size={18} aria-hidden="true" /><span><strong>{auth.label}</strong><small>{accountSummary ?? (auth.status === "signedIn" ? "Account & preferences" : auth.status === "signedOut" ? "Not signed in" : "Checking session")}</small></span>
91
+ </DropdownMenuTrigger>
92
+ <DropdownMenuContent className="organizer-account-popup" side={placement === "sidebar" ? "top" : "bottom"} align="end">
93
+ <DropdownMenuGroup>
94
+ <DropdownMenuLabel>{auth.label}</DropdownMenuLabel><DropdownMenuSeparator />
95
+ <ProspectusAccountChooser />
96
+ <DropdownMenuItem render={<Link href={getNewsroomNavHref(ORGANIZER_SETTINGS_DESTINATION.path)} />}><Settings aria-hidden="true" />{ORGANIZER_SETTINGS_DESTINATION.label}</DropdownMenuItem>
97
+ <ReaderAuthControl authState={auth} renderAction={({ disabled, onClick, signedIn }) => <DropdownMenuItem disabled={disabled} closeOnClick={false} onClick={onClick}>
98
+ {signedIn ? <LogOut aria-hidden="true" /> : <LogIn aria-hidden="true" />}{signedIn ? "Sign out" : "Sign in"}
99
+ </DropdownMenuItem>} />
100
+ </DropdownMenuGroup>
101
+ </DropdownMenuContent>
102
+ </DropdownMenu>;
123
103
  }
124
104
 
125
- export function NewsroomOpsShell({
126
- activeTab,
127
- appTitle,
128
- backHref = "/",
129
- backLabel,
130
- children,
131
- demo = false,
132
- headerActions,
133
- pageTitle,
134
- showNavigation = true,
135
- tabCounts = {},
136
- }: NewsroomOpsShellProps) {
105
+ export function NewsroomOpsShell({ activeTab, appTitle, backHref = "/", backLabel, children, demo = false, headerActions, pageTitle, showNavigation = true }: NewsroomOpsShellProps) {
106
+ const pathname = usePathname();
107
+ const session = useOptionalNewsDeskClient();
108
+ const admin = demo || session?.shell.dashboard?.canManageUsers === true;
137
109
  const [menuOpen, setMenuOpen] = useState(false);
138
- const resolvedActiveTab = activeTab === "desks" ? "topics" : activeTab;
139
- const mobilePrimary = useMemo(() => NEWSROOM_MOBILE_PRIMARY_NAV, []);
140
-
141
- if (SITE_BRAND.newsroomLayout === "organizer") return <NewsroomOrganizerShell activeTab={activeTab} appTitle={appTitle}
142
- backHref={backHref} backLabel={backLabel} demo={demo} headerActions={headerActions} pageTitle={pageTitle}
143
- showNavigation={showNavigation} tabCounts={tabCounts}>{children}</NewsroomOrganizerShell>;
144
-
145
- return (
146
- <div
147
- className="flex h-dvh max-h-dvh flex-col overflow-hidden bg-background text-foreground"
148
- data-news-desk
149
- data-newsroom-chrome="app"
150
- data-newsroom-ops-shell="true"
151
- >
152
- <header
153
- className="flex h-14 shrink-0 items-center gap-3 border-b border-border bg-card/50 px-3 sm:px-4"
154
- data-newsroom-ops-topbar
155
- >
156
- <Link
157
- className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "shrink-0 px-2")}
158
- href={backHref}
159
- >
160
- {backLabel}
161
- </Link>
162
- <div className="min-w-0 flex-1">
163
- <p className="truncate text-[0.65rem] font-semibold uppercase tracking-[0.12em] text-muted-foreground">
164
- {appTitle}
165
- </p>
166
- <h1 className="truncate text-base font-semibold tracking-tight text-foreground" data-newsroom-ops-title>
167
- {pageTitle}
168
- </h1>
169
- </div>
170
- <div className="flex shrink-0 items-center gap-1.5">{headerActions}</div>
171
- </header>
172
-
173
- <div className="flex min-h-0 flex-1">
174
- {showNavigation ? (
175
- <aside
176
- aria-label="Newsroom sections"
177
- className="hidden w-64 shrink-0 flex-col border-r border-border bg-muted/20 md:flex"
178
- data-newsroom-ops-sidebar
179
- >
180
- <ScrollArea className="min-h-0 flex-1 p-3">
181
- <nav className="flex flex-col gap-1">
182
- {NEWSROOM_OPS_NAV.map((item) => (
183
- <SidebarNavLink
184
- active={resolvedActiveTab === item.id}
185
- countState={tabCounts[item.id]}
186
- demo={demo}
187
- item={item}
188
- key={item.id}
189
- />
190
- ))}
191
- </nav>
192
- </ScrollArea>
193
- </aside>
194
- ) : null}
195
-
196
- <main className="flex min-h-0 min-w-0 flex-1 flex-col">
197
- <ScrollArea className="min-h-0 flex-1">
198
- <div className="mx-auto w-full max-w-6xl p-4 sm:p-6">{children}</div>
199
- </ScrollArea>
200
- </main>
110
+ const [collapsed, setCollapsed] = useState(false);
111
+ const [loadedPreference, setLoadedPreference] = useState(false);
112
+ const preferenceKey = `papyrus.cms.sidebar.v1.${SITE_BRAND.id}`;
113
+ useEffect(() => {
114
+ try { setCollapsed(localStorage.getItem(preferenceKey) === "true"); } catch { /* Optional browser preference. */ }
115
+ setLoadedPreference(true);
116
+ }, [preferenceKey]);
117
+ useEffect(() => { if (loadedPreference) try { localStorage.setItem(preferenceKey, String(collapsed)); } catch { /* Controls still work without storage. */ } }, [collapsed, loadedPreference, preferenceKey]);
118
+ useEffect(() => { setMenuOpen(false); }, [pathname]);
119
+ useEffect(() => {
120
+ const media = matchMedia("(max-width: 900px)");
121
+ let previousFocus: Element | null = null;
122
+ let frame = 0;
123
+ const remember = () => { if (document.activeElement !== document.body) previousFocus = document.activeElement; };
124
+ const change = () => {
125
+ const active = document.activeElement === document.body ? previousFocus : document.activeElement;
126
+ if (!(active instanceof HTMLElement)) return;
127
+ if (!media.matches) setMenuOpen(false);
128
+ const selector = active.closest(".organizer-account, .organizer-account-popup") ? ".organizer-account"
129
+ : media.matches && active.closest(".organizer-sidebar, .organizer-toggle") ? ".organizer-more"
130
+ : !media.matches && active.closest(".organizer-bottom-nav, .organizer-menu") ? ".organizer-toggle" : null;
131
+ if (!selector) return;
132
+ cancelAnimationFrame(frame);
133
+ frame = requestAnimationFrame(() => {
134
+ if (document.activeElement === active || document.activeElement === document.body || !(document.activeElement as HTMLElement)?.getClientRects().length)
135
+ Array.from(document.querySelectorAll<HTMLElement>(selector)).find(element => element.getClientRects().length)?.focus();
136
+ });
137
+ };
138
+ document.addEventListener("focusin", remember);
139
+ media.addEventListener("change", change);
140
+ return () => { document.removeEventListener("focusin", remember); media.removeEventListener("change", change); cancelAnimationFrame(frame); };
141
+ }, []);
142
+ const activePath = browserPathToInternalNewsroomPath(pathname ?? "/newsroom");
143
+ const sidebarToggleLabel = collapsed ? "Expand sidebar" : "Collapse sidebar";
144
+ const sidebarToggle = <button type="button" className="organizer-toggle" title={sidebarToggleLabel}
145
+ aria-label={sidebarToggleLabel} aria-expanded={!collapsed} aria-controls="organizer-sidebar" onClick={() => setCollapsed(value => !value)}>
146
+ {collapsed ? <PanelLeftOpen size={16} aria-hidden="true" /> : <PanelLeftClose size={16} aria-hidden="true" />}
147
+ </button>;
148
+ return <div className="newsroom-organizer" data-news-desk data-newsroom-ops-shell="true" data-newsroom-chrome="organizer" data-sidebar-collapsed={collapsed || !showNavigation ? "true" : "false"}>
149
+ {showNavigation && <aside className="organizer-sidebar" hidden={collapsed} id="organizer-sidebar">
150
+ <div className="organizer-sidebar-head">
151
+ <Link className="organizer-brand" href={getNewsroomNavHref("/newsroom", demo)}>{SITE_BRAND.components?.NewsroomLogo ? <SITE_BRAND.components.NewsroomLogo className="organizer-brand-logo" /> : appTitle}<small>The newsroom</small></Link>
152
+ {sidebarToggle}
201
153
  </div>
202
-
203
- {showNavigation ? (
204
- <nav
205
- aria-label="Primary newsroom navigation"
206
- className="shrink-0 border-t border-border bg-card/95 pb-[max(env(safe-area-inset-bottom),0.35rem)] pt-1 md:hidden"
207
- data-newsroom-ops-bottom-nav
208
- >
209
- <ul className="grid grid-cols-6 gap-1 px-1">
210
- {mobilePrimary.map((item) => {
211
- const Icon = MOBILE_TAB_ICONS[item.id] ?? LayoutGridIcon;
212
- const active = resolvedActiveTab === item.id;
213
- return (
214
- <li key={item.id}>
215
- <Link
216
- aria-current={active ? "page" : undefined}
217
- className={cn(
218
- "flex min-h-14 flex-col items-center justify-center gap-1 rounded-xl px-1 py-2 text-[0.68rem] font-medium",
219
- active
220
- ? "bg-primary text-primary-foreground shadow-sm"
221
- : "text-muted-foreground",
222
- )}
223
- data-news-desk-tab={item.id}
224
- href={getNewsroomNavHref(item.href, demo)}
225
- >
226
- <Icon className="size-4" aria-hidden="true" />
227
- <span>{item.label}</span>
228
- </Link>
229
- </li>
230
- );
231
- })}
232
- <li>
233
- <Sheet onOpenChange={setMenuOpen} open={menuOpen}>
234
- <SheetTrigger
235
- className={cn(
236
- "flex min-h-14 w-full flex-col items-center justify-center gap-1 rounded-xl px-1 py-2 text-[0.68rem] font-medium text-muted-foreground",
237
- )}
238
- >
239
- <MenuIcon className="size-4" aria-hidden="true" />
240
- <span>More</span>
241
- </SheetTrigger>
242
- <SheetContent className="gap-0 p-0" side="bottom">
243
- <SheetHeader className="border-b border-border px-4 py-4">
244
- <SheetTitle>All sections</SheetTitle>
245
- </SheetHeader>
246
- <ScrollArea className="max-h-[60dvh] p-3">
247
- <div className="flex flex-col gap-1">
248
- {NEWSROOM_OPS_NAV.map((item) => (
249
- <SidebarNavLink
250
- active={resolvedActiveTab === item.id}
251
- countState={tabCounts[item.id]}
252
- demo={demo}
253
- item={item}
254
- key={item.id}
255
- onNavigate={() => setMenuOpen(false)}
256
- />
257
- ))}
258
- </div>
259
- </ScrollArea>
260
- </SheetContent>
261
- </Sheet>
262
- </li>
263
- </ul>
264
- </nav>
265
- ) : null}
154
+ <Navigation activePath={activePath} demo={demo} admin={admin} surface="sidebar" />
155
+ <Account placement="sidebar" />
156
+ </aside>}
157
+ <div className="organizer-workspace">
158
+ <header className="organizer-topbar" data-newsroom-ops-topbar>
159
+ {showNavigation && collapsed && sidebarToggle}
160
+ <Link className="organizer-masthead" href={backHref} title={backLabel}>{appTitle}</Link>
161
+ <h1 data-newsroom-ops-title>{pageTitle}</h1><OrganizerSearch demo={demo} /><div className="organizer-header-actions">{headerActions}</div><Account placement="header" />
162
+ </header>
163
+ <main className="organizer-main">{demo && <p className="organizer-demo-notice">Demo workspace · synthetic examples</p>}{children}</main>
266
164
  </div>
267
- );
165
+ {showNavigation && <nav className="organizer-bottom-nav" aria-label="Primary newsroom navigation"><ul>
166
+ {ORGANIZER_PRIMARY_NAV.map(item => { const Icon = ICONS[item.key as keyof typeof ICONS]; return <li key={item.key}><Link
167
+ href={getNewsroomNavHref(item.path, demo)} title={item.description} aria-label={item.label} aria-current={activeTab === item.key ? "page" : undefined}>
168
+ <Icon size={18} aria-hidden="true" /><span>{item.label}</span></Link></li>; })}
169
+ <li><Sheet open={menuOpen} onOpenChange={setMenuOpen}><SheetTrigger className="organizer-more" aria-label="More"><Menu size={18} aria-hidden="true" /><span>More</span></SheetTrigger>
170
+ <SheetContent side="bottom" className="organizer-menu"><SheetHeader><SheetTitle>Newsroom</SheetTitle><SheetDescription>Workspaces and administration</SheetDescription></SheetHeader>
171
+ <Navigation activePath={activePath} demo={demo} admin={admin} surface="menu" onNavigate={() => setMenuOpen(false)} />
172
+ </SheetContent>
173
+ </Sheet></li>
174
+ </ul></nav>}
175
+ </div>;
268
176
  }
269
177
 
270
178
  export function NewsroomOpsSearchButton({
@@ -6,9 +6,8 @@ import { primingStateText, type PrimingRequestView } from "../lib/relevance-stat
6
6
  export type PrimingFormInput = { url: string; label: string; explanation: string };
7
7
 
8
8
  /**
9
- * A compact form that primes the running relevance cyclotron with a pasted
10
- * URL. The next sweep reads the page, adds it to the cyclotron's example list
11
- * and records the outcome, which this list shows beside each saved request.
9
+ * A compact "Add a reference" form for a pasted URL. The page is read in the
10
+ * background and the outcome is shown beside each added reference.
12
11
  */
13
12
  export function ReferenceCyclotronPriming({
14
13
  labels,
@@ -25,19 +24,19 @@ export function ReferenceCyclotronPriming({
25
24
  const [message, setMessage] = useState<string | null>(null);
26
25
 
27
26
  async function submit() {
28
- setMessage("Saving…");
27
+ setMessage("Adding…");
29
28
  try {
30
29
  await onRequestPriming({ url, label, explanation });
31
30
  setUrl("");
32
31
  setExplanation("");
33
- setMessage("Saved. The next sweep reads the page and adds it to the cyclotron.");
32
+ setMessage("Added. The page will be read shortly.");
34
33
  } catch (error) {
35
34
  setMessage(error instanceof Error ? error.message : String(error));
36
35
  }
37
36
  }
38
37
 
39
38
  return (
40
- <section aria-label="Prime the relevance cyclotron" className="space-y-2 text-sm" data-reference-cyclotron-priming>
39
+ <section aria-label="Add a reference" className="space-y-2 text-sm" data-reference-cyclotron-priming>
41
40
  <form
42
41
  className="flex flex-wrap items-end gap-3"
43
42
  onSubmit={(event) => {
@@ -46,9 +45,9 @@ export function ReferenceCyclotronPriming({
46
45
  }}
47
46
  >
48
47
  <label className="flex min-w-64 flex-1 flex-col gap-1">
49
- <span className="text-xs text-muted-foreground">Prime with a URL</span>
48
+ <span className="text-xs text-muted-foreground">Add a reference by URL</span>
50
49
  <input
51
- aria-label="Priming URL"
50
+ aria-label="Reference URL"
52
51
  onChange={(event) => setUrl(event.target.value)}
53
52
  placeholder="https://"
54
53
  required
@@ -57,8 +56,8 @@ export function ReferenceCyclotronPriming({
57
56
  />
58
57
  </label>
59
58
  <label className="flex flex-col gap-1">
60
- <span className="text-xs text-muted-foreground">Label</span>
61
- <select aria-label="Priming label" onChange={(event) => setLabel(event.target.value)} value={label}>
59
+ <span className="text-xs text-muted-foreground">Include or exclude</span>
60
+ <select aria-label="Include or exclude" onChange={(event) => setLabel(event.target.value)} value={label}>
62
61
  {labels.map((choice) => (
63
62
  <option key={choice} value={choice}>{choice}</option>
64
63
  ))}
@@ -66,13 +65,13 @@ export function ReferenceCyclotronPriming({
66
65
  </label>
67
66
  <label className="flex min-w-48 flex-1 flex-col gap-1">
68
67
  <span className="text-xs text-muted-foreground">Why (optional)</span>
69
- <input aria-label="Priming explanation" onChange={(event) => setExplanation(event.target.value)} type="text" value={explanation} />
68
+ <input aria-label="Reason" onChange={(event) => setExplanation(event.target.value)} type="text" value={explanation} />
70
69
  </label>
71
- <button className="cyclotron-review-secondary" type="submit">Save</button>
70
+ <button className="cyclotron-review-secondary" type="submit">Add reference</button>
72
71
  {message ? <p className="basis-full text-xs" role="status">{message}</p> : null}
73
72
  </form>
74
73
  {requests.length ? (
75
- <ul aria-label="Saved priming requests" className="space-y-1 text-xs text-muted-foreground">
74
+ <ul aria-label="Added references" className="space-y-1 text-xs text-muted-foreground">
76
75
  {requests.slice(0, 10).map((view) => (
77
76
  <li data-priming-request-state={view.outcome?.state ?? "waiting"} key={view.request.requestId}>
78
77
  <span className="font-medium">{view.request.label}</span> {view.request.url} · {primingStateText(view)}
@@ -38,19 +38,19 @@ export function ReferenceCyclotronStatus({
38
38
  setMessage("Sending…");
39
39
  try {
40
40
  await onRequestRate(choice);
41
- setMessage("The next sweep applies it and the status will show who set it.");
41
+ setMessage("Saved. The new rate takes effect shortly and the status will show who set it.");
42
42
  } catch (error) {
43
43
  setMessage(error instanceof Error ? error.message : String(error));
44
44
  }
45
45
  }
46
46
 
47
47
  return (
48
- <section aria-label="Relevance cyclotron" className="space-y-2" data-reference-cyclotron-status>
48
+ <section aria-label="Suggestion status" className="space-y-2" data-reference-cyclotron-status>
49
49
  <CyclotronStatusView status={status} />
50
50
  {stale ? (
51
51
  <p className="text-xs text-foreground" data-reference-cyclotron-status-stale>
52
52
  <span aria-hidden="true">⚠ </span>
53
- Snapshot from {Math.round(ageHours)} hours ago; the next sweep refreshes it.
53
+ Status last updated {Math.round(ageHours)} hours ago; it refreshes automatically.
54
54
  </p>
55
55
  ) : null}
56
56
  <button
@@ -59,7 +59,7 @@ export function ReferenceCyclotronStatus({
59
59
  onClick={() => setOpen((value) => !value)}
60
60
  type="button"
61
61
  >
62
- {open ? "Hide what the cyclotron is doing" : "What the cyclotron is doing"}
62
+ {open ? "Hide suggestion details" : "Suggestion details"}
63
63
  </button>
64
64
  {open ? (
65
65
  <div className="space-y-3">
@@ -101,12 +101,12 @@ export function ReferenceSuggestionProvenance({ decision }: { decision: Relevanc
101
101
  <ul className="mt-2 space-y-1">
102
102
  <li>{summary.teachingLabelsSentence}.</li>
103
103
  <li>{summary.primingExamplesSentence}.</li>
104
- <li>Doctrine fingerprint {summary.doctrineShortHash ?? "not recorded"}.</li>
105
- <li>Model {summary.modelVersion ?? "version not recorded"}.</li>
104
+ <li>Guidelines code {summary.doctrineShortHash ?? "not recorded"}.</li>
105
+ <li>Suggestion {summary.modelVersion ?? "revision not recorded"}.</li>
106
106
  <li>Decided {formatSuggestionTime(summary.decidedAt)}.</li>
107
107
  </ul>
108
108
  ) : (
109
- <p className="mt-2">This suggestion was made before the cyclotron recorded how. Only its model version and confidence are known.</p>
109
+ <p className="mt-2">This suggestion was made before the details were recorded. Only its revision and confidence are known.</p>
110
110
  )}
111
111
  </details>
112
112
  );
@@ -116,7 +116,7 @@ export function ReferenceSuggestionProvenance({ decision }: { decision: Relevanc
116
116
  export function CountsAsTrainingLabelNote({ referenceLineageId }: { referenceLineageId: string }) {
117
117
  return (
118
118
  <p className="border-l-2 border-foreground pl-2 text-xs font-semibold text-foreground" data-reference-training-label={referenceLineageId}>
119
- Counts as a training label: an editor made this decision, so the cyclotron learns from it.
119
+ Recorded as an editor&rsquo;s own decision.
120
120
  </p>
121
121
  );
122
122
  }
@@ -135,8 +135,8 @@ export function DelegatedCurationNote({ delegated, referenceLineageId }: { deleg
135
135
  <p className="text-xs">Delegation {delegated.delegationShortId || "id not recorded"}.</p>
136
136
  <p className="text-xs font-semibold" data-reference-training-label={referenceLineageId}>
137
137
  {delegated.countsAsTrainingLabel
138
- ? `Counts as a training label: the record is stamped as ${delegated.person ?? "the person"}'s own decision, so the cyclotron learns from it.`
139
- : "Does not count as a training label."}
138
+ ? `Recorded as ${delegated.person ?? "the person"}'s own decision.`
139
+ : "Not recorded as a person's own decision."}
140
140
  </p>
141
141
  </section>
142
142
  );
@@ -12,10 +12,10 @@ import { formatSuggestionTime } from "./reference-cyclotron-suggestion";
12
12
 
13
13
  function MeasurementFigures({ measurement }: { measurement: AgreementStripMeasurement }) {
14
14
  const figures: Array<[string, string]> = [
15
- ["Agreement", formatPercentage(measurement.agreement)],
16
- ["Precision", formatPercentage(measurement.precision)],
17
- ["Recall", formatPercentage(measurement.recall)],
18
- ["Comparisons", String(measurement.comparisons)],
15
+ ["Matches editors", formatPercentage(measurement.agreement)],
16
+ ["Suggested includes editors kept", formatPercentage(measurement.precision)],
17
+ ["Editor includes suggested", formatPercentage(measurement.recall)],
18
+ ["Decisions compared", String(measurement.comparisons)],
19
19
  ];
20
20
  return (
21
21
  <dl className="flex flex-wrap gap-x-6 gap-y-1">
@@ -30,19 +30,19 @@ function MeasurementFigures({ measurement }: { measurement: AgreementStripMeasur
30
30
  }
31
31
 
32
32
  /**
33
- * Live agreement at the top of References: how often the cyclotron's
33
+ * Live agreement at the top of References: how often the
34
34
  * suggestions matched what editors then decided. Hidden without a payload.
35
35
  */
36
36
  export function ReferenceLiveAgreement({ agreement }: { agreement: ShadowAgreement | null }) {
37
37
  const state = agreementStripState(agreement);
38
38
  if (state.kind === "hidden") return null;
39
39
  return (
40
- <section aria-label="Live agreement" className="shrink-0 space-y-2 border-y border-foreground py-3" data-reference-live-agreement={state.kind}>
41
- <h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">Live agreement</h3>
40
+ <section aria-label="Suggestion accuracy" className="shrink-0 space-y-2 border-y border-foreground py-3" data-reference-live-agreement={state.kind}>
41
+ <h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">Suggestion accuracy</h3>
42
42
  {state.loop ? (
43
43
  <p className="text-sm text-foreground" data-reference-live-agreement-loop>
44
44
  <span className="font-semibold">{loopStateWords(state.loop)}</span>
45
- {" · "}Last sweep {formatSuggestionTime(state.loop.lastSweepAt)}
45
+ {" · "}Last checked {formatSuggestionTime(state.loop.lastSweepAt)}
46
46
  {" · "}{dailyCapWords(state.loop)}
47
47
  </p>
48
48
  ) : null}
@@ -51,11 +51,11 @@ export function ReferenceLiveAgreement({ agreement }: { agreement: ShadowAgreeme
51
51
  ) : null}
52
52
  {state.kind === "not_enough" ? (
53
53
  <p className="text-sm text-foreground" data-reference-live-agreement-not-enough>
54
- Not enough comparisons yet: {state.measurement.comparisons} of {state.needed} editor decisions have followed a suggestion. Figures appear at {state.needed}.
54
+ Not enough decisions yet: {state.measurement.comparisons} of {state.needed} editor decisions have followed a suggestion. Figures appear at {state.needed}.
55
55
  </p>
56
56
  ) : <MeasurementFigures measurement={state.measurement} />}
57
57
  <p className="text-xs text-foreground">
58
- Suggestions compared with the decisions editors made afterwards. Computed {formatSuggestionTime(agreement?.computedAt ?? null)}.
58
+ Suggestions compared with the decisions editors made afterwards. Updated {formatSuggestionTime(agreement?.computedAt ?? null)}.
59
59
  </p>
60
60
  </section>
61
61
  );
@@ -10,7 +10,7 @@ export function ReferencePriming(props: PrimingPanelProps) {
10
10
  return (
11
11
  <section className="shrink-0 space-y-3" aria-label="Representative reference examples">
12
12
  <Button aria-expanded={open} onClick={() => setOpen((value) => !value)} variant="outline">
13
- {open ? "Hide example priming" : "Curate reference examples (optional)"}
13
+ {open ? "Hide example references" : "Add example references (optional)"}
14
14
  </Button>
15
15
  {open ? <div className="max-h-[55dvh] space-y-3 overflow-y-auto pr-1"><p className="text-sm text-muted-foreground">Corrections to extracted content: describe what needs fixing, then enter the corrected title and abstract or summary. The note is saved with your correction; it does not automatically regenerate the content. Choose Publish / Not publish separately. An explanation of that judgment is optional.</p><PrimingPanel {...props} renderItem={props.renderItem ?? ((item) => <div className="space-y-2"><p className="whitespace-pre-wrap text-sm">{String(item.values.abstract ?? item.values.text ?? "")}</p><p className="break-all text-xs text-muted-foreground">{String(item.values.source_uri ?? "")}</p></div>)} /></div> : null}
16
16
  </section>
@@ -67,7 +67,7 @@ export function ReferenceRelevanceReview({
67
67
  onChange={(event) => setShareable(event.target.checked)}
68
68
  type="checkbox"
69
69
  />
70
- My explanation may be quoted publicly (for the Cyclotron example page)
70
+ My explanation may be quoted publicly (on a public example page)
71
71
  </label>
72
72
  {error ? <p className="text-xs text-destructive" role="alert">{error}</p> : null}
73
73
  </section>