@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.
- package/app/globals.css +0 -175
- package/app/newsroom/[section]/[...selection]/page.tsx +0 -6
- package/app/newsroom/[section]/page.tsx +2 -4
- package/app/newsroom/articles/page.tsx +1 -2
- package/app/newsroom/sections/[sectionId]/page.tsx +2 -6
- package/bin/papyrus-infra.mjs +11 -2
- package/components/news-desk-page.tsx +3 -4
- package/components/newsroom-ops-shell.tsx +142 -234
- package/components/reference-cyclotron-priming.tsx +12 -13
- package/components/reference-cyclotron-status.tsx +4 -4
- package/components/reference-cyclotron-suggestion.tsx +6 -6
- package/components/reference-live-agreement.tsx +10 -10
- package/components/reference-priming.tsx +1 -1
- package/components/reference-relevance-review.tsx +1 -1
- package/components/reference-section-suggestion.tsx +1 -1
- package/components/topic-steering-workspace.tsx +17 -510
- package/lib/cyclotron-suggestions.ts +9 -9
- package/lib/newsroom-list-selection.ts +0 -3
- package/lib/newsroom-nav.ts +5 -8
- package/lib/newsroom-section-routing.ts +2 -4
- package/lib/relevance-status.ts +4 -4
- package/lib/site-brand.ts +1 -8
- package/package.json +2 -3
- package/routes.manifest.json +1 -1
- package/src/cdk-environment.mjs +44 -0
- package/components/newsroom-organizer-shell.tsx +0 -153
|
@@ -1,41 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
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 {
|
|
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:
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
>
|
|
116
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
|
10
|
-
*
|
|
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("
|
|
27
|
+
setMessage("Adding…");
|
|
29
28
|
try {
|
|
30
29
|
await onRequestPriming({ url, label, explanation });
|
|
31
30
|
setUrl("");
|
|
32
31
|
setExplanation("");
|
|
33
|
-
setMessage("
|
|
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="
|
|
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">
|
|
48
|
+
<span className="text-xs text-muted-foreground">Add a reference by URL</span>
|
|
50
49
|
<input
|
|
51
|
-
aria-label="
|
|
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">
|
|
61
|
-
<select aria-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="
|
|
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">
|
|
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="
|
|
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
|
|
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="
|
|
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
|
-
|
|
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
|
|
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>
|
|
105
|
-
<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
|
|
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
|
-
|
|
119
|
+
Recorded as an editor’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
|
-
? `
|
|
139
|
-
: "
|
|
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
|
-
["
|
|
16
|
-
["
|
|
17
|
-
["
|
|
18
|
-
["
|
|
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
|
|
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="
|
|
41
|
-
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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 (
|
|
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>
|