@anthusai/papyrus 5.131.0-next.2 → 5.131.0-next.3
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/functions/automation-view/wire.js +4 -1
- package/amplify/functions/automation-view/wire.ts +4 -1
- package/amplify/functions/image-service/schema.js +10 -0
- package/amplify/functions/image-service/schema.ts +10 -0
- package/amplify/functions/image-service/wire.js +9 -0
- package/amplify/functions/image-service/wire.ts +9 -0
- package/components/announcement-lines.css +26 -0
- package/components/announcement-lines.tsx +157 -0
- package/components/announcement-marks.tsx +36 -0
- package/components/announcements-panel.tsx +10 -34
- package/components/newsroom-article-editor.tsx +4 -0
- package/components/newsroom-organizer.css +1 -1
- package/components/today-view.tsx +45 -0
- package/components/writing-guidelines-admin-panel.tsx +272 -126
- package/lib/announcement-lines.ts +95 -0
- package/lib/announcements-demo.ts +96 -0
- package/lib/announcements-door-client.ts +21 -0
- package/lib/announcements-fixture.ts +1 -19
- package/lib/announcements-model.ts +0 -21
- package/lib/content-actions-demo.ts +2 -0
- package/lib/guidelines/guideline-files.ts +257 -0
- package/lib/guidelines/writing-guidelines-admin.ts +3 -67
- package/lib/images/operations.generated.ts +210 -0
- package/lib/newsroom-articles.ts +5 -0
- package/lib/today-fixture.ts +7 -0
- package/lib/today-overview.ts +40 -0
- package/package.json +7 -2
- package/routes.manifest.json +1 -1
- package/lib/announcements-data.ts +0 -21
|
@@ -3,15 +3,18 @@ import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
|
3
3
|
import { MONITORING_TABLE_PARAMETER, MONITORING_VIEW_TABLE_ACTIONS, monitoringViewParameterArn, monitoringViewTableArns, } from "../monitoring-view/wire.js";
|
|
4
4
|
import { connectToSiteApi } from "../../site-api-access.js";
|
|
5
5
|
import { allowWakeSending } from "../../agents/wake-queue.js";
|
|
6
|
-
/** The reads the function makes of its own site's API with its own role. It writes nothing there. Today reads the day's runs through the status index
|
|
6
|
+
/** The reads the function makes of its own site's API with its own role. It writes nothing there. Today reads the day's runs through the status index, the agents through the tenant index, and the day's email sends through the released-Announcements index, each one's Deliveries and its `announces` links. */
|
|
7
7
|
export const AUTOMATION_VIEW_FUNCTION_FIELDS = [
|
|
8
8
|
"Query/fields/getAutomation",
|
|
9
9
|
"Query/fields/getNewsroomProcedureDefinition",
|
|
10
10
|
"Query/fields/getProcedureRun",
|
|
11
|
+
"Query/fields/listAnnouncementDecisionsByStateAndReleaseAt",
|
|
11
12
|
"Query/fields/listAutomations",
|
|
12
13
|
"Query/fields/listAutomationsByTenant",
|
|
14
|
+
"Query/fields/listDeliveriesByAnnouncementAndCreatedAt",
|
|
13
15
|
"Query/fields/listProcedureRunsByProcedureAndRequestedAt",
|
|
14
16
|
"Query/fields/listProcedureRunsByStatusAndRequestedAt",
|
|
17
|
+
"Query/fields/listSemanticRelationsBySubjectState",
|
|
15
18
|
];
|
|
16
19
|
/** Run now writes one row of its own to the monitoring table, in a monitor's partition (`MONITOR#<id>`), and nothing else. */
|
|
17
20
|
export const AUTOMATION_RUN_NOW_TABLE_ACTIONS = ["dynamodb:PutItem"];
|
|
@@ -10,15 +10,18 @@ import {
|
|
|
10
10
|
import { connectToSiteApi } from "../../site-api-access";
|
|
11
11
|
import { allowWakeSending } from "../../agents/wake-queue";
|
|
12
12
|
|
|
13
|
-
/** The reads the function makes of its own site's API with its own role. It writes nothing there. Today reads the day's runs through the status index
|
|
13
|
+
/** The reads the function makes of its own site's API with its own role. It writes nothing there. Today reads the day's runs through the status index, the agents through the tenant index, and the day's email sends through the released-Announcements index, each one's Deliveries and its `announces` links. */
|
|
14
14
|
export const AUTOMATION_VIEW_FUNCTION_FIELDS = [
|
|
15
15
|
"Query/fields/getAutomation",
|
|
16
16
|
"Query/fields/getNewsroomProcedureDefinition",
|
|
17
17
|
"Query/fields/getProcedureRun",
|
|
18
|
+
"Query/fields/listAnnouncementDecisionsByStateAndReleaseAt",
|
|
18
19
|
"Query/fields/listAutomations",
|
|
19
20
|
"Query/fields/listAutomationsByTenant",
|
|
21
|
+
"Query/fields/listDeliveriesByAnnouncementAndCreatedAt",
|
|
20
22
|
"Query/fields/listProcedureRunsByProcedureAndRequestedAt",
|
|
21
23
|
"Query/fields/listProcedureRunsByStatusAndRequestedAt",
|
|
24
|
+
"Query/fields/listSemanticRelationsBySubjectState",
|
|
22
25
|
];
|
|
23
26
|
|
|
24
27
|
/** Run now writes one row of its own to the monitoring table, in a monitor's partition (`MONITOR#<id>`), and nothing else. */
|
|
@@ -26,6 +26,16 @@ export const imageServiceSchemaDefinitions = {
|
|
|
26
26
|
.returns(a.json())
|
|
27
27
|
.authorization((allow) => [allow.groups(editors)])
|
|
28
28
|
.handler(functionHandler("imageService", imageService)),
|
|
29
|
+
/**
|
|
30
|
+
* The announcements door (PPY-e4ae3a): reads only, for the Story drawer's lines and the Announcements list (`announcements_where`, `announcements_recent`). Editors and admins
|
|
31
|
+
* at the door, the same function and data source; everything that changes an announcement stays on the command line and in the agents' tools.
|
|
32
|
+
*/
|
|
33
|
+
announcementsRead: a
|
|
34
|
+
.query()
|
|
35
|
+
.arguments({ op: a.string().required(), input: a.json(), actorKind: a.string() })
|
|
36
|
+
.returns(a.json())
|
|
37
|
+
.authorization((allow) => [allow.groups(editors)])
|
|
38
|
+
.handler(functionHandler("imageService", imageService)),
|
|
29
39
|
imageRead: a
|
|
30
40
|
.query()
|
|
31
41
|
.arguments({ op: a.string().required(), input: a.json(), actorKind: a.string() })
|
|
@@ -28,6 +28,16 @@ export const imageServiceSchemaDefinitions = {
|
|
|
28
28
|
.returns(a.json())
|
|
29
29
|
.authorization((allow) => [allow.groups(editors)])
|
|
30
30
|
.handler(functionHandler("imageService", imageService)),
|
|
31
|
+
/**
|
|
32
|
+
* The announcements door (PPY-e4ae3a): reads only, for the Story drawer's lines and the Announcements list (`announcements_where`, `announcements_recent`). Editors and admins
|
|
33
|
+
* at the door, the same function and data source; everything that changes an announcement stays on the command line and in the agents' tools.
|
|
34
|
+
*/
|
|
35
|
+
announcementsRead: a
|
|
36
|
+
.query()
|
|
37
|
+
.arguments({ op: a.string().required(), input: a.json(), actorKind: a.string() })
|
|
38
|
+
.returns(a.json())
|
|
39
|
+
.authorization((allow) => [allow.groups(editors)])
|
|
40
|
+
.handler(functionHandler("imageService", imageService)),
|
|
31
41
|
imageRead: a
|
|
32
42
|
.query()
|
|
33
43
|
.arguments({ op: a.string().required(), input: a.json(), actorKind: a.string() })
|
|
@@ -16,6 +16,15 @@ export const IMAGE_SERVICE_FUNCTION_FIELDS = [
|
|
|
16
16
|
"Query/fields/listNewsroomSections",
|
|
17
17
|
// Guideline documents (PPY-8d41d7): the attachment rows that name each version's file, found by owner and role.
|
|
18
18
|
"Query/fields/listModelAttachmentsByOwnerRoleAndSortKey",
|
|
19
|
+
// The announcements door (PPY-e4ae3a) reads, never writes: an Announcement by id, its Deliveries, what is due, the planned list, the relation both ways, a Story's title and an open flag.
|
|
20
|
+
"Query/fields/getAnnouncementDecision",
|
|
21
|
+
"Query/fields/listAnnouncementDecisionsByStateAndReleaseAt",
|
|
22
|
+
"Query/fields/listDeliveriesByAnnouncementAndCreatedAt",
|
|
23
|
+
"Query/fields/listDeliveriesByDueKeyAndDueAt",
|
|
24
|
+
"Query/fields/listSemanticRelationsByObjectState",
|
|
25
|
+
"Query/fields/listSemanticRelationsBySubjectState",
|
|
26
|
+
"Query/fields/getItem",
|
|
27
|
+
"Query/fields/getReviewRequest",
|
|
19
28
|
"Mutation/fields/createItem",
|
|
20
29
|
"Mutation/fields/updateItem",
|
|
21
30
|
"Mutation/fields/createModelAttachment",
|
|
@@ -18,6 +18,15 @@ export const IMAGE_SERVICE_FUNCTION_FIELDS = [
|
|
|
18
18
|
"Query/fields/listNewsroomSections",
|
|
19
19
|
// Guideline documents (PPY-8d41d7): the attachment rows that name each version's file, found by owner and role.
|
|
20
20
|
"Query/fields/listModelAttachmentsByOwnerRoleAndSortKey",
|
|
21
|
+
// The announcements door (PPY-e4ae3a) reads, never writes: an Announcement by id, its Deliveries, what is due, the planned list, the relation both ways, a Story's title and an open flag.
|
|
22
|
+
"Query/fields/getAnnouncementDecision",
|
|
23
|
+
"Query/fields/listAnnouncementDecisionsByStateAndReleaseAt",
|
|
24
|
+
"Query/fields/listDeliveriesByAnnouncementAndCreatedAt",
|
|
25
|
+
"Query/fields/listDeliveriesByDueKeyAndDueAt",
|
|
26
|
+
"Query/fields/listSemanticRelationsByObjectState",
|
|
27
|
+
"Query/fields/listSemanticRelationsBySubjectState",
|
|
28
|
+
"Query/fields/getItem",
|
|
29
|
+
"Query/fields/getReviewRequest",
|
|
21
30
|
"Mutation/fields/createItem",
|
|
22
31
|
"Mutation/fields/updateItem",
|
|
23
32
|
"Mutation/fields/createModelAttachment",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* The Announcements list and the Story drawer's lines. Flat tone fills and rounded rectangles: no borders, no rules. Every state is a mark and words together; a fill only repeats
|
|
2
|
+
them, so nothing here depends on colour. The tones are mixed from the text colour, so they follow light and dark. */
|
|
3
|
+
.ann-card{display:grid;gap:8px;padding:12px 8px 4px}
|
|
4
|
+
.ann-card__heading{display:flex;align-items:center;gap:6px;margin:0;font:600 13px/1.2 var(--kb-theme-ui-font)}
|
|
5
|
+
.ann-list{display:grid;gap:10px}
|
|
6
|
+
.ann-entry{display:grid;gap:8px;padding:12px;border-radius:12px;background:color-mix(in oklab,currentColor 6%,transparent)}
|
|
7
|
+
.ann-entry__head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px}
|
|
8
|
+
.ann-entry__head strong{font:700 14px/1.3 var(--kb-theme-ui-font)}
|
|
9
|
+
.ann-entry__stories{margin:0;font:600 14px/1.4 var(--kb-theme-ui-font);overflow-wrap:anywhere}
|
|
10
|
+
.ann-lines{display:grid;gap:6px;margin:0;padding:0;list-style:none}
|
|
11
|
+
.ann-line{display:grid;gap:3px;padding:8px 10px;border-radius:10px;background:color-mix(in oklab,currentColor 6%,transparent)}
|
|
12
|
+
.ann-line p{margin:0}
|
|
13
|
+
.ann-line__head{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;font:500 13px/1.4 var(--kb-theme-ui-font)}
|
|
14
|
+
.ann-line__account{font-weight:400;opacity:.75}
|
|
15
|
+
.ann-line__state,.ann-line__attention,.ann-line__review,.ann-line__quiet{display:inline-flex;align-items:center;gap:5px}
|
|
16
|
+
.ann-line__state{padding:2px 8px;border-radius:8px;background:color-mix(in oklab,currentColor 10%,transparent);font:600 12px/1.4 var(--kb-theme-ui-font)}
|
|
17
|
+
.ann-line__attention{padding:2px 8px;border-radius:8px;background:color-mix(in oklab,currentColor 22%,transparent);font:700 12px/1.4 var(--kb-theme-ui-font)}
|
|
18
|
+
.ann-line__review{font:400 12px/1.4 var(--kb-theme-ui-font)}
|
|
19
|
+
.ann-line__quiet{margin:0;font:400 12px/1.45 var(--kb-theme-ui-font);opacity:.78}
|
|
20
|
+
.ann-line__head svg,.ann-line__review svg,.ann-line__quiet svg,.ann-flag svg{flex:none}
|
|
21
|
+
.ann-flag{display:flex;align-items:flex-start;gap:8px;margin:0;padding:8px 10px;border-radius:10px;background:color-mix(in oklab,currentColor 16%,transparent);font:400 13px/1.45 var(--kb-theme-ui-font)}
|
|
22
|
+
.ann-flag svg{margin-top:2px}
|
|
23
|
+
.ann-problem{display:flex;align-items:flex-start;padding:8px 10px;border-radius:10px;background:color-mix(in oklab,currentColor 10%,transparent);opacity:1}
|
|
24
|
+
.ann-more{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:6px 14px;border:0;border-radius:8px;background:color-mix(in oklab,currentColor 12%,transparent);color:inherit;font:600 13px var(--kb-theme-ui-font);cursor:pointer;justify-self:start}
|
|
25
|
+
.ann-more:disabled{opacity:.55;cursor:default}
|
|
26
|
+
.ann-more:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./announcement-lines.css";
|
|
3
|
+
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { Megaphone, TriangleAlert } from "lucide-react";
|
|
6
|
+
import { channelName, kindName, readDoor, waitingWords, type AnnouncementEntry, type AnnouncementsDoor, type AnnouncementsRecent, type DeliveryLine } from "../lib/announcement-lines";
|
|
7
|
+
import { formatWhen } from "../lib/announcements-model";
|
|
8
|
+
import { MarkIcon } from "./announcement-marks";
|
|
9
|
+
|
|
10
|
+
const OUTCOME_MARK = { started: "circle-help", unknown: "circle-help", sent: "circle-check", refused: "circle-x" } as const;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One Delivery as one line: the channel and account, its state, how it is reviewed, what it waits for, its last attempt, and what needs a person's eye. Every state is a mark and
|
|
14
|
+
* words together (a flat fill only repeats them), so the line reads without colour. The words and marks are the backend's (`lines.py`).
|
|
15
|
+
*/
|
|
16
|
+
export function DeliveryLineView({ line }: { line: DeliveryLine }) {
|
|
17
|
+
const waiting = waitingWords(line, formatWhen);
|
|
18
|
+
return (
|
|
19
|
+
<li className="ann-line" data-delivery-line={`${line.channel}#${line.accountId}`} data-delivery-state={line.state}>
|
|
20
|
+
<p className="ann-line__head">
|
|
21
|
+
<strong data-delivery-channel>{channelName(line.channel)} <span className="ann-line__account">{line.accountId}</span></strong>
|
|
22
|
+
<span className="ann-line__state" data-delivery-state-words><MarkIcon mark={line.mark} /> {line.words}</span>
|
|
23
|
+
{line.attention.map((item) => (
|
|
24
|
+
<span className="ann-line__attention" data-attention={item.kind} key={item.kind}><MarkIcon mark={item.mark} /> {item.words}</span>
|
|
25
|
+
))}
|
|
26
|
+
</p>
|
|
27
|
+
{line.approval ? <p className="ann-line__review" data-delivery-review><MarkIcon mark={line.approval.mark} /> {line.approval.words}</p> : null}
|
|
28
|
+
{waiting ? <p className="ann-line__quiet" data-delivery-waiting>{waiting}</p> : null}
|
|
29
|
+
{line.lastAttempt ? (
|
|
30
|
+
<p className="ann-line__quiet" data-delivery-attempt={line.lastAttempt.outcome}>
|
|
31
|
+
<MarkIcon mark={OUTCOME_MARK[line.lastAttempt.outcome]} /> Attempt {line.lastAttempt.number}: {line.lastAttempt.words}{line.lastAttempt.code ? ` (${line.lastAttempt.code})` : ""}
|
|
32
|
+
{line.lastAttempt.at ? `, ${formatWhen(line.lastAttempt.at)}` : ""}
|
|
33
|
+
{line.resultUrl ? <> · <a href={line.resultUrl} target="_blank" rel="noreferrer">view</a></> : null}
|
|
34
|
+
</p>
|
|
35
|
+
) : null}
|
|
36
|
+
</li>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One Announcement: what decided it, when it goes, its one open review flag, and one line for each of its Deliveries. */
|
|
41
|
+
export function AnnouncementView({ entry, showStories = false }: { entry: AnnouncementEntry; showStories?: boolean }) {
|
|
42
|
+
return (
|
|
43
|
+
<section className="ann-entry" data-announcement-entry={entry.id} data-announcement-kind={entry.kind}>
|
|
44
|
+
<header className="ann-entry__head">
|
|
45
|
+
<strong>{kindName(entry.kind)}</strong>
|
|
46
|
+
<span className="ann-line__quiet">{formatWhen(entry.releaseAt)}{entry.versionLookedAt ? `, version ${entry.versionLookedAt} of the Story` : ""}</span>
|
|
47
|
+
</header>
|
|
48
|
+
{showStories && entry.stories?.length ? (
|
|
49
|
+
<p className="ann-entry__stories" data-announcement-stories>{entry.stories.map((story) => story.title).join(" · ")}</p>
|
|
50
|
+
) : null}
|
|
51
|
+
{entry.reviewFlag ? (
|
|
52
|
+
<p className="ann-flag" data-review-flag>
|
|
53
|
+
<MarkIcon mark={entry.reviewFlag.mark} size={16} />
|
|
54
|
+
<span><strong>{entry.reviewFlag.words}</strong>{entry.reviewFlag.ask ? <> {entry.reviewFlag.ask}</> : null}</span>
|
|
55
|
+
</p>
|
|
56
|
+
) : null}
|
|
57
|
+
<ul className="ann-lines" data-delivery-lines>
|
|
58
|
+
{entry.deliveries.map((line) => <DeliveryLineView key={line.id} line={line} />)}
|
|
59
|
+
</ul>
|
|
60
|
+
</section>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function Problem({ text }: { text: string }) {
|
|
65
|
+
return <p className="ann-line__quiet ann-problem" data-announcements-problem><TriangleAlert aria-hidden="true" size={14} /> {text}</p>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Read<T> = { status: "loading" } | { status: "problem"; text: string } | { status: "ready"; value: T };
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The Story drawer's "where it was announced": one line for each Delivery, under the Announcement that decided it, read through the Story's `announces` relation (one indexed
|
|
72
|
+
* read, never a table listing). It reads when the Story opens and never subscribes to anything.
|
|
73
|
+
*/
|
|
74
|
+
export function StoryAnnouncementsCard({ lineageId, door }: { lineageId: string; door: AnnouncementsDoor }) {
|
|
75
|
+
const [read, setRead] = useState<Read<AnnouncementEntry[]>>({ status: "loading" });
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
let cancelled = false;
|
|
78
|
+
setRead({ status: "loading" });
|
|
79
|
+
readDoor(door, "announcements_where", { story: lineageId })
|
|
80
|
+
.then((answer) => { if (!cancelled) setRead({ status: "ready", value: answer.announcements }); })
|
|
81
|
+
.catch((error: unknown) => { if (!cancelled) setRead({ status: "problem", text: `Where this Story was announced could not be read. ${error instanceof Error ? error.message : ""}`.trim() }); });
|
|
82
|
+
return () => { cancelled = true; };
|
|
83
|
+
}, [door, lineageId]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<section className="ann-card" data-story-announcements aria-labelledby={`ann-story-${lineageId}`}>
|
|
87
|
+
<h3 className="ann-card__heading" id={`ann-story-${lineageId}`}><Megaphone aria-hidden="true" size={15} />Where it was announced</h3>
|
|
88
|
+
{read.status === "loading" ? <p className="ann-line__quiet" data-story-announcements-loading>Reading…</p> : null}
|
|
89
|
+
{read.status === "problem" ? <Problem text={read.text} /> : null}
|
|
90
|
+
{read.status === "ready" && read.value.length === 0 ? <p className="ann-line__quiet" data-story-announcements-none>This Story has not been announced.</p> : null}
|
|
91
|
+
{read.status === "ready" ? read.value.map((entry) => <AnnouncementView entry={entry} key={entry.id} />) : null}
|
|
92
|
+
</section>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The Announcements list: what is overdue first, then the Announcements newest first, one line for each Delivery. A page ends where the release time changes; "Show older" asks for the
|
|
98
|
+
* page after it. It reads on open and when asked, and never subscribes to anything.
|
|
99
|
+
*/
|
|
100
|
+
export function AnnouncementsList({ door }: { door: AnnouncementsDoor }) {
|
|
101
|
+
const [first, setFirst] = useState<Read<AnnouncementsRecent>>({ status: "loading" });
|
|
102
|
+
const [older, setOlder] = useState<AnnouncementEntry[]>([]);
|
|
103
|
+
const [next, setNext] = useState<string | null>(null);
|
|
104
|
+
const [loadingOlder, setLoadingOlder] = useState(false);
|
|
105
|
+
const [olderProblem, setOlderProblem] = useState<string | null>(null);
|
|
106
|
+
const live = useRef(true);
|
|
107
|
+
useEffect(() => { live.current = true; return () => { live.current = false; }; }, []);
|
|
108
|
+
|
|
109
|
+
const load = useCallback(async () => {
|
|
110
|
+
try {
|
|
111
|
+
const answer = await readDoor(door, "announcements_recent", {});
|
|
112
|
+
if (!live.current) return;
|
|
113
|
+
setFirst({ status: "ready", value: answer });
|
|
114
|
+
setOlder([]);
|
|
115
|
+
setNext(answer.next);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (live.current) setFirst({ status: "problem", text: `The list could not be read. ${error instanceof Error ? error.message : ""}`.trim() });
|
|
118
|
+
}
|
|
119
|
+
}, [door]);
|
|
120
|
+
useEffect(() => { void load(); }, [load]);
|
|
121
|
+
|
|
122
|
+
const showOlder = async () => {
|
|
123
|
+
if (!next) return;
|
|
124
|
+
setLoadingOlder(true);
|
|
125
|
+
setOlderProblem(null);
|
|
126
|
+
try {
|
|
127
|
+
const page = await readDoor(door, "announcements_recent", { before: next });
|
|
128
|
+
if (!live.current) return;
|
|
129
|
+
setOlder((current) => [...current, ...page.announcements]);
|
|
130
|
+
setNext(page.next);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (live.current) setOlderProblem(`Older announcements could not be read. ${error instanceof Error ? error.message : ""}`.trim());
|
|
133
|
+
} finally {
|
|
134
|
+
if (live.current) setLoadingOlder(false);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (first.status === "loading") return <p className="ann-line__quiet">Reading…</p>;
|
|
139
|
+
if (first.status === "problem") return <Problem text={first.text} />;
|
|
140
|
+
const { announcements, overdue } = first.value;
|
|
141
|
+
const unknown = [...announcements, ...older].flatMap((entry) => entry.deliveries).filter((line) => line.attention.some((item) => item.kind === "outcome_unknown")).length;
|
|
142
|
+
return (
|
|
143
|
+
<div className="ann-list" data-announcements-list>
|
|
144
|
+
{overdue.length ? (
|
|
145
|
+
<section className="ann-entry" data-announcements-overdue aria-label="Overdue">
|
|
146
|
+
<header className="ann-entry__head"><strong>Overdue</strong><span className="ann-line__quiet">{overdue.length} {overdue.length === 1 ? "Delivery was" : "Deliveries were"} due and nothing was tried</span></header>
|
|
147
|
+
<ul className="ann-lines">{overdue.map((line) => <DeliveryLineView key={line.id} line={line} />)}</ul>
|
|
148
|
+
</section>
|
|
149
|
+
) : null}
|
|
150
|
+
{unknown ? <p className="ann-line__quiet" data-announcements-unknown>{unknown} {unknown === 1 ? "Delivery has" : "Deliveries have"} an attempt with no answer yet. Each stays "Outcome unknown" until Caducus settles it.</p> : null}
|
|
151
|
+
{announcements.length + older.length === 0 ? <p className="ann-line__quiet" data-announcements-empty>Nothing has been announced yet.</p> : null}
|
|
152
|
+
{[...announcements, ...older].map((entry) => <AnnouncementView entry={entry} showStories key={entry.id} />)}
|
|
153
|
+
{olderProblem ? <Problem text={olderProblem} /> : null}
|
|
154
|
+
{next ? <button type="button" className="ann-more" disabled={loadingOlder} onClick={() => void showOlder()} data-announcements-older>Show older announcements</button> : null}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Ban, Bot, CalendarCheck, CircleCheck, CircleHelp, CircleX, ClockAlert, FlaskConical, Flag, Hand, Hourglass, PencilLine, Replace, Send, ShieldAlert, Undo2, UserCheck,
|
|
5
|
+
type LucideIcon,
|
|
6
|
+
} from "lucide-react";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Each mark the backend names (`lines.py`, `approval_words.py`) is a Lucide icon drawn beside the words, never in place of them. The backend and this table are kept in step by
|
|
10
|
+
* `features_backend/announcement-list-marks.feature`: a mark the backend can say that is not here fails that spec, so no line ever shows an icon of a different meaning.
|
|
11
|
+
*/
|
|
12
|
+
export const MARK_ICONS: Record<string, LucideIcon> = {
|
|
13
|
+
"pencil-line": PencilLine,
|
|
14
|
+
"calendar-check": CalendarCheck,
|
|
15
|
+
send: Send,
|
|
16
|
+
ban: Ban,
|
|
17
|
+
"circle-check": CircleCheck,
|
|
18
|
+
"circle-x": CircleX,
|
|
19
|
+
"flask-conical": FlaskConical,
|
|
20
|
+
"undo-2": Undo2,
|
|
21
|
+
replace: Replace,
|
|
22
|
+
"clock-alert": ClockAlert,
|
|
23
|
+
"circle-help": CircleHelp,
|
|
24
|
+
flag: Flag,
|
|
25
|
+
"shield-alert": ShieldAlert,
|
|
26
|
+
bot: Bot,
|
|
27
|
+
"user-check": UserCheck,
|
|
28
|
+
hourglass: Hourglass,
|
|
29
|
+
hand: Hand,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** The icon of a mark; the words beside it always say what it means. */
|
|
33
|
+
export function MarkIcon({ mark, size = 14 }: { mark: string; size?: number }) {
|
|
34
|
+
const Icon = MARK_ICONS[mark];
|
|
35
|
+
return Icon ? <Icon aria-hidden="true" size={size} data-mark={mark} /> : null;
|
|
36
|
+
}
|
|
@@ -5,14 +5,16 @@ import {
|
|
|
5
5
|
} from "lucide-react";
|
|
6
6
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
7
7
|
import { callAnnouncements, type AnnouncementsApi } from "../lib/announcements-client";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { announcementsDoor } from "../lib/announcements-door-client";
|
|
9
|
+
import { createDemoAnnouncementsDoor } from "../lib/announcements-demo";
|
|
10
|
+
import { createFixtureApi } from "../lib/announcements-fixture";
|
|
10
11
|
import {
|
|
11
12
|
MODE_OPTIONS, QUALITY_FLOOR_STARS, SETUP_INTRO, STAR_CHOICES, STORY_TYPE_OPTIONS, X_PRICING_URL, X_STATE_STORAGE_KEY,
|
|
12
|
-
callbackUrl, connectionWords, failureText, formatDate, formatMoney, formatWhen, modeBlockers, pauseText, setupSteps,
|
|
13
|
-
type AnnouncementFailure, type AnnouncementMode, type
|
|
13
|
+
callbackUrl, connectionWords, failureText, formatDate, formatMoney, formatWhen, modeBlockers, pauseText, setupSteps, toggled,
|
|
14
|
+
type AnnouncementFailure, type AnnouncementMode, type AnnouncementSettings, type XStatus, type XUsage,
|
|
14
15
|
} from "../lib/announcements-model";
|
|
15
16
|
import { getPublicNewsroomBasePath } from "../lib/newsroom-base-path";
|
|
17
|
+
import { AnnouncementsList } from "./announcement-lines";
|
|
16
18
|
|
|
17
19
|
type Message = { kind: "ok" | "problem"; text: string } | null;
|
|
18
20
|
type Section = { id: string; title: string };
|
|
@@ -33,7 +35,7 @@ const PRICE_FIELDS: { key: "createPost" | "createPostWithUrl" | "deletePost" | "
|
|
|
33
35
|
*/
|
|
34
36
|
export function AnnouncementsPanel({ isAdmin, isDemo, sections }: { isAdmin: boolean; isDemo: boolean; sections: Section[] }) {
|
|
35
37
|
const api: AnnouncementsApi = useMemo(() => (isDemo ? createFixtureApi() : callAnnouncements), [isDemo]);
|
|
36
|
-
const
|
|
38
|
+
const door = useMemo(() => (isDemo ? createDemoAnnouncementsDoor() : announcementsDoor), [isDemo]);
|
|
37
39
|
const live = useRef(true);
|
|
38
40
|
useEffect(() => {
|
|
39
41
|
live.current = true;
|
|
@@ -45,8 +47,6 @@ export function AnnouncementsPanel({ isAdmin, isDemo, sections }: { isAdmin: boo
|
|
|
45
47
|
const [status, setStatus] = useState<XStatus | null>(null);
|
|
46
48
|
const [usage, setUsage] = useState<XUsage | null>(null);
|
|
47
49
|
const [usageProblem, setUsageProblem] = useState<string | null>(null);
|
|
48
|
-
const [rows, setRows] = useState<AnnouncementRow[] | null>(null);
|
|
49
|
-
const [rowsProblem, setRowsProblem] = useState<string | null>(null);
|
|
50
50
|
const [problem, setProblem] = useState<string | null>(null);
|
|
51
51
|
const [message, setMessage] = useState<Message>(null);
|
|
52
52
|
const [busy, setBusy] = useState<string | null>(null);
|
|
@@ -72,15 +72,7 @@ export function AnnouncementsPanel({ isAdmin, isDemo, sections }: { isAdmin: boo
|
|
|
72
72
|
if (!live.current) return;
|
|
73
73
|
if (isFailure(used)) { setUsage(null); setUsageProblem(failureText(used)); } else { setUsage(used.usage); setUsageProblem(null); }
|
|
74
74
|
} else { setUsage(null); setUsageProblem(null); }
|
|
75
|
-
|
|
76
|
-
const list = await source.list();
|
|
77
|
-
if (live.current) { setRows(list); setRowsProblem(null); }
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (!live.current) return;
|
|
80
|
-
setRows(null);
|
|
81
|
-
setRowsProblem(error instanceof AnnouncementsBackendNotDeployed ? error.message : `The list could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
-
}
|
|
83
|
-
}, [api, source]);
|
|
75
|
+
}, [api]);
|
|
84
76
|
|
|
85
77
|
useEffect(() => { void load(); }, [load]);
|
|
86
78
|
|
|
@@ -366,24 +358,8 @@ export function AnnouncementsPanel({ isAdmin, isDemo, sections }: { isAdmin: boo
|
|
|
366
358
|
</div>
|
|
367
359
|
) : null}
|
|
368
360
|
|
|
369
|
-
<Card title="Announcements" note="
|
|
370
|
-
|
|
371
|
-
{rows && rows.length === 0 ? <p className="announcements__quiet">Nothing has qualified yet.</p> : null}
|
|
372
|
-
{rows ? (
|
|
373
|
-
<ul className="announcements__rows" data-announcements-rows>
|
|
374
|
-
{rows.map((row) => (
|
|
375
|
-
<li key={row.id} data-announcement={row.id} data-state={row.state}>
|
|
376
|
-
<p className="announcements__rowhead">
|
|
377
|
-
<span className="announcements__state" data-announcement-state>{row.state === "dry_run" ? <FlaskConical aria-hidden="true" size={14} /> : row.state === "posted" ? <CircleCheck aria-hidden="true" size={14} /> : row.state === "failed" ? <CircleX aria-hidden="true" size={14} /> : row.state === "blocked" ? <Ban aria-hidden="true" size={14} /> : <Megaphone aria-hidden="true" size={14} />} {stateWords(row.state)}{row.blockedReason ? `: ${row.blockedReason}` : ""}</span>
|
|
378
|
-
<strong>{row.storyTitle}</strong>
|
|
379
|
-
<span className="announcements__quiet">{formatWhen(row.at)}</span>
|
|
380
|
-
</p>
|
|
381
|
-
<p className="announcements__post" data-announcement-text>{row.text}</p>
|
|
382
|
-
<p className="announcements__quiet">{row.link} · {row.weightedLength} of 280 characters{row.costUsd ? ` · cost ${formatMoney(row.costUsd)}` : ""}{row.postUrl ? <> · <a href={row.postUrl} target="_blank" rel="noreferrer">view post</a></> : null}{row.error ? ` · ${row.error}` : ""}</p>
|
|
383
|
-
</li>
|
|
384
|
-
))}
|
|
385
|
-
</ul>
|
|
386
|
-
) : null}
|
|
361
|
+
<Card title="Announcements" note="Where each Story was announced, one line for each channel." id="list">
|
|
362
|
+
<AnnouncementsList door={door} />
|
|
387
363
|
</Card>
|
|
388
364
|
</div>
|
|
389
365
|
);
|
|
@@ -67,6 +67,7 @@ import { demoEditorialBackend } from "../lib/editorial-checks-demo";
|
|
|
67
67
|
import type { FindingActions } from "./editorial-finding-card";
|
|
68
68
|
import { EditorialFindingsPanel } from "./editorial-findings-panel";
|
|
69
69
|
import { StarRating } from "./star-rating";
|
|
70
|
+
import { StoryAnnouncementsCard } from "./announcement-lines";
|
|
70
71
|
import { StorySchedulePanel } from "./story-schedule-panel";
|
|
71
72
|
import { useScheduleZone } from "../lib/schedule-zone";
|
|
72
73
|
import { scheduleFromEntries, scheduleFromResult, type StorySchedule } from "../lib/story-schedule";
|
|
@@ -614,6 +615,7 @@ export function NewsroomArticleEditor({ articleId, demo, embedded = false, stars
|
|
|
614
615
|
<div aria-label="Loading article" aria-busy="true" className="space-y-4" data-newsroom-article-skeleton role="status">
|
|
615
616
|
<div className="rounded-md bg-muted" data-skeleton-toolbar />
|
|
616
617
|
{!isNew && scheduleZone !== null ? <div className="rounded-md bg-muted" data-skeleton-schedule /> : null}
|
|
618
|
+
{!isNew ? <div className="rounded-md bg-muted" data-skeleton-announcements /> : null}
|
|
617
619
|
{!isNew ? <div className="max-w-md rounded-md bg-muted" data-skeleton-stars /> : null}
|
|
618
620
|
<div className="rounded-md bg-muted" data-skeleton-headline />
|
|
619
621
|
<div className="grid gap-6">
|
|
@@ -775,6 +777,8 @@ export function NewsroomArticleEditor({ articleId, demo, embedded = false, stars
|
|
|
775
777
|
/>
|
|
776
778
|
) : null}
|
|
777
779
|
|
|
780
|
+
{editor.id !== null ? <StoryAnnouncementsCard door={backend.announcementsDoor} lineageId={lineageId ?? editor.id} /> : null}
|
|
781
|
+
|
|
778
782
|
{editor.id !== null ? (
|
|
779
783
|
<div className="max-w-md" data-newsroom-article-stars>
|
|
780
784
|
<StarRating
|
|
@@ -78,7 +78,7 @@ body:has(.newsroom-organizer)>[data-staging-banner]{flex-shrink:0}
|
|
|
78
78
|
.newsroom-embedded-article :is([data-newsroom-article-preview],[data-skeleton-preview]){min-height:min(28rem,55dvh)}
|
|
79
79
|
/* The loading skeleton is the loaded editor's size block for block: the toolbar wraps onto more rows as the panel narrows (a container query,
|
|
80
80
|
because the panel's width, not the window's, decides), and the three fields stack when it is narrow. */
|
|
81
|
-
[data-skeleton-schedule]{height:92px}[data-skeleton-toolbar]{height:44px}[data-skeleton-stars]{height:59px}[data-skeleton-fields]{height:262px}[data-skeleton-preview]{height:min(28rem,55dvh)}
|
|
81
|
+
[data-skeleton-schedule]{height:92px}[data-skeleton-announcements]{height:57px}[data-skeleton-toolbar]{height:44px}[data-skeleton-stars]{height:59px}[data-skeleton-fields]{height:262px}[data-skeleton-preview]{height:min(28rem,55dvh)}
|
|
82
82
|
/* The headline image block is one fixed height in every state (loading, none, processing, missing, loaded), and the skeleton reserves it. */
|
|
83
83
|
[data-story-headline-frame],[data-skeleton-headline]{height:11rem}
|
|
84
84
|
@container (max-width:719px){[data-skeleton-toolbar]{height:80px}[data-skeleton-fields]{height:282px}[data-skeleton-schedule]{height:113px}}
|
|
@@ -4,18 +4,23 @@ import {
|
|
|
4
4
|
OTHER_ORDER,
|
|
5
5
|
OUTCOME_ORDER,
|
|
6
6
|
OUTCOME_WORDS,
|
|
7
|
+
SEND_COUNT_ORDER,
|
|
8
|
+
SEND_COUNT_WORDS,
|
|
7
9
|
automationsHref,
|
|
8
10
|
costText,
|
|
9
11
|
countWords,
|
|
10
12
|
dayTitle,
|
|
11
13
|
reasonsText,
|
|
12
14
|
runsText,
|
|
15
|
+
sendCostText,
|
|
16
|
+
sendItemsText,
|
|
13
17
|
type TodayCountKey,
|
|
14
18
|
type TodayDidNotRun,
|
|
15
19
|
type TodayOverview,
|
|
16
20
|
type TodayResult,
|
|
17
21
|
type TodayRow,
|
|
18
22
|
type TodayRun,
|
|
23
|
+
type TodaySend,
|
|
19
24
|
} from "../lib/today-overview";
|
|
20
25
|
|
|
21
26
|
/** Every status is a mark and its words, never a colour alone. The marks are Lucide icons; the words come with them. */
|
|
@@ -112,6 +117,38 @@ function Row({ row, demo }: { row: TodayRow; demo: boolean }) {
|
|
|
112
117
|
);
|
|
113
118
|
}
|
|
114
119
|
|
|
120
|
+
/** Where a send stands: a mark and its words, never colour alone. A state the table does not name is shown by its words with the neutral mark. */
|
|
121
|
+
const SEND_MARKS: Record<string, LucideIcon> = {
|
|
122
|
+
sent: CheckIcon, sending: ClockIcon, ready: ClockIcon, drafted: ClockIcon, blocked: TriangleAlertIcon, failed: XIcon, dry_run: MinusIcon, withdrawn: MinusIcon, superseded: MinusIcon,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
function SendLine({ send }: { send: TodaySend }) {
|
|
126
|
+
const Icon = SEND_MARKS[send.state] ?? MinusIcon;
|
|
127
|
+
const counted = SEND_COUNT_ORDER.filter((key) => send.counts[key] > 0);
|
|
128
|
+
return (
|
|
129
|
+
<li className="space-y-2 rounded-[16px] bg-[var(--feed-card)] p-3" data-today-send={send.deliveryId} data-today-send-state={send.state}>
|
|
130
|
+
<div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
|
|
131
|
+
<h3 className="text-sm font-semibold">{send.lists.length ? send.lists.join(", ") : "No lists"}</h3>
|
|
132
|
+
<span className="text-xs tabular-nums text-muted-foreground" data-today-send-items-cost>{sendItemsText(send.items)} · {sendCostText(send.cost)}</span>
|
|
133
|
+
</div>
|
|
134
|
+
<p className="inline-flex items-center gap-1.5 text-xs font-medium" data-today-send-status>
|
|
135
|
+
<Icon aria-hidden="true" className="size-3.5 shrink-0" />
|
|
136
|
+
{send.stateWords}
|
|
137
|
+
</p>
|
|
138
|
+
{counted.length ? (
|
|
139
|
+
<ul className="flex flex-wrap gap-1.5" data-today-send-counts>
|
|
140
|
+
{counted.map((key) => (
|
|
141
|
+
<li className={CHIP} data-today-send-count={key} key={key}>
|
|
142
|
+
<span>{SEND_COUNT_WORDS[key]}</span>
|
|
143
|
+
<strong className="tabular-nums">{send.counts[key]}</strong>
|
|
144
|
+
</li>
|
|
145
|
+
))}
|
|
146
|
+
</ul>
|
|
147
|
+
) : <p className="text-xs text-muted-foreground" data-today-send-no-readers>No readers yet.</p>}
|
|
148
|
+
</li>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
115
152
|
function DidNotRunLine({ entry, demo }: { entry: TodayDidNotRun; demo: boolean }) {
|
|
116
153
|
return (
|
|
117
154
|
<li className="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-[16px] bg-[var(--feed-card)] p-3 text-sm" data-today-did-not-run={entry.automationId} data-today-why={entry.whyCode}>
|
|
@@ -138,6 +175,14 @@ function Ready({ overview, demo }: { overview: TodayOverview; demo: boolean }) {
|
|
|
138
175
|
{overview.rows.map((row) => <Row demo={demo} key={row.key} row={row} />)}
|
|
139
176
|
</ul>
|
|
140
177
|
) : <p className="text-sm text-muted-foreground" data-today-nothing-ran>Nothing ran in this day.</p>}
|
|
178
|
+
{overview.sends.length ? (
|
|
179
|
+
<>
|
|
180
|
+
<h3 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">Sends</h3>
|
|
181
|
+
<ul className="space-y-2" data-today-sends>
|
|
182
|
+
{overview.sends.map((send) => <SendLine key={send.deliveryId} send={send} />)}
|
|
183
|
+
</ul>
|
|
184
|
+
</>
|
|
185
|
+
) : null}
|
|
141
186
|
{overview.didNotRun.length ? (
|
|
142
187
|
<>
|
|
143
188
|
<h3 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">Did not run</h3>
|