@anthusai/papyrus 5.33.0 → 5.33.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/amplify/data/function-handler.js +20 -0
- package/amplify/data/function-handler.ts +40 -0
- package/amplify/data/resource.js +62 -60
- package/amplify/data/resource.ts +62 -60
- package/amplify/data/schema.js +57 -56
- package/amplify/data/schema.ts +57 -56
- package/amplify/functions/automation-view/schema.js +3 -2
- package/amplify/functions/automation-view/schema.ts +3 -2
- package/amplify/functions/editorial-checks/schema.js +9 -8
- package/amplify/functions/editorial-checks/schema.ts +9 -8
- package/amplify/functions/monitoring-view/schema.js +2 -1
- package/amplify/functions/monitoring-view/schema.ts +2 -1
- package/amplify/plugins/newsletter/schema.js +2 -1
- package/amplify/plugins/newsletter/schema.ts +2 -1
- package/amplify/plugins/reader-steering/schema.js +4 -3
- package/amplify/plugins/reader-steering/schema.ts +4 -3
- package/amplify/plugins/signup/schema.js +2 -1
- package/amplify/plugins/signup/schema.ts +2 -1
- package/components/news-desk-taxonomy-client.ts +24 -1
- package/components/newsroom-references-view.tsx +179 -36
- package/components/reference-cyclotron-suggestion.tsx +9 -5
- package/components/reference-relevance-review.tsx +3 -3
- package/components/topic-steering-workspace.tsx +143 -121
- package/lib/cyclotron-suggestions.ts +4 -4
- package/lib/reference-review-details.ts +71 -0
- package/lib/reference-review-request.ts +14 -0
- package/lib/relevance-decisions.ts +42 -10
- package/lib/use-reference-review-data.ts +44 -0
- package/package.json +4 -1
- package/routes.manifest.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { monitoringView } from "./resource";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler";
|
|
3
4
|
|
|
4
5
|
const editors = ["editor", "admin"];
|
|
5
6
|
|
|
@@ -14,5 +15,5 @@ export const monitoringViewSchemaDefinitions = {
|
|
|
14
15
|
.arguments({ scope: a.string() })
|
|
15
16
|
.returns(a.json())
|
|
16
17
|
.authorization((allow) => [allow.groups(editors)])
|
|
17
|
-
.handler(
|
|
18
|
+
.handler(functionHandler("monitoringView", monitoringView)),
|
|
18
19
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { newsletterOps } from "./ops/resource.js";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler.js";
|
|
3
4
|
const staff = ["editor", "admin"];
|
|
4
5
|
const admins = ["admin"];
|
|
5
6
|
/** The newsroom's newsletter operations, all JSON in and out. The function checks the groups again from the identity claims. */
|
|
@@ -46,7 +47,7 @@ export const NEWSLETTER_OPERATION_GROUPS = {
|
|
|
46
47
|
* table, never readable through the content API. It adds fourteen operations for the newsroom's Newsletter panel.
|
|
47
48
|
*/
|
|
48
49
|
export function newsletterSchemaDefinitions() {
|
|
49
|
-
const handler =
|
|
50
|
+
const handler = functionHandler("newsletterOps", newsletterOps);
|
|
50
51
|
const query = (name) => a.query().arguments({ input: a.json() }).returns(a.json()).authorization((allow) => [allow.groups(NEWSLETTER_OPERATION_GROUPS[name])]).handler(handler);
|
|
51
52
|
const mutation = (name) => a.mutation().arguments({ input: a.json() }).returns(a.json()).authorization((allow) => [allow.groups(NEWSLETTER_OPERATION_GROUPS[name])]).handler(handler);
|
|
52
53
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { newsletterOps } from "./ops/resource";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler";
|
|
3
4
|
|
|
4
5
|
const staff = ["editor", "admin"];
|
|
5
6
|
const admins = ["admin"];
|
|
@@ -49,7 +50,7 @@ export const NEWSLETTER_OPERATION_GROUPS: Record<string, string[]> = {
|
|
|
49
50
|
* table, never readable through the content API. It adds fourteen operations for the newsroom's Newsletter panel.
|
|
50
51
|
*/
|
|
51
52
|
export function newsletterSchemaDefinitions(): Record<string, unknown> {
|
|
52
|
-
const handler =
|
|
53
|
+
const handler = functionHandler("newsletterOps", newsletterOps);
|
|
53
54
|
const query = (name: string) =>
|
|
54
55
|
a.query().arguments({ input: a.json() }).returns(a.json()).authorization((allow) => [allow.groups(NEWSLETTER_OPERATION_GROUPS[name])]).handler(handler);
|
|
55
56
|
const mutation = (name: string) =>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { readerActions } from "./function/resource.js";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler.js";
|
|
3
4
|
/**
|
|
4
5
|
* Staff and IAM only: no guest, API key or reader rule on any model. The reader-actions function writes the
|
|
5
6
|
* tables directly with its own role, and editors may list them; admins may delete. `id` is the lookup key:
|
|
@@ -170,7 +171,7 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
170
171
|
})
|
|
171
172
|
.returns(a.ref("ProposalReceipt"))
|
|
172
173
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
173
|
-
.handler(
|
|
174
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
174
175
|
transitionProposal: a
|
|
175
176
|
.mutation()
|
|
176
177
|
.arguments({
|
|
@@ -181,7 +182,7 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
181
182
|
})
|
|
182
183
|
.returns(a.ref("ProposalReceipt"))
|
|
183
184
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
184
|
-
.handler(
|
|
185
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
185
186
|
ModerationReceipt: a.customType({
|
|
186
187
|
status: a.string().required(),
|
|
187
188
|
id: a.string(),
|
|
@@ -199,6 +200,6 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
199
200
|
})
|
|
200
201
|
.returns(a.ref("ModerationReceipt"))
|
|
201
202
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
202
|
-
.handler(
|
|
203
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
203
204
|
};
|
|
204
205
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { readerActions } from "./function/resource";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Staff and IAM only: no guest, API key or reader rule on any model. The reader-actions function writes the
|
|
@@ -172,7 +173,7 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
172
173
|
})
|
|
173
174
|
.returns(a.ref("ProposalReceipt"))
|
|
174
175
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
175
|
-
.handler(
|
|
176
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
176
177
|
transitionProposal: a
|
|
177
178
|
.mutation()
|
|
178
179
|
.arguments({
|
|
@@ -183,7 +184,7 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
183
184
|
})
|
|
184
185
|
.returns(a.ref("ProposalReceipt"))
|
|
185
186
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
186
|
-
.handler(
|
|
187
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
187
188
|
ModerationReceipt: a.customType({
|
|
188
189
|
status: a.string().required(),
|
|
189
190
|
id: a.string(),
|
|
@@ -201,6 +202,6 @@ export function readerSteeringSchemaDefinitions() {
|
|
|
201
202
|
})
|
|
202
203
|
.returns(a.ref("ModerationReceipt"))
|
|
203
204
|
.authorization((allow) => [allow.group("editor"), allow.group("admin")])
|
|
204
|
-
.handler(
|
|
205
|
+
.handler(functionHandler("readerActions", readerActions)),
|
|
205
206
|
};
|
|
206
207
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { signupSubmit } from "./function/resource.js";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler.js";
|
|
3
4
|
/**
|
|
4
5
|
* SignupEntry is never guest-readable and has no create rule for anyone: only the
|
|
5
6
|
* submitSignup function (IAM) writes it. Editors and admins list it; admins delete.
|
|
@@ -35,6 +36,6 @@ export function signupSchemaDefinitions() {
|
|
|
35
36
|
})
|
|
36
37
|
.returns(a.ref("SignupReceipt"))
|
|
37
38
|
.authorization((allow) => [allow.guest()])
|
|
38
|
-
.handler(
|
|
39
|
+
.handler(functionHandler("signupSubmit", signupSubmit)),
|
|
39
40
|
};
|
|
40
41
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a } from "@aws-amplify/backend";
|
|
2
2
|
import { signupSubmit } from "./function/resource";
|
|
3
|
+
import { functionHandler } from "../../data/function-handler";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* SignupEntry is never guest-readable and has no create rule for anyone: only the
|
|
@@ -36,6 +37,6 @@ export function signupSchemaDefinitions() {
|
|
|
36
37
|
})
|
|
37
38
|
.returns(a.ref("SignupReceipt"))
|
|
38
39
|
.authorization((allow) => [allow.guest()])
|
|
39
|
-
.handler(
|
|
40
|
+
.handler(functionHandler("signupSubmit", signupSubmit)),
|
|
40
41
|
};
|
|
41
42
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { loadReferenceReviewDetails } from "../lib/reference-review-details";
|
|
4
|
+
|
|
3
5
|
import { isEditorialWorkAssignment } from "../lib/newsroom-assignments";
|
|
4
6
|
import { isLocalPreviewEnabled } from "../lib/local-preview";
|
|
5
7
|
import { createLocalPreviewRealPublishedVersions, createLocalPreviewAssignments, createLocalPreviewContentItemVersions, createLocalPreviewReferences } from "../lib/local-preview-seed";
|
|
@@ -1852,9 +1854,29 @@ export async function loadEditorSemanticRelationsData(): Promise<SemanticRelatio
|
|
|
1852
1854
|
pageCount += 1;
|
|
1853
1855
|
} while (nextToken && pageCount < 40);
|
|
1854
1856
|
|
|
1857
|
+
if (nextToken) throw new Error("The activity feed is incomplete. Select a reference to load its prediction directly.");
|
|
1855
1858
|
return rows;
|
|
1856
1859
|
}
|
|
1857
1860
|
|
|
1861
|
+
/** Selected-reference details use indexes, not the bounded global activity feed. */
|
|
1862
|
+
export async function loadEditorReferenceReviewDetails(lineageId: string) {
|
|
1863
|
+
configureAmplifyClient();
|
|
1864
|
+
const testMock = getTestEditorNewsroomMock();
|
|
1865
|
+
return loadReferenceReviewDetails(lineageId, {
|
|
1866
|
+
relations: async (direction) => {
|
|
1867
|
+
if (testMock?.semanticRelations) return testMock.semanticRelations;
|
|
1868
|
+
return loadSemanticRelationsByState({
|
|
1869
|
+
field: direction === "outgoing" ? "listSemanticRelationsBySubjectState" : "listSemanticRelationsByObjectState",
|
|
1870
|
+
keyName: direction === "outgoing" ? "subjectStateKey" : "objectStateKey",
|
|
1871
|
+
keyValue: `reference#${lineageId}#current`,
|
|
1872
|
+
query: direction === "outgoing" ? LIST_SEMANTIC_RELATIONS_BY_SUBJECT_STATE_QUERY : LIST_SEMANTIC_RELATIONS_BY_OBJECT_STATE_QUERY,
|
|
1873
|
+
});
|
|
1874
|
+
},
|
|
1875
|
+
message: async (id) => testMock?.messages ? testMock.messages.find((message) => message.id === id) ?? null : getMessageRecordById(id),
|
|
1876
|
+
payloads: (id) => loadModelPayloadsForOwner("message", id, ["metadata"]),
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1858
1880
|
export async function loadNewsroomSemanticRelationPage(options: NewsroomSemanticRelationPageOptions = {}): Promise<NewsroomRecordPage<SemanticRelationRecord>> {
|
|
1859
1881
|
return loadNewsroomFeedPage<SemanticRelationRecord>({
|
|
1860
1882
|
query: NEWSROOM_SEMANTIC_RELATION_FEED_QUERY,
|
|
@@ -3134,7 +3156,7 @@ async function loadSemanticRelationsByState({
|
|
|
3134
3156
|
});
|
|
3135
3157
|
assertNoGraphQLErrors(response.errors);
|
|
3136
3158
|
const connection = response.data?.[field];
|
|
3137
|
-
if (!connection)
|
|
3159
|
+
if (!connection) throw new Error(`Missing GraphQL connection payload for ${field}.`);
|
|
3138
3160
|
for (const item of (connection.items ?? []).filter(Boolean) as SemanticRelationRecord[]) {
|
|
3139
3161
|
if (!item.id || seenIds.has(item.id)) continue;
|
|
3140
3162
|
seenIds.add(item.id);
|
|
@@ -3142,6 +3164,7 @@ async function loadSemanticRelationsByState({
|
|
|
3142
3164
|
}
|
|
3143
3165
|
nextToken = connection.nextToken ?? null;
|
|
3144
3166
|
} while (nextToken && pageCount < 200);
|
|
3167
|
+
if (nextToken) throw new Error("Reference details are incomplete. Try again before reviewing its prediction.");
|
|
3145
3168
|
return rows;
|
|
3146
3169
|
}
|
|
3147
3170
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ThumbsUpIcon,
|
|
14
14
|
} from "lucide-react";
|
|
15
15
|
import { usePathname } from "next/navigation";
|
|
16
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
16
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
17
17
|
import { Badge } from "./ui/badge";
|
|
18
18
|
import { Button } from "./ui/button";
|
|
19
19
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./ui/card";
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import { Tabs, TabsList, TabsTrigger } from "./ui/tabs";
|
|
29
29
|
import type { ReferenceAttachmentRecord, ReferenceRecord } from "../lib/category-repository";
|
|
30
30
|
import {
|
|
31
|
+
buildReferencesIndexQuery,
|
|
31
32
|
parseReferenceLineageIdFromNewsroomPathname,
|
|
32
33
|
syncBrowserNewsroomIndexUrl,
|
|
33
34
|
} from "../lib/newsroom-index-filters";
|
|
@@ -45,7 +46,7 @@ import {
|
|
|
45
46
|
type ReferenceCurationAction,
|
|
46
47
|
type ReferenceStatusFilter,
|
|
47
48
|
} from "../lib/newsroom-references";
|
|
48
|
-
import { normalizeReferenceCurationStatus } from "../lib/reference-policy";
|
|
49
|
+
import { normalizeReferenceCurationStatus, referenceReasonCode, REFERENCE_REJECTION_REASON_CODES, type ReferenceRejectionReasonCode } from "../lib/reference-policy";
|
|
49
50
|
import { newsroomListRowClassName } from "../lib/newsroom-list-selection";
|
|
50
51
|
import { ReferenceSourcePreview } from "./reference-source-preview";
|
|
51
52
|
import { ReferenceRelevanceReview } from "./reference-relevance-review";
|
|
@@ -61,7 +62,14 @@ import { SectionPicker, SectionSuggestionBlock, type SectionChoice } from "./ref
|
|
|
61
62
|
import type { SectionSuggestion, SiteSectionAgreement } from "../lib/site-section-suggestions";
|
|
62
63
|
|
|
63
64
|
/** What an editor adds to an accept: the Section the reference belongs in, which becomes a training label. */
|
|
64
|
-
export type ReferenceReviewOptions = {
|
|
65
|
+
export type ReferenceReviewOptions = {
|
|
66
|
+
sectionId?: string | null;
|
|
67
|
+
note?: string;
|
|
68
|
+
reasonCode?: ReferenceRejectionReasonCode | null;
|
|
69
|
+
decisionRelationId?: string;
|
|
70
|
+
shareable?: boolean;
|
|
71
|
+
};
|
|
72
|
+
type PredictionState = "loading" | "ready" | "error";
|
|
65
73
|
import type { DelegatedCuration, ShadowAgreement } from "../lib/cyclotron-suggestions";
|
|
66
74
|
import type { PrimingFormInput } from "./reference-cyclotron-priming";
|
|
67
75
|
import { ReferenceCyclotronStatus, type ReviewRateChoice } from "./reference-cyclotron-status";
|
|
@@ -102,9 +110,14 @@ type NewsroomReferencesViewProps = {
|
|
|
102
110
|
sectionSuggestions?: Map<string, SectionSuggestion>;
|
|
103
111
|
/** How often the Section suggestions matched later editor decisions. */
|
|
104
112
|
sectionAgreement?: SiteSectionAgreement | null;
|
|
105
|
-
|
|
113
|
+
reviewReasons?: Map<string, ReferenceRejectionReasonCode>;
|
|
114
|
+
reviewSectionIds?: Map<string, string>;
|
|
115
|
+
predictionState?: PredictionState;
|
|
116
|
+
predictionError?: string | null;
|
|
117
|
+
onRetryPredictions?: () => void;
|
|
118
|
+
onRelevanceReview?: (reference: ReferenceRecord, curation: RelevanceCuration) => Promise<void> | void;
|
|
106
119
|
initialReferenceLineageId?: string | null;
|
|
107
|
-
onReview: (reference: ReferenceRecord, action: ReferenceCurationAction, options?: ReferenceReviewOptions) => void;
|
|
120
|
+
onReview: (reference: ReferenceRecord, action: ReferenceCurationAction, options?: ReferenceReviewOptions) => Promise<void> | void;
|
|
108
121
|
referenceAttachments?: ReferenceAttachmentRecord[];
|
|
109
122
|
references: ReferenceRecord[];
|
|
110
123
|
};
|
|
@@ -251,6 +264,9 @@ function ReferenceDetailPanel({
|
|
|
251
264
|
disabled,
|
|
252
265
|
onRelevanceReview,
|
|
253
266
|
onReview,
|
|
267
|
+
predictionState = "ready",
|
|
268
|
+
reviewReason,
|
|
269
|
+
reviewSectionId,
|
|
254
270
|
previewAttachments,
|
|
255
271
|
reference,
|
|
256
272
|
onClose,
|
|
@@ -263,8 +279,11 @@ function ReferenceDetailPanel({
|
|
|
263
279
|
decision?: RelevanceDecisionView;
|
|
264
280
|
demo?: boolean;
|
|
265
281
|
disabled?: boolean;
|
|
266
|
-
onRelevanceReview?: (curation: RelevanceCuration) => void;
|
|
267
|
-
onReview: (action: ReferenceCurationAction, options?: ReferenceReviewOptions) => void;
|
|
282
|
+
onRelevanceReview?: (curation: RelevanceCuration) => Promise<void> | void;
|
|
283
|
+
onReview: (action: ReferenceCurationAction, options?: ReferenceReviewOptions) => Promise<void> | void;
|
|
284
|
+
predictionState?: PredictionState;
|
|
285
|
+
reviewReason?: ReferenceRejectionReasonCode;
|
|
286
|
+
reviewSectionId?: string;
|
|
268
287
|
sectionAgreement?: SiteSectionAgreement | null;
|
|
269
288
|
sectionSuggestion?: SectionSuggestion;
|
|
270
289
|
sections?: SectionChoice[];
|
|
@@ -273,13 +292,77 @@ function ReferenceDetailPanel({
|
|
|
273
292
|
onClose?: () => void;
|
|
274
293
|
}) {
|
|
275
294
|
const lineageId = referenceLineageId(reference);
|
|
276
|
-
const
|
|
277
|
-
|
|
295
|
+
const sourceNote = normalizeReferenceCurationStatus(reference.curationStatus) === "pending" ? "" : reference.curationStatusReason ?? "";
|
|
296
|
+
const sourceReason = reviewReason ?? referenceReasonCode(reference) ?? "";
|
|
297
|
+
const [note, setNote] = useState(sourceNote);
|
|
298
|
+
const [reasonCode, setReasonCode] = useState<ReferenceRejectionReasonCode | "">(sourceReason);
|
|
299
|
+
const [savedNote, setSavedNote] = useState(sourceNote);
|
|
300
|
+
const [savedReason, setSavedReason] = useState<ReferenceRejectionReasonCode | "">(sourceReason);
|
|
301
|
+
const [busy, setBusy] = useState(false);
|
|
302
|
+
const [reviewError, setReviewError] = useState<string | null>(null);
|
|
303
|
+
const [saved, setSaved] = useState(false);
|
|
304
|
+
const saving = useRef(false);
|
|
305
|
+
const noteEdited = useRef(false);
|
|
306
|
+
const reasonEdited = useRef(false);
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
setSavedNote(sourceNote);
|
|
309
|
+
if (!noteEdited.current) setNote(sourceNote);
|
|
310
|
+
}, [sourceNote]);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
setSavedReason(sourceReason);
|
|
313
|
+
if (!reasonEdited.current) setReasonCode(sourceReason);
|
|
314
|
+
}, [sourceReason]);
|
|
315
|
+
const [chosenSectionId, setChosenSectionId] = useState<string | null>(reviewSectionId ?? null);
|
|
316
|
+
const [savedSectionId, setSavedSectionId] = useState<string | null>(reviewSectionId ?? null);
|
|
317
|
+
const sectionEdited = useRef(false);
|
|
318
|
+
useEffect(() => {
|
|
319
|
+
setSavedSectionId(reviewSectionId ?? null);
|
|
320
|
+
if (!sectionEdited.current) setChosenSectionId(reviewSectionId ?? null);
|
|
321
|
+
}, [reviewSectionId]);
|
|
278
322
|
const status = normalizeReferenceCurationStatus(reference.curationStatus);
|
|
279
323
|
const url = referenceUrl(reference);
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
const
|
|
324
|
+
const locked = disabled || busy;
|
|
325
|
+
const acceptDisabled = locked || status === "accepted";
|
|
326
|
+
const rejectDisabled = locked || status === "rejected";
|
|
327
|
+
const archiveDisabled = locked || status === "archived";
|
|
328
|
+
|
|
329
|
+
async function save(action: ReferenceCurationAction, review?: RelevanceCuration) {
|
|
330
|
+
if (disabled || saving.current) return;
|
|
331
|
+
const rejectionReason = review?.reasonCode ?? reasonCode;
|
|
332
|
+
if (action === "reject" && !rejectionReason) {
|
|
333
|
+
setReviewError("Choose a rejection reason before saving. An explanation is optional.");
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
saving.current = true;
|
|
337
|
+
setBusy(true);
|
|
338
|
+
setSaved(false);
|
|
339
|
+
setReviewError(null);
|
|
340
|
+
try {
|
|
341
|
+
if (review && onRelevanceReview) await onRelevanceReview({ ...review, ...(action === "accept" && chosenSectionId ? { sectionId: chosenSectionId } : {}) });
|
|
342
|
+
else await onReview(action, {
|
|
343
|
+
note: note.trim(),
|
|
344
|
+
reasonCode: action === "reject" ? reasonCode || null : null,
|
|
345
|
+
...(action === "accept" && chosenSectionId ? { sectionId: chosenSectionId } : {}),
|
|
346
|
+
...(decision ? { decisionRelationId: decision.decisionRelationId, shareable: false } : {}),
|
|
347
|
+
});
|
|
348
|
+
if (review) {
|
|
349
|
+
setNote(review.note ?? "");
|
|
350
|
+
setReasonCode((review.reasonCode as ReferenceRejectionReasonCode) ?? "");
|
|
351
|
+
}
|
|
352
|
+
setSavedNote(review ? review.note ?? "" : note.trim());
|
|
353
|
+
setSavedReason(action === "reject" ? rejectionReason as ReferenceRejectionReasonCode : "");
|
|
354
|
+
setSavedSectionId(action === "accept" ? chosenSectionId : null);
|
|
355
|
+
noteEdited.current = false;
|
|
356
|
+
reasonEdited.current = false;
|
|
357
|
+
sectionEdited.current = false;
|
|
358
|
+
setSaved(true);
|
|
359
|
+
} catch (error) {
|
|
360
|
+
setReviewError(error instanceof Error ? error.message : "Review could not be saved. Try again.");
|
|
361
|
+
} finally {
|
|
362
|
+
saving.current = false;
|
|
363
|
+
setBusy(false);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
283
366
|
|
|
284
367
|
return (
|
|
285
368
|
<div
|
|
@@ -304,8 +387,8 @@ function ReferenceDetailPanel({
|
|
|
304
387
|
<div className="space-y-3" data-reference-relevance-decision={lineageId}>
|
|
305
388
|
<ReferenceSuggestionBlock
|
|
306
389
|
decision={decision}
|
|
307
|
-
disabled={
|
|
308
|
-
onCurate={onRelevanceReview}
|
|
390
|
+
disabled={locked}
|
|
391
|
+
onCurate={onRelevanceReview ? (review) => { void save(review.action, { ...review, note: note.trim() || null, reasonCode: review.action === "reject" ? reasonCode || null : null }); } : undefined}
|
|
309
392
|
referenceLineageId={lineageId}
|
|
310
393
|
settled={status !== "pending"}
|
|
311
394
|
statusLabel={referenceStatusLabel(status)}
|
|
@@ -317,31 +400,54 @@ function ReferenceDetailPanel({
|
|
|
317
400
|
<div className="mt-2">
|
|
318
401
|
<ReferenceRelevanceReview
|
|
319
402
|
decision={decision}
|
|
320
|
-
disabled={
|
|
321
|
-
onCurate={
|
|
403
|
+
disabled={locked}
|
|
404
|
+
onCurate={(review) => save(review.action, review)}
|
|
322
405
|
referenceLineageId={lineageId}
|
|
323
406
|
/>
|
|
324
407
|
</div>
|
|
325
408
|
</details>
|
|
326
409
|
) : null}
|
|
327
410
|
</div>
|
|
411
|
+
) : predictionState === "ready" ? (
|
|
412
|
+
<section aria-label="Publication prediction" className="space-y-1 rounded-md border p-3">
|
|
413
|
+
<h3 className="text-sm font-semibold">No prediction recorded</h3>
|
|
414
|
+
<p className="text-sm text-muted-foreground">No publication relevance prediction was returned for this reference. You can still review it. Pending is its editorial status, not a prediction status.</p>
|
|
415
|
+
</section>
|
|
328
416
|
) : null}
|
|
329
|
-
{status === "pending" &&
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
417
|
+
{sectionSuggestion || ((status === "pending" || status === "accepted") && sections.length) ? (
|
|
418
|
+
<details className="rounded-md border p-3 text-sm">
|
|
419
|
+
<summary className="cursor-pointer font-semibold">Section placement (optional)</summary>
|
|
420
|
+
<div className="mt-3 space-y-3">
|
|
421
|
+
{sectionSuggestion ? <SectionSuggestionBlock agreement={sectionAgreement} referenceLineageId={lineageId} sections={sections} suggestion={sectionSuggestion} /> : null}
|
|
422
|
+
{(status === "pending" || status === "accepted") && sections.length ? <SectionPicker
|
|
334
423
|
agreement={sectionAgreement}
|
|
335
424
|
chosenSectionId={chosenSectionId}
|
|
336
|
-
disabled={
|
|
337
|
-
onChoose={setChosenSectionId}
|
|
425
|
+
disabled={locked}
|
|
426
|
+
onChoose={(sectionId) => { setChosenSectionId(sectionId); sectionEdited.current = true; setSaved(false); }}
|
|
338
427
|
referenceLineageId={lineageId}
|
|
339
428
|
sections={sections}
|
|
340
429
|
suggestedSectionId={sectionSuggestion?.sectionId ?? null}
|
|
341
|
-
|
|
430
|
+
/> : null}
|
|
431
|
+
</div>
|
|
432
|
+
</details>
|
|
342
433
|
) : null}
|
|
343
434
|
{delegated ? <DelegatedCurationNote delegated={delegated} referenceLineageId={lineageId} /> : countsAsTrainingLabel ? <CountsAsTrainingLabelNote referenceLineageId={lineageId} /> : null}
|
|
344
435
|
|
|
436
|
+
<section aria-label="Editor feedback" className="space-y-3">
|
|
437
|
+
<h3 className="text-sm font-semibold">Editor feedback</h3>
|
|
438
|
+
{disabled ? <p className="text-sm text-muted-foreground">Editor access is required to change this reference.</p> : null}
|
|
439
|
+
<label className="block text-sm">
|
|
440
|
+
Review explanation (optional)
|
|
441
|
+
<textarea aria-label="Review explanation (optional)" className="mt-1 block min-h-20 w-full rounded-md border bg-background p-2" disabled={locked} value={note} onChange={(event) => { setNote(event.target.value); noteEdited.current = true; setSaved(false); }} />
|
|
442
|
+
</label>
|
|
443
|
+
<label className="block text-sm">
|
|
444
|
+
Rejection reason
|
|
445
|
+
<select aria-label="Rejection reason" className="mt-1 block w-full rounded-md border bg-background p-2" disabled={locked} value={reasonCode} onChange={(event) => { setReasonCode(event.target.value as ReferenceRejectionReasonCode | ""); reasonEdited.current = true; setSaved(false); }}>
|
|
446
|
+
<option value="">Choose a reason when rejecting</option>
|
|
447
|
+
{REFERENCE_REJECTION_REASON_CODES.map((code) => <option key={code} value={code}>{code.charAt(0).toUpperCase() + code.slice(1).replaceAll("_", " ")}</option>)}
|
|
448
|
+
</select>
|
|
449
|
+
</label>
|
|
450
|
+
<p className="text-xs text-muted-foreground">Only out of scope and policy exclusion are negative relevance labels. Other rejection reasons do not teach relevance.</p>
|
|
345
451
|
<div
|
|
346
452
|
className="flex flex-wrap items-center gap-2"
|
|
347
453
|
data-news-desk-reference-curation-cluster
|
|
@@ -352,7 +458,7 @@ function ReferenceDetailPanel({
|
|
|
352
458
|
aria-pressed={status === "accepted"}
|
|
353
459
|
data-news-desk-reference-accept
|
|
354
460
|
disabled={acceptDisabled}
|
|
355
|
-
onClick={() =>
|
|
461
|
+
onClick={() => { void save("accept"); }}
|
|
356
462
|
size="sm"
|
|
357
463
|
type="button"
|
|
358
464
|
variant={status === "accepted" ? "default" : "outline"}
|
|
@@ -365,7 +471,7 @@ function ReferenceDetailPanel({
|
|
|
365
471
|
aria-pressed={status === "rejected"}
|
|
366
472
|
data-news-desk-reference-reject
|
|
367
473
|
disabled={rejectDisabled}
|
|
368
|
-
onClick={() =>
|
|
474
|
+
onClick={() => { void save("reject"); }}
|
|
369
475
|
size="sm"
|
|
370
476
|
type="button"
|
|
371
477
|
variant={status === "rejected" ? "destructive" : "outline"}
|
|
@@ -376,7 +482,7 @@ function ReferenceDetailPanel({
|
|
|
376
482
|
<Button
|
|
377
483
|
aria-label="Archive reference"
|
|
378
484
|
disabled={archiveDisabled}
|
|
379
|
-
onClick={() =>
|
|
485
|
+
onClick={() => { void save("archive"); }}
|
|
380
486
|
size="sm"
|
|
381
487
|
type="button"
|
|
382
488
|
variant="outline"
|
|
@@ -384,7 +490,14 @@ function ReferenceDetailPanel({
|
|
|
384
490
|
<ArchiveIcon className="size-4" />
|
|
385
491
|
Archive
|
|
386
492
|
</Button>
|
|
493
|
+
{status === "accepted" || status === "rejected" ? (
|
|
494
|
+
<Button disabled={locked || predictionState !== "ready" || (note.trim() === savedNote.trim() && (status !== "rejected" || reasonCode === savedReason) && (status !== "accepted" || chosenSectionId === savedSectionId))} onClick={() => { void save(status === "accepted" ? "accept" : "reject"); }} size="sm" type="button" variant="outline">Save feedback</Button>
|
|
495
|
+
) : null}
|
|
387
496
|
</div>
|
|
497
|
+
{status !== "pending" && predictionState !== "ready" ? <p className="text-sm text-muted-foreground">Load the review details before revising saved feedback.</p> : null}
|
|
498
|
+
{busy ? <p role="status" className="text-sm">Saving review…</p> : saved ? <p role="status" className="text-sm">Review saved.</p> : null}
|
|
499
|
+
{reviewError ? <p role="alert" className="text-sm text-destructive">{reviewError}</p> : null}
|
|
500
|
+
</section>
|
|
388
501
|
|
|
389
502
|
<Separator />
|
|
390
503
|
|
|
@@ -398,7 +511,7 @@ function ReferenceDetailPanel({
|
|
|
398
511
|
<dt className="text-xs font-medium uppercase tracking-wide text-muted-foreground">Why</dt>
|
|
399
512
|
<dd className="mt-1 text-foreground">
|
|
400
513
|
{reference.curationStatusReason?.trim()
|
|
401
|
-
|| "
|
|
514
|
+
|| "No explanation recorded."}
|
|
402
515
|
</dd>
|
|
403
516
|
</div>
|
|
404
517
|
{url ? (
|
|
@@ -476,6 +589,11 @@ export function NewsroomReferencesView({
|
|
|
476
589
|
demo = false,
|
|
477
590
|
disabled = false,
|
|
478
591
|
onRelevanceReview,
|
|
592
|
+
predictionState = "ready",
|
|
593
|
+
predictionError,
|
|
594
|
+
reviewReasons,
|
|
595
|
+
reviewSectionIds,
|
|
596
|
+
onRetryPredictions,
|
|
479
597
|
sections = [],
|
|
480
598
|
sectionSuggestions,
|
|
481
599
|
sectionAgreement = null,
|
|
@@ -492,7 +610,7 @@ export function NewsroomReferencesView({
|
|
|
492
610
|
() => parseReferenceLineageIdFromNewsroomPathname(pathname),
|
|
493
611
|
[pathname],
|
|
494
612
|
);
|
|
495
|
-
const routeLineageId =
|
|
613
|
+
const routeLineageId = pathname ? pathnameLineageId ?? "" : initialReferenceLineageId ?? "";
|
|
496
614
|
|
|
497
615
|
const canonicalReferences = useMemo(() => selectCanonicalReferenceRecords(references), [references]);
|
|
498
616
|
const statusCounts = useMemo(() => countReferencesByStatus(canonicalReferences), [canonicalReferences]);
|
|
@@ -531,17 +649,21 @@ export function NewsroomReferencesView({
|
|
|
531
649
|
|
|
532
650
|
const syncStatusUrl = useCallback((nextStatus: ReferenceListFilter) => {
|
|
533
651
|
if (demo) return;
|
|
534
|
-
|
|
652
|
+
const filters = {
|
|
535
653
|
status: nextStatus === "all" ? "" : nextStatus,
|
|
536
654
|
processing: "",
|
|
537
|
-
order: "published",
|
|
538
|
-
}
|
|
539
|
-
|
|
655
|
+
order: "published" as const,
|
|
656
|
+
};
|
|
657
|
+
if (selectedLineageId && typeof window !== "undefined") {
|
|
658
|
+
window.history.replaceState(null, "", `${buildReferenceDetailPath(selectedLineageId)}${buildReferencesIndexQuery(filters)}`);
|
|
659
|
+
} else {
|
|
660
|
+
syncBrowserNewsroomIndexUrl("references", filters, { replace: true });
|
|
661
|
+
}
|
|
662
|
+
}, [demo, selectedLineageId]);
|
|
540
663
|
|
|
541
664
|
useEffect(() => {
|
|
542
|
-
if (!routeLineageId) return;
|
|
543
665
|
setSelectedLineageId(routeLineageId);
|
|
544
|
-
if (isMobileDetail) setMobileDetailOpen(
|
|
666
|
+
if (isMobileDetail) setMobileDetailOpen(Boolean(routeLineageId));
|
|
545
667
|
}, [isMobileDetail, routeLineageId]);
|
|
546
668
|
|
|
547
669
|
useEffect(() => {
|
|
@@ -571,7 +693,7 @@ export function NewsroomReferencesView({
|
|
|
571
693
|
|
|
572
694
|
const runReview = (action: ReferenceCurationAction, options?: ReferenceReviewOptions) => {
|
|
573
695
|
if (!selectedReference) return;
|
|
574
|
-
onReview(selectedReference, action, options);
|
|
696
|
+
return onReview(selectedReference, action, options);
|
|
575
697
|
};
|
|
576
698
|
|
|
577
699
|
const emptyLabel = canonicalReferences.length
|
|
@@ -591,6 +713,17 @@ export function NewsroomReferencesView({
|
|
|
591
713
|
Review source intake before it becomes accepted evidence.
|
|
592
714
|
</p>
|
|
593
715
|
</div>
|
|
716
|
+
{predictionState === "loading" ? <p role="status">Loading predictions…</p> : null}
|
|
717
|
+
{predictionState === "error" ? (
|
|
718
|
+
<div role="alert" className="space-y-2 rounded-md border p-3">
|
|
719
|
+
<p>Predictions unavailable. {predictionError}</p>
|
|
720
|
+
<p className="text-sm">You can still review references. Existing suggestions may be out of date.</p>
|
|
721
|
+
{onRetryPredictions ? <Button onClick={onRetryPredictions} size="sm" type="button" variant="outline">Retry predictions</Button> : null}
|
|
722
|
+
</div>
|
|
723
|
+
) : null}
|
|
724
|
+
<details className="shrink-0 overflow-y-auto rounded-md border p-3 text-sm" style={{ maxHeight: "35dvh" }}>
|
|
725
|
+
<summary className="cursor-pointer font-semibold">Add a reference and prediction activity</summary>
|
|
726
|
+
<div className="mt-3 space-y-4">
|
|
594
727
|
<ReferenceLiveAgreement agreement={shadowAgreement} />
|
|
595
728
|
<ReferenceAddEntry
|
|
596
729
|
importOptions={disabled ? null : priming ?? sessionImport?.panel}
|
|
@@ -606,6 +739,8 @@ export function NewsroomReferencesView({
|
|
|
606
739
|
<ReferenceCyclotronStatus onRequestRate={disabled ? undefined : onRequestReviewRate} status={cyclotronStatus} />
|
|
607
740
|
</div>
|
|
608
741
|
) : null}
|
|
742
|
+
</div>
|
|
743
|
+
</details>
|
|
609
744
|
|
|
610
745
|
<Tabs
|
|
611
746
|
className="shrink-0"
|
|
@@ -717,6 +852,10 @@ export function NewsroomReferencesView({
|
|
|
717
852
|
<ScrollArea className="min-h-0 flex-1">
|
|
718
853
|
{selectedReference ? (
|
|
719
854
|
<ReferenceDetailPanel
|
|
855
|
+
key={referenceLineageId(selectedReference)}
|
|
856
|
+
predictionState={predictionState}
|
|
857
|
+
reviewReason={reviewReasons?.get(referenceLineageId(selectedReference))}
|
|
858
|
+
reviewSectionId={reviewSectionIds?.get(referenceLineageId(selectedReference))}
|
|
720
859
|
countsAsTrainingLabel={humanCuratedReferenceLineageIds?.has(referenceLineageId(selectedReference))}
|
|
721
860
|
delegated={delegatedCurations?.get(referenceLineageId(selectedReference))}
|
|
722
861
|
decision={decisions?.get(referenceLineageId(selectedReference))}
|
|
@@ -753,6 +892,10 @@ export function NewsroomReferencesView({
|
|
|
753
892
|
{selectedReference ? (
|
|
754
893
|
<ScrollArea className="max-h-[75dvh]">
|
|
755
894
|
<ReferenceDetailPanel
|
|
895
|
+
key={referenceLineageId(selectedReference)}
|
|
896
|
+
predictionState={predictionState}
|
|
897
|
+
reviewReason={reviewReasons?.get(referenceLineageId(selectedReference))}
|
|
898
|
+
reviewSectionId={reviewSectionIds?.get(referenceLineageId(selectedReference))}
|
|
756
899
|
countsAsTrainingLabel={humanCuratedReferenceLineageIds?.has(referenceLineageId(selectedReference))}
|
|
757
900
|
delegated={delegatedCurations?.get(referenceLineageId(selectedReference))}
|
|
758
901
|
decision={decisions?.get(referenceLineageId(selectedReference))}
|
|
@@ -57,11 +57,12 @@ export function ReferenceSuggestionBlock({
|
|
|
57
57
|
const choose = (choice: SuggestionChoice) => onCurate?.(curationForSuggestionChoice(decision, choice));
|
|
58
58
|
const suggestsAccept = decision.positiveLabel !== null && decision.label === decision.positiveLabel;
|
|
59
59
|
return (
|
|
60
|
-
<section aria-label="
|
|
61
|
-
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">
|
|
60
|
+
<section aria-label="Publication prediction" className="space-y-2 border-y border-foreground py-3" data-reference-suggestion={referenceLineageId}>
|
|
61
|
+
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">Publication prediction</h3>
|
|
62
62
|
<p className="text-sm text-foreground">
|
|
63
63
|
Papyrus suggests <span className="font-semibold">{decision.label}</span> ({suggestionConfidenceWords(decision)}).
|
|
64
64
|
</p>
|
|
65
|
+
{decision.reviewDetail ? <p className="text-xs text-foreground">Why review was requested: {decision.reviewDetail}</p> : null}
|
|
65
66
|
<p className="text-xs text-foreground" data-reference-suggestion-notice>
|
|
66
67
|
A suggestion never changes the status until an editor acts. This reference is {statusLabel.toLowerCase()}.
|
|
67
68
|
</p>
|
|
@@ -99,14 +100,17 @@ export function ReferenceSuggestionProvenance({ decision }: { decision: Relevanc
|
|
|
99
100
|
<summary className="cursor-pointer font-semibold underline-offset-4 hover:underline">How this suggestion was made</summary>
|
|
100
101
|
{summary ? (
|
|
101
102
|
<ul className="mt-2 space-y-1">
|
|
102
|
-
<li>{summary.teachingLabelsSentence}.</li>
|
|
103
|
-
<li>{summary.primingExamplesSentence}.</li>
|
|
103
|
+
{summary.teachingLabelsSentence ? <li>{summary.teachingLabelsSentence}.</li> : null}
|
|
104
|
+
{summary.primingExamplesSentence ? <li>{summary.primingExamplesSentence}.</li> : null}
|
|
105
|
+
{decision.provenance?.system ? <li>Source: {decision.provenance.system === "cyclotron-lab" ? "Shared publication classifier" : decision.provenance.system}.</li> : null}
|
|
106
|
+
{decision.provenance?.output ? <li>Publication output: {decision.provenance.output}.</li> : null}
|
|
107
|
+
{decision.classifierId ? <li>Classifier: {decision.classifierId}.</li> : null}
|
|
104
108
|
<li>Guidelines code {summary.doctrineShortHash ?? "not recorded"}.</li>
|
|
105
109
|
<li>Suggestion {summary.modelVersion ?? "revision not recorded"}.</li>
|
|
106
110
|
<li>Decided {formatSuggestionTime(summary.decidedAt)}.</li>
|
|
107
111
|
</ul>
|
|
108
112
|
) : (
|
|
109
|
-
<p className="mt-2">
|
|
113
|
+
<p className="mt-2">Additional provenance was not recorded for this prediction.</p>
|
|
110
114
|
)}
|
|
111
115
|
</details>
|
|
112
116
|
);
|