A local-first multi-agent app development platform, built on PenguinHarness
One notice block on every page with updates waiting, with an update-all button (#529)
Yaowei Zheng596519e6b70c
diff --git a/changelog/unreleased/2026-08-28-bulk-update-notice.md b/changelog/unreleased/2026-08-28-bulk-update-notice.mdnew file mode 100644index 00000000..689ff255--- /dev/null+++ b/changelog/unreleased/2026-08-28-bulk-update-notice.md@@ -0,0 +1,43 @@+# One notice block on every page that has updates waiting, with an update-all button++- **Date:** 2026-08-28+- **Type:** feature+- **Scope:** `web`+- **PR:** [#529](https://github.com/Prism-Shadow/penguin-harness/pull/529)+- **Issue:** [#527](https://github.com/Prism-Shadow/penguin-harness/issues/527)++[中文版](2026-08-28-bulk-update-notice.zh.md)++The page notice that says what a nav dot was pointing at is now one shared block on all four+pages that carry one, and on Agents, Skills and Models it can act on everything it counts in a+single press instead of leaving the user to update the objects one at a time.++## Details++- The Agents page gained the block it never had. Its kernel trail became dismissible like the+ other three, so an Agent deliberately left on the defaults generation it was tuned against no+ longer keeps a red dot lit; the gate moved from `update-badges.ts` to `todo-badges.ts` and+ gained a signature, and a newly outdated Agent still raises the dot.+- Each block states what its page can honestly count. Models reports two numbers — entries the+ table lacks and entries whose catalog-owned fields have moved — read straight off the delta the+ sync action itself computes. Agents and Skills report one: an Agent's kernel is never new, and+ a Skill nobody has installed is not waiting for anyone. The Cost Center keeps its single+ "mark as read" control, because a past error is not something that can be updated.+- The bulk button confirms before it writes, in each page's existing words: an Agent kernel+ update is a smart merge that advances the untouched settings tabs and leaves the customized+ ones whole; a Skill update is an overwriting reinstall that drops local edits; a preset sync+ rewrites the catalog-owned fields and leaves locally added models and API keys alone. Every+ dialog lists exactly which objects the batch would write to.+- A partial failure of one of the new bulk actions names the Agents that did not take the+ write, rather than reporting the first error alone. The per-item controls are unchanged.+- The control that clears the notice is now labelled "Dismiss" on all four pages, where it read+ "Mark as handled" before. The Cost Center's "mark as read" is unchanged.+- The per-item paths are unchanged: "sync presets", the per-card Skill update buttons and the+ per-Agent kernel update in settings all still do what they did.++## Compatibility++The dismissal markers stored per user under `ui_prefs.todoDismissed` gained a fourth key,+`agents`. A map written before this change simply has no such key, which reads as "nothing+dismissed" — the Agents block appears once and can be dismissed again. Nothing needs migrating+and no stored marker is lost.diff --git a/changelog/unreleased/2026-08-28-bulk-update-notice.zh.md b/changelog/unreleased/2026-08-28-bulk-update-notice.zh.mdnew file mode 100644index 00000000..95586a07--- /dev/null+++ b/changelog/unreleased/2026-08-28-bulk-update-notice.zh.md@@ -0,0 +1,35 @@+# 每个有待更新的页面共用一个提示块,并支持一键全部升级++- **Date:** 2026-08-28+- **Type:** feature+- **Scope:** `web`+- **PR:** [#529](https://github.com/Prism-Shadow/penguin-harness/pull/529)+- **Issue:** [#527](https://github.com/Prism-Shadow/penguin-harness/issues/527)++[English](2026-08-28-bulk-update-notice.md)++用于说明侧栏小红点指向何处的页面提示,现在在四个页面上是同一个共享块;在 Agents、技能库与模型库+上,它可以一次性处理自己所统计的全部对象,用户不必再逐个更新。++## 细节++- Agents 页面新增了此前没有的提示块。其内核提示与另外三条一样变为可忽略:用户若有意让某个 Agent+ 停留在它当初调校所依据的默认值代次上,红点不再长亮。该 gate 从 `update-badges.ts` 移入+ `todo-badges.ts` 并带上了签名;有新的 Agent 落后时,红点仍会重新亮起。+- 每个块只陈述本页面能够诚实统计的数字。模型库报告两个数字——表中缺失的目录条目,以及目录字段已+ 变化的条目——直接取自同步动作本身计算的 delta。Agents 与技能库只报告一个:Agent 的内核不存在+ 「新增」,而无人安装的 Skill 也不构成待办。成本中心保留单一的「标记为已读」,因为已经发生的错误+ 无从更新。+- 批量按钮在写入前必须确认,措辞沿用各页面已有的原文:Agent 内核更新是智能合并,推进未改动的设置+ 页、完整保留已自定义的设置页;Skill 更新是覆盖式重装,本地改动会丢失;预置同步以目录字段为准刷新+ 差异,本地新增模型与 API key 保持不变。每个对话框都会列出批量操作将写入的具体对象。+- 新增的批量操作部分失败时会点名未成功的 Agent,而不只报告第一个错误;逐个操作的提示不变。+- 清除该提示的按钮统一为「忽略」(英文 Dismiss),此前四个页面上写作「标记为已处理」;成本中心的「标记为已读」不变。+- 逐个操作的路径保持不变:「同步预置」、各卡片上的 Skill 更新按钮,以及设置页内的单个 Agent 内核+ 更新,行为一如既往。++## 兼容性++按用户存储在 `ui_prefs.todoDismissed` 下的忽略标记新增了第四个键 `agents`。此前写入的数据没有该+键,会被读作「未忽略任何内容」——Agents 的提示块会出现一次,可以再次忽略。无需迁移,也不会丢失+任何已存储的标记。diff --git a/packages/web/src/components/ui/todo-notice.tsx b/packages/web/src/components/ui/todo-notice.tsxindex 26c96f3a..750d21d9 100644--- a/packages/web/src/components/ui/todo-notice.tsx+++ b/packages/web/src/components/ui/todo-notice.tsx@@ -1,32 +1,43 @@/**- * The last stop on each of the three DISMISSIBLE trails: a notice directly under the page- * title saying what is waiting, plus the control that puts the dot down.+ * The last stop on each of the four DISMISSIBLE trails: one notice directly under the page+ * title saying what is waiting, the control that acts on all of it at once, and the control+ * that puts the dot down.*- * It exists because those trails, unlike the software and kernel ones, can end in a decision- * NOT to act — a model table kept off the catalog, an error read and understood — and a dot- * with no way down is a dot that stops meaning anything. What the trail was already saying in- * every tooltip above is repeated here verbatim, so arriving confirms rather than re-explains.+ * It exists because those trails, unlike the software one, can end in a decision NOT to act — a+ * model table kept off the catalog, an Agent left on the generation it was tuned against, an+ * error read and understood — and a dot with no way down is a dot that stops meaning anything.+ * What the trail was already saying in every tooltip above is repeated here, so arriving+ * confirms rather than re-explains.*- * **One shape on all three pages**, owner-specified: same block, same place, directly below the- * `<h1>`. The Skills library, the model library and the cost center were three different- * shapes before, and a reader who had learned one had learned nothing about the next.+ * **One shape on all four pages**, owner-specified: same block, same place, directly below the+ * `<h1>`. The Skills library, the model library and the cost center were three different shapes+ * before, and a reader who had learned one had learned nothing about the next.** `toneStrip.attention` is the tone by its own definition — "unfinished: waiting on time, a- * queue, or the user" is exactly what all three trails are — and by its own shape, since- * `toneStrip` is the map for a bordered notice that owns a row. Not `danger`, which means- * failed, destructive or over a limit: a Skill with a newer copy in the library is none of- * those. The class string is the one the other attention strips already use- * (`prompt-injection-controls.tsx`, `memory-tab.tsx`).+ * queue, or the user" is exactly what all four trails are — and by its own shape, since+ * `toneStrip` is the map for a bordered notice that owns a row. Its pale amber ground is the+ * block's requested pale yellow, arrived at through the token rather than around it. Not+ * `danger`, which means failed, destructive or over a limit: a Skill with a newer copy in the+ * library is none of those, and repainting a failure strip this colour to match would lose the+ * one distinction the tones exist to carry.** The 6px red dot stays INSIDE the block, in the same fill it carried down the trail* (`update-dot.tsx`), so the notice reads as "this is that dot": red is the trail's identity* and amber is the notice's shape. It is decorative — the sentence beside it is the carrier,- * and the button folds that sentence into its own accessible name, keeping its visible label as- * the prefix.+ * and each button folds that sentence into its own accessible name, keeping its visible label+ * as the prefix.*- * The top margin is built in rather than left to the caller: three pages place this and all- * three want the same gap under their title. A page whose container spaces its children (the- * cost center's `space-y-4`) overrides it, which is the right answer there too.+ * **The bulk action is optional, and its absence is meaningful.** Three pages can act on+ * everything the notice counts, and pass `actionLabel`; the cost center cannot — there is no+ * "update" for an error that has already happened — so it passes none and the block renders the+ * single button it always had. A page that offers the action must confirm before it runs+ * (`onAction` is expected to open a dialog, not to write): the point of the button is that it+ * overwrites many objects in one press, and every one of these pages already warns before+ * overwriting a single one.+ *+ * The top margin is built in rather than left to the caller: four pages place this and all four+ * want the same gap under their title. A page whose container spaces its children (the cost+ * center's `space-y-4`) overrides it, which is the right answer there too.*/import { Button } from "./button";import { UPDATE_DOT_INLINE } from "./update-dot";@@ -35,15 +46,31 @@ import { toneStrip } from "../../lib/tone";export function TodoNotice({text,+ actionLabel,+ onAction,+ busy = false,dismissLabel,onDismiss,}: {/** What is waiting — the trail's own sentence, unchanged from the dot's tooltip. */text: string;+ /**+ * The bulk action's wording, on the pages that have one. Omitted on the cost center, where+ * nothing is being updated; the block then shows the dismiss control alone.+ */+ actionLabel?: string;+ /**+ * Opens the page's confirmation for updating everything the notice counts. Not the write+ * itself: a bulk overwrite is consented to before it runs, never after.+ */+ onAction?: () => void;+ /** Disables both controls while the confirmed batch is in flight. */+ busy?: boolean;/** The clearing action's wording; "mark as read" where nothing is being updated. */dismissLabel: string;onDismiss: () => void;}) {+ const offersAction = actionLabel !== undefined && onAction !== undefined;return (<divclassName={`mt-3 flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${toneStrip.attention}`}@@ -52,14 +79,31 @@ export function TodoNotice({<span aria-hidden className={`shrink-0 ${UPDATE_DOT_INLINE}`} /><span className="min-w-0">{text}</span></p>- <Button- size="sm"- className="shrink-0"- aria-label={`${dismissLabel} · ${text}`}- onClick={onDismiss}- >- {dismissLabel}- </Button>+ {/* The update sits to the RIGHT of the dismiss, which is where every ConfirmModal in the+ app puts its confirm and where the dialog this button opens will put it a moment later.+ Ordering the pair the other way would place the affirmative action in the slot the+ whole app uses for Cancel. */}+ <div className="flex shrink-0 items-center gap-2">+ <Button+ size="sm"+ disabled={busy}+ aria-label={`${dismissLabel} · ${text}`}+ onClick={onDismiss}+ >+ {dismissLabel}+ </Button>+ {offersAction && (+ <Button+ size="sm"+ variant="primary"+ disabled={busy}+ aria-label={`${actionLabel} · ${text}`}+ onClick={onAction}+ >+ {actionLabel}+ </Button>+ )}+ </div></div>);}diff --git a/packages/web/src/features/agents/agents-page.tsx b/packages/web/src/features/agents/agents-page.tsxindex c3aa318c..373a0789 100644--- a/packages/web/src/features/agents/agents-page.tsx+++ b/packages/web/src/features/agents/agents-page.tsx@@ -26,6 +26,9 @@ import { apiErrorText } from "../../lib/api-error";import { SEMANTIC_ID_PATTERN } from "../../lib/semantic-id";import { formatDateTime, formatRelativeDays } from "../../lib/format";import { useDocumentTitle } from "../../lib/use-document-title";+import { useUpdateBadges } from "../../lib/use-update-badges";+import { dismissTodo } from "../../lib/todo-dismissals";+import { bulkOutcome, failedList, firstFailure, noticeCounts } from "../../lib/bulk-update";import { useAuth } from "../../state/auth";import { useLocale } from "../../state/locale";import { agentDisplayName, useProject } from "../../state/project";@@ -35,12 +38,14 @@ import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { FormPicker } from "../../components/ui/form-picker";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";+import { toastError, toastSuccess } from "../../components/ui/toast";import { Badge } from "../../components/ui/badge";import { Skeleton, SkeletonCard } from "../../components/ui/skeleton";import { EmptyState } from "../../components/ui/empty-state";import { AgentAvatar } from "../../components/ui/agent-avatar";import { GlyphIcon } from "../../components/ui/glyph-icon";import { UpdatePill } from "../../components/ui/update-dot";+import { TodoNotice } from "../../components/ui/todo-notice";import { GEAR_ICON } from "../../components/ui/icons";import { STAT_ICONS } from "../../lib/stat-icons";import { DRAFT_SESSION_ID } from "../chat/chat-page";@@ -99,6 +104,11 @@ export function AgentsPage() {const { locale } = useLocale();const { user } = useAuth();const { currentProject, agents, agentsLoading, reloadAgents, setCurrentAgentId } = useProject();+ /** The kernel trail's raised badge, or undefined — the notice under the title acts on it or clears it. */+ const kernelTodo = useUpdateBadges().todos.agents;+ /** The bulk kernel update's confirmation is open. */+ const [kernelConfirmOpen, setKernelConfirmOpen] = useState(false);+ const [kernelRunning, setKernelRunning] = useState(false);const [createOpen, setCreateOpen] = useState(false);const [agentId, setAgentId] = useState("");const [name, setName] = useState("");@@ -343,6 +353,48 @@ export function AgentsPage() {}};+ /**+ * The notice's bulk action: run the kernel update on every Agent behind the current defaults+ * generation. The per-Agent update on the settings overview is untouched and stays the way to+ * take just one — which is what makes dismissing this notice safe, since nothing it silences+ * becomes unreachable.+ *+ * `Promise.allSettled` with a named partial failure, the shape the Skills page's bulk update+ * uses: a smart merge that lands on three Agents and fails on two must say WHICH two, or the+ * user is left re-checking every card by hand.+ */+ const runKernelUpdates = async (targets: readonly string[]) => {+ if (!projectId || targets.length === 0) return;+ setKernelRunning(true);+ const labels = targets.map((agentId) => {+ const agent = agents.find((a) => a.agentId === agentId);+ return agent ? agentDisplayName(agent) : agentId;+ });+ const results = await Promise.allSettled(+ targets.map((agentId) => api.kernelUpdateAgentConfig(projectId, agentId)),+ );+ const outcome = bulkOutcome(labels, results);+ if (outcome.allOk) toastSuccess(S.todo.bulkDone(outcome.ok));+ else {+ toastError(+ `${S.todo.bulkPartial(outcome.ok, failedList(outcome.failed, S.todo.listSeparator))} — ${apiErrorText(firstFailure(results))}`,+ );+ }+ // The gate reads `AgentSummary.kernelOutdated` off the Project's Agent list, so the dot only+ // goes down once that list is re-read. Runs after a partial failure too — some Agent moved.+ // Guarded, because `reloadAgents` rejects on a failed list read and the busy flag disables+ // every control on this page, the dialog's Cancel included: a reload that failed after the+ // writes landed would otherwise leave the page frozen with nothing saying why.+ try {+ await reloadAgents();+ } catch (e) {+ toastError(apiErrorText(e));+ } finally {+ setKernelRunning(false);+ setKernelConfirmOpen(false);+ }+ };+return (<div className="h-full overflow-y-auto p-4 md:p-6"><div className="mx-auto max-w-5xl">@@ -353,6 +405,22 @@ export function AgentsPage() {</Button></div>+ {/* Last stop on the kernel trail, in the one shape all four dismissible trails use.+ An Agent's kernel is never NEW — the Agent already exists and its config is simply+ behind the defaults generation — so the line states the upgradable count alone+ rather than padding it with a zero the page has no meaning for. The per-card capsule+ below and the per-Agent update in settings are untouched. */}+ {kernelTodo && (+ <TodoNotice+ text={S.todo.changesUpgradable(noticeCounts(kernelTodo).updated)}+ actionLabel={S.todo.updateNow}+ busy={kernelRunning}+ onAction={() => setKernelConfirmOpen(true)}+ dismissLabel={S.todo.dismiss}+ onDismiss={() => dismissTodo(projectId ?? null, "agents", kernelTodo.signature)}+ />+ )}+{agentsLoading ? (/* Same single-column row styling as the real list (space-y-3 + px-5 py-4), with athree-line info column plus sparkline/button-group placeholders, so no layout shift@@ -758,6 +826,39 @@ export function AgentsPage() {</div></Modal>+ {/* Bulk kernel update confirmation. The body is the per-Agent confirm's own wording,+ verbatim — a kernel update is a smart merge that advances the settings tabs the user+ has not touched and leaves the customized ones whole — with the list naming every+ Agent the batch would write to. Primary (overwrite) tone, like its per-Agent twin. */}+ {kernelTodo && kernelConfirmOpen && (+ <ConfirmModal+ open+ title={S.todo.agentsConfirmTitle(kernelTodo.count)}+ tone="primary"+ confirmLabel={S.agent.kernelUpdateAction}+ busy={kernelRunning}+ onClose={() => setKernelConfirmOpen(false)}+ onConfirm={() => void runKernelUpdates(kernelTodo.items)}+ >+ <div className="space-y-3">+ <p className="text-sm text-gray-600 dark:text-gray-300">+ {S.agent.kernelUpdateConfirmBody}+ </p>+ <p className="text-xs text-gray-500 dark:text-gray-400">{S.todo.willTouch}</p>+ <ul className="max-h-60 divide-y divide-gray-100 overflow-y-auto rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800">+ {kernelTodo.items.map((id) => {+ const agent = agents.find((a) => a.agentId === id);+ return (+ <li key={id} className="px-3 py-1.5 text-xs">+ {agent ? agentDisplayName(agent) : id}+ </li>+ );+ })}+ </ul>+ </div>+ </ConfirmModal>+ )}+{/* Delete confirmation (shared ConfirmModal) */}<ConfirmModalopen={deleting !== null}diff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsxindex 3f352c7a..fcb1b83a 100644--- a/packages/web/src/features/models/models-page.tsx+++ b/packages/web/src/features/models/models-page.tsx@@ -113,6 +113,7 @@ import { clearDraftModelRef } from "../chat/draft-cache";import { syncRowsWithCatalog } from "./catalog-sync";import { useUpdateBadges } from "../../lib/use-update-badges";import { dismissTodo } from "../../lib/todo-dismissals";+import { noticeCounts } from "../../lib/bulk-update";import { refreshProjectTodos } from "../../lib/use-project-todos";import { UpdateDot } from "../../components/ui/update-dot";import { TodoNotice } from "../../components/ui/todo-notice";@@ -538,6 +539,11 @@ export function ModelsPage() {const todo = useUpdateBadges().todos.models;/** What the trail says, read at render time: `S` is a live binding swapped on locale change. */const syncNote = todo ? S.todo.presetUpdates(todo.count) : "";+ /** The notice's two counts, both off the delta the sync action itself computes. */+ const syncCounts = todo ? noticeCounts(todo) : null;+ /** The notice's sync confirmation is open (it lists the refs the delta named). */+ const [syncConfirmOpen, setSyncConfirmOpen] = useState(false);+ const [syncing, setSyncing] = useState(false);const userId = useAuth().user?.userId ?? null;/** Per-model speed results (in-memory, reset on every project switch; "pending" while that model's turn is running). */const [speedResults, setSpeedResults] = useState<Map<string, SpeedResult | "pending">>(new Map());@@ -698,6 +704,11 @@ export function ModelsPage() {const merged = syncRowsWithCatalog(rows);if (merged.added === 0 && merged.updated === 0) {toastInfo(S.models.syncUpToDate);+ // Re-probe here too: the badge is gated on a cached probe, and an entry brought back into+ // line by a hand edit leaves that probe claiming a change this sync has just found none+ // of. Without it the notice keeps offering a button that can only answer "already+ // up to date" — a loop the user gets out of only by dismissing or reloading.+ refreshProjectTodos(projectId);return;}await persist(@@ -935,12 +946,23 @@ export function ModelsPage() {)}</div></div>- {/* Last stop on the Models trail, in the one shape all three dismissible trails use:- directly under the title, naming what is waiting and carrying the way down for- someone who has looked and decided to stay off the catalog. */}- {isOwner && todo && (+ {/* Last stop on the Models trail, in the one shape all four dismissible trails use:+ directly under the title, naming what is waiting, carrying the sync itself, and+ carrying the way down for someone who has looked and decided to stay off the+ catalog. This is the one page whose two counts are both real — the catalog is a+ list of entries, so an entry the table lacks is genuinely new — and both come off+ the delta the sync action itself computes (catalog-sync.ts), never a second count.+ The toolbar's "sync presets" button is unchanged and still runs it directly. */}+ {isOwner && todo && syncCounts && (<TodoNotice- text={syncNote}+ text={+ syncCounts.added === null+ ? S.todo.changesUpgradable(syncCounts.updated)+ : S.todo.changesWithAdded(syncCounts.added, syncCounts.updated)+ }+ actionLabel={S.todo.updateNow}+ busy={syncing}+ onAction={() => setSyncConfirmOpen(true)}dismissLabel={S.todo.dismiss}onDismiss={() => dismissTodo(projectId, "models", todo.signature)}/>@@ -1264,6 +1286,41 @@ export function ModelsPage() {</ConfirmModal>)}+ {/* The notice's bulk sync. Same union the toolbar button runs (syncPresets), but+ confirm-first: the button on the notice is reached from a block announcing a batch, and+ a sync rewrites the catalog-owned fields of every entry it names. The body is the+ toolbar button's own description of those semantics, verbatim — the wording that has+ always stated what a sync keeps and what it overwrites. */}+ {todo && syncConfirmOpen && (+ <ConfirmModal+ open+ title={S.todo.modelsConfirmTitle(todo.count)}+ tone="primary"+ confirmLabel={S.models.syncCatalog}+ busy={syncing}+ onClose={() => setSyncConfirmOpen(false)}+ onConfirm={() => {+ setSyncing(true);+ void syncPresets().finally(() => {+ setSyncing(false);+ setSyncConfirmOpen(false);+ });+ }}+ >+ <div className="space-y-3">+ <p className="text-sm text-gray-600 dark:text-gray-300">{S.models.syncCatalogHint}</p>+ <p className="text-xs text-gray-500 dark:text-gray-400">{S.todo.willTouch}</p>+ <ul className="max-h-60 divide-y divide-gray-100 overflow-y-auto rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800">+ {todo.items.map((ref) => (+ <li key={ref} className="px-3 py-1.5 font-mono text-xs">+ {ref}+ </li>+ ))}+ </ul>+ </div>+ </ConfirmModal>+ )}+{speedFor !== null && (<Modal open title={S.models.speedTestTitle} onClose={() => setSpeedFor(null)}><p className="text-sm text-gray-600 dark:text-gray-300">diff --git a/packages/web/src/features/skills/skills-page.tsx b/packages/web/src/features/skills/skills-page.tsxindex 162b6029..9823faf7 100644--- a/packages/web/src/features/skills/skills-page.tsx+++ b/packages/web/src/features/skills/skills-page.tsx@@ -37,7 +37,11 @@*/import { useEffect, useState } from "react";import { useNavigate } from "react-router";-import type { SkillGroupItem, SkillMetadataItem } from "@prismshadow/penguin-server/api";+import type {+ AgentSummary,+ SkillGroupItem,+ SkillMetadataItem,+} from "@prismshadow/penguin-server/api";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";@@ -46,6 +50,7 @@ import { formatRelativeDate } from "../../lib/format";import { useDocumentTitle } from "../../lib/use-document-title";import { useUpdateBadges } from "../../lib/use-update-badges";import { dismissTodo } from "../../lib/todo-dismissals";+import { bulkOutcome, failedList, firstFailure, noticeCounts } from "../../lib/bulk-update";import { useAuth } from "../../state/auth";import { useLocale } from "../../state/locale";import { agentDisplayName, useProject } from "../../state/project";@@ -95,6 +100,37 @@ export function outdatedAgentIds(});}+/**+ * What updating EVERY outdated Skill on this page would write, grouped the way it is sent.+ *+ * Read off `AgentSummary.skillUpdates` — the same field the Skills gate counts — so the plan and+ * the notice above the button cannot describe different work. One request per Agent rather than+ * one per (Agent, Skill): the install endpoint already takes a list of names, and an Agent behind+ * on four Skills is one overwrite of its skills directory either way.+ *+ * `skills` is the distinct library Skills across the whole plan, sorted, which is what the+ * confirmation lists and what the notice counts — the page shows the library once, so an update+ * touching five Agents is still one Skill to the reader.+ */+export interface SkillUpdatePlan {+ perAgent: { agentId: string; names: string[] }[];+ skills: string[];+}++export function skillUpdatePlan(+ agents: ReadonlyArray<Pick<AgentSummary, "agentId" | "skillUpdates">>,+): SkillUpdatePlan {+ const perAgent: { agentId: string; names: string[] }[] = [];+ const skills = new Set<string>();+ for (const agent of agents) {+ const names = (agent.skillUpdates ?? []).map((u) => u.name).sort();+ if (names.length === 0) continue;+ perAgent.push({ agentId: agent.agentId, names });+ for (const name of names) skills.add(name);+ }+ return { perAgent, skills: [...skills].sort() };+}+export function SkillsPage() {useDocumentTitle(S.nav.skills);const navigate = useNavigate();@@ -103,8 +139,11 @@ export function SkillsPage() {const { currentProject, agents, currentAgent, setCurrentAgentId, reloadAgents } = useProject();const projectId = currentProject?.projectId ?? null;- /** The Skills trail's raised badge, or undefined — the notice under the title clears it. */+ /** The Skills trail's raised badge, or undefined — the notice under the title acts on it or clears it. */const todo = useUpdateBadges().todos.skills;+ /** The bulk update's confirmation is open (null = closed); it holds the plan it will run. */+ const [pendingBulk, setPendingBulk] = useState<SkillUpdatePlan | null>(null);+ const [bulkRunning, setBulkRunning] = useState(false);const [groups, setGroups] = useState<SkillGroupItem[] | null>(null);const [error, setError] = useState<string | null>(null);@@ -235,6 +274,52 @@ export function SkillsPage() {void reloadAgents();};+ /**+ * The notice's bulk action: reinstall the library copy of every outdated Skill, on every Agent+ * behind on it — the per-card update, over the whole page. The per-card and per-Agent controls+ * are untouched and remain the way to update just one.+ *+ * `Promise.allSettled` over one request per Agent, the shape the per-Skill update already+ * uses, and the same reload afterwards: the gate reads `AgentSummary.skillUpdates`, which this+ * page's install map does not feed, so without it the dot would survive the very update it led+ * the user to. What is new is that a partial failure NAMES the Agents that did not take it —+ * on a control whose whole point is "all of them at once", a first-error toast leaves the user+ * unable to tell which half they are looking at.+ */+ const runBulkUpdate = async (plan: SkillUpdatePlan) => {+ if (!projectId || plan.perAgent.length === 0) return;+ setBulkRunning(true);+ const labels = plan.perAgent.map(({ agentId }) => {+ const agent = agents.find((a) => a.agentId === agentId);+ return agent ? agentDisplayName(agent) : agentId;+ });+ const results = await Promise.allSettled(+ plan.perAgent.map(async ({ agentId, names }) => {+ const res = await api.installAgentSkills(projectId, agentId, names);+ calibrateAgent(agentId, res.skills);+ }),+ );+ const outcome = bulkOutcome(labels, results);+ if (outcome.allOk) toastSuccess(S.todo.bulkDone(outcome.ok));+ else {+ toastError(+ `${S.todo.bulkPartial(outcome.ok, failedList(outcome.failed, S.todo.listSeparator))} — ${apiErrorText(firstFailure(results))}`,+ );+ }+ // Runs after a partial failure too — some Agent moved, and the gate has to see it. Guarded,+ // because `reloadAgents` rejects on a failed list read and the busy flag disables every+ // control here, the dialog's Cancel included: a reload that failed after the writes landed+ // would otherwise leave the page frozen with nothing saying why.+ try {+ await reloadAgents();+ } catch (e) {+ toastError(apiErrorText(e));+ } finally {+ setBulkRunning(false);+ setPendingBulk(null);+ }+ };+/*** Quick invoke: pre-selects the skill in the draft cache (the `skills`* field, used by ChatInput as its initial selection on mount), pre-fills@@ -273,12 +358,18 @@ export function SkillsPage() {{S.skills.pageTitle}<InfoPopover label={S.skills.pageTitle}>{S.skills.pageDesc}</InfoPopover></h1>- {/* Last stop on the Skills trail: what the sidebar's dot was pointing at, in its own- wording, plus the way to clear it for someone who has looked and decided to stay on- the installed copies. The per-card update buttons below are the action itself. */}+ {/* Last stop on the Skills trail: what the sidebar's dot was pointing at, the control+ that takes all of it in one press, and the way to clear it for someone who has looked+ and decided to stay on the installed copies. A Skill is never NEW here — one nobody+ has installed is not waiting for anyone — so the line states the upgradable count+ alone rather than padding it with a zero. The per-card update buttons below remain+ the way to take just one. */}{todo && (<TodoNotice- text={S.todo.skillUpdates(todo.count)}+ text={S.todo.changesUpgradable(noticeCounts(todo).updated)}+ actionLabel={S.todo.updateNow}+ busy={bulkRunning}+ onAction={() => setPendingBulk(skillUpdatePlan(agents))}dismissLabel={S.todo.dismiss}onDismiss={() => dismissTodo(projectId, "skills", todo.signature)}/>@@ -375,6 +466,34 @@ export function SkillsPage() {</div>)}</div>++ {/* Bulk update confirmation. Same warning as the per-Skill confirm — an update is an+ overwriting reinstall — and the same primary (overwrite) tone, with the list naming+ every Skill the batch would rewrite. Confirm-first is the point of the button: it+ overwrites many installs in one press, and a single one already asks. */}+ {pendingBulk !== null && (+ <ConfirmModal+ open+ title={S.todo.skillsConfirmTitle(pendingBulk.skills.length)}+ tone="primary"+ confirmLabel={S.skills.updateAction}+ busy={bulkRunning}+ onClose={() => setPendingBulk(null)}+ onConfirm={() => void runBulkUpdate(pendingBulk)}+ >+ <div className="space-y-3">+ <p className="text-sm text-gray-600 dark:text-gray-300">{S.todo.skillsConfirmBody}</p>+ <p className="text-xs text-gray-500 dark:text-gray-400">{S.todo.willTouch}</p>+ <ul className="max-h-60 divide-y divide-gray-100 overflow-y-auto rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800">+ {pendingBulk.skills.map((name) => (+ <li key={name} className="px-3 py-1.5 font-mono text-xs">+ {name}+ </li>+ ))}+ </ul>+ </div>+ </ConfirmModal>+ )}</div>);}@@ -559,7 +678,7 @@ function SkillCard({{S.skills.updateConfirmWarning(skill.name)}</p>{/* Per-agent old → new version, so it's clear exactly which installs get overwritten. */}- <ul className="divide-y divide-gray-100 overflow-hidden rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800">+ <ul className="max-h-60 divide-y divide-gray-100 overflow-y-auto rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800">{pendingUpdate.map((agentId) => {const oldVersion = installed.get(agentId)?.get(skill.name);const target = agents.find((a) => a.agentId === agentId);diff --git a/packages/web/src/features/usage/usage-page.tsx b/packages/web/src/features/usage/usage-page.tsxindex fdff3ec6..a51460cc 100644--- a/packages/web/src/features/usage/usage-page.tsx+++ b/packages/web/src/features/usage/usage-page.tsx@@ -352,11 +352,13 @@ export function UsagePage() {</div></div>- {/* Last stop on the Cost Center trail, in the one shape all three dismissible trails+ {/* Last stop on the Cost Center trail, in the one shape all four dismissible trailsuse: directly under the title, not down against the errors table. It counts theprobe's own trailing window (use-project-todos.ts), which is not the filters aboveit, so it states what the badge is about rather than what any one panel is showing.- "Read", not "done" — nothing is being updated here, the user has simply looked. */}+ "Read", not "done" — nothing is being updated here, the user has simply looked, and+ this is the one of the four that offers no bulk action: a past error cannot be+ updated, so the block renders the dismiss control alone. */}{todo && (<TodoNoticetext={S.todo.unexpectedErrors(todo.count)}diff --git a/packages/web/src/lib/bulk-update.ts b/packages/web/src/lib/bulk-update.tsnew file mode 100644index 00000000..31db8ddb--- /dev/null+++ b/packages/web/src/lib/bulk-update.ts@@ -0,0 +1,91 @@+/**+ * The decisions behind the page notice's "update everything on this tab" button: what the+ * notice claims is waiting, and what the user is told afterwards when only some of it landed.+ *+ * Kept pure and apart from the pages for the reason `todo-badges.ts` is: vitest runs node-only+ * here, so a rule that lives in a component is a rule nothing checks. The pages own the+ * requests; everything that decides what a number MEANS is here.+ */+import type { Todo } from "./todo-badges";++/**+ * The two numbers a notice may state. `added` is absent on the trails that cannot honestly+ * report one — see {@link Todo.breakdown}; the notice then names the upgradable count alone+ * rather than padding the sentence with a zero.+ */+export interface NoticeCounts {+ added: number | null;+ updated: number;+}++/**+ * What the notice says is waiting, read off the SAME raised to-do that lit the nav dot. Going+ * back to the underlying data for a second opinion is the one thing this must not do: a block+ * claiming three updates under a dot raised for four is a bug the user cannot resolve, and it is+ * exactly what two independent counts drift into.+ *+ * A trail with no breakdown reports its whole count as upgradable, which is what it is: a Skill+ * some Agent has fallen behind on and an Agent behind the defaults generation are both things+ * the Project already has an older form of.+ */+export function noticeCounts(todo: Todo): NoticeCounts {+ if (todo.breakdown === undefined) return { added: null, updated: todo.count };+ return { added: todo.breakdown.added, updated: todo.breakdown.updated };+}++/** How a bulk write went, in the terms the toast reports it in. */+export interface BulkOutcome {+ /** Everything landed. */+ allOk: boolean;+ /** How many targets were written successfully. */+ ok: number;+ /** The labels that failed, in the order they were attempted; empty when none did. */+ failed: string[];+}++/**+ * Zips a settled batch back onto the labels it was launched from, so a partial failure can name+ * WHICH targets are still behind.+ *+ * `Promise.allSettled` preserves input order, which is what makes the pairing sound — and the+ * reason the labels are passed in rather than recovered from the results, which carry no+ * identity of their own. Reporting only the first error (the precedent this replaces) leaves+ * the user knowing that something failed and not what: on a page whose whole point is acting on+ * everything at once, "3 of 5 updated" without the missing two is an unfinished sentence.+ */+export function bulkOutcome(+ labels: readonly string[],+ results: readonly PromiseSettledResult<unknown>[],+): BulkOutcome {+ const failed: string[] = [];+ let ok = 0;+ results.forEach((result, i) => {+ if (result.status === "fulfilled") ok += 1;+ // A label the caller did not supply for this index would be a programming error, not a+ // user-facing one; falling back to the index keeps the toast honest instead of blank.+ else failed.push(labels[i] ?? String(i));+ });+ return { allOk: failed.length === 0, ok, failed };+}++/**+ * How many failed targets the toast names before it stops listing.+ *+ * Naming them is the point of the partial-failure report, but a batch of twenty turns a+ * six-second toast into a wall of text nobody finishes reading. The overflow is reported as a+ * count rather than dropped silently: the reader still knows the list is not the whole of it.+ */+const MAX_NAMED_FAILURES = 8;++/** The failed labels as one string, capped. `+N` stands for the ones past the cap. */+export function failedList(failed: readonly string[], separator: string): string {+ if (failed.length <= MAX_NAMED_FAILURES) return failed.join(separator);+ const named = failed.slice(0, MAX_NAMED_FAILURES).join(separator);+ return `${named}${separator}+${failed.length - MAX_NAMED_FAILURES}`;+}++/** The first rejection's reason, for the error text appended to a partial-failure report. */+export function firstFailure(results: readonly PromiseSettledResult<unknown>[]): unknown {+ const rejected = results.find((r): r is PromiseRejectedResult => r.status === "rejected");+ return rejected?.reason;+}diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex 8b844168..d959b088 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -254,9 +254,10 @@ export const en: Strings = {},/**- * The three DISMISSIBLE badge trails (Skill library / model library / cost center) and the- * controls that clear them. One sentence per trail, carried unchanged from the dot's tooltip- * down to the notice on the page it leads to — the same discipline the kernel trail keeps.+ * The four DISMISSIBLE badge trails (Agents / Skill library / model library / cost center),+ * the controls that clear them and the control that acts on all of one at once. The tooltip+ * sentences below are what each dot says; the page notice restates the same count in its own+ * `changes*` wording, since a block that can act needs to say what it would act on.*/todo: {skillUpdates: (n: number) => (n === 1 ? "1 skill update" : `${n} skill updates`),@@ -266,9 +267,37 @@ export const en: Strings = {/** Combined anchor whose trails are not all updates — an unexpected error is not one. */pending: "Something needs attention",/** Clears an update the user has decided not to take now (a later one raises the badge again). */- dismiss: "Mark as handled",+ dismiss: "Dismiss",/** The cost center's wording: nothing is being updated there, the errors are simply read. */markRead: "Mark as read",++ // —— The page notice's own line and its bulk action (components/ui/todo-notice.tsx) ——++ /** The notice line where the trail can separate genuinely new things from upgradable ones (Models only). */+ changesWithAdded: (added: number, updated: number): string =>+ `Changes detected: ${added} new, ${updated} to upgrade`,+ /** The same line where the trail has only one honest count — no padded zero (Agents, Skills). */+ changesUpgradable: (updated: number): string => `Changes detected: ${updated} to upgrade`,+ /** Updates every object the notice counts, behind the page's own confirmation. */+ updateNow: "Update now",+ /** Heading of the confirmation's list of exactly what the batch would write to. */+ willTouch: "This will touch:",+ /** Bulk kernel update confirmation; the body reuses agent.kernelUpdateConfirmBody verbatim. */+ agentsConfirmTitle: (n: number): string => `Update the kernel of ${n} agent(s)`,+ /** Bulk Skill update confirmation. Same warning as the per-Skill confirm, with no single subject. */+ skillsConfirmTitle: (n: number): string => `Update ${n} skill(s)`,+ skillsConfirmBody:+ "Updating reinstalls the library copy over each agent's installed files — any local edits to the installed skill are lost. Export a backup first if you need them.",+ /** Bulk preset sync confirmation; the body reuses models.syncCatalogHint verbatim. */+ modelsConfirmTitle: (n: number): string => `Sync ${n} preset model(s)`,+ /** Every target of the batch was written. Counted in agents: both pages that use this+ * send one request per agent, and the partial-failure line below names agents too. */+ bulkDone: (ok: number): string => `${ok} agent${ok === 1 ? "" : "s"} updated`,+ /** Some targets were written and some were not — the failed ones are named, never just counted. */+ bulkPartial: (ok: number, failed: string): string =>+ `${ok} agent${ok === 1 ? "" : "s"} updated; these did not: ${failed}`,+ /** Separator between named targets in the two strings above. */+ listSeparator: ", ",},/** Desktop task-completion notifications (window unfocused; desktop-shell sessions only). */diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 564a85bc..738761b6 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -258,9 +258,10 @@ export const zh = {},/**- * The three DISMISSIBLE badge trails (Skill library / model library / cost center) and the- * controls that clear them. One sentence per trail, carried unchanged from the dot's tooltip- * down to the notice on the page it leads to — the same discipline the kernel trail keeps.+ * The four DISMISSIBLE badge trails (Agents / Skill library / model library / cost center),+ * the controls that clear them and the control that acts on all of one at once. The tooltip+ * sentences below are what each dot says; the page notice restates the same count in its own+ * `changes*` wording, since a block that can act needs to say what it would act on.*/todo: {skillUpdates: (n: number) => `${n} 个技能有更新`,@@ -269,9 +270,37 @@ export const zh = {/** Combined anchor whose trails are not all updates — an unexpected error is not one. */pending: "有待处理事项",/** Clears an update the user has decided not to take now (a later one raises the badge again). */- dismiss: "标记为已处理",+ dismiss: "忽略",/** The cost center's wording: nothing is being updated there, the errors are simply read. */markRead: "标记为已读",++ // —— The page notice's own line and its bulk action (components/ui/todo-notice.tsx) ——++ /** The notice line where the trail can separate genuinely new things from upgradable ones (Models only). */+ changesWithAdded: (added: number, updated: number): string =>+ `检测到变更:${added} 个新增,${updated} 个可升级`,+ /** The same line where the trail has only one honest count — no padded zero (Agents, Skills). */+ changesUpgradable: (updated: number): string => `检测到变更:${updated} 个可升级`,+ /** Updates every object the notice counts, behind the page's own confirmation. */+ updateNow: "现在升级",+ /** Heading of the confirmation's list of exactly what the batch would write to. */+ willTouch: "将影响以下对象:",+ /** Bulk kernel update confirmation; the body reuses agent.kernelUpdateConfirmBody verbatim. */+ agentsConfirmTitle: (n: number): string => `更新 ${n} 个 Agent 的内核`,+ /** Bulk Skill update confirmation. Same warning as the per-Skill confirm, with no single subject. */+ skillsConfirmTitle: (n: number): string => `更新 ${n} 个技能`,+ skillsConfirmBody:+ "更新会把库内当前副本重装到各 Agent,覆盖其已安装的文件——对已装技能的本地改动会丢失,如有需要请先导出备份。",+ /** Bulk preset sync confirmation; the body reuses models.syncCatalogHint verbatim. */+ modelsConfirmTitle: (n: number): string => `同步 ${n} 个预置模型`,+ /** Every target of the batch was written. Counted in Agents: both pages that use this+ * send one request per Agent, and the partial-failure line below names Agents too. */+ bulkDone: (ok: number): string => `已更新 ${ok} 个 Agent`,+ /** Some targets were written and some were not — the failed ones are named, never just counted. */+ bulkPartial: (ok: number, failed: string): string =>+ `已更新 ${ok} 个 Agent;以下未成功:${failed}`,+ /** Separator between named targets in the two strings above. */+ listSeparator: "、",},/** Desktop task-completion notifications (window unfocused; desktop-shell sessions only). */diff --git a/packages/web/src/lib/todo-badges.ts b/packages/web/src/lib/todo-badges.tsindex deb72c8d..d5af9198 100644--- a/packages/web/src/lib/todo-badges.ts+++ b/packages/web/src/lib/todo-badges.ts@@ -1,13 +1,14 @@/**- * The three DISMISSIBLE badge trails, and what a dismissal is stamped against.+ * The four DISMISSIBLE badge trails, and what a dismissal is stamped against.*- * `update-badges.ts` next door covers the two trails that clear themselves — a software- * release and an Agent kernel — where there is nothing to dismiss: the badge is gone the- * moment the update is installed. These three are different in one way that decides the- * whole design: the user may reasonably look at what is waiting and choose to leave it- * there. A model table deliberately kept off the catalog, a Skill deliberately pinned to an- * older copy, an error already read and understood — none of those should keep a red dot lit- * forever, and none of them changes any state a gate could read.+ * `update-badges.ts` next door covers the one trail that clears itself — a software release —+ * where there is nothing to dismiss: the badge is gone the moment the update is installed.+ * These four are different in one way that decides the whole design: the user may reasonably+ * look at what is waiting and choose to leave it there. A model table deliberately kept off+ * the catalog, a Skill deliberately pinned to an older copy, an Agent deliberately left on the+ * defaults generation it was tuned against, an error already read and understood — none of+ * those should keep a red dot lit forever, and none of them changes any state a gate could+ * read.** So each trail produces a **signature**: a string naming exactly WHAT is waiting. Dismissing* stores that string (`todo-dismissals.ts`); the badge is raised again only when what is@@ -26,8 +27,8 @@import type { AgentSummary, UsageErrorsPage } from "@prismshadow/penguin-server/api";import type { CatalogDelta } from "../features/models/catalog-sync";-/** The three trails, in sidebar order. Also the key each dismissal is stored under. */-export type TodoKey = "skills" | "models" | "errors";+/** The four trails, in sidebar order. Also the key each dismissal is stored under. */+export type TodoKey = "agents" | "skills" | "models" | "errors";/*** How a dismissal is compared against what is waiting now.@@ -41,6 +42,22 @@ export type TodoKey = "skills" | "models" | "errors";*/export type TodoMatch = "set" | "watermark";+/**+ * The two kinds of change a trail can be carrying, where it can tell them apart. Only the+ * Models trail can: the catalog is a list of entries, so an entry the table lacks is genuinely+ * NEW and one whose fields have moved is an upgrade, and `catalogDelta` already separates them+ * for the sync action itself. The other three cannot, and say so by leaving this absent rather+ * than reporting a zero — a Skill nobody has installed is not waiting for anyone, and an+ * Agent's kernel is never new, so "0 added" on those pages would be an answer to a question+ * that was never asked.+ */+export interface TodoBreakdown {+ /** Things the Project does not have at all yet. */+ added: number;+ /** Things it has an older form of. */+ updated: number;+}+/** What one trail has waiting. */export interface Todo {/** What is waiting, as one string: {@link items} joined by `,`. This is what a dismissal stores. */@@ -55,6 +72,40 @@ export interface Todo {count: number;/** Which containment rule {@link raisedTodo} applies to this trail. */match: TodoMatch;+ /**+ * The added/upgradable split where the trail can honestly make one, absent where it cannot+ * (see {@link TodoBreakdown}). It always sums to {@link count}, so the page notice and the+ * nav dot cannot report different totals.+ */+ breakdown?: TodoBreakdown;+}++/**+ * Agents in this Project whose config is behind the current defaults generation. The flag rides+ * along on the Project's Agent list, so this costs no request of its own.+ *+ * **The signature is the set of outdated Agent ids, not id-plus-generation**, which makes this+ * the one trail whose dismissal is coarser than the others: a later defaults generation does+ * NOT raise the dot again for an Agent already waved away, the way a later Skill version or a+ * different catalog entry does. That is a deliberate limit rather than an oversight — the+ * generation stamp a signature would need (`KERNEL_VERSION`) lives in core's `state/`+ * alongside `node:crypto`, and pulling it into the browser bundle to sharpen a dismissal is a+ * bad trade. What makes the coarse form safe is that dismissing here silences only the page+ * notice and the nav dot: every outdated Agent keeps its own capsule on the list card and its+ * own update button in settings, so nothing the user waved away becomes unreachable. A NEW+ * Agent falling behind still raises it, which is the case a per-Project mute would lose.+ *+ * Counted by Agent, because that is what the page lists and what the update acts on one of.+ */+export function kernelUpdateTodo(+ agents: ReadonlyArray<Pick<AgentSummary, "agentId" | "kernelOutdated">>,+): Todo | null {+ const items = agents+ .filter((a) => a.kernelOutdated)+ .map((a) => a.agentId)+ .sort();+ if (items.length === 0) return null;+ return { signature: items.join(","), items, count: items.length, match: "set" };}/**@@ -91,6 +142,10 @@ export function skillUpdateTodo(* The signature is the list of references that would change, so syncing part of the table by* hand and dismissing the rest behaves the way the user would expect, and a catalog release* touching a different model raises the badge again even when the count happens to match.+ *+ * The added/updated split is carried straight off the delta rather than recounted here, for the+ * same reason the count is: the notice on the page and the sync action behind its button have to+ * be describing one calculation, not two that agree today.*/export function presetUpdateTodo(delta: CatalogDelta): Todo | null {if (delta.refs.length === 0) return null;@@ -99,6 +154,7 @@ export function presetUpdateTodo(delta: CatalogDelta): Todo | null {items: [...delta.refs],count: delta.refs.length,match: "set",+ breakdown: { added: delta.added, updated: delta.updated },};}diff --git a/packages/web/src/lib/todo-dismissals.ts b/packages/web/src/lib/todo-dismissals.tsindex 92e8ef34..497f4d01 100644--- a/packages/web/src/lib/todo-dismissals.ts+++ b/packages/web/src/lib/todo-dismissals.ts@@ -1,5 +1,5 @@/**- * "I have dealt with this" markers for the three dismissible badge trails, per Project.+ * "I have dealt with this" markers for the four dismissible badge trails, per Project.** What is stored is not a hidden flag but the SIGNATURE the trail carried when it was* dismissed (`todo-badges.ts` explains why): the badge stays down while what is waiting is@@ -36,8 +36,16 @@ export type TodoDismissals = Partial<Record<TodoKey, string>>;/** Every Project's markers, keyed by Project id — the shape held under {@link TODO_PREFS_KEY}. */export type TodoDismissMap = Record<string, TodoDismissals>;-/** The three keys, listed once so parsing cannot drift from the union. */-const TODO_KEYS: readonly TodoKey[] = ["skills", "models", "errors"];+/**+ * The four keys, listed once so parsing cannot drift from the union.+ *+ * `agents` is the newest of them, and a stored map written before it existed simply has no such+ * key: {@link parseTodoDismissMap} reads that as "nothing dismissed", which shows a dot the user+ * can clear again. That is the same direction every other malformed case degrades in, so the+ * markers already on disk need no migration and nothing is lost by an older client writing the+ * map back without it.+ */+const TODO_KEYS: readonly TodoKey[] = ["agents", "skills", "models", "errors"];const EMPTY: TodoDismissals = {};diff --git a/packages/web/src/lib/update-badges.ts b/packages/web/src/lib/update-badges.tsindex 621aed18..7e7cafef 100644--- a/packages/web/src/lib/update-badges.ts+++ b/packages/web/src/lib/update-badges.ts@@ -1,12 +1,12 @@/*** What raises an update notification badge, and what the anchor carrying it says.*- * Two independent trails end in two different controls, so they are two independent gates:- * a *software* update, actionable in the sidebar user menu, and an *Agent kernel* update,- * actionable on the Agent settings page. The outermost chrome (the mobile menu button) shows- * one dot for either — and, since `todo-badges.ts` joined them, for the three dismissible- * trails as well; `badgeNote` at the bottom is what every anchor covering more than one of- * them speaks through.+ * One gate lives here: the *software* update, actionable in the sidebar user menu. The other+ * four trails are all dismissible and live in `todo-badges.ts` — the Agent kernel one moved+ * there when its page grew a notice with a way down, since a gate that can be waved away has to+ * produce a signature and not just a boolean. The outermost chrome (the mobile menu button)+ * shows one dot for any of the five; `badgeNote` at the bottom is what every anchor covering+ * more than one of them speaks through.** Every gate here is written as "is there a control the user can reach": a badge over a path* with nothing actionable at the end of it is worse than no badge. That is why the software@@ -17,11 +17,7 @@* Pure decisions only (vitest runs node-only here, so nothing renders) — `use-update-badges.ts`* wires them to the live stores and turns a note into localized copy.*/-import type {- AgentSummary,- DesktopUpdateStatus,- UpdateCheckResponse,-} from "@prismshadow/penguin-server/api";+import type { DesktopUpdateStatus, UpdateCheckResponse } from "@prismshadow/penguin-server/api";import { clientUpdateRow } from "./desktop-update";/** A software update the running mode can act on, and the version the offer names. */@@ -68,20 +64,10 @@ export function softwareUpdate(input: SoftwareUpdateInput): SoftwareUpdate | nul}/**- * Whether any Agent in the current Project carries an outdated kernel — the gate for the- * Agents nav entries, which lead to the list where the individual cards say which ones. The- * flag rides along on the Project's Agent list, so this costs no request of its own.- */-export function anyKernelOutdated(- agents: ReadonlyArray<Pick<AgentSummary, "kernelOutdated">>,-): boolean {- return agents.some((a) => a.kernelOutdated);-}--/**- * One thing a dot can stand for. The first two are the self-clearing trails above; the last- * three are the dismissible ones in `todo-badges.ts`, which carry a count because the anchors- * that name them have room to say how many.+ * One thing a dot can stand for. The first is the self-clearing trail above; the rest are the+ * dismissible ones in `todo-badges.ts`. Three of those carry a count because the anchors that+ * name them have room to say how many; `kernel` does not, because the Agents nav entry says+ * "kernel update available" without a number and always has.*/export type BadgeSource =| SoftwareUpdatediff --git a/packages/web/src/lib/use-update-badges.ts b/packages/web/src/lib/use-update-badges.tsindex 451e3fb5..36d3e72b 100644--- a/packages/web/src/lib/use-update-badges.ts+++ b/packages/web/src/lib/use-update-badges.ts@@ -23,9 +23,15 @@ import { S } from "./strings";import { offersClientUpdate } from "./desktop-update";import { refreshDesktopUpdate, useDesktopUpdate } from "./use-desktop-update";import { useVersionInfo } from "./use-version-info";-import { anyKernelOutdated, badgeNote, softwareUpdate } from "./update-badges";+import { badgeNote, softwareUpdate } from "./update-badges";import type { BadgeSource, SoftwareUpdate, UpdateBadgeNote } from "./update-badges";-import { presetUpdateTodo, raisedTodo, skillUpdateTodo, unexpectedErrorTodo } from "./todo-badges";+import {+ kernelUpdateTodo,+ presetUpdateTodo,+ raisedTodo,+ skillUpdateTodo,+ unexpectedErrorTodo,+} from "./todo-badges";import type { Todo, TodoKey } from "./todo-badges";import { useTodoDismissals } from "./todo-dismissals";import { useProjectTodos } from "./use-project-todos";@@ -75,7 +81,7 @@ export function useUpdateBadges(eager = false): UpdateBadges {update,clientStatus: status,});- const kernel = anyKernelOutdated(agents);+// Memoized on the cached response's identity: this walks the whole built-in catalog, and the// hook re-runs on every render of the pages that read it (a keystroke in the model search box).const presetTodo = useMemo(@@ -86,6 +92,9 @@ export function useUpdateBadges(eager = false): UpdateBadges {// moment later, on a trail the user had already dealt with, is worse than a late dot.const raise = (todo: Todo | null, key: TodoKey): Todo | null =>dismissed === null ? null : raisedTodo(todo, dismissed[key] ?? null);+ // The kernel trail is dismissible like the other three: an Agent can be deliberately left on+ // the generation it was tuned against, and the page notice that says so needs a way down.+ const kernelTodo = raise(kernelUpdateTodo(agents), "agents");const skills = raise(skillUpdateTodo(agents), "skills");const models = raise(presetTodo, "models");const errors = raise(@@ -97,13 +106,13 @@ export function useUpdateBadges(eager = false): UpdateBadges {// the per-route map below is what each individual anchor says.const sources: BadgeSource[] = [];if (software !== null) sources.push(software);- if (kernel) sources.push({ kind: "kernel" });+ if (kernelTodo !== null) sources.push({ kind: "kernel" });if (skills !== null) sources.push({ kind: "skills", count: skills.count });if (models !== null) sources.push({ kind: "models", count: models.count });if (errors !== null) sources.push({ kind: "errors", count: errors.count });const navNotes: Partial<Record<BadgedRoute, string>> = {};- if (kernel) navNotes["/agents"] = S.agent.kernelOutdatedHint;+ if (kernelTodo !== null) navNotes["/agents"] = S.agent.kernelOutdatedHint;if (skills !== null) navNotes["/skills"] = S.todo.skillUpdates(skills.count);if (models !== null) navNotes["/models"] = S.todo.presetUpdates(models.count);if (errors !== null) navNotes["/usage"] = S.todo.unexpectedErrors(errors.count);@@ -113,6 +122,7 @@ export function useUpdateBadges(eager = false): UpdateBadges {softwareNote: software === null ? null : noteText(software),navNotes,todos: {+ ...(kernelTodo !== null ? { agents: kernelTodo } : {}),...(skills !== null ? { skills } : {}),...(models !== null ? { models } : {}),...(errors !== null ? { errors } : {}),diff --git a/packages/web/test/catalog-sync.test.ts b/packages/web/test/catalog-sync.test.tsindex 24041110..2b4ecb11 100644--- a/packages/web/test/catalog-sync.test.ts+++ b/packages/web/test/catalog-sync.test.ts@@ -10,6 +10,8 @@import { describe, expect, it } from "vitest";import type { ModelsResponse } from "@prismshadow/penguin-server/api";import { catalogDelta, syncRowsWithCatalog } from "../src/features/models/catalog-sync";+import { presetUpdateTodo } from "../src/lib/todo-badges";+import { noticeCounts } from "../src/lib/bulk-update";import { toRow } from "../src/features/models/models-page";import type { RowState } from "../src/features/models/models-page";@@ -264,4 +266,21 @@ describe("catalogDelta", () => {expect([delta.added, delta.updated]).toEqual([merged.added, merged.updated]);expect(delta.refs.length).toBeGreaterThan(30);});++ /**+ * The page notice states "N new, M to upgrade" above a button that runs the merge. Those two+ * numbers must be the merge's own, carried through the gate — not a third opinion computed for+ * the block. This walks the same chain the page does: delta -> raised to-do -> notice counts.+ */+ it("hands the merge's own two numbers all the way to the page notice", () => {+ const table = [+ makeDto({ provider: "deepseek", modelId: "deepseek-v4-pro", contextWindow: 1000000 }),+ makeDto({ provider: "custom", modelId: "my-own", contextWindow: 8192 }),+ ];+ const merged = syncRowsWithCatalog(table.map(toRow), PRESET);+ const todo = presetUpdateTodo(catalogDelta(table, PRESET))!;+ expect(noticeCounts(todo)).toEqual({ added: merged.added, updated: merged.updated });+ // And the dot the notice sits under is raised from the same total.+ expect((noticeCounts(todo).added ?? 0) + noticeCounts(todo).updated).toBe(todo.count);+ });});diff --git a/packages/web/test/skill-outdated.test.ts b/packages/web/test/skill-outdated.test.tsindex fef21e72..0c15b70b 100644--- a/packages/web/test/skill-outdated.test.ts+++ b/packages/web/test/skill-outdated.test.ts@@ -1,9 +1,10 @@/**- * outdatedAgentIds unit tests: the skill-library update reminder's data source — Agents- * whose installed copy is strictly older than the library's version.+ * The Skills page's two update questions: `outdatedAgentIds`, the per-Skill reminder's data+ * source — Agents whose installed copy is strictly older than the library's version — and+ * `skillUpdatePlan`, the page notice's "update all of them" version of the same question.*/import { describe, expect, it } from "vitest";-import { outdatedAgentIds } from "../src/features/skills/skills-page";+import { outdatedAgentIds, skillUpdatePlan } from "../src/features/skills/skills-page";import type { InstalledMap } from "../src/features/skills/skills-page";const installed: InstalledMap = new Map([@@ -39,3 +40,50 @@ describe("outdatedAgentIds", () => {expect(outdatedAgentIds(AGENTS, installed, "agenthub-dev", 1)).toEqual([]);});});++describe("skillUpdatePlan", () => {+ /** Just the two fields the plan reads (it takes a Pick, so the fixture can be one too). */+ const agent = (agentId: string, ...updates: Array<{ name: string; version: number }>) => ({+ agentId,+ skillUpdates: updates,+ });++ it("is empty when no Agent is behind, so the notice has nothing to offer", () => {+ expect(skillUpdatePlan([agent("a"), agent("b")])).toEqual({ perAgent: [], skills: [] });+ });++ it("sends one request per Agent, carrying every Skill that Agent is behind on", () => {+ // The install endpoint takes a list, and an Agent behind on two Skills is one overwrite of+ // its skills directory either way.+ expect(+ skillUpdatePlan([+ agent("alpha", { name: "web-design", version: 3 }, { name: "vllm", version: 2 }),+ agent("beta"),+ agent("gamma", { name: "web-design", version: 3 }),+ ]),+ ).toEqual({+ perAgent: [+ { agentId: "alpha", names: ["vllm", "web-design"] },+ { agentId: "gamma", names: ["web-design"] },+ ],+ skills: ["vllm", "web-design"],+ });+ });++ it("counts distinct Skills, matching what the notice above the button says", () => {+ // The gate counts by Skill because the page lists the library once. The plan's `skills` is+ // what the confirmation lists, so the two must be the same number or the dialog would+ // contradict the block that opened it.+ const plan = skillUpdatePlan([+ agent("alpha", { name: "shared", version: 2 }),+ agent("beta", { name: "shared", version: 2 }),+ agent("gamma", { name: "shared", version: 2 }),+ ]);+ expect(plan.skills).toEqual(["shared"]);+ expect(plan.perAgent).toHaveLength(3);+ });++ it("tolerates an Agent list that predates the skillUpdates field", () => {+ expect(skillUpdatePlan([{ agentId: "alpha", skillUpdates: undefined! }]).perAgent).toEqual([]);+ });+});diff --git a/packages/web/test/todo-badges.test.ts b/packages/web/test/todo-badges.test.tsindex d6dbce41..19c03560 100644--- a/packages/web/test/todo-badges.test.ts+++ b/packages/web/test/todo-badges.test.ts@@ -1,5 +1,5 @@/**- * Gate + dismissal unit tests for the three DISMISSIBLE badge trails.+ * Gate + dismissal unit tests for the four DISMISSIBLE badge trails.** The rule every case here defends is the one that makes a dismissal safe: what the badge is* dismissed against is WHAT is waiting, not the fact that something was. So dismissing hides@@ -10,6 +10,7 @@import { describe, expect, it } from "vitest";import type { AgentSummary, UsageErrorsPage } from "@prismshadow/penguin-server/api";import {+ kernelUpdateTodo,presetUpdateTodo,raisedTodo,skillUpdateTodo,@@ -56,6 +57,10 @@ describe("skillUpdateTodo", () => {});});+ it("reports no added/upgradable split: an uninstalled Skill is not waiting for anyone", () => {+ expect(skillUpdateTodo([agent({ name: "a", version: 2 })])!.breakdown).toBeUndefined();+ });+it("is order-independent, so two loads of the same state dismiss alike", () => {const a = skillUpdateTodo([agent({ name: "b", version: 1 }, { name: "a", version: 2 })]);const b = skillUpdateTodo([agent({ name: "a", version: 2 }), agent({ name: "b", version: 1 })]);@@ -93,9 +98,18 @@ describe("presetUpdateTodo", () => {items: ["anthropic/claude-opus-5", "openai/gpt-5"],count: 2,match: "set",+ breakdown: { added: 1, updated: 1 },});});+ it("carries the delta's own added/updated split, and it always sums to the count", () => {+ // The page notice states these two numbers under a dot raised from `count`. If the split+ // could disagree with the total, the block and the badge would be describing different work.+ const todo = presetUpdateTodo({ added: 2, updated: 3, refs: ["a", "b", "c", "d", "e"] })!;+ expect(todo.breakdown).toEqual({ added: 2, updated: 3 });+ expect(todo.breakdown!.added + todo.breakdown!.updated).toBe(todo.count);+ });+it("separates two deltas of the same size, so a different model still raises the dot", () => {const first = presetUpdateTodo({ added: 1, updated: 0, refs: ["a/one"] });const second = presetUpdateTodo({ added: 1, updated: 0, refs: ["b/two"] });@@ -104,6 +118,78 @@ describe("presetUpdateTodo", () => {});});+describe("kernelUpdateTodo", () => {+ it("is null when every Agent is on the current defaults generation", () => {+ expect(+ kernelUpdateTodo([+ { agentId: "a", kernelOutdated: false },+ { agentId: "b", kernelOutdated: false },+ ]),+ ).toBeNull();+ });++ it("is null for an empty or not-yet-loaded Agent list", () => {+ expect(kernelUpdateTodo([])).toBeNull();+ });++ it("names the outdated Agents and counts them, ignoring the current ones", () => {+ expect(+ kernelUpdateTodo([+ { agentId: "beta", kernelOutdated: true },+ { agentId: "alpha", kernelOutdated: true },+ { agentId: "gamma", kernelOutdated: false },+ ]),+ ).toEqual({+ signature: "alpha,beta",+ items: ["alpha", "beta"],+ count: 2,+ match: "set",+ });+ });++ it("is order-independent, so two loads of the same state dismiss alike", () => {+ const a = kernelUpdateTodo([+ { agentId: "b", kernelOutdated: true },+ { agentId: "a", kernelOutdated: true },+ ]);+ const b = kernelUpdateTodo([+ { agentId: "a", kernelOutdated: true },+ { agentId: "b", kernelOutdated: true },+ ]);+ expect(a).toEqual(b);+ });++ it("reports no added/upgradable split: an Agent's kernel is never new", () => {+ // The notice on that page shows one count for this reason. A `breakdown: {added: 0}` would+ // be an answer to a question the page never asks.+ expect(kernelUpdateTodo([{ agentId: "a", kernelOutdated: true }])!.breakdown).toBeUndefined();+ });++ it("stays down for the Agents already waved away, and comes back up for a new one", () => {+ const first = kernelUpdateTodo([{ agentId: "alpha", kernelOutdated: true }])!;+ expect(raisedTodo(first, first.signature)).toBeNull();+ const later = kernelUpdateTodo([+ { agentId: "alpha", kernelOutdated: true },+ { agentId: "beta", kernelOutdated: true },+ ])!;+ expect(raisedTodo(later, first.signature)).toBe(later);+ });++ it("stays down when a dismissed Agent is updated and the rest of the batch is not", () => {+ // Containment, not equality: dealing with one of two dismissed Agents must not resurrect+ // the dot over the other, which is the one the user waved away.+ const both = kernelUpdateTodo([+ { agentId: "alpha", kernelOutdated: true },+ { agentId: "beta", kernelOutdated: true },+ ])!;+ const after = kernelUpdateTodo([+ { agentId: "alpha", kernelOutdated: false },+ { agentId: "beta", kernelOutdated: true },+ ])!;+ expect(raisedTodo(after, both.signature)).toBeNull();+ });+});+describe("unexpectedErrorTodo", () => {it("is null on an empty window", () => {expect(unexpectedErrorTodo(errorPage(0))).toBeNull();diff --git a/packages/web/test/todo-notice.test.ts b/packages/web/test/todo-notice.test.tsnew file mode 100644index 00000000..30505d48--- /dev/null+++ b/packages/web/test/todo-notice.test.ts@@ -0,0 +1,220 @@+/**+ * The shared page notice (src/components/ui/todo-notice.tsx) and the decisions behind its+ * bulk-update button (src/lib/bulk-update.ts).+ *+ * Three rules are defended here, and each is a rule rather than a preference because breaking it+ * produces a screen the user cannot reason about:+ *+ * 1. **The counts come off the raised to-do**, never a second calculation. A block claiming three+ * updates under a dot raised for four is unresolvable from the outside.+ * 2. **The button opens a confirmation; it does not write.** A bulk overwrite is consented to+ * before it runs, and every one of these pages already asks before overwriting a single+ * object.+ * 3. **A partial failure names the targets that failed.** On a control whose entire point is+ * "all of them at once", a count with no names leaves the user re-checking every row by hand.+ *+ * Rules 2 and 3's first half are source scans over the real JSX rather than render assertions —+ * vitest runs node-only here, so the thing that decays is a call site, not a component's output.+ */+import { describe, expect, it } from "vitest";+import { readdirSync, readFileSync, statSync } from "node:fs";+import { join, sep } from "node:path";+import { fileURLToPath } from "node:url";+import ts from "typescript";+import { bulkOutcome, failedList, firstFailure, noticeCounts } from "../src/lib/bulk-update";+import type { Todo } from "../src/lib/todo-badges";++const SRC = fileURLToPath(new URL("../src", import.meta.url));++function tsxFiles(dir = SRC, out: string[] = []): string[] {+ for (const name of readdirSync(dir)) {+ const path = join(dir, name);+ if (statSync(path).isDirectory()) tsxFiles(path, out);+ else if (name.endsWith(".tsx")) out.push(path);+ }+ return out;+}++/** Every `<TodoNotice …>` in the app, as "relative/path" plus its attributes by name. */+function noticeSites(): { file: string; attrs: Map<string, string>; source: string }[] {+ const sites: { file: string; attrs: Map<string, string>; source: string }[] = [];+ for (const path of tsxFiles()) {+ const rel = path.slice(SRC.length + 1).replaceAll(sep, "/");+ const source = readFileSync(path, "utf8");+ const sf = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);+ const visit = (node: ts.Node): void => {+ const opening = ts.isJsxSelfClosingElement(node)+ ? node+ : ts.isJsxElement(node)+ ? node.openingElement+ : null;+ if (opening !== null && opening.tagName.getText() === "TodoNotice") {+ const attrs = new Map<string, string>();+ for (const attr of opening.attributes.properties) {+ if (!ts.isJsxAttribute(attr)) continue;+ attrs.set(attr.name.getText(), attr.initializer?.getText() ?? "");+ }+ sites.push({ file: rel, attrs, source });+ }+ ts.forEachChild(node, visit);+ };+ visit(sf);+ }+ // The component's own definition is not a call site.+ return sites.filter((s) => s.file !== "components/ui/todo-notice.tsx");+}++describe("the notice block is the one shape on every page that has one", () => {+ const sites = noticeSites();++ it("is placed on all four dismissible trails and nowhere else", () => {+ expect(sites.map((s) => s.file).sort()).toEqual([+ "features/agents/agents-page.tsx",+ "features/models/models-page.tsx",+ "features/skills/skills-page.tsx",+ "features/usage/usage-page.tsx",+ ]);+ });++ it("never offers a bulk action without labelling it, or a label without an action", () => {+ for (const { file, attrs } of sites) {+ expect(attrs.has("actionLabel"), `${file} action label and handler must agree`).toBe(+ attrs.has("onAction"),+ );+ }+ });++ it("only the cost center omits the bulk action — nothing there can be updated", () => {+ const withAction = sites.filter((s) => s.attrs.has("onAction")).map((s) => s.file);+ expect(withAction.sort()).toEqual([+ "features/agents/agents-page.tsx",+ "features/models/models-page.tsx",+ "features/skills/skills-page.tsx",+ ]);+ });+});++describe("the bulk button confirms before it writes", () => {+ const withAction = noticeSites().filter((s) => s.attrs.has("onAction"));++ it("has a handler that opens something rather than calling the API", () => {+ for (const { file, attrs } of withAction) {+ const handler = attrs.get("onAction") ?? "";+ expect(handler, `${file}'s onAction must not write; it opens the confirmation`).not.toMatch(+ /\bapi\./,+ );+ expect(handler, `${file}'s onAction must not await a write`).not.toMatch(/\bawait\b/);+ }+ });++ it("flips a state that gates the batch's own ConfirmModal", () => {+ // Not "the file contains a ConfirmModal somewhere" — every one of these pages already had+ // one (a delete confirm, a group confirm) before this block existed, so that assertion is+ // true whether or not the batch confirms. What has to hold is the LINK: the state the+ // button sets is the state the dialog is rendered behind.+ for (const { file, attrs, source } of withAction) {+ const setter = /\bset([A-Z]\w*)\s*\(/.exec(attrs.get("onAction") ?? "");+ expect(+ setter,+ `${file}'s onAction must open the confirmation by setting state`,+ ).not.toBeNull();+ const state = setter![1]!.charAt(0).toLowerCase() + setter![1]!.slice(1);+ const guarded = new RegExp(`${state}[^\\n]*&&[\\s\\S]{0,400}?<ConfirmModal`);+ expect(+ guarded.test(source),+ `${file} must render its batch ConfirmModal behind ${state}`,+ ).toBe(true);+ }+ });+});++describe("noticeCounts", () => {+ const base = { signature: "s", items: ["s"], match: "set" } as const;++ it("reports the whole count as upgradable where the trail has no honest split", () => {+ // Agents and Skills: an Agent's kernel is never new, and a Skill nobody installed is not+ // waiting for anyone. The notice then states one number instead of padding with a zero.+ const todo: Todo = { ...base, items: ["a", "b", "c"], count: 3 };+ expect(noticeCounts(todo)).toEqual({ added: null, updated: 3 });+ });++ it("splits added from upgradable where the trail can tell them apart", () => {+ const todo: Todo = {+ ...base,+ items: ["a", "b"],+ count: 2,+ breakdown: { added: 1, updated: 1 },+ };+ expect(noticeCounts(todo)).toEqual({ added: 1, updated: 1 });+ });++ it("never reports more than the gate raised the dot for", () => {+ const todo: Todo = {+ ...base,+ items: ["a", "b"],+ count: 2,+ breakdown: { added: 2, updated: 0 },+ };+ const { added, updated } = noticeCounts(todo);+ expect((added ?? 0) + updated).toBe(todo.count);+ });+});++describe("bulkOutcome", () => {+ const ok = { status: "fulfilled", value: undefined } as const;+ const bad = (reason: string) => ({ status: "rejected", reason }) as const;++ it("is clean when every target took the write", () => {+ expect(bulkOutcome(["alpha", "beta"], [ok, ok])).toEqual({ allOk: true, ok: 2, failed: [] });+ });++ it("names the targets that failed, not just how many", () => {+ expect(bulkOutcome(["alpha", "beta", "gamma"], [ok, bad("boom"), bad("nope")])).toEqual({+ allOk: false,+ ok: 1,+ failed: ["beta", "gamma"],+ });+ });++ it("pairs labels to results by position, which allSettled preserves", () => {+ expect(bulkOutcome(["alpha", "beta"], [bad("boom"), ok]).failed).toEqual(["alpha"]);+ });++ it("stays honest when a label is missing rather than reporting a blank target", () => {+ expect(bulkOutcome([], [bad("boom")]).failed).toEqual(["0"]);+ });++ it("is clean on an empty batch, so a no-op cannot report a failure", () => {+ expect(bulkOutcome([], [])).toEqual({ allOk: true, ok: 0, failed: [] });+ });+});++describe("failedList", () => {+ const names = (n: number) => Array.from({ length: n }, (_, i) => `a${i}`);++ it("names them all while the list is short enough to read", () => {+ expect(failedList(names(8), ", ")).toBe("a0, a1, a2, a3, a4, a5, a6, a7");+ });++ it("reports the overflow as a count rather than dropping it silently", () => {+ // A batch of twenty must not turn a six-second toast into a wall of text, but the reader+ // still has to know the names shown are not the whole of it.+ expect(failedList(names(11), ", ")).toBe("a0, a1, a2, a3, a4, a5, a6, a7, +3");+ });+});++describe("firstFailure", () => {+ it("surfaces the first rejection, for the error text beside the named targets", () => {+ expect(+ firstFailure([+ { status: "fulfilled", value: 1 },+ { status: "rejected", reason: "first" },+ { status: "rejected", reason: "second" },+ ]),+ ).toBe("first");+ });++ it("is undefined when nothing failed", () => {+ expect(firstFailure([{ status: "fulfilled", value: 1 }])).toBeUndefined();+ });+});diff --git a/packages/web/test/update-badges.test.ts b/packages/web/test/update-badges.test.tsindex 73fe6720..a7402bd2 100644--- a/packages/web/test/update-badges.test.ts+++ b/packages/web/test/update-badges.test.ts@@ -3,15 +3,14 @@* several trails says. The rule every case here defends is that a dot must end in a control the user* can actually reach — so the release gate is closed wherever the sidebar does not offer the* release row, a fail-soft check raises nothing, and a download still in flight is not a badge.+ *+ * The Agent-kernel gate used to live here as `anyKernelOutdated`. It moved to `todo-badges.ts`+ * (and is covered there, as `kernelUpdateTodo`) when its page grew a notice with a way down: a+ * gate that can be dismissed has to name WHAT is waiting, not just whether something is.*/import { describe, expect, it } from "vitest";import type { DesktopUpdateStatus, UpdateCheckResponse } from "@prismshadow/penguin-server/api";-import {- anyKernelOutdated,- badgeNote,- releaseUpdate,- softwareUpdate,-} from "../src/lib/update-badges";+import { badgeNote, releaseUpdate, softwareUpdate } from "../src/lib/update-badges";function check(overrides: Partial<UpdateCheckResponse>): UpdateCheckResponse {return {@@ -142,20 +141,6 @@ describe("softwareUpdate", () => {});});-describe("anyKernelOutdated", () => {- it("is true when at least one Agent is behind", () => {- expect(anyKernelOutdated([{ kernelOutdated: false }, { kernelOutdated: true }])).toBe(true);- });-- it("is false when every Agent is current", () => {- expect(anyKernelOutdated([{ kernelOutdated: false }, { kernelOutdated: false }])).toBe(false);- });-- it("is false for an empty or not-yet-loaded Agent list", () => {- expect(anyKernelOutdated([])).toBe(false);- });-});-describe("badgeNote", () => {const release = { kind: "release", version: "0.2.0" } as const;const kernel = { kind: "kernel" } as const;