A local-first multi-agent app development platform, built on PenguinHarness
Update badges lead from the outermost menu to the update control (#472)
Yaowei Zheng6446684a9704
diff --git a/changelog/unreleased/2026-08-26-update-badges.md b/changelog/unreleased/2026-08-26-update-badges.mdnew file mode 100644index 00000000..4d73ccfb--- /dev/null+++ b/changelog/unreleased/2026-08-26-update-badges.md@@ -0,0 +1,59 @@+# Update notification badges lead from the outermost menu to the update itself++- **Date:** 2026-08-26+- **Type:** feature+- **Scope:** `web`+- **PR:** [#472](https://github.com/Prism-Shadow/penguin-harness/pull/472)++[中文版](2026-08-26-update-badges.zh.md)++A phone-style red dot now marks the chrome whenever something is updatable, and every dot leads+down an unbroken path to the control that performs the update. Two trails carry one: a+**software** update — a newer release for a browser install, or a downloaded client build for+the desktop shell's own window — and an **Agent kernel** update for any Agent in the current+Project. The mobile menu button carries a dot for either.++## The trails++- **Software** — the `<md` top bar's menu button, the collapsed rail's avatar and the pinned+ sidebar's avatar, ending at the user menu's update row and its update dialog.+- **Agent kernel** — the same menu button, the pinned sidebar's Agents entry, the collapsed+ rail's Agents icon, the Agents list card of each outdated Agent — which carries a pale-red+ "Kernel update needed" capsule in the version badge's own shape, itself the control that+ opens the right settings page — then that page's Overview tab and the enabled "update+ kernel" button in the Kernel section. The badge clears with the config refresh the update+ already performs.++The session list's conversation groups are deliberately left unbadged: that list is about+conversations, not Agent configuration, and a dot there would lead to no action.++## Details++- `components/ui/update-dot.tsx` is the one place the badge colours are written — the dot's and+ the Agents-card capsule's — and every mark in the feature renders through it, the sidebar+ avatar's included, which previously drew its own accent-coloured dot. A notification badge is+ not a status tone, so the colours live there rather than in `lib/tone.ts`, whose five tones+ each judge a thing's state; the component's header states that and records the measured+ contrast on every surface a mark lands on, including the light-theme surfaces where the pale+ red the marks are set in falls under WCAG 1.4.11's 3 : 1 and why that is accepted. A dot+ anchors to its control's full box — the row, tab or button — never to the label text's width:+ a full-width row carries it at the right edge, vertically centred, while a button or a tab+ takes the top-right corner, straddling the border where that corner is visible and pulled+ inside the padding where an ancestor clips it. Each dot is `aria-hidden` and its anchor names+ what is updatable in its `title` and accessible name.+- The update check runs once per browser session from the app layout, so a badge is present on a+ fresh load; it was previously activated by opening the sidebar's user menu. The module-level+ cache keeps it to one request, the check stays fail-soft, and `PENGUIN_UPDATE_CHECK=off`+ produces no dot and no notice.+- A badge only appears where the running mode offers a control to act on. Desktop mode hides the+ server-release row and updates through the shell instead, so the avatar there marks a+ downloaded client build waiting to install rather than a server release; a client download+ still in flight is not badged, since there is nothing to act on until it lands.+- The gates are pure functions in `lib/update-badges.ts` with unit tests: the release gate+ (including the disabled and failed-lookup paths, and an available-but-unnamed release), the+ client-build gate over every shell state, "any Agent outdated", and the combined wording.+- `Tabs` gained an optional per-tab badge, which folds its sentence into the tab's tooltip and+ accessible name and sits inside the button's padding so the tab strip's vertical clip cannot+ cut it.+- Two new bilingual strings: one for the anchor that covers both trails at once and must not+ claim to be either, and the Agents-card capsule's label.diff --git a/changelog/unreleased/2026-08-26-update-badges.zh.md b/changelog/unreleased/2026-08-26-update-badges.zh.mdnew file mode 100644index 00000000..da1077bd--- /dev/null+++ b/changelog/unreleased/2026-08-26-update-badges.zh.md@@ -0,0 +1,26 @@+# 更新提醒红点从最外层菜单一路指向更新入口++- **Date:** 2026-08-26+- **Type:** feature+- **Scope:** `web`+- **PR:** [#472](https://github.com/Prism-Shadow/penguin-harness/pull/472)++[English](2026-08-26-update-badges.md)++有东西可更新时,外层界面会出现手机式的红点,且每个红点都沿一条不断裂的路径指向真正执行更新的控件。两条路径各自触发红点:**软件**更新——浏览器安装看新版本发布,桌面端外壳自己的窗口看已下载的客户端构建——以及当前 Project 中任一 Agent 的**内核**更新。移动端的菜单按钮对两者都显示同一个红点。++## 两条路径++- **软件**——`<md` 顶栏的菜单按钮、收起态侧栏的头像、固定侧栏的头像,终点是用户菜单里的更新入口及其更新对话框。+- **Agent 内核**——同一个菜单按钮、固定侧栏的「智能体」入口、收起态侧栏的智能体图标、Agents 列表中每个内核落后的卡片——卡片上是一枚与版本徽标同形的淡红「内核需要更新」胶囊,其本身就是打开对应设置页的控件——然后是该设置页的概览标签页与内核小节中处于可用状态的「更新内核」按钮。更新本就会刷新配置,红点随之消失。++会话列表的对话分组刻意不加红点:那份列表面向对话而非 Agent 配置,在那里加红点会指向一条无事可做的路径。++## 细节++- `components/ui/update-dot.tsx` 是红点与卡片胶囊的颜色唯一被写下的地方,本功能的每个标记都经由它渲染——包括侧栏头像原先自绘的那个主题色标记。通知红点不是状态语义色,因此颜色不放进 `lib/tone.ts`(其五种语义色各自是对事物状态的判断);组件头部说明了这一点,并记录了标记会落在的各个表面上实测的对比度,其中包括浅色主题下这枚淡红低于 WCAG 1.4.11 所要求的 3 : 1、以及为何接受这一点。红点一律锚定在其控件的整个盒子上——整行、标签页或按钮——而不是按文字宽度挂在词尾:整行的红点靠右边缘、纵向居中;按钮与标签页的红点落在右上角,边角可见时压在描边上,被祖先裁剪时则收进内边距。红点本身 `aria-hidden`,由其锚点在 `title` 与可访问名称中说明什么可更新。+- 更新检查改为在 App 布局挂载时按浏览器会话执行一次,因此刚打开页面就能看到红点;此前要打开侧栏用户菜单才会触发。模块级缓存保证仍只有一次请求,检查依旧 fail-soft,`PENGUIN_UPDATE_CHECK=off` 时既无红点也无提示。+- 只有当前运行模式确实提供可操作的控件时才出现红点。桌面模式隐藏服务端发布入口、改由外壳更新,因此那里的头像标记的是已下载待安装的客户端构建而非服务端发布;仍在下载中的客户端构建不标记,因为在它落地前用户无事可做。+- 判定逻辑是 `lib/update-badges.ts` 中的纯函数,并附单元测试:发布判定(含关闭检查与查询失败两条路径,以及「可用但未命名版本」的情形)、覆盖外壳全部状态的客户端构建判定、「是否存在内核落后的 Agent」,以及合并措辞。+- `Tabs` 新增可选的单标签页红点,会把说明折入该标签页的 tooltip 与可访问名称,并置于按钮内边距之内,使标签栏的纵向裁剪不会切掉它。+- 新增两条双语文案:一条用于同时覆盖两条路径的锚点——它不能声称自己是其中某一条;另一条是卡片胶囊的文字。diff --git a/packages/web/src/components/layout/app-layout.tsx b/packages/web/src/components/layout/app-layout.tsxindex 7b26bdfc..cc6c66c3 100644--- a/packages/web/src/components/layout/app-layout.tsx+++ b/packages/web/src/components/layout/app-layout.tsx@@ -9,13 +9,14 @@ import { NavLink, Outlet, useMatch, useNavigate } from "react-router";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { latestConversation } from "../../lib/session-grouping";-import { useVersionInfo } from "../../lib/use-version-info";+import { useUpdateBadges } from "../../lib/use-update-badges";import { useAuth } from "../../state/auth";import { useProject } from "../../state/project";import { useSessions } from "../../state/sessions";import { useCompletionNotifications } from "../../state/use-completion-notifications";import { Drawer } from "../ui/drawer";import { GlyphIcon } from "../ui/glyph-icon";+import { UpdateDot } from "../ui/update-dot";import { CloseIcon, NAV_ICONS } from "../ui/icons";import { NEW_CHAT_ICON, Sidebar } from "./sidebar";import { DRAFT_SESSION_ID } from "../../features/chat/chat-page";@@ -28,9 +29,9 @@ import { toneStrip } from "../../lib/tone";/** "Last conversation" glyph (chat lines + resume arrow), used only by the rail. */const LAST_CHAT_ICON = "M8 10h8M8 14h5M21 12a9 9 0 1 1-4.2-7.6L21 4v5h-5";-/** Shared look of rail entries (icon buttons and NavLinks alike): solid gray fill when active, gray hover otherwise. */+/** Shared look of rail entries (icon buttons and NavLinks alike): solid gray fill when active, gray hover otherwise. `relative` so an entry can anchor an update badge on its corner (no z-index, so it still creates no stacking context). */const railItemClass = (active: boolean) =>- `flex h-8 w-8 items-center justify-center rounded-md transition-colors duration-150 ${+ `relative flex h-8 w-8 items-center justify-center rounded-md transition-colors duration-150 ${active? "bg-gray-200/70 text-gray-900 dark:bg-gray-800 dark:text-gray-100": "text-gray-500 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"@@ -48,13 +49,12 @@ function CollapsedRail({ onExpand }: { onExpand: () => void }) {const { agents, currentProject, setCurrentAgentId } = useProject();const { sessions, loading } = useSessions();/**- * Passive (active=false): never triggers a fetch — the rail mirrors whatever the lazy- * check has already learned (the pinned sidebar's dropdown or the draft page started it),- * matching the pinned sidebar's avatar dot. Cache pushes keep it live while mounted.+ * Passive: the layout above owns the one fetch per session, so the rail only reads the+ * shared caches — and gets pushed a result that lands while it is mounted. Two badges here:+ * the avatar mirrors the pinned sidebar's software dot (the user menu behind it holds the+ * update row), and the Agents entry leads to the outdated Agent's kernel action.*/- const { update } = useVersionInfo(false);- /** Same "named release only" gate as the pinned sidebar's update row (see sidebar.tsx). */- const newVersion = update?.updateAvailable === true ? (update.latestVersion ?? null) : null;+ const badges = useUpdateBadges();const activeSessionId = useMatch("/chat/:sessionId")?.params.sessionId ?? null;/** On some conversation (any non-draft /chat/:id): the "you are here" state of the last-conversation entry. */const onConversation = activeSessionId !== null && activeSessionId !== DRAFT_SESSION_ID;@@ -133,41 +133,42 @@ function CollapsedRail({ onExpand }: { onExpand: () => void }) {<GlyphIcon d={NEW_CHAT_ICON} size={18} /></button>{/* 3-8. Page entries */}- {pages.map((item) => (- <NavLink- key={item.to}- to={item.to}- title={item.label}- aria-label={item.label}- className={({ isActive }) => railItemClass(isActive)}- >- <GlyphIcon d={item.icon} size={18} />- </NavLink>- ))}+ {pages.map((item) => {+ /* Agents is the one entry on a badge trail: an outdated kernel is fixed on the+ Agent settings page this entry leads to. The dot itself is decorative — the+ tooltip and the accessible name say what is updatable. */+ const note = item.to === "/agents" ? badges.kernelNote : null;+ return (+ <NavLink+ key={item.to}+ to={item.to}+ title={note !== null ? `${item.label} · ${note}` : item.label}+ aria-label={note !== null ? `${item.label} · ${note}` : item.label}+ className={({ isActive }) => railItemClass(isActive)}+ >+ <GlyphIcon d={item.icon} size={18} />+ {note !== null && <UpdateDot />}+ </NavLink>+ );+ })}</nav><buttontype="button"title={[user?.userId ?? "", S.nav.expandSidebar]- .concat(newVersion !== null ? [S.update.newVersion(newVersion)] : [])+ .concat(badges.softwareNote !== null ? [badges.softwareNote] : []).join(" · ")}aria-label={- newVersion !== null- ? `${user?.userId ?? ""} · ${S.update.newVersion(newVersion)}`+ badges.softwareNote !== null+ ? `${user?.userId ?? ""} · ${badges.softwareNote}`: (user?.userId ?? S.auth.admin)}onClick={onExpand}className="relative mt-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900">{(user?.userId ?? "?").slice(0, 1).toUpperCase()}- {/* Update reminder dot, mirroring the pinned sidebar's avatar (same look, same- border trick against the rail background); the title/aria-label above name the- release, since the rail has no update row of its own. */}- {newVersion !== null && (- <span- aria-hidden- className="absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"- />- )}+ {/* Update reminder, mirroring the pinned sidebar's avatar: expanding the rail is the+ only way to the update row, so the title/aria-label above name what is waiting. */}+ {badges.software !== null && <UpdateDot />}</button></div>);@@ -188,6 +189,10 @@ export function AppLayout() {// Desktop shell only (gated inside): system notification when a task finishes while// the window is unfocused.useCompletionNotifications();+ // The single eager owner of the update checks (use-update-badges.ts): one request per+ // browser session, so a dot can be there on a fresh load instead of waiting for someone to+ // open the sidebar menu. Every other anchor reads the same caches passively.+ const badges = useUpdateBadges(true);const [drawerOpen, setDrawerOpen] = useState(false);const [changePasswordOpen, setChangePasswordOpen] = useState(false);// Initial-password banner dismissal: server-persisted per user (ui_prefs). null = prefs not@@ -247,11 +252,18 @@ export function AppLayout() {<div className="flex min-w-0 flex-1 flex-col">{/* Mobile: top thin bar (hamburger + brand) */}<header className="flex h-12 shrink-0 items-center gap-2 border-b border-gray-200 bg-white px-2 md:hidden dark:border-gray-800 dark:bg-gray-950">+ {/* The outermost menu on a phone: it carries a dot for EITHER trail, so its wording+ is the combined one — naming one of two updates would point at the wrong trail.+ Both trails continue inside the drawer's sidebar (the Agents entry, the user+ row's update entry). */}<buttontype="button"- aria-label={S.chat.sessionList}+ aria-label={+ badges.note !== null ? `${S.chat.sessionList} · ${badges.note}` : S.chat.sessionList+ }+ {...(badges.note !== null ? { title: badges.note } : {})}onClick={() => setDrawerOpen(true)}- className="flex h-9 w-9 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"+ className="relative flex h-9 w-9 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"><svgwidth="18"@@ -265,6 +277,7 @@ export function AppLayout() {><path d="M4 6h16M4 12h16M4 18h16" /></svg>+ {badges.any && <UpdateDot />}</button><span className="text-sm font-semibold">{S.appName}</span></header>diff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsxindex c9872ce7..1e49af20 100644--- a/packages/web/src/components/layout/sidebar.tsx+++ b/packages/web/src/components/layout/sidebar.tsx@@ -145,6 +145,7 @@ import { ConfirmModal } from "../ui/confirm-modal";import { Button } from "../ui/button";import { Input, noAutofill } from "../ui/input";import { SkeletonList } from "../ui/skeleton";+import { UpdateDot } from "../ui/update-dot";import { DRAFT_SESSION_ID } from "../../features/chat/chat-page";import { WorkspaceSelect } from "../../features/chat/workspace-select";import { clearDraft, sessionDraftKey } from "../../features/chat/draft-cache";@@ -162,6 +163,8 @@ import { UpdateDialog } from "../account/update-dialog";import { offersClientUpdate } from "../../lib/desktop-update";import { requestClientInstall, useDesktopUpdate } from "../../lib/use-desktop-update";import { forceUpdateCheck, updateCheckOutcome, useVersionInfo } from "../../lib/use-version-info";+import { useUpdateBadges } from "../../lib/use-update-badges";+import { releaseUpdate } from "../../lib/update-badges";import { SettingsDialog } from "../../features/settings/settings-dialog";import { ICON_SIZE } from "../../lib/icon-scale";@@ -352,16 +355,23 @@ export function Sidebar({const clientUpdate = useDesktopUpdate(clientUpdateOffered, userOpen);/** Install confirmation (restarting interrupts running tasks — same consent as the shell's native prompt). */const [clientInstallOpen, setClientInstallOpen] = useState(false);- // Server update: nothing is fetched until the dropdown first opens.+ // Server update: the app layout already ran the one check per session; keeping the dropdown+ // as an activation only costs a retry after a failed one.const { version, update } = useVersionInfo(userOpen);- const updateAvailable = update?.updateAvailable === true;+ /**+ * The two update badges (use-update-badges.ts). Not the same gate as `newVersion` below,+ * which drives the ROW: a badge only appears where the trail ends in a control this mode+ * actually offers, so in the shell's own window the avatar marks the client build waiting+ * to install rather than a server release the menu never shows here.+ */+ const badges = useUpdateBadges();/*** The newer release's version string, or null while none is known — the single update row's* whole state machine. A resolved version is required, not just the boolean: the row's label* names it, so a would-be "available but unnamed" result stays on the check action rather* than rendering a versionless reminder.*/- const newVersion = updateAvailable ? (update?.latestVersion ?? null) : null;+ const newVersion = releaseUpdate(update);/** Release announcement + admin self-update, opened from the update row once a release is known. */const [updateDialogOpen, setUpdateDialogOpen] = useState(false);/**@@ -1606,25 +1616,46 @@ export function Sidebar({navCollapsed ? "opacity-0" : "opacity-100"}`}>- {navItems.map((item) => (- <NavLink- key={item.to}- to={item.to}- onClick={() => onNavigate?.()}- className={({ isActive }) =>- `flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${- isActive- ? "bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100"- : "text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"- }`- }- >- <span className="text-gray-500 dark:text-gray-400">- <Icon d={item.icon} />- </span>- {item.label}- </NavLink>- ))}+ {navItems.map((item) => {+ /* Agents is the one nav entry on a badge trail: an outdated kernel is fixed+ on the Agent settings page two clicks down. The dot is anchored to the row,+ not to the label text (where it would float over whatever follows the word):+ at the row's right edge, on the same inset as its horizontal padding, and+ vertically centred on the row rather than on the line of text. */+ const note = item.to === "/agents" ? badges.kernelNote : null;+ return (+ <NavLink+ key={item.to}+ to={item.to}+ onClick={() => onNavigate?.()}+ {...(note !== null+ ? {+ // The row's own label is visible, so the tooltip only adds what+ // the dot means; the accessible name keeps that label as its+ // prefix. (The collapsed rail's icon-only twin has no visible+ // label, so its tooltip carries both.)+ title: note,+ "aria-label": `${item.label} · ${note}`,+ }+ : {})}+ className={({ isActive }) =>+ `relative flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${+ isActive+ ? "bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100"+ : "text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"+ }`+ }+ >+ <span className="text-gray-500 dark:text-gray-400">+ <Icon d={item.icon} />+ </span>+ {item.label}+ {note !== null && (+ <UpdateDot size="inline" position="right-2.5 top-1/2 -translate-y-1/2" />+ )}+ </NavLink>+ );+ })}</div></div></div>@@ -2126,28 +2157,21 @@ export function Sidebar({<buttontype="button"onClick={() => setUserOpen(!userOpen)}- {...(newVersion !== null+ {...(badges.softwareNote !== null? {- // The dot alone is mysterious: name the release on the trigger (hover- // tooltip + accessible name), in the update row's exact wording.- title: S.update.newVersion(newVersion),- "aria-label": `${user?.userId ?? ""} · ${S.update.newVersion(newVersion)}`,+ // The dot alone is mysterious: name what is waiting on the trigger (hover+ // tooltip + accessible name), in the update row's own wording.+ title: badges.softwareNote,+ "aria-label": `${user?.userId ?? ""} · ${badges.softwareNote}`,}: {})}className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 hover:bg-gray-200/70 dark:hover:bg-gray-800"><span className="relative flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900">{(user?.userId ?? "?").slice(0, 1).toUpperCase()}- {/* Update reminder dot: only once the lazy check has actually run and found a- newer release (the trigger button's tooltip/label above explains it). The- border (sidebar background color) separates it from the avatar for every- accent — the neutral accent matches the avatar fill. */}- {updateAvailable && (- <span- aria-hidden- className="absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"- />- )}+ {/* Update reminder: the menu behind this trigger holds the row that acts on+ it, and the trigger's tooltip/label above say what it is. */}+ {badges.software !== null && <UpdateDot />}</span><span className="min-w-0 flex-1 truncate text-sm font-medium">{user?.userId}</span>{user?.isAdmin && (diff --git a/packages/web/src/components/ui/tabs.tsx b/packages/web/src/components/ui/tabs.tsxindex c959faca..9f202c17 100644--- a/packages/web/src/components/ui/tabs.tsx+++ b/packages/web/src/components/ui/tabs.tsx@@ -2,9 +2,17 @@* Tab switcher component (controlled): GitHub-style underline; scrolls* horizontally on narrow screens.*/+import { UpdateDot } from "./update-dot";+export interface TabItem<K extends string = string> {key: K;label: string;+ /**+ * Something updatable behind this tab: raises an update badge and folds this sentence into+ * the tab's tooltip and accessible name (the dot itself carries nothing). Null / omitted =+ * no badge.+ */+ badge?: string | null;}export function Tabs<K extends string>({@@ -22,22 +30,29 @@ export function Tabs<K extends string>({// overflow-y-hidden: only allow horizontal scroll on narrow screens, otherwise some browsers reserve a vertical scrollbar gutter for overflow-x-auto.className="flex max-w-full gap-1 overflow-x-auto overflow-y-hidden border-b border-gray-200 dark:border-gray-800">- {items.map((item) => (- <button- key={item.key}- type="button"- role="tab"- aria-selected={item.key === active}- onClick={() => onChange(item.key)}- className={`-mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors duration-150 ${- item.key === active- ? "border-gray-900 font-semibold text-gray-900 dark:border-gray-100 dark:text-gray-100"- : "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-800 dark:text-gray-400 dark:hover:border-gray-700 dark:hover:text-gray-200"- }`}- >- {item.label}- </button>- ))}+ {items.map((item) => {+ const badge = item.badge ?? null;+ return (+ <button+ key={item.key}+ type="button"+ role="tab"+ aria-selected={item.key === active}+ {...(badge !== null ? { title: badge, "aria-label": `${item.label} · ${badge}` } : {})}+ onClick={() => onChange(item.key)}+ className={`relative -mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors duration-150 ${+ item.key === active+ ? "border-gray-900 font-semibold text-gray-900 dark:border-gray-100 dark:text-gray-100"+ : "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-800 dark:text-gray-400 dark:hover:border-gray-700 dark:hover:text-gray-200"+ }`}+ >+ {item.label}+ {/* Inside the button's own padding, not hanging off its corner: the strip clips+ vertically (overflow-y-hidden above), so an overhanging dot would be cut. */}+ {badge !== null && <UpdateDot size="inline" position="right-1 top-1" />}+ </button>+ );+ })}</div>);}diff --git a/packages/web/src/components/ui/update-dot.tsx b/packages/web/src/components/ui/update-dot.tsxnew file mode 100644index 00000000..8ad08172--- /dev/null+++ b/packages/web/src/components/ui/update-dot.tsx@@ -0,0 +1,116 @@+/**+ * The update notification badge: a small dot hung on the top-right corner of whatever entry+ * leads toward something updatable, the way a phone marks a menu that has news behind it.+ *+ * **Not a status tone, deliberately.** `lib/tone.ts` is the one place a *status* colour is+ * spelled, and each of its five tones is a judgement about a thing's own state — `danger` is+ * failed, destructive or over a limit; `attention` is unfinished work waiting on someone. An+ * available update is neither: nothing has gone wrong and nothing is stuck. What this mark+ * says is "there is something new further down this path", a category `tone.ts` explicitly+ * keeps out of scope. So the badge colour lives here instead, written once, and every dot on+ * an update trail renders through this component rather than spelling a palette class inline.+ *+ * Red, because that is what a notification badge is everywhere else a user has seen one, and+ * `red-400`, the pale rung, so the mark reads as news rather than as an alarm. WCAG 2.x contrast+ * against the six surfaces a dot lands on — in light, 2.89 : 1 on white, 2.76 : 1 on the+ * sidebar's gray-50 and 2.46 : 1 on a nav row's active/hover fill (gray-200/70 over gray-50); in+ * dark, 7.27 : 1 on gray-950 (`#000000` here), 6.73 : 1 on gray-900 (`#0d0d0d` here) and+ * 5.71 : 1 on gray-800. Dark clears on all three the 3 : 1 WCAG 1.4.11 asks of a graphical+ * object; light misses on all three, by 4% to 18%, knowingly. 1.4.11 scopes to a graphical+ * object *required* to understand the content, and this one never is: it is `aria-hidden`, and+ * its anchor states what is updatable in its own `title` and accessible name, so no information+ * reaches the user through the mark alone. Light is what binds: red-500 is the palest rung on+ * Tailwind's red ramp that clears 3 : 1 on all three light surfaces (3.81 / 3.64 / 3.25 : 1), so+ * the pale end of the ramp and the threshold do not overlap. One value across both themes, for+ * the reason `toneDot` keeps one: a dot this small has no interior to read.+ *+ * **The dot never carries the meaning.** It is `aria-hidden`, and the anchor states what is+ * updatable in its own `title` and accessible name ("<anchor> · <what is updatable>"). A+ * decorative dot with no accessible text beside it is the bug this pattern usually ships with.+ *+ * Layout-neutral: absolutely positioned, so a caller only has to be `relative`, and no row+ * changes height for carrying one. `pointer-events-none` keeps it out of its anchor's hit area.+ *+ * Anchoring rule, owner-specified: a dot marks its control's **full box** — the whole row, tab or+ * button — never the label glyphs, where it would track the text's width, float over whatever+ * follows the word and ride above the line box. Two shapes of box, two placements. A full-width+ * row hangs the dot at the right edge, vertically centred (`right-2.5 top-1/2 -translate-y-1/2`,+ * the inset matching the row's own horizontal padding): a row has an end to align to and no+ * corner a reader's eye goes to. A button or a tab takes the top-right corner, straddling the+ * border where that corner is visible and pulled inside the padding where an ancestor clips it+ * (the tab strip's `overflow-y-hidden`). Chrome anchors are their own box, so their default+ * overhang stands.+ */+import type { ReactNode } from "react";++/**+ * Sizes named by the anchor they sit on, not by a number (the `icon-scale.ts` convention).+ * Note the web root font is 18px, so a Tailwind spacing unit is 1.125× its usual pixel value:+ * `h-2.5` is 11.25px, `h-1.5` is 6.75px.+ */+const DOT_SIZE = {+ /**+ * A filled or boxed chrome anchor — an avatar, a rail icon button, the mobile menu button.+ * The ring is the chrome's own background colour (gray-50 pinned/rail sidebar, gray-900 in+ * dark), which is what separates the dot from the avatar fill or the row's hover fill+ * underneath it; 11.25px outer leaves a 7.25px core.+ */+ chrome: "h-2.5 w-2.5 border-2 border-gray-50 dark:border-gray-900",+ /**+ * A line of text or a bare glyph, where the dot sits directly on the page surface: no ring,+ * because there is nothing underneath to separate it from and a ring would only shrink it.+ */+ inline: "h-1.5 w-1.5",+} as const;++export type UpdateDotSize = keyof typeof DOT_SIZE;++export function UpdateDot({+ size = "chrome",+ position = "-right-0.5 -top-0.5",+}: {+ size?: UpdateDotSize;+ /**+ * Where the dot sits inside its `relative` anchor — Tailwind inset utilities, plus a+ * `translate-*` where the dot is centred on an edge or straddles a corner instead of being+ * inset from one. The default hangs it just past the anchor's top-right corner; an anchor+ * whose own padding or a clipping ancestor would swallow that (a tab strip's+ * `overflow-y-hidden`) moves it in.+ */+ position?: string;+}) {+ return (+ <span+ aria-hidden+ className={`pointer-events-none absolute rounded-full bg-red-400 ${DOT_SIZE[size]} ${position}`}+ />+ );+}++/**+ * The labeled form of the badge, for the one stop on a trail where a bare dot undersells the+ * state: the Agents list card of an outdated Agent, which is also the control the sidebar's+ * dot leads to. A real button — it opens the Agent settings overview the trail ends on —+ * shaped exactly like the `Badge` pills sharing its row (`v<version>`: same radius, padding+ * and 11px semibold type), so the row reads as one family of capsules.+ *+ * A tinted capsule, not the dot's flat fill: this one has an interior, so its label owes WCAG+ * 1.4.3's 4.5 : 1 against its own background, and a surface pale enough to belong beside the+ * dots can only pay that with a dark ink. Measured red-800 on red-100 6.85 : 1 in light and+ * red-300 on red-950 8.42 : 1 in dark, with the hover fills (red-200 / red-900) still at+ * 5.75 : 1 and 5.22 : 1 under the same ink. Tint against card rather than ink against card is+ * what the neighbouring gray `Badge` also runs on: the capsule is found by its text.+ * The badge colours stay in this module, with the dot's, for the reason the header gives — an+ * update mark is not a `tone.ts` status.+ */+export function UpdatePill({ onClick, children }: { onClick: () => void; children: ReactNode }) {+ return (+ <button+ type="button"+ onClick={onClick}+ className="inline-flex shrink-0 items-center whitespace-nowrap rounded-full bg-red-100 px-2 py-0.5 text-[11px] font-semibold text-red-800 transition-colors duration-150 hover:bg-red-200 dark:bg-red-950 dark:text-red-300 dark:hover:bg-red-900"+ >+ {children}+ </button>+ );+}diff --git a/packages/web/src/features/agents/agent-settings-page.tsx b/packages/web/src/features/agents/agent-settings-page.tsxindex 6801665b..c95845f6 100644--- a/packages/web/src/features/agents/agent-settings-page.tsx+++ b/packages/web/src/features/agents/agent-settings-page.tsx@@ -38,6 +38,7 @@ import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal"import { CopyButton, ROW_COPY_CLASS } from "../../components/ui/copy-button";import { Skeleton } from "../../components/ui/skeleton";import { GlyphIcon } from "../../components/ui/glyph-icon";+import { UpdateDot } from "../../components/ui/update-dot";import { SkillsTab } from "./skills-tab";import { MemoryTab } from "./memory-tab";import { kernelTabLabel } from "./kernel-labels";@@ -245,7 +246,17 @@ export function AgentSettingsPage() {</Button><h1 className="mb-1 text-xl font-semibold">{data.config.name ?? agentId}</h1><p className="mb-4 font-mono text-xs text-gray-400">{agentId}</p>- <Tabs items={TABS} active={tab} onChange={switchTab} />+ {/* The kernel update action lives in the Overview tab's Kernel section, so the trail+ from the Agents list has to cross the tab strip to reach it. */}+ <Tabs+ items={TABS.map((t) =>+ t.key === "overview" && data.config.kernelOutdated+ ? { ...t, badge: S.agent.kernelOutdatedHint }+ : t,+ )}+ active={tab}+ onChange={switchTab}+ /><div className="py-4">{tab === "overview" && (<OverviewTab@@ -491,14 +502,30 @@ function OverviewTab({light, mirroring the State rows' label/value contrast. */}<section className="border-t border-gray-200 pt-4 dark:border-gray-800"><div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2">+ {/* Last stop on the kernel trail: the dot sits on the update control itself, straddling+ the top-right corner of the enabled button's border (the anchoring rule in+ update-dot.tsx), not hung off the section title's text, whose flex item is only+ as wide as its glyphs. The dot is decorative — the sr-only sentence folds what is+ waiting into the button's accessible name, in the same wording the trail carried+ all the way down. */}<p className="text-sm font-medium">{S.agent.kernelTitle}</p><div className="flex shrink-0 items-center gap-2"><Buttonsize="sm"+ className="relative"disabled={kernelUpdating || !data.config.kernelOutdated}onClick={() => setKernelOpen(true)}>{S.agent.kernelUpdateAction}+ {data.config.kernelOutdated && (+ <>+ <UpdateDot+ size="inline"+ position="right-0.5 top-0.5 -translate-y-1/2 translate-x-1/2"+ />+ <span className="sr-only"> · {S.agent.kernelOutdatedHint}</span>+ </>+ )}</Button><Buttonsize="sm"diff --git a/packages/web/src/features/agents/agents-page.tsx b/packages/web/src/features/agents/agents-page.tsxindex 85600381..c3aa318c 100644--- a/packages/web/src/features/agents/agents-page.tsx+++ b/packages/web/src/features/agents/agents-page.tsx@@ -40,6 +40,7 @@ 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 { GEAR_ICON } from "../../components/ui/icons";import { STAT_ICONS } from "../../lib/stat-icons";import { DRAFT_SESSION_ID } from "../chat/chat-page";@@ -82,8 +83,6 @@ const CARD_ICONS = {/** Memory (brain: two hemispheres + inner fold, lucide simplified), opens the settings tab */memory:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18ZM12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18ZM15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",- /** Kernel update available (rotate-cw — the skill library's update glyph), deep-links to the settings overview */- kernelUpdate: "M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10",} as const;/**@@ -410,19 +409,15 @@ export function AgentsPage() {{a.agentId}</span><Badge tone="gray">v{a.version}</Badge>- {/* Kernel-outdated hint: minimal icon + tooltip (skills-library update- convention, no textual/red alarm), deep-linking to the settings- overview where the update action lives. */}+ {/* Kernel-outdated pill: the card the sidebar's Agents dot leads to, so it+ names the state in words rather than as another bare dot — a capsule in+ the version badge's own geometry, tinted the same pale red the dots on+ this trail carry, opening the settings overview where the update action+ lives. */}{a.kernelOutdated && (- <button- type="button"- className="shrink-0 cursor-pointer text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300"- title={S.agent.kernelOutdatedHint}- aria-label={S.agent.kernelOutdatedHint}- onClick={() => openSettingsTab(a.agentId, "overview")}- >- <GlyphIcon d={CARD_ICONS.kernelUpdate} size={ICON_SIZE.inlineGlyph} />- </button>+ <UpdatePill onClick={() => openSettingsTab(a.agentId, "overview")}>+ {S.agent.kernelUpdateNeeded}+ </UpdatePill>)}</div>{/* Description truncated to one line (an empty description still takes up a line, keeping card heights equal) */}diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex d6839c22..427babd4 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -162,6 +162,7 @@ export const en: Strings = {/** Superscript badge on the version lines when the update check found a newer release. */newVersionBadge: "New version available",newVersion: (v: string) => `New version v${v} available`,+ updatesAvailable: "Updates available",/*** The sidebar user menu's SINGLE update row: it reads "Check for updates" until a newer* release is known and runs the manual check; once one is known it reads newVersion() and@@ -606,6 +607,7 @@ export const en: Strings = {kernelTitle: "Kernel",kernelLegacy: "predates kernel versioning",kernelOutdatedHint: "Kernel update available",+ kernelUpdateNeeded: "Kernel update needed",kernelUpToDate: "Up to date",kernelUpdateTitle: "Update kernel",kernelCurrent: "current",diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex f441f93e..ebe676d9 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -167,6 +167,12 @@ export const zh = {/** Superscript badge on the version lines when the update check found a newer release (owner-specified wording). */newVersionBadge: "有新版本可用",newVersion: (v: string) => `新版本 v${v} 可用`,+ /**+ * The combined wording for an anchor that leads to BOTH update trails at once (the+ * mobile menu button): something is updatable, without claiming which — naming one of+ * two would send the user down the wrong one.+ */+ updatesAvailable: "有可用更新",/*** The sidebar user menu's SINGLE update row: it reads checkNow until a newer release* is known and runs the manual check; once one is known it reads newVersion() and@@ -568,6 +574,8 @@ export const zh = {kernelTitle: "内核",kernelLegacy: "早于内核版本机制",kernelOutdatedHint: "内核有更新",+ /** The Agents-list card's dark-red capsule on an outdated Agent — a control, not a label: it opens the settings overview where the update runs. */+ kernelUpdateNeeded: "内核需要更新",kernelUpToDate: "已是最新",kernelUpdateTitle: "更新内核",/** Inline labels around the outdated line's two generation values (the values themselves render dark and semibold). */diff --git a/packages/web/src/lib/update-badges.ts b/packages/web/src/lib/update-badges.tsnew file mode 100644index 00000000..b7db8b3c--- /dev/null+++ b/packages/web/src/lib/update-badges.ts@@ -0,0 +1,96 @@+/**+ * 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.+ *+ * 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+ * gate takes which row the running mode actually offers — desktop mode hides the server+ * release row entirely and updates the client through the shell instead, so a newer server+ * release must not raise a dot there.+ *+ * 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 { clientUpdateRow } from "./desktop-update";++/** A software update the running mode can act on, and the version the offer names. */+export type SoftwareUpdate =+ | { kind: "release"; version: string }+ /** A client build the shell has downloaded; `version` is null when the shell did not name one. */+ | { kind: "client"; version: string | null };++/**+ * The newer release the server-update row acts on, or null. A resolved version is required,+ * not just the boolean — the row and every tooltip along the trail name it, so an "available+ * but unnamed" result must not raise a dot leading to a versionless reminder. The check is+ * fail-soft on the server, so a disabled check (`PENGUIN_UPDATE_CHECK=off`) and a failed+ * lookup both arrive as `updateAvailable: false` and raise nothing.+ */+export function releaseUpdate(update: UpdateCheckResponse | null): string | null {+ return update?.updateAvailable === true ? (update.latestVersion ?? null) : null;+}++export interface SoftwareUpdateInput {+ /** Whether the sidebar user menu offers the server release row here (everything but desktop mode). */+ releaseRowOffered: boolean;+ /** Whether it offers the desktop client row here (`offersClientUpdate`: the shell's own window). */+ clientRowOffered: boolean;+ update: UpdateCheckResponse | null;+ clientStatus: DesktopUpdateStatus | null;+}++/**+ * The one software gate behind every dot on that trail. A client build still downloading is+ * deliberately not one: the row shows its progress, but there is nothing for the user to do+ * until it lands, and a badge that cannot be cleared by acting on it is noise.+ */+export function softwareUpdate(input: SoftwareUpdateInput): SoftwareUpdate | null {+ if (input.releaseRowOffered) {+ const version = releaseUpdate(input.update);+ if (version !== null) return { kind: "release", version };+ }+ if (input.clientRowOffered) {+ const row = clientUpdateRow(input.clientStatus);+ if (row.action === "install") return { kind: "client", version: row.version };+ }+ return null;+}++/**+ * 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);+}++/**+ * What an anchor covering BOTH trails says. `mixed` is the combined case: two different+ * things are updatable and the anchor leads to both, so it must not claim to be either.+ */+export type UpdateBadgeNote =+ | { kind: "none" }+ | { kind: "release"; version: string }+ | { kind: "client"; version: string | null }+ | { kind: "kernel" }+ | { kind: "mixed" };++/** Classifies what one anchor over both trails should say (see {@link UpdateBadgeNote}). */+export function updateBadgeNote(software: SoftwareUpdate | null, kernel: boolean): UpdateBadgeNote {+ if (software !== null && kernel) return { kind: "mixed" };+ if (software !== null) return software;+ if (kernel) return { kind: "kernel" };+ return { kind: "none" };+}diff --git a/packages/web/src/lib/use-desktop-update.ts b/packages/web/src/lib/use-desktop-update.tsindex 8b1b13dd..20c222c9 100644--- a/packages/web/src/lib/use-desktop-update.ts+++ b/packages/web/src/lib/use-desktop-update.ts@@ -85,6 +85,15 @@ function poll(): Promise<void> {return inflight;}+/**+ * One passive read of the shell's updater snapshot, for a consumer that does not poll: the+ * update badge asks once per app load so a build downloaded before this load can raise its+ * dot without the user opening the menu first. Concurrent callers ride the in-flight GET.+ */+export function refreshDesktopUpdate(): void {+ void poll();+}+/** Row action: arm the settle watch, then ask the shell to check. A failed POST disarms and reports itself. */export async function requestClientCheck(): Promise<void> {if (watch !== null) return;diff --git a/packages/web/src/lib/use-update-badges.ts b/packages/web/src/lib/use-update-badges.tsnew file mode 100644index 00000000..53b46254--- /dev/null+++ b/packages/web/src/lib/use-update-badges.ts@@ -0,0 +1,90 @@+/**+ * The live update badges, read by every anchor on the two update trails: the mobile menu+ * button, the sidebar avatar and its collapsed-rail twin, and both Agents nav entries.+ *+ * One owner activates the fetches. `AppLayout` calls this with `eager` on, which is what makes+ * a badge appear on a fresh load at all — the anchors below it stay passive and read the shared+ * caches (`use-version-info.ts`, `use-desktop-update.ts`), which push every consumer when a+ * result lands. Both caches are module level, so "eager" still costs one request per browser+ * session, and both are fail-soft: an unreachable check leaves every gate closed and says+ * nothing.+ *+ * The gates themselves are pure and unit tested in `update-badges.ts`; this file only wires+ * them to the stores and turns the note into localized copy.+ */+import { useEffect } from "react";+import { S } from "./strings";+import { offersClientUpdate } from "./desktop-update";+import { refreshDesktopUpdate, useDesktopUpdate } from "./use-desktop-update";+import { useVersionInfo } from "./use-version-info";+import { anyKernelOutdated, softwareUpdate, updateBadgeNote } from "./update-badges";+import type { SoftwareUpdate, UpdateBadgeNote } from "./update-badges";+import { useAuth } from "../state/auth";+import { useProject } from "../state/project";++export interface UpdateBadges {+ /** A software update this mode can act on, or null. */+ software: SoftwareUpdate | null;+ /** What the software anchors (the avatars) say — the update row's own wording; null with no update. */+ softwareNote: string | null;+ /** Whether any Agent in the current Project has an outdated kernel. */+ kernel: boolean;+ /** What the Agents anchors say; null when no kernel is outdated. */+ kernelNote: string | null;+ /** Whether the outermost chrome shows a dot at all. */+ any: boolean;+ /** What an anchor covering both trails says — the combined case names neither. Null when there is nothing. */+ note: string | null;+}++export function useUpdateBadges(eager = false): UpdateBadges {+ const { desktopMode, sessionVia } = useAuth();+ const { agents } = useProject();+ const clientRowOffered = offersClientUpdate({ desktopMode, sessionVia });+ const { update } = useVersionInfo(eager);+ // Passive: the shell's snapshot is polled by the sidebar's own hook instance while the user+ // menu is open. The one-shot refresh below is what lets a build downloaded before this load+ // show up without opening anything.+ const { status } = useDesktopUpdate(false, false);+ useEffect(() => {+ if (eager && clientRowOffered) refreshDesktopUpdate();+ }, [eager, clientRowOffered]);++ const software = softwareUpdate({+ releaseRowOffered: !desktopMode,+ clientRowOffered,+ update,+ clientStatus: status,+ });+ const kernel = anyKernelOutdated(agents);+ const kernelNote = kernel ? S.agent.kernelOutdatedHint : null;+ const softwareNote = software === null ? null : noteText(software);++ return {+ software,+ softwareNote,+ kernel,+ kernelNote,+ any: software !== null || kernel,+ note: noteText(updateBadgeNote(software, kernel)),+ };+}++/**+ * The localized sentence for one note. Read at call time, never hoisted: `S` is a live binding+ * swapped on locale change.+ */+function noteText(note: UpdateBadgeNote): string | null {+ switch (note.kind) {+ case "none":+ return null;+ case "release":+ return S.update.newVersion(note.version);+ case "client":+ return S.update.clientRestartToInstall(note.version);+ case "kernel":+ return S.agent.kernelOutdatedHint;+ default:+ return S.update.updatesAvailable;+ }+}diff --git a/packages/web/src/lib/use-version-info.ts b/packages/web/src/lib/use-version-info.tsindex 7aaedea2..b35adfc3 100644--- a/packages/web/src/lib/use-version-info.ts+++ b/packages/web/src/lib/use-version-info.ts@@ -1,14 +1,18 @@/**- * Lazily fetched version identity + update check for the sidebar user menu.+ * Version identity + update check, shared by every surface that shows either.*- * Neither request fires on app load: both start on the first activation (the first time- * the user opens the bottom dropdown) and the results are cached at module level for the- * rest of the browser session — a locale switch remounts the whole tree, and component- * state would refetch on every remount. Failures resolve to null and clear the shared- * promise so a later dropdown open retries; nothing is surfaced as an error (the footer- * simply shows nothing, and "no update known" hides the reminder). forceUpdateCheck is- * the one deliberate exception to the laziness: the user asked, so it refetches now and- * broadcasts the result to every mounted hook.+ * Both requests fire once per browser session, from the first hook activated with+ * `active` — the app layout, which activates on mount so the update badge can appear on a+ * fresh load without the user opening anything. The results are cached at module level for+ * the rest of the session: a locale switch remounts the whole tree, and component state+ * would refetch on every remount. Passive consumers (`active: false`) never fetch and read+ * that cache. Failures resolve to null and clear the shared promise so a later activation+ * retries; nothing is surfaced as an error (the footer simply shows nothing, and "no update+ * known" hides the reminder and every badge). The server caches its own lookup for an hour+ * and shares one in-flight call, so an app load costs no outbound request of its own, and+ * `PENGUIN_UPDATE_CHECK=off` still answers without dialing out at all. forceUpdateCheck is+ * the user asking directly: it refetches past the server's TTL and broadcasts the result to+ * every mounted hook.*/import { useEffect, useState } from "react";import type { UpdateCheckResponse, VersionResponse } from "@prismshadow/penguin-server/api";@@ -23,10 +27,10 @@ let updatePromise: Promise<UpdateCheckResponse> | null = null;* Mounted hooks subscribe here so any refresh of the module cache reaches every* consumer at once — the footer, the update dots, the reminder rows, and the draft* page's version line all react without a remount. Two paths push: forceUpdateCheck- * (the sidebar's manual "check for updates" action) and the lazy fetch resolving.+ * (the sidebar's manual "check for updates" action) and the shared fetch resolving.* Active hooks await the shared promise themselves, but passive ones (active=false,- * e.g. the collapsed rail's avatar dot) only ever read the cache — without the lazy- * push they would miss a result that lands while they are mounted.+ * e.g. the collapsed rail's avatar dot) only ever read the cache — without this push+ * they would miss a result that lands while they are mounted.*/const listeners = new Set<() => void>();@@ -64,7 +68,7 @@ export interface VersionInfo {export function useVersionInfo(active: boolean): VersionInfo {// Initial state comes from the module cache, so a remounted sidebar (locale switch)- // shows the version footer and the update dot immediately, without reopening anything.+ // shows the version footer and the update dot immediately, with no second request.const [version, setVersion] = useState<VersionResponse | null>(versionCache);const [update, setUpdate] = useState<UpdateCheckResponse | null>(updateCache);diff --git a/packages/web/test/update-badges.test.ts b/packages/web/test/update-badges.test.tsnew file mode 100644index 00000000..214c6b7e--- /dev/null+++ b/packages/web/test/update-badges.test.ts@@ -0,0 +1,185 @@+/**+ * Update-badge gate unit tests: what raises a notification dot, and what an anchor over both+ * 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.+ */+import { describe, expect, it } from "vitest";+import type { DesktopUpdateStatus, UpdateCheckResponse } from "@prismshadow/penguin-server/api";+import {+ anyKernelOutdated,+ releaseUpdate,+ softwareUpdate,+ updateBadgeNote,+} from "../src/lib/update-badges";++function check(overrides: Partial<UpdateCheckResponse>): UpdateCheckResponse {+ return {+ currentVersion: "0.1.5",+ buildDate: null,+ latestVersion: null,+ updateAvailable: false,+ releaseUrl: null,+ publishedAt: null,+ checkedAt: "2026-08-26T00:00:00.000Z",+ ...overrides,+ };+}++const AVAILABLE = check({ updateAvailable: true, latestVersion: "0.2.0" });++function shell(overrides: Partial<DesktopUpdateStatus>): DesktopUpdateStatus {+ return { appVersion: "0.1.5", state: "idle", ...overrides };+}++describe("releaseUpdate", () => {+ it("names the newer release", () => {+ expect(releaseUpdate(AVAILABLE)).toBe("0.2.0");+ });++ it("raises nothing before the check has answered", () => {+ expect(releaseUpdate(null)).toBeNull();+ });++ it("raises nothing when the running version is current", () => {+ expect(releaseUpdate(check({ latestVersion: "0.1.5" }))).toBeNull();+ });++ it("raises nothing when the lookup failed — a fail-soft error is not an update", () => {+ // The response is HTTP 200 with `error` set; updateAvailable stays false, so no badge and+ // no noise. The user hears about a failure only from the manual check they asked for.+ expect(releaseUpdate(check({ error: "network" }))).toBeNull();+ expect(releaseUpdate(check({ error: "rate_limited" }))).toBeNull();+ });++ it("raises nothing when checks are turned off (PENGUIN_UPDATE_CHECK=off)", () => {+ expect(releaseUpdate(check({ disabled: true }))).toBeNull();+ });++ it("raises nothing for an available-but-unnamed release", () => {+ // Every tooltip along the trail names the version; without one the dot would lead to a+ // versionless reminder.+ expect(releaseUpdate(check({ updateAvailable: true }))).toBeNull();+ });+});++describe("softwareUpdate", () => {+ const base = { releaseRowOffered: true, clientRowOffered: false, clientStatus: null };++ it("offers the release when the menu holds the release row", () => {+ expect(softwareUpdate({ ...base, update: AVAILABLE })).toEqual({+ kind: "release",+ version: "0.2.0",+ });+ });++ it("stays silent about a release the running mode never offers a row for", () => {+ // Desktop mode hides the server-update row and updates the client through the shell, so a+ // dot for a newer server release there would point at nothing.+ expect(softwareUpdate({ ...base, releaseRowOffered: false, update: AVAILABLE })).toBeNull();+ });++ it("offers a downloaded client build waiting to be installed", () => {+ expect(+ softwareUpdate({+ releaseRowOffered: false,+ clientRowOffered: true,+ update: null,+ clientStatus: shell({ state: "downloaded", version: "0.3.0" }),+ }),+ ).toEqual({ kind: "client", version: "0.3.0" });+ });++ it("does not badge a client download still in flight", () => {+ // The row shows its progress; there is nothing to act on until it lands, and a badge the+ // user cannot clear by acting on it is noise.+ expect(+ softwareUpdate({+ releaseRowOffered: false,+ clientRowOffered: true,+ update: null,+ clientStatus: shell({ state: "downloading", version: "0.3.0", percent: 40 }),+ }),+ ).toBeNull();+ });++ it("does not badge an idle, checking, up-to-date or unsupported shell", () => {+ for (const state of ["idle", "checking", "up-to-date", "unsupported", "error"] as const) {+ expect(+ softwareUpdate({+ releaseRowOffered: false,+ clientRowOffered: true,+ update: null,+ clientStatus: shell({ state }),+ }),+ state,+ ).toBeNull();+ }+ });++ it("stays silent when neither row is offered", () => {+ // A browser signed into a desktop-mode server gets neither the release row nor the client+ // row (offersClientUpdate's pair), so it gets no software badge either.+ expect(+ softwareUpdate({+ releaseRowOffered: false,+ clientRowOffered: false,+ update: AVAILABLE,+ clientStatus: shell({ state: "downloaded", version: "0.3.0" }),+ }),+ ).toBeNull();+ });++ it("prefers the release when a mode somehow offers both rows", () => {+ expect(+ softwareUpdate({+ releaseRowOffered: true,+ clientRowOffered: true,+ update: AVAILABLE,+ clientStatus: shell({ state: "downloaded", version: "0.3.0" }),+ }),+ ).toEqual({ kind: "release", version: "0.2.0" });+ });+});++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("updateBadgeNote", () => {+ const release = { kind: "release", version: "0.2.0" } as const;++ it("says nothing when nothing is updatable", () => {+ expect(updateBadgeNote(null, false)).toEqual({ kind: "none" });+ });++ it("names the release when only software is updatable", () => {+ expect(updateBadgeNote(release, false)).toEqual(release);+ });++ it("carries a client build's version through, null included", () => {+ expect(updateBadgeNote({ kind: "client", version: null }, false)).toEqual({+ kind: "client",+ version: null,+ });+ });++ it("says kernel when only an Agent is behind", () => {+ expect(updateBadgeNote(null, true)).toEqual({ kind: "kernel" });+ });++ it("names neither when both trails have something", () => {+ // The combined anchor leads to both; naming one of the two would point at the wrong trail.+ expect(updateBadgeNote(release, true)).toEqual({ kind: "mixed" });+ });+});