diff --git a/pm-stack/console/README.md b/pm-stack/console/README.md index cf723134b2..7657e85b24 100644 --- a/pm-stack/console/README.md +++ b/pm-stack/console/README.md @@ -132,7 +132,7 @@ late. ### Phones -The Android app's home-screen widget reads a short summary (three counts +The Android app's home-screen widget reads a short summary (four counts and the top line of each list) with a token of its own, since it cannot use the browser's sign-in. Linking passes no secret through an address: the phone shows the signed-in owner a hash, the owner approves it under diff --git a/pm-stack/console/android/README.md b/pm-stack/console/android/README.md index e9cd8185f2..f6272a9a65 100644 --- a/pm-stack/console/android/README.md +++ b/pm-stack/console/android/README.md @@ -10,10 +10,10 @@ Around the site, the app uses what only an installed app has: | What | How it is used | Code | | -------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| Home-screen widget | In progress, queued next, needs me, and the task being worked on. Each number opens its screen | `StatusWidget`, `Fleet` | +| Home-screen widget | In progress, queued next, needs me, unread instructions, and the task being worked on. Each number opens its screen | `StatusWidget`, `Fleet` | | Dictation | Long-press the icon and choose Dictate, or tap the "Ask the fleet" quick-settings tile: the words land in the Ask box | `DictateActivity`, `AskTileService` | -| Share and selection | Share text from any app, or select text and choose "Ask the fleet": it lands in the Ask box | `ShareActivity` | -| Long-press shortcuts | Dictate, Ask, Needs me, Now. They move the open app to that screen and do not reload it | `OpenActivity`, `res/xml/shortcuts` | +| Share and selection | Share text from any app, or select text and choose "Ask the fleet": it lands in the Ask box. An enroll command lands in provisioning on the Agents screen instead | `ShareActivity`, `Links` | +| Long-press shortcuts | Dictate, Ask, Needs me, Now, Messages. They move the open app to that screen and do not reload it | `OpenActivity`, `res/xml/shortcuts` | | Notifications | The site's notifications arrive as the app's own, with its mark in the status bar; the app asks for the permission itself | the helper library's activities | | Links | `https://pm.security.cab/...` links open in the app | the launcher activity's intent filter | diff --git a/pm-stack/console/android/app/src/twa/AndroidManifest.xml b/pm-stack/console/android/app/src/twa/AndroidManifest.xml index 3c7d39d792..178ce9b397 100644 --- a/pm-stack/console/android/app/src/twa/AndroidManifest.xml +++ b/pm-stack/console/android/app/src/twa/AndroidManifest.xml @@ -38,7 +38,7 @@ - + @@ -74,11 +74,14 @@ + - + - + MAX_TEXT) { + text = text.substring(0, MAX_TEXT); + } + return open(context, "more/agents/enroll=" + Uri.encode(text)); + } } diff --git a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/OpenActivity.java b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/OpenActivity.java index 1de5dc761c..176b628268 100644 --- a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/OpenActivity.java +++ b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/OpenActivity.java @@ -20,13 +20,18 @@ protected void onCreate(Bundle savedInstanceState) { finish(); } - /** The screen an action names; anything unknown opens Now. */ + /** The screen an action names; anything unknown opens Now. + * Messages is the console's `#more/messages` (#14377): the name + * the shortcut carries is not the route, so it is translated. */ static String screen(String action) { if (action != null && action.startsWith(PREFIX)) { String name = action.substring(PREFIX.length()).toLowerCase(Locale.ROOT); if (name.equals("ask") || name.equals("needs") || name.equals("next")) { return name; } + if (name.equals("messages")) { + return "more/messages"; + } } return "now"; } diff --git a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/ShareActivity.java b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/ShareActivity.java index 287d6c951b..3a818bb7a6 100644 --- a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/ShareActivity.java +++ b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/ShareActivity.java @@ -7,7 +7,10 @@ /** * Receives text from anywhere on the phone: "Share" in another app, or * "Ask the fleet" in the menu that appears when text is selected. The - * text lands in the Ask box, ready to edit and send. + * text lands in the Ask box, ready to edit and send — unless it is an + * enroll command, which lands in provisioning on the Agents screen + * instead (#14377): a bootstrap token pasted into an Ask would file + * it as a task and leave the new agent unenrolled. */ public class ShareActivity extends Activity { @Override @@ -25,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) { text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); } if (text != null && text.toString().trim().length() > 0) { - startActivity(Links.ask(this, text)); + startActivity(Links.enrollCommand(text) ? Links.provision(this, text) : Links.ask(this, text)); } else { startActivity(Links.open(this, "ask")); } diff --git a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/StatusWidget.java b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/StatusWidget.java index 21db17e07f..ad29f6ed9b 100644 --- a/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/StatusWidget.java +++ b/pm-stack/console/android/app/src/twa/java/today/developing/pmconsole/StatusWidget.java @@ -18,8 +18,9 @@ /** * The home-screen widget: how many tasks are in progress, how many are - * queued, how many things need the owner, and what is being worked on - * now. Each number opens its screen; the microphone starts dictation. + * queued, how many things need the owner, how many instructions are + * unread, and what is being worked on now. Each number opens its + * screen; the microphone starts dictation. * *

It is drawn from the last summary read, then the summary is read * again: every half hour, whenever the app is opened, and on a tap of @@ -115,11 +116,13 @@ static void draw(Context context) { views.setTextViewText(R.id.widget_now_n, count(summary, "now", "count")); views.setTextViewText(R.id.widget_next_n, count(summary, "next", "count")); views.setTextViewText(R.id.widget_needs_n, count(summary, "needs", "total")); + views.setTextViewText(R.id.widget_messages_n, count(summary, "messages", "unreadInstructions")); views.setTextViewText(R.id.widget_line, line(context, summary)); views.setTextViewText(R.id.widget_asof, asOf(context, summary)); views.setOnClickPendingIntent(R.id.widget_now, PendingIntent.getActivity(context, 1, Links.open(context, "now"), flags)); views.setOnClickPendingIntent(R.id.widget_next, PendingIntent.getActivity(context, 2, Links.open(context, "next"), flags)); views.setOnClickPendingIntent(R.id.widget_needs, PendingIntent.getActivity(context, 3, Links.open(context, "needs"), flags)); + views.setOnClickPendingIntent(R.id.widget_messages, PendingIntent.getActivity(context, 8, Links.open(context, "more/messages"), flags)); views.setOnClickPendingIntent(R.id.widget_root, PendingIntent.getActivity(context, 4, Links.open(context, "now"), flags)); } else { views.setViewVisibility(R.id.widget_counts, View.GONE); diff --git a/pm-stack/console/android/app/src/twa/res/drawable/ic_messages.xml b/pm-stack/console/android/app/src/twa/res/drawable/ic_messages.xml new file mode 100644 index 0000000000..eee0121c5e --- /dev/null +++ b/pm-stack/console/android/app/src/twa/res/drawable/ic_messages.xml @@ -0,0 +1,14 @@ + + + + diff --git a/pm-stack/console/android/app/src/twa/res/layout/widget_status.xml b/pm-stack/console/android/app/src/twa/res/layout/widget_status.xml index 51442f51fe..24d1e898d4 100644 --- a/pm-stack/console/android/app/src/twa/res/layout/widget_status.xml +++ b/pm-stack/console/android/app/src/twa/res/layout/widget_status.xml @@ -1,5 +1,5 @@ - + + + + + + + What needs me Now What is in progress + Messages + The fleet\'s messages PM PM status - In progress, queued next and what needs you, with the task being worked on now. + In progress, queued next, what needs you and how many instructions are unread, with the task being worked on now. Next Read again Tap to link this phone, so the counts can show here. diff --git a/pm-stack/console/android/app/src/twa/res/xml/shortcuts.xml b/pm-stack/console/android/app/src/twa/res/xml/shortcuts.xml index 6252149c93..b6c0acc2d2 100644 --- a/pm-stack/console/android/app/src/twa/res/xml/shortcuts.xml +++ b/pm-stack/console/android/app/src/twa/res/xml/shortcuts.xml @@ -45,4 +45,15 @@ android:targetClass="today.developing.pmconsole.OpenActivity" android:targetPackage="today.developing.pmconsole" /> + + + diff --git a/pm-stack/console/edge/src/direct.ts b/pm-stack/console/edge/src/direct.ts index 8fd1cd441e..1422c4047c 100644 --- a/pm-stack/console/edge/src/direct.ts +++ b/pm-stack/console/edge/src/direct.ts @@ -39,8 +39,9 @@ import { memoryShelf, type Shelf, Trends } from "../../src/trends.ts"; /** Sections the edge reads itself. `agents` is read through the * bridge, so it is only the edge's while it holds the PM bridge * credential (edge.ts `owned` says which of these are its, case by - * case); the rest are GitHub's and the queue store's. */ -export const DIRECT_READ_SECTIONS = ["board", "prs", "priorities", "asks", "census", "done", "agents"] as const; + * case); the pipeline's unread-instruction count is the bridge's + * the same way (#14377); the rest are GitHub's and the queue store's. */ +export const DIRECT_READ_SECTIONS = ["board", "prs", "priorities", "asks", "census", "done", "agents", "pipeline"] as const; /** Actions the edge runs itself: each is one or a few calls to GitHub * or the queue store, and needs nothing a machine has. */ export const DIRECT_ACTIONS = [ @@ -84,6 +85,7 @@ export const READ_FROM: Record<(typeof DIRECT_READ_SECTIONS)[number], Outward["t census: ["github"], done: ["queue", "github"], agents: ["bridge"], + pipeline: ["bridge"], }; export interface DirectSecrets { @@ -1023,6 +1025,8 @@ export async function directRead(section: string, ops: Ops, work: Work): Promise return work.done(); case "agents": return ops.agents(); + case "pipeline": + return ops.unreadInstructions(); default: throw new Error(`not a section the edge reads itself: ${section}`); } diff --git a/pm-stack/console/edge/src/edge.ts b/pm-stack/console/edge/src/edge.ts index 18514f77bd..4eae331238 100644 --- a/pm-stack/console/edge/src/edge.ts +++ b/pm-stack/console/edge/src/edge.ts @@ -112,6 +112,7 @@ const SECTIONS: Record = { priorities: 180_000, done: 120_000, agents: 75_000, + pipeline: 75_000, services: 45_000, more: 2 * 60 * 60_000, }; @@ -1549,7 +1550,9 @@ export class Edge { // The agents list is the bridge's: read here only while this // side holds the PM bridge credential (#14373). Without it a // machine goes on reporting the list, as it did before. - (name !== "agents" || this.bridgeReady()), + (name !== "agents" || this.bridgeReady()) && + // The pipeline count is the bridge's the same way (#14377). + (name !== "pipeline" || this.bridgeReady()), ); } @@ -1749,11 +1752,12 @@ export class Edge { for (const name of DIRECT_READ_SECTIONS) { // The agents section is the bridge's: with no PM bridge // credential held there is no path here to prove, and the - // section is a machine's, as it was before (#14373). Every + // section is a machine's, as it was before (#14373). The + // pipeline count is the bridge's the same way (#14377). Every // other section is checked even while it is a machine's for // being refused: the check is how this side finds it can read // the section itself again. - if (name === "agents" && !this.bridgeReady()) continue; + if ((name === "agents" || name === "pipeline") && !this.bridgeReady()) continue; try { await directRead(name, direct.ops, direct.work); kinds[name] = { ok: true }; diff --git a/pm-stack/console/public/app.js b/pm-stack/console/public/app.js index 6af114a8df..417bd04827 100644 --- a/pm-stack/console/public/app.js +++ b/pm-stack/console/public/app.js @@ -1499,6 +1499,32 @@ export function askArgs(text, intent) { return { text: text.trim(), ...(kind === "task" ? {} : { intent: kind }) }; } +/** An enroll command as the provisioning form mints it, read back: + * the binding a shared `fleet agent enroll … --bootstrap ` + * carries (#14377). The token is opaque — it has no shape of its + * own — so a command is known by its flags, and anything without a + * bootstrap token in it is not one (null). The command as shared is + * what the card shows; this only picks out the fields the form + * below can be filled in from. + * @param {unknown} text */ +export function enrollCommand(text) { + if (typeof text !== "string" || !/\benroll\b/.test(text)) return null; + const flag = (name) => { + const m = text.match(new RegExp(`--${name}[\\s=]+("[^"]*"|'[^']*'|\\S+)`)); + return m ? m[1].replace(/^["']|["']$/g, "") : undefined; + }; + const token = flag("bootstrap"); + if (!token) return null; + const groups = flag("groups"); + return { + token, + name: flag("name"), + kind: flag("kind"), + groups: groups ? groups.split(",").map((g) => g.trim()).filter(Boolean) : [], + notesIdentity: flag("notes-identity"), + }; +} + /** What he is told when it has gone. * @param {unknown} intent * @param {{ issue: number, queued?: boolean, note?: string }} result */ @@ -2596,6 +2622,7 @@ const REFUSED_SAID = { "read.census": "reading what needs you", "read.done": "reading what was finished", "read.agents": "reading the agents list", + "read.pipeline": "reading the unread instructions", }; /** What the edge says of doing the core itself, read from its public @@ -3674,7 +3701,7 @@ async function viewMessages() { ]; } -async function viewAgents() { +async function viewAgents(sub) { const agents = docs.ops?.agents || []; const to = h("select", { "aria-label": "To" }, h("option", { value: "all" }, "Everyone"), agents.map((a) => h("option", { value: `agent:${a.name}` }, a.name))); const text = typed("message", { rows: 3, placeholder: "A message, or a command to act on", "aria-label": "Message" }); @@ -3974,8 +4001,67 @@ async function viewAgents() { : null, ); }; + // An enroll command handed over by the Android app (#14377): the + // app's share flow sends text carrying one here instead of to the + // Ask box. It arrives after the "#", which never leaves the phone, + // and is consumed here — shown once, on this draw, like a mint: + // the token in it is live until it is used or runs out, so it is + // never put into this screen's state, the documents or the outbox. + // The form below is filled in from the command's binding, so + // minting a fresh token for the same agent is one tap from here. + let handed = null; + if (sub?.startsWith("enroll=")) { + let shared = ""; + try { + shared = decodeURIComponent(sub.slice(7)); + } catch { + // not valid text: nothing was handed over that can be shown + } + history.replaceState(null, "", "#more/agents"); + if (shared) { + const parsed = enrollCommand(shared); + if (parsed) { + if (parsed.name) pName.value = parsed.name; + if (parsed.kind) pKind.value = parsed.kind; + if (parsed.groups.length) pGroups.value = parsed.groups.join(", "); + if (parsed.notesIdentity) pNotes.value = parsed.notesIdentity; + } + const copyShared = (what, label) => + h( + "button", + { + class: "small", + onclick: () => + navigator.clipboard + .writeText(what) + .then(() => toast("Copied")) + .catch(() => toast("Copying failed — select the text and copy it by hand", true)), + }, + label, + ); + handed = card( + h("h3", {}, "An enroll command was shared to this phone"), + h( + "p", + { class: "why" }, + parsed + ? `It is bound to ${parsed.name ?? "an unnamed agent"}${parsed.kind ? ` (${parsed.kind})` : ""}${parsed.groups.length ? `, in ${parsed.groups.join(", ")}` : ""}. Its token works until it is used or runs out; run the command on the new seat, or copy the token. Nothing was sent anywhere — the command came with the share, and leaving this screen takes it with it. The form below is filled in from it, if a fresh token should be minted instead.` + : "It does not carry a bootstrap token, so it is not a complete enroll command; it is shown as shared, and nothing was sent anywhere.", + ), + h("pre", {}, shared), + h( + "div", + { class: "row end" }, + parsed ? copyShared(parsed.token, "Copy the token") : null, + copyShared(shared, "Copy the command"), + h("button", { class: "small ghost", onclick: () => handed.remove() }, "Hide it"), + ), + ); + } + } return [ ...notices(docs.ops, ["agents"]), + handed, compose, h("h2", {}, `Agents (${roster.length})`), directory === null ? empty("The unified directory could not be read just now; the fleet roster is shown, without credential state.") : null, diff --git a/pm-stack/console/src/devices.ts b/pm-stack/console/src/devices.ts index a4ae75a40b..d8c67ad64e 100644 --- a/pm-stack/console/src/devices.ts +++ b/pm-stack/console/src/devices.ts @@ -313,6 +313,10 @@ export function summary(sections: Record, at: number): Record, at: number): Record clip(t.title, 90)), }, needs: { total: questions + hands + reviews, questions, hands, reviews }, + messages: { unreadInstructions }, asks: { answered: asks.filter((a) => a.status === "answered").length, waiting: asks.filter((a) => a.status !== "answered" && a.status !== "done").length, diff --git a/pm-stack/console/src/http.ts b/pm-stack/console/src/http.ts index 65ec77f297..a029965a31 100644 --- a/pm-stack/console/src/http.ts +++ b/pm-stack/console/src/http.ts @@ -93,7 +93,7 @@ export interface Phones { /** Sections the summary is built from, and how long a phone waits for * them to be read again. */ -const SUMMARY_SECTIONS = ["board", "sessions", "census", "asks", "questionCount"]; +const SUMMARY_SECTIONS = ["board", "sessions", "census", "asks", "questionCount", "pipeline"]; /** Under the five seconds the phone gives a read. */ const SUMMARY_WAIT_MS = 3_500; const DEVICE_BODY_LIMIT = 1024; diff --git a/pm-stack/console/src/ops.ts b/pm-stack/console/src/ops.ts index 0f0fe9a686..c3c1d613ad 100644 --- a/pm-stack/console/src/ops.ts +++ b/pm-stack/console/src/ops.ts @@ -567,6 +567,27 @@ export class Ops { return Array.isArray(rows) ? rows : []; } + /** + * The one count the phone's widget adds to its summary (#14377, + * design §4.10): how many instructions in the owner's pipeline are + * unread — connector instructions and fleet commands under the + * pipeline's own unread rule (inbound, not yet read), counted from + * the same feed the Messages screen shows, so the widget's number + * is the screen's. The feed is read at its own largest page: a + * backlog past the page counts as the page, as it does on the + * screen. This is the `pipeline` document section's whole data; + * the phone's token stays read-only and summary-scoped — it is + * handed this count by the summary, never the feed. + */ + async unreadInstructions() { + const rows = await this.pipelineFeed(new URLSearchParams({ unread: "1", limit: "200" })); + const instructions = rows.filter((r) => { + const kind = (r as { kind?: unknown } | null)?.kind; + return kind === "instruction" || kind === "command"; + }).length; + return { unreadInstructions: instructions }; + } + /** Per-agent credential state on the bridge (#14374): active or * revoked, the scopes the live credentials carry. State only — the * bridge never returns a hash, and neither does this. */ diff --git a/pm-stack/console/src/server.ts b/pm-stack/console/src/server.ts index 71e953627a..a806394b0e 100644 --- a/pm-stack/console/src/server.ts +++ b/pm-stack/console/src/server.ts @@ -567,6 +567,9 @@ export function loaders( priorities: { ttlMs: 120_000, load: () => ops.priorities() }, done: { ttlMs: 60_000, load: () => work.done() }, agents: { ttlMs: 30_000, load: () => ops.agents() }, + // The pipeline counted down to its unread instructions (#14377): + // all the phone's summary takes from the feed. + pipeline: { ttlMs: 30_000, load: () => ops.unreadInstructions() }, services: { ttlMs: 20_000, load: () => ops.services() }, more: { ttlMs: 3_600_000, load: async () => more }, }; diff --git a/pm-stack/console/test/app.test.ts b/pm-stack/console/test/app.test.ts index 3eaabf8d6f..9c4c9e672d 100644 --- a/pm-stack/console/test/app.test.ts +++ b/pm-stack/console/test/app.test.ts @@ -31,6 +31,7 @@ import { deviceLabel, deviceState, endpointMark, + enrollCommand, everyRead, flushSaid, freshSaid, @@ -1222,6 +1223,37 @@ test("each kind of prompt has its own words, and the platform takes every kind t expect(askSent("task", { issue: 7, queued: false })).toBe("Filed as #7."); }); +// An enroll command shared to the phone is read back for the +// provisioning form (#14377): the binding the mint put in it. The +// oracle is the command the form itself shows at a mint (name, kind, +// groups, the bootstrap token); the token is opaque, so a command is +// known by its flags, and text without one is not a command. +test("a shared enroll command gives its binding back, and other text does not", () => { + expect( + enrollCommand("fleet agent enroll --name scout-1 --kind muse --groups muse,fleet --bootstrap tok-abc123"), + ).toEqual({ token: "tok-abc123", name: "scout-1", kind: "muse", groups: ["muse", "fleet"], notesIdentity: undefined }); + expect(enrollCommand("fleet agent enroll --name solo --bootstrap tok-xyz")).toEqual({ + token: "tok-xyz", + name: "solo", + kind: undefined, + groups: [], + notesIdentity: undefined, + }); + expect(enrollCommand("fleet agent enroll --name n --kind codex --notes-identity muse/n --bootstrap t")).toEqual({ + token: "t", + name: "n", + kind: "codex", + groups: [], + notesIdentity: "muse/n", + }); + // No bootstrap token, no enroll step, or not text at all: not a command. + expect(enrollCommand("fleet agent enroll --name scout-1 --kind muse")).toBeNull(); + expect(enrollCommand("please enroll the new laptop when it arrives")).toBeNull(); + expect(enrollCommand("run --bootstrap the servers")).toBeNull(); + expect(enrollCommand(null)).toBeNull(); + expect(enrollCommand(42)).toBeNull(); +}); + // A goal most of a list shares is said once, not on every card. Seen // live: sixty queued tasks, fifty-nine of them triage with the same // three lines of goal each. The oracle is counting: the goal that more diff --git a/pm-stack/console/test/console.test.ts b/pm-stack/console/test/console.test.ts index b0b2b007a1..a2353a61bc 100644 --- a/pm-stack/console/test/console.test.ts +++ b/pm-stack/console/test/console.test.ts @@ -776,6 +776,22 @@ describe("operations", () => { expect(r.calls.length).toBe(1); }); + test("the widget's count is the pipeline's unread instructions and nothing else (#14377)", async () => { + // The feed's unread page, as the bridge projects it: instructions + // and commands count; plain messages and notes do not. + const rows = [ + { surface: "connector", kind: "instruction", body: "do it" }, + { surface: "fleet", kind: "command", body: "and this" }, + { surface: "fleet", kind: "command", body: "and this too" }, + { surface: "fleet", kind: "message", body: "just word" }, + { surface: "notes", kind: "note", body: "a note" }, + ]; + const r = recorder(() => JSON.stringify({ messages: rows })); + const ops = new Ops(CFG, r.run); + expect(await ops.unreadInstructions()).toEqual({ unreadInstructions: 3 }); + expect(r.calls[0].argv).toEqual(["fleet", "bridge", "pipeline", "--order", "desc", "--unread", "--limit", "200"]); + }); + test("the directory merges credential state in, and a revocation shows on the next read", async () => { // The bridge's answers, as they stand: felix's credential live. // The row shape mirrors what the bridge returns: revoked_at starts diff --git a/pm-stack/console/test/devices.test.ts b/pm-stack/console/test/devices.test.ts index 64b3e3f18c..98daf2ef3c 100644 --- a/pm-stack/console/test/devices.test.ts +++ b/pm-stack/console/test/devices.test.ts @@ -262,6 +262,7 @@ describe("the summary", () => { census: { hands: [{}, {}, {}], reviews: [{}], other: [{}, {}, {}, {}, {}] }, asks: [{ status: "answered" }, { status: "working" }, { status: "done" }, { status: "queued" }], questionCount: { total: 7, sets: 2 }, + pipeline: { unreadInstructions: 3 }, }; test("counts and the top lines, with the same needs sum as the app's badge", () => { @@ -279,6 +280,8 @@ describe("the summary", () => { next: { count: 2, top: ["N1", "N2"] }, // 7 questions + (3 hands + 2 sessions waiting) + 1 review; "other" is the fleet's to decide. needs: { total: 13, questions: 7, hands: 5, reviews: 1 }, + // The pipeline section's count, carried through whole (#14377). + messages: { unreadInstructions: 3 }, asks: { answered: 1, waiting: 2 }, }); }); @@ -290,6 +293,7 @@ describe("the summary", () => { now: { count: 0, top: [] }, next: { count: 0, top: [] }, needs: { total: 0, questions: 0, hands: 0, reviews: 0 }, + messages: { unreadInstructions: 0 }, asks: { answered: 0, waiting: 0 }, }); const long = summary({ board: { counts: {}, now: [{ title: "x".repeat(300), step: "y".repeat(300) }] } }, 1) as { @@ -318,6 +322,7 @@ describe("over HTTP, without the sign-in", () => { "priorities", "done", "agents", + "pipeline", "services", "more", ].map((name) => [ @@ -331,7 +336,9 @@ describe("over HTTP, without the sign-in", () => { ? { counts: { claimed: 2, queued: 1 }, now: [{ title: "T" }], next: [] } : name === "questionCount" ? { total: 3 } - : []; + : name === "pipeline" + ? { unreadInstructions: 2 } + : []; }, }, ]), @@ -401,20 +408,21 @@ describe("over HTTP, without the sign-in", () => { now: { count: 2, top: [{ title: "T", step: "" }] }, next: { count: 1, top: [] }, needs: { total: 3, questions: 3, hands: 0, reviews: 0 }, + messages: { unreadInstructions: 2 }, asks: { answered: 0, waiting: 0 }, }); // Only the sections the summary is built from were read. - expect([...w.reads].sort()).toEqual(["asks", "board", "census", "questionCount", "sessions"]); + expect([...w.reads].sort()).toEqual(["asks", "board", "census", "pipeline", "questionCount", "sessions"]); // Read again at once: served from memory. await w.read(token); - expect(w.reads).toHaveLength(5); + expect(w.reads).toHaveLength(6); // A widget's read does not count as someone looking: the loop stays idle. w.now.t += 60_000; w.docs.tick(); - expect(w.reads).toHaveLength(5); + expect(w.reads).toHaveLength(6); // The next read, after the sections have aged, reads them again and waits for them. expect(((await (await w.read(token)).json()) as { at: string }).at).toBe(new Date(w.now.t).toISOString()); - expect(w.reads).toHaveLength(10); + expect(w.reads).toHaveLength(12); } finally { w.done(); } diff --git a/pm-stack/console/test/direct.test.ts b/pm-stack/console/test/direct.test.ts index fb0e260592..962b45b478 100644 --- a/pm-stack/console/test/direct.test.ts +++ b/pm-stack/console/test/direct.test.ts @@ -476,6 +476,11 @@ describe("the edge's run: the bridge through its binding", () => { const ops = { agents: async () => [{ name: "felix-1" }] }; expect(await directRead("agents", ops as never, {} as never)).toEqual([{ name: "felix-1" }]); }); + + test("the pipeline section is the unread-instruction count, read the same way (#14377)", async () => { + const ops = { unreadInstructions: async () => ({ unreadInstructions: 2 }) }; + expect(await directRead("pipeline", ops as never, {} as never)).toEqual({ unreadInstructions: 2 }); + }); }); describe("the direct classes", () => { @@ -826,6 +831,7 @@ describe("what this side notes of each call it makes", () => { census: ["github"], done: ["queue", "github"], agents: ["bridge"], + pipeline: ["bridge"], }); }); });