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 @@
+
+, 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"],
});
});
});