@anthusai/papyrus 1.19.1 → 2.0.0-next.10

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.
Files changed (80) hide show
  1. package/amplify/data/resource.js +7 -0
  2. package/amplify/data/resource.ts +8 -0
  3. package/amplify/data/schema.js +8 -0
  4. package/amplify/data/schema.ts +9 -0
  5. package/amplify/functions/assignment-action/data-access.js +88 -0
  6. package/amplify/functions/assignment-action/data-access.ts +87 -0
  7. package/amplify/functions/content-actions/handler.py +7 -0
  8. package/amplify/functions/model-attachment-upload/handler.ts +1 -0
  9. package/amplify/plugins/editorial-checks/function/handler.py +14 -0
  10. package/amplify/plugins/editorial-checks/function/requirements.txt +1 -0
  11. package/amplify/plugins/editorial-checks/function/resource.js +43 -0
  12. package/amplify/plugins/editorial-checks/function/resource.ts +60 -0
  13. package/amplify/plugins/editorial-checks/papyrus.plugin.js +71 -0
  14. package/amplify/plugins/editorial-checks/papyrus.plugin.ts +87 -0
  15. package/amplify/plugins/editorial-checks/schema.js +94 -0
  16. package/amplify/plugins/editorial-checks/schema.ts +96 -0
  17. package/amplify/plugins/registry.js +2 -0
  18. package/amplify/plugins/registry.ts +2 -0
  19. package/amplify/site-backend.js +5 -0
  20. package/amplify/site-backend.ts +11 -0
  21. package/app/globals.css +0 -175
  22. package/app/newsroom/[section]/[...selection]/page.tsx +0 -6
  23. package/app/newsroom/[section]/page.tsx +2 -4
  24. package/app/newsroom/articles/page.tsx +1 -2
  25. package/app/newsroom/sections/[sectionId]/page.tsx +2 -6
  26. package/bin/papyrus-infra.mjs +11 -2
  27. package/components/editorial-checks-admin-panel.tsx +337 -0
  28. package/components/editorial-finding-card.tsx +162 -0
  29. package/components/editorial-findings-panel.tsx +91 -0
  30. package/components/editorial-preview-popover.tsx +103 -0
  31. package/components/markus-body-editor.tsx +213 -0
  32. package/components/markus-ir-preview.tsx +147 -6
  33. package/components/news-desk-page.tsx +3 -4
  34. package/components/newsroom-article-editor.tsx +138 -11
  35. package/components/newsroom-board-view.tsx +6 -7
  36. package/components/newsroom-ops-shell.tsx +146 -234
  37. package/components/newsroom-organizer.css +57 -61
  38. package/components/newsroom-theme-fonts/broadsheet-green.css +10 -0
  39. package/components/newsroom-theme-fonts/broadsheet-green.tsx +6 -0
  40. package/components/newsroom-theme-fonts/newspaper-gothic.css +9 -0
  41. package/components/newsroom-theme-fonts/newspaper-gothic.tsx +6 -0
  42. package/components/newsroom-theme-fonts/night-desk.css +10 -0
  43. package/components/newsroom-theme-fonts/night-desk.tsx +6 -0
  44. package/components/newsroom-theme-fonts/refined-newsprint.css +11 -0
  45. package/components/newsroom-theme-fonts/refined-newsprint.tsx +6 -0
  46. package/components/newsroom-theme.css +39 -0
  47. package/components/newsroom-theme.tsx +33 -0
  48. package/components/reference-cyclotron-priming.tsx +12 -13
  49. package/components/reference-cyclotron-status.tsx +4 -4
  50. package/components/reference-cyclotron-suggestion.tsx +6 -6
  51. package/components/reference-live-agreement.tsx +10 -10
  52. package/components/reference-priming.tsx +1 -1
  53. package/components/reference-relevance-review.tsx +1 -1
  54. package/components/reference-section-suggestion.tsx +1 -1
  55. package/components/topic-steering-workspace.tsx +36 -511
  56. package/components/use-editorial-checks.ts +131 -0
  57. package/lib/cyclotron-suggestions.ts +9 -9
  58. package/lib/editorial-checks-backend.ts +16 -0
  59. package/lib/editorial-checks-client.ts +194 -0
  60. package/lib/editorial-checks-demo.ts +147 -0
  61. package/lib/editorial-checks-settings.ts +24 -0
  62. package/lib/editorial-checks.ts +178 -0
  63. package/lib/editorial-preview.ts +228 -0
  64. package/lib/newsroom-board.ts +27 -2
  65. package/lib/newsroom-list-selection.ts +0 -3
  66. package/lib/newsroom-nav.ts +5 -8
  67. package/lib/newsroom-section-routing.ts +2 -4
  68. package/lib/relevance-status.ts +4 -4
  69. package/lib/site-brand.ts +18 -8
  70. package/package.json +34 -3
  71. package/routes.manifest.json +1 -1
  72. package/src/cdk-environment.mjs +44 -0
  73. package/components/newsroom-fonts/playfair-display-700.ttf +0 -0
  74. package/components/newsroom-fonts/playfair-display-900.ttf +0 -0
  75. package/components/newsroom-fonts/playfair-display-OFL.txt +0 -93
  76. package/components/newsroom-fonts/plus-jakarta-sans-400.ttf +0 -0
  77. package/components/newsroom-fonts/plus-jakarta-sans-600.ttf +0 -0
  78. package/components/newsroom-fonts/plus-jakarta-sans-OFL.txt +0 -93
  79. package/components/newsroom-newsprint-board.css +0 -7
  80. package/components/newsroom-organizer-shell.tsx +0 -153
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Editorial checks: the Limatus result shapes the newsroom uses, and pure helpers
3
+ * over them. Limatus counts offsets in UTF-16 code units, which is exactly how
4
+ * JavaScript indexes strings, so spans apply to the body text as they are.
5
+ */
6
+ import { pluginSettings, type PluginOutputs } from "./plugin-settings";
7
+
8
+ export const EDITORIAL_CHECKS_PLUGIN = "editorial-checks";
9
+
10
+ export type Span = { start: number; end: number };
11
+ export type Severity = "info" | "warn" | "error";
12
+
13
+ export type EditorialFinding = {
14
+ id: string;
15
+ policyId: string;
16
+ policyVersion: number;
17
+ detectorId: string;
18
+ lane: "rules" | "classifier";
19
+ severity: Severity;
20
+ status: "violation" | "review";
21
+ segmentId: string;
22
+ span: Span;
23
+ excerpt: string;
24
+ /** The excerpt as a reader sees it (inline markup removed). */
25
+ excerptText?: string;
26
+ message: string;
27
+ probability?: number;
28
+ rawProbability?: number;
29
+ replacement?: string;
30
+ };
31
+
32
+ export type EditorialSegment = {
33
+ id: string;
34
+ kind: "document" | "paragraph" | "sentence";
35
+ block?: "paragraph" | "heading" | "listItem";
36
+ parentId?: string;
37
+ start: number;
38
+ end: number;
39
+ textHash: string;
40
+ /** Plain prose of a paragraph or sentence segment. */
41
+ text?: string;
42
+ };
43
+
44
+ export type LaneStatus = { status: "ran" | "disabled" | "unavailable" | "failed" | "partial"; reason?: string; detectors?: number };
45
+
46
+ export type EditorialCheckResult = {
47
+ schemaVersion: 1;
48
+ offsetUnit: "utf16";
49
+ document: { hash: string; length: number };
50
+ pack: { packId: string; version: string };
51
+ segments: EditorialSegment[];
52
+ protected: { kind: string; start: number; end: number }[];
53
+ findings: EditorialFinding[];
54
+ coverage: unknown[];
55
+ lanes: { rules: LaneStatus; classifier: LaneStatus };
56
+ usage?: Record<string, number>;
57
+ };
58
+
59
+ export type RewriteOption = {
60
+ id: string;
61
+ span: Span;
62
+ replacement: string;
63
+ rationale: string;
64
+ factVerificationRequired: boolean;
65
+ unresolvedQuestions: string[];
66
+ };
67
+
68
+ export type RewriteResult = {
69
+ target: { findingId?: string; span: Span; excerpt: string };
70
+ model: string;
71
+ options: RewriteOption[];
72
+ dropped?: { replacement: string; reason: string }[];
73
+ };
74
+
75
+ export type FeedbackDecision = "accepted" | "fixed" | "dismissed";
76
+
77
+ export type EditorialFeedbackInput = {
78
+ itemId: string;
79
+ findingId: string;
80
+ policyId: string;
81
+ detectorId: string;
82
+ lane: EditorialFinding["lane"];
83
+ probability: number | null;
84
+ decision: FeedbackDecision;
85
+ reason: string | null;
86
+ text: string | null;
87
+ };
88
+
89
+ /** Decisions on an article that has never been saved are kept under this id. */
90
+ export const UNSAVED_ITEM_ID = "unsaved";
91
+
92
+ const SEVERITY_ORDER: Record<Severity, number> = { error: 0, warn: 1, info: 2 };
93
+
94
+ export function editorialChecksEnabled(outputs: PluginOutputs | null | undefined): boolean {
95
+ return pluginSettings(outputs, EDITORIAL_CHECKS_PLUGIN) !== null;
96
+ }
97
+
98
+ /** Findings worth showing: not dismissed, not covering the whole document, most severe first, then in reading order. */
99
+ export function visibleFindings(findings: EditorialFinding[], dismissed: ReadonlySet<string>): EditorialFinding[] {
100
+ return findings
101
+ .filter((finding) => !dismissed.has(finding.id))
102
+ .sort(
103
+ (a, b) =>
104
+ SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] ||
105
+ a.span.start - b.span.start ||
106
+ a.policyId.localeCompare(b.policyId),
107
+ );
108
+ }
109
+
110
+ /** Findings that can be marked in the text (document-level ones have no excerpt). */
111
+ export function inlineFindings(findings: EditorialFinding[]): EditorialFinding[] {
112
+ return findings.filter((finding) => finding.excerpt.length > 0 && finding.span.end > finding.span.start);
113
+ }
114
+
115
+ export type FindingGroup = { policyId: string; severity: Severity; findings: EditorialFinding[] };
116
+
117
+ export function groupByPolicy(findings: EditorialFinding[]): FindingGroup[] {
118
+ const groups = new Map<string, FindingGroup>();
119
+ for (const finding of findings) {
120
+ const group = groups.get(finding.policyId) ?? { policyId: finding.policyId, severity: finding.severity, findings: [] };
121
+ group.findings.push(finding);
122
+ if (SEVERITY_ORDER[finding.severity] < SEVERITY_ORDER[group.severity]) group.severity = finding.severity;
123
+ groups.set(finding.policyId, group);
124
+ }
125
+ return [...groups.values()].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] || a.policyId.localeCompare(b.policyId));
126
+ }
127
+
128
+ /** Open findings that should make an editor pause before publishing (never a block). */
129
+ export function publishWarnings(findings: EditorialFinding[], dismissed: ReadonlySet<string>): EditorialFinding[] {
130
+ return visibleFindings(findings, dismissed).filter((finding) => finding.severity !== "info" && finding.status === "violation");
131
+ }
132
+
133
+ /** The text of the segment a finding sits in, which becomes a few-shot example for the classifier. */
134
+ export function findingSegmentText(result: EditorialCheckResult, body: string, finding: EditorialFinding): string | null {
135
+ const segment = result.segments.find((candidate) => candidate.id === finding.segmentId);
136
+ if (!segment || segment.kind === "document") return null;
137
+ return body.slice(segment.start, segment.end);
138
+ }
139
+
140
+ export function feedbackFor(
141
+ result: EditorialCheckResult,
142
+ body: string,
143
+ finding: EditorialFinding,
144
+ decision: FeedbackDecision,
145
+ itemId: string | null,
146
+ reason: string | null = null,
147
+ ): EditorialFeedbackInput {
148
+ return {
149
+ itemId: itemId ?? UNSAVED_ITEM_ID,
150
+ findingId: finding.id,
151
+ policyId: finding.policyId,
152
+ detectorId: finding.detectorId,
153
+ lane: finding.lane,
154
+ probability: finding.rawProbability ?? finding.probability ?? null,
155
+ decision,
156
+ reason: reason?.trim() ? reason.trim() : null,
157
+ text: finding.lane === "classifier" ? findingSegmentText(result, body, finding) : null,
158
+ };
159
+ }
160
+
161
+ /** Replace one span of the body; the span must still hold the text it was computed for. */
162
+ export function applyReplacement(body: string, span: Span, expected: string, replacement: string): string | null {
163
+ if (body.slice(span.start, span.end) !== expected) return null;
164
+ return body.slice(0, span.start) + replacement + body.slice(span.end);
165
+ }
166
+
167
+ export function describeProbability(finding: EditorialFinding): string | null {
168
+ if (finding.probability === undefined) return null;
169
+ return `${Math.round(finding.probability * 100)}% sure`;
170
+ }
171
+
172
+ export function laneNotice(result: EditorialCheckResult): string | null {
173
+ const classifier = result.lanes.classifier;
174
+ if (classifier.status === "partial") return `Some sentences were not judged: ${classifier.reason ?? "the check ran out of time"}.`;
175
+ if (classifier.status === "failed") return `The judgment checks failed: ${classifier.reason ?? "unknown error"}. Rule checks still ran.`;
176
+ if (classifier.status === "unavailable" && (classifier.detectors ?? 0) === 0 && classifier.reason) return `Judgment checks are not configured: ${classifier.reason}.`;
177
+ return null;
178
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Places Limatus findings on the rendered Markus preview.
3
+ *
4
+ * Limatus reports spans in the markup; the preview renders an IR tree with no
5
+ * character offsets. Both sides agree on the words a reader sees, so findings
6
+ * are placed by text: each Limatus paragraph is matched, in document order, to
7
+ * the rendered prose block with the same words, and each finding's plain
8
+ * excerpt is located inside that block. Whitespace is ignored while matching,
9
+ * because rendering and Limatus collapse it differently (citations, breaks).
10
+ *
11
+ * "Rendered text" is defined by `inlineLeaves`, which the preview renderer also
12
+ * uses, so offsets computed here are offsets the renderer can split on.
13
+ */
14
+ import type { EditorialCheckResult, EditorialFinding, Severity, Span } from "./editorial-checks";
15
+ import type { MarkusBlock, MarkusDocument, MarkusInline, MarkusNode } from "./markus-ir";
16
+
17
+ export const CITATION_TOKEN = /PAPYRUSMARKUP\d{5}END/g;
18
+
19
+ export type InlineLeaf =
20
+ | { kind: "text"; node: MarkusInline & { type: "text" }; start: number; pieces: { raw: string; start: number; isToken: boolean }[] }
21
+ | { kind: "code"; node: MarkusInline & { type: "code_span" }; start: number; text: string }
22
+ | { kind: "break"; start: number; text: string }
23
+ | { kind: "opaque"; start: number };
24
+
25
+ /** The reader-visible text of a run of inlines; citation tokens and images take no width. */
26
+ export function inlineLeaves(inlines: MarkusInline[], offset = 0): { leaves: InlineLeaf[]; text: string } {
27
+ const leaves: InlineLeaf[] = [];
28
+ let text = "";
29
+ const walk = (nodes: MarkusInline[]) => {
30
+ for (const node of nodes) {
31
+ const start = offset + text.length;
32
+ switch (node.type) {
33
+ case "text": {
34
+ const pieces: { raw: string; start: number; isToken: boolean }[] = [];
35
+ let cursor = 0;
36
+ let plainLength = 0;
37
+ for (const match of node.text.matchAll(CITATION_TOKEN)) {
38
+ const index = match.index ?? 0;
39
+ if (index > cursor) {
40
+ pieces.push({ raw: node.text.slice(cursor, index), start: start + plainLength, isToken: false });
41
+ plainLength += index - cursor;
42
+ }
43
+ pieces.push({ raw: match[0], start: start + plainLength, isToken: true });
44
+ cursor = index + match[0].length;
45
+ }
46
+ if (cursor < node.text.length) {
47
+ pieces.push({ raw: node.text.slice(cursor), start: start + plainLength, isToken: false });
48
+ plainLength += node.text.length - cursor;
49
+ }
50
+ leaves.push({ kind: "text", node, start, pieces });
51
+ text += pieces.filter((piece) => !piece.isToken).map((piece) => piece.raw).join("");
52
+ break;
53
+ }
54
+ case "code_span":
55
+ leaves.push({ kind: "code", node, start, text: node.code });
56
+ text += node.code;
57
+ break;
58
+ case "soft_break":
59
+ case "hard_break":
60
+ leaves.push({ kind: "break", start, text: " " });
61
+ text += " ";
62
+ break;
63
+ case "emphasis":
64
+ case "strong":
65
+ case "strikethrough":
66
+ case "link":
67
+ walk(node.children);
68
+ break;
69
+ default:
70
+ leaves.push({ kind: "opaque", start });
71
+ }
72
+ }
73
+ };
74
+ walk(inlines);
75
+ return { leaves, text };
76
+ }
77
+
78
+ /** Prose blocks (paragraphs and headings, including those inside lists, quotes and directives) in reading order. */
79
+ export function proseBlocks(document: MarkusDocument): (MarkusBlock & { inline: MarkusInline[] })[] {
80
+ const blocks: (MarkusBlock & { inline: MarkusInline[] })[] = [];
81
+ const visit = (nodes: MarkusNode[]) => {
82
+ for (const node of nodes) {
83
+ if (node.type === "directive") visit(node.children);
84
+ else if (node.type === "paragraph" || node.type === "heading") blocks.push(node);
85
+ else if (node.type === "list") for (const item of node.items) visit(item.children);
86
+ else if (node.type === "blockquote") visit(node.children);
87
+ }
88
+ };
89
+ visit(document.children);
90
+ return blocks;
91
+ }
92
+
93
+ export type PreviewMark = Span & { findingIds: string[]; severity: Severity; status: EditorialFinding["status"] };
94
+ export type PreviewSentence = Span & { segmentId: string; source: Span };
95
+
96
+ /** What the preview needs for one rendered block, in that block's rendered-text offsets. */
97
+ export type BlockAnnotation = { marks: PreviewMark[]; sentences: PreviewSentence[] };
98
+
99
+ export type PreviewPlan = WeakMap<object, BlockAnnotation>;
100
+
101
+ const SEVERITY_RANK: Record<Severity, number> = { error: 0, warn: 1, info: 2 };
102
+
103
+ /** Text without whitespace, with a map from each kept character back to its index in the original. */
104
+ function compact(text: string): { value: string; index: number[] } {
105
+ let value = "";
106
+ const index: number[] = [];
107
+ for (let i = 0; i < text.length; i += 1) {
108
+ if (!/\s/.test(text[i])) {
109
+ value += text[i];
110
+ index.push(i);
111
+ }
112
+ }
113
+ return { value, index };
114
+ }
115
+
116
+ /** Locate `needle` in `haystack` ignoring whitespace; the occurrence nearest `near` (a 0..1 position) wins. */
117
+ export function locate(haystack: string, needle: string, near = 0): Span | null {
118
+ const hay = compact(haystack);
119
+ const want = compact(needle).value;
120
+ if (!want) return null;
121
+ let best: number | null = null;
122
+ for (let at = hay.value.indexOf(want); at !== -1; at = hay.value.indexOf(want, at + 1)) {
123
+ if (best === null || Math.abs(at / Math.max(hay.value.length, 1) - near) < Math.abs(best / Math.max(hay.value.length, 1) - near)) best = at;
124
+ }
125
+ if (best === null) return null;
126
+ return { start: hay.index[best], end: hay.index[best + want.length - 1] + 1 };
127
+ }
128
+
129
+ /** The identity of a block's words: no whitespace, no stray emphasis or code markers. */
130
+ function blockKey(text: string): string {
131
+ return compact(text).value.replace(/[*_`~]/g, "");
132
+ }
133
+
134
+ /** Match every Limatus paragraph to a rendered block and place its findings and sentences there. */
135
+ export function planPreview(
136
+ document: MarkusDocument,
137
+ result: EditorialCheckResult,
138
+ findings: EditorialFinding[],
139
+ ): PreviewPlan {
140
+ const plan: PreviewPlan = new WeakMap();
141
+ const blocks = proseBlocks(document).map((block) => ({ block, text: inlineLeaves(block.inline).text }));
142
+ const paragraphs = result.segments.filter((segment) => segment.kind === "paragraph" && segment.text);
143
+ let cursor = 0;
144
+ for (const paragraph of paragraphs) {
145
+ const wanted = blockKey(paragraph.text ?? "");
146
+ let matched = -1;
147
+ for (let candidate = cursor; candidate < blocks.length; candidate += 1) {
148
+ if (blockKey(blocks[candidate].text) === wanted) {
149
+ matched = candidate;
150
+ break;
151
+ }
152
+ }
153
+ if (matched === -1) continue;
154
+ cursor = matched + 1;
155
+ const { block, text } = blocks[matched];
156
+ const sentences: PreviewSentence[] = [];
157
+ for (const sentence of result.segments.filter((s) => s.kind === "sentence" && s.parentId === paragraph.id)) {
158
+ const near = (sentence.start - paragraph.start) / Math.max(paragraph.end - paragraph.start, 1);
159
+ const span = locate(text, sentence.text ?? "", near);
160
+ if (span) sentences.push({ ...span, segmentId: sentence.id, source: { start: sentence.start, end: sentence.end } });
161
+ }
162
+ const ranges: (Span & { finding: EditorialFinding })[] = [];
163
+ for (const finding of findings) {
164
+ const inParagraph =
165
+ finding.segmentId === paragraph.id ||
166
+ result.segments.some((s) => s.id === finding.segmentId && s.parentId === paragraph.id);
167
+ if (!inParagraph || !finding.excerptText) continue;
168
+ const near = (finding.span.start - paragraph.start) / Math.max(paragraph.end - paragraph.start, 1);
169
+ const span = locate(text, finding.excerptText, near);
170
+ if (span) ranges.push({ ...span, finding });
171
+ }
172
+ plan.set(block, { marks: flatten(ranges), sentences });
173
+ }
174
+ return plan;
175
+ }
176
+
177
+ /** Overlapping finding ranges become non-overlapping marks, each listing every finding it belongs to. */
178
+ function flatten(ranges: (Span & { finding: EditorialFinding })[]): PreviewMark[] {
179
+ const cuts = [...new Set(ranges.flatMap((range) => [range.start, range.end]))].sort((a, b) => a - b);
180
+ const marks: PreviewMark[] = [];
181
+ for (let i = 0; i < cuts.length - 1; i += 1) {
182
+ const start = cuts[i];
183
+ const end = cuts[i + 1];
184
+ const covering = ranges.filter((range) => range.start <= start && end <= range.end).map((range) => range.finding);
185
+ if (covering.length === 0) continue;
186
+ const strongest = [...covering].sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity])[0];
187
+ const previous = marks[marks.length - 1];
188
+ const ids = covering.map((finding) => finding.id).sort();
189
+ if (previous && previous.end === start && previous.findingIds.join() === ids.join()) {
190
+ previous.end = end;
191
+ continue;
192
+ }
193
+ marks.push({
194
+ start,
195
+ end,
196
+ findingIds: ids,
197
+ severity: strongest.severity,
198
+ status: covering.every((finding) => finding.status === "review") ? "review" : "violation",
199
+ });
200
+ }
201
+ return marks;
202
+ }
203
+
204
+ /** A selection on the preview, as the source span of the whole sentences it touches. */
205
+ export function selectionToSource(annotation: BlockAnnotation | undefined, selection: Span): Span | null {
206
+ if (!annotation) return null;
207
+ const touched = annotation.sentences.filter((sentence) => sentence.start < selection.end && selection.start < sentence.end);
208
+ if (touched.length === 0) return null;
209
+ return {
210
+ start: Math.min(...touched.map((sentence) => sentence.source.start)),
211
+ end: Math.max(...touched.map((sentence) => sentence.source.end)),
212
+ };
213
+ }
214
+
215
+ /** Split [start, end) of rendered text at mark boundaries; each piece says which mark (if any) covers it. */
216
+ export function splitByMarks(start: number, end: number, marks: PreviewMark[]): { start: number; end: number; mark: PreviewMark | null }[] {
217
+ const pieces: { start: number; end: number; mark: PreviewMark | null }[] = [];
218
+ let cursor = start;
219
+ for (const mark of marks) {
220
+ if (mark.end <= cursor || mark.start >= end) continue;
221
+ if (mark.start > cursor) pieces.push({ start: cursor, end: mark.start, mark: null });
222
+ const pieceEnd = Math.min(mark.end, end);
223
+ pieces.push({ start: Math.max(mark.start, cursor), end: pieceEnd, mark });
224
+ cursor = pieceEnd;
225
+ }
226
+ if (cursor < end) pieces.push({ start: cursor, end, mark: null });
227
+ return pieces;
228
+ }
@@ -21,6 +21,31 @@ export interface NativeBoardIssue extends KanbanIssue {
21
21
  href: string;
22
22
  /** A few lines to show under the headline: the blurb, else the subtitle. */
23
23
  excerpt?: string;
24
+ /** The quiet path shown where a board would print the ID, e.g. `articles/my-slug` or `assignments/write-it`. */
25
+ displayId: string;
26
+ }
27
+
28
+ function slugify(text: string): string {
29
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
30
+ }
31
+
32
+ /** Section and slug for a content item, falling back to the publication's board path segment. */
33
+ export function contentItemDisplayId(version: { section?: string | null; slug?: string | null; lineageId: string }): string {
34
+ const section = slugify(version.section ?? "") || contentItemBoardPathSegment();
35
+ return `${section}/${slugify(version.slug ?? "") || version.lineageId.slice(0, 8)}`;
36
+ }
37
+
38
+ /** Assignments have no slug: use the title as one, else a short id. */
39
+ export function assignmentDisplayId(assignment: { id: string; title?: string | null }): string {
40
+ const titleSlug = slugify(assignment.title ?? "").slice(0, 48).replace(/-+$/g, "");
41
+ return `assignments/${titleSlug || assignment.id.slice(0, 8)}`;
42
+ }
43
+
44
+ /** `formatIssueId` for the Kanbus UI: the host-provided path, never the raw `kind:id` prefix. */
45
+ export function formatNativeIssueId(issue: KanbanIssue): string {
46
+ const displayId = (issue as Partial<NativeBoardIssue>).displayId;
47
+ if (displayId) return displayId;
48
+ return issue.id.replace(/^[A-Za-z]+:/, "").slice(0, 12);
24
49
  }
25
50
 
26
51
  export function contentItemBoardPathSegment(): string {
@@ -60,7 +85,7 @@ export function projectContentItemBoard(records: {
60
85
  title: version.headline || version.title || version.slug, nativeStatus: stage, status: `${contentItemType}/${stage}`,
61
86
  priority: 2, description: workCount ? `${workCount} assignment${workCount === 1 ? "" : "s"} on this ${contentItemType}.` : undefined,
62
87
  updated_at: version.updatedAt ?? undefined, href: `/newsroom/articles/${encodeURIComponent(version.id)}`,
63
- excerpt: contentItemExcerpt(version),
88
+ excerpt: contentItemExcerpt(version), displayId: contentItemDisplayId(version),
64
89
  };
65
90
  });
66
91
  }
@@ -73,7 +98,7 @@ export function projectAssignmentBoard(assignments: readonly AssignmentRecord[])
73
98
  priority: row.priority ?? 2, assignee: row.assigneeId || undefined,
74
99
  description: row.summary || row.brief || undefined,
75
100
  created_at: row.createdAt, updated_at: row.updatedAt,
76
- href: `/newsroom/assignments/${encodeURIComponent(row.id)}`,
101
+ href: `/newsroom/assignments/${encodeURIComponent(row.id)}`, displayId: assignmentDisplayId(row),
77
102
  }));
78
103
  }
79
104
 
@@ -22,9 +22,6 @@ export const NEWSROOM_INBOX_ROW_ACTIVE =
22
22
  export const NEWSROOM_SIDEBAR_NAV_ACTIVE =
23
23
  "bg-primary/10 text-foreground shadow-none hover:bg-primary/15";
24
24
 
25
- export const NEWSROOM_SIDEBAR_NAV_INACTIVE =
26
- "text-muted-foreground hover:bg-muted/50 hover:text-foreground";
27
-
28
25
  export function newsroomListRowClassName(active: boolean, className?: string): string {
29
26
  return cn(
30
27
  NEWSROOM_LIST_ROW_BASE,
@@ -18,23 +18,20 @@ export type NewsroomNavItem = {
18
18
  label: string;
19
19
  detail: string;
20
20
  href: string;
21
- mobilePrimary?: boolean;
22
21
  };
23
22
 
24
23
  export const NEWSROOM_OPS_NAV: NewsroomNavItem[] = [
25
- { id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref(), mobilePrimary: true },
26
- { id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles"), mobilePrimary: true },
27
- { id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments"), mobilePrimary: true },
28
- { id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references"), mobilePrimary: true },
24
+ { id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref() },
25
+ { id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles") },
26
+ { id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments") },
27
+ { id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references") },
29
28
  { id: "messages", label: "Messages", detail: "Forum", href: newsroomHref("messages") },
30
- { id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics"), mobilePrimary: true },
29
+ { id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics") },
31
30
  { id: "concepts", label: "Concept wiki", detail: "Knowledge graph", href: newsroomHref("concepts") },
32
31
  { id: "search", label: "Search", detail: "Knowledge base", href: newsroomHref("search") },
33
32
  { id: "administration", label: "Administration", detail: "Users & policies", href: newsroomHref("administration") },
34
33
  ];
35
34
 
36
- export const NEWSROOM_MOBILE_PRIMARY_NAV = NEWSROOM_OPS_NAV.filter((item) => item.mobilePrimary);
37
-
38
35
  export function getNewsroomNavHref(href: string, demo?: boolean): string {
39
36
  const path = toPublicNewsroomPath(href);
40
37
  if (!demo) return path;
@@ -1,16 +1,14 @@
1
1
  import type { NewsDeskTab } from "../components/topic-steering-workspace";
2
2
 
3
- /** The organizer restores the existing taxonomy editor; legacy sites retain their aliases. */
3
+ /** Resolves the requested newsroom section, mapping retired aliases onto their current destinations. */
4
4
  export function resolveNewsDeskTab(
5
5
  sectionValue: string | string[] | null | undefined,
6
6
  legacyTabValue: string | string[] | null | undefined,
7
- organizer = false,
8
7
  ): NewsDeskTab {
9
8
  const section = Array.isArray(sectionValue) ? sectionValue[0] : sectionValue;
10
9
  const legacyTab = Array.isArray(legacyTabValue) ? legacyTabValue[0] : legacyTabValue;
11
10
  const raw = section ?? (legacyTab === "categories" ? "topics" : legacyTab);
12
- const value = raw === "users" || raw === "doctrine" ? "administration"
13
- : raw === "desks" && !organizer ? "topics" : raw;
11
+ const value = raw === "users" || raw === "doctrine" ? "administration" : raw;
14
12
  switch (value) {
15
13
  case "desks": case "administration": case "topics": case "concepts":
16
14
  case "references": case "messages": case "assignments": case "search":
@@ -127,10 +127,10 @@ export function isPrimingOutcome(value: unknown): value is PrimingOutcome {
127
127
  || (outcome.state === "failed" && typeof outcome.message === "string");
128
128
  }
129
129
 
130
- /** In words: waiting for the next sweep, applied as version N, or failed with the reason. */
130
+ /** In plain words: Adding, Added, or Couldn't add with the reason. */
131
131
  export function primingStateText(view: PrimingRequestView): string {
132
- if (!view.outcome) return "Waiting for the next sweep";
132
+ if (!view.outcome) return "Adding";
133
133
  return view.outcome.state === "applied"
134
- ? `Applied as version ${view.outcome.version}`
135
- : `Failed: ${view.outcome.message}`;
134
+ ? "Added"
135
+ : `Couldn't add: ${view.outcome.message}`;
136
136
  }
package/lib/site-brand.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { isLocalPreviewEnabled } from "./local-preview";
2
1
  import { areEditionsEnabled } from "./site-env";
3
2
  import type { ComponentType } from "react";
4
3
  import type { EditionPresentationFormat } from "./content-types";
5
4
  import type { Article, ArticleVideoAsset } from "./articles";
6
5
  import type { BlogPageBackgroundProps } from "../components/blog-page-background";
6
+ import type { KanbusThemeId } from "@kanbus/ui";
7
7
  import type { SiteBrandFont } from "./brand-fonts";
8
8
  import type { PictogramFigureProps } from "../components/pictogram-figure";
9
9
  import papyrusSite from "papyrus-site";
@@ -119,6 +119,13 @@ export type SiteBrand = {
119
119
  defaultVideoCredit?: string;
120
120
  themePack: ThemePackId;
121
121
  themeTokens: ThemePackTokens;
122
+ /**
123
+ * The Kanbus editorial theme the whole newsroom (sidebar, toolbar, boards,
124
+ * detail panel) renders in. Hard-coded per publication: editors cannot
125
+ * change it. Per-publication tweaks are `--kb-theme-*` overrides in the
126
+ * publication's `theme.css`, scoped to `[data-kanbus-theme]`.
127
+ */
128
+ kanbusTheme: KanbusThemeId;
122
129
  renderer: RendererConfig;
123
130
  hosting: HostingConfig;
124
131
  /** Static reader app when it is not co-hosted with this Papyrus checkout. */
@@ -134,8 +141,6 @@ export type SiteBrand = {
134
141
  /** Public URL prefix for the Pretext reader (home, editions, articles, archive, settings). Default `""`; e.g. `/information`. */
135
142
  readerBasePath?: string;
136
143
  opsChrome: OpsChrome;
137
- /** Opt-in CMS viewport layout; independent of the public reader renderer/theme. */
138
- newsroomLayout?: "organizer";
139
144
  corpusKey: string;
140
145
  steeringConfigPath: string;
141
146
  newsroomSectionsConfigPath: string;
@@ -185,6 +190,7 @@ const REFERENCE_SITE_BRANDS: Record<SiteBrandId, SiteBrand> = {
185
190
  sectionLinkStrategy: "route",
186
191
  themePack: "papyrus",
187
192
  themeTokens: DEFAULT_THEME_PACK_TOKENS,
193
+ kanbusTheme: "broadsheet-green",
188
194
  renderer: { kind: "pretext" },
189
195
  hosting: { kind: "amplify-ssr" },
190
196
  opsChrome: "app",
@@ -205,11 +211,7 @@ const REGISTERED_SITE_BRANDS: Record<SiteBrandId, SiteBrand> = {
205
211
  ...Object.fromEntries((papyrusSite.brands ?? []).map((brand) => [brand.id, brand])),
206
212
  };
207
213
 
208
- const SITE_BRANDS: Record<SiteBrandId, SiteBrand> = isLocalPreviewEnabled()
209
- ? Object.fromEntries(
210
- Object.entries(REGISTERED_SITE_BRANDS).map(([id, brand]) => [id, { ...brand, newsroomLayout: "organizer" as const }]),
211
- )
212
- : REGISTERED_SITE_BRANDS;
214
+ const SITE_BRANDS: Record<SiteBrandId, SiteBrand> = REGISTERED_SITE_BRANDS;
213
215
 
214
216
  export function normalizeSiteBrandId(value: string | undefined | null): SiteBrandId | null {
215
217
  if (!value) return null;
@@ -244,6 +246,14 @@ export function getSiteBrand(id: SiteBrandId = resolveSiteBrandId()): SiteBrand
244
246
 
245
247
  export const SITE_BRAND = getSiteBrand();
246
248
 
249
+ /** Mirrors `DEFAULT_KANBUS_THEME` from `@kanbus/ui` (a test keeps the two equal) without a runtime import. */
250
+ export const FALLBACK_KANBUS_THEME: KanbusThemeId = "newspaper-gothic";
251
+
252
+ /** The newsroom theme for a brand; a brand that predates the field falls back to the default theme. */
253
+ export function getKanbusTheme(brand: Pick<SiteBrand, "kanbusTheme"> = SITE_BRAND): KanbusThemeId {
254
+ return brand.kanbusTheme ?? FALLBACK_KANBUS_THEME;
255
+ }
256
+
247
257
  export function getContentItemName(brand: SiteBrand = SITE_BRAND): ContentItemName {
248
258
  return brand.contentItemName ?? DEFAULT_CONTENT_ITEM_NAME;
249
259
  }