Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

refactor(ui): W3 — menus, dialogs, tooltips and toasts move into the UI package (#899)

Yaowei Zhengf6bf5b511528
diff --git a/.agents/skills/penguin-harness-frontend/SKILL.md b/.agents/skills/penguin-harness-frontend/SKILL.md
index 3466c3be..3eac8d95 100644
--- a/.agents/skills/penguin-harness-frontend/SKILL.md
+++ b/.agents/skills/penguin-harness-frontend/SKILL.md
@@ -25,9 +25,10 @@ This file records the decisions that already exist so they are not re-litigated
| `danger` | failed, destructive, over a limit | errors, delete affordances |
| `muted` | settled; the mark should recede | a done row's glyph |
-Four maps, by the shape of the thing being coloured: `toneInk` (a glyph or a line of status text),
-`toneSurface` (a tinted pill with its own text — badges), `toneDot` (the 6px state dots),
-`toneStrip` (a bordered notice that owns a row).
+Three maps, by the shape of the thing being coloured: `toneInk` (a glyph or a line of status text),
+`toneSurface` (a tinted pill with its own text — badges), `toneDot` (the 6px state dots). A
+notice that owns a row is the shared UI package's `NoticeStrip`, which takes the package's tone
+names (`busy` → `success`, `link` → `info`, `muted` → `neutral`); toasts render through it.
Rules:
@@ -223,9 +224,16 @@ Three behaviours there are load-bearing:
- **`z-[60]`**, above the modal overlay's `z-50`: a portaled node sits in the root stacking context
and may be opened from inside a dialog.
-Modals and `Dropdown` additionally register in the Esc-layer stack (`modal.tsx`'s `pushEscLayer`),
-so Escape only acts on the topmost layer. A portal panel does not need to — capture plus
-`stopPropagation` already gets there first.
+Modals, drawers, sheets, the lightbox and `Dropdown` additionally register in the Esc-layer stack
+(the UI package's `esc-layers.ts`: `useEscLayer`, or `pushEscLayer` / `isTopEscLayer`), so Escape
+only acts on the topmost layer. A portal panel does not need to — capture plus `stopPropagation`
+already gets there first.
+
+A menu's rows are the package's Menu family, never a hand-built row: `Menu` (the list, `role="menu"`,
+density `md` for account and project menus, `sm` for a row's overflow and context menus) holding
+`MenuItem` (glyph, label, description, trailing note, `danger`, `checked`, `href`),
+`MenuRadioItem`, `MenuSeparator` and `MenuLabel`. The panel around them stays a `Dropdown`. A row
+outside a `Menu` is a plain button, for a panel that mixes rows with a search box or a listbox.
## The rest of the house style
diff --git a/changelog/unreleased/2026-09-30-ui-migration-w3.md b/changelog/unreleased/2026-09-30-ui-migration-w3.md
new file mode 100644
index 00000000..b5683922
--- /dev/null
+++ b/changelog/unreleased/2026-09-30-ui-migration-w3.md
@@ -0,0 +1,36 @@
+# Menus, dialogs, tooltips and toasts move into the shared UI package
+
+- **Date:** 2026-09-30
+- **Type:** refactor
+- **Scope:** `ui`, `web`, `ui-gallery`
+
+[中文版](2026-09-30-ui-migration-w3.zh.md)
+
+W3 of the UI-package migration moves the Web App's overlays into `@prismshadow/penguin-ui`: menus and dropdowns, tooltips, dialogs and sheets, and toasts.
+
+## What moved
+
+- **Menus:** `Dropdown`, `FormPicker`, `useRowContextMenu`, and a new `Menu` family (`Menu`, `MenuItem`, `MenuRadioItem`, `MenuLabel`, `MenuSeparator`) that the account, project, organization, list-settings, dock, permission and file menus now share in place of hand-built rows.
+- **Tooltips:** `Tooltip`, `TooltipLayer` and `TooltipPanel`, with the rule that hides a hint repeating text already shown whole.
+- **Dialogs:** the Esc layer stack (`pushEscLayer`, `useDialogLayer`, `useEscLayer`), `Modal`, `ConfirmModal`, `PagedDialog`, `Drawer`, `Sheet` and `Lightbox`, with the spring and sheet physics they animate by.
+- **Toasts and notices:** `Toaster` with its store (`toastSuccess`, `toastInfo`, `toastAttention`, `toastError`) and `NoticeStrip`.
+- **On code that came from main during the migration:** `Modal` keeps the Workspace finder's full-screen phone layout (`fullScreenOnPhone`); the Esc layer stack reports whether any layer is open (`hasEscLayers`), which the Web App installs as its shortcut blocker so no global shortcut runs behind a dialog or menu; `FormPickerTrigger` (the model picker's and the Workspace finder's trigger) moves with `FormPicker`; the conversation's link menu, the built-in browser's overflow menu and the Workspace finder's context menu use the `Menu` rows.
+
+## Details
+
+- `ConfirmModal` takes its confirm and cancel labels from every caller; the package no longer supplies a default.
+- The package's accessibility fallbacks gain the toast stack's name and its dismiss hint.
+- Menu rows carry menu roles (`menuitem`, `menuitemradio`) instead of plain buttons.
+- The component gallery's frame keeps its height when a bottom sheet or drawer opens; it used to grow without end.
+
+## Visible changes in the default theme (Primer)
+
+- **Menus:** every menu row shares one padding and hover (`px-3 py-1.5`, a fainter hover fill); the current choice is filled and checked; row labels truncate to one line instead of wrapping; section labels are 12 px; danger rows are one step darker red.
+- **Project and organization switchers:** the current row is filled, medium weight and checked instead of only bold; "+" and Settings get glyphs; the organization group label is no longer uppercase.
+- **Dock add-menu:** rows lose the inset rounded hover; ink is darker and glyphs are smaller.
+- **Tooltip:** text one step darker in light and lighter in dark.
+- **Confirmation dialog (danger):** the warning mark sits on a neutral disc instead of a red one.
+- **Paged dialog:** the rail's active and hover fills are one step fainter; group headings take the eyebrow style.
+- **Lightbox:** a lighter backdrop (the shared dialog backdrop) and a token-drawn close button.
+- **Notice strips and toasts:** borders become neutral gray and text one step lighter in light; the dark toast fill is less saturated.
+- A few 11 px captions in dialogs and menus become 12 px.
diff --git a/changelog/unreleased/2026-09-30-ui-migration-w3.zh.md b/changelog/unreleased/2026-09-30-ui-migration-w3.zh.md
new file mode 100644
index 00000000..ffc1dd28
--- /dev/null
+++ b/changelog/unreleased/2026-09-30-ui-migration-w3.zh.md
@@ -0,0 +1,36 @@
+# 菜单、对话框、提示与 Toast 迁入共享 UI 包
+
+- **Date:** 2026-09-30
+- **Type:** refactor
+- **Scope:** `ui`, `web`, `ui-gallery`
+
+[English](2026-09-30-ui-migration-w3.md)
+
+UI 包迁移的 W3 把 Web App 的浮层搬进 `@prismshadow/penguin-ui`:菜单与下拉框、提示、对话框与底部面板,以及 Toast。
+
+## 迁入的内容
+
+- **菜单**:`Dropdown`、`FormPicker`、`useRowContextMenu`,以及新增的 `Menu` 系列(`Menu`、`MenuItem`、`MenuRadioItem`、`MenuLabel`、`MenuSeparator`);账户、项目、组织、列表设置、Dock、权限与文件菜单改用它,取代各自手写的行。
+- **提示**:`Tooltip`、`TooltipLayer` 与 `TooltipPanel`,连同「文本已完整可见时不再显示提示」的规则。
+- **对话框**:Esc 层栈(`pushEscLayer`、`useDialogLayer`、`useEscLayer`)、`Modal`、`ConfirmModal`、`PagedDialog`、`Drawer`、`Sheet` 与 `Lightbox`,以及驱动其动画的弹簧与面板物理。
+- **Toast 与通知条**:`Toaster` 及其 store(`toastSuccess`、`toastInfo`、`toastAttention`、`toastError`)和 `NoticeStrip`。
+- **迁移期间 main 合入的代码**:`Modal` 保留 Workspace 查找器在手机上的全屏布局(`fullScreenOnPhone`);Esc 层栈可报告是否有层打开(`hasEscLayers`),Web App 以此作为快捷键拦截条件,对话框或菜单打开时全局快捷键不在其背后触发;`FormPickerTrigger`(模型选择器与 Workspace 查找器的触发按钮)随 `FormPicker` 迁入;对话中的链接菜单、内置浏览器的溢出菜单与 Workspace 查找器的右键菜单改用 `Menu` 行。
+
+## 细节
+
+- `ConfirmModal` 的确认与取消文案改由每个调用方提供,包内不再给默认值。
+- 包内无障碍兜底文案新增 Toast 栈的名称与关闭提示。
+- 菜单行带上菜单角色(`menuitem`、`menuitemradio`),不再是普通按钮。
+- 组件画廊的框架在底部面板或抽屉打开时保持高度,此前会无限增高。
+
+## 默认主题(Primer)的可见变化
+
+- **菜单**:所有菜单行统一内边距与悬停(`px-3 py-1.5`,悬停底色更浅);当前项填充并打勾;行文字单行截断,不再换行;分组标签为 12 px;危险项的红色深一级。
+- **项目与组织切换器**:当前项改为填充、中等字重并打勾,不再只是加粗;「+」与设置项配上图标;组织分组标签不再全大写。
+- **Dock 添加菜单**:行去掉内缩的圆角悬停;文字更深,图标更小。
+- **提示**:文字在浅色下深一级、深色下浅一级。
+- **确认对话框(危险)**:警示标记的底圆由红色改为中性色。
+- **分页对话框**:侧栏选中与悬停底色浅一级;分组标题改用 eyebrow 样式。
+- **Lightbox**:遮罩变浅(共用对话框遮罩),关闭按钮改由 Token 绘制。
+- **通知条与 Toast**:浅色下边框改为中性灰、文字浅一级;深色 Toast 底色饱和度降低。
+- 对话框与菜单中若干 11 px 的说明文字改为 12 px。
diff --git a/packages/ui-gallery/src/library/boards/dialogs.tsx b/packages/ui-gallery/src/library/boards/dialogs.tsx
index 89066650..635af148 100644
--- a/packages/ui-gallery/src/library/boards/dialogs.tsx
+++ b/packages/ui-gallery/src/library/boards/dialogs.tsx
@@ -1,23 +1,48 @@
-/** 对话框: Modal, ConfirmModal, Drawer and Sheet, each opened from a button and closed as the app closes it. */
+/**
+ * 对话框: Modal, ConfirmModal in both tones, PagedDialog, Drawer, Sheet and the Lightbox, each
+ * opened from a button (the lightbox from its thumbnail) and closed as the app closes it.
+ */
import { useState } from "react";
-import { Button, Input } from "@prismshadow/penguin-ui";
-import { ConfirmModal } from "../../../../web/src/components/ui/confirm-modal";
-import { Drawer } from "../../../../web/src/components/ui/drawer";
-import { Modal } from "../../../../web/src/components/ui/modal";
-import { Sheet } from "../../../../web/src/components/ui/sheet";
-import type { SheetSnap } from "../../../../web/src/components/ui/sheet";
+import {
+ Button,
+ ConfirmModal,
+ Drawer,
+ Input,
+ Modal,
+ PagedDialog,
+ Sheet,
+ ZoomableImage,
+} from "@prismshadow/penguin-ui";
+import type { PagedDialogGroup, SheetSnap } from "@prismshadow/penguin-ui";
import { BoardGroup } from "../../foundations/shared";
+import { BASE } from "../../lib/location";
import { useGallery } from "../../state";
+type Page = "general" | "appearance" | "account";
+
export function DialogsBoard() {
const { S } = useGallery();
const t = S.library.dialogs;
const [modal, setModal] = useState(false);
const [confirm, setConfirm] = useState(false);
+ const [saveConfirm, setSaveConfirm] = useState(false);
+ const [paged, setPaged] = useState(false);
+ const [page, setPage] = useState<Page>("general");
const [drawer, setDrawer] = useState(false);
const [sheet, setSheet] = useState(false);
const [snap, setSnap] = useState<SheetSnap>("half");
const [name, setName] = useState(t.modalTitle);
+ const groups: PagedDialogGroup<Page>[] = [
+ {
+ key: "app",
+ label: t.pagedGroups.app,
+ items: [
+ { key: "general", label: t.pages.general },
+ { key: "appearance", label: t.pages.appearance, info: t.appearanceInfo },
+ ],
+ },
+ { key: "you", label: t.pagedGroups.you, items: [{ key: "account", label: t.pages.account }] },
+ ];
return (
<div className="gf-board">
<BoardGroup title={t.modal}>
@@ -50,16 +75,44 @@ export function DialogsBoard() {
<Button variant="danger" onClick={() => setConfirm(true)}>
{t.openConfirm}
</Button>
+ <Button onClick={() => setSaveConfirm(true)}>{t.openSaveConfirm}</Button>
</div>
<ConfirmModal
open={confirm}
title={t.confirmTitle}
confirmLabel={t.confirmLabel}
+ cancelLabel={t.cancel}
onClose={() => setConfirm(false)}
onConfirm={() => setConfirm(false)}
>
{t.confirmBody}
</ConfirmModal>
+ <ConfirmModal
+ open={saveConfirm}
+ title={t.saveConfirmTitle}
+ tone="primary"
+ confirmLabel={t.save}
+ cancelLabel={t.cancel}
+ onClose={() => setSaveConfirm(false)}
+ onConfirm={() => setSaveConfirm(false)}
+ >
+ {t.saveConfirmBody}
+ </ConfirmModal>
+ </BoardGroup>
+ <BoardGroup title={t.paged}>
+ <div className="lib-row">
+ <Button onClick={() => setPaged(true)}>{t.openPaged}</Button>
+ </div>
+ <PagedDialog
+ open={paged}
+ onClose={() => setPaged(false)}
+ title={t.pagedTitle}
+ groups={groups}
+ active={page}
+ onSelect={setPage}
+ >
+ <p className="text-sm">{t.pageBody}</p>
+ </PagedDialog>
</BoardGroup>
<BoardGroup title={t.drawer}>
<div className="lib-row">
@@ -83,6 +136,15 @@ export function DialogsBoard() {
<p className="p-4 text-sm">{t.sheetBody}</p>
</Sheet>
</BoardGroup>
+ <BoardGroup title={t.lightbox} aside={t.lightboxHint}>
+ <div className="lib-row">
+ <ZoomableImage
+ src={`${BASE}/penguin-logo.svg`}
+ alt={t.lightboxAlt}
+ className="h-16 w-16"
+ />
+ </div>
+ </BoardGroup>
</div>
);
}
diff --git a/packages/ui-gallery/src/library/boards/notices.tsx b/packages/ui-gallery/src/library/boards/notices.tsx
index 45241a14..7025f40a 100644
--- a/packages/ui-gallery/src/library/boards/notices.tsx
+++ b/packages/ui-gallery/src/library/boards/notices.tsx
@@ -1,15 +1,13 @@
/**
- * 提示条: the app's NoticeStrip in every tone — plain, with the leading mark a call site draws
+ * 提示条: the package's NoticeStrip in every tone — plain, with the leading mark a call site draws
* (`data-slot="icon"`, which a theme that draws its own tone mark hides), and with actions.
*/
-import { Button } from "@prismshadow/penguin-ui";
-import { NoticeStrip } from "../../../../web/src/components/ui/notice-strip";
-import { toneDot } from "../../../../web/src/lib/tone";
-import type { Tone } from "../../../../web/src/lib/tone";
+import { Button, Dot, NoticeStrip } from "@prismshadow/penguin-ui";
+import type { NoticeStripTone } from "@prismshadow/penguin-ui";
import { BoardGroup } from "../../foundations/shared";
import { useGallery } from "../../state";
-const TONES: readonly Tone[] = ["link", "success", "busy", "attention", "danger", "muted"];
+const TONES: readonly NoticeStripTone[] = ["info", "success", "attention", "danger", "neutral"];
const STRIP_CLASS = "flex flex-wrap items-center gap-2 rounded-md border px-3 py-2 text-sm";
@@ -31,11 +29,9 @@ export function NoticesBoard() {
<div className="lib-stack">
{TONES.map((tone) => (
<NoticeStrip key={tone} tone={tone} className={STRIP_CLASS}>
- <span
- data-slot="icon"
- aria-hidden
- className={`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${toneDot[tone]}`}
- />
+ <span data-slot="icon" className="flex">
+ <Dot tone={tone} />
+ </span>
<span>{t.texts[tone]}</span>
</NoticeStrip>
))}
@@ -43,7 +39,7 @@ export function NoticesBoard() {
</BoardGroup>
<BoardGroup title={t.withActions}>
<div className="lib-stack">
- {(["link", "attention", "danger"] as const).map((tone) => (
+ {(["info", "attention", "danger"] as const).map((tone) => (
<NoticeStrip key={tone} tone={tone} className={STRIP_CLASS}>
<span className="min-w-0 flex-1">{t.texts[tone]}</span>
<span data-slot="actions" className="flex shrink-0 gap-2">
diff --git a/packages/ui-gallery/src/library/boards/pickers.tsx b/packages/ui-gallery/src/library/boards/pickers.tsx
index 1a4d2a92..43cf80ad 100644
--- a/packages/ui-gallery/src/library/boards/pickers.tsx
+++ b/packages/ui-gallery/src/library/boards/pickers.tsx
@@ -1,20 +1,27 @@
/**
- * 选择器: the package's Select, Segmented, Switch, ToggleRow, SwatchPicker and OptionMenu, and the
- * app's Dropdown, each holding its own choice.
+ * 选择器: the package's Select, Segmented, Switch, ToggleRow, SwatchPicker, OptionMenu and
+ * Dropdown, each holding its own choice, and the Menu rows at both densities.
*/
import { useState } from "react";
import {
ACCENT_PRESETS,
Button,
ChevronDown,
+ Dropdown,
+ ICONS,
+ Menu,
+ MenuItem,
+ MenuLabel,
+ MenuRadioItem,
+ MenuSeparator,
OptionMenu,
Segmented,
Select,
SwatchPicker,
Switch,
ToggleRow,
+ menuPanelClass,
} from "@prismshadow/penguin-ui";
-import { Dropdown, menuItemClass } from "../../../../web/src/components/ui/dropdown";
import { BoardGroup } from "../../foundations/shared";
import { useGallery } from "../../state";
@@ -36,6 +43,8 @@ export function PickersBoard() {
const [swatch, setSwatch] = useState(swatches[0]?.value ?? "");
const [permission, setPermission] = useState<string | null>(t.choices[1]?.value ?? null);
const [menuOpen, setMenuOpen] = useState(false);
+ const [groupBy, setGroupBy] = useState<"workspace" | "agent">("workspace");
+ const [sortBy, setSortBy] = useState<"recent" | "manual">("recent");
return (
<div className="gf-board">
<BoardGroup title={t.select}>
@@ -147,20 +156,68 @@ export function PickersBoard() {
</Button>
}
>
- {t.menuItems.map((item) => (
- <button
- key={item}
- type="button"
- role="menuitem"
- className={menuItemClass}
- onClick={() => setMenuOpen(false)}
- >
- {item}
- </button>
- ))}
+ <Menu>
+ <MenuItem glyph={ICONS.pin} label={t.menuPin} onSelect={() => setMenuOpen(false)} />
+ <MenuItem
+ glyph={ICONS.pencil}
+ label={t.menuRename}
+ onSelect={() => setMenuOpen(false)}
+ />
+ <MenuItem label={t.menuMove} onSelect={() => setMenuOpen(false)} />
+ <MenuSeparator />
+ <MenuItem
+ glyph={ICONS.trash}
+ label={t.menuDelete}
+ danger
+ onSelect={() => setMenuOpen(false)}
+ />
+ </Menu>
</Dropdown>
</div>
</BoardGroup>
+ <BoardGroup title={t.menuRows} aside={t.menuRowsHint}>
+ {/* The rows as an open panel shows them, side by side: the body rung, then the small. */}
+ <div className="lib-row items-start">
+ <div className={`${menuPanelClass} w-56`}>
+ <Menu density="md">
+ <MenuItem label={t.menuSettings} />
+ <MenuItem label={t.menuUpdate} trailing={t.menuVersion} />
+ <MenuItem label={t.menuSignOut} danger />
+ </Menu>
+ </div>
+ <div className={`${menuPanelClass} w-44`}>
+ <Menu density="sm">
+ <MenuLabel>{t.menuGroupBy}</MenuLabel>
+ <MenuRadioItem
+ glyph={ICONS.folder}
+ label={t.menuByWorkspace}
+ checked={groupBy === "workspace"}
+ onSelect={() => setGroupBy("workspace")}
+ />
+ <MenuRadioItem
+ glyph={ICONS.robot}
+ label={t.menuByAgent}
+ checked={groupBy === "agent"}
+ onSelect={() => setGroupBy("agent")}
+ />
+ <MenuSeparator />
+ <MenuLabel>{t.menuSortBy}</MenuLabel>
+ <MenuRadioItem
+ glyph={ICONS.clock}
+ label={t.menuRecent}
+ checked={sortBy === "recent"}
+ onSelect={() => setSortBy("recent")}
+ />
+ <MenuRadioItem
+ glyph={ICONS.arrowUpDown}
+ label={t.menuManual}
+ checked={sortBy === "manual"}
+ onSelect={() => setSortBy("manual")}
+ />
+ </Menu>
+ </div>
+ </div>
+ </BoardGroup>
</div>
);
}
diff --git a/packages/ui-gallery/src/library/boards/streaming.tsx b/packages/ui-gallery/src/library/boards/streaming.tsx
index b02e3752..9406a961 100644
--- a/packages/ui-gallery/src/library/boards/streaming.tsx
+++ b/packages/ui-gallery/src/library/boards/streaming.tsx
@@ -12,9 +12,8 @@
* shares the live reply's grid cell), so the frame does not grow line by line as text arrives.
*/
import { useEffect, useMemo, useState } from "react";
-import { STREAM_REVEALS } from "@prismshadow/penguin-ui";
+import { STREAM_REVEALS, usePrefersReducedMotion } from "@prismshadow/penguin-ui";
import type { StreamReveal } from "@prismshadow/penguin-ui";
-import { usePrefersReducedMotion } from "../../../../web/src/components/ui/use-reduced-motion";
import { AssistantReplyBody } from "../../../../web/src/features/chat/assistant-reply-body";
import { streamScript } from "../../app/mock/stream-script";
import { streamingAnswer } from "../../app/mock/transcripts";
diff --git a/packages/ui-gallery/src/library/boards/toasts.tsx b/packages/ui-gallery/src/library/boards/toasts.tsx
index bdb93315..1136f40c 100644
--- a/packages/ui-gallery/src/library/boards/toasts.tsx
+++ b/packages/ui-gallery/src/library/boards/toasts.tsx
@@ -1,11 +1,14 @@
-/** 提示弹窗: the toast after an action completes, in its four kinds, fired from buttons (the Toaster is mounted by the frame). */
-import { Button } from "@prismshadow/penguin-ui";
+/**
+ * 提示弹窗: the package's toast after an action completes, in its four kinds, fired from buttons
+ * (the Toaster is mounted by the frame).
+ */
import {
+ Button,
toastAttention,
toastError,
toastInfo,
toastSuccess,
-} from "../../../../web/src/components/ui/toast";
+} from "@prismshadow/penguin-ui";
import { BoardGroup } from "../../foundations/shared";
import { useGallery } from "../../state";
diff --git a/packages/ui-gallery/src/library/boards/tooltips.tsx b/packages/ui-gallery/src/library/boards/tooltips.tsx
index ea518a6a..be28e2fd 100644
--- a/packages/ui-gallery/src/library/boards/tooltips.tsx
+++ b/packages/ui-gallery/src/library/boards/tooltips.tsx
@@ -1,6 +1,5 @@
-/** 悬停提示: the app's one tooltip, by attribute (read by the frame's TooltipLayer) and by component, and on a truncated line. */
-import { Button } from "@prismshadow/penguin-ui";
-import { Tooltip } from "../../../../web/src/components/ui/tooltip";
+/** 悬停提示: the package's one tooltip, by attribute (read by the frame's TooltipLayer) and by component, and on a truncated line. */
+import { Button, ICONS, Tooltip } from "@prismshadow/penguin-ui";
import { BoardGroup } from "../../foundations/shared";
import { useGallery } from "../../state";
@@ -48,11 +47,16 @@ export function TooltipsBoard() {
</BoardGroup>
<BoardGroup title={t.component} aside={t.componentHint}>
<div className="lib-row">
- <Tooltip label={t.beside} placement="right">
- <Button size="sm">{t.beside}</Button>
+ {/* Icon-only triggers: a hint never shows over a label the reader can already read whole. */}
+ <Tooltip label={t.besideTip} placement="right">
+ <Button size="icon" aria-label={t.besideTip}>
+ <Glyph d={ICONS.chevronRight} />
+ </Button>
</Tooltip>
- <Tooltip label={t.below} placement="bottom">
- <Button size="sm">{t.below}</Button>
+ <Tooltip label={t.belowTip} placement="bottom">
+ <Button size="icon" aria-label={t.belowTip}>
+ <Glyph d={ICONS.arrowDownToLine} />
+ </Button>
</Tooltip>
</div>
</BoardGroup>
diff --git a/packages/ui-gallery/src/library/frame-height.ts b/packages/ui-gallery/src/library/frame-height.ts
index 7786efb1..e8d61f17 100644
--- a/packages/ui-gallery/src/library/frame-height.ts
+++ b/packages/ui-gallery/src/library/frame-height.ts
@@ -16,8 +16,12 @@
* otherwise grow it without end.
* The height shrinks back as soon as an overlay closes; it is a function of what is there.
*
- * `measureFrameHeight` reads those rects off a document; only the direct children of the body
- * other than the app's root count as overlays.
+ * `measureFrameHeight` reads those rects off a document. The overlays are the direct children of
+ * the body other than the app's root, and the outermost fixed-position boxes inside the board: a
+ * panel the app renders in place rather than in a portal (the bottom sheet, the drawer) is
+ * anchored to the viewport, not laid out in the board, so it is measured as an overlay. Counted as
+ * board content, a sheet parked below the viewport before it slides in would put the board's
+ * bottom near twice the frame's height, and the frame would double on every measure.
*/
export interface MeasuredMain {
@@ -71,12 +75,13 @@ export function coversViewport(
/** A painted box: anything with no size is not on screen and says nothing about the height. */
const painted = (rect: DOMRect) => rect.width > 0 && rect.height > 0;
-/** The lowest visible edge of an element and everything inside it. */
-function lowestEdge(el: Element): number {
+/** The lowest visible edge of an element and everything inside it, bar the `skip` subtrees. */
+function lowestEdge(el: Element, skip: readonly Element[] = []): number {
let bottom = -Infinity;
const rect = el.getBoundingClientRect();
if (painted(rect)) bottom = rect.bottom;
for (const child of el.querySelectorAll("*")) {
+ if (skip.some((s) => s.contains(child))) continue;
const r = child.getBoundingClientRect();
if (painted(r)) bottom = Math.max(bottom, r.bottom);
}
@@ -93,6 +98,18 @@ function panelHeightIn(el: Element, viewportHeight: number): number {
return tallest;
}
+/** The outermost fixed-position boxes inside an element, in document order. */
+function fixedBoxesIn(el: Element): Element[] {
+ const view = el.ownerDocument.defaultView;
+ if (!view) return [];
+ const found: Element[] = [];
+ for (const child of el.querySelectorAll("*")) {
+ if (found.some((f) => f.contains(child))) continue;
+ if (view.getComputedStyle(child).position === "fixed") found.push(child);
+ }
+ return found;
+}
+
/** Reads the board and the overlays off a document and applies the rule. */
export function measureFrameHeight(
doc: Document,
@@ -101,13 +118,16 @@ export function measureFrameHeight(
options: FrameHeightOptions = FRAME_HEIGHT_OPTIONS,
): number {
const viewportHeight = doc.defaultView?.innerHeight ?? 0;
+ const inPlace = fixedBoxesIn(main);
const measuredMain: MeasuredMain = {
bottom: main.getBoundingClientRect().bottom,
- contentBottom: lowestEdge(main),
+ contentBottom: lowestEdge(main, inPlace),
};
+ const portals = Array.from(doc.body.children).filter(
+ (el) => el !== root && el.tagName !== "SCRIPT" && el.tagName !== "STYLE",
+ );
const overlays: MeasuredOverlay[] = [];
- for (const el of Array.from(doc.body.children)) {
- if (el === root || el.tagName === "SCRIPT" || el.tagName === "STYLE") continue;
+ for (const el of [...portals, ...inPlace]) {
const rect = el.getBoundingClientRect();
if (coversViewport(rect, viewportHeight)) {
overlays.push({
diff --git a/packages/ui-gallery/src/library/main.tsx b/packages/ui-gallery/src/library/main.tsx
index 7507abad..bc4f390f 100644
--- a/packages/ui-gallery/src/library/main.tsx
+++ b/packages/ui-gallery/src/library/main.tsx
@@ -11,8 +11,7 @@
*/
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
-import { Toaster } from "../../../web/src/components/ui/toast";
-import { TooltipLayer } from "../../../web/src/components/ui/tooltip";
+import { Toaster, TooltipLayer } from "@prismshadow/penguin-ui";
import { LocaleProvider, LocaleScope } from "../../../web/src/state/locale";
import { ThemeProvider } from "../../../web/src/state/theme";
// The app's dependency, reached through its own node_modules, ahead of the app's own sheet.
diff --git a/packages/ui-gallery/src/strings-en.ts b/packages/ui-gallery/src/strings-en.ts
index 14fdc8a5..9f301c9c 100644
--- a/packages/ui-gallery/src/strings-en.ts
+++ b/packages/ui-gallery/src/strings-en.ts
@@ -403,7 +403,7 @@ export const en: GalleryStrings = {
pickers: {
title: "Pickers",
description:
- "Select, segmented control, switch and toggle rows, swatches, option menu and dropdown.",
+ "Select, segmented control, switch and toggle rows, swatches, option menu, dropdown and menu rows.",
},
toasts: {
title: "Toasts",
@@ -416,7 +416,7 @@ export const en: GalleryStrings = {
},
dialogs: {
title: "Dialogs",
- description: "Modal, confirmation, drawer and bottom sheet.",
+ description: "Modal, confirmation, paged dialog, drawer, bottom sheet and lightbox.",
},
tooltips: {
title: "Tooltips",
@@ -581,7 +581,23 @@ export const en: GalleryStrings = {
],
dropdown: "Dropdown",
menu: "More actions",
- menuItems: ["Pin", "Rename", "Move to…", "Delete"],
+ menuPin: "Pin",
+ menuRename: "Rename",
+ menuMove: "Move to…",
+ menuDelete: "Delete",
+ menuRows: "Menu rows",
+ menuRowsHint:
+ "Two densities: the account and project menus on the body size, a row's more and context menus on the small size.",
+ menuSettings: "Settings",
+ menuUpdate: "Check for updates",
+ menuVersion: "v0.2.13",
+ menuSignOut: "Sign out",
+ menuGroupBy: "Group by",
+ menuByWorkspace: "By Workspace",
+ menuByAgent: "By agent",
+ menuSortBy: "Sort by",
+ menuRecent: "Recently active",
+ menuManual: "Manual order",
},
toasts: {
fire: "Fire a toast",
@@ -600,12 +616,11 @@ export const en: GalleryStrings = {
dotted: "With a leading mark",
withActions: "With actions",
texts: {
- link: "Version 0.3.0 is available.",
+ info: "Version 0.3.0 is available.",
success: "Index rebuilt: 214 files.",
- busy: "Syncing the corpus…",
attention: "1 unexpected error.",
danger: "The model returned 401: invalid key.",
- muted: "This session is archived.",
+ neutral: "This session is archived.",
},
action: "View",
dismiss: "Dismiss",
@@ -622,6 +637,16 @@ export const en: GalleryStrings = {
confirmTitle: "Delete this session?",
confirmBody: "The transcript and the Trace files go with it; this cannot be undone.",
confirmLabel: "Delete",
+ openSaveConfirm: "Save changes…",
+ saveConfirmTitle: "Save these changes?",
+ saveConfirmBody: "The agent uses the new settings from its next task.",
+ paged: "Paged dialog",
+ openPaged: "Open settings",
+ pagedTitle: "Settings",
+ pagedGroups: { app: "App", you: "Account" },
+ pages: { general: "General", appearance: "Appearance", account: "Profile" },
+ pageBody: "The current page's settings go here.",
+ appearanceInfo: "Theme, accent and density apply to this browser only.",
drawer: "Drawer",
openDrawer: "Open a drawer",
drawerTitle: "Navigation",
@@ -630,6 +655,9 @@ export const en: GalleryStrings = {
openSheet: "Open a sheet",
sheetTitle: "Files",
sheetBody: "Drag up for the full screen, down to close.",
+ lightbox: "Lightbox",
+ lightboxHint: "Click the thumbnail to zoom in; Esc or a click outside the image closes it.",
+ lightboxAlt: "The Penguin logo",
},
tooltips: {
attribute: "The data-tooltip attribute",
@@ -642,8 +670,8 @@ export const en: GalleryStrings = {
edit: "Edit",
copy: "Copy",
settings: "Settings",
- beside: "Beside",
- below: "Below",
+ besideTip: "Opens to the right of its trigger",
+ belowTip: "Opens under its trigger",
command:
"pnpm --filter @prismshadow/penguin-web exec vitest run test/session-activity.test.ts --reporter verbose",
},
diff --git a/packages/ui-gallery/src/strings.ts b/packages/ui-gallery/src/strings.ts
index dff671b2..9de9fcd5 100644
--- a/packages/ui-gallery/src/strings.ts
+++ b/packages/ui-gallery/src/strings.ts
@@ -405,14 +405,17 @@ export const zh = {
},
pickers: {
title: "选择器",
- description: "下拉选择、分段控件、开关与开关行、色板、选项菜单与下拉菜单。",
+ description: "下拉选择、分段控件、开关与开关行、色板、选项菜单、下拉菜单与菜单行。",
},
toasts: {
title: "提示弹窗",
description: "完成操作后的弹出提示:成功、信息、注意与错误,按按钮触发。",
},
notices: { title: "提示条", description: "占据一行的提示:每种语气,带与不带操作。" },
- dialogs: { title: "对话框", description: "模态对话框、确认框、抽屉与底部面板。" },
+ dialogs: {
+ title: "对话框",
+ description: "模态对话框、确认框、分页对话框、抽屉、底部面板与图片放大。",
+ },
tooltips: {
title: "悬停提示",
description: "悬停与聚焦时出现的提示:data-tooltip 属性与 Tooltip 组件。",
@@ -549,7 +552,22 @@ export const zh = {
] as readonly { value: string; trigger: string; label: string; description: string }[],
dropdown: "下拉菜单",
menu: "更多操作",
- menuItems: ["置顶", "重命名", "移动到…", "删除"] as readonly string[],
+ menuPin: "置顶",
+ menuRename: "重命名",
+ menuMove: "移动到…",
+ menuDelete: "删除",
+ menuRows: "菜单行",
+ menuRowsHint: "两种密度:账号与项目菜单用正文字号,行的更多菜单与右键菜单用小字号。",
+ menuSettings: "设置",
+ menuUpdate: "检查更新",
+ menuVersion: "v0.2.13",
+ menuSignOut: "退出登录",
+ menuGroupBy: "分组方式",
+ menuByWorkspace: "按工作区",
+ menuByAgent: "按 Agent",
+ menuSortBy: "排序方式",
+ menuRecent: "最近活跃",
+ menuManual: "手动排序",
},
toasts: {
fire: "触发一条提示",
@@ -568,12 +586,11 @@ export const zh = {
dotted: "带前导标记",
withActions: "带操作",
texts: {
- link: "新版本 0.3.0 可用。",
+ info: "新版本 0.3.0 可用。",
success: "索引已重建,共 214 个文件。",
- busy: "正在同步语料库…",
attention: "有 1 条未预期错误。",
danger: "模型返回 401:密钥无效。",
- muted: "这个会话已归档。",
+ neutral: "这个会话已归档。",
},
action: "查看",
dismiss: "忽略",
@@ -590,6 +607,16 @@ export const zh = {
confirmTitle: "删除这个会话?",
confirmBody: "对话记录与 Trace 文件会一并删除,无法恢复。",
confirmLabel: "删除",
+ openSaveConfirm: "保存修改…",
+ saveConfirmTitle: "保存这些修改?",
+ saveConfirmBody: "智能体从下一个任务开始使用新的设置。",
+ paged: "分页对话框",
+ openPaged: "打开设置",
+ pagedTitle: "设置",
+ pagedGroups: { app: "应用", you: "账号" },
+ pages: { general: "通用", appearance: "外观", account: "个人资料" },
+ pageBody: "当前页的设置项放在这里。",
+ appearanceInfo: "主题、强调色与密度只作用于这个浏览器。",
drawer: "抽屉",
openDrawer: "打开抽屉",
drawerTitle: "导航",
@@ -598,6 +625,9 @@ export const zh = {
openSheet: "打开底部面板",
sheetTitle: "文件",
sheetBody: "向上拖动展开到整屏,向下拖动关闭。",
+ lightbox: "图片放大",
+ lightboxHint: "点击缩略图放大;按 Esc 或点击图片以外的地方关闭。",
+ lightboxAlt: "企鹅标志",
},
tooltips: {
attribute: "data-tooltip 属性",
@@ -609,8 +639,8 @@ export const zh = {
edit: "编辑",
copy: "复制",
settings: "设置",
- beside: "右侧",
- below: "下方",
+ besideTip: "在触发元素右侧弹出",
+ belowTip: "在触发元素下方弹出",
command:
"pnpm --filter @prismshadow/penguin-web exec vitest run test/session-activity.test.ts --reporter verbose",
},
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 557546ab..85d74110 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -37,7 +37,8 @@
"@fontsource-variable/jetbrains-mono": "^5.3.0",
"@fontsource-variable/mona-sans": "^5.3.0",
"@fontsource-variable/noto-sans-sc": "^5.3.0",
- "@fontsource/ibm-plex-sans-condensed": "^5.3.0"
+ "@fontsource/ibm-plex-sans-condensed": "^5.3.0",
+ "zustand": "^5.0.15"
},
"devDependencies": {
"@types/node": "^24.0.0",
diff --git a/packages/ui/src/components/feedback/notice/notice-strip.tsx b/packages/ui/src/components/feedback/notice/notice-strip.tsx
new file mode 100644
index 00000000..8e1c05e9
--- /dev/null
+++ b/packages/ui/src/components/feedback/notice/notice-strip.tsx
@@ -0,0 +1,74 @@
+/**
+ * A notice that owns a row: an error line, a warning above a form, a status strip — and, drawn by
+ * the Toaster, a toast. The caller keeps its own layout, spacing, radius and border width
+ * (`border`, `border-b` or none), so every strip sits where its caller puts it; the strip adds
+ * the tone.
+ *
+ * The tone is a tint with its own ink (`bg-tone-<t>-bg text-tone-<t>-fg`) on the neutral line
+ * (`border-line`): the tint alone says which tone it is, and a tinted box that also took its
+ * tone's line would say it twice.
+ *
+ * It carries the `ui-notice` hook, so a theme can render notices its own way — a floating card
+ * with a tone dot, a console status line with a tone tag — without a call site knowing.
+ * `data-tone` names the tone in the hook's words ({@link NOTICE_TONE}). Children may mark their
+ * parts with `data-slot`: `"body"` for the text, `"title"` for a heading, `"actions"` for the
+ * buttons, and `"icon"` for a mark the caller draws before its text (a dot, a glyph). A mark
+ * belongs in that slot: a theme that draws its own tone mark hides the slot, so a mark left
+ * outside it would show twice. An action's own glyph, inside its button, is not the notice's
+ * mark. (The web app's `notice-chart-hooks` test holds every call site to this.)
+ */
+import type { HTMLAttributes, ReactNode } from "react";
+import type { ToneName } from "../../../tokens";
+
+/** The `ui-notice` hook's tone words: what `data-tone` says and the theme recipes select on. */
+export type NoticeTone = "info" | "success" | "warning" | "danger" | "neutral";
+
+/** The tones a notice takes: every semantic tone but `done`, which the hook has no word for. */
+export type NoticeStripTone = Exclude<ToneName, "done">;
+
+/** The tones in the hook's words: an unfinished state warns, a settled one is neutral. */
+export const NOTICE_TONE: Readonly<Record<NoticeStripTone, NoticeTone>> = {
+ info: "info",
+ success: "success",
+ attention: "warning",
+ danger: "danger",
+ neutral: "neutral",
+};
+
+/** A tone's tint and the ink that reads on it. */
+const TONE_CLASS: Readonly<Record<NoticeStripTone, string>> = {
+ info: "bg-tone-info-bg text-tone-info-fg",
+ success: "bg-tone-success-bg text-tone-success-fg",
+ attention: "bg-tone-attention-bg text-tone-attention-fg",
+ danger: "bg-tone-danger-bg text-tone-danger-fg",
+ neutral: "bg-tone-neutral-bg text-tone-neutral-fg",
+};
+
+export function NoticeStrip({
+ tone,
+ as: Tag = "div",
+ className = "",
+ children,
+ ...rest
+}: {
+ tone: NoticeStripTone;
+ /**
+ * A strip that is one sentence of prose may be a paragraph; a notice the reader presses (a
+ * toast, which dismisses itself) is a button, and gets `type="button"`.
+ */
+ as?: "div" | "p" | "button";
+ /** Layout, spacing, radius and border width; the colours are the tone's. */
+ className?: string;
+ children?: ReactNode;
+} & Omit<HTMLAttributes<HTMLElement>, "className" | "children">) {
+ return (
+ <Tag
+ {...rest}
+ {...(Tag === "button" ? { type: "button" as const } : {})}
+ data-tone={NOTICE_TONE[tone]}
+ className={`ui-notice ${className} border-line ${TONE_CLASS[tone]}`}
+ >
+ {children}
+ </Tag>
+ );
+}
diff --git a/packages/web/src/components/ui/form-picker.tsx b/packages/ui/src/components/forms/select/form-picker.tsx
similarity index 88%
rename from packages/web/src/components/ui/form-picker.tsx
rename to packages/ui/src/components/forms/select/form-picker.tsx
index b4975041..1a90aa76 100644
--- a/packages/web/src/components/ui/form-picker.tsx
+++ b/packages/ui/src/components/forms/select/form-picker.tsx
@@ -12,9 +12,11 @@
* and close on pick).
*/
import type { ReactNode } from "react";
-import { ChevronDown, controlBase, sizeClass } from "@prismshadow/penguin-ui";
-import type { ControlSize } from "@prismshadow/penguin-ui";
-import { Dropdown } from "./dropdown";
+import { ChevronDown } from "../../icons/marks/marks";
+import { Dropdown } from "../../overlays/dropdown/dropdown";
+import { controlBase } from "../field/field";
+import { sizeClass } from "../input/input";
+import type { ControlSize } from "../input/input";
/** The trigger's own props: everything FormPicker draws, minus the menu it hangs. */
export interface FormPickerTriggerProps {
@@ -67,10 +69,12 @@ export function FormPickerTrigger({
className={`flex w-full items-center gap-2 text-left ${controlBase} ${sizeClass[size]} disabled:cursor-not-allowed disabled:opacity-60`}
>
{leading}
- <span className={`min-w-0 flex-1 truncate ${muted ? "text-gray-400" : ""} ${labelClassName}`}>
+ <span
+ className={`min-w-0 flex-1 truncate ${muted ? "text-fg-subtle" : ""} ${labelClassName}`}
+ >
{label}
</span>
- <ChevronDown className="text-gray-400" />
+ <ChevronDown className="text-fg-subtle" />
</button>
);
}
diff --git a/packages/ui/src/components/forms/select/option-menu.tsx b/packages/ui/src/components/forms/select/option-menu.tsx
index 7de079f2..55eac4c4 100644
--- a/packages/ui/src/components/forms/select/option-menu.tsx
+++ b/packages/ui/src/components/forms/select/option-menu.tsx
@@ -53,8 +53,8 @@ const PANEL_WIDTH = 288; // w-72
* A row description's font size per tier. Descriptions sit on the small rung: at the base tier
* that is a step below the row title; at the sm tier the title is already on the small rung and
* there is no rung below it, so the two share a size and the description stands apart by its
- * muted ink alone (a fixed `text-[Npx]` would ignore the user's font-size setting). Hand-built
- * menus that mimic this row (the protocol suffix menu) read it from here.
+ * muted ink alone (a fixed `text-[Npx]` would ignore the user's font-size setting). The Menu
+ * rows' description sits on the same small rung.
*/
export const rowDescClass: Record<ControlSize, string> = { base: "text-xs", sm: "text-xs" };
diff --git a/packages/web/src/components/ui/confirm-modal.tsx b/packages/ui/src/components/overlays/confirm-modal/confirm-modal.tsx
similarity index 50%
rename from packages/web/src/components/ui/confirm-modal.tsx
rename to packages/ui/src/components/overlays/confirm-modal/confirm-modal.tsx
index dfee7dcd..4783970b 100644
--- a/packages/web/src/components/ui/confirm-modal.tsx
+++ b/packages/ui/src/components/overlays/confirm-modal/confirm-modal.tsx
@@ -1,28 +1,32 @@
/**
- * Confirmation dialog for destructive or overwriting actions (delete,
- * overwrite-on-update, save-to-file, …), deliberately minimal: **no title bar** —
- * just the tone icon, the message and a small Cancel / Confirm pair, so every
- * confirmation in the app is one compact, identical card. `tone` picks the look —
- * danger (red) for deletions, primary for saves and other overwrites. The message
- * and any details (e.g. a version list) go in children; `title` only names the
- * dialog for assistive tech (never rendered).
+ * Confirmation dialog for destructive or overwriting actions (delete, overwrite-on-update,
+ * save-to-file, …), deliberately minimal: **no title bar** — just the tone mark, the message and a
+ * small Cancel / Confirm pair, so every confirmation in the app is one compact, identical card.
+ * `tone` picks the look — danger for deletions, primary for saves and other overwrites. The
+ * message and any details (e.g. a version list) go in children; `title` only names the dialog for
+ * assistive tech (never rendered).
*
- * A dialog may add ONE extra choice (`secondaryLabel` + `onSecondary`) between Cancel
- * and Confirm — for prompts whose recommended path is the confirm button while a plain
- * "do it anyway" escape hatch has to stay one click away (the mid-chat thinking-level
- * switch: compact-then-switch / switch anyway / cancel). It stays the same card: a
- * neutral button in the same row, never a second primary. `confirmDisabled` covers the
- * case where that recommended action is temporarily unavailable — the body then says
- * why, and the other choices stay live.
+ * Both button labels are the caller's copy: what "confirm" means is the action's own verb
+ * (Delete, Overwrite, Save), and the app's dictionary owns the Cancel beside it.
+ *
+ * A dialog may add ONE extra choice (`secondaryLabel` + `onSecondary`) between Cancel and Confirm
+ * — for prompts whose recommended path is the confirm button while a plain "do it anyway" escape
+ * hatch has to stay one click away (the mid-chat thinking-level switch: compact-then-switch /
+ * switch anyway / cancel). It stays the same card: a neutral button in the same row, never a
+ * second primary. `confirmDisabled` covers the case where that recommended action is temporarily
+ * unavailable — the body then says why, and the other choices stay live.
*/
-import { useState } from "react";
import type { ReactNode } from "react";
-import { Button, ICONS } from "@prismshadow/penguin-ui";
-import { Modal } from "./modal";
-import { S } from "../../lib/strings";
+import { Button } from "../../actions/button/button";
+import { ICONS } from "../../icons/icons";
+import { Modal } from "../modal/modal";
-/** Tinted icon badge per tone: warning triangle on red for danger, pencil-on-gray for confirmations that overwrite/save. */
-function ToneBadge({ tone }: { tone: "danger" | "primary" }) {
+/**
+ * The card's leading mark: a warning triangle for danger, a pencil for confirmations that
+ * overwrite or save. The tone is carried by the glyph's ink alone, on the same neutral disc for
+ * both — an icon never sits in a tint of its own tone.
+ */
+function ToneMark({ tone }: { tone: "danger" | "primary" }) {
const glyph =
tone === "danger"
? ICONS.triangleAlert
@@ -31,10 +35,8 @@ function ToneBadge({ tone }: { tone: "danger" | "primary" }) {
return (
<span
aria-hidden
- className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-full ${
- tone === "danger"
- ? "bg-red-100 text-red-600 dark:bg-red-950/60 dark:text-red-400"
- : "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"
+ className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-line-muted ${
+ tone === "danger" ? "text-tone-danger-fg" : "text-tone-neutral-fg"
}`}
>
<svg
@@ -53,26 +55,16 @@ function ToneBadge({ tone }: { tone: "danger" | "primary" }) {
);
}
-export function ConfirmModal({
- open,
- title,
- onClose,
- onConfirm,
- confirmLabel,
- confirmDisabled = false,
- secondaryLabel,
- onSecondary,
- tone = "danger",
- busy = false,
- children,
-}: {
+export interface ConfirmModalProps {
open: boolean;
/** Accessible dialog name only — the compact card renders no title bar. */
title: string;
onClose: () => void;
onConfirm: () => void;
- /** Confirm button text (defaults to the shared "Confirm"). */
- confirmLabel?: string;
+ /** Confirm button text: the action's own verb where it has one, else the app's "Confirm". */
+ confirmLabel: string;
+ /** Cancel button text, from the app's dictionary. */
+ cancelLabel: string;
/** Disables ONLY the confirm button (its action is temporarily unavailable — the body copy is expected to say why); Cancel and the secondary action stay clickable. */
confirmDisabled?: boolean;
/** Optional third choice, rendered as a neutral button between Cancel and Confirm; needs `onSecondary` to appear. */
@@ -83,18 +75,33 @@ export function ConfirmModal({
tone?: "danger" | "primary";
busy?: boolean;
children: ReactNode;
-}) {
+}
+
+export function ConfirmModal({
+ open,
+ title,
+ onClose,
+ onConfirm,
+ confirmLabel,
+ cancelLabel,
+ confirmDisabled = false,
+ secondaryLabel,
+ onSecondary,
+ tone = "danger",
+ busy = false,
+ children,
+}: ConfirmModalProps) {
return (
<Modal open={open} title={title} onClose={onClose} headerless widthClass="sm:max-w-sm">
<div className="flex items-start gap-3">
- <ToneBadge tone={tone} />
+ <ToneMark tone={tone} />
<div className="min-w-0 flex-1 pt-1.5">{children}</div>
</div>
{/* Wraps rather than overflows: three choices with long labels don't fit one row inside
the bottom-sheet width on a phone (a two-button card never reaches the wrap point). */}
<div className="mt-4 flex flex-wrap justify-end gap-2">
<Button size="sm" onClick={onClose} disabled={busy}>
- {S.common.cancel}
+ {cancelLabel}
</Button>
{secondaryLabel !== undefined && onSecondary !== undefined && (
<Button size="sm" onClick={onSecondary} disabled={busy}>
@@ -102,38 +109,9 @@ export function ConfirmModal({
</Button>
)}
<Button size="sm" variant={tone} disabled={busy || confirmDisabled} onClick={onConfirm}>
- {confirmLabel ?? S.common.confirm}
+ {confirmLabel}
</Button>
</div>
</Modal>
);
}
-
-/**
- * Shared confirm-before-save flow for the settings forms: `requestSave(run)` opens a
- * standard "save these changes?" dialog and Confirm executes `run`. The caller decides
- * beforehand whether there is anything to save (no changes → an info toast, not a
- * dialog). Render `element` once per surface.
- */
-export function useSaveConfirm(): {
- requestSave: (run: () => void) => void;
- element: ReactNode;
-} {
- const [pending, setPending] = useState<(() => void) | null>(null);
- const element = (
- <ConfirmModal
- open={pending !== null}
- title={S.common.confirmSaveTitle}
- tone="primary"
- confirmLabel={S.common.save}
- onClose={() => setPending(null)}
- onConfirm={() => {
- pending?.();
- setPending(null);
- }}
- >
- <p className="text-sm text-gray-600 dark:text-gray-300">{S.common.confirmSaveBody}</p>
- </ConfirmModal>
- );
- return { requestSave: (run: () => void) => setPending(() => run), element };
-}
diff --git a/packages/ui/src/components/overlays/drawer/drawer.tsx b/packages/ui/src/components/overlays/drawer/drawer.tsx
new file mode 100644
index 00000000..0a5e3627
--- /dev/null
+++ b/packages/ui/src/components/overlays/drawer/drawer.tsx
@@ -0,0 +1,62 @@
+/**
+ * Drawer component (for mobile nav/panels): overlay fades in + panel slides in from the side; Esc
+ * or clicking the overlay closes it. `side` determines the docking direction; the panel width
+ * defaults to 80vw, capped by widthClass.
+ *
+ * Escape goes through the shared Escape-layer stack, so a dialog or menu opened from inside a
+ * drawer takes the first Escape alone: without that, one press would close the confirmation *and*
+ * the drawer under it, dropping the panel the user was working in.
+ */
+import type { ReactNode } from "react";
+import { CloseButton } from "../../actions/close-button/close-button";
+import { useEscLayer } from "../esc-layers/esc-layers";
+
+export interface DrawerProps {
+ open: boolean;
+ side?: "left" | "right";
+ title?: string;
+ onClose: () => void;
+ children: ReactNode;
+ /** Panel max-width class (default max-w-xs). */
+ widthClass?: string;
+ /** The header's close cross's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
+}
+
+export function Drawer({
+ open,
+ side = "left",
+ title,
+ onClose,
+ children,
+ widthClass,
+ closeLabel,
+}: DrawerProps) {
+ useEscLayer(open, onClose);
+
+ if (!open) return null;
+ return (
+ <div className="fixed inset-0 z-50">
+ <div
+ // ui-scrim: the dimmed layer behind the drawer; a theme may blur the page through it.
+ className="ui-scrim anim-fade absolute inset-0 bg-[var(--ui-overlay-backdrop)]"
+ onMouseDown={onClose}
+ />
+ <div
+ className={`absolute inset-y-0 flex w-[80vw] flex-col bg-surface shadow-xl ${widthClass ?? "max-w-xs"} ${
+ side === "left"
+ ? "anim-drawer-left left-0 border-r border-line"
+ : "anim-drawer-right right-0 border-l border-line"
+ }`}
+ >
+ <div className="flex shrink-0 items-center justify-between border-b border-line px-4 py-3">
+ <span className="text-base font-semibold">{title ?? ""}</span>
+ <CloseButton onClose={onClose} label={closeLabel} />
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]">
+ {children}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/web/src/components/ui/sheet.tsx b/packages/ui/src/components/overlays/drawer/sheet.tsx
similarity index 90%
rename from packages/web/src/components/ui/sheet.tsx
rename to packages/ui/src/components/overlays/drawer/sheet.tsx
index 52019471..709de57b 100644
--- a/packages/web/src/components/ui/sheet.tsx
+++ b/packages/ui/src/components/overlays/drawer/sheet.tsx
@@ -17,7 +17,9 @@
* animation); prefers-reduced-motion degrades to a fade plus a direct snap
* into position.
* - Body scroll is locked while open; Esc or clicking the overlay closes it;
- * focus returns to the element that had it before opening.
+ * focus returns to the element that had it before opening. Escape goes
+ * through the shared Escape-layer stack, so a dialog or menu opened from
+ * inside the sheet takes the first Escape alone.
*
* Coordinate system: the panel sits at bottom-0 with height 92dvh (FULL_FRACTION
* and the class must be changed together), translateY y is in [0, panel height],
@@ -26,11 +28,12 @@
*/
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
import type { PointerEvent as ReactPointerEvent, ReactNode } from "react";
-import { CloseButton } from "@prismshadow/penguin-ui";
-import { usePrefersReducedMotion } from "./use-reduced-motion";
-import { SPRING_DEFAULT, SPRING_MOMENTUM, createSpringDriver } from "../../lib/spring";
-import type { SpringDriver } from "../../lib/spring";
-import { nearestSnap, project, rubberband } from "../../lib/sheet-physics";
+import { CloseButton } from "../../actions/close-button/close-button";
+import { nearestSnap, project, rubberband } from "../../../motion/sheet-physics";
+import { SPRING_DEFAULT, SPRING_MOMENTUM, createSpringDriver } from "../../../motion/spring";
+import type { SpringDriver } from "../../../motion/spring";
+import { usePrefersReducedMotion } from "../../../motion/use-reduced-motion";
+import { useEscLayer } from "../esc-layers/esc-layers";
export type SheetSnap = "half" | "full";
@@ -48,9 +51,19 @@ export interface SheetProps {
onClose: () => void;
title?: string;
children: ReactNode;
+ /** The header's close cross's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
}
-export function Sheet({ open, snap, onSnapChange, onClose, title, children }: SheetProps) {
+export function Sheet({
+ open,
+ snap,
+ onSnapChange,
+ onClose,
+ title,
+ children,
+ closeLabel,
+}: SheetProps) {
// Don't unmount immediately when open=false: unmount only after the exit animation finishes (onSettle).
const [mounted, setMounted] = useState(open);
const panelRef = useRef<HTMLDivElement | null>(null);
@@ -154,14 +167,9 @@ export function Sheet({ open, snap, onSnapChange, onClose, title, children }: Sh
};
}, [mounted]);
- useEffect(() => {
- if (!mounted || !open) return;
- const onKey = (e: KeyboardEvent) => {
- if (e.key === "Escape") onClose();
- };
- window.addEventListener("keydown", onKey);
- return () => window.removeEventListener("keydown", onKey);
- }, [mounted, open, onClose]);
+ // Escape closes only while the sheet is the topmost layer: a dialog or menu opened from inside
+ // it is closed first.
+ useEscLayer(mounted && open, onClose);
// Focus restoration: return to the element that had focus before opening, after closing.
useEffect(() => {
@@ -271,7 +279,7 @@ export function Sheet({ open, snap, onSnapChange, onClose, title, children }: Sh
/>
<div
ref={panelRef}
- className={`absolute inset-x-0 bottom-0 flex h-[92dvh] flex-col overflow-hidden rounded-t-2xl border-t border-gray-200 bg-white shadow-2xl dark:border-gray-800 dark:bg-gray-900 ${
+ className={`absolute inset-x-0 bottom-0 flex h-[92dvh] flex-col overflow-hidden rounded-t-2xl border-t border-line bg-surface shadow-[var(--ui-shadow-drawer)] ${
reduced ? "anim-fade" : ""
}`}
style={{ transform: "translate3d(0, 100%, 0)" }}
@@ -287,10 +295,14 @@ export function Sheet({ open, snap, onSnapChange, onClose, title, children }: Sh
// Also fires after a normal pointerup — the draggingRef guard in onPointerCancel prevents double handling.
onLostPointerCapture={onPointerCancel}
>
- <div className="mx-auto mt-2 h-1 w-9 rounded-full bg-gray-300 dark:bg-gray-600" />
+ <div className="mx-auto mt-2 h-1 w-9 rounded-full bg-line-emphasis" />
<div className="flex items-center justify-between px-4 pb-2 pt-1.5">
<span className="text-base font-semibold">{title ?? ""}</span>
- <CloseButton onClose={onClose} onPointerDown={(e) => e.stopPropagation()} />
+ <CloseButton
+ onClose={onClose}
+ label={closeLabel}
+ onPointerDown={(e) => e.stopPropagation()}
+ />
</div>
</div>
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)]">
diff --git a/packages/web/src/components/ui/dropdown.tsx b/packages/ui/src/components/overlays/dropdown/dropdown.tsx
similarity index 94%
rename from packages/web/src/components/ui/dropdown.tsx
rename to packages/ui/src/components/overlays/dropdown/dropdown.tsx
index 9411c7fb..0babd189 100644
--- a/packages/web/src/components/ui/dropdown.tsx
+++ b/packages/ui/src/components/overlays/dropdown/dropdown.tsx
@@ -3,16 +3,17 @@
* positioned (z-40, per the layering convention — chrome avoids stacking contexts, in-flow
* menus are z-40, overlays are z-50, and **portaled** popups are z-[60] so they clear an
* open Modal, matching Select's portal panel). menuClass controls the docking direction and
- * width.
+ * width. The rows inside are the caller's — the Menu family (`Menu`, `MenuItem`, …) for a plain
+ * menu, or any body a picker needs (a search box over a list, a directory browser).
*
* `portal` switches the panel to the shared popup strategy (same idea as OptionMenu's
- * use-portal-panel): mounted on document.body with `position: fixed` against viewport
+ * usePortalPanel): mounted on document.body with `position: fixed` against viewport
* coordinates, so **no ancestor's overflow can clip it**. Anchoring inside a scrolling
* container (the composer toolbar scrolls horizontally on phones) makes that mandatory:
* setting one axis to a non-`visible` overflow makes the other compute to `auto` too, so an
* absolutely-positioned panel — an upward one especially — is clipped away entirely.
*
- * Escape goes through the shared esc-layer stack (see modal.tsx): while open, the menu is
+ * Escape goes through the shared esc-layer stack (esc-layers.ts): while open, the menu is
* the topmost layer, so one Escape closes only the menu even inside a Modal — the Modal's
* own handler sees itself not on top and stays; the next Escape closes the dialog. The
* event is deliberately NOT stopped, so element-level Escape handlers inside the panel
@@ -21,7 +22,7 @@
* Keyboard: opening moves focus to the panel's first focusable item, Up/Down walk the
* items (wrapping), and closing via Escape returns focus to the trigger — without this a
* keyboard user could open a menu and never reach its contents, which is exactly what
- * happened when the sidebar's row actions moved from bare buttons into these panels.
+ * happened when a list's row actions moved from bare buttons into these panels.
*
* `anchorRect` turns the same panel into a context menu: placement measures the given
* viewport box instead of the container's own, so the menu can hang off the point a
@@ -37,20 +38,19 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react
import { createPortal } from "react-dom";
import type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from "react";
import {
- menuPanelClass,
- menuRowClass,
- menuRowTone,
- scrollMovesAnchor,
-} from "@prismshadow/penguin-ui";
-import { FOCUSABLE_SELECTOR, isTopEscLayer, popEscLayer, pushEscLayer } from "./modal";
+ FOCUSABLE_SELECTOR,
+ isTopEscLayer,
+ popEscLayer,
+ pushEscLayer,
+} from "../esc-layers/esc-layers";
+import { menuPanelClass } from "../menu-panel/menu-panel";
+import type { AnchorRect } from "../portal-panel/context-menu";
+import { scrollMovesAnchor } from "../portal-panel/use-portal-panel";
/** Gap between the trigger and the portaled panel, and the panel's minimum distance from the viewport edge (px). */
const PANEL_GAP = 4;
const VIEWPORT_MARGIN = 8;
-/** The panel's plain row: full-width, left-aligned, hover-filled. Shared so menus opened from different anchors cannot drift apart on density. */
-export const menuItemClass = `block ${menuRowClass} text-sm ${menuRowTone()}`;
-
/** Portal docking: which way the panel opens and which of its edges lines up with the trigger. */
export interface DropdownPortal {
direction: "up" | "down";
@@ -82,7 +82,11 @@ export function Dropdown({
menuStyle?: CSSProperties;
/** Extra classes for the root container (e.g. flex-1 in a flex layout). */
className?: string;
- /** Render the panel through a body portal at fixed viewport coordinates, escaping any clipping ancestor. */
+ /**
+ * Render the panel through a body portal at fixed viewport coordinates, escaping any clipping
+ * ancestor. New menus pass it; the in-flow panel stays only for the call sites that still sit
+ * in an unclipped container.
+ */
portal?: DropdownPortal;
/**
* Place the panel against this viewport box instead of the container's own — a context
@@ -90,7 +94,7 @@ export function Dropdown({
* Requires `portal`. While set, a scroll that moved the anchored content dismisses the
* panel rather than re-placing it — see `anchorOwner` for which scrolls those are.
*/
- anchorRect?: { top: number; bottom: number; left: number; right: number } | null;
+ anchorRect?: AnchorRect | null;
/**
* The element the `anchorRect` was measured from. A scroll then dismisses the panel only
* when this element moved with it, which is what keeps a context menu in the sidebar
diff --git a/packages/ui/src/components/overlays/esc-layers/esc-layers.ts b/packages/ui/src/components/overlays/esc-layers/esc-layers.ts
new file mode 100644
index 00000000..fe9df714
--- /dev/null
+++ b/packages/ui/src/components/overlays/esc-layers/esc-layers.ts
@@ -0,0 +1,169 @@
+/**
+ * The Escape-layer stack and the focus rules every overlay shares: dialogs, drawers, sheets, the
+ * lightbox and popup menus all register here, so one Escape press closes exactly one layer — the
+ * topmost — and a dialog hands focus in and back the same way wherever it is drawn.
+ *
+ * Kept apart from `Modal` because the menus need the same stack without the dialog: a Dropdown
+ * opened inside a Modal pushes above it, so the first Escape closes only the menu and the next
+ * one the dialog.
+ */
+import { useEffect, useRef } from "react";
+import type { KeyboardEvent as ReactKeyboardEvent, RefObject } from "react";
+
+/**
+ * Stack of currently open Escape-consuming layers: Escape only acts on the **topmost** one.
+ * Modals AND popup menus join the same stack. When dialogs are nested (a confirmation popped
+ * inside a settings modal), each registers its own window keydown handler; without checking the
+ * top of the stack, a single Escape would close both layers at once and discard unsaved edits in
+ * the outer one. Pushed in mount order, so the top of the stack is the visually topmost layer.
+ */
+const escLayers: symbol[] = [];
+
+/** Register an Escape-consuming layer (called when an overlay opens); pair with popEscLayer. */
+export function pushEscLayer(): symbol {
+ const id = Symbol("esc-layer");
+ escLayers.push(id);
+ return id;
+}
+
+/** Remove a layer pushed by {@link pushEscLayer}; a layer already gone is a no-op. */
+export function popEscLayer(id: symbol): void {
+ const i = escLayers.lastIndexOf(id);
+ if (i !== -1) escLayers.splice(i, 1);
+}
+
+/** Whether this layer is the topmost one — the only layer an Escape press may act on. */
+export function isTopEscLayer(id: symbol): boolean {
+ return escLayers[escLayers.length - 1] === id;
+}
+
+/**
+ * Whether any dialog or menu is open — the state in which an app-wide keyboard shortcut must not
+ * run behind it. The app installs this as its shortcut blocker.
+ */
+export function hasEscLayers(): boolean {
+ return escLayers.length > 0;
+}
+
+/**
+ * Joins the Escape stack while `active`: an Escape press calls `onEscape` only while this layer
+ * is the topmost one. The overlays with no focus ring of their own (Drawer, Sheet, Lightbox) use
+ * it directly; {@link useDialogLayer} builds on it.
+ *
+ * `onEscape` is read through a ref so the effect re-runs ONLY when `active` flips: call sites pass
+ * an inline arrow, and re-running on its identity would pop and re-push the layer on every render
+ * — jumping it back above a menu or dialog opened inside it, so Escape would close the outer layer
+ * instead of the inner one.
+ */
+export function useEscLayer(active: boolean, onEscape: () => void): void {
+ const onEscapeRef = useRef(onEscape);
+ onEscapeRef.current = onEscape;
+
+ useEffect(() => {
+ if (!active) return;
+ const id = pushEscLayer();
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === "Escape" && isTopEscLayer(id)) onEscapeRef.current();
+ };
+ window.addEventListener("keydown", onKey);
+ return () => {
+ window.removeEventListener("keydown", onKey);
+ popEscLayer(id);
+ };
+ }, [active]);
+}
+
+/**
+ * The elements an overlay hands focus to, in DOM order. Shared by dialogs and menus so both agree
+ * on what "focusable" means. Visually hidden controls stay in the set on purpose: the app's file
+ * pickers are hidden the `sr-only` way rather than with `display: none` precisely so they keep
+ * their place in the Tab order (`HiddenFileInput`).
+ */
+export const FOCUSABLE_SELECTOR =
+ 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
+
+/**
+ * Index that Tab — or Shift+Tab, `backward` — moves to within a ring of `count` focusables,
+ * wrapping at both ends so focus cannot walk out of the dialog. `at` is -1 when focus sits on the
+ * panel container itself rather than on one of the ring's elements, which enters the ring at
+ * whichever end the direction implies.
+ */
+export function nextFocusIndex(count: number, at: number, backward: boolean): number {
+ if (at < 0) return backward ? count - 1 : 0;
+ return (at + (backward ? -1 : 1) + count) % count;
+}
+
+/**
+ * What makes a portaled panel a dialog for the keyboard, shared by Modal and the overlays that own
+ * their layout (the command palette, the harness history): Escape closes it only while it is the
+ * topmost Escape-consuming layer; opening moves focus into the panel and closing hands it back;
+ * Tab and Shift+Tab cycle inside it. The returned `onKeyDown` goes on the panel element, which
+ * also needs `tabIndex={-1}` so it can hold focus when nothing inside can.
+ *
+ * `onClose` is read through a ref (see {@link useEscLayer}), so the effects re-run ONLY on
+ * open/close.
+ */
+export function useDialogLayer(
+ open: boolean,
+ panelRef: RefObject<HTMLElement | null>,
+ onClose: () => void,
+): { onKeyDown: (e: ReactKeyboardEvent<HTMLElement>) => void } {
+ useEscLayer(open, onClose);
+
+ // Where focus goes when the dialog closes, read during render rather than in the effect below:
+ // a child with `autoFocus` is focused during the same commit, before any effect runs, so by
+ // effect time document.activeElement already points inside the dialog and the element to
+ // return to is gone. Written only on the closed->open edge, so reopening from a different
+ // trigger returns to that trigger, and a StrictMode double-mount — whose extra cleanup restores
+ // focus once before the real one — does not drop the target.
+ const restoreFocusRef = useRef<HTMLElement | null>(null);
+ const wasOpenRef = useRef(false);
+ if (open !== wasOpenRef.current) {
+ wasOpenRef.current = open;
+ if (open)
+ restoreFocusRef.current =
+ document.activeElement instanceof HTMLElement ? document.activeElement : null;
+ }
+
+ // Opening moves focus into the panel, closing hands it back. `aria-modal` tells assistive tech
+ // the page behind is out of scope but moves nothing, so without this a keyboard user stays
+ // parked on the trigger with the dialog's own controls several Tabs away.
+ useEffect(() => {
+ if (!open) return;
+ const panel = panelRef.current;
+ // A child with autoFocus already claimed focus during the commit — leave it there.
+ if (panel && !panel.contains(document.activeElement))
+ (panel.querySelector<HTMLElement>(FOCUSABLE_SELECTOR) ?? panel).focus();
+ // Every close path lands in this cleanup: Escape, the close button, the overlay mousedown,
+ // `open` going false, and the dialog unmounting outright.
+ return () => restoreFocusRef.current?.focus();
+ // Keyed on `open` alone (a ref object is stable), so the cleanup runs for every close path.
+ }, [open]);
+
+ /**
+ * Tab and Shift+Tab cycle inside the panel instead of walking out into the page behind the
+ * overlay.
+ *
+ * Two things this must not take over. A control that owns Tab for its own model (the composer's
+ * slash picker accepts a completion with it) marks the event handled, and this yields to that
+ * the way Dropdown's arrow keys do. And a menu or popover opened from inside the dialog is
+ * portaled to body — outside this panel's DOM subtree, yet still a React child, so its keydown
+ * bubbles through here; the containment check leaves that panel's own focus alone.
+ */
+ const onPanelKeyDown = (e: ReactKeyboardEvent<HTMLElement>) => {
+ if (e.key !== "Tab" || e.defaultPrevented) return;
+ const panel = panelRef.current;
+ if (!panel?.contains(document.activeElement)) return;
+ e.preventDefault();
+ const items = [...panel.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)];
+ // A dialog with nothing focusable in it keeps focus on the container, which is what the
+ // panel's tabIndex={-1} is for.
+ if (items.length === 0) {
+ panel.focus();
+ return;
+ }
+ const at = items.indexOf(document.activeElement as HTMLElement);
+ items[nextFocusIndex(items.length, at, e.shiftKey)]?.focus();
+ };
+ return { onKeyDown: onPanelKeyDown };
+}
diff --git a/packages/ui/src/components/overlays/lightbox/lightbox.tsx b/packages/ui/src/components/overlays/lightbox/lightbox.tsx
new file mode 100644
index 00000000..4cebe748
--- /dev/null
+++ b/packages/ui/src/components/overlays/lightbox/lightbox.tsx
@@ -0,0 +1,91 @@
+/**
+ * The lightbox: an image shown large over the page, in a bordered frame with a close glyph in the
+ * top-right corner (no title bar), closable via Esc or clicking the overlay. `ZoomableImage` is the
+ * thumbnail that opens it: the thumbnail keeps the caller's styling, and a click zooms in.
+ *
+ * The lightbox is rendered via portal to body — the thumbnail may be nested inside a card with a
+ * transform entrance animation or overflow-hidden, and a `fixed` layer rendered in place would get
+ * hijacked or clipped by that ancestor (the same reason the Select panel portals). Escape goes
+ * through the shared Escape-layer stack like every other overlay's, so a lightbox opened from
+ * inside a dialog closes alone and leaves the dialog up.
+ */
+import { useState } from "react";
+import { createPortal } from "react-dom";
+import { useUiStrings } from "../../../strings";
+import { CloseIcon } from "../../icons/marks/marks";
+import { useEscLayer } from "../esc-layers/esc-layers";
+
+export interface LightboxProps {
+ open: boolean;
+ src: string;
+ alt: string;
+ onClose: () => void;
+ /** The close glyph's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
+}
+
+export function Lightbox({ open, src, alt, onClose, closeLabel }: LightboxProps) {
+ const strings = useUiStrings();
+ useEscLayer(open, onClose);
+
+ if (!open) return null;
+ return createPortal(
+ <div
+ // ui-scrim: the overlay is the dimmed layer, with the image inside it.
+ className="ui-scrim anim-fade fixed inset-0 z-50 flex items-center justify-center bg-[var(--ui-overlay-backdrop)] p-10"
+ onMouseDown={(e) => {
+ if (e.target === e.currentTarget) onClose();
+ }}
+ >
+ <div className="anim-pop relative">
+ {/* Close glyph: top-right inside the frame, floating over the image on a translucent
+ disc of the ink colour, which keeps it visible on any image. */}
+ <button
+ type="button"
+ aria-label={closeLabel ?? strings.close}
+ onClick={onClose}
+ className="absolute right-2 top-2 flex h-7 w-7 items-center justify-center rounded-full bg-fg/50 text-canvas transition-colors duration-150 hover:bg-fg/70"
+ >
+ <CloseIcon />
+ </button>
+ <img
+ src={src}
+ alt={alt}
+ className="max-h-[85vh] max-w-[88vw] rounded-lg border border-line bg-surface"
+ />
+ </div>
+ </div>,
+ document.body,
+ );
+}
+
+/** A clickable image that opens itself in the {@link Lightbox}. */
+export function ZoomableImage({
+ src,
+ alt,
+ className,
+ closeLabel,
+}: {
+ src: string;
+ alt: string;
+ /** Style for the thumbnail img (keeps the caller's original class). */
+ className?: string;
+ /** The lightbox's close glyph's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
+}) {
+ const [open, setOpen] = useState(false);
+ return (
+ <>
+ <button type="button" className="block cursor-zoom-in" onClick={() => setOpen(true)}>
+ <img src={src} alt={alt} className={className} />
+ </button>
+ <Lightbox
+ open={open}
+ src={src}
+ alt={alt}
+ onClose={() => setOpen(false)}
+ closeLabel={closeLabel}
+ />
+ </>
+ );
+}
diff --git a/packages/ui/src/components/overlays/menu/menu.tsx b/packages/ui/src/components/overlays/menu/menu.tsx
new file mode 100644
index 00000000..b7cba019
--- /dev/null
+++ b/packages/ui/src/components/overlays/menu/menu.tsx
@@ -0,0 +1,215 @@
+/**
+ * The menu rows: one row family, at two densities, for every menu a Dropdown (or a context menu)
+ * opens. Built on the menu panel's row states (`menuRowClass`, `menuRowTone`, `ChoiceCheck`), so
+ * an action row, a current choice and a destructive row read the same wherever they are offered.
+ *
+ * - `Menu` is the list: `role="menu"`, named by `label`, and the density its rows take — `md`
+ * (the body rung) for an account or project menu, `sm` (the small rung) for a row's overflow
+ * and context menus. The panel around it stays the caller's `Dropdown`, which owns placement,
+ * dismissal and the Up/Down walk.
+ * - `MenuItem` is one row: an optional leading glyph, the label (and a muted description under
+ * it), an optional trailing note, and the check slot when it stands for a choice. A glyph given
+ * as a registry path is decorative (`ui-icon-decor`, role `menu`) and muted; a node (an avatar,
+ * a spinner) is drawn as given. `danger` sets the row in the danger tone, its glyph with it.
+ * With `href` the row is a link — a download, say — rather than a button.
+ * - `MenuRadioItem` is a row that picks one of several (`menuitemradio` inside a Menu).
+ * - `MenuSeparator` rules one group of rows off from the next; `MenuLabel` names the group below
+ * it in the small muted rung.
+ *
+ * Outside a `Menu` the rows are plain buttons with no menu role — a picker's list or a panel that
+ * mixes rows with other controls uses them that way, and adds whatever role its container needs
+ * (`role="option"` makes the row a listbox option, its state `aria-selected`).
+ */
+import { createContext, useContext } from "react";
+import type { ReactNode } from "react";
+import { ICON_GAP } from "../../../icon-scale";
+import { GlyphIcon } from "../../icons/glyph-icon/glyph-icon";
+import { ChoiceCheck, menuRowClass, menuRowTone } from "../menu-panel/menu-panel";
+
+/** A menu's row density: `md` rows on the body rung, `sm` rows on the small rung. */
+export type MenuDensity = "sm" | "md";
+
+const densityText: Record<MenuDensity, string> = { sm: "text-xs", md: "text-sm" };
+
+interface MenuScope {
+ density: MenuDensity;
+ /** Inside a `Menu`: rows take the menu roles. */
+ inMenu: boolean;
+}
+
+const MenuScopeContext = createContext<MenuScope>({ density: "md", inMenu: false });
+
+export function Menu({
+ label,
+ density = "md",
+ className,
+ children,
+}: {
+ /** The menu's accessible name, when the trigger that opened it does not already give one. */
+ label?: string;
+ /** Row density for every row inside (a row may still override it). */
+ density?: MenuDensity;
+ className?: string;
+ children: ReactNode;
+}) {
+ return (
+ <MenuScopeContext.Provider value={{ density, inMenu: true }}>
+ <div role="menu" aria-label={label} className={className}>
+ {children}
+ </div>
+ </MenuScopeContext.Provider>
+ );
+}
+
+/** The roles a row may take: a menu's three, or a listbox option. */
+export type MenuItemRole = "menuitem" | "menuitemcheckbox" | "menuitemradio" | "option";
+
+export interface MenuItemProps {
+ /** The row's words. */
+ label: ReactNode;
+ /** Runs when the row is chosen (for a link row, as it navigates). */
+ onSelect?: () => void;
+ /**
+ * The leading mark: a registry path (drawn as a decorative, muted glyph) or a node the caller
+ * sized — an avatar, a provider logo, a spinner.
+ */
+ glyph?: string | ReactNode;
+ /** A muted line under the label saying what the row does or when it applies. */
+ description?: ReactNode;
+ /** A muted note at the row's end: a keyboard shortcut, a count, a version, why it is disabled. */
+ trailing?: ReactNode;
+ /** Destructive: the row and its glyph take the danger tone. */
+ danger?: boolean;
+ /**
+ * Makes the row a choice: the current one is filled, set in the medium weight and checked, and
+ * every choice keeps the check's slot so the rows of one list align.
+ */
+ checked?: boolean;
+ disabled?: boolean;
+ /** Render the row as a link to this address instead of a button. */
+ href?: string;
+ /** With `href`: download the target under this file name. */
+ download?: string;
+ /** Overrides the density of the enclosing `Menu`. */
+ density?: MenuDensity;
+ /** Overrides the role the row takes from its container (see the module header). */
+ role?: MenuItemRole;
+ /** Layout extras on the row (a width, a margin); its look is the family's. */
+ className?: string;
+ "aria-label"?: string;
+ /** ARIA the caller's container needs on the row (`aria-current` on the open one, say). */
+ [aria: `aria-${string}`]: string | number | boolean | undefined;
+ /** Test and state hooks the caller reads back (`data-testid`, a hint, an id the row stands for). */
+ [data: `data-${string}`]: string | number | boolean | undefined;
+}
+
+/** Whether an optional slot has anything to draw (`cond && <X />` leaves `false` behind). */
+const shown = (node: ReactNode): boolean =>
+ node !== undefined && node !== null && node !== false && node !== "";
+
+/** The ARIA state a choice row carries, by its role. */
+function choiceState(
+ role: MenuItemRole | undefined,
+ checked: boolean | undefined,
+): { "aria-checked"?: boolean; "aria-selected"?: boolean } {
+ if (checked === undefined || role === undefined || role === "menuitem") return {};
+ return role === "option" ? { "aria-selected": checked } : { "aria-checked": checked };
+}
+
+export function MenuItem({
+ label,
+ onSelect,
+ glyph,
+ description,
+ trailing,
+ danger = false,
+ checked,
+ disabled = false,
+ href,
+ download,
+ density,
+ role,
+ className = "",
+ ...rest
+}: MenuItemProps) {
+ const scope = useContext(MenuScopeContext);
+ const size = density ?? scope.density;
+ const resolvedRole =
+ role ?? (scope.inMenu ? (checked === undefined ? "menuitem" : "menuitemcheckbox") : undefined);
+ const tone = danger
+ ? "text-tone-danger-fg hover:bg-tone-danger-bg"
+ : menuRowTone(checked === true);
+ const rowClass = `flex items-center ${ICON_GAP.menu} ${menuRowClass} ${densityText[size]} ${tone} disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent ${className}`;
+ const lead = !shown(glyph) ? null : typeof glyph === "string" ? (
+ <GlyphIcon d={glyph} decor="menu" className={danger ? "" : "text-fg-subtle"} />
+ ) : (
+ <span className="flex shrink-0 items-center">{glyph}</span>
+ );
+ const body = (
+ <>
+ {lead}
+ <span className="min-w-0 flex-1">
+ <span className="block truncate">{label}</span>
+ {shown(description) && (
+ <span className="mt-0.5 block text-xs text-fg-muted">{description}</span>
+ )}
+ </span>
+ {shown(trailing) && <span className="shrink-0 text-xs text-fg-subtle">{trailing}</span>}
+ {checked !== undefined && <ChoiceCheck on={checked} />}
+ </>
+ );
+ if (href !== undefined) {
+ return (
+ <a
+ {...rest}
+ href={href}
+ download={download}
+ role={resolvedRole}
+ onClick={onSelect}
+ className={rowClass}
+ >
+ {body}
+ </a>
+ );
+ }
+ return (
+ <button
+ {...rest}
+ type="button"
+ role={resolvedRole}
+ {...choiceState(resolvedRole, checked)}
+ disabled={disabled}
+ onClick={onSelect}
+ className={rowClass}
+ >
+ {body}
+ </button>
+ );
+}
+
+export type MenuRadioItemProps = Omit<MenuItemProps, "checked"> & {
+ /** Whether this is the current choice of its group. */
+ checked: boolean;
+};
+
+/** A row that picks one of several: `menuitemradio` inside a Menu, the choice look everywhere. */
+export function MenuRadioItem({ checked, role, ...props }: MenuRadioItemProps) {
+ const { inMenu } = useContext(MenuScopeContext);
+ return (
+ <MenuItem {...props} checked={checked} role={role ?? (inMenu ? "menuitemradio" : undefined)} />
+ );
+}
+
+/** The rule between two groups of rows. */
+export function MenuSeparator() {
+ return <div role="separator" className="my-1 border-t border-line-muted" />;
+}
+
+/** A group's name, above its rows, in the small muted rung; it is not a row and takes no focus. */
+export function MenuLabel({ children }: { children: ReactNode }) {
+ return (
+ <div role="presentation" className="px-3 pb-0.5 pt-1.5 text-xs font-medium text-fg-subtle">
+ {children}
+ </div>
+ );
+}
diff --git a/packages/ui/src/components/overlays/modal/modal.tsx b/packages/ui/src/components/overlays/modal/modal.tsx
new file mode 100644
index 00000000..27681a79
--- /dev/null
+++ b/packages/ui/src/components/overlays/modal/modal.tsx
@@ -0,0 +1,105 @@
+/**
+ * Modal dialog component: overlay fades in, panel rises into place; closes on Esc or clicking the
+ * overlay. Docked to the bottom on narrow screens (bottom sheet style), centered card at >=sm.
+ *
+ * **Rendered via portal to body**: the panel has its own transform entrance animation
+ * (anim-pop), which makes it a containing block for descendant `fixed` elements — if a nested
+ * modal (e.g. a delete confirmation inside a settings modal) rendered in place, its overlay would
+ * be confined to the parent panel's rectangle, leaving a misaligned edge (a white sliver showing
+ * through). After portaling, every modal is a sibling child of body and stacks naturally in DOM
+ * order.
+ *
+ * **Focus is contained**: opening moves focus into the panel, Tab and Shift+Tab cycle inside it,
+ * and closing returns focus to whatever held it before. `role="dialog"` plus `aria-modal`
+ * announce the page behind as out of scope, but neither moves focus — without the trap, Tab walks
+ * straight out of the overlay into content the dialog sits on top of. The keyboard wiring is
+ * {@link useDialogLayer}, shared with the overlays that own their layout.
+ */
+import { useId, useRef } from "react";
+import { createPortal } from "react-dom";
+import type { ReactNode } from "react";
+import { CloseButton } from "../../actions/close-button/close-button";
+import { useDialogLayer } from "../esc-layers/esc-layers";
+
+export interface ModalProps {
+ open: boolean;
+ /** Dialog name: rendered as the header bar and used to name the dialog, or (headerless) exposed as the panel's aria-label only. */
+ title: string;
+ onClose: () => void;
+ children: ReactNode;
+ footer?: ReactNode;
+ /** Panel width class (defaults to sm:max-w-md). */
+ widthClass?: string;
+ /** No header bar (no visible title, no close button): compact dialogs like confirmations — the title still names the dialog for assistive tech. */
+ headerless?: boolean;
+ /** Render children full-bleed: no built-in padding or 70vh scroller. For dialogs that own their inner layout and scroll regions (PagedDialog); the caller then also owns a close control. */
+ bare?: boolean;
+ /**
+ * Fill the whole screen on a phone instead of rising as a bottom sheet, and lay the panel out
+ * as a column so a `bare` body can take the height between header and footer. For dialogs
+ * that are a workspace of their own (the Workspace finder) rather than a question; pair it
+ * with an `sm:` height in `widthClass`, since above the breakpoint the panel is a card again.
+ */
+ fullScreenOnPhone?: boolean;
+ /** The header's close cross's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
+}
+
+export function Modal({
+ open,
+ title,
+ onClose,
+ children,
+ footer,
+ widthClass,
+ headerless,
+ bare,
+ fullScreenOnPhone,
+ closeLabel,
+}: ModalProps) {
+ const titleId = useId();
+ const panelRef = useRef<HTMLDivElement>(null);
+ const { onKeyDown: onPanelKeyDown } = useDialogLayer(open, panelRef, onClose);
+
+ if (!open) return null;
+ return createPortal(
+ <div
+ // ui-scrim: the dimmed layer between the page and the dialog; a theme may blur the page
+ // through it. The overlay is the scrim itself, with the dialog inside it.
+ className="ui-scrim anim-fade fixed inset-0 z-50 flex items-end justify-center bg-[var(--ui-overlay-backdrop)] p-0 sm:items-center sm:p-4"
+ onMouseDown={(e) => {
+ if (e.target === e.currentTarget) onClose();
+ }}
+ >
+ <div
+ ref={panelRef}
+ role="dialog"
+ aria-modal="true"
+ // The titled branch is named by its own heading rather than a second copy of the
+ // string, so a renamed dialog cannot end up announcing the old name.
+ {...(headerless ? { "aria-label": title } : { "aria-labelledby": titleId })}
+ tabIndex={-1}
+ onKeyDown={onPanelKeyDown}
+ className={`ui-glass anim-pop w-full ${widthClass ?? "sm:max-w-md"} ${
+ fullScreenOnPhone
+ ? "flex h-[100dvh] flex-col pt-[env(safe-area-inset-top)] sm:pt-0"
+ : "rounded-t-lg"
+ } border border-line bg-surface pb-[env(safe-area-inset-bottom)] shadow-xl sm:rounded-lg sm:pb-0`}
+ >
+ {!headerless && (
+ <div className="flex items-center justify-between border-b border-line px-4 py-3">
+ <h2 id={titleId} className="text-base font-semibold">
+ {title}
+ </h2>
+ <CloseButton onClose={onClose} label={closeLabel} />
+ </div>
+ )}
+ {bare ? children : <div className="max-h-[70vh] overflow-y-auto px-4 py-4">{children}</div>}
+ {footer && (
+ <div className="flex justify-end gap-2 border-t border-line px-4 py-3">{footer}</div>
+ )}
+ </div>
+ </div>,
+ document.body,
+ );
+}
diff --git a/packages/web/src/components/ui/paged-dialog.tsx b/packages/ui/src/components/overlays/paged-dialog/paged-dialog.tsx
similarity index 64%
rename from packages/web/src/components/ui/paged-dialog.tsx
rename to packages/ui/src/components/overlays/paged-dialog/paged-dialog.tsx
index 606fc322..d46e5755 100644
--- a/packages/web/src/components/ui/paged-dialog.tsx
+++ b/packages/ui/src/components/overlays/paged-dialog/paged-dialog.tsx
@@ -1,19 +1,20 @@
/**
- * PagedDialog: a large modal whose left rail switches sub-pages — the shared shell for
- * multi-page settings surfaces (Settings today; Project settings converges on the
- * same shell). Purely presentational: the caller owns which pages exist, which one is
- * active, and what the pane renders; the shell draws the rail (grouped, icon + label,
- * solid-fill active row — the sidebar's convention), the pane heading, and the close
- * control.
+ * PagedDialog: a large modal whose left rail switches sub-pages — the shared shell for multi-page
+ * settings surfaces (Settings today; Project settings converges on the same shell). Purely
+ * presentational: the caller owns which pages exist, which one is active, and what the pane
+ * renders; the shell draws the rail (grouped, icon + label, solid-fill active row — the sidebar's
+ * convention), the pane heading, and the close control.
*
- * Built on Modal, so it inherits the portal, the Escape layer stack (nested dialogs and
- * menus close in visual order) and the bottom-sheet posture on narrow screens — where the
- * rail folds into a horizontal scroller above the pane and group headings are dropped
- * along with the second dimension (Tabs' convention).
+ * Built on Modal, so it inherits the portal, the Escape layer stack (nested dialogs and menus
+ * close in visual order) and the bottom-sheet posture on narrow screens — where the rail folds
+ * into a horizontal scroller above the pane and group headings are dropped along with the second
+ * dimension (Tabs' convention).
*/
import type { ReactNode } from "react";
-import { CloseButton, ICON_GAP, InfoPopover } from "@prismshadow/penguin-ui";
-import { Modal } from "./modal";
+import { CloseButton } from "../../actions/close-button/close-button";
+import { ICON_GAP } from "../../../icon-scale";
+import { InfoPopover } from "../info-popover/info-popover";
+import { Modal } from "../modal/modal";
export interface PagedDialogItem<K extends string> {
key: K;
@@ -21,10 +22,10 @@ export interface PagedDialogItem<K extends string> {
/** Small leading glyph in the rail; sized by the caller (16px reads well). */
icon?: ReactNode;
/**
- * The page's semantic explanation, disclosed by a "?" beside the pane heading. It belongs
- * here rather than at the top of the page body because the heading is the only title a page
- * has — a "?" inside the body would be a mark modifying nothing, and a paragraph there would
- * be re-read on every visit.
+ * The page's semantic explanation, disclosed by a "?" beside the pane heading. It belongs here
+ * rather than at the top of the page body because the heading is the only title a page has — a
+ * "?" inside the body would be a mark modifying nothing, and a paragraph there would be re-read
+ * on every visit.
*/
info?: ReactNode;
}
@@ -36,12 +37,12 @@ export interface PagedDialogGroup<K extends string> {
items: ReadonlyArray<PagedDialogItem<K>>;
}
-/** Rail entry: solid gray fill when active, gray hover otherwise (the sidebar's convention). */
+/** Rail entry: a solid fill when active, a lighter fill on hover otherwise (the sidebar's convention). */
const railItemClass = (active: boolean) =>
`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${
active
- ? "bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100"
- : "text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"
+ ? "bg-line-muted font-medium text-fg"
+ : "text-fg-muted hover:bg-surface-muted hover:text-fg"
}`;
export function PagedDialog<K extends string>({
@@ -52,6 +53,7 @@ export function PagedDialog<K extends string>({
active,
onSelect,
children,
+ closeLabel,
}: {
open: boolean;
onClose: () => void;
@@ -62,6 +64,8 @@ export function PagedDialog<K extends string>({
onSelect: (key: K) => void;
/** The active page's content. */
children: ReactNode;
+ /** The close cross's accessible name; defaults to the interface's word for "close". */
+ closeLabel?: string;
}) {
const showGroupHeadings = groups.length > 1;
const activeItem = groups.flatMap((g) => g.items).find((item) => item.key === active);
@@ -73,12 +77,14 @@ export function PagedDialog<K extends string>({
{/* Rail: vertical on desktop, a horizontal scroller above the pane on narrow screens. */}
<nav
aria-label={title}
- className="flex shrink-0 gap-1 overflow-x-auto border-b border-gray-100 p-2 sm:w-44 sm:flex-col sm:overflow-x-visible sm:overflow-y-auto sm:border-b-0 sm:border-r sm:p-3 dark:border-gray-800"
+ className="flex shrink-0 gap-1 overflow-x-auto border-b border-line-muted p-2 sm:w-44 sm:flex-col sm:overflow-x-visible sm:overflow-y-auto sm:border-b-0 sm:border-r sm:p-3"
>
{groups.map((group) => (
<div key={group.key} className="contents sm:mt-3 sm:block sm:first:mt-0">
{showGroupHeadings && group.label !== undefined && (
- <p className="hidden px-2.5 pb-1 text-[11px] font-medium uppercase tracking-wide text-gray-400 sm:block dark:text-gray-500">
+ // ui-eyebrow: the group label's rung (size, weight, tracking and case are the
+ // theme's); only the spacing and the ink are this rail's.
+ <p className="ui-eyebrow hidden px-2.5 pb-1 text-fg-subtle sm:block">
{group.label}
</p>
)}
@@ -93,7 +99,7 @@ export function PagedDialog<K extends string>({
{item.icon !== undefined && (
<span
aria-hidden
- className="ui-icon-decor shrink-0 text-gray-400 dark:text-gray-500"
+ className="ui-icon-decor shrink-0 text-fg-subtle"
data-role="nav"
>
{item.icon}
@@ -114,7 +120,7 @@ export function PagedDialog<K extends string>({
<InfoPopover label={activeLabel}>{activeItem.info}</InfoPopover>
)}
</h2>
- <CloseButton onClose={onClose} />
+ <CloseButton onClose={onClose} label={closeLabel} />
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-4 pt-3 sm:px-6 sm:pb-6">
{children}
diff --git a/packages/web/src/lib/context-menu.ts b/packages/ui/src/components/overlays/portal-panel/context-menu.ts
similarity index 91%
rename from packages/web/src/lib/context-menu.ts
rename to packages/ui/src/components/overlays/portal-panel/context-menu.ts
index f8ab47ee..7751e14a 100644
--- a/packages/web/src/lib/context-menu.ts
+++ b/packages/ui/src/components/overlays/portal-panel/context-menu.ts
@@ -1,14 +1,14 @@
/**
- * Pure geometry and gesture rules behind a row context menu (the sidebar's Session rows
- * are the first user). The component half is `components/ui/context-menu.tsx`; the parts
- * that decide *where* a menu lands and *whether* a gesture counts as a request for one
- * live here so they can be tested in this package's node-only vitest environment.
+ * Pure geometry and gesture rules behind a row context menu (the app's Session rows are the
+ * first user). The hook half is `use-row-context-menu.ts`; the parts that decide *where* a menu
+ * lands and *whether* a gesture counts as a request for one live here so they can be tested in
+ * the package's node-only vitest environment.
*
- * A context menu must not be a mouse-only affordance: `design/specs/06-PROTOTYPE.md`
- * states that hover-reveal is desktop-only because touch screens have no hover, and a
- * secondary click is desktop-only for the same reason. So three gestures open the same
- * menu — a right-click at the pointer, the platform's keyboard chord against the focused
- * row, and press-and-hold on touch — and the rules for telling them apart are here.
+ * A context menu must not be a mouse-only affordance: hover-reveal is desktop-only because touch
+ * screens have no hover, and a secondary click is desktop-only for the same reason. So three
+ * gestures open the same menu — a right-click at the pointer, the platform's keyboard chord
+ * against the focused row, and press-and-hold on touch — and the rules for telling them apart
+ * are here.
*/
/** Viewport-space box a portaled panel is placed against (the Dropdown's `anchorRect`). */
diff --git a/packages/web/src/components/ui/context-menu.tsx b/packages/ui/src/components/overlays/portal-panel/use-row-context-menu.ts
similarity index 97%
rename from packages/web/src/components/ui/context-menu.tsx
rename to packages/ui/src/components/overlays/portal-panel/use-row-context-menu.ts
index e6651c48..e05c28ca 100644
--- a/packages/web/src/components/ui/context-menu.tsx
+++ b/packages/ui/src/components/overlays/portal-panel/use-row-context-menu.ts
@@ -17,7 +17,7 @@
*
* This half owns only the DOM: element rects, the hold timer, and dispatching events.
* Every decision — which gesture counts, which anchor, whether a dismiss is believed —
- * is pure and lives in `lib/context-menu.ts`, where the sequences can be tested without
+ * is pure and lives in `context-menu.ts` beside it, where the sequences can be tested without
* a DOM.
*/
import { useCallback, useEffect, useRef, useState } from "react";
@@ -35,8 +35,8 @@ import {
longPressMoved,
pointerAnchor,
reduceHold,
-} from "../../lib/context-menu";
-import type { AnchorRect, HoldEvent, HoldState } from "../../lib/context-menu";
+} from "./context-menu";
+import type { AnchorRect, HoldEvent, HoldState } from "./context-menu";
/** Handlers the owning row spreads onto its container element. */
export interface ContextMenuRowProps {
diff --git a/packages/ui/src/components/overlays/toaster/toaster.tsx b/packages/ui/src/components/overlays/toaster/toaster.tsx
new file mode 100644
index 00000000..48ab45a8
--- /dev/null
+++ b/packages/ui/src/components/overlays/toaster/toaster.tsx
@@ -0,0 +1,142 @@
+/**
+ * The top toasts: a result like "Saved" or "Connection failed" pops up at the top of the page and
+ * leaves by itself after a few seconds.
+ *
+ * Raise one from anywhere — `toastSuccess("Saved")`, `toastInfo("Already up to date")`,
+ * `toastAttention("Two desks share one minute")`, `toastError("Connection failed: …")` — with no
+ * context: a module-level store and one `<Toaster />` mounted at the app root are all it takes.
+ * The words are the caller's. The package adds only the stack's accessible name and the hint that
+ * pressing a toast dismisses it (`UiStrings`).
+ *
+ * A toast is a notice: each one renders through `NoticeStrip` as a button, so it carries the
+ * `ui-notice` hook and the strip's tone colours, and a theme that restyles notices restyles toasts
+ * with them. The stack is portaled to the body above dialogs and drawers (`z-[100]` over their
+ * `z-50`), so a toast raised inside a dialog is still seen; the stack lets the pointer through and
+ * only the toasts take it.
+ *
+ * The stack is a polite live region, and it stays mounted while empty: a region inserted together
+ * with its first message is often not announced at all.
+ *
+ * Each toast stands on an opaque backing in the overlay colour. The tone tints are translucent in
+ * the dark modes — they are drawn for a strip on a page surface — while a toast floats over
+ * whatever lies under it, which would otherwise show through its text. The backing takes the
+ * largest corner a notice recipe gives a toast (`rounded-lg`), so its corners never reach past
+ * the toast's own.
+ */
+import { useId } from "react";
+import { createPortal } from "react-dom";
+import { useStore } from "zustand/react";
+import { createStore } from "zustand/vanilla";
+import { useUiStrings } from "../../../strings";
+import { NoticeStrip } from "../../feedback/notice/notice-strip";
+import type { NoticeStripTone } from "../../feedback/notice/notice-strip";
+
+/** `attention` is the advisory kind: the write went through, and something in it needs a look. */
+export type ToastKind = "success" | "error" | "info" | "attention";
+
+export interface ToastItem {
+ id: number;
+ kind: ToastKind;
+ text: string;
+ /** Leaving: plays the exit animation first, and is removed from the list once it has run. */
+ leaving?: boolean;
+}
+
+/**
+ * How long a toast stays, ms: an error and an advisory both need reading, so they stay longest;
+ * info sits in between; a plain success is gone as soon as it is seen.
+ */
+const DURATION: Readonly<Record<ToastKind, number>> = {
+ success: 2500,
+ info: 4000,
+ attention: 6000,
+ error: 6000,
+};
+
+/** The exit animation's length, ms (the web app's `anim-toast-out`). */
+const LEAVE_MS = 160;
+
+const KIND_TONE: Readonly<Record<ToastKind, NoticeStripTone>> = {
+ success: "success",
+ error: "danger",
+ info: "info",
+ attention: "attention",
+};
+
+/** The toasts on screen, oldest first. Raise them through the functions below. */
+export const toastStore = createStore<{ items: ToastItem[] }>(() => ({ items: [] }));
+let nextId = 1;
+
+function dismiss(id: number): void {
+ const item = toastStore.getState().items.find((i) => i.id === id);
+ if (!item || item.leaving) return;
+ // Marked as leaving first, which plays the exit animation, and removed once it has run —
+ // otherwise the toast would vanish abruptly.
+ toastStore.setState((s) => ({
+ items: s.items.map((i) => (i.id === id ? { ...i, leaving: true } : i)),
+ }));
+ setTimeout(() => {
+ toastStore.setState((s) => ({ items: s.items.filter((i) => i.id !== id) }));
+ }, LEAVE_MS);
+}
+
+function push(kind: ToastKind, text: string): void {
+ if (!text) return;
+ const id = nextId++;
+ toastStore.setState((s) => ({ items: [...s.items, { id, kind, text }] }));
+ setTimeout(() => dismiss(id), DURATION[kind]);
+}
+
+export const toastSuccess = (text: string): void => push("success", text);
+export const toastError = (text: string): void => push("error", text);
+export const toastInfo = (text: string): void => push("info", text);
+export const toastAttention = (text: string): void => push("attention", text);
+
+/** The stack as it is drawn, without the portal: what `Toaster` renders into the body. */
+export function ToastStack({
+ items,
+ onDismiss,
+}: {
+ items: readonly ToastItem[];
+ /** Pressing a toast dismisses it at once. */
+ onDismiss: (id: number) => void;
+}) {
+ const strings = useUiStrings();
+ const hint = useId();
+ return (
+ <section
+ aria-label={strings.notifications}
+ aria-live="polite"
+ aria-relevant="additions text"
+ className="pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4"
+ >
+ <span id={hint} hidden>
+ {strings.dismiss}
+ </span>
+ {items.map((t) => (
+ <div
+ key={t.id}
+ className={`max-w-lg rounded-lg bg-overlay ${t.leaving ? "anim-toast-out" : "anim-toast-in"}`}
+ >
+ <NoticeStrip
+ as="button"
+ tone={KIND_TONE[t.kind]}
+ aria-describedby={hint}
+ onClick={() => onDismiss(t.id)}
+ className="pointer-events-auto block w-full break-words rounded-md border px-3 py-2 text-left text-sm shadow-lg"
+ >
+ <span data-slot="body">{t.text}</span>
+ </NoticeStrip>
+ </div>
+ ))}
+ </section>
+ );
+}
+
+/** The toast stack: mount once at the app root. */
+export function Toaster() {
+ const items = useStore(toastStore, (s) => s.items);
+ // A static render has no document to portal into, and nothing to show there.
+ if (typeof document === "undefined") return null;
+ return createPortal(<ToastStack items={items} onDismiss={dismiss} />, document.body);
+}
diff --git a/packages/web/src/components/ui/tooltip.tsx b/packages/ui/src/components/overlays/tooltip/tooltip.tsx
similarity index 98%
rename from packages/web/src/components/ui/tooltip.tsx
rename to packages/ui/src/components/overlays/tooltip/tooltip.tsx
index ae73c602..702e6c00 100644
--- a/packages/web/src/components/ui/tooltip.tsx
+++ b/packages/ui/src/components/overlays/tooltip/tooltip.tsx
@@ -24,9 +24,9 @@
*
* Portaled to document.body at fixed viewport coordinates, like every other overlay here
* (see use-portal-panel.ts): an in-place absolute panel is a descendant of its trigger, so a
- * scrolling or clipping ancestor — the collapsed rail is both — cuts it off. It sits on the
+ * scrolling or clipping ancestor — a collapsed rail is both — cuts it off. It sits on the
* portaled-panel layer (z-[60]) and takes no pointer events, so it can never swallow a click
- * meant for what it covers.
+ * meant for what it covers. It is drawn on the overlay surface every menu uses, in the body ink.
*
* Two geometries, chosen by the shape of the control strip rather than by taste: `right` for
* a vertical rail, `bottom` for a horizontal toolbar, where a panel to the side would cover
@@ -324,7 +324,7 @@ function TooltipPanel({
right: position.right,
maxWidth: `min(${contentMaxWidth[content]}, ${position.room}px)`,
}}
- className={`ui-glass anim-fade pointer-events-none z-[60] w-max rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 ${contentClass[content]} ${placement === "right" ? "-translate-y-1/2" : ""}`}
+ className={`ui-glass anim-fade pointer-events-none z-[60] w-max rounded-md border border-line bg-overlay px-2 py-1 text-xs text-fg shadow-lg ${contentClass[content]} ${placement === "right" ? "-translate-y-1/2" : ""}`}
>
{label}
</div>,
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 5f04ae0a..3c8079a9 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -69,3 +69,31 @@ export * from "./components/forms/toggle-row/toggle-row";
export * from "./components/forms/segmented/segmented";
export * from "./components/forms/swatch-picker/swatch-picker";
export * from "./components/forms/pref-row/pref-row";
+
+// W3-A — menus and hints: the dropdown panel and the Menu rows it holds, the row context menu
+// (its hook and its pure gesture rules), the form-style picker built on the dropdown, and the
+// tooltip with its document-wide `data-tooltip` layer.
+export * from "./components/overlays/dropdown/dropdown";
+export * from "./components/overlays/menu/menu";
+export * from "./components/overlays/portal-panel/context-menu";
+export * from "./components/overlays/portal-panel/use-row-context-menu";
+export * from "./components/forms/select/form-picker";
+export * from "./components/overlays/tooltip/tooltip";
+
+// W3-B — dialogs: the Escape-layer stack and focus rules every overlay shares, the modal family,
+// the drawer and the spring sheet with their motion helpers, and the lightbox.
+export * from "./components/overlays/esc-layers/esc-layers";
+export * from "./components/overlays/modal/modal";
+export * from "./components/overlays/confirm-modal/confirm-modal";
+export * from "./components/overlays/paged-dialog/paged-dialog";
+export * from "./components/overlays/drawer/drawer";
+export * from "./components/overlays/drawer/sheet";
+export * from "./components/overlays/lightbox/lightbox";
+export * from "./motion/spring";
+export * from "./motion/sheet-physics";
+export * from "./motion/use-reduced-motion";
+
+// W3-C — notices: the notice strip, and the toast stack that renders its toasts through it
+// (with the `toast*` functions and their store).
+export * from "./components/feedback/notice/notice-strip";
+export * from "./components/overlays/toaster/toaster";
diff --git a/packages/web/src/lib/sheet-physics.ts b/packages/ui/src/motion/sheet-physics.ts
similarity index 93%
rename from packages/web/src/lib/sheet-physics.ts
rename to packages/ui/src/motion/sheet-physics.ts
index a0f85a09..577387e5 100644
--- a/packages/web/src/lib/sheet-physics.ts
+++ b/packages/ui/src/motion/sheet-physics.ts
@@ -1,5 +1,5 @@
/**
- * Gesture math for the bottom Sheet (pure functions, unit-test covered):
+ * Gesture math for the bottom Sheet and the dock launcher (pure functions, unit-test covered):
* - project: projects release velocity to an inertial endpoint using the
* iOS scroll deceleration curve — the snap point is chosen from the
* projected point rather than the release point, so a quick flick can
diff --git a/packages/web/src/lib/spring.ts b/packages/ui/src/motion/spring.ts
similarity index 100%
rename from packages/web/src/lib/spring.ts
rename to packages/ui/src/motion/spring.ts
diff --git a/packages/ui/src/motion/use-reduced-motion.ts b/packages/ui/src/motion/use-reduced-motion.ts
new file mode 100644
index 00000000..f4d144cb
--- /dev/null
+++ b/packages/ui/src/motion/use-reduced-motion.ts
@@ -0,0 +1,45 @@
+/**
+ * Whether the reader asked their system to reduce motion, as live state.
+ *
+ * The stylesheets already disable CSS animations under that preference, so this hook is for what
+ * CSS cannot reach on its own: motion driven frame by frame in JS, and the one disclosure that
+ * has to know whether the keyframes are running at all (the app's truncated-text reveal). Its
+ * callers replace the animation with the resting state it would have ended on — the Sheet snaps to
+ * its target, the dock launcher's ball jumps home and its fan opens and folds without one.
+ *
+ * One query and one listener for the whole app rather than one per component: the truncated-text
+ * reveal reads this from every truncating row, and per-row media-query subscriptions are exactly
+ * what that reveal was built to avoid. Reading through `useSyncExternalStore` also closes the
+ * window a useState/useEffect pair leaves open, in which a change landing between the first render
+ * and the effect is never seen. The window guard keeps the module importable outside a browser,
+ * since the query is opened at import time.
+ */
+import { useSyncExternalStore } from "react";
+
+const QUERY = "(prefers-reduced-motion: reduce)";
+
+const query =
+ typeof window !== "undefined" && typeof window.matchMedia === "function"
+ ? window.matchMedia(QUERY)
+ : null;
+
+const listeners = new Set<() => void>();
+
+query?.addEventListener("change", () => {
+ for (const notify of listeners) notify();
+});
+
+function subscribe(onStoreChange: () => void): () => void {
+ listeners.add(onStoreChange);
+ return () => {
+ listeners.delete(onStoreChange);
+ };
+}
+
+function prefersReducedMotion(): boolean {
+ return query?.matches ?? false;
+}
+
+export function usePrefersReducedMotion(): boolean {
+ return useSyncExternalStore(subscribe, prefersReducedMotion, prefersReducedMotion);
+}
diff --git a/packages/ui/src/strings.ts b/packages/ui/src/strings.ts
index fa00c820..01fed6a9 100644
--- a/packages/ui/src/strings.ts
+++ b/packages/ui/src/strings.ts
@@ -33,6 +33,10 @@ export interface UiStrings {
moreInfo: string;
/** The same name with the subject folded in ("More info: Vault"): InfoPopover, HelpFold. */
moreInfoAbout: (subject: string) => string;
+ /** The toast stack's name as a live region and landmark (`Toaster`). */
+ notifications: string;
+ /** What pressing a toast does, read after its text: it dismisses it (`Toaster`). */
+ dismiss: string;
}
/** The English fallbacks, used wherever no provider is mounted (a test, a stand-alone page). */
@@ -45,6 +49,8 @@ export const DEFAULT_UI_STRINGS: UiStrings = {
clearSearch: "Clear search",
moreInfo: "More info",
moreInfoAbout: (subject) => `More info: ${subject}`,
+ notifications: "Notifications",
+ dismiss: "Dismiss",
};
const UiStringsContext = createContext<UiStrings>(DEFAULT_UI_STRINGS);
diff --git a/packages/ui/test/confirm-modal.test.ts b/packages/ui/test/confirm-modal.test.ts
new file mode 100644
index 00000000..3c6955a4
--- /dev/null
+++ b/packages/ui/test/confirm-modal.test.ts
@@ -0,0 +1,80 @@
+/**
+ * ConfirmModal (src/components/overlays/confirm-modal/confirm-modal.tsx): the headerless confirm
+ * card. Both labels are the caller's copy, the optional third choice needs both halves to appear,
+ * `confirmDisabled` holds back the confirm button alone, and the tone rides on the mark's ink over
+ * a neutral disc — never an icon in a tint of its own tone.
+ */
+import { createElement } from "react";
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { ConfirmModal } from "../src/components/overlays/confirm-modal/confirm-modal";
+import type { ConfirmModalProps } from "../src/components/overlays/confirm-modal/confirm-modal";
+import { classTokens, renderStatic } from "../src/testing";
+import { stubDialogGlobals } from "./helpers/dialog-env";
+
+vi.mock("react-dom", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-dom")>()),
+ createPortal: (node: ReactNode) => node,
+}));
+stubDialogGlobals();
+
+const noop = () => {};
+const confirm = (props: Partial<ConfirmModalProps> = {}) =>
+ renderStatic(
+ createElement(ConfirmModal, {
+ open: true,
+ title: "Delete this session?",
+ onClose: noop,
+ onConfirm: noop,
+ confirmLabel: "Delete",
+ cancelLabel: "Keep it",
+ children: "The transcript goes with it.",
+ ...props,
+ }),
+ );
+
+/** The rendered buttons' texts, in order. */
+const buttons = (html: string) =>
+ [...html.matchAll(/<button\b[^>]*>([^<]*)<\/button>/g)].map((m) => m[1]);
+
+describe("ConfirmModal", () => {
+ it("is a headerless dialog named by its title", () => {
+ const html = confirm();
+ expect(html).toContain('role="dialog"');
+ expect(html).toContain('aria-label="Delete this session?"');
+ expect(html).not.toContain("<h2");
+ expect(html).toContain("The transcript goes with it.");
+ });
+
+ it("labels both buttons with the caller's copy, cancel first", () => {
+ expect(buttons(confirm())).toEqual(["Keep it", "Delete"]);
+ });
+
+ it("adds the third choice between them only when it has both a label and a handler", () => {
+ expect(buttons(confirm({ secondaryLabel: "Switch anyway" }))).toEqual(["Keep it", "Delete"]);
+ expect(buttons(confirm({ secondaryLabel: "Switch anyway", onSecondary: noop }))).toEqual([
+ "Keep it",
+ "Switch anyway",
+ "Delete",
+ ]);
+ });
+
+ it("holds back the confirm button alone while its action is unavailable, all while busy", () => {
+ const disabled = (html: string) =>
+ [...html.matchAll(/<button\b[^>]*>/g)].filter((m) => m[0].includes('disabled=""')).length;
+ expect(disabled(confirm())).toBe(0);
+ expect(disabled(confirm({ confirmDisabled: true }))).toBe(1);
+ expect(disabled(confirm({ busy: true }))).toBe(2);
+ });
+
+ it("carries the tone in the mark's ink, on the same neutral disc for both tones", () => {
+ const mark = (html: string) =>
+ classTokens(/<span aria-hidden="true"[^>]*>/.exec(html)?.[0] ?? "");
+ const danger = mark(confirm());
+ expect(danger).toEqual(expect.arrayContaining(["bg-line-muted", "text-tone-danger-fg"]));
+ expect(danger.filter((t) => t.startsWith("bg-tone-"))).toEqual([]);
+ const primary = mark(confirm({ tone: "primary" }));
+ expect(primary).toEqual(expect.arrayContaining(["bg-line-muted", "text-tone-neutral-fg"]));
+ expect(primary).not.toContain("text-tone-danger-fg");
+ });
+});
diff --git a/packages/ui/test/context-menu.test.ts b/packages/ui/test/context-menu.test.ts
new file mode 100644
index 00000000..8c9a0bc7
--- /dev/null
+++ b/packages/ui/test/context-menu.test.ts
@@ -0,0 +1,268 @@
+/**
+ * The row context menu's rules and hook (src/components/overlays/portal-panel/context-menu.ts and
+ * use-row-context-menu.ts): which gesture asks for a row's menu, where the panel lands, and how
+ * the hook keeps the browser's own menu to the row it serves.
+ *
+ * Two things matter beyond the arithmetic. **Anchoring** has to distinguish a real secondary click
+ * from the keyboard chord browsers synthesize a `contextmenu` event for, because a keyboard user
+ * has no pointer and a pointer-anchored panel would open in the corner of the screen. And the
+ * feature must not be mouse-only: touch screens have neither hover nor a secondary button, so
+ * touch keeps a path of its own (press-and-hold).
+ *
+ * The hook and the Dropdown it drives need a DOM this suite does not have, so what they must do
+ * is pinned against their source: the one handler that suppresses the native menu, the
+ * containment guard that keeps the portaled panel's own events from re-anchoring it, and the
+ * Dropdown asking `scrollMovesAnchor` before an anchored panel dismisses itself (the rule's cases
+ * are in portal-panel.test.ts). How the app wires rows to it is the web app's
+ * `context-menu.test.ts`.
+ */
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import {
+ IDLE_HOLD,
+ LONG_PRESS_MS,
+ LONG_PRESS_SETTLE_MS,
+ LONG_PRESS_SLOP_PX,
+ contextMenuAnchor,
+ isContextMenuKey,
+ isLongPressPointer,
+ isPointerContextMenu,
+ longPressMoved,
+ pointerAnchor,
+ reduceHold,
+ withinSettleWindow,
+} from "../src/components/overlays/portal-panel/context-menu";
+import type { HoldEvent } from "../src/components/overlays/portal-panel/context-menu";
+import { SRC_DIR } from "./helpers/paths";
+
+const ROW = { top: 100, bottom: 132, left: 8, right: 260 };
+
+describe("pointerAnchor", () => {
+ it("is a zero-size box at the point, so the panel hangs off the click itself", () => {
+ expect(pointerAnchor(420, 300)).toEqual({ top: 300, bottom: 300, left: 420, right: 420 });
+ });
+});
+
+describe("isPointerContextMenu", () => {
+ it("recognizes a secondary click", () => {
+ expect(isPointerContextMenu({ button: 2, clientX: 420, clientY: 300 })).toBe(true);
+ });
+
+ it("rejects the keyboard-synthesized event, which reports no button", () => {
+ expect(isPointerContextMenu({ button: 0, clientX: 130, clientY: 110 })).toBe(false);
+ });
+
+ it("rejects the (0, 0) coordinates some browsers report for the Menu key", () => {
+ expect(isPointerContextMenu({ button: 2, clientX: 0, clientY: 0 })).toBe(false);
+ });
+});
+
+describe("contextMenuAnchor", () => {
+ it("opens at the pointer for a right-click", () => {
+ expect(contextMenuAnchor({ button: 2, clientX: 420, clientY: 300 }, ROW)).toEqual(
+ pointerAnchor(420, 300),
+ );
+ });
+
+ it("falls back to the row's own box when the keyboard asked, not to the viewport corner", () => {
+ expect(contextMenuAnchor({ button: 0, clientX: 0, clientY: 0 }, ROW)).toEqual(ROW);
+ });
+});
+
+describe("isContextMenuKey", () => {
+ it("is Shift+F10, the platform chord for the focused element's context menu", () => {
+ expect(isContextMenuKey({ key: "F10", shiftKey: true })).toBe(true);
+ });
+
+ it("ignores a bare F10 and other shifted keys, so the row eats no ordinary typing", () => {
+ expect(isContextMenuKey({ key: "F10", shiftKey: false })).toBe(false);
+ expect(isContextMenuKey({ key: "F11", shiftKey: true })).toBe(false);
+ expect(isContextMenuKey({ key: "Enter", shiftKey: true })).toBe(false);
+ });
+});
+
+describe("press-and-hold (the touch path)", () => {
+ it("holds for touch and pen only — a mouse has a secondary button and uses it", () => {
+ expect(isLongPressPointer("touch")).toBe(true);
+ expect(isLongPressPointer("pen")).toBe(true);
+ expect(isLongPressPointer("mouse")).toBe(false);
+ expect(isLongPressPointer("")).toBe(false);
+ });
+
+ it("tolerates a finger's jitter but treats real travel as a scroll", () => {
+ const from = { x: 100, y: 200 };
+ expect(longPressMoved(from, { x: 100, y: 200 })).toBe(false);
+ expect(longPressMoved(from, { x: 100 + LONG_PRESS_SLOP_PX, y: 200 })).toBe(false);
+ expect(longPressMoved(from, { x: 100, y: 200 + LONG_PRESS_SLOP_PX + 1 })).toBe(true);
+ expect(longPressMoved(from, { x: 100 - LONG_PRESS_SLOP_PX - 1, y: 200 })).toBe(true);
+ });
+
+ it("waits long enough not to fire on an ordinary tap", () => {
+ expect(LONG_PRESS_MS).toBeGreaterThanOrEqual(400);
+ expect(LONG_PRESS_SETTLE_MS).toBeGreaterThan(0);
+ });
+
+ it("ignores a dismiss inside the grace window that started at the given moment", () => {
+ const opened = 10_000;
+ expect(withinSettleWindow(opened, opened)).toBe(true);
+ expect(withinSettleWindow(opened, opened + LONG_PRESS_SETTLE_MS - 1)).toBe(true);
+ expect(withinSettleWindow(opened, opened + LONG_PRESS_SETTLE_MS)).toBe(false);
+ expect(withinSettleWindow(opened, opened + 5_000)).toBe(false);
+ });
+});
+
+/**
+ * The gesture lifecycle, driven as ordered sequences. This is where the interesting bugs
+ * live — every one of the cases below is a real touch sequence, not a synthetic one — and
+ * it is only reachable from a node-only suite because the decisions were kept pure.
+ */
+describe("reduceHold", () => {
+ /** Feed a sequence, returning each step's outcome. */
+ const play = (events: HoldEvent[]) => {
+ let state = IDLE_HOLD;
+ return events.map((e) => {
+ const out = reduceHold(state, e);
+ state = out.state;
+ return out;
+ });
+ };
+
+ it("opens on the hold and swallows the click the lift replays", () => {
+ const [, held, , click] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ { kind: "pointerup", at: 1_200 },
+ { kind: "click" },
+ ]);
+ expect(held!.open).toBe("held");
+ expect(click!.swallow).toBe(true);
+ });
+
+ it("measures the grace window from the LIFT, so reading the menu before lifting is safe", () => {
+ // The whole point: the menu opens at 1s and the user studies it for two seconds before
+ // lifting. The compatibility mousedown arrives at the lift, not at the open — anchoring
+ // the window to the open time would dismiss the menu the gesture just produced.
+ const [, , , dismiss] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ { kind: "pointerup", at: 3_000 },
+ { kind: "dismiss", at: 3_010 },
+ ]);
+ expect(dismiss!.close).toBe(false);
+ });
+
+ it("believes a dismiss once the replayed events can no longer be in flight", () => {
+ const [, , , dismiss] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ { kind: "pointerup", at: 3_000 },
+ { kind: "dismiss", at: 3_000 + LONG_PRESS_SETTLE_MS },
+ ]);
+ expect(dismiss!.close).toBe(true);
+ });
+
+ it("treats a native contextmenu raised during a touch hold as the hold itself", () => {
+ // Android raises its own contextmenu mid-hold and can beat our timer to it. If that is
+ // not recognized as a hold, the lift's replayed click falls through and opens the
+ // conversation on top of the menu.
+ const [, native, , click] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "nativemenu", at: 1_000 },
+ { kind: "pointerup", at: 1_100 },
+ { kind: "click" },
+ ]);
+ expect(native!.open).toBe("event");
+ expect(native!.state.held).toBe(true);
+ expect(click!.swallow).toBe(true);
+ });
+
+ it("does not re-anchor an already-held menu when the browser raises its own afterwards", () => {
+ const [, , native] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ { kind: "nativemenu", at: 1_050 },
+ ]);
+ expect(native!.open).toBeNull();
+ });
+
+ it("leaves a mouse right-click free of hold semantics", () => {
+ const [, native, dismiss, click] = play([
+ { kind: "pointerdown", pointerType: "mouse" },
+ { kind: "nativemenu", at: 1_000 },
+ { kind: "dismiss", at: 1_010 },
+ { kind: "click" },
+ ]);
+ expect(native!.open).toBe("event");
+ expect(native!.state.held).toBe(false);
+ // No grace window for a mouse: the very next outside click closes the menu.
+ expect(dismiss!.close).toBe(true);
+ expect(click!.swallow).toBe(false);
+ });
+
+ it("clears a hold flag left over from a gesture whose replayed click never came", () => {
+ const [, , down, click] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ // No click followed; the next gesture starts clean rather than eating its tap.
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "click" },
+ ]);
+ expect(down!.state.held).toBe(false);
+ expect(click!.swallow).toBe(false);
+ });
+
+ it("swallows only one click per hold", () => {
+ const [, , , first, second] = play([
+ { kind: "pointerdown", pointerType: "touch" },
+ { kind: "hold", at: 1_000 },
+ { kind: "pointerup", at: 1_100 },
+ { kind: "click" },
+ { kind: "click" },
+ ]);
+ expect(first!.swallow).toBe(true);
+ expect(second!.swallow).toBe(false);
+ });
+});
+
+const read = (rel: string) => readFileSync(join(SRC_DIR, rel), "utf8");
+const HOOK = read("components/overlays/portal-panel/use-row-context-menu.ts");
+const DROPDOWN = read("components/overlays/dropdown/dropdown.tsx");
+
+describe("anchored dismissal wiring", () => {
+ it("asks scrollMovesAnchor before dismissing an anchored panel", () => {
+ // What a node-only suite cannot reach is the component consulting the rule at all, and that
+ // is where this silently breaks: drop the call and every case of the rule still passes while
+ // the reported bug — a streaming message list wiping a menu opened in the sidebar — comes
+ // straight back.
+ const onScroll = /const onScroll = \(e: Event\) => \{([\s\S]*?)\n {4}\};/.exec(DROPDOWN);
+ expect(onScroll, "onScroll should be declared in dropdown.tsx").not.toBeNull();
+ expect(onScroll![1]).toContain("scrollMovesAnchor(");
+ // The owner is the element the anchorRect was measured from, read at event time.
+ expect(onScroll![1]).toContain("anchorOwnerRef.current");
+ });
+});
+
+describe("native-menu suppression scope", () => {
+ it("calls preventDefault inside the contextmenu handler itself, not somewhere adjacent", () => {
+ // Tied to the handler rather than to the file: preventDefault also appears in onKeyDown, so
+ // file-level presence would prove nothing about the native menu.
+ const handler = /onContextMenu:\s*\(e\)\s*=>\s*\{([\s\S]*?)\n {4}\},/.exec(HOOK);
+ expect(handler).not.toBeNull();
+ expect(handler![1]).toContain("e.preventDefault()");
+ });
+
+ it("ignores events that bubbled out of the portaled panel rather than the row", () => {
+ // React propagates through its own tree, so the Dropdown's body portal — a React child of
+ // the row — would otherwise re-anchor the open menu when one of its items is right-clicked.
+ // A DOM containment check separates the two trees.
+ expect(HOOK).toContain("host.contains(e.target as Node)");
+ for (const handler of ["onContextMenu", "onKeyDown", "onPointerDown"]) {
+ const body = new RegExp(`${handler}:\\s*\\(e\\)\\s*=>\\s*\\{([\\s\\S]*?)\\n {4}\\},`).exec(
+ HOOK,
+ );
+ expect(body, `${handler} should exist`).not.toBeNull();
+ expect(body![1], `${handler} should guard on fromRow`).toContain("if (!fromRow(e)) return;");
+ }
+ });
+});
diff --git a/packages/ui/test/drawer.test.ts b/packages/ui/test/drawer.test.ts
new file mode 100644
index 00000000..fcd35f13
--- /dev/null
+++ b/packages/ui/test/drawer.test.ts
@@ -0,0 +1,116 @@
+/**
+ * Drawer and Sheet (src/components/overlays/drawer/): the side panel and the spring sheet. Both
+ * render in place (no portal), dim the page through the scrim hook, name their close cross in the
+ * interface's words, and close on Escape only through the shared layer stack, so a dialog opened
+ * from inside one takes the first Escape alone.
+ */
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import { Drawer } from "../src/components/overlays/drawer/drawer";
+import { Sheet } from "../src/components/overlays/drawer/sheet";
+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";
+import { classTokens, renderStatic } from "../src/testing";
+import { SRC_DIR } from "./helpers/paths";
+
+const noop = () => {};
+const source = (rel: string) => readFileSync(join(SRC_DIR, rel), "utf8");
+
+describe("Drawer", () => {
+ const drawer = (side?: "left" | "right") =>
+ renderStatic(
+ createElement(Drawer, {
+ open: true,
+ side,
+ title: "Navigation",
+ onClose: noop,
+ children: "x",
+ }),
+ );
+
+ it("renders nothing while closed", () => {
+ expect(renderStatic(createElement(Drawer, { open: false, onClose: noop, children: "x" }))).toBe(
+ "",
+ );
+ });
+
+ it("docks to the side it is given, ruled off the page on its inner edge", () => {
+ expect(classTokens(drawer())).toEqual(expect.arrayContaining(["left-0", "border-r"]));
+ expect(classTokens(drawer("right"))).toEqual(expect.arrayContaining(["right-0", "border-l"]));
+ });
+
+ it("dims the page through the scrim, and paints its panel in tokens", () => {
+ expect(classTokens(drawer())).toEqual(
+ expect.arrayContaining([
+ "ui-scrim",
+ "bg-[var(--ui-overlay-backdrop)]",
+ "bg-surface",
+ "border-line",
+ "shadow-xl",
+ ]),
+ );
+ });
+
+ it("shows its title and names its close cross in the interface's words", () => {
+ const html = renderStatic(
+ createElement(
+ UiStringsProvider,
+ { strings: { ...DEFAULT_UI_STRINGS, close: "关闭" } },
+ createElement(Drawer, { open: true, title: "Navigation", onClose: noop, children: "x" }),
+ ),
+ );
+ expect(html).toContain(">Navigation</span>");
+ expect(html).toContain('aria-label="关闭"');
+ });
+});
+
+describe("Sheet", () => {
+ const sheet = () =>
+ renderStatic(
+ createElement(Sheet, {
+ open: true,
+ snap: "half",
+ title: "Files",
+ onClose: noop,
+ children: "x",
+ }),
+ );
+
+ it("renders nothing before it first opens", () => {
+ expect(
+ renderStatic(
+ createElement(Sheet, { open: false, snap: "half", onClose: noop, children: "x" }),
+ ),
+ ).toBe("");
+ });
+
+ it("is a modal dialog named by its title", () => {
+ const html = sheet();
+ expect(html).toMatch(/^<div class="[^"]*" role="dialog" aria-modal="true" aria-label="Files">/);
+ expect(html).toContain('aria-label="Close"');
+ });
+
+ it("dims the page through the scrim, and lifts its panel on the drawer shadow token", () => {
+ expect(classTokens(sheet())).toEqual(
+ expect.arrayContaining([
+ "ui-scrim",
+ "bg-[var(--ui-overlay-backdrop)]",
+ "bg-surface",
+ "border-line",
+ "shadow-[var(--ui-shadow-drawer)]",
+ "bg-line-emphasis",
+ ]),
+ );
+ });
+});
+
+describe("the drawer family's Escape", () => {
+ it("goes through the shared layer stack, never a listener of its own", () => {
+ const drawer = source("components/overlays/drawer/drawer.tsx");
+ const sheet = source("components/overlays/drawer/sheet.tsx");
+ expect(drawer).toContain("useEscLayer(open, onClose)");
+ expect(sheet).toContain("useEscLayer(mounted && open, onClose)");
+ for (const text of [drawer, sheet]) expect(text).not.toMatch(/"keydown"/);
+ });
+});
diff --git a/packages/ui/test/dropdown.test.ts b/packages/ui/test/dropdown.test.ts
new file mode 100644
index 00000000..b96ad86e
--- /dev/null
+++ b/packages/ui/test/dropdown.test.ts
@@ -0,0 +1,116 @@
+/**
+ * The dropdown panel (src/components/overlays/dropdown/dropdown.tsx) and the form-style picker
+ * built on it (src/components/forms/select/form-picker.tsx).
+ *
+ * The panel mounts only while open, and its portal mode reaches for `document.body`, which a
+ * static render has none of; the in-flow panel renders, and what the portal path must keep doing
+ * (share the dialogs' focusable set and Escape stack) is pinned against the source. How the app's
+ * menus consult the scroll rule is `context-menu.test.ts`; that dialogs and menus share one
+ * focusable selector is the web app's `modal-focus.test.ts`.
+ */
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import { FormPicker } from "../src/components/forms/select/form-picker";
+import { Dropdown } from "../src/components/overlays/dropdown/dropdown";
+import { menuPanelClass } from "../src/components/overlays/menu-panel/menu-panel";
+import { classTokens, renderStatic } from "../src/testing";
+import { SRC_DIR } from "./helpers/paths";
+
+const trigger = createElement("button", { type: "button" }, "Open");
+const row = createElement("button", { type: "button" }, "Rename");
+
+describe("Dropdown", () => {
+ it("renders only its trigger while closed", () => {
+ const html = renderStatic(
+ createElement(Dropdown, {
+ button: trigger,
+ open: false,
+ setOpen: () => {},
+ className: "flex-1",
+ children: row,
+ }),
+ );
+ expect(html).toBe('<div class="relative flex-1"><button type="button">Open</button></div>');
+ });
+
+ it("opens the menu panel in flow, on the menu tier, as a glass layer", () => {
+ const html = renderStatic(
+ createElement(Dropdown, { button: trigger, open: true, setOpen: () => {}, children: row }),
+ );
+ const tokens = classTokens(html);
+ expect(tokens).toEqual(
+ expect.arrayContaining([
+ "ui-glass",
+ ...menuPanelClass.split(" "),
+ "absolute",
+ "z-40",
+ "max-h-[70vh]",
+ // The default docking: downward, left-aligned, capped to the viewport.
+ "top-full",
+ "left-0",
+ "w-64",
+ ]),
+ );
+ expect(html).toContain("Rename</button></div></div>");
+ });
+
+ it("takes the caller's size classes and inline overrides for the panel", () => {
+ const html = renderStatic(
+ createElement(Dropdown, {
+ button: trigger,
+ open: true,
+ setOpen: () => {},
+ menuClass: "right-0 top-full w-40",
+ menuStyle: { maxWidth: 320 },
+ children: row,
+ }),
+ );
+ expect(html).toContain('style="max-width:320px"');
+ expect(classTokens(html)).toContain("w-40");
+ expect(classTokens(html)).not.toContain("w-64");
+ });
+
+ it("walks the dialogs' focusable set and joins their Escape stack", () => {
+ const source = readFileSync(join(SRC_DIR, "components/overlays/dropdown/dropdown.tsx"), "utf8");
+ expect(source).toContain('from "../esc-layers/esc-layers"');
+ expect(source).toContain("querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)");
+ expect(source).toMatch(/const layer = pushEscLayer\(\);[\s\S]*isTopEscLayer\(layer\)/);
+ // Portaled panels clear a dialog's overlay; in-flow ones stay on the menu tier.
+ expect(source).toContain('${portal ? "z-[60]" : "z-40"}');
+ });
+});
+
+describe("FormPicker", () => {
+ const picker = (muted: boolean) =>
+ renderStatic(
+ createElement(FormPicker, {
+ open: false,
+ setOpen: () => {},
+ label: "gpt-5",
+ muted,
+ title: "Model",
+ ariaLabel: "Choose a model",
+ menuClass: "w-72",
+ children: row,
+ }),
+ );
+
+ it("is a full-width trigger that names itself and the list it opens", () => {
+ const html = picker(false);
+ expect(html).toContain('aria-label="Choose a model"');
+ expect(html).toContain('aria-haspopup="listbox"');
+ expect(html).toContain('aria-expanded="false"');
+ // The hint goes through the shared tooltip, never a native title.
+ expect(html).toContain('data-tooltip="Model"');
+ expect(html).not.toContain("title=");
+ expect(classTokens(html)).toEqual(expect.arrayContaining(["w-full", "truncate"]));
+ });
+
+ it("greys a placeholder with the subtle ink, and colours only through tokens", () => {
+ const tokens = classTokens(picker(true));
+ expect(tokens).toContain("text-fg-subtle");
+ expect(tokens.filter((t) => /gray|dark:/.test(t))).toEqual([]);
+ });
+});
diff --git a/packages/ui/test/helpers/dialog-env.ts b/packages/ui/test/helpers/dialog-env.ts
new file mode 100644
index 00000000..8b0d2079
--- /dev/null
+++ b/packages/ui/test/helpers/dialog-env.ts
@@ -0,0 +1,22 @@
+/**
+ * What a portaled overlay needs to render once in Node: a `document` whose body the portal
+ * targets, and an `HTMLElement` for the focus-restore read a dialog makes during render. A suite
+ * pairs it with `createPortal` mocked to render in place, since the server renderer refuses
+ * portals:
+ *
+ * vi.mock("react-dom", async (importOriginal) => ({
+ * ...(await importOriginal<typeof import("react-dom")>()),
+ * createPortal: (node: ReactNode) => node,
+ * }));
+ *
+ * Only the markup is reachable this way; effects never run under the static renderer.
+ */
+import { afterAll, vi } from "vitest";
+
+export function stubDialogGlobals(): void {
+ vi.stubGlobal("document", { body: {}, activeElement: null });
+ vi.stubGlobal("HTMLElement", class {});
+ afterAll(() => {
+ vi.unstubAllGlobals();
+ });
+}
diff --git a/packages/ui/test/hooks.test.ts b/packages/ui/test/hooks.test.ts
index ee3def18..6624d924 100644
--- a/packages/ui/test/hooks.test.ts
+++ b/packages/ui/test/hooks.test.ts
@@ -94,7 +94,6 @@ const HOSTS: Readonly<Record<string, readonly string[]>> = {
],
"ui-eyebrow": ["Sidebar", "GroupHeader", "PagedDialog"],
"ui-display": [
- "Heading",
"EmptyState",
"AgentsPage",
"ModelsPage",
@@ -114,6 +113,7 @@ const HOSTS: Readonly<Record<string, readonly string[]>> = {
"PagedDialog",
"SettingsDialog",
"MenuItemGlyph",
+ "MenuItem",
"GroupHeader",
"Tabs",
"EmptyState",
diff --git a/packages/ui/test/lightbox.test.ts b/packages/ui/test/lightbox.test.ts
new file mode 100644
index 00000000..40c8dc59
--- /dev/null
+++ b/packages/ui/test/lightbox.test.ts
@@ -0,0 +1,86 @@
+/**
+ * Lightbox and ZoomableImage (src/components/overlays/lightbox/lightbox.tsx): the thumbnail keeps
+ * the caller's styling and mounts nothing else until clicked; the lightbox names its close glyph in
+ * the interface's words, dims the page through the scrim hook, and closes on Escape only through
+ * the shared layer stack, so a lightbox opened inside a dialog closes alone.
+ */
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { createElement } from "react";
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { Lightbox, ZoomableImage } from "../src/components/overlays/lightbox/lightbox";
+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";
+import { classTokens, renderStatic } from "../src/testing";
+import { stubDialogGlobals } from "./helpers/dialog-env";
+import { SRC_DIR } from "./helpers/paths";
+
+vi.mock("react-dom", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-dom")>()),
+ createPortal: (node: ReactNode) => node,
+}));
+stubDialogGlobals();
+
+const noop = () => {};
+const lightbox = (closeLabel?: string) =>
+ renderStatic(
+ createElement(Lightbox, { open: true, src: "/a.png", alt: "Chart", onClose: noop, closeLabel }),
+ );
+
+describe("ZoomableImage", () => {
+ it("is a button around the caller's thumbnail, with the lightbox not yet mounted", () => {
+ const html = renderStatic(
+ createElement(ZoomableImage, { src: "/a.png", alt: "Chart", className: "h-20" }),
+ );
+ // React 19's server renderer prepends a preload hint for an eager image; not our markup.
+ expect(html.replace(/^<link rel="preload"[^>]*\/>/, "")).toBe(
+ '<button type="button" class="block cursor-zoom-in"><img src="/a.png" alt="Chart" class="h-20"/></button>',
+ );
+ });
+});
+
+describe("Lightbox", () => {
+ it("renders nothing while closed", () => {
+ expect(
+ renderStatic(
+ createElement(Lightbox, { open: false, src: "/a.png", alt: "Chart", onClose: noop }),
+ ),
+ ).toBe("");
+ });
+
+ it("shows the image whole, with its alt text", () => {
+ expect(lightbox()).toMatch(/<img src="\/a\.png" alt="Chart" class="[^"]*"\/>/);
+ });
+
+ it("names its close glyph in the interface's words, or the caller's", () => {
+ expect(lightbox()).toContain('aria-label="Close"');
+ const injected = renderStatic(
+ createElement(
+ UiStringsProvider,
+ { strings: { ...DEFAULT_UI_STRINGS, close: "关闭" } },
+ createElement(Lightbox, { open: true, src: "/a.png", alt: "Chart", onClose: noop }),
+ ),
+ );
+ expect(injected).toContain('aria-label="关闭"');
+ expect(lightbox("Close the image")).toContain('aria-label="Close the image"');
+ });
+
+ it("dims the page through the scrim, and paints in tokens", () => {
+ expect(classTokens(lightbox())).toEqual(
+ expect.arrayContaining([
+ "ui-scrim",
+ "bg-[var(--ui-overlay-backdrop)]",
+ "bg-fg/50",
+ "text-canvas",
+ "border-line",
+ "bg-surface",
+ ]),
+ );
+ });
+
+ it("closes on Escape through the shared layer stack, never a listener of its own", () => {
+ const text = readFileSync(join(SRC_DIR, "components/overlays/lightbox/lightbox.tsx"), "utf8");
+ expect(text).toContain("useEscLayer(open, onClose)");
+ expect(text).not.toMatch(/"keydown"/);
+ });
+});
diff --git a/packages/ui/test/menu.test.ts b/packages/ui/test/menu.test.ts
new file mode 100644
index 00000000..e568b586
--- /dev/null
+++ b/packages/ui/test/menu.test.ts
@@ -0,0 +1,130 @@
+/**
+ * The menu rows (src/components/overlays/menu/menu.tsx): one row family at two densities, built
+ * on the menu panel's row states, taking the menu roles inside a `Menu` and none outside one.
+ */
+import { createElement } from "react";
+import type { ReactElement } from "react";
+import { describe, expect, it } from "vitest";
+import { ICONS } from "../src/components/icons/icons";
+import {
+ Menu,
+ MenuItem,
+ MenuLabel,
+ MenuRadioItem,
+ MenuSeparator,
+} from "../src/components/overlays/menu/menu";
+import { classTokens, renderStatic } from "../src/testing";
+
+const inMenu = (density: "sm" | "md", ...rows: ReactElement[]) =>
+ renderStatic(createElement(Menu, { label: "Workspace", density, children: rows }));
+
+describe("Menu", () => {
+ it("is a named menu whose rows are menu items", () => {
+ const html = inMenu("md", createElement(MenuItem, { key: "a", label: "Rename" }));
+ expect(html).toMatch(/^<div role="menu" aria-label="Workspace"/);
+ expect(html).toContain('<button type="button" role="menuitem"');
+ expect(html).toContain(">Rename</span>");
+ });
+
+ it("sets its rows on the body rung at md and the small rung at sm", () => {
+ const md = inMenu("md", createElement(MenuItem, { key: "a", label: "Settings" }));
+ const sm = inMenu("sm", createElement(MenuItem, { key: "a", label: "Copy path" }));
+ expect(classTokens(md)).toContain("text-sm");
+ expect(classTokens(md)).not.toContain("text-xs");
+ expect(classTokens(sm)).toContain("text-xs");
+ expect(classTokens(sm)).not.toContain("text-sm");
+ });
+
+ it("gives a choice its menu role and checked state", () => {
+ const html = inMenu(
+ "sm",
+ createElement(MenuRadioItem, { key: "a", label: "By Workspace", checked: true }),
+ createElement(MenuRadioItem, { key: "b", label: "By agent", checked: false }),
+ createElement(MenuItem, { key: "c", label: "Wrap lines", checked: false }),
+ );
+ expect(html.match(/role="menuitemradio"/g)).toHaveLength(2);
+ expect(html).toContain('role="menuitemradio" aria-checked="true"');
+ expect(html).toContain('role="menuitemradio" aria-checked="false"');
+ expect(html).toContain('role="menuitemcheckbox" aria-checked="false"');
+ });
+
+ it("rules groups apart and names them without making either a row", () => {
+ const html = inMenu(
+ "sm",
+ createElement(MenuLabel, { key: "l", children: "Group by" }),
+ createElement(MenuSeparator, { key: "s" }),
+ );
+ expect(html).toContain('<div role="presentation"');
+ expect(html).toContain(">Group by</div>");
+ expect(html).toContain('<div role="separator" class="my-1 border-t border-line-muted"></div>');
+ expect(html).not.toContain("<button");
+ });
+});
+
+describe("MenuItem", () => {
+ const render = (props: Parameters<typeof MenuItem>[0]) =>
+ renderStatic(createElement(MenuItem, props));
+
+ it("is a plain button with no menu role outside a Menu", () => {
+ const html = render({ label: "Rename", checked: true });
+ expect(html).toMatch(/^<button type="button" class="/);
+ expect(html).not.toContain("role=");
+ expect(html).not.toContain("aria-checked");
+ });
+
+ it("takes a listbox option's role and state when its container asks for one", () => {
+ const html = render({ label: "Local", role: "option", checked: true });
+ expect(html).toContain('role="option" aria-selected="true"');
+ });
+
+ it("draws a registry glyph as a muted decorative mark, and a node as given", () => {
+ const glyph = render({ label: "Rename", glyph: ICONS.pencil });
+ expect(glyph).toContain(`d="${ICONS.pencil}"`);
+ expect(glyph).toContain('data-role="menu"');
+ expect(classTokens(glyph)).toEqual(expect.arrayContaining(["ui-icon-decor", "text-fg-subtle"]));
+ const node = render({ label: "Me", glyph: createElement("i", { className: "avatar" }) });
+ expect(node).toContain('<i class="avatar"></i>');
+ expect(node).not.toContain("ui-icon-decor");
+ // A false left by `cond && <X />` draws nothing, not an empty slot.
+ expect(render({ label: "Plain", glyph: false })).not.toContain("shrink-0 items-center");
+ });
+
+ it("keeps the danger tone on the row and lets its glyph inherit it", () => {
+ const html = render({ label: "Delete", glyph: ICONS.trash, danger: true });
+ const tokens = classTokens(html);
+ expect(tokens).toEqual(
+ expect.arrayContaining(["text-tone-danger-fg", "hover:bg-tone-danger-bg"]),
+ );
+ expect(tokens).not.toContain("text-fg-subtle");
+ expect(tokens).not.toContain("hover:bg-surface-muted");
+ });
+
+ it("fills and checks the current choice, and keeps the check's slot on the others", () => {
+ const on = classTokens(render({ label: "A", checked: true }));
+ const off = render({ label: "B", checked: false });
+ expect(on).toEqual(expect.arrayContaining(["bg-surface-muted", "font-medium"]));
+ expect(off).toMatch(/<span aria-hidden="true" class="[^"]*w-3[^"]*"><\/span><\/button>$/);
+ // An action row carries no check slot at all.
+ expect(render({ label: "C" })).not.toContain("w-3");
+ });
+
+ it("sets a description under the label and a note at the row's end, both muted", () => {
+ const html = render({ label: "Read & write", description: "Edits files", trailing: "v1.2" });
+ expect(html).toContain('<span class="mt-0.5 block text-xs text-fg-muted">Edits files</span>');
+ expect(html).toContain('<span class="shrink-0 text-xs text-fg-subtle">v1.2</span>');
+ });
+
+ it("becomes a link for an address, and passes the caller's data attributes through", () => {
+ const link = render({ label: "Download", href: "/f/a.txt", download: "a.txt" });
+ expect(link).toMatch(/^<a href="\/f\/a.txt" download="a.txt"/);
+ const tagged = render({ label: "Trace", "data-testid": "dock-add-trace", disabled: true });
+ expect(tagged).toContain('data-testid="dock-add-trace"');
+ expect(tagged).toContain('disabled=""');
+ });
+
+ it("colours only through tokens and never sets its label in mono", () => {
+ const tokens = classTokens(render({ label: "Row", glyph: ICONS.pencil, checked: true }));
+ expect(tokens.filter((t) => /gray|dark:|red-|white/.test(t))).toEqual([]);
+ expect(tokens).not.toContain("font-mono");
+ });
+});
diff --git a/packages/ui/test/modal.test.ts b/packages/ui/test/modal.test.ts
new file mode 100644
index 00000000..c5483177
--- /dev/null
+++ b/packages/ui/test/modal.test.ts
@@ -0,0 +1,93 @@
+/**
+ * Modal (src/components/overlays/modal/modal.tsx): a named modal dialog on both branches, whose
+ * close cross speaks the interface's words, with the scrim and glass hooks on their host. The
+ * focus and Escape wiring is pinned against the source by the web app's modal-focus.test.ts; here
+ * the dialog renders once, its portal replaced by an in-place render.
+ */
+import { createElement } from "react";
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { Modal } from "../src/components/overlays/modal/modal";
+import type { ModalProps } from "../src/components/overlays/modal/modal";
+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";
+import { classTokens, renderStatic } from "../src/testing";
+import { stubDialogGlobals } from "./helpers/dialog-env";
+
+vi.mock("react-dom", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-dom")>()),
+ createPortal: (node: ReactNode) => node,
+}));
+stubDialogGlobals();
+
+const noop = () => {};
+const modal = (props: Partial<ModalProps> = {}) =>
+ renderStatic(
+ createElement(Modal, {
+ open: true,
+ title: "Rename session",
+ onClose: noop,
+ children: "Body",
+ ...props,
+ }),
+ );
+
+describe("Modal", () => {
+ it("renders nothing while closed", () => {
+ expect(modal({ open: false })).toBe("");
+ });
+
+ it("is a modal dialog named by its own heading", () => {
+ const html = modal();
+ expect(html).toContain('role="dialog"');
+ expect(html).toContain('aria-modal="true"');
+ expect(html).toContain('tabindex="-1"');
+ const id = /aria-labelledby="([^"]+)"/.exec(html)?.[1];
+ expect(id).toBeDefined();
+ expect(html).toContain(`<h2 id="${id}"`);
+ expect(html).toContain(">Rename session</h2>");
+ });
+
+ it("names a headerless dialog by its title alone, with no heading and no close cross", () => {
+ const html = modal({ headerless: true });
+ expect(html).toContain('aria-label="Rename session"');
+ expect(html).not.toContain("aria-labelledby");
+ expect(html).not.toContain("<h2");
+ expect(html).not.toContain('aria-label="Close"');
+ });
+
+ it("names its close cross in the interface's words, or the caller's", () => {
+ expect(modal()).toContain('aria-label="Close"');
+ const injected = renderStatic(
+ createElement(
+ UiStringsProvider,
+ { strings: { ...DEFAULT_UI_STRINGS, close: "关闭" } },
+ createElement(Modal, { open: true, title: "t", onClose: noop, children: "Body" }),
+ ),
+ );
+ expect(injected).toContain('aria-label="关闭"');
+ expect(modal({ closeLabel: "Close the rename dialog" })).toContain(
+ 'aria-label="Close the rename dialog"',
+ );
+ });
+
+ it("pads and scrolls its body unless the caller owns the layout", () => {
+ expect(modal()).toContain("max-h-[70vh]");
+ expect(modal({ bare: true })).not.toContain("max-h-[70vh]");
+ expect(modal({ footer: "Actions" })).toMatch(/border-t border-line[^"]*">Actions<\/div>/);
+ });
+
+ it("carries the scrim and glass hooks, and paints in tokens", () => {
+ expect(classTokens(modal())).toEqual(
+ expect.arrayContaining([
+ "ui-scrim",
+ "ui-glass",
+ "bg-[var(--ui-overlay-backdrop)]",
+ "bg-surface",
+ "border-line",
+ "shadow-xl",
+ "sm:max-w-md",
+ ]),
+ );
+ expect(classTokens(modal({ widthClass: "sm:max-w-3xl" }))).toContain("sm:max-w-3xl");
+ });
+});
diff --git a/packages/ui/test/notice-strip.test.ts b/packages/ui/test/notice-strip.test.ts
new file mode 100644
index 00000000..cba9deb9
--- /dev/null
+++ b/packages/ui/test/notice-strip.test.ts
@@ -0,0 +1,67 @@
+/**
+ * The notice strip (src/components/feedback/notice/notice-strip.tsx): the one `ui-notice` box,
+ * naming its tone in the hook's words and painting it as a tint with its own ink on the neutral
+ * line, around whatever layout and words the caller brings.
+ *
+ * Which call sites use it, and the icon-slot convention they are held to, is the web app's
+ * `notice-chart-hooks.test.ts`.
+ */
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import { NOTICE_TONE, NoticeStrip } from "../src/components/feedback/notice/notice-strip";
+import type { NoticeStripTone } from "../src/components/feedback/notice/notice-strip";
+import { classTokens, renderStatic } from "../src/testing";
+
+const TONES = Object.keys(NOTICE_TONE) as NoticeStripTone[];
+
+type StripProps = Omit<Parameters<typeof NoticeStrip>[0], "tone">;
+
+const strip = (tone: NoticeStripTone, props: StripProps = {}) =>
+ renderStatic(createElement(NoticeStrip, { ...props, tone }, "Heads up"));
+
+describe("NoticeStrip", () => {
+ it("names every tone in the hook's five words, the attention tone as a warning", () => {
+ expect([...TONES].sort()).toEqual(["attention", "danger", "info", "neutral", "success"]);
+ expect(new Set(Object.values(NOTICE_TONE))).toEqual(
+ new Set(["info", "success", "warning", "danger", "neutral"]),
+ );
+ expect(strip("attention")).toContain('data-tone="warning"');
+ expect(strip("danger")).toContain('data-tone="danger"');
+ });
+
+ it("paints each tone as its tint and ink on the neutral line, never its own line", () => {
+ for (const tone of TONES) {
+ const tokens = classTokens(strip(tone));
+ expect(tokens, tone).toEqual(
+ expect.arrayContaining([
+ "ui-notice",
+ "border-line",
+ `bg-tone-${tone}-bg`,
+ `text-tone-${tone}-fg`,
+ ]),
+ );
+ expect(
+ tokens.filter((t) => t.startsWith("border-tone-")),
+ tone,
+ ).toEqual([]);
+ }
+ });
+
+ it("keeps the caller's layout, words and attributes", () => {
+ const html = strip("danger", {
+ className: "mt-4 rounded-md border px-3 py-2 text-sm",
+ role: "alert",
+ });
+ expect(html).toMatch(/^<div role="alert"/);
+ expect(classTokens(html)).toEqual(
+ expect.arrayContaining(["mt-4", "rounded-md", "border", "px-3", "py-2", "text-sm"]),
+ );
+ expect(html).toContain(">Heads up</div>");
+ });
+
+ it("is a paragraph for one sentence of prose, and a real button when pressed", () => {
+ expect(strip("neutral", { as: "p" })).toMatch(/^<p /);
+ expect(strip("info", { as: "button" })).toMatch(/^<button type="button"/);
+ expect(strip("info")).not.toContain("type=");
+ });
+});
diff --git a/packages/ui/test/paged-dialog.test.ts b/packages/ui/test/paged-dialog.test.ts
new file mode 100644
index 00000000..c4bf31af
--- /dev/null
+++ b/packages/ui/test/paged-dialog.test.ts
@@ -0,0 +1,83 @@
+/**
+ * PagedDialog (src/components/overlays/paged-dialog/paged-dialog.tsx): a dialog with a page rail.
+ * The rail is a named navigation whose active row is the current page, group headings appear only
+ * when there is more than one group and set on the eyebrow rung, the rail glyphs are decorative,
+ * and the pane heading is the active page's label with its "?" when the page explains itself.
+ */
+import { createElement } from "react";
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { PagedDialog } from "../src/components/overlays/paged-dialog/paged-dialog";
+import type { PagedDialogGroup } from "../src/components/overlays/paged-dialog/paged-dialog";
+import { classTokens, renderStatic } from "../src/testing";
+import { stubDialogGlobals } from "./helpers/dialog-env";
+
+vi.mock("react-dom", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("react-dom")>()),
+ createPortal: (node: ReactNode) => node,
+}));
+stubDialogGlobals();
+
+type Page = "general" | "appearance" | "account";
+
+const GROUPS: PagedDialogGroup<Page>[] = [
+ {
+ key: "app",
+ label: "App",
+ items: [
+ { key: "general", label: "General", icon: createElement("svg") },
+ { key: "appearance", label: "Appearance", info: "Theme and density." },
+ ],
+ },
+ { key: "you", label: "You", items: [{ key: "account", label: "Account" }] },
+];
+
+const dialog = (groups: PagedDialogGroup<Page>[], active: Page) =>
+ renderStatic(
+ createElement(PagedDialog<Page>, {
+ open: true,
+ onClose: () => {},
+ title: "Settings",
+ groups,
+ active,
+ onSelect: () => {},
+ children: "Pane",
+ }),
+ );
+
+describe("PagedDialog", () => {
+ it("is a dialog named by its title, with the rail as a navigation of the same name", () => {
+ const html = dialog(GROUPS, "general");
+ expect(html).toContain('role="dialog"');
+ expect(html).toContain('aria-label="Settings"');
+ expect(html).toMatch(/<nav aria-label="Settings"/);
+ });
+
+ it("marks the active page as the current one, and only it", () => {
+ const html = dialog(GROUPS, "appearance");
+ expect([...html.matchAll(/aria-current="page"/g)]).toHaveLength(1);
+ expect(html).toMatch(/aria-current="page"[^>]*><span class="min-w-0 truncate">Appearance</);
+ });
+
+ it("heads the pane with the active page's label, and its explanation behind a ?", () => {
+ const html = dialog(GROUPS, "appearance");
+ expect(html).toMatch(/<h2[^>]*>Appearance/);
+ expect(html).toContain('aria-label="More info: Appearance"');
+ expect(dialog(GROUPS, "general")).not.toContain("More info");
+ });
+
+ it("sets group headings on the eyebrow rung, and drops a lone group's heading", () => {
+ const html = dialog(GROUPS, "general");
+ expect(html).toMatch(/<p class="ui-eyebrow [^"]*">App<\/p>/);
+ expect(html).toMatch(/<p class="ui-eyebrow [^"]*">You<\/p>/);
+ expect(classTokens(html)).not.toContain("uppercase");
+ const lone = dialog([GROUPS[0]!], "general");
+ expect(lone).not.toContain("ui-eyebrow");
+ });
+
+ it("marks the rail glyphs as decoration", () => {
+ expect(dialog(GROUPS, "general")).toMatch(
+ /<span aria-hidden="true" class="ui-icon-decor [^"]*" data-role="nav"><svg><\/svg><\/span>/,
+ );
+ });
+});
diff --git a/packages/web/test/sheet-physics.test.ts b/packages/ui/test/sheet-physics.test.ts
similarity index 91%
rename from packages/web/test/sheet-physics.test.ts
rename to packages/ui/test/sheet-physics.test.ts
index 6bf0146f..d1cb6d9a 100644
--- a/packages/web/test/sheet-physics.test.ts
+++ b/packages/ui/test/sheet-physics.test.ts
@@ -1,5 +1,6 @@
+/** The Sheet's gesture math (src/motion/sheet-physics.ts). */
import { describe, expect, it } from "vitest";
-import { nearestSnap, project, rubberband } from "../src/lib/sheet-physics";
+import { nearestSnap, project, rubberband } from "../src/motion/sheet-physics";
describe("project", () => {
it("zero velocity, zero displacement", () => {
diff --git a/packages/web/test/spring.test.ts b/packages/ui/test/spring.test.ts
similarity index 92%
rename from packages/web/test/spring.test.ts
rename to packages/ui/test/spring.test.ts
index a8e6193c..2fa90338 100644
--- a/packages/web/test/spring.test.ts
+++ b/packages/ui/test/spring.test.ts
@@ -1,6 +1,7 @@
+/** The spring the Sheet and the dock launcher animate with (src/motion/spring.ts). */
import { describe, expect, it } from "vitest";
-import { SPRING_DEFAULT, SPRING_MOMENTUM, isSettled, stepSpring } from "../src/lib/spring";
-import type { SpringConfig } from "../src/lib/spring";
+import { SPRING_DEFAULT, SPRING_MOMENTUM, isSettled, stepSpring } from "../src/motion/spring";
+import type { SpringConfig } from "../src/motion/spring";
/** Runs a number of frames at 16ms per frame, returning the final state and path. */
function run(from: number, target: number, config: SpringConfig, frames = 240) {
diff --git a/packages/ui/test/strings.test.ts b/packages/ui/test/strings.test.ts
index 74309cdd..adfc9d8e 100644
--- a/packages/ui/test/strings.test.ts
+++ b/packages/ui/test/strings.test.ts
@@ -26,10 +26,12 @@ describe("UiStrings", () => {
"clearSearch",
"close",
"copied",
+ "dismiss",
"hidePassword",
"loading",
"moreInfo",
"moreInfoAbout",
+ "notifications",
"showPassword",
]);
expect(DEFAULT_UI_STRINGS).toMatchObject({
@@ -40,6 +42,8 @@ describe("UiStrings", () => {
hidePassword: "Hide password",
clearSearch: "Clear search",
moreInfo: "More info",
+ notifications: "Notifications",
+ dismiss: "Dismiss",
});
// The one formatter: the subject folds into the name, keeping "More info" its prefix.
expect(DEFAULT_UI_STRINGS.moreInfoAbout("Vault")).toBe("More info: Vault");
diff --git a/packages/ui/test/toaster.test.ts b/packages/ui/test/toaster.test.ts
new file mode 100644
index 00000000..e8756751
--- /dev/null
+++ b/packages/ui/test/toaster.test.ts
@@ -0,0 +1,140 @@
+/**
+ * The toasts (src/components/overlays/toaster/toaster.tsx): the store the `toast*` functions write
+ * to and how long each kind stays, and the stack as it is drawn — a polite live region named in
+ * the interface's words, each toast a notice-strip button on an opaque backing.
+ *
+ * The portal itself needs a document, which this suite has not; `ToastStack` is what `Toaster`
+ * portals, so the markup is asserted on it.
+ */
+import { createElement } from "react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ ToastStack,
+ Toaster,
+ toastAttention,
+ toastError,
+ toastInfo,
+ toastStore,
+ toastSuccess,
+} from "../src/components/overlays/toaster/toaster";
+import type { ToastItem } from "../src/components/overlays/toaster/toaster";
+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";
+import { classTokens, renderStatic } from "../src/testing";
+
+const items = () => toastStore.getState().items;
+
+describe("the toast store", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ toastStore.setState({ items: [] });
+ });
+ afterEach(() => {
+ vi.clearAllTimers();
+ vi.useRealTimers();
+ toastStore.setState({ items: [] });
+ });
+
+ it("stacks toasts oldest first, and ignores an empty one", () => {
+ toastSuccess("Saved");
+ toastError("Connection failed");
+ toastSuccess("");
+ expect(items().map(({ kind, text }) => ({ kind, text }))).toEqual([
+ { kind: "success", text: "Saved" },
+ { kind: "error", text: "Connection failed" },
+ ]);
+ });
+
+ it("plays the exit before removing a toast, once its stay is over", () => {
+ toastSuccess("Saved");
+ vi.advanceTimersByTime(2499);
+ expect(items()[0]?.leaving).toBeUndefined();
+ vi.advanceTimersByTime(1);
+ expect(items()[0]?.leaving).toBe(true);
+ vi.advanceTimersByTime(160);
+ expect(items()).toEqual([]);
+ });
+
+ it("keeps what needs reading longer: info 4 s, an advisory and an error 6 s", () => {
+ toastInfo("Already up to date");
+ toastAttention("Saved, but 2 fields were truncated");
+ toastError("Connection failed");
+ vi.advanceTimersByTime(4000);
+ expect(items().map((t) => [t.kind, t.leaving === true])).toEqual([
+ ["info", true],
+ ["attention", false],
+ ["error", false],
+ ]);
+ vi.advanceTimersByTime(2000);
+ expect(items().map((t) => t.kind)).toEqual(["attention", "error"]);
+ expect(items().every((t) => t.leaving)).toBe(true);
+ });
+});
+
+const STACK: ToastItem[] = [
+ { id: 1, kind: "success", text: "Saved" },
+ { id: 2, kind: "error", text: "Connection failed" },
+ { id: 3, kind: "info", text: "Rebuilding the index" },
+ { id: 4, kind: "attention", text: "Saved, but 2 fields were truncated", leaving: true },
+];
+
+const stack = (list: readonly ToastItem[]) =>
+ renderStatic(createElement(ToastStack, { items: list, onDismiss: () => {} }));
+
+describe("ToastStack", () => {
+ const html = stack(STACK);
+
+ it("is a polite live region, named, and mounted while empty", () => {
+ expect(html).toMatch(
+ /^<section aria-label="Notifications" aria-live="polite" aria-relevant="additions text"/,
+ );
+ const empty = stack([]);
+ expect(empty).toMatch(/^<section aria-label="Notifications"/);
+ expect(empty).not.toContain("<button");
+ });
+
+ it("draws each toast as a notice-strip button in its kind's tone, words in the body", () => {
+ const buttons = [...html.matchAll(/<button [^>]*type="button"[^>]*data-tone="([a-z]+)"/g)];
+ expect(buttons.map((m) => m[1])).toEqual(["success", "danger", "info", "warning"]);
+ expect(html).toContain('<span data-slot="body">Connection failed</span>');
+ expect(classTokens(html)).toEqual(
+ expect.arrayContaining([
+ "ui-notice",
+ "border-line",
+ "bg-tone-danger-bg",
+ "text-tone-danger-fg",
+ ]),
+ );
+ });
+
+ it("says that pressing a toast dismisses it, through a hint every toast points at", () => {
+ const hint = /<span id="([^"]+)" hidden="">Dismiss<\/span>/.exec(html);
+ expect(hint).not.toBeNull();
+ const described = [...html.matchAll(/aria-describedby="([^"]+)"/g)].map((m) => m[1]);
+ expect(described).toEqual(STACK.map(() => hint![1]));
+ });
+
+ it("stands each toast on an opaque backing, and plays the exit on a leaving one", () => {
+ expect(html.match(/class="max-w-lg rounded-lg bg-overlay anim-toast-in"/g)).toHaveLength(3);
+ expect(html.match(/class="max-w-lg rounded-lg bg-overlay anim-toast-out"/g)).toHaveLength(1);
+ });
+
+ it("speaks the interface's words once the app provides them", () => {
+ const zh = renderStatic(
+ createElement(
+ UiStringsProvider,
+ { strings: { ...DEFAULT_UI_STRINGS, notifications: "通知", dismiss: "关闭" } },
+ createElement(ToastStack, { items: STACK, onDismiss: () => {} }),
+ ),
+ );
+ expect(zh).toContain('aria-label="通知"');
+ expect(zh).toContain('hidden="">关闭</span>');
+ expect(zh).not.toContain("Notifications");
+ expect(zh).not.toContain("Dismiss");
+ });
+});
+
+describe("Toaster", () => {
+ it("renders nothing without a document to portal into", () => {
+ expect(renderStatic(createElement(Toaster))).toBe("");
+ });
+});
diff --git a/packages/ui/test/tooltip.test.ts b/packages/ui/test/tooltip.test.ts
new file mode 100644
index 00000000..5bc7a052
--- /dev/null
+++ b/packages/ui/test/tooltip.test.ts
@@ -0,0 +1,185 @@
+/**
+ * The tooltip (src/components/overlays/tooltip/tooltip.tsx): where it hangs its panel and how wide
+ * the panel may grow, the rule that decides whether a hint shows at all, and how the one
+ * `TooltipLayer` reads a `data-tooltip` request.
+ *
+ * The panel is pinned by one horizontal edge and grows away from it, so the only width it can
+ * safely take is the room between that edge and the viewport margin on the far side. A long
+ * text — a background process's command, shown whole — wraps at that room instead of running off
+ * a phone's screen; a short label never reaches it.
+ *
+ * The rule: a hint shows for an element with no visible text of its own, or one whose visible
+ * text is cut off — never for a label the reader can already read in full.
+ *
+ * The panel itself mounts only while hovered and through a portal, which a static render cannot
+ * reach; what it may be drawn with (the overlay surface, token inks, the glass hook) is pinned
+ * against the source. Where the app may still use a native `title` is the web app's
+ * `no-native-title.test.ts`.
+ */
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import {
+ Tooltip,
+ belowTrigger,
+ besideTrigger,
+ hintAllowed,
+ isCutOff,
+ namedHint,
+ tooltipRequest,
+} from "../src/components/overlays/tooltip/tooltip";
+import { renderStatic } from "../src/testing";
+import { SRC_DIR } from "./helpers/paths";
+
+const VIEWPORT = { width: 1000, height: 800 };
+
+/** A trigger box from its left/top corner and size. */
+const box = (left: number, top: number, width: number, height: number) => ({
+ left,
+ top,
+ width,
+ height,
+ right: left + width,
+ bottom: top + height,
+});
+
+describe("belowTrigger", () => {
+ it("anchors by the right edge in the right half, with the room reaching back to the left margin", () => {
+ // A command line near the right of the window: the panel grows leftward from its right edge.
+ expect(belowTrigger(box(700, 100, 200, 20), VIEWPORT)).toEqual({
+ top: 128,
+ right: 100,
+ room: 892,
+ });
+ });
+
+ it("anchors by the left edge in the left half, with the room reaching to the right margin", () => {
+ // A phone-width card: the room, not the panel's own cap, is what keeps the text on screen.
+ expect(belowTrigger(box(40, 100, 200, 20), { width: 390, height: 800 })).toEqual({
+ top: 128,
+ left: 40,
+ room: 342,
+ });
+ });
+
+ it("keeps the anchored edge inside the viewport margin", () => {
+ expect(belowTrigger(box(900, 0, 100, 20), VIEWPORT).right).toBe(8);
+ expect(belowTrigger(box(-20, 0, 100, 20), VIEWPORT).left).toBe(8);
+ });
+});
+
+describe("besideTrigger", () => {
+ it("hangs to the right of a rail entry, centred on it, with the room to the right margin", () => {
+ expect(besideTrigger(box(8, 200, 32, 32), VIEWPORT)).toEqual({ top: 216, left: 48, room: 944 });
+ });
+
+ it("clamps the centre into the viewport and never reports negative room", () => {
+ const offscreen = besideTrigger(box(990, 900, 32, 32), VIEWPORT);
+ expect(offscreen.top).toBe(792);
+ expect(offscreen.room).toBe(0);
+ });
+});
+
+const clip = (scrollWidth: number, clientWidth: number, scrollHeight = 16, clientHeight = 16) => ({
+ scrollWidth,
+ clientWidth,
+ scrollHeight,
+ clientHeight,
+});
+
+describe("isCutOff", () => {
+ it("reads overflow on either axis as cut off", () => {
+ expect(isCutOff(clip(240, 120))).toBe(true);
+ expect(isCutOff(clip(100, 100, 40, 20))).toBe(true);
+ });
+
+ it("forgives the pixel of overflow layout reports for text that fits", () => {
+ expect(isCutOff(clip(101, 100, 17, 16))).toBe(false);
+ expect(isCutOff(clip(100, 100))).toBe(false);
+ });
+});
+
+describe("hintAllowed", () => {
+ it("shows the hint of an element with no text of its own (an icon, a chart mark)", () => {
+ expect(hintAllowed("", [clip(24, 24)])).toBe(true);
+ expect(hintAllowed(" ", [])).toBe(true);
+ });
+
+ it("shows the hint when the visible text is cut off anywhere inside", () => {
+ expect(hintAllowed("A very long Session title", [clip(200, 200), clip(320, 180)])).toBe(true);
+ });
+
+ it("shows no hint for text that is fully visible, whatever the hint would add", () => {
+ expect(hintAllowed("3 min ago", [clip(60, 60), clip(58, 60)])).toBe(false);
+ expect(hintAllowed("Copy prompt", [])).toBe(false);
+ });
+});
+
+describe("a data-tooltip request", () => {
+ const el = (attrs: Record<string, string>) => ({
+ getAttribute: (name: string) => attrs[name] ?? null,
+ });
+
+ it("reads the text, the kind and the side, defaulting to a label below", () => {
+ expect(tooltipRequest(el({ "data-tooltip": "Rename" }))).toEqual({
+ label: "Rename",
+ content: "label",
+ placement: "bottom",
+ });
+ expect(
+ tooltipRequest(
+ el({
+ "data-tooltip": "npm run dev",
+ "data-tooltip-content": "code",
+ "data-tooltip-placement": "right",
+ }),
+ ),
+ ).toEqual({ label: "npm run dev", content: "code", placement: "right" });
+ });
+
+ it("asks for nothing when the text is missing or blank", () => {
+ expect(tooltipRequest(el({}))).toBeNull();
+ expect(tooltipRequest(el({ "data-tooltip": " " }))).toBeNull();
+ });
+});
+
+describe("namedHint", () => {
+ it("names a wordless mark with the words its hint shows", () => {
+ expect(namedHint("Bar 3")).toEqual({
+ role: "img",
+ "aria-label": "Bar 3",
+ "data-tooltip": "Bar 3",
+ });
+ });
+});
+
+describe("Tooltip", () => {
+ it("wraps its trigger in the measuring span and renders no panel until hovered", () => {
+ const html = renderStatic(
+ createElement(Tooltip, { label: "Settings", className: "mt-auto", children: "gear" }),
+ );
+ expect(html).toBe('<span class="flex mt-auto">gear</span>');
+ // Deliberately no tooltip role or description: the trigger's own name is the one name.
+ expect(html).not.toContain('role="tooltip"');
+ expect(html).not.toContain("aria-describedby");
+ });
+
+ it("draws the panel on the overlay surface in token inks, as a glass layer that takes no clicks", () => {
+ const source = readFileSync(join(SRC_DIR, "components/overlays/tooltip/tooltip.tsx"), "utf8");
+ const panel = /className=\{`(ui-glass [^`]*)`\}/.exec(source);
+ expect(panel, "the panel's class string").not.toBeNull();
+ const tokens = panel![1]!.split(/\s+/);
+ expect(tokens).toEqual(
+ expect.arrayContaining([
+ "ui-glass",
+ "pointer-events-none",
+ "border-line",
+ "bg-overlay",
+ "text-fg",
+ "z-[60]",
+ ]),
+ );
+ expect(source).toContain("aria-hidden");
+ });
+});
diff --git a/packages/web/e2e/compact-abort.spec.mjs b/packages/web/e2e/compact-abort.spec.mjs
index 7e55461e..086c4d5c 100644
--- a/packages/web/e2e/compact-abort.spec.mjs
+++ b/packages/web/e2e/compact-abort.spec.mjs
@@ -74,7 +74,7 @@ test("aborting before any turn completes: /compact says so instead of doing noth
await expect(page.getByRole("button", { name: "停止" })).toHaveCount(0);
// The actual user path: type /compact in the input box and press Enter (slash menu).
- // Feedback goes through a **top toast** (the Toaster from components/ui/toast; the toast
+ // Feedback goes through a **top toast** (the shared UI package's Toaster; the toast
// itself is a clickable, dismissible button), not a native browser alert — the latter would
// trigger Playwright's dialog event, which lets us assert we didn't fall back to it.
const nativeDialogs = [];
diff --git a/packages/web/e2e/company.spec.mjs b/packages/web/e2e/company.spec.mjs
index af37e152..3b286f73 100644
--- a/packages/web/e2e/company.spec.mjs
+++ b/packages/web/e2e/company.spec.mjs
@@ -158,7 +158,7 @@ test("company mode: create the organization, meet the CEO, see the board and the
await page.goto(`/org/${projectId}/${ORG}/chart`);
// The card's face is inert; its kebab menu is the way into the desk session.
await page.getByRole("button", { name: "Dana Dev · 员工操作" }).click();
- await page.getByRole("button", { name: "打开工位会话" }).click();
+ await page.getByRole("menuitem", { name: "打开工位会话" }).click();
await expect(page).toHaveURL(/\/chat\/session-/);
await expect(page.getByText("Dana Dev 的工位").first()).toBeVisible();
await expect(sidebar.getByRole("button", { name: /Dana Dev 的工位/ })).toHaveAttribute(
diff --git a/packages/web/e2e/draft-user-scope.spec.mjs b/packages/web/e2e/draft-user-scope.spec.mjs
index d9696bbd..a297e280 100644
--- a/packages/web/e2e/draft-user-scope.spec.mjs
+++ b/packages/web/e2e/draft-user-scope.spec.mjs
@@ -62,7 +62,7 @@ test("switching accounts: B does not restore A's draft; both drafts coexist", as
// the last match, which is the bottom user menu). The menu row only opens the confirmation;
// the dialog's own button, scoped to the dialog because both carry the same label, ends the session.
await page.getByRole("button", { name: UA }).last().click();
- await page.getByRole("button", { name: "登出" }).click();
+ await page.getByRole("menuitem", { name: "登出" }).click();
await page.getByRole("dialog").getByRole("button", { name: "登出" }).click();
await page.waitForURL(/\/login/);
diff --git a/packages/web/e2e/draft.spec.mjs b/packages/web/e2e/draft.spec.mjs
index ff5d4496..aeeaccf6 100644
--- a/packages/web/e2e/draft.spec.mjs
+++ b/packages/web/e2e/draft.spec.mjs
@@ -293,7 +293,7 @@ test("draft: pick model/approval -> reload restores them -> send creates the ses
// —— Switch the sidebar to agent mode via the header's list-settings menu (persists in
// localStorage; the grouping radios moved from the inline toggle into this menu) ——
await page.getByRole("button", { name: "列表选项" }).click();
- await page.getByRole("button", { name: "按 Agent 分组" }).click();
+ await page.getByRole("menuitemradio", { name: "按 Agent 分组" }).click();
await expect
.poll(() => page.evaluate(() => localStorage.getItem("penguin.sidebarGroupMode")))
.toBe("agent");
diff --git a/packages/web/e2e/selection-menu.spec.mjs b/packages/web/e2e/selection-menu.spec.mjs
index 730970bb..0c9f3c49 100644
--- a/packages/web/e2e/selection-menu.spec.mjs
+++ b/packages/web/e2e/selection-menu.spec.mjs
@@ -76,8 +76,8 @@ test("selected conversation text offers Copy and Add to conversation", async ({
const reply = page.getByText(SENTENCE, { exact: true });
await expect(reply).toBeVisible({ timeout: 30_000 });
- const copyRow = page.getByRole("button", { name: "复制", exact: true });
- const addRow = page.getByRole("button", { name: "添加到对话", exact: true });
+ const copyRow = page.getByRole("menuitem", { name: "复制", exact: true });
+ const addRow = page.getByRole("menuitem", { name: "添加到对话", exact: true });
// Nothing selected: the app's menu stays shut and the browser keeps its own.
await page.evaluate(() => window.getSelection()?.removeAllRanges());
@@ -195,7 +195,7 @@ test("an open selection menu holds a live reply's auto-follow, and closing it ca
// click would first scroll the target into view. Retried: a snap's scroll event from just
// before the click can still land after the menu opened, and a scroll that moves the menu's
// anchor closes it, which is the behaviour the hold must not take away from the user.
- const addRow = page.getByRole("button", { name: "添加到对话", exact: true });
+ const addRow = page.getByRole("menuitem", { name: "添加到对话", exact: true });
await expect(async () => {
const at = await page.evaluate(() => {
const stream = document.querySelector("[data-outline-anchor]").closest(".overflow-y-auto");
diff --git a/packages/web/src/app.tsx b/packages/web/src/app.tsx
index 0a08000a..7927e0f7 100644
--- a/packages/web/src/app.tsx
+++ b/packages/web/src/app.tsx
@@ -10,13 +10,11 @@
* drop on the sidebar do something; it makes it do nothing.
*/
import { useEffect } from "react";
-import { ClipboardWriterProvider } from "@prismshadow/penguin-ui";
+import { ClipboardWriterProvider, Toaster, TooltipLayer } from "@prismshadow/penguin-ui";
import { LocaleProvider, LocaleScope } from "./state/locale";
import { ThemeProvider } from "./state/theme";
import { AuthProvider } from "./state/auth";
import { AppRouter } from "./router";
-import { Toaster } from "./components/ui/toast";
-import { TooltipLayer } from "./components/ui/tooltip";
import { writeClipboard } from "./lib/clipboard";
import { guardWindowDragOver, guardWindowDrop } from "./lib/file-drop";
diff --git a/packages/web/src/components/account/change-password-dialog.tsx b/packages/web/src/components/account/change-password-dialog.tsx
index 784e60c2..d9af8614 100644
--- a/packages/web/src/components/account/change-password-dialog.tsx
+++ b/packages/web/src/components/account/change-password-dialog.tsx
@@ -4,14 +4,13 @@
* notice banner disappears once passwordIsInitial clears. Shared by the sidebar user menu and the notice banner.
*/
import { useEffect, useState } from "react";
-import { Button, PasswordInput } from "@prismshadow/penguin-ui";
+import { Button, Modal, PasswordInput } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useAuth } from "../../state/auth";
import { omitsOldPassword } from "../../lib/account-menu";
-import { Modal } from "../ui/modal";
export function ChangePasswordDialog({ open, onClose }: { open: boolean; onClose: () => void }) {
const { refresh, desktopMode, sessionVia } = useAuth();
diff --git a/packages/web/src/components/account/update-modal.tsx b/packages/web/src/components/account/update-modal.tsx
index 095539f9..fa910290 100644
--- a/packages/web/src/components/account/update-modal.tsx
+++ b/packages/web/src/components/account/update-modal.tsx
@@ -14,7 +14,7 @@
* The flow and the actions live in `use-update-flow.ts`; this file only renders.
*/
import type { ReactNode } from "react";
-import { Button, Link, Spinner } from "@prismshadow/penguin-ui";
+import { Button, Link, Modal, Spinner } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { stripAnsi } from "../../lib/strip-ansi";
import { toneInk } from "../../lib/tone";
@@ -27,7 +27,6 @@ import {
useUpdateFlow,
useUpdateFlowOwner,
} from "../../lib/use-update-flow";
-import { Modal } from "../ui/modal";
const RELEASES_URL = "https://github.com/Prism-Shadow/penguin-harness/releases";
diff --git a/packages/web/src/components/account/update-row.tsx b/packages/web/src/components/account/update-row.tsx
index 22b369b5..19f27980 100644
--- a/packages/web/src/components/account/update-row.tsx
+++ b/packages/web/src/components/account/update-row.tsx
@@ -3,20 +3,18 @@
* names where the flow stands (check / checking / a release offered / downloading with its
* percentage / restart to update / restarting / cannot update), and every state opens the
* update modal, which is where the flow is explained and acted on. The running version
- * sits muted on the right. Renders nothing where this session can update nothing.
+ * sits muted on the right. Renders nothing where this session can update nothing. A Menu row,
+ * like the menu's other entries.
*/
-import { Spinner } from "@prismshadow/penguin-ui";
+import { MenuItem, Spinner } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { updateRowModel } from "../../lib/update-flow";
import type { UpdateFlow } from "../../lib/update-flow";
import { useUpdateFlow } from "../../lib/use-update-flow";
export function UpdateRow({
- menuItemClass,
onOpen,
}: {
- /** The menu's shared row class (dropdown.tsx's `menuItemClass`). */
- menuItemClass: string;
/** Click: the account menu closes and the update modal opens. */
onOpen: () => void;
}) {
@@ -24,28 +22,22 @@ export function UpdateRow({
if (mode === "none") return null;
const row = updateRowModel(flow);
return (
- <button
- type="button"
- onClick={onOpen}
- className={`${menuItemClass} flex items-center justify-between gap-2`}
- >
- <span className="flex min-w-0 items-center gap-2">
- {/* The row's words already say what is running; hidden, the spinner stays out of the
- menu item's accessible name. */}
- {row.busy && (
+ <MenuItem
+ glyph={
+ row.busy ? (
+ // The row's words already say what is running; hidden, the spinner stays out of the
+ // menu item's accessible name.
<span aria-hidden className="flex shrink-0">
<Spinner size="sm" label={S.common.loading} />
</span>
- )}
- {row.dot && <span aria-hidden className="h-2 w-2 shrink-0 rounded-full bg-accent" />}
- <span className="min-w-0 truncate">{rowLabel(flow)}</span>
- </span>
- {currentVersion !== null && (
- <span className="shrink-0 text-xs text-gray-400 dark:text-gray-500">
- {`v${currentVersion}`}
- </span>
- )}
- </button>
+ ) : row.dot ? (
+ <span aria-hidden className="h-2 w-2 shrink-0 rounded-full bg-accent" />
+ ) : undefined
+ }
+ label={rowLabel(flow)}
+ trailing={currentVersion !== null ? `v${currentVersion}` : undefined}
+ onSelect={onOpen}
+ />
);
}
diff --git a/packages/web/src/components/layout/app-layout.tsx b/packages/web/src/components/layout/app-layout.tsx
index a4aac07f..06cea9e3 100644
--- a/packages/web/src/components/layout/app-layout.tsx
+++ b/packages/web/src/components/layout/app-layout.tsx
@@ -6,7 +6,16 @@
*/
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { NavLink, Outlet, useLocation, useMatch, useNavigate } from "react-router";
-import { CloseIcon, GlyphIcon, ICONS, UpdateDot, UserAvatar } from "@prismshadow/penguin-ui";
+import {
+ CloseIcon,
+ Drawer,
+ GlyphIcon,
+ ICONS,
+ NoticeStrip,
+ Tooltip,
+ UpdateDot,
+ UserAvatar,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { nagsAboutInitialPassword } from "../../lib/account-menu";
import { S } from "../../lib/strings";
@@ -19,8 +28,6 @@ import { useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
import { useCompletionNotifications } from "../../state/use-completion-notifications";
import { useTrayLocale } from "../../state/use-tray-locale";
-import { Drawer } from "../ui/drawer";
-import { Tooltip } from "../ui/tooltip";
import { NAV_ICONS } from "../../lib/nav-icons";
import { useCompany } from "../../state/company";
import { COMPANY_NAV_ICONS } from "../../features/company/company-nav-icons";
@@ -43,7 +50,6 @@ import { ShortcutRuntime } from "../../features/settings/shortcut-runtime";
import { BuiltinBrowserLayer } from "../../features/builtin-browser/browser-layer";
import { setDockScope } from "../../features/dock/dock-state";
import { AppPalette } from "../../features/palette/app-palette";
-import { NoticeStrip } from "../ui/notice-strip";
/**
* "Last conversation" glyph, used only by the rail: lucide's history mark — a clock read
diff --git a/packages/web/src/components/layout/project-dialogs.tsx b/packages/web/src/components/layout/project-dialogs.tsx
index 0cb38f1c..6f8b9932 100644
--- a/packages/web/src/components/layout/project-dialogs.tsx
+++ b/packages/web/src/components/layout/project-dialogs.tsx
@@ -15,15 +15,19 @@ import type {
import {
Badge,
Button,
+ ConfirmModal,
FieldError,
FieldHint,
FieldLabel,
ICONS,
InfoPopover,
Input,
+ Modal,
Select,
SettingRow,
Switch,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -44,9 +48,6 @@ import { ModelSelect, modelLabel } from "../../features/chat/model-select";
import { SELECTABLE_THINKING_LEVELS } from "../../features/chat/thinking-level";
import { WorkspaceSelect } from "../../features/chat/workspace-select";
import { sameModelRef } from "../../features/models/model-grouping";
-import { toastError, toastSuccess } from "../ui/toast";
-import { Modal } from "../ui/modal";
-import { ConfirmModal } from "../ui/confirm-modal";
import { SemanticIdField } from "../../features/semantic-id/semantic-id-field";
/** Approval modes offered by the new-chat-defaults select, in the composer menu's order. */
@@ -394,6 +395,8 @@ function GeneralSection({
title={S.project.deleteProject}
onClose={() => setConfirmDelete(false)}
onConfirm={() => void doDelete()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">{S.project.deleteConfirm}</p>
</ConfirmModal>
@@ -1053,7 +1056,7 @@ function SecurityPolicySection({ projectId, isOwner }: { projectId: string; isOw
<p className="mt-0.5 text-xs text-gray-400">{r.description}</p>
)}
<p
- className="mt-0.5 truncate font-mono text-[11px] text-gray-400"
+ className="mt-0.5 truncate font-mono text-xs text-gray-400"
data-tooltip={r.pattern}
data-tooltip-content="code"
>
diff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsx
index a2b27aea..8089e2f4 100644
--- a/packages/web/src/components/layout/sidebar.tsx
+++ b/packages/web/src/components/layout/sidebar.tsx
@@ -50,17 +50,28 @@ import {
BackgroundTasksMark,
Badge,
Button,
- CheckIcon,
ChevronDown,
+ ConfirmModal,
+ Dropdown,
ICONS,
ICON_SIZE,
Input,
+ Menu,
+ MenuItem,
+ MenuLabel,
+ MenuRadioItem,
+ MenuSeparator,
+ Modal,
ScheduleMark,
SearchInput,
Segmented,
SkeletonList,
UpdateDot,
UserAvatar,
+ toastError,
+ toastInfo,
+ toastSuccess,
+ useRowContextMenu,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -144,16 +155,11 @@ import {
orderGroups,
saveGroupOrder,
} from "../../lib/group-order";
-import { Dropdown, menuItemClass } from "../ui/dropdown";
-import { useRowContextMenu } from "../ui/context-menu";
import {
HOVER_ROW_ACTIONS,
SessionRowHoverActions,
SessionRowMenuRows,
contextMenuActions,
- overflowMenuDangerClass,
- overflowMenuGlyph,
- overflowMenuRowClass,
} from "../ui/session-row-menu";
import type { SessionRowAction } from "../ui/session-row-menu";
import { NAV_ICONS } from "../../lib/nav-icons";
@@ -170,11 +176,8 @@ import {
storeGroupMode,
} from "../ui/group-list";
import type { GroupMode } from "../ui/group-list";
-import { toastError, toastInfo, toastSuccess } from "../ui/toast";
import { writeClipboard } from "../../lib/clipboard";
import { Truncated } from "../ui/truncated";
-import { Modal } from "../ui/modal";
-import { ConfirmModal } from "../ui/confirm-modal";
import { DRAFT_SESSION_ID } from "../../features/chat/chat-page";
import { MessagingBindingModal } from "../../features/messaging/messaging-binding-modal";
import { WorkspaceSelect } from "../../features/chat/workspace-select";
@@ -281,10 +284,6 @@ const headerControlClass = (active: boolean) =>
: "text-gray-400 hover:bg-gray-200/50 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-800/70 dark:hover:text-gray-300"
}`;
-/** Muted section label inside the list-settings menu (分组方式 / 排序方式), at the overflow menus' density. */
-const menuSectionClass =
- "px-2.5 pb-0.5 pt-1.5 text-[11px] font-medium text-gray-400 dark:text-gray-500";
-
/**
* Collapsed-group and pinned-group persistence (survives a refresh), one storage key
* per Project and concern — group keys are Agent ids / Workspace paths, which are
@@ -1852,46 +1851,39 @@ export function Sidebar({
</button>
}
>
+ {/* Plain rows rather than a role="menu": the switcher's Project rows are named
+ like its trigger, and both are reached as buttons. */}
{projects.map((p) => (
- <button
+ <MenuRadioItem
key={p.projectId}
- type="button"
- onClick={() => {
+ label={<span className="font-sans">{projectDisplayName(p)}</span>}
+ trailing={<Badge>{p.role}</Badge>}
+ checked={p.projectId === currentProject?.projectId}
+ onSelect={() => {
setCurrentProjectId(p.projectId);
setProjectOpen(false);
}}
- className={`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-sm transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${
- p.projectId === currentProject?.projectId ? "font-semibold" : ""
- }`}
- >
- <span className="truncate font-sans">{projectDisplayName(p)}</span>
- <Badge>{p.role}</Badge>
- </button>
+ />
))}
- <div className="mt-1.5 border-t border-gray-100 pt-1.5 dark:border-gray-800">
- <button
- type="button"
- className={menuItemClass}
- onClick={() => {
+ <MenuSeparator />
+ <MenuItem
+ glyph={ICONS.plus}
+ label={S.project.create}
+ onSelect={() => {
+ setProjectOpen(false);
+ setCreateProjectOpen(true);
+ }}
+ />
+ {currentProject && (
+ <MenuItem
+ glyph={ICONS.gear}
+ label={S.project.settings}
+ onSelect={() => {
setProjectOpen(false);
- setCreateProjectOpen(true);
+ setProjectSettingsOpen(true);
}}
- >
- + {S.project.create}
- </button>
- {currentProject && (
- <button
- type="button"
- className={menuItemClass}
- onClick={() => {
- setProjectOpen(false);
- setProjectSettingsOpen(true);
- }}
- >
- {S.project.settings}
- </button>
- )}
- </div>
+ />
+ )}
</Dropdown>
)}
</div>
@@ -2151,57 +2143,59 @@ export function Sidebar({
</button>
}
>
- <p className={menuSectionClass}>{S.chat.groupModeSection}</p>
- <MenuRadioRow
- icon={GROUP_MODE_ICONS.workspace}
- label={S.chat.groupByWorkspace}
- checked={groupMode === "workspace"}
- onSelect={() => {
- setGroupMode("workspace");
- setListSettingsOpen(false);
- }}
- />
- <MenuRadioRow
- icon={GROUP_MODE_ICONS.agent}
- label={S.chat.groupByAgent}
- checked={groupMode === "agent"}
- onSelect={() => {
- setGroupMode("agent");
- setListSettingsOpen(false);
- }}
- />
- <MenuRadioRow
- icon={GROUP_MODE_ICONS.time}
- label={S.chat.groupByTime}
- checked={groupMode === "time"}
- onSelect={() => {
- setGroupMode("time");
- setListSettingsOpen(false);
- }}
- />
- <div className="my-1 border-t border-gray-100 dark:border-gray-800" />
- <p className={menuSectionClass}>{S.chat.sortModeSection}</p>
- {/* Manual order is offered only where a drag can actually happen (see canDrag). */}
- {canDrag && (
- <MenuRadioRow
- icon={SORT_MODE_ICONS.manual}
- label={S.chat.sortManual}
- checked={sortMode === "manual"}
+ <Menu density="sm">
+ <MenuLabel>{S.chat.groupModeSection}</MenuLabel>
+ <MenuRadioItem
+ glyph={GROUP_MODE_ICONS.workspace}
+ label={S.chat.groupByWorkspace}
+ checked={groupMode === "workspace"}
onSelect={() => {
- setSortMode("manual");
+ setGroupMode("workspace");
setListSettingsOpen(false);
}}
/>
- )}
- <MenuRadioRow
- icon={SORT_MODE_ICONS.recent}
- label={S.chat.sortRecent}
- checked={sortMode === "recent"}
- onSelect={() => {
- setSortMode("recent");
- setListSettingsOpen(false);
- }}
- />
+ <MenuRadioItem
+ glyph={GROUP_MODE_ICONS.agent}
+ label={S.chat.groupByAgent}
+ checked={groupMode === "agent"}
+ onSelect={() => {
+ setGroupMode("agent");
+ setListSettingsOpen(false);
+ }}
+ />
+ <MenuRadioItem
+ glyph={GROUP_MODE_ICONS.time}
+ label={S.chat.groupByTime}
+ checked={groupMode === "time"}
+ onSelect={() => {
+ setGroupMode("time");
+ setListSettingsOpen(false);
+ }}
+ />
+ <MenuSeparator />
+ <MenuLabel>{S.chat.sortModeSection}</MenuLabel>
+ {/* Manual order is offered only where a drag can actually happen (see canDrag). */}
+ {canDrag && (
+ <MenuRadioItem
+ glyph={SORT_MODE_ICONS.manual}
+ label={S.chat.sortManual}
+ checked={sortMode === "manual"}
+ onSelect={() => {
+ setSortMode("manual");
+ setListSettingsOpen(false);
+ }}
+ />
+ )}
+ <MenuRadioItem
+ glyph={SORT_MODE_ICONS.recent}
+ label={S.chat.sortRecent}
+ checked={sortMode === "recent"}
+ onSelect={() => {
+ setSortMode("recent");
+ setListSettingsOpen(false);
+ }}
+ />
+ </Menu>
</Dropdown>
{/* Mode-dependent create — 具体新建的对象按分组方式决定, the icon following
suit (folder+ / robot+, a bottom-right plus badge on the entity's glyph):
@@ -2757,6 +2751,7 @@ export function Sidebar({
open={deletingSession !== null}
title={S.chat.deleteSession}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
busy={deletingBusy}
onClose={() => (deletingBusy ? undefined : setDeletingSession(null))}
onConfirm={() => void confirmDeleteSession()}
@@ -2775,6 +2770,7 @@ export function Sidebar({
open={deletingWorkspace !== null}
title={S.chat.deleteWorkspace}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
onClose={() => setDeletingWorkspace(null)}
onConfirm={confirmDeleteWorkspace}
>
@@ -2789,6 +2785,7 @@ export function Sidebar({
open={deletingDraft !== null}
title={S.chat.deleteDraft}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
onClose={() => setDeletingDraft(null)}
onConfirm={confirmDeleteDraft}
>
@@ -3221,7 +3218,7 @@ function SessionRow({
/**
* Registry-backed workspace group's overflow (… to the right of the header's "+"):
- * 重命名工作区 / 删除工作区 in the session-row menu's compact style. Sits among the
+ * 重命名工作区 / 删除工作区 as small Menu rows, like the session row's menu. Sits among the
* header's action buttons — outside the header's collapse toggle, so opening it never
* expands/collapses the group. Body-portaled like every menu inside the scroller.
*/
@@ -3259,53 +3256,15 @@ function GroupOverflowMenu({ onRename, onDelete }: { onRename: () => void; onDel
</button>
}
>
- <button type="button" className={overflowMenuRowClass} onClick={item(onRename)}>
- {overflowMenuGlyph(ICONS.pencil)}
- {S.chat.renameWorkspace}
- </button>
- <button type="button" className={overflowMenuDangerClass} onClick={item(onDelete)}>
- <span className="shrink-0">
- <Icon d={ICONS.trash} size={13} />
- </span>
- {S.chat.deleteWorkspace}
- </button>
+ <Menu density="sm">
+ <MenuItem glyph={ICONS.pencil} label={S.chat.renameWorkspace} onSelect={item(onRename)} />
+ <MenuItem
+ glyph={ICONS.trash}
+ label={S.chat.deleteWorkspace}
+ danger
+ onSelect={item(onDelete)}
+ />
+ </Menu>
</Dropdown>
);
}
-
-/**
- * List-settings menu option: leading glyph + label, with a checkmark marking the active
- * choice (reference-style radio row; aria-pressed carries the state). Same type scale and
- * leading-glyph column as the session/workspace overflow menus (用户口径: 字体和 Session
- * 更多一样), so the two menus read as one family.
- *
- * The glyph is decorative — it names the option's subject (a folder for Workspace
- * grouping, a clock for recency) beside a label that is never dropped, so the row's
- * accessible name stays the label alone.
- */
-function MenuRadioRow({
- icon,
- label,
- checked,
- onSelect,
-}: {
- icon: string;
- label: string;
- checked: boolean;
- onSelect: () => void;
-}) {
- return (
- <button
- type="button"
- aria-pressed={checked}
- onClick={onSelect}
- className={`${overflowMenuRowClass} justify-between`}
- >
- <span className="flex min-w-0 items-center gap-2">
- {overflowMenuGlyph(icon)}
- <span className="truncate">{label}</span>
- </span>
- {checked && <CheckIcon className="shrink-0 text-gray-500 dark:text-gray-400" />}
- </button>
- );
-}
diff --git a/packages/web/src/components/layout/user-menu.tsx b/packages/web/src/components/layout/user-menu.tsx
index f806572a..2ae074c7 100644
--- a/packages/web/src/components/layout/user-menu.tsx
+++ b/packages/web/src/components/layout/user-menu.tsx
@@ -17,12 +17,17 @@
import { useEffect, useState } from "react";
import type { ReactNode } from "react";
import { useNavigate } from "react-router";
-import { ICON_GAP, UserAvatar } from "@prismshadow/penguin-ui";
+import {
+ ConfirmModal,
+ Dropdown,
+ ICON_GAP,
+ Menu,
+ MenuItem,
+ UserAvatar,
+} from "@prismshadow/penguin-ui";
+import type { DropdownPortal } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { useAuth } from "../../state/auth";
-import { ConfirmModal } from "../ui/confirm-modal";
-import { Dropdown, menuItemClass } from "../ui/dropdown";
-import type { DropdownPortal } from "../ui/dropdown";
import { UpdateRow } from "../account/update-row";
import { openUpdateModal } from "../../lib/use-update-flow";
import { SettingsDialog } from "../../features/settings/settings-dialog";
@@ -107,45 +112,41 @@ export function UserMenu({
personal pages, and the server-global ones inside it stay gated by the
section registry rather than by this row. The preference rows that used to
stack here live on its pages now. */}
- <button
- type="button"
- className={menuItemClass}
- onClick={() => {
- setOpen(false);
- setSettingsSection(undefined);
- setSettingsOpen(true);
- }}
- >
- {S.settings.title}
- </button>
- {/* Update entry, directly under the settings entry rather than on a page inside
- it: one row for both backends (the server release here, the shell's own
- updater in the desktop window), naming where the update flow stands and
- opening the update modal — where the flow is explained and acted on. The
- modal is mounted by the app layout, so it outlives this menu. Hidden where
- this session can update nothing (a browser signed into a desktop-mode
- server, see updateModeFor). */}
- <UpdateRow
- menuItemClass={menuItemClass}
- onOpen={() => {
- setOpen(false);
- openUpdateModal();
- }}
- />
- {/* Hidden in desktop mode: the window IS the session — logging out would
- strand the user on a login page whose password was never shown. */}
- {!desktopMode && (
- <button
- type="button"
- className="block w-full px-3.5 py-2 text-left text-sm text-red-600 transition-colors duration-150 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40"
- onClick={() => {
+ <Menu>
+ <MenuItem
+ label={S.settings.title}
+ onSelect={() => {
setOpen(false);
- setConfirmingLogout(true);
+ setSettingsSection(undefined);
+ setSettingsOpen(true);
}}
- >
- {S.auth.logout}
- </button>
- )}
+ />
+ {/* Update entry, directly under the settings entry rather than on a page inside
+ it: one row for both backends (the server release here, the shell's own
+ updater in the desktop window), naming where the update flow stands and
+ opening the update modal — where the flow is explained and acted on. The
+ modal is mounted by the app layout, so it outlives this menu. Hidden where
+ this session can update nothing (a browser signed into a desktop-mode
+ server, see updateModeFor). */}
+ <UpdateRow
+ onOpen={() => {
+ setOpen(false);
+ openUpdateModal();
+ }}
+ />
+ {/* Hidden in desktop mode: the window IS the session — logging out would
+ strand the user on a login page whose password was never shown. */}
+ {!desktopMode && (
+ <MenuItem
+ danger
+ onSelect={() => {
+ setOpen(false);
+ setConfirmingLogout(true);
+ }}
+ label={S.auth.logout}
+ />
+ )}
+ </Menu>
</div>
</Dropdown>
<SettingsDialog
@@ -160,6 +161,7 @@ export function UserMenu({
open={confirmingLogout}
title={S.auth.logoutConfirmTitle}
confirmLabel={S.auth.logout}
+ cancelLabel={S.common.cancel}
onClose={() => setConfirmingLogout(false)}
onConfirm={() => {
setConfirmingLogout(false);
diff --git a/packages/web/src/components/ui/drawer.tsx b/packages/web/src/components/ui/drawer.tsx
deleted file mode 100644
index 10101de8..00000000
--- a/packages/web/src/components/ui/drawer.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Drawer component (for mobile nav/panels): overlay fades in + panel slides in from the side; Esc or clicking the overlay closes it.
- * `side` determines the docking direction; the panel width defaults to 80vw, capped by widthClass.
- *
- * Escape goes through the shared esc-layer stack (see modal.tsx), so a dialog or menu opened
- * from inside a drawer takes the first Escape alone: without that, one press would close the
- * confirmation *and* the drawer under it, dropping the panel the user was working in.
- */
-import { useEffect, useRef } from "react";
-import type { ReactNode } from "react";
-import { CloseButton } from "@prismshadow/penguin-ui";
-import { isTopEscLayer, popEscLayer, pushEscLayer } from "./modal";
-
-export interface DrawerProps {
- open: boolean;
- side?: "left" | "right";
- title?: string;
- onClose: () => void;
- children: ReactNode;
- /** Panel max-width class (default max-w-xs). */
- widthClass?: string;
-}
-
-export function Drawer({ open, side = "left", title, onClose, children, widthClass }: DrawerProps) {
- // Latest-callback ref, so the effect below re-runs ONLY on open/close: call sites pass an
- // inline arrow for onClose, and re-running on its identity would pop and re-push this
- // drawer's esc-layer on every render — jumping it back above a dialog opened inside it.
- const onCloseRef = useRef(onClose);
- onCloseRef.current = onClose;
-
- useEffect(() => {
- if (!open) return;
- const layer = pushEscLayer();
- const onKey = (e: KeyboardEvent) => {
- if (e.key === "Escape" && isTopEscLayer(layer)) onCloseRef.current();
- };
- window.addEventListener("keydown", onKey);
- return () => {
- window.removeEventListener("keydown", onKey);
- popEscLayer(layer);
- };
- }, [open]);
-
- if (!open) return null;
- return (
- <div className="fixed inset-0 z-50">
- <div
- // ui-scrim: the dimmed layer behind the drawer; a theme may blur the page through it.
- className="ui-scrim anim-fade absolute inset-0 bg-[var(--ui-overlay-backdrop)]"
- onMouseDown={onClose}
- />
- <div
- className={`absolute inset-y-0 flex w-[80vw] flex-col bg-white shadow-xl dark:bg-gray-900 ${widthClass ?? "max-w-xs"} ${
- side === "left"
- ? "anim-drawer-left left-0 border-r border-gray-200 dark:border-gray-800"
- : "anim-drawer-right right-0 border-l border-gray-200 dark:border-gray-800"
- }`}
- >
- <div className="flex shrink-0 items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800">
- <span className="text-base font-semibold">{title ?? ""}</span>
- <CloseButton onClose={onClose} />
- </div>
- <div className="min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]">
- {children}
- </div>
- </div>
- </div>
- );
-}
diff --git a/packages/web/src/components/ui/image-zoom.tsx b/packages/web/src/components/ui/image-zoom.tsx
deleted file mode 100644
index 1ad3994b..00000000
--- a/packages/web/src/components/ui/image-zoom.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Clickable image that zooms in on click. The thumbnail keeps the caller's styling;
- * clicking it opens a lightbox: a bordered image panel with a close glyph in the
- * top-right corner (no title bar), closable via Esc or clicking the overlay.
- * The lightbox is rendered via portal to body — the thumbnail may be nested inside
- * a card with a transform entrance animation or overflow-hidden, and a `fixed`
- * layer rendered in place would get hijacked/clipped by that ancestor (same fix
- * as the Select dropdown).
- */
-import { useEffect, useState } from "react";
-import { createPortal } from "react-dom";
-import { CloseIcon } from "@prismshadow/penguin-ui";
-import { S } from "../../lib/strings";
-
-export function ZoomableImage({
- src,
- alt,
- className,
-}: {
- src: string;
- alt: string;
- /** Style for the thumbnail img (keeps the caller's original class). */
- className?: string;
-}) {
- const [open, setOpen] = useState(false);
- return (
- <>
- <button type="button" className="block cursor-zoom-in" onClick={() => setOpen(true)}>
- <img src={src} alt={alt} className={className} />
- </button>
- {open && <Lightbox src={src} alt={alt} onClose={() => setOpen(false)} />}
- </>
- );
-}
-
-function Lightbox({ src, alt, onClose }: { src: string; alt: string; onClose: () => void }) {
- useEffect(() => {
- const onKey = (e: KeyboardEvent) => {
- if (e.key === "Escape") onClose();
- };
- window.addEventListener("keydown", onKey);
- return () => window.removeEventListener("keydown", onKey);
- }, [onClose]);
-
- return createPortal(
- <div
- // ui-scrim: the overlay is the dimmed layer, with the image inside it.
- className="ui-scrim anim-fade fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-10"
- onMouseDown={(e) => {
- if (e.target === e.currentTarget) onClose();
- }}
- >
- <div className="anim-pop relative">
- {/* Close glyph: top-right inside the frame, floating over the image (dark semi-transparent background keeps it visible on any image). */}
- <button
- type="button"
- aria-label={S.common.close}
- onClick={onClose}
- className="absolute right-2 top-2 flex h-7 w-7 items-center justify-center rounded-full bg-black/50 text-white transition-colors duration-150 hover:bg-black/70"
- >
- <CloseIcon />
- </button>
- <img
- src={src}
- alt={alt}
- className="max-h-[85vh] max-w-[88vw] rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"
- />
- </div>
- </div>,
- document.body,
- );
-}
diff --git a/packages/web/src/components/ui/modal.tsx b/packages/web/src/components/ui/modal.tsx
deleted file mode 100644
index 001432e4..00000000
--- a/packages/web/src/components/ui/modal.tsx
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Modal dialog component: overlay fades in, panel rises into place; closes on
- * Esc or clicking the overlay. Docked to the bottom on narrow screens (bottom
- * sheet style), centered card at >=sm.
- *
- * **Rendered via portal to body**: the panel has its own transform entrance
- * animation (anim-pop), which makes it a containing block for descendant `fixed`
- * elements — if a nested modal (e.g. a delete confirmation inside a settings
- * modal) rendered in place, its overlay would be confined to the parent panel's
- * rectangle, leaving a misaligned edge (a white sliver showing through). After
- * portaling, every modal is a sibling child of body and stacks naturally in DOM
- * order.
- *
- * **Focus is contained**: opening moves focus into the panel, Tab and Shift+Tab cycle
- * inside it, and closing returns focus to whatever held it before. `role="dialog"` plus
- * `aria-modal` announce the page behind as out of scope, but neither moves focus — without
- * the trap, Tab walks straight out of the overlay into content the dialog sits on top of.
- */
-import { useEffect, useId, useRef } from "react";
-import { createPortal } from "react-dom";
-import type { KeyboardEvent as ReactKeyboardEvent, ReactNode, RefObject } from "react";
-import { CloseButton } from "@prismshadow/penguin-ui";
-import { setShortcutBlocker } from "../../lib/shortcuts/dispatcher";
-
-export interface ModalProps {
- open: boolean;
- /** Dialog name: rendered as the header bar and used to name the dialog, or (headerless) exposed as the panel's aria-label only. */
- title: string;
- onClose: () => void;
- children: ReactNode;
- footer?: ReactNode;
- /** Panel width class (defaults to sm:max-w-md). */
- widthClass?: string;
- /** No header bar (no visible title, no close button): compact dialogs like confirmations — the title still names the dialog for assistive tech. */
- headerless?: boolean;
- /** Render children full-bleed: no built-in padding or 70vh scroller. For dialogs that own their inner layout and scroll regions (PagedDialog); the caller then also owns a close control. */
- bare?: boolean;
- /**
- * Fill the whole screen on a phone instead of rising as a bottom sheet, and lay the panel out
- * as a column so a `bare` body can take the height between header and footer. For dialogs
- * that are a workspace of their own (the Workspace finder) rather than a question; pair it
- * with an `sm:` height in `widthClass`, since above the breakpoint the panel is a card again.
- */
- fullScreenOnPhone?: boolean;
-}
-
-/**
- * Stack of currently open Escape-consuming layers: Escape only acts on the **topmost**
- * one. Modals AND popup menus (Dropdown) join the same stack. When dialogs are nested
- * (e.g. a confirmation popped inside a settings modal), each Modal registers its own
- * window keydown->onClose; without checking the top of the stack, a single Escape would
- * close both layers at once and discard unsaved edits in the outer modal. The same rule
- * gives menus-inside-dialogs the right order: a Dropdown opened inside a Modal pushes
- * above it, so the first Escape closes only the menu (the Modal's handler sees itself
- * not on top and stays), and the next one closes the dialog. Pushed in mount order, so
- * the top of the stack is the visually topmost layer.
- */
-const escLayers: symbol[] = [];
-
-/** Register an Escape-consuming layer (called when a modal/menu opens); pair with popEscLayer. */
-export function pushEscLayer(): symbol {
- const id = Symbol("esc-layer");
- escLayers.push(id);
- return id;
-}
-
-export function popEscLayer(id: symbol): void {
- const i = escLayers.lastIndexOf(id);
- if (i !== -1) escLayers.splice(i, 1);
-}
-
-/** Whether this layer is the topmost one — the only layer an Escape press may act on. */
-export function isTopEscLayer(id: symbol): boolean {
- return escLayers[escLayers.length - 1] === id;
-}
-
-/** Whether any dialog or menu is open — the state in which a global shortcut must not run behind it. */
-export function hasEscLayers(): boolean {
- return escLayers.length > 0;
-}
-
-setShortcutBlocker(hasEscLayers);
-
-/**
- * The elements an overlay hands focus to, in DOM order. Shared with Dropdown so a dialog and
- * a menu agree on what "focusable" means. Visually hidden controls stay in the set on
- * purpose: the app's file pickers are hidden the `sr-only` way rather than with `display:
- * none` precisely so they keep their place in the Tab order (hidden-file-input.tsx).
- */
-export const FOCUSABLE_SELECTOR =
- 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
-
-/**
- * Index that Tab — or Shift+Tab, `backward` — moves to within a ring of `count` focusables,
- * wrapping at both ends so focus cannot walk out of the dialog. `at` is -1 when focus sits on
- * the panel container itself rather than on one of the ring's elements, which enters the ring
- * at whichever end the direction implies.
- */
-export function nextFocusIndex(count: number, at: number, backward: boolean): number {
- if (at < 0) return backward ? count - 1 : 0;
- return (at + (backward ? -1 : 1) + count) % count;
-}
-
-/**
- * What makes a portaled panel a dialog for the keyboard, shared by Modal and the overlays that
- * own their layout (the command palette, the harness history): Escape closes it only while it
- * is the topmost esc-consuming layer; opening moves focus into the panel and closing hands it
- * back; Tab and Shift+Tab cycle inside it. The returned `onKeyDown` goes on the panel element,
- * which also needs `tabIndex={-1}` so it can hold focus when nothing inside can.
- *
- * `onClose` is read through a ref so the effects re-run ONLY on open/close: call sites pass an
- * inline arrow, and re-running on its identity would pop and re-push this dialog's esc-layer
- * on every render — jumping it back above a menu opened inside it, so Escape would close the
- * whole dialog instead of just the menu. Dropdown keeps the same guard for the same reason.
- */
-export function useDialogLayer(
- open: boolean,
- panelRef: RefObject<HTMLElement | null>,
- onClose: () => void,
-): { onKeyDown: (e: ReactKeyboardEvent<HTMLElement>) => void } {
- const onCloseRef = useRef(onClose);
- onCloseRef.current = onClose;
-
- // Where focus goes when the dialog closes, read during render rather than in the effect
- // below: a child with `autoFocus` is focused during the same commit, before any effect
- // runs, so by effect time document.activeElement already points inside the dialog and the
- // element to return to is gone. Written only on the closed->open edge, so reopening from a
- // different trigger returns to that trigger, and a StrictMode double-mount — whose extra
- // cleanup restores focus once before the real one — does not drop the target.
- const restoreFocusRef = useRef<HTMLElement | null>(null);
- const wasOpenRef = useRef(false);
- if (open !== wasOpenRef.current) {
- wasOpenRef.current = open;
- if (open)
- restoreFocusRef.current =
- document.activeElement instanceof HTMLElement ? document.activeElement : null;
- }
-
- useEffect(() => {
- if (!open) return;
- const id = pushEscLayer();
- const onKey = (e: KeyboardEvent) => {
- if (e.key === "Escape" && isTopEscLayer(id)) onCloseRef.current();
- };
- window.addEventListener("keydown", onKey);
- return () => {
- window.removeEventListener("keydown", onKey);
- popEscLayer(id);
- };
- }, [open]);
-
- // Opening moves focus into the panel, closing hands it back. `aria-modal` tells assistive
- // tech the page behind is out of scope but moves nothing, so without this a keyboard user
- // stays parked on the trigger with the dialog's own controls several Tabs away.
- useEffect(() => {
- if (!open) return;
- const panel = panelRef.current;
- // A child with autoFocus already claimed focus during the commit — leave it there.
- if (panel && !panel.contains(document.activeElement))
- (panel.querySelector<HTMLElement>(FOCUSABLE_SELECTOR) ?? panel).focus();
- // Every close path lands in this cleanup: Escape, the close button, the overlay
- // mousedown, `open` going false, and the dialog unmounting outright.
- return () => restoreFocusRef.current?.focus();
- // Keyed on `open` alone (a ref object is stable), so the cleanup runs for every close path.
- }, [open]);
-
- /**
- * Tab and Shift+Tab cycle inside the panel instead of walking out into the page behind the
- * overlay.
- *
- * Two things this must not take over. A control that owns Tab for its own model (the
- * composer's slash picker accepts a completion with it) marks the event handled, and this
- * yields to that the way Dropdown's arrow keys do. And a menu or popover opened from inside
- * the dialog is portaled to body — outside this panel's DOM subtree, yet still a React
- * child, so its keydown bubbles through here; the containment check leaves that panel's own
- * focus alone.
- */
- const onPanelKeyDown = (e: ReactKeyboardEvent<HTMLElement>) => {
- if (e.key !== "Tab" || e.defaultPrevented) return;
- const panel = panelRef.current;
- if (!panel?.contains(document.activeElement)) return;
- e.preventDefault();
- const items = [...panel.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)];
- // A dialog with nothing focusable in it keeps focus on the container, which is what the
- // panel's tabIndex={-1} is for.
- if (items.length === 0) {
- panel.focus();
- return;
- }
- const at = items.indexOf(document.activeElement as HTMLElement);
- items[nextFocusIndex(items.length, at, e.shiftKey)]?.focus();
- };
- return { onKeyDown: onPanelKeyDown };
-}
-
-export function Modal({
- open,
- title,
- onClose,
- children,
- footer,
- widthClass,
- headerless,
- bare,
- fullScreenOnPhone,
-}: ModalProps) {
- const titleId = useId();
- const panelRef = useRef<HTMLDivElement>(null);
- const { onKeyDown: onPanelKeyDown } = useDialogLayer(open, panelRef, onClose);
-
- if (!open) return null;
- return createPortal(
- <div
- // ui-scrim: the dimmed layer between the page and the dialog; a theme may blur the page
- // through it. The overlay is the scrim itself, with the dialog inside it.
- className="ui-scrim anim-fade fixed inset-0 z-50 flex items-end justify-center bg-[var(--ui-overlay-backdrop)] p-0 sm:items-center sm:p-4"
- onMouseDown={(e) => {
- if (e.target === e.currentTarget) onClose();
- }}
- >
- <div
- ref={panelRef}
- role="dialog"
- aria-modal="true"
- // The titled branch is named by its own heading rather than a second copy of the
- // string, so a renamed dialog cannot end up announcing the old name.
- {...(headerless ? { "aria-label": title } : { "aria-labelledby": titleId })}
- tabIndex={-1}
- onKeyDown={onPanelKeyDown}
- className={`ui-glass anim-pop w-full ${widthClass ?? "sm:max-w-md"} ${
- fullScreenOnPhone
- ? "flex h-[100dvh] flex-col pt-[env(safe-area-inset-top)] sm:pt-0"
- : "rounded-t-lg"
- } border border-gray-200 bg-white pb-[env(safe-area-inset-bottom)] shadow-xl sm:rounded-lg sm:pb-0 dark:border-gray-800 dark:bg-gray-900`}
- >
- {!headerless && (
- <div className="flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800">
- <h2 id={titleId} className="text-base font-semibold">
- {title}
- </h2>
- <CloseButton onClose={onClose} />
- </div>
- )}
- {bare ? children : <div className="max-h-[70vh] overflow-y-auto px-4 py-4">{children}</div>}
- {footer && (
- <div className="flex justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800">
- {footer}
- </div>
- )}
- </div>
- </div>,
- document.body,
- );
-}
diff --git a/packages/web/src/components/ui/notice-strip.tsx b/packages/web/src/components/ui/notice-strip.tsx
deleted file mode 100644
index 5a01d05a..00000000
--- a/packages/web/src/components/ui/notice-strip.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * A notice that owns a row: an error line, a warning above a form, a status strip. The strip's
- * colours are `toneStrip`'s, chosen by meaning (see lib/tone.ts); the caller keeps its own
- * layout, spacing and border classes, so every strip sits where it sat before.
- *
- * It carries the `ui-notice` hook, so a theme can render notices its own way — a floating card
- * with a tone dot, a log line with a tone tag — without every call site knowing. `data-tone`
- * names the tone in the hook's vocabulary; callers may mark their text `data-slot="body"` and
- * their buttons `data-slot="actions"`.
- */
-import type { HTMLAttributes, ReactNode } from "react";
-import { toneStrip } from "../../lib/tone";
-import type { Tone } from "../../lib/tone";
-
-export type NoticeTone = "info" | "success" | "warning" | "danger" | "neutral";
-
-/** The app's tones in the notice hook's words: an unfinished state warns, a settled one is neutral. */
-export const NOTICE_TONE: Readonly<Record<Tone, NoticeTone>> = {
- busy: "success",
- success: "success",
- attention: "warning",
- danger: "danger",
- link: "info",
- muted: "neutral",
-};
-
-export function NoticeStrip({
- tone,
- as: Tag = "div",
- className = "",
- children,
- ...rest
-}: {
- tone: Tone;
- /** A strip that is one sentence of prose may be a paragraph. */
- as?: "div" | "p";
- className?: string;
- children?: ReactNode;
-} & Omit<HTMLAttributes<HTMLElement>, "className" | "children">) {
- return (
- <Tag
- {...rest}
- data-tone={NOTICE_TONE[tone]}
- className={`ui-notice ${className} ${toneStrip[tone]}`}
- >
- {children}
- </Tag>
- );
-}
diff --git a/packages/web/src/components/ui/session-row-menu.tsx b/packages/web/src/components/ui/session-row-menu.tsx
index c9087e14..3e9d45f1 100644
--- a/packages/web/src/components/ui/session-row-menu.tsx
+++ b/packages/web/src/components/ui/session-row-menu.tsx
@@ -19,7 +19,7 @@
*/
import type { MouseEvent as ReactMouseEvent } from "react";
import { GlyphIcon, ICONS, menuRowClass, menuRowTone } from "@prismshadow/penguin-ui";
-import type { AnchorRect } from "../../lib/context-menu";
+import type { AnchorRect } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { Icon } from "./group-list";
diff --git a/packages/web/src/components/ui/toast.tsx b/packages/web/src/components/ui/toast.tsx
deleted file mode 100644
index b6271c0a..00000000
--- a/packages/web/src/components/ui/toast.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Top overlay toast: results like "saved successfully" or "connection failed"
- * all pop up at the top of the page and disappear automatically after a few
- * seconds.
- *
- * Rendered via portal to body with a z-index above Modal/drawer (z-50), so a
- * toast triggered inside a dialog is still visible; the container doesn't
- * intercept mouse events (pointer-events-none) — only the toast itself is
- * interactive (clicking it dismisses immediately).
- *
- * Usage: call `toastSuccess("Saved")` / `toastInfo("Already up to date")` /
- * `toastAttention("Two desks share one minute")` / `toastError("Connection
- * failed: ...")` from anywhere, no context needed — a module-level store plus a
- * single `<Toaster />` mounted at the app root is all it takes.
- */
-import { createPortal } from "react-dom";
-import { useStore } from "zustand/react";
-import { createStore } from "zustand/vanilla";
-
-/** `attention` is the advisory kind: the write went through, and something about it is worth a look. */
-type ToastKind = "success" | "error" | "info" | "attention";
-
-interface ToastItem {
- id: number;
- kind: ToastKind;
- text: string;
- /** Leaving: plays the exit animation first, removed from the list once it finishes. */
- leaving?: boolean;
-}
-
-/** Display duration: an error and an advisory both need reading, so they get the longest stay; info sits in between; a plain success is gone as soon as it is seen. */
-const DURATION: Record<ToastKind, number> = {
- success: 2500,
- info: 4000,
- attention: 6000,
- error: 6000,
-};
-
-const toastStore = createStore<{ items: ToastItem[] }>(() => ({ items: [] }));
-let nextId = 1;
-
-/** Exit animation duration (matches toast-out in styles.css). */
-const LEAVE_MS = 160;
-
-function dismiss(id: number): void {
- const item = toastStore.getState().items.find((i) => i.id === id);
- if (!item || item.leaving) return;
- // Mark as leaving first (triggering the exit animation), then actually remove it once the animation ends — otherwise the toast would just vanish abruptly.
- toastStore.setState((s) => ({
- items: s.items.map((i) => (i.id === id ? { ...i, leaving: true } : i)),
- }));
- setTimeout(() => {
- toastStore.setState((s) => ({ items: s.items.filter((i) => i.id !== id) }));
- }, LEAVE_MS);
-}
-
-function push(kind: ToastKind, text: string): void {
- if (!text) return;
- const id = nextId++;
- toastStore.setState((s) => ({ items: [...s.items, { id, kind, text }] }));
- setTimeout(() => dismiss(id), DURATION[kind]);
-}
-
-export const toastSuccess = (text: string): void => push("success", text);
-export const toastError = (text: string): void => push("error", text);
-export const toastInfo = (text: string): void => push("info", text);
-export const toastAttention = (text: string): void => push("attention", text);
-
-const KIND_CLASS: Record<ToastKind, string> = {
- success:
- "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-200",
- error:
- "border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",
- info: "border-sky-200 bg-sky-50 text-sky-800 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-200",
- attention:
- "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",
-};
-
-/** A toast's kind in the `ui-notice` hook's vocabulary, so a theme can style it like any notice. */
-const KIND_TONE: Record<ToastKind, "success" | "danger" | "info" | "warning"> = {
- success: "success",
- error: "danger",
- info: "info",
- attention: "warning",
-};
-
-/** Toast container: mount once at the app root. */
-export function Toaster() {
- const list = useStore(toastStore, (s) => s.items);
- if (list.length === 0) return null;
- return createPortal(
- <div className="pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4">
- {list.map((t) => (
- <button
- key={t.id}
- type="button"
- onClick={() => dismiss(t.id)}
- data-tone={KIND_TONE[t.kind]}
- className={`ui-notice pointer-events-auto max-w-lg break-words rounded-md border px-3 py-2 text-left text-sm shadow-lg ${t.leaving ? "anim-toast-out" : "anim-toast-in"} ${KIND_CLASS[t.kind]}`}
- >
- <span data-slot="body">{t.text}</span>
- </button>
- ))}
- </div>,
- document.body,
- );
-}
diff --git a/packages/web/src/components/ui/todo-notice.tsx b/packages/web/src/components/ui/todo-notice.tsx
index 552f7cff..6796d6f5 100644
--- a/packages/web/src/components/ui/todo-notice.tsx
+++ b/packages/web/src/components/ui/todo-notice.tsx
@@ -13,10 +13,10 @@
* `<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 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
+ * `attention` is the tone by its own definition — "unfinished: waiting on time, a queue, or the
+ * user" is exactly what all four trails are — and `NoticeStrip` is the shape by its own, the
+ * 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.
@@ -39,8 +39,7 @@
* 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, ICON_GAP, UPDATE_DOT_INLINE } from "@prismshadow/penguin-ui";
-import { NoticeStrip } from "./notice-strip";
+import { Button, ICON_GAP, NoticeStrip, UPDATE_DOT_INLINE } from "@prismshadow/penguin-ui";
export function TodoNotice({
text,
diff --git a/packages/web/src/components/ui/truncated.tsx b/packages/web/src/components/ui/truncated.tsx
index 63b491ad..8d13faa6 100644
--- a/packages/web/src/components/ui/truncated.tsx
+++ b/packages/web/src/components/ui/truncated.tsx
@@ -17,7 +17,7 @@
* `title-scroll-reveal` keyframes) driven by the two custom properties set here:
* this component only measures and publishes numbers. There are no timers, and
* the reduced-motion query is one app-wide subscription shared by every row
- * (use-reduced-motion.ts), not one per row.
+ * (the UI package's usePrefersReducedMotion), not one per row.
*
* Which of the two discloses the tail is `titleDisclosure` (title-reveal.ts), and
* they are alternatives: the tooltip covers the text the scroll cannot reach —
@@ -34,9 +34,8 @@
*/
import { useLayoutEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
+import { Tooltip, usePrefersReducedMotion } from "@prismshadow/penguin-ui";
import { revealDistancePx, revealDurationMs, titleDisclosure } from "../../lib/title-reveal";
-import { Tooltip } from "./tooltip";
-import { usePrefersReducedMotion } from "./use-reduced-motion";
export function Truncated({
text,
diff --git a/packages/web/src/components/ui/use-reduced-motion.ts b/packages/web/src/components/ui/use-reduced-motion.ts
deleted file mode 100644
index 514c2292..00000000
--- a/packages/web/src/components/ui/use-reduced-motion.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Whether the reader asked their system to reduce motion, as live state.
- *
- * `styles.css` already disables the app's CSS animations under that preference, so this hook is
- * for what CSS cannot reach on its own: motion driven frame by frame in JS, and the one
- * disclosure that has to know whether the keyframes are running at all (truncated.tsx, #570).
- * Its callers replace the animation with the resting state it would have ended on — the sheet
- * snaps to its target, the dock launcher's ball jumps home and its fan opens and folds without
- * one.
- *
- * One query and one listener for the whole app rather than one per component: `Truncated` reads
- * this from every truncating row, and per-row media-query subscriptions are exactly what the
- * scroll reveal was built to avoid (#309). Reading through `useSyncExternalStore` also closes
- * the window a useState/useEffect pair leaves open, in which a change landing between the first
- * render and the effect is never seen. The window guard keeps the module importable outside a
- * browser, since the query is opened at import time.
- */
-import { useSyncExternalStore } from "react";
-
-const QUERY = "(prefers-reduced-motion: reduce)";
-
-const query =
- typeof window !== "undefined" && typeof window.matchMedia === "function"
- ? window.matchMedia(QUERY)
- : null;
-
-const listeners = new Set<() => void>();
-
-query?.addEventListener("change", () => {
- for (const notify of listeners) notify();
-});
-
-function subscribe(onStoreChange: () => void): () => void {
- listeners.add(onStoreChange);
- return () => {
- listeners.delete(onStoreChange);
- };
-}
-
-function prefersReducedMotion(): boolean {
- return query?.matches ?? false;
-}
-
-export function usePrefersReducedMotion(): boolean {
- return useSyncExternalStore(subscribe, prefersReducedMotion, prefersReducedMotion);
-}
diff --git a/packages/web/src/features/admin/admin-users-page.tsx b/packages/web/src/features/admin/admin-users-page.tsx
index ba6e4818..dc7d5a3d 100644
--- a/packages/web/src/features/admin/admin-users-page.tsx
+++ b/packages/web/src/features/admin/admin-users-page.tsx
@@ -7,7 +7,7 @@
*/
import { useCallback, useEffect, useState } from "react";
import type { UserInfo } from "@prismshadow/penguin-server/api";
-import { Badge, Button, Input, PasswordInput } from "@prismshadow/penguin-ui";
+import { Badge, Button, Input, Modal, PasswordInput } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
@@ -15,7 +15,6 @@ import { apiErrorText } from "../../lib/api-error";
import { USERNAME_PATTERN } from "../../lib/semantic-id";
import { formatDateTime } from "../../lib/format";
import { useAuth } from "../../state/auth";
-import { Modal } from "../../components/ui/modal";
export function AdminUsersSection() {
const { user, desktopMode } = useAuth();
diff --git a/packages/web/src/features/agents/agent-settings-page.tsx b/packages/web/src/features/agents/agent-settings-page.tsx
index b9c92cbc..18ce8d4b 100644
--- a/packages/web/src/features/agents/agent-settings-page.tsx
+++ b/packages/web/src/features/agents/agent-settings-page.tsx
@@ -24,6 +24,7 @@ import type {
import type { ToolDefinitionConfig, ToolPermission } from "@prismshadow/penguin-core/interfaces";
import {
Button,
+ ConfirmModal,
CopyButton,
GlyphIcon,
HiddenFileInput,
@@ -36,6 +37,9 @@ import {
Switch,
Textarea,
UpdateDot,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import type { OptionMenuChoice } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
@@ -45,8 +49,7 @@ import { apiErrorText } from "../../lib/api-error";
import { useDocumentTitle } from "../../lib/use-document-title";
import { useProject } from "../../state/project";
import { Tabs } from "../../components/ui/tabs";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
-import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal";
+import { useSaveConfirm } from "./save-confirm";
import { SkillsTab } from "./skills-tab";
import { HooksTab } from "./hooks-tab";
import { MemoryTab } from "./memory-tab";
@@ -611,6 +614,8 @@ function OverviewTab({
onConfirm={() => {
if (conflict !== null) void runImport(conflict, true);
}}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">{S.agent.importConflictBody}</p>
</ConfirmModal>
@@ -626,6 +631,7 @@ function OverviewTab({
onClose={() => setKernelOpen(false)}
onConfirm={() => void runKernelUpdate()}
confirmLabel={S.agent.kernelUpdateAction}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{S.agent.kernelUpdateConfirmBody}
@@ -640,6 +646,7 @@ function OverviewTab({
onClose={() => setResetOpen(false)}
onConfirm={() => void runReset()}
confirmLabel={S.agent.resetConfigAction}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">{S.agent.resetConfigConfirmBody}</p>
</ConfirmModal>
diff --git a/packages/web/src/features/agents/agents-page.tsx b/packages/web/src/features/agents/agents-page.tsx
index 108a2d4e..e859f313 100644
--- a/packages/web/src/features/agents/agents-page.tsx
+++ b/packages/web/src/features/agents/agents-page.tsx
@@ -31,19 +31,24 @@ import {
Badge,
Button,
CloseIcon,
+ ConfirmModal,
EmptyState,
FieldError,
FieldHint,
FieldLabel,
+ FormPicker,
GlyphIcon,
HiddenFileInput,
ICONS,
ICON_SIZE,
Input,
+ Modal,
Skeleton,
SkeletonCard,
Textarea,
UpdatePill,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -57,10 +62,6 @@ import { bulkOutcome, failedList, firstFailure, noticeCounts } from "../../lib/b
import { useAuth } from "../../state/auth";
import { useLocale } from "../../state/locale";
import { agentDisplayName, useProject } from "../../state/project";
-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 { TodoNotice } from "../../components/ui/todo-notice";
import { SemanticIdField } from "../semantic-id/semantic-id-field";
import { STAT_ICONS } from "../../lib/stat-icons";
@@ -1008,6 +1009,7 @@ export function AgentsPage() {
title={S.todo.agentsConfirmTitle(kernelTodo.count)}
tone="primary"
confirmLabel={S.agent.kernelUpdateAction}
+ cancelLabel={S.common.cancel}
busy={kernelRunning}
onClose={() => setKernelConfirmOpen(false)}
onConfirm={() => void runKernelUpdates(kernelTodo.items)}
@@ -1041,6 +1043,8 @@ export function AgentsPage() {
setDeleteError(null);
}}
onConfirm={() => void doDelete()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{deleting ? S.agent.deleteConfirm(deleting.name) : ""}
diff --git a/packages/web/src/features/agents/hooks-tab.tsx b/packages/web/src/features/agents/hooks-tab.tsx
index c5707b9a..3c3cb5e7 100644
--- a/packages/web/src/features/agents/hooks-tab.tsx
+++ b/packages/web/src/features/agents/hooks-tab.tsx
@@ -25,6 +25,7 @@ import type { HookItem } from "@prismshadow/penguin-server/api";
import {
Badge,
Button,
+ ConfirmModal,
CopiedStatus,
CopyCheckGlyph,
DownloadIcon,
@@ -32,9 +33,12 @@ import {
HelpFold,
HiddenFileInput,
ICONS,
+ Modal,
SettingsEmpty,
SkeletonList,
Textarea,
+ toastError,
+ toastSuccess,
useCopied,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
@@ -43,9 +47,6 @@ import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useLocale } from "../../state/locale";
import { agentDisplayName, useProject } from "../../state/project";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Modal } from "../../components/ui/modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { localizedText } from "../chat/skill-use";
import { SkillTile } from "../skills/skill-icon-view";
import { useAiBridge } from "../ai-create";
@@ -406,6 +407,7 @@ export function HooksTab({
open={overwriting !== null}
title={S.hooks.importOverwriteTitle}
confirmLabel={S.hooks.importOverwriteAction}
+ cancelLabel={S.common.cancel}
busy={uploading}
onClose={() => setOverwriting(null)}
onConfirm={() => {
@@ -424,6 +426,8 @@ export function HooksTab({
busy={busy}
onClose={() => setRemoving(null)}
onConfirm={() => void confirmRemove()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{removing !== null ? S.hooks.uninstallConfirmBody(removing, agentName) : ""}
diff --git a/packages/web/src/features/agents/mcp-servers-section.tsx b/packages/web/src/features/agents/mcp-servers-section.tsx
index 2be95490..2aefd92e 100644
--- a/packages/web/src/features/agents/mcp-servers-section.tsx
+++ b/packages/web/src/features/agents/mcp-servers-section.tsx
@@ -20,12 +20,16 @@ import { useState } from "react";
import type { MCPServerConfig } from "@prismshadow/penguin-core/interfaces";
import {
Button,
+ ConfirmModal,
InfoPopover,
Input,
+ Modal,
OptionMenu,
Segmented,
SettingsEmpty,
Textarea,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import type { OptionMenuChoice } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
@@ -33,9 +37,6 @@ import type { McpServerTestResponse } from "@prismshadow/penguin-server/api";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import {
emptyMcpForm,
formToServer,
@@ -588,6 +589,8 @@ export function McpServersSection({
busy={busy}
onClose={() => setDeleting(null)}
onConfirm={() => void confirmDelete()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{deleting !== null ? S.agent.mcpDeleteConfirm(servers[deleting]?.name ?? "") : ""}
diff --git a/packages/web/src/features/agents/memory-tab.tsx b/packages/web/src/features/agents/memory-tab.tsx
index a3ccc68f..174aa6ab 100644
--- a/packages/web/src/features/agents/memory-tab.tsx
+++ b/packages/web/src/features/agents/memory-tab.tsx
@@ -32,23 +32,31 @@ import type {
import {
Button,
Chevron,
+ ConfirmModal,
CopiedStatus,
CopyCheckGlyph,
DownloadIcon,
+ Drawer,
GlyphIcon,
HelpFold,
HiddenFileInput,
ICONS,
IconButton,
InfoPopover,
+ Modal,
+ NoticeStrip,
RadioGroup,
+ Sheet,
SkeletonList,
Textarea,
ToggleRow,
UploadIcon,
buttonClass,
+ toastError,
+ toastSuccess,
useCopied,
} from "@prismshadow/penguin-ui";
+import type { SheetSnap } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
@@ -56,11 +64,7 @@ import { formatRelativeDate } from "../../lib/format";
import { useAuth } from "../../state/auth";
import { useLocale } from "../../state/locale";
import { useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
-import { Drawer } from "../../components/ui/drawer";
-import { Sheet, type SheetSnap } from "../../components/ui/sheet";
-import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
+import { useSaveConfirm } from "./save-confirm";
import { Md } from "../chat/md";
import { useAiBridge } from "../ai-create";
import { buildMemoryAddPrompt, buildMemoryEditPrompt } from "./memory-chat-prompts";
@@ -73,7 +77,6 @@ import {
import type { MemoryImportPlan } from "./memory-transfer";
import { bodyWithoutFrontmatter } from "../../lib/frontmatter";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** Same breakpoint as the chat page's panels: \u22651024px the view opens as a side Drawer, below it as a bottom Sheet. */
const DESKTOP_QUERY = "(min-width: 1024px)";
@@ -946,6 +949,7 @@ export function MemoryTab({
tone="danger"
title={S.memory.importConfirmTitle}
confirmLabel={S.memory.importAction}
+ cancelLabel={S.common.cancel}
busy={importBusy}
onClose={() => setImportPlan(null)}
onConfirm={() => void runImport(true)}
@@ -967,6 +971,7 @@ export function MemoryTab({
tone="danger"
title={S.memory.deleteTitle}
confirmLabel={S.memory.delete}
+ cancelLabel={S.common.cancel}
onClose={() => setRemoving(null)}
onConfirm={() => void confirmRemove()}
>
diff --git a/packages/web/src/features/agents/prompt-injection-controls.tsx b/packages/web/src/features/agents/prompt-injection-controls.tsx
index ddb61497..4be7541d 100644
--- a/packages/web/src/features/agents/prompt-injection-controls.tsx
+++ b/packages/web/src/features/agents/prompt-injection-controls.tsx
@@ -28,14 +28,20 @@ import type {
AgentSkillsConfigDto,
AgentVaultConfigDto,
} from "@prismshadow/penguin-server/api";
-import { Button, InfoPopover, Textarea, ToggleRow } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ InfoPopover,
+ NoticeStrip,
+ Textarea,
+ ToggleRow,
+ toastError,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
-import { useSaveConfirm } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
-import { NoticeStrip } from "../../components/ui/notice-strip";
+import { useSaveConfirm } from "./save-confirm";
export type PromptInjectionFeature = "skills" | "vault" | "schedules" | "hooks";
diff --git a/packages/web/src/features/agents/save-confirm.tsx b/packages/web/src/features/agents/save-confirm.tsx
new file mode 100644
index 00000000..4e8a7c76
--- /dev/null
+++ b/packages/web/src/features/agents/save-confirm.tsx
@@ -0,0 +1,34 @@
+/**
+ * Shared confirm-before-save flow for the agent settings forms: `requestSave(run)` opens a
+ * standard "save these changes?" dialog and Confirm executes `run`. The caller decides beforehand
+ * whether there is anything to save (no changes → an info toast, not a dialog). Render `element`
+ * once per surface.
+ */
+import { useState } from "react";
+import type { ReactNode } from "react";
+import { ConfirmModal } from "@prismshadow/penguin-ui";
+import { S } from "../../lib/strings";
+
+export function useSaveConfirm(): {
+ requestSave: (run: () => void) => void;
+ element: ReactNode;
+} {
+ const [pending, setPending] = useState<(() => void) | null>(null);
+ const element = (
+ <ConfirmModal
+ open={pending !== null}
+ title={S.common.confirmSaveTitle}
+ tone="primary"
+ confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
+ onClose={() => setPending(null)}
+ onConfirm={() => {
+ pending?.();
+ setPending(null);
+ }}
+ >
+ <p className="text-sm text-gray-600 dark:text-gray-300">{S.common.confirmSaveBody}</p>
+ </ConfirmModal>
+ );
+ return { requestSave: (run: () => void) => setPending(() => run), element };
+}
diff --git a/packages/web/src/features/agents/schedules-tab.tsx b/packages/web/src/features/agents/schedules-tab.tsx
index 34605266..10103bfd 100644
--- a/packages/web/src/features/agents/schedules-tab.tsx
+++ b/packages/web/src/features/agents/schedules-tab.tsx
@@ -24,15 +24,22 @@ import type {
SchedulesResponse,
ScheduleStatus,
} from "@prismshadow/penguin-server/api";
-import { Badge, Button, HelpFold, SettingsEmpty, SkeletonList } from "@prismshadow/penguin-ui";
+import {
+ Badge,
+ Button,
+ ConfirmModal,
+ HelpFold,
+ SettingsEmpty,
+ SkeletonList,
+ toastError,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import type { BadgeStyle } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { formatDateTime } from "../../lib/format";
import { useProject } from "../../state/project";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { AiCreateModal, CreateButtons } from "../ai-create";
import { ScheduleFormModal } from "../schedules/schedule-form-modal";
import { ScheduleSuggestions, scheduleExamples } from "../schedules/schedule-suggestions";
@@ -320,6 +327,8 @@ export function SchedulesTab({
busy={busy}
onClose={() => setDeleting(null)}
onConfirm={() => void confirmRemove()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{deleting !== null ? S.schedule.deleteConfirm(deleting) : ""}
diff --git a/packages/web/src/features/agents/skills-tab.tsx b/packages/web/src/features/agents/skills-tab.tsx
index c07c9ede..b2a08260 100644
--- a/packages/web/src/features/agents/skills-tab.tsx
+++ b/packages/web/src/features/agents/skills-tab.tsx
@@ -22,6 +22,7 @@ import type { ChangeEvent } from "react";
import type { SkillMetadataItem } from "@prismshadow/penguin-server/api";
import {
Button,
+ ConfirmModal,
CopiedStatus,
CopyCheckGlyph,
DownloadIcon,
@@ -31,10 +32,13 @@ import {
ICONS,
IconButton,
Input,
+ Modal,
SettingsEmpty,
SkeletonList,
Textarea,
buttonClass,
+ toastError,
+ toastSuccess,
useCopied,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
@@ -43,9 +47,6 @@ import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useLocale } from "../../state/locale";
import { agentDisplayName, useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { SkillTile } from "../skills/skill-icon-view";
import { localizedShortText } from "../chat/skill-use";
import { useAiBridge } from "../ai-create";
@@ -392,6 +393,7 @@ export function SkillsTab({
open={overwriting !== null}
title={S.skills.importOverwriteTitle}
confirmLabel={S.skills.importOverwriteAction}
+ cancelLabel={S.common.cancel}
busy={uploading}
onClose={() => setOverwriting(null)}
onConfirm={() => {
@@ -410,6 +412,8 @@ export function SkillsTab({
busy={busy}
onClose={() => setRemoving(null)}
onConfirm={() => void confirmRemove()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{removing !== null ? S.skills.uninstallConfirmBody(removing, agentName) : ""}
diff --git a/packages/web/src/features/agents/vault-tab.tsx b/packages/web/src/features/agents/vault-tab.tsx
index 8dffd319..c1241047 100644
--- a/packages/web/src/features/agents/vault-tab.tsx
+++ b/packages/web/src/features/agents/vault-tab.tsx
@@ -17,22 +17,23 @@ import { useCallback, useEffect, useState } from "react";
import type { VaultEntryInfo, VaultUpdateRequest } from "@prismshadow/penguin-server/api";
import {
Button,
+ ConfirmModal,
HelpFold,
Input,
+ Modal,
+ NoticeStrip,
PasswordInput,
SettingsEmpty,
SkeletonList,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { usePromptInjection } from "./prompt-injection-controls";
import { AiCreateModal, CreateButtons } from "../ai-create";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** Vault key naming rule (consistent with core/server): shell environment variable name. */
const VAULT_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -308,6 +309,7 @@ export function VaultTab({
title={S.vault.overwriteTitle}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => setOverwriting(null)}
onConfirm={() => void addEntry()}
@@ -324,6 +326,8 @@ export function VaultTab({
busy={busy}
onClose={() => setDeleting(null)}
onConfirm={() => void confirmRemove()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{deleting !== null ? S.vault.deleteConfirm(deleting) : ""}
diff --git a/packages/web/src/features/ai-create/ai-create-modal.tsx b/packages/web/src/features/ai-create/ai-create-modal.tsx
index 2142bedc..9e56351c 100644
--- a/packages/web/src/features/ai-create/ai-create-modal.tsx
+++ b/packages/web/src/features/ai-create/ai-create-modal.tsx
@@ -6,9 +6,8 @@
* dialog starts from `initialValue` again.
*/
import { useState } from "react";
-import { Button, GlyphIcon, ICONS } from "@prismshadow/penguin-ui";
+import { Button, GlyphIcon, ICONS, Modal } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Modal } from "../../components/ui/modal";
import { useAiBridge } from "./ai-bridge";
import { AiCreatePanel } from "./ai-create-panel";
import type { AiCreatePanelProps } from "./ai-create-panel";
diff --git a/packages/web/src/features/benchmark/benchmark-detail.tsx b/packages/web/src/features/benchmark/benchmark-detail.tsx
index 77592857..acf506d6 100644
--- a/packages/web/src/features/benchmark/benchmark-detail.tsx
+++ b/packages/web/src/features/benchmark/benchmark-detail.tsx
@@ -18,6 +18,7 @@ import {
GlyphIcon,
ICONS,
ICON_SIZE,
+ Modal,
} from "@prismshadow/penguin-ui";
import type { MergedBenchmark, MergedCase } from "../../lib/benchmark-merge";
import { S } from "../../lib/strings";
@@ -26,7 +27,6 @@ import { formatDateTime, formatMoney, formatScore, humanizeDuration } from "../.
import { toneInk } from "../../lib/tone";
import { useTheme } from "../../state/theme";
import type { Currency } from "../../state/theme";
-import { Modal } from "../../components/ui/modal";
import { NEUTRAL_SERIES } from "../../lib/category-colors";
import { makeRangeGeom, segmentPoints } from "../usage/chart-geom";
import { ChartLine, ChartPoint, ChartSwatch, type ChartPaint } from "../../components/ui/chart";
diff --git a/packages/web/src/features/benchmark/benchmark-page.tsx b/packages/web/src/features/benchmark/benchmark-page.tsx
index 9fe330d3..6f72531d 100644
--- a/packages/web/src/features/benchmark/benchmark-page.tsx
+++ b/packages/web/src/features/benchmark/benchmark-page.tsx
@@ -21,6 +21,7 @@ import {
AgentAvatar,
AvatarStack,
Button,
+ ConfirmModal,
EmptyState,
GlyphIcon,
ICONS,
@@ -30,6 +31,8 @@ import {
Select,
Skeleton,
SkeletonCard,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -43,8 +46,6 @@ import { useSessions } from "../../state/sessions";
import type { MergedBenchmark } from "../../lib/benchmark-merge";
import { nameOnMachine } from "../../lib/workspace-machines";
import { useLocale } from "../../state/locale";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { AiCreateModal, CreateButtons, pickDefaultAgent } from "../ai-create";
import { latestWithDelta, matchesBenchmarkQuery, sparklineSeries } from "./benchmark-metrics";
import { benchmarkCreateExamples, benchmarkCreateTail } from "./benchmark-prompts";
@@ -585,6 +586,7 @@ export function BenchmarkPage() {
onClose={() => setDeleting(null)}
onConfirm={() => void confirmDelete()}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
busy={deleteBusy}
>
<p className="text-sm text-gray-700 dark:text-gray-200">
diff --git a/packages/web/src/features/benchmark/create-benchmark-modal.tsx b/packages/web/src/features/benchmark/create-benchmark-modal.tsx
index c5030027..80edaaff 100644
--- a/packages/web/src/features/benchmark/create-benchmark-modal.tsx
+++ b/packages/web/src/features/benchmark/create-benchmark-modal.tsx
@@ -16,16 +16,16 @@ import {
ICON_SIZE,
InfoPopover,
Input,
+ Modal,
PlusIcon,
Textarea,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { toneInk } from "../../lib/tone";
-import { Modal } from "../../components/ui/modal";
-import { toastSuccess } from "../../components/ui/toast";
import { SemanticIdField } from "../semantic-id/semantic-id-field";
import { ID_PATTERN, caseId, isValidRuns } from "./benchmark-prompts";
@@ -221,7 +221,7 @@ function CreateBenchmarkDialog({ onClose, projectId, onCreated }: CreateBenchmar
<span className="text-xs font-semibold text-gray-600 dark:text-gray-300">
{S.benchmark.caseHeading(i + 1)}
</span>
- <span className="min-w-0 flex-1 truncate font-mono text-[11px] text-gray-400">
+ <span className="min-w-0 flex-1 truncate font-mono text-xs text-gray-400">
{dirName}
</span>
{cases.length > 1 && (
diff --git a/packages/web/src/features/benchmark/evaluation-detail-modal.tsx b/packages/web/src/features/benchmark/evaluation-detail-modal.tsx
index 41e45284..dcddae3c 100644
--- a/packages/web/src/features/benchmark/evaluation-detail-modal.tsx
+++ b/packages/web/src/features/benchmark/evaluation-detail-modal.tsx
@@ -18,11 +18,11 @@ import {
ICONS,
ICON_GAP,
ICON_SIZE,
+ Modal,
} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { formatDateTime, formatMoney, formatScore, humanizeDuration } from "../../lib/format";
import type { Currency } from "../../state/theme";
-import { Modal } from "../../components/ui/modal";
import { AskAiModal } from "./ask-ai-modal";
import { evaluationLabel } from "./benchmark-metrics";
import { askEvaluationExamples, askEvaluationTail } from "./benchmark-prompts";
@@ -82,7 +82,7 @@ function CaseRow({
</span>
)}
{title && title !== c.case && (
- <span className="block font-mono text-[11px] text-gray-400">{c.case}</span>
+ <span className="block font-mono text-xs text-gray-400">{c.case}</span>
)}
</span>
</span>
@@ -123,7 +123,7 @@ function CaseRow({
function Metric({ label, value, strong }: { label: string; value: string; strong?: boolean }) {
return (
<span className="min-w-0">
- <span className="block text-[11px] text-gray-500 dark:text-gray-400">{label}</span>
+ <span className="block text-xs text-gray-500 dark:text-gray-400">{label}</span>
<span
className={`block font-mono text-xs tabular-nums ${strong ? "font-semibold" : "text-gray-600 dark:text-gray-300"}`}
>
diff --git a/packages/web/src/features/benchmark/use-benchmark-modal.tsx b/packages/web/src/features/benchmark/use-benchmark-modal.tsx
index 036cce23..0651ffdc 100644
--- a/packages/web/src/features/benchmark/use-benchmark-modal.tsx
+++ b/packages/web/src/features/benchmark/use-benchmark-modal.tsx
@@ -31,6 +31,8 @@ import {
GlyphIcon,
ICONS,
Input,
+ Modal,
+ NoticeStrip,
Segmented,
Select,
Textarea,
@@ -39,13 +41,11 @@ import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { formatScore } from "../../lib/format";
import { agentDisplayName, useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
import { PromptFold, composeAiPrompt, pickDefaultAgent, useAiBridge } from "../ai-create";
import { ModelSelect } from "../chat/model-select";
import { defaultTargetScore, latestScoreOfAgent } from "./benchmark-metrics";
import { MAX_RUNS, evaluateTail, optimizeTail } from "./benchmark-prompts";
import type { EvaluateParams, OptimizeParams } from "./benchmark-prompts";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** The Skill the evaluator agent must carry; the dialog warns when the chosen agent lacks it. */
const EVALUATION_SKILL = "agent-evaluation";
diff --git a/packages/web/src/features/builtin-browser/browser-actions.ts b/packages/web/src/features/builtin-browser/browser-actions.ts
index 74455811..918d1cdd 100644
--- a/packages/web/src/features/builtin-browser/browser-actions.ts
+++ b/packages/web/src/features/builtin-browser/browser-actions.ts
@@ -3,11 +3,11 @@
* makes it feel immediate. Components call these; none of them throws.
*/
import type { BuiltinBrowserTab } from "@prismshadow/penguin-server/api";
+import { toastError } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
-import { toastError } from "../../components/ui/toast";
import { openPanel } from "../dock/dock-state";
import { dispatchBrowser } from "./browser-store";
import type { BrowserGuest } from "./browser-state";
diff --git a/packages/web/src/features/builtin-browser/browser-layer.tsx b/packages/web/src/features/builtin-browser/browser-layer.tsx
index ac76d9d6..58e756ce 100644
--- a/packages/web/src/features/builtin-browser/browser-layer.tsx
+++ b/packages/web/src/features/builtin-browser/browser-layer.tsx
@@ -38,7 +38,7 @@ import {
} from "react";
import type { CSSProperties } from "react";
import type { BuiltinBrowserLoadWarning } from "@prismshadow/penguin-server/api";
-import { toastAttention } from "../../components/ui/toast";
+import { toastAttention } from "@prismshadow/penguin-ui";
import { toneInk } from "../../lib/tone";
import { currentDockScope, isTabShown, openPanel } from "../dock/dock-state";
import { isBlankUrl } from "./address";
diff --git a/packages/web/src/features/builtin-browser/browser-toolbar.tsx b/packages/web/src/features/builtin-browser/browser-toolbar.tsx
index 2bedbbf5..99bd7cc1 100644
--- a/packages/web/src/features/builtin-browser/browser-toolbar.tsx
+++ b/packages/web/src/features/builtin-browser/browser-toolbar.tsx
@@ -12,12 +12,19 @@
import { useState } from "react";
import type { ReactNode, Ref } from "react";
import type { BuiltinBrowserTab } from "@prismshadow/penguin-server/api";
-import { CloseIcon, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import {
+ CloseIcon,
+ Dropdown,
+ GlyphIcon,
+ ICONS,
+ ICON_SIZE,
+ Menu,
+ MenuItem,
+ MenuSeparator,
+ Tooltip,
+} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { toneInk } from "../../lib/tone";
-import { Dropdown } from "../../components/ui/dropdown";
-import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";
-import { Tooltip } from "../../components/ui/tooltip";
import { AddressBar } from "./address-bar";
import type { BrowserActivity } from "./browser-state";
@@ -177,37 +184,38 @@ export function BrowserToolbar(props: BrowserToolbarProps) {
</ToolButton>
}
>
- <button type="button" className={overflowMenuRowClass} onClick={item(props.onImport)}>
- {overflowMenuGlyph(ICONS.download)}
- {S.builtinBrowser.importAction}
- </button>
- <button type="button" className={overflowMenuRowClass} onClick={item(props.onClearData)}>
- {overflowMenuGlyph(ICONS.trash)}
- {S.builtinBrowser.clearDataAction}
- </button>
- <button type="button" className={overflowMenuRowClass} onClick={item(props.onSetHomepage)}>
- {overflowMenuGlyph(ICONS.house)}
- {S.builtinBrowser.setHomepageAction}
- </button>
- {(props.onOpenExternal !== null || props.hostsPage) && (
- <div className="mx-2 my-1 border-t border-gray-100 dark:border-gray-800" />
- )}
- {props.onOpenExternal !== null && (
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={item(props.onOpenExternal)}
- >
- {overflowMenuGlyph(ICONS.externalLink)}
- {S.builtinBrowser.openExternal}
- </button>
- )}
- {props.hostsPage && (
- <button type="button" className={overflowMenuRowClass} onClick={item(props.onDevTools)}>
- {overflowMenuGlyph(ICONS.angleBrackets)}
- {S.builtinBrowser.devTools}
- </button>
- )}
+ <Menu density="sm">
+ <MenuItem
+ glyph={ICONS.download}
+ label={S.builtinBrowser.importAction}
+ onSelect={item(props.onImport)}
+ />
+ <MenuItem
+ glyph={ICONS.trash}
+ label={S.builtinBrowser.clearDataAction}
+ onSelect={item(props.onClearData)}
+ />
+ <MenuItem
+ glyph={ICONS.house}
+ label={S.builtinBrowser.setHomepageAction}
+ onSelect={item(props.onSetHomepage)}
+ />
+ {(props.onOpenExternal !== null || props.hostsPage) && <MenuSeparator />}
+ {props.onOpenExternal !== null && (
+ <MenuItem
+ glyph={ICONS.externalLink}
+ label={S.builtinBrowser.openExternal}
+ onSelect={item(props.onOpenExternal)}
+ />
+ )}
+ {props.hostsPage && (
+ <MenuItem
+ glyph={ICONS.angleBrackets}
+ label={S.builtinBrowser.devTools}
+ onSelect={item(props.onDevTools)}
+ />
+ )}
+ </Menu>
</Dropdown>
</div>
);
diff --git a/packages/web/src/features/builtin-browser/clear-data-dialog.tsx b/packages/web/src/features/builtin-browser/clear-data-dialog.tsx
index 1380f11b..dde082e5 100644
--- a/packages/web/src/features/builtin-browser/clear-data-dialog.tsx
+++ b/packages/web/src/features/builtin-browser/clear-data-dialog.tsx
@@ -4,13 +4,11 @@
* on each opening; the confirm stays disabled while none is.
*/
import { useEffect, useState } from "react";
-import { Checkbox } from "@prismshadow/penguin-ui";
+import { Checkbox, ConfirmModal, toastError, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import type { BuiltinBrowserStorage } from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
type ClearKind = BuiltinBrowserStorage | "history";
@@ -69,6 +67,7 @@ export function ClearDataDialog({ open, onClose }: { open: boolean; onClose: ()
onClose={onClose}
onConfirm={() => void run()}
confirmLabel={S.builtinBrowser.clearConfirm}
+ cancelLabel={S.common.cancel}
confirmDisabled={chosen.size === 0}
busy={busy}
>
diff --git a/packages/web/src/features/builtin-browser/homepage-dialog.tsx b/packages/web/src/features/builtin-browser/homepage-dialog.tsx
index e53ecd9d..c585beeb 100644
--- a/packages/web/src/features/builtin-browser/homepage-dialog.tsx
+++ b/packages/web/src/features/builtin-browser/homepage-dialog.tsx
@@ -9,12 +9,10 @@
* opening starts from the homepage as saved.
*/
import { useState } from "react";
-import { Button, Input } from "@prismshadow/penguin-ui";
+import { Button, Input, Modal, toastError } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
-import { Modal } from "../../components/ui/modal";
-import { toastError } from "../../components/ui/toast";
import { homepageFromInput } from "./address";
import { dispatchBrowser } from "./browser-store";
diff --git a/packages/web/src/features/builtin-browser/import-dialog.tsx b/packages/web/src/features/builtin-browser/import-dialog.tsx
index 59100c12..8f4d7108 100644
--- a/packages/web/src/features/builtin-browser/import-dialog.tsx
+++ b/packages/web/src/features/builtin-browser/import-dialog.tsx
@@ -8,12 +8,11 @@ import type {
BuiltinBrowserImportResult,
BuiltinBrowserImportSource,
} from "@prismshadow/penguin-server/api";
-import { Button, Checkbox, FieldLabel, Input, Radio } from "@prismshadow/penguin-ui";
+import { Button, Checkbox, FieldLabel, Input, Modal, Radio } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
import { toneInk } from "../../lib/tone";
-import { Modal } from "../../components/ui/modal";
import {
groupSources,
importRequest,
diff --git a/packages/web/src/features/chat/chat-input.tsx b/packages/web/src/features/chat/chat-input.tsx
index 4366bd03..54bfe314 100644
--- a/packages/web/src/features/chat/chat-input.tsx
+++ b/packages/web/src/features/chat/chat-input.tsx
@@ -92,30 +92,30 @@ import {
Button,
CheckIcon,
ChevronDown,
- ChoiceCheck,
+ Dropdown,
GlyphIcon,
ICONS,
ICON_GAP,
ICON_SIZE,
+ MenuItem,
+ NoticeStrip,
PickerList,
ProviderLogo,
+ ZoomableImage,
menuPanelClass,
- menuRowClass,
- menuRowTone,
noAutofill,
+ toastError,
+ toastInfo,
} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { formatBytes, humanizeTokens } from "../../lib/format";
import { useLocale } from "../../state/locale";
import { useAuth } from "../../state/auth";
import { agentDisplayName } from "../../state/project";
-import { Dropdown } from "../../components/ui/dropdown";
import { PermissionSelect } from "./permission-select";
-import { toastError, toastInfo } from "../../components/ui/toast";
import { SkillIcon } from "../skills/skill-icon-view";
import { SkillPickList } from "../skills/skill-pick-list";
import { toggleSkillName } from "../skills/skill-selection";
-import { ZoomableImage } from "../../components/ui/image-zoom";
import { sameModelRef } from "../models/model-grouping";
import { filterAgents, stagedSendRoute } from "./agent-handoff";
import { ModelSelect, modelLabel } from "./model-select";
@@ -142,7 +142,6 @@ import { splitDroppedFiles } from "../../lib/file-drop";
import { splitBySize } from "../../lib/upload-limits";
import type { ComposerReference } from "../../lib/workspace-tree";
import { ReferenceChip } from "./reference-chip";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/**
* Agent candidate panel for the `/agent` switch picker, on the shared PickerList (search, scroll
@@ -291,23 +290,19 @@ function ThinkingLevelSelect({
{S.chat.thinkingLevel}
</div>
{SELECTABLE_THINKING_LEVELS.map((level) => (
- <button
+ <MenuItem
key={level}
- type="button"
- onClick={() => {
+ density="sm"
+ checked={level === value}
+ onSelect={() => {
onChange(level);
setOpen(false);
}}
- className={`flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone(level === value)}`}
- >
- {/* The one surface that annotates: a menu row is where the tier is CHOSEN, so it
- names the wire value the pick will send. The trigger above stays the plain
- name — in zh that is 低/中/高/极高/最高, in en the annotation is a no-op. */}
- <span className="min-w-0 flex-1 truncate">
- {S.chat.thinkingLevelMenuName(S.chat.thinkingLevelNames[level] ?? level, level)}
- </span>
- <ChoiceCheck on={level === value} />
- </button>
+ // The one surface that annotates: a menu row is where the tier is CHOSEN, so it
+ // names the wire value the pick will send. The trigger above stays the plain
+ // name — in zh that is 低/中/高/极高/最高, in en the annotation is a no-op.
+ label={S.chat.thinkingLevelMenuName(S.chat.thinkingLevelNames[level] ?? level, level)}
+ />
))}
{note && (
<div className="max-w-56 border-t border-gray-100 px-3 pb-1 pt-1.5 text-[11px] leading-snug text-gray-400 dark:border-gray-800 dark:text-gray-500">
@@ -507,24 +502,25 @@ function PlusMenu({
}
>
{items.map((item) => (
- <button
+ <MenuItem
key={item.key}
- type="button"
+ density="sm"
aria-pressed={item.active}
disabled={item.disabled}
- onClick={() => {
+ checked={item.active}
+ onSelect={() => {
setOpen(false);
item.onSelect();
}}
- className={`flex items-center gap-2 ${menuRowClass} text-xs disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent dark:disabled:hover:bg-transparent ${menuRowTone(item.active)}`}
- >
- <GlyphIcon d={item.icon} className="shrink-0 text-gray-400 dark:text-gray-500" />
- <span className="shrink-0">{item.label}</span>
- <span className="min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500">
- {item.desc}
- </span>
- <ChoiceCheck on={item.active} />
- </button>
+ glyph={item.icon}
+ // The description runs on after the name, muted, and is what gives way when the
+ // row runs out of room.
+ label={
+ <>
+ {item.label} <span className="text-gray-400 dark:text-gray-500">{item.desc}</span>
+ </>
+ }
+ />
))}
{footer && (
<div className="mt-1 border-t border-gray-100 pt-1 dark:border-gray-800">{footer}</div>
diff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsx
index eeeac1c4..81e67b7e 100644
--- a/packages/web/src/features/chat/chat-page.tsx
+++ b/packages/web/src/features/chat/chat-page.tsx
@@ -35,14 +35,20 @@ import type {
import {
ActivityIcon,
Button,
+ ConfirmModal,
CopyButton,
Dot,
+ Dropdown,
EmptyState,
GlyphIcon,
ICONS,
ICON_GAP,
ICON_SIZE,
+ Modal,
Skeleton,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { switchDeskModel } from "../company/desk-model";
@@ -85,11 +91,7 @@ import { useAuth } from "../../state/auth";
import { useTheme } from "../../state/theme";
import { agentDisplayName, useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import { Truncated } from "../../components/ui/truncated";
-import { Dropdown } from "../../components/ui/dropdown";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { MessageStream } from "./message-stream";
import type { StreamRenderContext } from "./message-stream";
import type { ForkTarget } from "./task-stats-line";
@@ -2571,6 +2573,7 @@ export function ChatPage() {
title={S.chat.thinkingSwitchTitle}
tone="primary"
confirmLabel={S.chat.thinkingSwitchCompactFirst}
+ cancelLabel={S.common.cancel}
confirmDisabled={stream.taskState !== "idle"}
onConfirm={compactThenThinkingSwitch}
secondaryLabel={S.chat.thinkingSwitchConfirm}
diff --git a/packages/web/src/features/chat/context-gauge.tsx b/packages/web/src/features/chat/context-gauge.tsx
index 5a6b2081..b5e9a39d 100644
--- a/packages/web/src/features/chat/context-gauge.tsx
+++ b/packages/web/src/features/chat/context-gauge.tsx
@@ -68,9 +68,8 @@ import { useEffect, useId, useRef, useState } from "react";
import type { RefObject } from "react";
import { createPortal } from "react-dom";
import type { SessionContextResponse } from "@prismshadow/penguin-server/api";
-import { Input, usePortalPanel } from "@prismshadow/penguin-ui";
+import { ConfirmModal, Input, usePortalPanel } from "@prismshadow/penguin-ui";
import { getSessionContext } from "../../api/endpoints";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import {
MIN_COMPACTION_THRESHOLD,
THRESHOLD_STEP,
@@ -811,6 +810,7 @@ function ThresholdDialog({
title={S.chat.contextThresholdTitle}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
confirmDisabled={!valid}
busy={busy}
onClose={onClose}
diff --git a/packages/web/src/features/chat/conversation-outline.tsx b/packages/web/src/features/chat/conversation-outline.tsx
index 0ef4e1cc..27d53978 100644
--- a/packages/web/src/features/chat/conversation-outline.tsx
+++ b/packages/web/src/features/chat/conversation-outline.tsx
@@ -36,9 +36,8 @@
*/
import { useEffect, useRef, useState } from "react";
import type { FocusEvent, MouseEvent, RefObject } from "react";
-import { Dot, GlyphIcon } from "@prismshadow/penguin-ui";
+import { Dot, Dropdown, GlyphIcon } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Dropdown } from "../../components/ui/dropdown";
import type { OutlineEntry } from "./outline-model";
import {
globalTurnNumber,
diff --git a/packages/web/src/features/chat/draft-view.tsx b/packages/web/src/features/chat/draft-view.tsx
index a9ad0995..e9a1df28 100644
--- a/packages/web/src/features/chat/draft-view.tsx
+++ b/packages/web/src/features/chat/draft-view.tsx
@@ -54,12 +54,11 @@ import type {
import {
AgentAvatar,
Chevron,
- ChoiceCheck,
+ Dropdown,
ICONS,
- ICON_GAP,
+ MenuItem,
PenguinLogo,
- menuRowClass,
- menuRowTone,
+ toastError,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -72,8 +71,6 @@ import { useAuth } from "../../state/auth";
import { useLocale } from "../../state/locale";
import { agentDisplayName, useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
-import { Dropdown } from "../../components/ui/dropdown";
-import { toastError } from "../../components/ui/toast";
import { useVersionInfo } from "../../lib/use-version-info";
import { versionBadgeFor } from "../../lib/update-flow";
import { openUpdateModal, useUpdateFlow } from "../../lib/use-update-flow";
@@ -1125,32 +1122,28 @@ function AgentSelect({
{agents.map((a) => {
const active = a.agentId === selected?.agentId;
return (
- <button
+ <MenuItem
key={a.agentId}
- type="button"
+ density="sm"
aria-pressed={active}
- onClick={() => {
+ checked={active}
+ onSelect={() => {
onSelect(a);
setOpen(false);
}}
- className={`flex items-center ${ICON_GAP.menu} ${menuRowClass} ${menuRowTone(active)}`}
- >
- <AgentAvatar
- id={a.agentId}
- name={agentDisplayName(a)}
- size={20}
- className="shrink-0 rounded"
- />
- <span className="min-w-0 flex-1">
- <span className="block truncate text-xs">{agentDisplayName(a)}</span>
- {a.description && (
- <span className="block truncate text-[11px] text-gray-400 dark:text-gray-500">
- {a.description}
- </span>
- )}
- </span>
- <ChoiceCheck on={active} />
- </button>
+ glyph={
+ <AgentAvatar
+ id={a.agentId}
+ name={agentDisplayName(a)}
+ size={20}
+ className="shrink-0 rounded"
+ />
+ }
+ label={agentDisplayName(a)}
+ description={
+ a.description ? <span className="block truncate">{a.description}</span> : undefined
+ }
+ />
);
})}
</div>
diff --git a/packages/web/src/features/chat/memory-changes-card.tsx b/packages/web/src/features/chat/memory-changes-card.tsx
index 8c379d16..a06a056d 100644
--- a/packages/web/src/features/chat/memory-changes-card.tsx
+++ b/packages/web/src/features/chat/memory-changes-card.tsx
@@ -10,13 +10,12 @@
* it does from the panel's list; the whole card hides when nothing survives.
*/
import { useState } from "react";
-import { Chevron, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import { Chevron, GlyphIcon, ICONS, ICON_SIZE, namedHint } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import type { MemoryChangeRow } from "../../lib/omni/memory-changes";
import { memoryRowKey } from "../../lib/omni/memory-changes";
import { PathLabel } from "./message-files-card";
import { scopeGlyph } from "./memory-view";
-import { namedHint } from "../../components/ui/tooltip";
const MAX_VISIBLE = 3;
diff --git a/packages/web/src/features/chat/message-item.tsx b/packages/web/src/features/chat/message-item.tsx
index df3547ab..18d0b4ff 100644
--- a/packages/web/src/features/chat/message-item.tsx
+++ b/packages/web/src/features/chat/message-item.tsx
@@ -5,7 +5,7 @@
* stats lines. Items have a light entrance animation.
*/
import { useEffect, useState } from "react";
-import { CopyButton, GlyphIcon } from "@prismshadow/penguin-ui";
+import { CopyButton, GlyphIcon, ZoomableImage } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { useLocale } from "../../state/locale";
import { formatMessageTime } from "../../lib/format";
@@ -13,7 +13,6 @@ import { STAT_ICONS } from "../../lib/stat-icons";
import { splitAttachments } from "../../lib/attachments";
import type { ChatItem, ReconnectItem } from "../../lib/omni/stream-model";
import { AssistantReplyBody } from "./assistant-reply-body";
-import { ZoomableImage } from "../../components/ui/image-zoom";
import { MessageFilesCard } from "./message-files-card";
import { MemoryChangesCard } from "./memory-changes-card";
import { ThinkingBlock } from "./thinking-block";
diff --git a/packages/web/src/features/chat/model-picker-modal.tsx b/packages/web/src/features/chat/model-picker-modal.tsx
index a0c849bc..6293686d 100644
--- a/packages/web/src/features/chat/model-picker-modal.tsx
+++ b/packages/web/src/features/chat/model-picker-modal.tsx
@@ -38,11 +38,11 @@ import {
GlyphIcon,
ICONS,
ICON_SIZE,
+ Modal,
ProviderLogo,
SearchInput,
} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Modal } from "../../components/ui/modal";
import { hasConfiguredKey, sameModelRef } from "../models/model-grouping";
import { loadModelGroupOrder } from "../models/model-group-order";
import { TAG_SHAPE } from "../models/model-tags";
diff --git a/packages/web/src/features/chat/model-select.tsx b/packages/web/src/features/chat/model-select.tsx
index 941e6baa..b5e154a7 100644
--- a/packages/web/src/features/chat/model-select.tsx
+++ b/packages/web/src/features/chat/model-select.tsx
@@ -6,9 +6,8 @@
*/
import { useState } from "react";
import type { ModelInfo, ModelRefDto } from "@prismshadow/penguin-server/api";
-import { ChevronDown, ICON_SIZE, ProviderLogo } from "@prismshadow/penguin-ui";
+import { ChevronDown, FormPickerTrigger, ICON_SIZE, ProviderLogo } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { FormPickerTrigger } from "../../components/ui/form-picker";
import { sameModelRef } from "../models/model-grouping";
import { modelLabel } from "./model-picker-logic";
import { ModelPickerModal } from "./model-picker-modal";
diff --git a/packages/web/src/features/chat/permission-select.tsx b/packages/web/src/features/chat/permission-select.tsx
index 9a72493c..0e299c4a 100644
--- a/packages/web/src/features/chat/permission-select.tsx
+++ b/packages/web/src/features/chat/permission-select.tsx
@@ -14,11 +14,17 @@
* chat input docked at the bottom of the screen opens upward.
*/
import { useState } from "react";
-import type { ReactNode } from "react";
import type { ApprovalMode, SessionSandbox } from "@prismshadow/penguin-server/api";
-import { ChoiceCheck, GlyphIcon, menuRowClass, menuRowTone } from "@prismshadow/penguin-ui";
+import {
+ Dropdown,
+ GlyphIcon,
+ Menu,
+ MenuItem,
+ MenuLabel,
+ MenuRadioItem,
+ MenuSeparator,
+} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Dropdown } from "../../components/ui/dropdown";
import { toneInk } from "../../lib/tone";
import {
PERMISSION_LEVEL_GLYPH,
@@ -31,15 +37,6 @@ import { SettingsDialog } from "../settings/settings-dialog";
const FS_MODES: SessionSandbox["mode"][] = ["read-only", "workspace-write", "danger-full-access"];
const NETWORK_MODES: SessionSandbox["network"][] = ["open", "local", "none"];
-/** A section's small heading inside the panel. */
-function Heading({ children }: { children: ReactNode }) {
- return (
- <div className="px-3 pt-2 pb-1 text-xs font-medium text-gray-400 dark:text-gray-500">
- {children}
- </div>
- );
-}
-
/**
* One choice row: its text, and a check when it is the current value. An unavailable choice
* stays listed, greyed out, with a short note saying why (`unavailable`).
@@ -57,22 +54,14 @@ function Choice({
}) {
const off = unavailable !== undefined;
return (
- <button
- type="button"
- role="menuitemradio"
- aria-checked={selected}
- aria-disabled={off || undefined}
+ <MenuRadioItem
+ label={label}
+ checked={selected}
disabled={off}
data-tooltip={unavailable}
- onClick={onPick}
- className={`flex items-center gap-2 ${menuRowClass} text-xs ${
- off ? "cursor-not-allowed text-gray-400 dark:text-gray-600" : menuRowTone(selected)
- }`}
- >
- <span className="min-w-0 flex-1 truncate whitespace-nowrap">{label}</span>
- {off && <span className="shrink-0 text-xs">{S.chat.permission.unsupported}</span>}
- <ChoiceCheck on={selected} />
- </button>
+ trailing={off ? S.chat.permission.unsupported : undefined}
+ onSelect={onPick}
+ />
);
}
@@ -165,8 +154,8 @@ export function PermissionSelect({
</button>
}
>
- <div role="menu" aria-label={P.label} className="pb-1">
- <Heading>{P.fs}</Heading>
+ <Menu label={P.label} density="sm" className="pb-1">
+ <MenuLabel>{P.fs}</MenuLabel>
{FS_MODES.map((mode) => (
<Choice
key={mode}
@@ -179,7 +168,7 @@ export function PermissionSelect({
}
/>
))}
- <Heading>{P.network}</Heading>
+ <MenuLabel>{P.network}</MenuLabel>
{NETWORK_MODES.map((network) => (
<Choice
key={network}
@@ -196,7 +185,7 @@ export function PermissionSelect({
}
/>
))}
- <Heading>{P.approval}</Heading>
+ <MenuLabel>{P.approval}</MenuLabel>
{approvalModes.map((mode) => (
<Choice
key={mode}
@@ -211,23 +200,19 @@ export function PermissionSelect({
))}
{isAdmin && (
<>
- <div className="my-1 border-t border-gray-100 dark:border-gray-800" />
+ <MenuSeparator />
{/* More…: the rest of the sandbox (masked paths, the temp directory, the backend)
is on the Settings page's Sandbox card, where this opens. */}
- <button
- type="button"
- role="menuitem"
- onClick={() => {
+ <MenuItem
+ label={P.more}
+ onSelect={() => {
setOpen(false);
setSettingsOpen(true);
}}
- className={`flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone()}`}
- >
- <span className="min-w-0 flex-1 truncate whitespace-nowrap">{P.more}</span>
- </button>
+ />
</>
)}
- </div>
+ </Menu>
</Dropdown>
{isAdmin && (
<SettingsDialog
diff --git a/packages/web/src/features/chat/shortcuts-folder.tsx b/packages/web/src/features/chat/shortcuts-folder.tsx
index 2cb36dc2..2763df7f 100644
--- a/packages/web/src/features/chat/shortcuts-folder.tsx
+++ b/packages/web/src/features/chat/shortcuts-folder.tsx
@@ -21,19 +21,19 @@
import { useCallback, useEffect, useRef, useState } from "react";
import {
Button,
+ ConfirmModal,
GlyphIcon,
ICONS,
ICON_SIZE,
Input,
+ Modal,
PlusIcon,
Textarea,
+ toastError,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Modal } from "../../components/ui/modal";
-import { toastError } from "../../components/ui/toast";
import { ExampleFolderRow, exampleRowClass } from "./example-folder-row";
import {
SHORTCUT_MAX_COUNT,
@@ -278,6 +278,7 @@ export function ShortcutsFolder({
open={deleting !== null}
title={S.chat.shortcuts.deleteTitle}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
onClose={() => setDeleting(null)}
onConfirm={() => {
if (deleting !== null) persist(removeShortcut(shortcuts, deleting.id));
diff --git a/packages/web/src/features/chat/stream-selection-menu.tsx b/packages/web/src/features/chat/stream-selection-menu.tsx
index bcb03bdd..4d806b68 100644
--- a/packages/web/src/features/chat/stream-selection-menu.tsx
+++ b/packages/web/src/features/chat/stream-selection-menu.tsx
@@ -9,8 +9,8 @@
*
* It is the Files panel preview's selection menu applied to the conversation, and it borrows
* that menu's parts instead of copying them: `useRowContextMenu` for the anchored open state
- * and its dismissal, the `Dropdown` in `anchorRect` mode for the panel, the overflow-menu row
- * styling, and `restoreSelection` for the highlight. It is also what gives the desktop app a
+ * and its dismissal, the `Dropdown` in `anchorRect` mode for the panel, the small Menu rows,
+ * and `restoreSelection` for the highlight. It is also what gives the desktop app a
* copy menu for conversation text, and a menu for its links, since Electron raises no context
* menu of its own.
*
@@ -28,12 +28,21 @@ import type {
PointerEvent as ReactPointerEvent,
ReactNode,
} from "react";
-import { ICONS } from "@prismshadow/penguin-ui";
+import {
+ Dropdown,
+ ICONS,
+ Menu,
+ MenuItem,
+ MenuSeparator,
+ contextMenuAnchor,
+ isContextMenuKey,
+ toastSuccess,
+ useRowContextMenu,
+} from "@prismshadow/penguin-ui";
+import type { AnchorRect, ContextMenuEventLike } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { STAT_ICONS } from "../../lib/stat-icons";
import { isDesktopShellWindow } from "../../lib/account-menu";
-import { contextMenuAnchor, isContextMenuKey } from "../../lib/context-menu";
-import type { AnchorRect, ContextMenuEventLike } from "../../lib/context-menu";
import {
SELECTION_MENU_ITEMS,
excerptReference,
@@ -45,12 +54,8 @@ import {
} from "../../lib/selection-menu";
import type { ComposerReference } from "../../lib/workspace-tree";
import { useAuth } from "../../state/auth";
-import { useRowContextMenu } from "../../components/ui/context-menu";
import { writeClipboard } from "../../lib/clipboard";
-import { Dropdown } from "../../components/ui/dropdown";
-import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";
import { restoreSelection } from "../../components/ui/text-selection";
-import { toastSuccess } from "../../components/ui/toast";
import { openLinkInBrowser } from "../builtin-browser/browser-actions";
import { isBrowserOffered, subscribeBrowser } from "../builtin-browser/browser-store";
@@ -87,31 +92,25 @@ export function SelectionMenuRows({
<>
{SELECTION_MENU_ITEMS.map((item) =>
item === "copy" ? (
- <button
+ <MenuItem
key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
+ glyph={STAT_ICONS.copy}
+ label={S.common.copy}
+ onSelect={() => {
void writeClipboard(selection.text).then((ok) => ok && toastSuccess(S.common.copied));
onDone(selection);
}}
- >
- {overflowMenuGlyph(STAT_ICONS.copy)}
- {S.common.copy}
- </button>
+ />
) : (
- <button
+ <MenuItem
key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
+ glyph={ICONS.messagePlus}
+ label={S.files.addToChat}
+ onSelect={() => {
onAddExcerpt(excerptReference(selection.text));
onDone(selection);
}}
- >
- {overflowMenuGlyph(ICONS.messagePlus)}
- {S.files.addToChat}
- </button>
+ />
),
)}
</>
@@ -150,41 +149,32 @@ export function LinkMenuRows({
switch (item) {
case "openInBuiltinBrowser":
return (
- <button
+ <MenuItem
key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={run(() => openLinkInBrowser(href))}
- >
- {overflowMenuGlyph(ICONS.globe)}
- {S.chat.linkMenu.openInBuiltinBrowser}
- </button>
+ glyph={ICONS.globe}
+ label={S.chat.linkMenu.openInBuiltinBrowser}
+ onSelect={run(() => openLinkInBrowser(href))}
+ />
);
case "openExternal":
return (
- <button
+ <MenuItem
key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={run(() => window.open(href, "_blank", "noopener,noreferrer"))}
- >
- {overflowMenuGlyph(ICONS.externalLink)}
- {desktopShell ? S.chat.linkMenu.openExternal : S.chat.linkMenu.openInNewTab}
- </button>
+ glyph={ICONS.externalLink}
+ label={desktopShell ? S.chat.linkMenu.openExternal : S.chat.linkMenu.openInNewTab}
+ onSelect={run(() => window.open(href, "_blank", "noopener,noreferrer"))}
+ />
);
case "copyLink":
return (
- <button
+ <MenuItem
key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={run(() => {
+ glyph={ICONS.chainLink}
+ label={S.chat.linkMenu.copyLink}
+ onSelect={run(() => {
void writeClipboard(href).then((ok) => ok && toastSuccess(S.common.copied));
})}
- >
- {overflowMenuGlyph(ICONS.chainLink)}
- {S.chat.linkMenu.copyLink}
- </button>
+ />
);
}
})}
@@ -370,13 +360,11 @@ export function useStreamSelectionMenu(
button={null}
>
{captured !== null && (
- <>
+ <Menu density="sm">
{captured.linkHref !== null && (
<StreamLinkRows href={captured.linkHref} onDone={() => done(captured.selection)} />
)}
- {captured.linkHref !== null && captured.selection !== null && (
- <div className="mx-2 my-1 border-t border-gray-100 dark:border-gray-800" />
- )}
+ {captured.linkHref !== null && captured.selection !== null && <MenuSeparator />}
{captured.selection !== null && (
<SelectionMenuRows
selection={captured.selection}
@@ -384,7 +372,7 @@ export function useStreamSelectionMenu(
onDone={done}
/>
)}
- </>
+ </Menu>
)}
</Dropdown>
);
diff --git a/packages/web/src/features/chat/subagents-view.tsx b/packages/web/src/features/chat/subagents-view.tsx
index 93289f69..45551ef3 100644
--- a/packages/web/src/features/chat/subagents-view.tsx
+++ b/packages/web/src/features/chat/subagents-view.tsx
@@ -33,10 +33,16 @@ import type {
SubagentRuntimeInfo,
TaskInputPart,
} from "@prismshadow/penguin-server/api";
-import { AgentAvatar, EmptyState, GlyphIcon, ICON_SIZE, StatusIcon } from "@prismshadow/penguin-ui";
+import {
+ AgentAvatar,
+ EmptyState,
+ GlyphIcon,
+ ICON_SIZE,
+ StatusIcon,
+ toastError,
+} from "@prismshadow/penguin-ui";
import { ApiError } from "../../api/client";
import { abortSubagent, getAgentSkills, messageSubagent, patchSession } from "../../api/endpoints";
-import { toastError } from "../../components/ui/toast";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
import type { NestedSessionMeta, StreamModel } from "../../lib/omni/stream-model";
diff --git a/packages/web/src/features/chat/task-stats-line.tsx b/packages/web/src/features/chat/task-stats-line.tsx
index f12e8bfb..3c574187 100644
--- a/packages/web/src/features/chat/task-stats-line.tsx
+++ b/packages/web/src/features/chat/task-stats-line.tsx
@@ -28,7 +28,7 @@
*/
import { useState } from "react";
import type { TracePosition } from "@prismshadow/penguin-server/api";
-import { CopyButton, GlyphIcon, Spinner } from "@prismshadow/penguin-ui";
+import { ConfirmModal, CopyButton, GlyphIcon, Spinner } from "@prismshadow/penguin-ui";
import { formatTaskStats } from "../../lib/omni/task-stats";
import type { TaskStats } from "../../lib/omni/task-stats";
import {
@@ -40,7 +40,6 @@ import {
} from "../../lib/format";
import { STAT_ICONS } from "../../lib/stat-icons";
import { S } from "../../lib/strings";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import { useTheme } from "../../state/theme";
import { useLocale } from "../../state/locale";
@@ -225,6 +224,7 @@ export function TaskStatsLine({
title={S.chat.forkSession}
tone="primary"
confirmLabel={S.chat.forkSessionConfirmAction}
+ cancelLabel={S.common.cancel}
busy={forking}
onClose={() => setConfirmingFork(false)}
onConfirm={() => {
diff --git a/packages/web/src/features/chat/tool-call-card.tsx b/packages/web/src/features/chat/tool-call-card.tsx
index f4f35248..7c6da4d9 100644
--- a/packages/web/src/features/chat/tool-call-card.tsx
+++ b/packages/web/src/features/chat/tool-call-card.tsx
@@ -16,7 +16,7 @@
*/
import { useMemo, useRef, useState } from "react";
import { DETACHED_TOOL_NOTE_PREFIX } from "@prismshadow/penguin-core/interfaces";
-import { Chevron, StatusIcon } from "@prismshadow/penguin-ui";
+import { Chevron, StatusIcon, ZoomableImage } from "@prismshadow/penguin-ui";
import type { RunState } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { humanizeDuration } from "../../lib/format";
@@ -31,7 +31,6 @@ import {
DISCLOSURE_ROW_STICKY_CLASS,
activityState,
} from "./disclosure-row";
-import { ZoomableImage } from "../../components/ui/image-zoom";
import { toneInk } from "../../lib/tone";
import { ApprovalButtons } from "./approval-buttons";
import { LiveDuration, useElapsedPast } from "./live-duration";
diff --git a/packages/web/src/features/chat/use-stream-reveal.ts b/packages/web/src/features/chat/use-stream-reveal.ts
index 8865fecc..b78bb03d 100644
--- a/packages/web/src/features/chat/use-stream-reveal.ts
+++ b/packages/web/src/features/chat/use-stream-reveal.ts
@@ -17,7 +17,7 @@
* paced theme paces only what arrives next.
*/
import { useEffect, useRef, useState } from "react";
-import { usePrefersReducedMotion } from "../../components/ui/use-reduced-motion";
+import { usePrefersReducedMotion } from "@prismshadow/penguin-ui";
import { effectiveReveal, useStreamStyle } from "../../lib/stream-style";
import {
receiveText,
diff --git a/packages/web/src/features/chat/workspace-browser.tsx b/packages/web/src/features/chat/workspace-browser.tsx
index 4222136c..9df375f8 100644
--- a/packages/web/src/features/chat/workspace-browser.tsx
+++ b/packages/web/src/features/chat/workspace-browser.tsx
@@ -50,8 +50,10 @@ import ReactMarkdown from "react-markdown";
import {
Button,
CloseIcon,
+ ConfirmModal,
CopiedStatus,
CopyCheckGlyph,
+ Dropdown,
EmptyState,
GlyphIcon,
HiddenFileInput,
@@ -61,8 +63,16 @@ import {
SearchInput,
SkeletonList,
Spinner,
+ Tooltip,
+ ZoomableImage,
+ isContextMenuKey,
+ isLongPressPointer,
noAutofill,
+ toastError,
+ toastInfo,
+ toastSuccess,
useCopied,
+ useRowContextMenu,
} from "@prismshadow/penguin-ui";
import { REHYPE_PLUGINS, REMARK_PLUGINS } from "../../lib/markdown-plugins";
import type { SessionInfo, WorkspaceSearchHit } from "@prismshadow/penguin-server/api";
@@ -116,14 +126,7 @@ import {
writeTreeWidth,
} from "../../lib/workspace-tree";
import type { ComposerReference, EditorState, Listings } from "../../lib/workspace-tree";
-import { isContextMenuKey, isLongPressPointer } from "../../lib/context-menu";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { useRowContextMenu } from "../../components/ui/context-menu";
-import { Dropdown } from "../../components/ui/dropdown";
-import { ZoomableImage } from "../../components/ui/image-zoom";
import { restoreSelection } from "../../components/ui/text-selection";
-import { Tooltip } from "../../components/ui/tooltip";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { STAT_ICONS } from "../../lib/stat-icons";
import { toneInk } from "../../lib/tone";
import { setCloseGuard } from "../dock/close-guard";
@@ -2547,6 +2550,7 @@ export function WorkspaceBrowser({
title={S.files.overwriteTitle}
tone="primary"
confirmLabel={S.files.upload}
+ cancelLabel={S.common.cancel}
onClose={() => setPendingUpload(null)}
onConfirm={() => {
if (pendingUpload) void doUpload(pendingUpload.files, pendingUpload.dir);
@@ -2578,6 +2582,7 @@ export function WorkspaceBrowser({
title={S.files.saveConfirmTitle}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
busy={saving}
onClose={() => setSaveConfirm(false)}
onConfirm={() => void save()}
@@ -2593,6 +2598,7 @@ export function WorkspaceBrowser({
open={renameTarget !== null}
title={S.files.renameTitle}
confirmLabel={S.files.renameConfirm}
+ cancelLabel={S.common.cancel}
confirmDisabled={renameTarget?.version == null || renameDraft.trim() === ""}
busy={fileActionBusy}
tone="primary"
@@ -2614,6 +2620,7 @@ export function WorkspaceBrowser({
open={removeTarget !== null}
title={S.files.deleteTitle}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
confirmDisabled={removeTarget?.version == null}
busy={fileActionBusy}
onClose={() => setRemoveTarget(null)}
@@ -2631,6 +2638,7 @@ export function WorkspaceBrowser({
title={S.files.conflictTitle}
tone="primary"
confirmLabel={S.files.overwriteAnyway}
+ cancelLabel={S.common.cancel}
onClose={() => setConflict(null)}
onConfirm={() => void save({ overwrite: true })}
>
@@ -2644,6 +2652,7 @@ export function WorkspaceBrowser({
open={discardPrompt !== null}
title={S.files.discardTitle}
confirmLabel={S.files.discard}
+ cancelLabel={S.common.cancel}
onClose={() => {
discardPrompt?.resolve(false);
setDiscardPrompt(null);
diff --git a/packages/web/src/features/chat/workspace-file-menu.tsx b/packages/web/src/features/chat/workspace-file-menu.tsx
index d522d192..9934eed1 100644
--- a/packages/web/src/features/chat/workspace-file-menu.tsx
+++ b/packages/web/src/features/chat/workspace-file-menu.tsx
@@ -10,17 +10,12 @@
* same shape the preview header already uses: it is the browser's own save, not a fetch this
* app has to run.
*
- * The rows reuse the session row menu's compact styling (see its module header, which already
- * declares itself shared beyond that row), so every overflow menu in the app reads the same.
+ * The rows are the UI package's Menu rows at the small density, the one every overflow and
+ * context menu in the app uses, so they read the same as the Session row's menu.
*/
-import { ICONS } from "@prismshadow/penguin-ui";
+import { ICONS, Menu, MenuItem } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { STAT_ICONS } from "../../lib/stat-icons";
-import {
- overflowMenuDangerClass,
- overflowMenuGlyph,
- overflowMenuRowClass,
-} from "../../components/ui/session-row-menu";
/** The one Workspace entry a menu is acting on. */
export interface FileMenuTarget {
@@ -66,62 +61,59 @@ export function WorkspaceFileMenuRows({
onClose: () => void;
}) {
return (
- <>
- <button type="button" className={overflowMenuRowClass} onClick={() => onCopyPath(target)}>
- {overflowMenuGlyph(STAT_ICONS.copy)}
- {S.files.copyPath}
- </button>
- <button type="button" className={overflowMenuRowClass} onClick={() => onAddToChat(target)}>
- {overflowMenuGlyph(ICONS.messagePlus)}
- {S.files.addToChat}
- </button>
+ <Menu density="sm">
+ <MenuItem
+ glyph={STAT_ICONS.copy}
+ label={S.files.copyPath}
+ onSelect={() => onCopyPath(target)}
+ />
+ <MenuItem
+ glyph={ICONS.messagePlus}
+ label={S.files.addToChat}
+ onSelect={() => onAddToChat(target)}
+ />
{onAddSelection !== undefined && (
- <button type="button" className={overflowMenuRowClass} onClick={onAddSelection}>
- {overflowMenuGlyph(ICONS.messagePlus)}
- {S.files.addSelectionToChat}
- </button>
+ <MenuItem
+ glyph={ICONS.messagePlus}
+ label={S.files.addSelectionToChat}
+ onSelect={onAddSelection}
+ />
)}
{target.kind === "dir" ? (
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={() => onUploadInto(target.path)}
- >
- {overflowMenuGlyph(ICONS.upload)}
- {S.files.uploadHere}
- </button>
+ <MenuItem
+ glyph={ICONS.upload}
+ label={S.files.uploadHere}
+ onSelect={() => onUploadInto(target.path)}
+ />
) : (
<>
- <a
+ <MenuItem
+ glyph={ICONS.download}
+ label={S.files.download}
href={downloadHref(target.path)}
download={downloadName(target.path)}
- onClick={onClose}
- className={overflowMenuRowClass}
- >
- {overflowMenuGlyph(ICONS.download)}
- {S.files.download}
- </a>
+ onSelect={onClose}
+ />
{/* The two that change the Workspace come last, after everything that only reads it,
and the destructive one is last of all — the furthest row from where the pointer
lands, in the red every other overflow menu gives a delete. */}
{onRename !== undefined && (
- <button type="button" className={overflowMenuRowClass} onClick={() => onRename(target)}>
- {overflowMenuGlyph(ICONS.penLine)}
- {S.files.renameTitle}
- </button>
+ <MenuItem
+ glyph={ICONS.penLine}
+ label={S.files.renameTitle}
+ onSelect={() => onRename(target)}
+ />
)}
{onDelete !== undefined && (
- <button
- type="button"
- className={overflowMenuDangerClass}
- onClick={() => onDelete(target)}
- >
- {overflowMenuGlyph(ICONS.trash)}
- {S.common.delete}
- </button>
+ <MenuItem
+ glyph={ICONS.trash}
+ label={S.common.delete}
+ danger
+ onSelect={() => onDelete(target)}
+ />
)}
</>
)}
- </>
+ </Menu>
);
}
diff --git a/packages/web/src/features/chat/workspace-finder.tsx b/packages/web/src/features/chat/workspace-finder.tsx
index cce7ce85..105b2d54 100644
--- a/packages/web/src/features/chat/workspace-finder.tsx
+++ b/packages/web/src/features/chat/workspace-finder.tsx
@@ -27,30 +27,33 @@ import type { DesktopPrivacyPane, DirListResponse } from "@prismshadow/penguin-s
import {
Button,
CloseIcon,
+ Dropdown,
GlyphIcon,
ICONS,
ICON_GAP,
ICON_SIZE,
+ Menu,
+ MenuItem,
+ Modal,
+ NoticeStrip,
+ isContextMenuKey,
+ isLongPressPointer,
noAutofill,
+ toastError,
+ toastSuccess,
+ useRowContextMenu,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { writeClipboard } from "../../lib/clipboard";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
-import { isContextMenuKey, isLongPressPointer } from "../../lib/context-menu";
import { isElectronRenderer } from "../../lib/desktop-renderer";
import { formatDateTime } from "../../lib/format";
import { STAT_ICONS } from "../../lib/stat-icons";
-import { NoticeStrip } from "../../components/ui/notice-strip";
import { machineLabel, nameOnMachine, workspaceMachines } from "../../lib/workspace-machines";
import type { WorkspaceMachine } from "../../lib/workspace-machines";
import { useSessions } from "../../state/sessions";
-import { Modal } from "../../components/ui/modal";
-import { useRowContextMenu } from "../../components/ui/context-menu";
-import { Dropdown } from "../../components/ui/dropdown";
-import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import {
EMPTY_HISTORY,
TYPE_SELECT_RESET_MS,
@@ -1380,19 +1383,18 @@ export function WorkspaceFinder({
menuClass="w-max min-w-40 max-w-[calc(100vw-2rem)]"
button={null}
>
- {finderMenuItems(menuTarget, inQuickAccess(menuTarget.path, menuTarget.machine)).map(
- (item) => (
- <button
- key={item}
- type="button"
- className={overflowMenuRowClass}
- onClick={() => runMenuItem(item, menuTarget)}
- >
- {overflowMenuGlyph(MENU_ICON[item])}
- {menuLabel(item, menuTarget)}
- </button>
- ),
- )}
+ <Menu density="sm">
+ {finderMenuItems(menuTarget, inQuickAccess(menuTarget.path, menuTarget.machine)).map(
+ (item) => (
+ <MenuItem
+ key={item}
+ glyph={MENU_ICON[item]}
+ label={menuLabel(item, menuTarget)}
+ onSelect={() => runMenuItem(item, menuTarget)}
+ />
+ ),
+ )}
+ </Menu>
</Dropdown>
)}
</Modal>
diff --git a/packages/web/src/features/chat/workspace-select.tsx b/packages/web/src/features/chat/workspace-select.tsx
index 3e3189b1..804ca469 100644
--- a/packages/web/src/features/chat/workspace-select.tsx
+++ b/packages/web/src/features/chat/workspace-select.tsx
@@ -12,9 +12,8 @@
*/
import { useState } from "react";
import type { ReactNode } from "react";
-import { Chevron, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import { Chevron, FormPickerTrigger, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { FormPickerTrigger } from "../../components/ui/form-picker";
import { WorkspaceFinder } from "./workspace-finder";
import { baseName } from "./workspace-finder-model";
diff --git a/packages/web/src/features/company/calendar-page.tsx b/packages/web/src/features/company/calendar-page.tsx
index fdbe7404..74f14e88 100644
--- a/packages/web/src/features/company/calendar-page.tsx
+++ b/packages/web/src/features/company/calendar-page.tsx
@@ -29,16 +29,22 @@ import type {
import {
Button,
CloseIcon,
+ ConfirmModal,
GlyphIcon,
ICONS,
ICON_GAP,
ICON_SIZE,
Input,
+ Modal,
+ NoticeStrip,
Segmented,
Select,
Skeleton,
Switch,
Textarea,
+ toastAttention,
+ toastError,
+ toastSuccess,
usePortalPanel,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
@@ -51,9 +57,6 @@ import { toneInk } from "../../lib/tone";
import type { Tone } from "../../lib/tone";
import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastAttention, toastError, toastSuccess } from "../../components/ui/toast";
import { OrgPage, useOrg } from "./org-layout";
import {
cadenceOf,
@@ -72,7 +75,6 @@ import {
} from "./calendar-geom";
import type { Cadence, CalendarView, EventInstance, GridDay } from "./calendar-geom";
import { dismissHint, hintKey, isHintDismissed } from "./page-hints";
-import { NoticeStrip } from "../../components/ui/notice-strip";
const OUTCOME_TONE: Record<OrgCalendarOutcome, Tone> = {
fired: "success",
@@ -812,7 +814,7 @@ export function CalendarPage() {
{events !== null && events.length === 0 && invalidFiles.length === 0 && !hintDismissed && (
<NoticeStrip
- tone="muted"
+ tone="neutral"
className="mb-3 flex items-center gap-2 rounded-md border px-3 py-2 text-xs"
>
<span className="min-w-0 flex-1">{S.company.calendar.emptyHint}</span>
@@ -1016,6 +1018,7 @@ export function CalendarPage() {
title={S.common.confirmSaveTitle}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setConfirmSave(false))}
onConfirm={() => void save()}
@@ -1028,6 +1031,7 @@ export function CalendarPage() {
open={deleting !== null}
title={S.company.calendar.delete}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setDeleting(null))}
onConfirm={() => void remove()}
diff --git a/packages/web/src/features/company/channel-composer.tsx b/packages/web/src/features/company/channel-composer.tsx
index 50b02a07..fbbbd3c6 100644
--- a/packages/web/src/features/company/channel-composer.tsx
+++ b/packages/web/src/features/company/channel-composer.tsx
@@ -43,9 +43,8 @@ import type {
DragEvent as ReactDragEvent,
KeyboardEvent as ReactKeyboardEvent,
} from "react";
-import { Button, ICON_GAP, noAutofill } from "@prismshadow/penguin-ui";
+import { Button, Dropdown, ICON_GAP, noAutofill } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Dropdown } from "../../components/ui/dropdown";
import { PrincipalChip } from "./shared";
import {
mentionInsertId,
diff --git a/packages/web/src/features/company/channel-dialogs.tsx b/packages/web/src/features/company/channel-dialogs.tsx
index 1caeb9bd..0f5085cb 100644
--- a/packages/web/src/features/company/channel-dialogs.tsx
+++ b/packages/web/src/features/company/channel-dialogs.tsx
@@ -11,13 +11,11 @@
*/
import { useEffect, useState } from "react";
import type { OrgChannelItem } from "@prismshadow/penguin-server/api";
-import { Button, Input, Textarea } from "@prismshadow/penguin-ui";
+import { Button, ConfirmModal, Input, Modal, Textarea } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Modal } from "../../components/ui/modal";
import { channelIdProblem } from "./channel-list";
import type { ChannelIdProblem } from "./channel-list";
import { SemanticIdField } from "../semantic-id/semantic-id-field";
@@ -285,6 +283,7 @@ export function JoinChannelConfirm({
title={S.company.channels.joinTitle}
tone="primary"
confirmLabel={S.company.channels.join}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={onClose}
onConfirm={onConfirm}
diff --git a/packages/web/src/features/company/channel-header.tsx b/packages/web/src/features/company/channel-header.tsx
index fb181f5b..7642edf2 100644
--- a/packages/web/src/features/company/channel-header.tsx
+++ b/packages/web/src/features/company/channel-header.tsx
@@ -21,17 +21,21 @@ import {
AgentAvatar,
AvatarStack,
Button,
+ ConfirmModal,
+ Dropdown,
GlyphIcon,
ICONS,
ICON_GAP,
ICON_SIZE,
InfoPopover,
Input,
+ Menu,
+ MenuItem,
UserAvatar,
menuPanelClass,
- menuRowClass,
- menuRowTone,
noAutofill,
+ toastError,
+ toastSuccess,
usePortalPanel,
} from "@prismshadow/penguin-ui";
import type { AvatarStackItem } from "@prismshadow/penguin-ui";
@@ -39,10 +43,6 @@ import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Dropdown } from "../../components/ui/dropdown";
-import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { Truncated } from "../../components/ui/truncated";
import { ChannelTextDialog } from "./channel-dialogs";
import { channelGlyph } from "./channel-sidebar";
@@ -226,28 +226,24 @@ function InvitePicker({
</p>
) : (
candidates.map((c) => (
- <button
+ <MenuItem
key={c.principal}
- type="button"
+ density="sm"
disabled={busy}
- onClick={() => {
+ onSelect={() => {
setOpen(false);
onQuery("");
onPick(c);
}}
- className={`flex items-center justify-between gap-3 ${menuRowClass} text-xs disabled:opacity-60 ${menuRowTone()}`}
- >
- <span className={`flex min-w-0 items-center ${ICON_GAP.row}`}>
+ glyph={
<MemberAvatar
member={{ principal: c.principal, name: c.name, kind: c.kind }}
size={ICON_SIZE.rowLead}
/>
- <span className="min-w-0 truncate">{c.name}</span>
- </span>
- <span className="shrink-0 text-[11px] text-gray-400 dark:text-gray-500">
- {c.detail ?? (c.kind === "user" ? S.company.channels.members : "")}
- </span>
- </button>
+ }
+ label={c.name}
+ trailing={c.detail ?? (c.kind === "user" ? S.company.channels.members : "")}
+ />
))
)}
</div>
@@ -466,60 +462,50 @@ export function ChannelHeader({
</button>
}
>
- {!detail.archived && (
- <>
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
- setMenuOpen(false);
- setRenameOpen(true);
- }}
- >
- {overflowMenuGlyph(ICONS.pencil)}
- {S.company.channels.rename}
- </button>
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
- setMenuOpen(false);
- setPurposeOpen(true);
- }}
- >
- {overflowMenuGlyph(PURPOSE_ICON)}
- {S.company.channels.editPurpose}
- </button>
- </>
- )}
- {/* Archiving is a people-only action, and the Web App's caller is always a
- person — an employee reaches channels through the CLI. */}
- {!allHands &&
- (detail.archived ? (
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
- setMenuOpen(false);
- void setArchived(false);
- }}
- >
- {overflowMenuGlyph(ICONS.archiveRestore)}
- {S.company.channels.unarchive}
- </button>
- ) : (
- <button
- type="button"
- className={overflowMenuRowClass}
- onClick={() => {
- setMenuOpen(false);
- setArchiveOpen(true);
- }}
- >
- {overflowMenuGlyph(ICONS.archive)}
- {S.company.channels.archive}
- </button>
- ))}
+ <Menu density="sm">
+ {!detail.archived && (
+ <>
+ <MenuItem
+ glyph={ICONS.pencil}
+ label={S.company.channels.rename}
+ onSelect={() => {
+ setMenuOpen(false);
+ setRenameOpen(true);
+ }}
+ />
+ <MenuItem
+ glyph={PURPOSE_ICON}
+ label={S.company.channels.editPurpose}
+ onSelect={() => {
+ setMenuOpen(false);
+ setPurposeOpen(true);
+ }}
+ />
+ </>
+ )}
+ {/* Archiving is a people-only action, and the Web App's caller is always a
+ person — an employee reaches channels through the CLI. */}
+ {!allHands &&
+ (detail.archived ? (
+ <MenuItem
+ glyph={ICONS.archiveRestore}
+ label={S.company.channels.unarchive}
+ onSelect={() => {
+ setMenuOpen(false);
+ void setArchived(false);
+ }}
+ />
+ ) : (
+ <MenuItem
+ glyph={ICONS.archive}
+ label={S.company.channels.archive}
+ onSelect={() => {
+ setMenuOpen(false);
+ setArchiveOpen(true);
+ }}
+ />
+ ))}
+ </Menu>
{/* The all-hands channel simply has no archive row; one short line says why it is
missing. What that channel IS belongs to the header's "?", and repeating the
whole paragraph here made a menu out of an explanation. */}
@@ -555,6 +541,7 @@ export function ChannelHeader({
open={leaveOpen}
title={S.company.channels.leaveTitle}
confirmLabel={S.company.channels.leave}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setLeaveOpen(false))}
onConfirm={() => void leave(me)}
@@ -567,6 +554,7 @@ export function ChannelHeader({
open={archiveOpen}
title={S.company.channels.archiveTitle}
confirmLabel={S.company.channels.archive}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setArchiveOpen(false))}
onConfirm={() => void setArchived(true)}
diff --git a/packages/web/src/features/company/channel-sidebar.tsx b/packages/web/src/features/company/channel-sidebar.tsx
index 9cde3f98..f7529326 100644
--- a/packages/web/src/features/company/channel-sidebar.tsx
+++ b/packages/web/src/features/company/channel-sidebar.tsx
@@ -23,6 +23,8 @@ import {
ICON_SIZE,
PlusIcon,
SkeletonList,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -31,7 +33,6 @@ import { toneInk, toneSurface } from "../../lib/tone";
import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
import { FolderSection, Icon } from "../../components/ui/group-list";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { Truncated } from "../../components/ui/truncated";
import { orgChannelPath } from "./company-nav";
import { JoinChannelConfirm, NewChannelDialog } from "./channel-dialogs";
diff --git a/packages/web/src/features/company/channel-view.tsx b/packages/web/src/features/company/channel-view.tsx
index 32285381..eba216ec 100644
--- a/packages/web/src/features/company/channel-view.tsx
+++ b/packages/web/src/features/company/channel-view.tsx
@@ -49,7 +49,10 @@ import {
GlyphIcon,
ICON_GAP,
ICON_SIZE,
+ NoticeStrip,
Skeleton,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -60,7 +63,6 @@ import { toneDot, toneInk } from "../../lib/tone";
import { useAuth } from "../../state/auth";
import { useCompany, useCompanyEvents } from "../../state/company";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { createStreamFollow, stickToBottom } from "../chat/stream-follow";
import { useOrg } from "./org-layout";
import { principalLabel } from "./shared";
@@ -94,7 +96,6 @@ import {
} from "./channel-stream";
import type { BubbleShape, ChannelDay, StreamItem } from "./channel-stream";
import { parsePrincipal } from "./principals";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** What the first response fixes for this channel: today, the day list, and the read cursor the divider is drawn at. */
interface StreamMeta {
@@ -739,7 +740,7 @@ export function ChannelView() {
<ChannelComposer candidates={candidates} names={names} onSend={send} />
) : detail !== null && detail.archived ? (
<NoticeStrip
- tone="muted"
+ tone="neutral"
as="p"
className="mt-3 rounded-md border px-3 py-2 text-xs"
role="status"
diff --git a/packages/web/src/features/company/chart-card.tsx b/packages/web/src/features/company/chart-card.tsx
index 4f0513fc..a8a39e95 100644
--- a/packages/web/src/features/company/chart-card.tsx
+++ b/packages/web/src/features/company/chart-card.tsx
@@ -36,15 +36,21 @@
import { useEffect } from "react";
import type { ReactNode } from "react";
import type { OrgEmployeeItem, OrgEmployeeState } from "@prismshadow/penguin-server/api";
-import { AgentAvatar, Dot, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import {
+ AgentAvatar,
+ Dot,
+ Dropdown,
+ GlyphIcon,
+ ICONS,
+ ICON_SIZE,
+ useRowContextMenu,
+} from "@prismshadow/penguin-ui";
import type { ToneName } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { useRowContextMenu } from "../../components/ui/context-menu";
import { formatMoney, formatPercent } from "../../lib/format";
import { toneDot, toneInk } from "../../lib/tone";
import type { Tone } from "../../lib/tone";
import type { Currency } from "../../state/theme";
-import { Dropdown } from "../../components/ui/dropdown";
import { budgetTone } from "./finance-tree";
import { INVALID_ICON } from "./shared";
import { CHART_NODE_H, CHART_NODE_W, workspaceTail } from "./org-chart-tree";
diff --git a/packages/web/src/features/company/employee-dialogs.tsx b/packages/web/src/features/company/employee-dialogs.tsx
index d0f6f04a..7afee932 100644
--- a/packages/web/src/features/company/employee-dialogs.tsx
+++ b/packages/web/src/features/company/employee-dialogs.tsx
@@ -13,14 +13,19 @@ import { useEffect, useState } from "react";
import type { OrgEmployeeItem, OrgHireRequest } from "@prismshadow/penguin-server/api";
import {
Button,
+ ConfirmModal,
FieldError,
FieldHint,
FieldLabel,
+ FormPicker,
ICONS,
Input,
+ Modal,
Segmented,
Select,
Textarea,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
@@ -31,10 +36,6 @@ import { formatMoney } from "../../lib/format";
import { useCompany } from "../../state/company";
import { agentDisplayName, useProject } from "../../state/project";
import { useTheme } from "../../state/theme";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { FormPicker } from "../../components/ui/form-picker";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { SkillPickList } from "../skills/skill-pick-list";
import type { PickableItem } from "../skills/skill-pick-list";
import { addSkillNames, removeSkillNames, toggleSkillName } from "../skills/skill-selection";
@@ -377,6 +378,7 @@ export function HireDialog({
title={S.company.chart.hire}
tone="primary"
confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setConfirmOpen(false))}
onConfirm={() => void hire()}
@@ -570,6 +572,7 @@ export function EmployeeEditDialog({
title={title}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setConfirmOpen(false))}
onConfirm={() => void save()}
diff --git a/packages/web/src/features/company/finance-page.tsx b/packages/web/src/features/company/finance-page.tsx
index 4b570455..6284e833 100644
--- a/packages/web/src/features/company/finance-page.tsx
+++ b/packages/web/src/features/company/finance-page.tsx
@@ -45,8 +45,11 @@ import {
ICON_GAP,
ICON_SIZE,
InfoPopover,
+ NoticeStrip,
Segmented,
noAutofill,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -60,7 +63,6 @@ import { useCompany } from "../../state/company";
import { useTheme } from "../../state/theme";
import type { Currency } from "../../state/theme";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { TrendChart } from "../usage/trend-chart";
import { OrgPage, OrgPageSkeleton, useOrg } from "./org-layout";
import {
@@ -91,7 +93,6 @@ import {
} from "./finance-tree";
import type { SpendStateKey } from "./finance-tree";
import { agentPrincipal } from "./principals";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** Percent (lucide percent): the ratio tile's glyph. */
const PERCENT_ICON =
diff --git a/packages/web/src/features/company/handbook-page.tsx b/packages/web/src/features/company/handbook-page.tsx
index 302f7da5..eacc9021 100644
--- a/packages/web/src/features/company/handbook-page.tsx
+++ b/packages/web/src/features/company/handbook-page.tsx
@@ -22,13 +22,17 @@ import type { KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent
import type { OrgHandbookFile, OrgHandbookFileResponse } from "@prismshadow/penguin-server/api";
import {
Button,
+ ConfirmModal,
EmptyState,
GlyphIcon,
ICON_GAP,
ICON_SIZE,
Input,
+ Modal,
Skeleton,
Textarea,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -40,10 +44,7 @@ import { keymap } from "../../lib/shortcuts/store";
import { useShortcutLabel } from "../../lib/shortcuts/use-keymap";
import { useDocumentTitle } from "../../lib/use-document-title";
import { useLocale } from "../../state/locale";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Modal } from "../../components/ui/modal";
import type { TreeToggle } from "../../components/ui/file-tree";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { Md } from "../chat/md";
import { OrgEmptyLine, OrgPage, OrgSection, useOrg } from "./org-layout";
import { ErrorLine } from "./shared";
@@ -447,6 +448,7 @@ export function HandbookPage() {
open={deleteOpen}
title={S.company.handbook.deleteDocument}
confirmLabel={S.common.delete}
+ cancelLabel={S.common.cancel}
busy={deleting}
onClose={() => (deleting ? undefined : setDeleteOpen(false))}
onConfirm={() => void remove()}
diff --git a/packages/web/src/features/company/org-chart-page.tsx b/packages/web/src/features/company/org-chart-page.tsx
index 86cb30e9..a488e3c7 100644
--- a/packages/web/src/features/company/org-chart-page.tsx
+++ b/packages/web/src/features/company/org-chart-page.tsx
@@ -28,7 +28,20 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } fr
import type { KeyboardEvent as ReactKeyboardEvent } from "react";
import { useNavigate } from "react-router";
import type { OrgChartResponse, OrgEmployeeItem } from "@prismshadow/penguin-server/api";
-import { Button, EmptyState, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ ConfirmModal,
+ EmptyState,
+ GlyphIcon,
+ ICONS,
+ ICON_SIZE,
+ Menu,
+ MenuItem,
+ MenuSeparator,
+ NoticeStrip,
+ toastError,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
@@ -37,13 +50,6 @@ import { toneInk } from "../../lib/tone";
import { useCompany } from "../../state/company";
import { useLiveSessionStatuses } from "../../state/sessions";
import { useTheme } from "../../state/theme";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
-import {
- overflowMenuDangerClass,
- overflowMenuGlyph,
- overflowMenuRowClass,
-} from "../../components/ui/session-row-menu";
import { usePointerDrag } from "../dock/use-pointer-drag";
import { OrgPage, OrgPageSkeleton, useOrg } from "./org-layout";
import { orgKey } from "./company-nav";
@@ -65,7 +71,6 @@ import type { CanvasSize, CanvasView } from "./canvas-view";
import { ChartCard, ChartLegend } from "./chart-card";
import { DeskRenewDialog, EmployeeEditDialog, HireDialog } from "./employee-dialogs";
import type { EmployeeEdit } from "./employee-dialogs";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** Node-menu glyphs (24x24 line paths): the open door of a desk session, a plus person for hiring, a coin for budget, an arrow for the line, a refresh for a fresh desk, a door out for leaving. */
const MENU_ICONS = {
@@ -358,33 +363,25 @@ export function OrgChartPage() {
danger = false,
disabled = false,
) => (
- <button
- type="button"
- className={danger ? overflowMenuDangerClass : overflowMenuRowClass}
+ <MenuItem
+ glyph={icon}
+ label={label}
+ danger={danger}
disabled={disabled}
- onClick={() => {
+ onSelect={() => {
close();
onClick();
}}
- >
- {danger ? (
- <span className="shrink-0">
- <GlyphIcon d={icon} size={ICON_SIZE.inlineGlyph} />
- </span>
- ) : (
- overflowMenuGlyph(icon)
- )}
- {label}
- </button>
+ />
);
/* Opening the desk sits first and apart: it is where the reader goes, while everything
below it rewrites the chart file. `close` is the card's own panel dismissal — the card
owns the menu, since only it sees the gesture that opened one. */
const nodeMenu = (employee: OrgEmployeeItem, isCeo: boolean, close: () => void) => (
- <>
+ <Menu density="sm">
{menuRow(close, MENU_ICONS.openDesk, S.company.openDesk, () => void openDesk(employee))}
- <div className="my-1 border-t border-gray-100 dark:border-gray-800" />
+ <MenuSeparator />
{menuRow(close, MENU_ICONS.hire, S.company.chart.hire, () => setHireFor(employee))}
{menuRow(close, MENU_ICONS.budget, S.company.chart.setBudget, () =>
setEditFor({ employee, edit: "budget" }),
@@ -394,7 +391,7 @@ export function OrgChartPage() {
setEditFor({ employee, edit: "reportsTo" }),
)}
{menuRow(close, MENU_ICONS.renewDesk, S.company.chart.renewDesk, () => setRenewFor(employee))}
- <div className="my-1 border-t border-gray-100 dark:border-gray-800" />
+ <MenuSeparator />
{isCeo ? (
<span className="block px-2.5 py-1.5 text-xs text-gray-400 dark:text-gray-500">
{S.company.chart.ceoCannotLeave}
@@ -402,7 +399,7 @@ export function OrgChartPage() {
) : (
menuRow(close, MENU_ICONS.leave, S.company.chart.leave, () => setLeaveFor(employee), true)
)}
- </>
+ </Menu>
);
const zoomControl = (
@@ -596,6 +593,7 @@ export function OrgChartPage() {
title={S.company.chart.leave}
tone="danger"
confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setLeaveFor(null))}
onConfirm={() => void runLeave()}
diff --git a/packages/web/src/features/company/org-dialogs.tsx b/packages/web/src/features/company/org-dialogs.tsx
index 9b409d37..32aa7b3b 100644
--- a/packages/web/src/features/company/org-dialogs.tsx
+++ b/packages/web/src/features/company/org-dialogs.tsx
@@ -40,14 +40,18 @@ import type {
} from "@prismshadow/penguin-server/api";
import {
Button,
+ ConfirmModal,
FieldError,
FieldHint,
FieldLabel,
ICON_GAP,
InfoPopover,
Input,
+ Modal,
Select,
Textarea,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
@@ -58,9 +62,6 @@ import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
import { projectDisplayName, useProject } from "../../state/project";
import { useTheme } from "../../state/theme";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { ModelSelect, modelLabel } from "../chat/model-select";
import { WorkspaceSelect } from "../chat/workspace-select";
import { sameModelRef } from "../models/model-grouping";
@@ -841,6 +842,8 @@ export function OrganizationSettingsDialog({
title={S.company.deleteOrg}
busy={busy}
confirmDisabled={typedId.trim() !== orgId}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
onClose={() => setConfirmDelete(false)}
onConfirm={() => void doDelete()}
>
diff --git a/packages/web/src/features/company/org-session-groups.tsx b/packages/web/src/features/company/org-session-groups.tsx
index 9299005d..32238f94 100644
--- a/packages/web/src/features/company/org-session-groups.tsx
+++ b/packages/web/src/features/company/org-session-groups.tsx
@@ -34,10 +34,14 @@ import {
AgentAvatar,
Button,
CloseIcon,
+ Dropdown,
ICONS,
ICON_GAP,
ICON_SIZE,
SkeletonList,
+ toastError,
+ toastSuccess,
+ useRowContextMenu,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -48,9 +52,7 @@ import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
import { useProject } from "../../state/project";
import { useLiveSessionStatuses } from "../../state/sessions";
-import { useRowContextMenu } from "../../components/ui/context-menu";
import { writeClipboard } from "../../lib/clipboard";
-import { Dropdown } from "../../components/ui/dropdown";
import { FolderSection, Icon } from "../../components/ui/group-list";
import {
DESK_ROW_ACTIONS,
@@ -58,7 +60,6 @@ import {
SessionRowMenuRows,
} from "../../components/ui/session-row-menu";
import type { SessionRowAction, SessionRowState } from "../../components/ui/session-row-menu";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { Truncated } from "../../components/ui/truncated";
import { MessagingBindingModal } from "../messaging/messaging-binding-modal";
import { orgKey } from "./company-nav";
diff --git a/packages/web/src/features/company/org-switcher.tsx b/packages/web/src/features/company/org-switcher.tsx
index 956978de..e58668d1 100644
--- a/packages/web/src/features/company/org-switcher.tsx
+++ b/packages/web/src/features/company/org-switcher.tsx
@@ -6,7 +6,7 @@
* Project with a check mark on the open one (picking one opens its overview), then the two
* entries that make and shape one — "New organization" (success makes the new organization
* the shell's current one and lands in its CEO's desk session) and "Organization settings".
- * Same Dropdown, same menu rows as the Project switcher, so the two modes read as one shell.
+ * Same Dropdown, same Menu rows as the Project switcher, so the two modes read as one shell.
*
* Beside it lives what the sidebar shows in place of a channel list while the user has no
* organization at all — the same create dialog, reached from the slot where the list would be.
@@ -16,22 +16,20 @@ import { useNavigate } from "react-router";
import {
Badge,
Button,
- CheckIcon,
ChevronDown,
- GlyphIcon,
+ Dropdown,
ICONS,
ICON_GAP,
- ICON_SIZE,
- PlusIcon,
+ MenuItem,
+ MenuLabel,
+ MenuRadioItem,
+ MenuSeparator,
SkeletonList,
- menuRowClass,
- menuRowTone,
} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { toneSurface } from "../../lib/tone";
import { useCompany } from "../../state/company";
import { projectDisplayName, useProject } from "../../state/project";
-import { Dropdown } from "../../components/ui/dropdown";
import { groupOrganizationsByProject, orgKey, orgPagePath, parseOrgKey } from "./company-nav";
import {
CreateOrganizationDialog,
@@ -40,10 +38,6 @@ import {
} from "./org-dialogs";
import { OrgStatusDot, OrgStatusPill, orgStatusText } from "./shared";
-/** The switcher's rows: the shared menu row, a list of organizations and the actions under it. */
-const menuItemBase = `flex items-center ${ICON_GAP.menu} ${menuRowClass} text-sm`;
-const menuItemClass = `${menuItemBase} ${menuRowTone()}`;
-
export function OrgSwitcher({ onNavigate }: { onNavigate?: () => void }) {
const navigate = useNavigate();
const company = useCompany();
@@ -153,38 +147,35 @@ export function OrgSwitcher({ onNavigate }: { onNavigate?: () => void }) {
>
{groups.map((group) => (
<div key={group.projectId} role="group" aria-label={projectName(group.projectId)}>
- <p className="px-3.5 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500">
- {projectName(group.projectId)}
- </p>
+ <MenuLabel>{projectName(group.projectId)}</MenuLabel>
{group.organizations.map((o) => {
const key = orgKey(o.projectId, o.orgId);
const active = key === currentKey;
return (
- <button
+ <MenuRadioItem
key={key}
- type="button"
data-tooltip={S.company.inProject(projectName(o.projectId), o.name)}
aria-current={active ? "true" : undefined}
- onClick={() => {
+ onSelect={() => {
setOpen(false);
go(orgPagePath(o.projectId, o.orgId, "overview"));
}}
- className={`${menuItemBase} ${menuRowTone(active)}`}
- >
- <OrgStatusDot org={o} />
- <span className="min-w-0 flex-1 truncate">{o.name}</span>
- {o.invalid !== undefined ? (
- <Badge tone="danger">{S.company.orgInvalid}</Badge>
- ) : o.status === "paused" ? (
- <Badge tone="attention">{S.company.orgPaused}</Badge>
- ) : null}
- {active && (
- <span className="shrink-0 text-gray-500 dark:text-gray-400">
- <CheckIcon />
- <span className="sr-only">{S.company.switcherCurrent}</span>
- </span>
- )}
- </button>
+ glyph={<OrgStatusDot org={o} />}
+ label={
+ <>
+ {o.name}
+ {active && <span className="sr-only">{S.company.switcherCurrent}</span>}
+ </>
+ }
+ trailing={
+ o.invalid !== undefined ? (
+ <Badge tone="danger">{S.company.orgInvalid}</Badge>
+ ) : o.status === "paused" ? (
+ <Badge tone="attention">{S.company.orgPaused}</Badge>
+ ) : undefined
+ }
+ checked={active}
+ />
);
})}
</div>
@@ -194,36 +185,25 @@ export function OrgSwitcher({ onNavigate }: { onNavigate?: () => void }) {
{company.orgsLoaded ? S.company.noOrganizations : S.common.loading}
</p>
)}
- <div className="mt-1.5 border-t border-gray-100 pt-1.5 dark:border-gray-800">
- <button
- type="button"
- className={menuItemClass}
- onClick={() => {
+ <MenuSeparator />
+ <MenuItem
+ glyph={ICONS.plus}
+ label={S.company.createOrg}
+ onSelect={() => {
+ setOpen(false);
+ setCreateOpen(true);
+ }}
+ />
+ {settingsTarget !== null && (
+ <MenuItem
+ glyph={ICONS.gear}
+ label={S.company.orgSettings}
+ onSelect={() => {
setOpen(false);
- setCreateOpen(true);
+ setSettingsOpen(true);
}}
- >
- <span className="shrink-0 text-gray-400 dark:text-gray-500">
- <PlusIcon size={ICON_SIZE.rowLead} />
- </span>
- {S.company.createOrg}
- </button>
- {settingsTarget !== null && (
- <button
- type="button"
- className={menuItemClass}
- onClick={() => {
- setOpen(false);
- setSettingsOpen(true);
- }}
- >
- <span className="shrink-0 text-gray-400 dark:text-gray-500">
- <GlyphIcon d={ICONS.gear} size={ICON_SIZE.rowLead} />
- </span>
- {S.company.orgSettings}
- </button>
- )}
- </div>
+ />
+ )}
</Dropdown>
<CreateOrganizationDialog
diff --git a/packages/web/src/features/company/overview-page.tsx b/packages/web/src/features/company/overview-page.tsx
index 6aa01be4..9d36181a 100644
--- a/packages/web/src/features/company/overview-page.tsx
+++ b/packages/web/src/features/company/overview-page.tsx
@@ -39,6 +39,7 @@ import {
ICON_GAP,
ICON_SIZE,
Segmented,
+ toastError,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -52,7 +53,6 @@ import { useLocale } from "../../state/locale";
import { useLiveSessionStatuses } from "../../state/sessions";
import { useTheme } from "../../state/theme";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { toastError } from "../../components/ui/toast";
import { STAT_ICONS } from "../../lib/stat-icons";
import { orgChannelPath, orgKey, orgPagePath } from "./company-nav";
import type { CompanyNavKey } from "./company-nav";
diff --git a/packages/web/src/features/company/shared.tsx b/packages/web/src/features/company/shared.tsx
index c0462a4e..965d3899 100644
--- a/packages/web/src/features/company/shared.tsx
+++ b/packages/web/src/features/company/shared.tsx
@@ -25,6 +25,7 @@ import {
ICON_GAP,
ICON_SIZE,
Input,
+ NoticeStrip,
} from "@prismshadow/penguin-ui";
import type { BadgeStyle, ToneName } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
@@ -37,7 +38,6 @@ import { budgetTone } from "./finance-tree";
import { parsePrincipal } from "./principals";
import { ORG_STATUS_TONE, orgStatusKind } from "./shell-org-status";
import type { OrgStatusKind } from "./shell-org-status";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** Circled exclamation (lucide circle-alert): the mark of an invalid chart entry or ticket file, and of the finance page's alert count. */
export const INVALID_ICON = "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 8v4m0 4h.01";
diff --git a/packages/web/src/features/company/ticket-dialog.tsx b/packages/web/src/features/company/ticket-dialog.tsx
index ab0eb19c..583a97b4 100644
--- a/packages/web/src/features/company/ticket-dialog.tsx
+++ b/packages/web/src/features/company/ticket-dialog.tsx
@@ -40,15 +40,21 @@ import {
Button,
Chevron,
CloseButton,
+ ConfirmModal,
CopyButton,
FieldLabel,
ICON_GAP,
ICON_SIZE,
Input,
+ Modal,
+ NoticeStrip,
Segmented,
Select,
Skeleton,
Textarea,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -59,9 +65,6 @@ import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
import { useProject } from "../../state/project";
import { useTheme } from "../../state/theme";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Modal } from "../../components/ui/modal";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { OrgSection } from "./org-layout";
import { PathMarkdown, PathText } from "./path-capsule";
import {
@@ -83,7 +86,6 @@ import {
} from "./ticket-board";
import { ticketHistoryRows, ticketSummaryCounts } from "./ticket-history";
import { dayKey } from "./calendar-geom";
-import { NoticeStrip } from "../../components/ui/notice-strip";
import { orgKey } from "./company-nav";
import { deskRows } from "./org-sessions";
import { chatPath, openTempSession } from "./temp-session";
@@ -938,6 +940,7 @@ function TicketDialog({
title={S.common.confirmSaveTitle}
tone="primary"
confirmLabel={S.common.save}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setPendingSave(null))}
onConfirm={commitSave}
@@ -951,6 +954,7 @@ function TicketDialog({
title={S.company.tickets.unblock}
tone="primary"
confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
busy={busy}
onClose={() => (busy ? undefined : setConfirmUnblock(false))}
onConfirm={() => {
@@ -1054,6 +1058,7 @@ export function MoveTicketConfirm({
title={S.company.tickets.moveTitle}
tone={move?.to === "rejected" ? "danger" : "primary"}
confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
confirmDisabled={needsReason && reason.trim() === ""}
busy={busy}
onClose={onClose}
diff --git a/packages/web/src/features/company/tickets-page.tsx b/packages/web/src/features/company/tickets-page.tsx
index e8b8b2f1..02d5ab77 100644
--- a/packages/web/src/features/company/tickets-page.tsx
+++ b/packages/web/src/features/company/tickets-page.tsx
@@ -43,12 +43,16 @@ import {
ICONS,
ICON_SIZE,
Input,
+ Modal,
+ NoticeStrip,
SearchInput,
Segmented,
Select,
Skeleton,
Switch,
Textarea,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -57,8 +61,6 @@ import { useDocumentTitle } from "../../lib/use-document-title";
import { toneDot, toneInk } from "../../lib/tone";
import { useAuth } from "../../state/auth";
import { useCompany } from "../../state/company";
-import { Modal } from "../../components/ui/modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { OrgPage, useOrg } from "./org-layout";
import {
BlockedBadge,
@@ -84,7 +86,6 @@ import { MoveTicketConfirm } from "./ticket-dialog";
import { dismissHint, hintKey, isHintDismissed } from "./page-hints";
import { agentPrincipal, splitPrincipalList } from "./principals";
import { dayKey } from "./calendar-geom";
-import { NoticeStrip } from "../../components/ui/notice-strip";
import { TICKET_COLUMN_ATTR, useTicketBoardDrag } from "./ticket-drag";
const PRIORITIES: readonly OrgTicketPriority[] = ["P0", "P1", "P2"];
@@ -379,7 +380,7 @@ export function TicketsPage() {
board.invalidFiles.length === 0 &&
!hintDismissed && (
<NoticeStrip
- tone="muted"
+ tone="neutral"
className="mb-3 flex items-center gap-2 rounded-md border px-3 py-2 text-xs"
>
<span className="min-w-0 flex-1">{S.company.tickets.emptyHint}</span>
diff --git a/packages/web/src/features/dock/dock-launcher-state.ts b/packages/web/src/features/dock/dock-launcher-state.ts
index 4849721f..9e8f1789 100644
--- a/packages/web/src/features/dock/dock-launcher-state.ts
+++ b/packages/web/src/features/dock/dock-launcher-state.ts
@@ -12,7 +12,7 @@
* toolbar and the composer — and its horizontal offset from the resting edge: 0 on the
* edge, negative when pulled into the conversation.
*/
-import { rubberband } from "../../lib/sheet-physics";
+import { rubberband } from "@prismshadow/penguin-ui";
/** localStorage key of the resting position: the ball's centre as a ratio of the body's height. */
export const LAUNCHER_Y_KEY = "penguin.dock.launcherY";
diff --git a/packages/web/src/features/dock/dock-launcher.tsx b/packages/web/src/features/dock/dock-launcher.tsx
index 1154aaae..977914de 100644
--- a/packages/web/src/features/dock/dock-launcher.tsx
+++ b/packages/web/src/features/dock/dock-launcher.tsx
@@ -36,14 +36,21 @@ import type {
KeyboardEvent as ReactKeyboardEvent,
ReactNode,
} from "react";
-import { GlyphIcon, ICONS, ICON_SIZE, scrollMovesAnchor } from "@prismshadow/penguin-ui";
+import {
+ GlyphIcon,
+ ICONS,
+ ICON_SIZE,
+ SPRING_DEFAULT,
+ SPRING_MOMENTUM,
+ createSpringDriver,
+ scrollMovesAnchor,
+ toastInfo,
+ usePrefersReducedMotion,
+} from "@prismshadow/penguin-ui";
+import type { SpringDriver } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { toastInfo } from "../../components/ui/toast";
-import { usePrefersReducedMotion } from "../../components/ui/use-reduced-motion";
import { toneDot, toneInk } from "../../lib/tone";
-import { SPRING_DEFAULT, SPRING_MOMENTUM, createSpringDriver } from "../../lib/spring";
-import type { SpringDriver } from "../../lib/spring";
import { subscribeTerminals, terminalApiSupported } from "../terminal/terminal-list";
import { isBrowserOffered, subscribeBrowser } from "../builtin-browser/browser-store";
import { openTerminalInDock } from "./dock-terminal";
diff --git a/packages/web/src/features/dock/dock-panel.tsx b/packages/web/src/features/dock/dock-panel.tsx
index 4063bed8..6aa17d9e 100644
--- a/packages/web/src/features/dock/dock-panel.tsx
+++ b/packages/web/src/features/dock/dock-panel.tsx
@@ -32,11 +32,19 @@ import {
useSyncExternalStore,
} from "react";
import type { ReactNode } from "react";
-import { CloseIcon, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import {
+ CloseIcon,
+ ConfirmModal,
+ Dropdown,
+ GlyphIcon,
+ ICONS,
+ ICON_SIZE,
+ Menu,
+ MenuItem,
+ MenuSeparator,
+} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Dropdown } from "../../components/ui/dropdown";
import { ChordKbd } from "../../components/ui/chord-kbd";
import { useDisplayedBinding, useShortcutLabel } from "../../lib/shortcuts/use-keymap";
import { useCoarsePointer } from "../../lib/use-coarse-pointer";
@@ -59,7 +67,7 @@ import { isBrowserOffered, subscribeBrowser } from "../builtin-browser/browser-s
import { confirmClose } from "./close-guard";
import { createShellInDock, detachTerminal, openTerminalInDock } from "./dock-terminal";
import { DockDragOverlay, dockDropCandidate } from "./dock-drag";
-import { panelGlyph, panelLabel } from "./panel-meta";
+import { panelGlyph, panelGlyphPath, panelLabel } from "./panel-meta";
import {
DOCK_MIN_HEIGHT_PX,
DOCK_RATIO_MAX,
@@ -608,54 +616,46 @@ export function DockPanel({
</DockButton>
}
>
- {PANEL_KINDS.filter((kind) => kind !== "builtin-browser" || browserOffered).map((kind) => (
- <button
- key={kind}
- type="button"
- data-testid={`dock-add-${kind}`}
- onClick={() => openPanelHere(kind)}
- className="mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"
- >
- <span className="shrink-0 text-gray-500 dark:text-gray-400">{panelGlyph(kind)}</span>
- <span className="min-w-0 truncate">{panelLabel(kind)}</span>
- </button>
- ))}
- {terminalSupported && (
- <>
- <div className="mx-2 my-1 border-t border-gray-100 dark:border-gray-800" />
- <button
- type="button"
- data-testid="dock-add-terminal"
- onClick={() => {
- setAddOpen(false);
- void createShellInDock(merged ? undefined : position);
- }}
- className="mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"
- >
- <span className="shrink-0 text-gray-500 dark:text-gray-400">
- <GlyphIcon d={ICONS.plus} size={ICON_SIZE.iconButton} />
- </span>
- <span className="min-w-0 truncate">{S.terminal.newShell}</span>
- </button>
- {adoptable.map((terminal, index) => (
- <button
- key={terminal.id}
- type="button"
- data-testid="dock-add-shell"
- data-terminal-id={terminal.id}
- onClick={() => {
+ <Menu>
+ {PANEL_KINDS.filter((kind) => kind !== "builtin-browser" || browserOffered).map((kind) => (
+ <MenuItem
+ key={kind}
+ data-testid={`dock-add-${kind}`}
+ glyph={panelGlyphPath(kind)}
+ label={panelLabel(kind)}
+ onSelect={() => openPanelHere(kind)}
+ />
+ ))}
+ {terminalSupported && (
+ <>
+ <MenuSeparator />
+ <MenuItem
+ data-testid="dock-add-terminal"
+ glyph={ICONS.plus}
+ label={S.terminal.newShell}
+ onSelect={() => {
setAddOpen(false);
- addTerminalTab(terminal.id, merged ? undefined : position);
+ void createShellInDock(merged ? undefined : position);
}}
- className="mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"
- >
- <span className="min-w-0 truncate">
- {terminalLabel(terminal, terminal.id, index + 1)}
- </span>
- </button>
- ))}
- </>
- )}
+ />
+ {/* Live shells no conversation holds, on the small rung: they are entries of the
+ row above rather than panels of their own. */}
+ {adoptable.map((terminal, index) => (
+ <MenuItem
+ key={terminal.id}
+ density="sm"
+ data-testid="dock-add-shell"
+ data-terminal-id={terminal.id}
+ label={terminalLabel(terminal, terminal.id, index + 1)}
+ onSelect={() => {
+ setAddOpen(false);
+ addTerminalTab(terminal.id, merged ? undefined : position);
+ }}
+ />
+ ))}
+ </>
+ )}
+ </Menu>
</Dropdown>
);
@@ -858,6 +858,7 @@ export function DockPanel({
onClose={() => setConfirmKill(null)}
onConfirm={killConfirmed}
confirmLabel={S.terminal.killShell}
+ cancelLabel={S.common.cancel}
>
{confirmKill !== null && (
<p className="break-words text-sm text-gray-600 dark:text-gray-300">
diff --git a/packages/web/src/features/dock/dock-terminal.ts b/packages/web/src/features/dock/dock-terminal.ts
index 3333e558..77ca45b5 100644
--- a/packages/web/src/features/dock/dock-terminal.ts
+++ b/packages/web/src/features/dock/dock-terminal.ts
@@ -3,9 +3,9 @@
* global `terminal.toggle` command. Split from dock-state.ts so the store stays pure (unit-testable
* without fetch); this module owns every server round-trip a terminal tab needs.
*/
+import { toastError } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { onCommand } from "../../lib/shortcuts/dispatcher";
-import { toastError } from "../../components/ui/toast";
import {
HttpStatusError,
fetchJson,
diff --git a/packages/web/src/features/dock/panel-meta.tsx b/packages/web/src/features/dock/panel-meta.tsx
index 02c8736b..4674d32d 100644
--- a/packages/web/src/features/dock/panel-meta.tsx
+++ b/packages/web/src/features/dock/panel-meta.tsx
@@ -29,21 +29,26 @@ export function panelLabel(kind: PanelKind): string {
}
}
-export function panelGlyph(kind: PanelKind, size: number = ICON_SIZE.iconButton): ReactNode {
+/** The panel's mark, as the registry path a Menu row draws on its own. */
+export function panelGlyphPath(kind: PanelKind): string {
switch (kind) {
case "agents":
- return <GlyphIcon d={ICONS.robotPair} size={size} />;
+ return ICONS.robotPair;
case "workspace":
- return <GlyphIcon d={ICONS.folder} size={size} />;
+ return ICONS.folder;
case "memory":
- return <GlyphIcon d={ICONS.brain} size={size} />;
+ return ICONS.brain;
case "trace":
- return <GlyphIcon d={NAV_ICONS.traces} size={size} />;
+ return NAV_ICONS.traces;
case "messaging":
- return <GlyphIcon d={ICONS.paperPlane} size={size} />;
+ return ICONS.paperPlane;
case "schedules":
- return <GlyphIcon d={ICONS.alarmClock} size={size} />;
+ return ICONS.alarmClock;
case "builtin-browser":
- return <GlyphIcon d={ICONS.globe} size={size} />;
+ return ICONS.globe;
}
}
+
+export function panelGlyph(kind: PanelKind, size: number = ICON_SIZE.iconButton): ReactNode {
+ return <GlyphIcon d={panelGlyphPath(kind)} size={size} />;
+}
diff --git a/packages/web/src/features/harness/harness-history-overlay.tsx b/packages/web/src/features/harness/harness-history-overlay.tsx
index 0035ee55..f2343038 100644
--- a/packages/web/src/features/harness/harness-history-overlay.tsx
+++ b/packages/web/src/features/harness/harness-history-overlay.tsx
@@ -12,8 +12,7 @@
*/
import { useEffect, useMemo, useRef, useState } from "react";
import { createPortal } from "react-dom";
-import { Badge, CloseIcon, Skeleton } from "@prismshadow/penguin-ui";
-import { useDialogLayer } from "../../components/ui/modal";
+import { Badge, CloseIcon, NoticeStrip, Skeleton, useDialogLayer } from "@prismshadow/penguin-ui";
import type {
HarnessHistoryEntry,
IfaceChange,
@@ -26,7 +25,6 @@ import * as api from "../../api/endpoints";
import { formatDateTime } from "../../lib/format";
import { S } from "../../lib/strings";
import { ModuleTreeView } from "./module-tree-view";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** The last path segment without its extension: `store/platform/1a2b….mjs` → `1a2b…`. */
function shortSha(pointer: string | null): string {
@@ -160,8 +158,8 @@ export function HarnessHistoryOverlay({ open, onClose }: { open: boolean; onClos
}, [open]);
// Escape closes it only while it is the topmost esc-consuming layer (shared with Modal /
- // Dropdown / the palette, see modal.tsx); Tab stays inside the panel, and closing hands
- // focus back to where it was.
+ // Dropdown / the palette, see the UI package's esc-layers); Tab stays inside the panel, and
+ // closing hands focus back to where it was.
const panelRef = useRef<HTMLElement>(null);
const { onKeyDown: onPanelKeyDown } = useDialogLayer(open, panelRef, onClose);
diff --git a/packages/web/src/features/harness/module-tree-view.tsx b/packages/web/src/features/harness/module-tree-view.tsx
index bedd640b..7d17c7e7 100644
--- a/packages/web/src/features/harness/module-tree-view.tsx
+++ b/packages/web/src/features/harness/module-tree-view.tsx
@@ -4,11 +4,10 @@
* Pure rendering over the table — the same data the CI page draws.
*/
import { useEffect, useMemo, useState } from "react";
-import { Badge, Skeleton } from "@prismshadow/penguin-ui";
+import { Badge, NoticeStrip, Skeleton } from "@prismshadow/penguin-ui";
import type { BadgeStyle } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
-import { NoticeStrip } from "../../components/ui/notice-strip";
interface Manifest {
name: string;
diff --git a/packages/web/src/features/machines/machine-picker.tsx b/packages/web/src/features/machines/machine-picker.tsx
index d6e60dcc..dd3c7d73 100644
--- a/packages/web/src/features/machines/machine-picker.tsx
+++ b/packages/web/src/features/machines/machine-picker.tsx
@@ -8,14 +8,7 @@
* in-place panel.
*/
import { useState } from "react";
-import {
- Button,
- ChevronDown,
- ChoiceCheck,
- menuRowClass,
- menuRowTone,
-} from "@prismshadow/penguin-ui";
-import { Dropdown } from "../../components/ui/dropdown";
+import { Button, ChevronDown, Dropdown, MenuItem } from "@prismshadow/penguin-ui";
export interface MachineChoice {
value: string;
@@ -61,17 +54,14 @@ export function MachinePicker({
const selected = choice.value === value;
return (
<li key={choice.value} role="option" aria-selected={selected}>
- <button
- type="button"
- onClick={() => {
+ <MenuItem
+ label={choice.label}
+ checked={selected}
+ onSelect={() => {
setOpen(false);
if (!selected) onChange(choice.value);
}}
- className={`${menuRowClass} flex items-center gap-2 text-sm ${menuRowTone(selected)}`}
- >
- <span className="min-w-0 flex-1 truncate">{choice.label}</span>
- <ChoiceCheck on={selected} />
- </button>
+ />
</li>
);
})}
diff --git a/packages/web/src/features/machines/machines-page.tsx b/packages/web/src/features/machines/machines-page.tsx
index 26b38c8b..ea4b7946 100644
--- a/packages/web/src/features/machines/machines-page.tsx
+++ b/packages/web/src/features/machines/machines-page.tsx
@@ -28,11 +28,14 @@ import type { MachineInfo, MachineJob, MachinesResponse } from "@prismshadow/pen
import {
Button,
ChevronDown,
+ Dropdown,
GlyphIcon,
ICONS,
ICON_SIZE,
+ NoticeStrip,
SearchInput,
Skeleton,
+ toastError,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { useProject } from "../../state/project";
@@ -42,8 +45,6 @@ import { apiErrorText } from "../../lib/api-error";
import { useDocumentTitle } from "../../lib/use-document-title";
import { formatDateTime, formatMessageTime } from "../../lib/format";
import { toneDot, toneInk } from "../../lib/tone";
-import { Dropdown } from "../../components/ui/dropdown";
-import { toastError } from "../../components/ui/toast";
import { NAV_ICONS } from "../../lib/nav-icons";
import {
MACHINE_PHASES,
@@ -61,7 +62,6 @@ import { MAX_VISIBLE_MACHINES, highlightSegments, matchMachines } from "./machin
import { probeDelayMs, probeFingerprint } from "./probe-schedule";
import { SshHostDialog } from "./ssh-host-dialog";
import type { HostFormMode } from "./ssh-host-dialog";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** How often the page re-reads the list while a job is queued or running. */
const POLL_MS = 1500;
diff --git a/packages/web/src/features/machines/ssh-host-dialog.tsx b/packages/web/src/features/machines/ssh-host-dialog.tsx
index ef21da53..ed8230f7 100644
--- a/packages/web/src/features/machines/ssh-host-dialog.tsx
+++ b/packages/web/src/features/machines/ssh-host-dialog.tsx
@@ -16,13 +16,10 @@ import type {
SshHostRequest,
SshHostResponse,
} from "@prismshadow/penguin-server/api";
-import { Button, Input } from "@prismshadow/penguin-ui";
+import { Button, Input, Modal, NoticeStrip, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
-import { Modal } from "../../components/ui/modal";
-import { toastSuccess } from "../../components/ui/toast";
-import { NoticeStrip } from "../../components/ui/notice-strip";
type Field = "alias" | "hostName" | "user" | "port" | "identityFile";
type Form = Record<Field, string>;
diff --git a/packages/web/src/features/messaging/messaging-binding-editor.tsx b/packages/web/src/features/messaging/messaging-binding-editor.tsx
index 1de3c61a..a2beea29 100644
--- a/packages/web/src/features/messaging/messaging-binding-editor.tsx
+++ b/packages/web/src/features/messaging/messaging-binding-editor.tsx
@@ -58,13 +58,15 @@ import {
PasswordInput,
Segmented,
Switch,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { formatDateTime } from "../../lib/format";
import { toneInk, type Tone } from "../../lib/tone";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { QQScanConnect } from "./qq-scan-connect";
import { WeChatScanConnect } from "./wechat-scan-connect";
import {
diff --git a/packages/web/src/features/messaging/messaging-binding-modal.tsx b/packages/web/src/features/messaging/messaging-binding-modal.tsx
index a31b624e..da44c66c 100644
--- a/packages/web/src/features/messaging/messaging-binding-modal.tsx
+++ b/packages/web/src/features/messaging/messaging-binding-modal.tsx
@@ -11,9 +11,8 @@
* clear checkbox.
*/
import type { MessagingChannel } from "@prismshadow/penguin-server/api";
-import { Button } from "@prismshadow/penguin-ui";
+import { Button, Modal } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { Modal } from "../../components/ui/modal";
import {
MessagingBindingBody,
MessagingBindingHelp,
diff --git a/packages/web/src/features/messaging/qq-scan-connect.tsx b/packages/web/src/features/messaging/qq-scan-connect.tsx
index adb7bcde..03069bc8 100644
--- a/packages/web/src/features/messaging/qq-scan-connect.tsx
+++ b/packages/web/src/features/messaging/qq-scan-connect.tsx
@@ -25,11 +25,10 @@ import type {
QQBindingInfo,
QQScanPollResponse,
} from "@prismshadow/penguin-server/api";
-import { Button } from "@prismshadow/penguin-ui";
+import { Button, toastError, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
-import { toastError, toastSuccess } from "../../components/ui/toast";
/** Modules of quiet zone around the code — four is what the QR spec asks for. */
const QUIET_ZONE = 4;
diff --git a/packages/web/src/features/messaging/wechat-scan-connect.tsx b/packages/web/src/features/messaging/wechat-scan-connect.tsx
index 267efcda..431d85a1 100644
--- a/packages/web/src/features/messaging/wechat-scan-connect.tsx
+++ b/packages/web/src/features/messaging/wechat-scan-connect.tsx
@@ -30,11 +30,10 @@ import type {
WeChatBindingInfo,
WeChatScanPollResponse,
} from "@prismshadow/penguin-server/api";
-import { Button, Input } from "@prismshadow/penguin-ui";
+import { Button, Input, toastError, toastInfo, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { QrCode } from "./qq-scan-connect";
/**
diff --git a/packages/web/src/features/models/key-auth-dialog.tsx b/packages/web/src/features/models/key-auth-dialog.tsx
index a61f7684..fa6a745c 100644
--- a/packages/web/src/features/models/key-auth-dialog.tsx
+++ b/packages/web/src/features/models/key-auth-dialog.tsx
@@ -6,11 +6,10 @@ import type {
} from "@prismshadow/penguin-server/api";
import type { KeyAuthEndpoints } from "../../api/endpoints";
import { ApiError } from "../../api/client";
-import { Modal } from "../../components/ui/modal";
import { apiErrorText } from "../../lib/api-error";
import { isElectronRenderer } from "../../lib/desktop-renderer";
import { S } from "../../lib/strings";
-import { Button, Spinner } from "@prismshadow/penguin-ui";
+import { Button, Modal, Spinner } from "@prismshadow/penguin-ui";
const POLL_MS = 3_000;
diff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsx
index 154cdd82..040c64b7 100644
--- a/packages/web/src/features/models/models-page.tsx
+++ b/packages/web/src/features/models/models-page.tsx
@@ -45,6 +45,7 @@ import {
Button,
Checkbox,
Chevron,
+ ConfirmModal,
EmptyState,
FieldError,
FieldLabel,
@@ -54,6 +55,8 @@ import {
InfoPopover,
Input,
Link,
+ Modal,
+ NoticeStrip,
PasswordInput,
ProviderLogo,
Segmented,
@@ -62,6 +65,9 @@ import {
Spinner,
Switch,
buttonClass,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
@@ -72,10 +78,7 @@ import { useProject } from "../../state/project";
import { useAuth } from "../../state/auth";
import { USD_TO_CNY, useTheme } from "../../state/theme";
import type { Currency } from "../../state/theme";
-import { Modal } from "../../components/ui/modal";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import { AiCreateModal, CreateButtons } from "../ai-create";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { formatDateTime, humanizeTokens } from "../../lib/format";
import {
MODEL_PROVIDERS,
@@ -144,7 +147,6 @@ import type { SpeedResult, SpeedTone } from "./speed-test";
import { toneInk } from "../../lib/tone";
import { KeyAuthDialog } from "./key-auth-dialog";
import type { KeyAuthTexts } from "./key-auth-dialog";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/**
* The authorization flows a group's "authorize a key" dialog can run, keyed by the flow named
@@ -1641,6 +1643,8 @@ export function ModelsPage() {
S.models.groupDeleted(removed.length),
);
}}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-700 dark:text-gray-300">
{/* Offered on user-defined groups only, whose display info is always synthesized. */}
@@ -1663,6 +1667,7 @@ export function ModelsPage() {
title={S.todo.modelsConfirmTitle(todo.count)}
tone="primary"
confirmLabel={S.models.syncCatalog}
+ cancelLabel={S.common.cancel}
busy={syncing}
onClose={() => setSyncConfirmOpen(false)}
onConfirm={() => {
@@ -3623,6 +3628,8 @@ function ModelDialog({
setConfirmingFastMode(false);
set({ fastMode: true });
}}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-700 dark:text-gray-300">{S.models.fastModeConfirmBody}</p>
{fastProtocol === "anthropic" && (
@@ -3645,6 +3652,8 @@ function ModelDialog({
setConfirming(null);
void submit(action);
}}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-700 dark:text-gray-300">
{CONFIRM_BODY[confirming](modelLabel)}
diff --git a/packages/web/src/features/models/protocol-suffix.tsx b/packages/web/src/features/models/protocol-suffix.tsx
index 26e94977..257831ef 100644
--- a/packages/web/src/features/models/protocol-suffix.tsx
+++ b/packages/web/src/features/models/protocol-suffix.tsx
@@ -30,19 +30,10 @@
* the call site — so no extra row appears in the happy path.
*/
import { useState } from "react";
-import {
- ChevronDown,
- ChoiceCheck,
- menuRowClass,
- menuRowTone,
- rowDescClass,
- sizeTextClass,
- Spinner,
-} from "@prismshadow/penguin-ui";
-import { Dropdown } from "../../components/ui/dropdown";
+import { ChevronDown, Dropdown, Menu, MenuRadioItem, Spinner } from "@prismshadow/penguin-ui";
// This menu is an OptionMenu by hand (its trigger lives inside the base URL field, which
-// OptionMenu cannot do), so it takes its row typography from OptionMenu's own records rather
-// than re-spelling them — a change to the family reaches it.
+// OptionMenu cannot do), so it takes its rows from the Menu family rather than re-spelling
+// them — a change to the family reaches it.
import { S } from "../../lib/strings";
import { protocolPathForModel } from "./protocol-path";
import { PROTOCOL_CLIENT_TYPES } from "./protocol-types";
@@ -108,38 +99,22 @@ export function ProtocolSuffixMenu({
</button>
}
>
- <div role="menu">
- {PROTOCOL_CLIENT_TYPES.map((t) => {
- const selected = t === value;
- return (
- <button
- key={t}
- type="button"
- role="menuitemradio"
- aria-checked={selected}
- onClick={() => {
- setOpen(false);
- onPick(t);
- }}
- className={`block ${menuRowClass} ${menuRowTone(selected)}`}
- >
- <span className="flex items-center justify-between gap-2">
- <span className={`min-w-0 truncate ${sizeTextClass.sm}`}>
- {S.models.protocolNames[t] ?? t}
- </span>
- <ChoiceCheck on={selected} />
- </span>
- {/* The path this protocol appends: the same string the trigger shows, so the
- menu explains what the suffix in the field means. */}
- <span
- className={`mt-0.5 block font-mono ${rowDescClass.sm} text-gray-500 dark:text-gray-500`}
- >
- {protocolPathForModel("custom", t)}
- </span>
- </button>
- );
- })}
- </div>
+ <Menu density="sm">
+ {PROTOCOL_CLIENT_TYPES.map((t) => (
+ <MenuRadioItem
+ key={t}
+ checked={t === value}
+ onSelect={() => {
+ setOpen(false);
+ onPick(t);
+ }}
+ label={S.models.protocolNames[t] ?? t}
+ // The path this protocol appends: the same string the trigger shows, so the menu
+ // explains what the suffix in the field means.
+ description={<span className="font-mono">{protocolPathForModel("custom", t)}</span>}
+ />
+ ))}
+ </Menu>
</Dropdown>
);
}
diff --git a/packages/web/src/features/palette/command-palette.tsx b/packages/web/src/features/palette/command-palette.tsx
index e9d944df..a5e8ebcb 100644
--- a/packages/web/src/features/palette/command-palette.tsx
+++ b/packages/web/src/features/palette/command-palette.tsx
@@ -5,12 +5,12 @@
* capability registers an action instead of claiming another global shortcut.
*
* Keyboard model: ArrowUp/ArrowDown move the selection (wrapping), Enter runs, Escape
- * closes through the shared esc-layer stack (modal.tsx), and the shortcut that opened it
- * toggles it closed. Filtering is filterPaletteActions (lib/command-palette.ts).
+ * closes through the shared esc-layer stack (the UI package's esc-layers), and the shortcut
+ * that opened it toggles it closed. Filtering is filterPaletteActions (lib/command-palette.ts).
*/
import { useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
-import { useDialogLayer } from "../../components/ui/modal";
+import { useDialogLayer } from "@prismshadow/penguin-ui";
import { filterPaletteActions, type PaletteAction } from "../../lib/command-palette";
import { onCommand } from "../../lib/shortcuts/dispatcher";
import { useShortcutLabel } from "../../lib/shortcuts/use-keymap";
@@ -36,8 +36,8 @@ export function CommandPalette({ actions }: { actions: readonly PaletteAction[]
const toggleShortcut = useShortcutLabel("palette.toggle");
// Escape closes it only while it is the topmost esc-consuming layer (shared with Modal /
- // Dropdown, see modal.tsx), so an action's own dialog above it gets its Escape first; Tab
- // stays inside the panel, and closing hands focus back to where it was.
+ // Dropdown, see the UI package's esc-layers), so an action's own dialog above it gets its
+ // Escape first; Tab stays inside the panel, and closing hands focus back to where it was.
const panelRef = useRef<HTMLDivElement>(null);
const { onKeyDown: onPanelKeyDown } = useDialogLayer(open, panelRef, () => setOpen(false));
diff --git a/packages/web/src/features/plugins/plugin-detail.tsx b/packages/web/src/features/plugins/plugin-detail.tsx
index b6e88802..6e1e3de2 100644
--- a/packages/web/src/features/plugins/plugin-detail.tsx
+++ b/packages/web/src/features/plugins/plugin-detail.tsx
@@ -9,8 +9,7 @@
* on hand at once and nothing here is fetched per directory.
*/
import { useEffect, useState } from "react";
-import { Badge, ICONS } from "@prismshadow/penguin-ui";
-import { Modal } from "../../components/ui/modal";
+import { Badge, ICONS, Modal } from "@prismshadow/penguin-ui";
import { FileBrowser } from "../../components/ui/file-browser";
import type { FileBrowserPreview } from "../../components/ui/file-browser";
import type { TreeToggle } from "../../components/ui/file-tree";
diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsx
index 18dbba1a..03566705 100644
--- a/packages/web/src/features/plugins/plugins-page.tsx
+++ b/packages/web/src/features/plugins/plugins-page.tsx
@@ -52,15 +52,20 @@ import {
AgentAvatar,
Button,
Chevron,
+ ConfirmModal,
GlyphIcon,
ICONS,
ICON_SIZE,
InfoPopover,
+ Modal,
+ NoticeStrip,
SearchInput,
Skeleton,
SkeletonCard,
StatusIcon,
UpdateDot,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
@@ -76,10 +81,7 @@ import { agentDisplayName, useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
import { MachinePicker, type MachineChoice } from "../machines/machine-picker";
import { NAV_ICONS } from "../../lib/nav-icons";
-import { Modal } from "../../components/ui/modal";
import { TodoNotice } from "../../components/ui/todo-notice";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { DRAFT_SESSION_ID } from "../chat/chat-page";
import { draftKey, loadDraft, saveDraft } from "../chat/draft-cache";
import { prepareNewChatDraft } from "../chat/new-chat";
@@ -89,7 +91,6 @@ import { SettingsDialog } from "../settings/settings-dialog";
import { formatRelativeDate } from "../../lib/format";
import { SkillTile } from "../skills/skill-icon-view";
import { toneInk, toneSurface } from "../../lib/tone";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/**
* What one Agent has installed, by name → the installed copy's version (`YYYY.MM.DD.N`, or ""
@@ -796,6 +797,7 @@ export function PluginsPage() {
}
tone="primary"
confirmLabel={pendingApply.install ? S.plugins.install : S.plugins.uninstall}
+ cancelLabel={S.common.cancel}
busy={pendingSpecifier !== null}
onClose={() => setPendingApply(null)}
onConfirm={() => void runDeploymentInstall(pendingApply.specifier, pendingApply.install)}
@@ -813,6 +815,7 @@ export function PluginsPage() {
title={S.todo.pluginsConfirmTitle(pendingBulk.plugins.length)}
tone="primary"
confirmLabel={S.skills.updateAction}
+ cancelLabel={S.common.cancel}
busy={bulkRunning}
onClose={() => setPendingBulk(null)}
onConfirm={() => void runBulkUpdate(pendingBulk)}
@@ -1435,6 +1438,7 @@ function PluginCard({
title={S.plugins.updateConfirmTitle(plugin.name)}
tone="primary"
confirmLabel={S.skills.updateAction}
+ cancelLabel={S.common.cancel}
busy={updating}
onClose={() => setPendingUpdate(null)}
onConfirm={() => void confirmUpdate()}
@@ -1471,6 +1475,7 @@ function PluginCard({
open
title={S.plugins.uninstallConfirmTitle(plugin.name)}
confirmLabel={S.skills.uninstall}
+ cancelLabel={S.common.cancel}
onClose={() => setPendingUninstall(null)}
onConfirm={() => {
const agentId = pendingUninstall;
diff --git a/packages/web/src/features/schedules/schedule-ai-modal.tsx b/packages/web/src/features/schedules/schedule-ai-modal.tsx
index 40465324..40d45b2f 100644
--- a/packages/web/src/features/schedules/schedule-ai-modal.tsx
+++ b/packages/web/src/features/schedules/schedule-ai-modal.tsx
@@ -9,10 +9,9 @@
*/
import { useState } from "react";
import type { AgentSummary } from "@prismshadow/penguin-server/api";
-import { Button, GlyphIcon, ICONS } from "@prismshadow/penguin-ui";
+import { Button, GlyphIcon, ICONS, Modal } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { agentDisplayName } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
import { AiCreatePanel, composeAiPrompt } from "../ai-create";
import { scheduleExamples } from "./schedule-suggestions";
diff --git a/packages/web/src/features/schedules/schedule-form-modal.tsx b/packages/web/src/features/schedules/schedule-form-modal.tsx
index fb8ce3a1..e0d82c9d 100644
--- a/packages/web/src/features/schedules/schedule-form-modal.tsx
+++ b/packages/web/src/features/schedules/schedule-form-modal.tsx
@@ -26,18 +26,19 @@ import {
FieldError,
FieldHint,
FieldLabel,
+ FormPicker,
Input,
+ Modal,
PickerList,
Select,
Textarea,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
-import { Modal } from "../../components/ui/modal";
-import { FormPicker } from "../../components/ui/form-picker";
-import { toastInfo, toastSuccess } from "../../components/ui/toast";
import { ModelSelect } from "../chat/model-select";
import { WorkspaceSelect } from "../chat/workspace-select";
import { sameModelRef } from "../models/model-grouping";
diff --git a/packages/web/src/features/schedules/schedule-panel.tsx b/packages/web/src/features/schedules/schedule-panel.tsx
index 0e24140f..b5687037 100644
--- a/packages/web/src/features/schedules/schedule-panel.tsx
+++ b/packages/web/src/features/schedules/schedule-panel.tsx
@@ -23,14 +23,20 @@ import type {
} from "@prismshadow/penguin-server/api";
import {
Badge,
+ ConfirmModal,
+ Dropdown,
GlyphIcon,
ICONS,
ICON_SIZE,
+ Menu,
+ MenuItem,
SearchInput,
Segmented,
SettingsEmpty,
SkeletonList,
Switch,
+ toastError,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -38,15 +44,6 @@ import { apiErrorText } from "../../lib/api-error";
import { toneInk } from "../../lib/tone";
import { useLocale } from "../../state/locale";
import { useProject } from "../../state/project";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { Dropdown } from "../../components/ui/dropdown";
-import { Icon } from "../../components/ui/group-list";
-import {
- overflowMenuDangerClass,
- overflowMenuGlyph,
- overflowMenuRowClass,
-} from "../../components/ui/session-row-menu";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { CreateButtons } from "../ai-create";
import { describeSchedule } from "./schedule-describe";
import { ScheduleAiModal } from "./schedule-ai-modal";
@@ -92,7 +89,7 @@ function StateGlyph({ item }: { item: ScheduleItem }) {
);
}
-/** A row's overflow menu: edit, and delete in the destructive treatment (the session row menu's rows). */
+/** A row's overflow menu: edit, and delete in the destructive treatment (small Menu rows). */
function RowMenu({ onEdit, onDelete }: { onEdit: () => void; onDelete: () => void }) {
const [open, setOpen] = useState(false);
const item = (fn: () => void) => () => {
@@ -119,17 +116,11 @@ function RowMenu({ onEdit, onDelete }: { onEdit: () => void; onDelete: () => voi
</button>
}
>
- <button type="button" className={overflowMenuRowClass} onClick={item(onEdit)}>
- {overflowMenuGlyph(ICONS.pencil)}
- {S.common.edit}
- </button>
- <button type="button" className={overflowMenuDangerClass} onClick={item(onDelete)}>
+ <Menu density="sm">
+ <MenuItem glyph={ICONS.pencil} label={S.common.edit} onSelect={item(onEdit)} />
{/* The glyph inherits the row's red. */}
- <span className="shrink-0">
- <Icon d={ICONS.trash} size={13} />
- </span>
- {S.common.delete}
- </button>
+ <MenuItem glyph={ICONS.trash} label={S.common.delete} danger onSelect={item(onDelete)} />
+ </Menu>
</Dropdown>
);
}
@@ -359,6 +350,8 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePa
busy={busy}
onClose={() => setDeleting(null)}
onConfirm={() => void confirmRemove()}
+ confirmLabel={S.common.confirm}
+ cancelLabel={S.common.cancel}
>
<p className="text-sm text-gray-600 dark:text-gray-300">
{deleting !== null ? S.schedule.deleteConfirm(deleting.name) : ""}
diff --git a/packages/web/src/features/semantic-id/semantic-id-field.tsx b/packages/web/src/features/semantic-id/semantic-id-field.tsx
index c2654bb8..b7980eff 100644
--- a/packages/web/src/features/semantic-id/semantic-id-field.tsx
+++ b/packages/web/src/features/semantic-id/semantic-id-field.tsx
@@ -35,12 +35,12 @@ import {
GlyphIcon,
ICON_SIZE,
Input,
+ toastError,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { toneInk } from "../../lib/tone";
-import { toastError } from "../../components/ui/toast";
import { idSuggestNotice, proposalValue } from "./id-suggest-notice";
import type { IdSuggestNotice } from "./id-suggest-notice";
diff --git a/packages/web/src/features/settings/company-section.tsx b/packages/web/src/features/settings/company-section.tsx
index 23e82185..efae137b 100644
--- a/packages/web/src/features/settings/company-section.tsx
+++ b/packages/web/src/features/settings/company-section.tsx
@@ -13,13 +13,12 @@
* wherever the switch stands.
*/
import { useEffect, useState } from "react";
-import { SettingsSection, ToggleRow } from "@prismshadow/penguin-ui";
+import { SettingsSection, ToggleRow, toastError } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { toneInk } from "../../lib/tone";
import { useAuth } from "../../state/auth";
-import { toastError } from "../../components/ui/toast";
import { writeCompanyMode } from "./company-mode-write";
export function CompanySection() {
diff --git a/packages/web/src/features/settings/plugins-section.tsx b/packages/web/src/features/settings/plugins-section.tsx
index aa625723..ede49d92 100644
--- a/packages/web/src/features/settings/plugins-section.tsx
+++ b/packages/web/src/features/settings/plugins-section.tsx
@@ -27,21 +27,23 @@ import { S } from "../../lib/strings";
import { useLocale } from "../../state/locale";
import { localizedText } from "../chat/skill-use";
import { apiErrorText } from "../../lib/api-error";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
import { toneInk } from "../../lib/tone";
import { useSessions } from "../../state/sessions";
import { MachinePicker } from "../machines/machine-picker";
-import { NoticeStrip } from "../../components/ui/notice-strip";
import {
Button,
Checkbox,
Input,
+ NoticeStrip,
PasswordInput,
Select,
SettingsSection,
Spinner,
Textarea,
ToggleRow,
+ toastError,
+ toastInfo,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
/** The picker's value for this server; a machine id is never this short. */
diff --git a/packages/web/src/features/settings/profile-section.tsx b/packages/web/src/features/settings/profile-section.tsx
index 20f5c3ea..f5b54f14 100644
--- a/packages/web/src/features/settings/profile-section.tsx
+++ b/packages/web/src/features/settings/profile-section.tsx
@@ -36,6 +36,7 @@ import {
USER_AVATAR_SIZE,
UserAvatar,
buttonClass,
+ toastSuccess,
} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
@@ -43,7 +44,6 @@ import { apiErrorText } from "../../lib/api-error";
import { avatarDataUrlFromFile } from "../../lib/avatar-image";
import { profileControls } from "../../lib/profile-form";
import { useAuth } from "../../state/auth";
-import { toastSuccess } from "../../components/ui/toast";
/** What the picker offers — the three formats the server stores, spelled the way `accept` wants. */
const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp";
diff --git a/packages/web/src/features/settings/proxy-section.tsx b/packages/web/src/features/settings/proxy-section.tsx
index ac85d732..8ad800a3 100644
--- a/packages/web/src/features/settings/proxy-section.tsx
+++ b/packages/web/src/features/settings/proxy-section.tsx
@@ -38,13 +38,20 @@ import type {
ProxyProbeTargetDto,
ServerSettings,
} from "@prismshadow/penguin-server/api";
-import { Button, Input, SettingsSection, ToggleRow } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ Input,
+ SettingsSection,
+ ToggleRow,
+ toastError,
+ toastInfo,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { toneInk } from "../../lib/tone";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
/** Brand names: identical in every locale, so they are keyed off the server's provider id rather than doubled into both dictionaries. */
const PROVIDER_LABEL: Record<ProxyProbeProvider, string> = {
diff --git a/packages/web/src/features/settings/settings-dialog.tsx b/packages/web/src/features/settings/settings-dialog.tsx
index 41dff79d..1c129278 100644
--- a/packages/web/src/features/settings/settings-dialog.tsx
+++ b/packages/web/src/features/settings/settings-dialog.tsx
@@ -8,7 +8,8 @@
* anything not on it falls back to the first page they can actually open.
*/
import { useEffect, useState } from "react";
-import { ICONS } from "@prismshadow/penguin-ui";
+import { ICONS, PagedDialog } from "@prismshadow/penguin-ui";
+import type { PagedDialogGroup } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import {
resolveSettingsSection,
@@ -17,8 +18,6 @@ import {
} from "../../lib/settings-sections";
import type { SettingsGroupKey, SettingsSectionKey } from "../../lib/settings-sections";
import { useAuth } from "../../state/auth";
-import { PagedDialog } from "../../components/ui/paged-dialog";
-import type { PagedDialogGroup } from "../../components/ui/paged-dialog";
import { Icon } from "../../components/ui/group-list";
import { ProfileSection } from "./profile-section";
import { GeneralSection } from "./general-section";
diff --git a/packages/web/src/features/settings/shortcut-runtime.tsx b/packages/web/src/features/settings/shortcut-runtime.tsx
index edb227c1..9a8ac91b 100644
--- a/packages/web/src/features/settings/shortcut-runtime.tsx
+++ b/packages/web/src/features/settings/shortcut-runtime.tsx
@@ -7,9 +7,9 @@
* mirror standing — the next hydrate reconciles.
*/
import { useEffect } from "react";
+import { toastError } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
-import { toastError } from "../../components/ui/toast";
import { hydrateFromServer, setKeybindingsPersister } from "../../lib/shortcuts/store";
import { useAuth } from "../../state/auth";
diff --git a/packages/web/src/features/settings/shortcuts-section.tsx b/packages/web/src/features/settings/shortcuts-section.tsx
index f48aa81b..df1e0b3a 100644
--- a/packages/web/src/features/settings/shortcuts-section.tsx
+++ b/packages/web/src/features/settings/shortcuts-section.tsx
@@ -8,9 +8,14 @@
* tab never receives ⌘W; ⌘P takes over the browser's Print; the desktop menu also carries ⌘R).
*/
import { useState } from "react";
-import { Button, GlyphIcon, ICON_SIZE, SettingsSection } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ ConfirmModal,
+ GlyphIcon,
+ ICON_SIZE,
+ SettingsSection,
+} from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import { conflictsOf, findConflicts, type Conflict } from "../../lib/shortcuts/conflicts";
import { currentHost, currentPlatform } from "../../lib/shortcuts/platform";
import { SHORTCUT_COMMANDS, SHORTCUT_GROUPS, commandById } from "../../lib/shortcuts/registry";
@@ -163,6 +168,7 @@ export function ShortcutsSection() {
setConfirmReset(false);
}}
confirmLabel={S.shortcuts.resetAll}
+ cancelLabel={S.common.cancel}
>
{S.shortcuts.resetAllBody(overriddenCount)}
</ConfirmModal>
diff --git a/packages/web/src/features/settings/trace-import-row.tsx b/packages/web/src/features/settings/trace-import-row.tsx
index 416ffe98..04d39478 100644
--- a/packages/web/src/features/settings/trace-import-row.tsx
+++ b/packages/web/src/features/settings/trace-import-row.tsx
@@ -19,11 +19,17 @@
import { useEffect, useState } from "react";
import type { ChangeEvent } from "react";
import type { AgentSummary, ProjectSummary } from "@prismshadow/penguin-server/api";
-import { HiddenFileInput, PrefRow, Select, UploadIcon } from "@prismshadow/penguin-ui";
+import {
+ HiddenFileInput,
+ PrefRow,
+ Select,
+ UploadIcon,
+ toastError,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { agentDisplayName, projectDisplayName, useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
diff --git a/packages/web/src/features/settings/uploads-section.tsx b/packages/web/src/features/settings/uploads-section.tsx
index 7ca4f037..92e6f88f 100644
--- a/packages/web/src/features/settings/uploads-section.tsx
+++ b/packages/web/src/features/settings/uploads-section.tsx
@@ -14,13 +14,19 @@
*/
import { useEffect, useState } from "react";
import type { ServerSettings } from "@prismshadow/penguin-server/api";
-import { Button, Input, SettingsSection } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ Input,
+ SettingsSection,
+ toastError,
+ toastInfo,
+ toastSuccess,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { useAuth } from "../../state/auth";
-import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";
export function UploadsSection() {
const { uploadLimits, refresh } = useAuth();
diff --git a/packages/web/src/features/skills/skill-pick-list.tsx b/packages/web/src/features/skills/skill-pick-list.tsx
index 8de3dc13..c0621dd1 100644
--- a/packages/web/src/features/skills/skill-pick-list.tsx
+++ b/packages/web/src/features/skills/skill-pick-list.tsx
@@ -18,13 +18,7 @@
*/
import { useState } from "react";
import type { SkillMetadataItem } from "@prismshadow/penguin-server/api";
-import {
- ChoiceCheck,
- ICON_SIZE,
- SearchInput,
- menuRowClass,
- menuRowTone,
-} from "@prismshadow/penguin-ui";
+import { ICON_SIZE, MenuItem, SearchInput } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { useLocale } from "../../state/locale";
import { filterSkills, localizedShortText } from "../chat/skill-use";
@@ -109,27 +103,32 @@ export function SkillPickList({
filtered.map((s) => {
const on = selected.includes(s.name);
return (
- <button
+ <MenuItem
key={s.name}
- type="button"
+ density="sm"
aria-pressed={on}
- onClick={() => onToggle(s.name)}
- className={`flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone(on)}`}
- >
- {/* Each row's icon (icon.svg, sanitized and inlined), else the kind's glyph. */}
- <SkillIcon
- icon={s.icon}
- fallback={s.fallbackIcon}
- size={ICON_SIZE.inlineGlyph}
- className="shrink-0 text-gray-400 dark:text-gray-500"
- />
- <span className="shrink-0 font-mono">{s.name}</span>
- {/* Prefers the short description (falls back to the full description if missing), per the UI language. */}
- <span className="min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500">
- {localizedShortText(locale, s)}
- </span>
- <ChoiceCheck on={on} />
- </button>
+ checked={on}
+ onSelect={() => onToggle(s.name)}
+ // Each row's icon (icon.svg, sanitized and inlined), else the kind's glyph.
+ glyph={
+ <SkillIcon
+ icon={s.icon}
+ fallback={s.fallbackIcon}
+ size={ICON_SIZE.inlineGlyph}
+ className="shrink-0 text-gray-400 dark:text-gray-500"
+ />
+ }
+ // The name, then the short description (falls back to the full description if
+ // missing, per the UI language), muted, which gives way when the row runs out.
+ label={
+ <>
+ <span className="font-mono">{s.name}</span>{" "}
+ <span className="text-gray-400 dark:text-gray-500">
+ {localizedShortText(locale, s)}
+ </span>
+ </>
+ }
+ />
);
})
)}
diff --git a/packages/web/src/features/terminal/terminal-page.tsx b/packages/web/src/features/terminal/terminal-page.tsx
index 65b51ae5..68429f01 100644
--- a/packages/web/src/features/terminal/terminal-page.tsx
+++ b/packages/web/src/features/terminal/terminal-page.tsx
@@ -24,9 +24,8 @@
* status dot, the "+") stay, each naming itself.
*/
import { useCallback, useMemo, useState } from "react";
-import { GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
+import { ConfirmModal, GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
import { useCoarsePointer } from "../../lib/use-coarse-pointer";
import { useVisualViewportHeight } from "../../lib/use-visual-viewport-height";
import { useTerminalChrome } from "./terminal-appearance";
@@ -244,6 +243,7 @@ export function TerminalPage() {
onClose={() => setConfirmKill(false)}
onConfirm={() => void killConfirmed()}
confirmLabel={S.terminal.killShell}
+ cancelLabel={S.common.cancel}
>
{info && (
<p className="break-words text-sm text-gray-600 dark:text-gray-300">
diff --git a/packages/web/src/features/traces/timeline-chart.tsx b/packages/web/src/features/traces/timeline-chart.tsx
index ddbe4a2c..6f75a3f0 100644
--- a/packages/web/src/features/traces/timeline-chart.tsx
+++ b/packages/web/src/features/traces/timeline-chart.tsx
@@ -29,11 +29,11 @@ import type {
TraceOtherSpan,
TraceToolSpan,
} from "@prismshadow/penguin-server/api";
+import { namedHint } from "@prismshadow/penguin-ui";
import { S } from "../../lib/strings";
import { humanizeDuration } from "../../lib/format";
import { packToolLanes, toolSpanBounds } from "./lane-packing";
import type { PackedLane } from "./lane-packing";
-import { namedHint } from "../../components/ui/tooltip";
import { ChartSwatch, TimelineBar, type ChartPaint } from "../../components/ui/chart";
/**
diff --git a/packages/web/src/features/traces/trace-event-row.tsx b/packages/web/src/features/traces/trace-event-row.tsx
index 93924719..cdb001fb 100644
--- a/packages/web/src/features/traces/trace-event-row.tsx
+++ b/packages/web/src/features/traces/trace-event-row.tsx
@@ -12,7 +12,7 @@
* aren't highlighted together).
*/
import { Fragment, useState } from "react";
-import { Badge, ICONS, RequiredMark } from "@prismshadow/penguin-ui";
+import { Badge, ICONS, RequiredMark, ZoomableImage } from "@prismshadow/penguin-ui";
import type { BadgeStyle } from "@prismshadow/penguin-ui";
import ReactMarkdown from "react-markdown";
import { REHYPE_PLUGINS, REMARK_PLUGINS } from "../../lib/markdown-plugins";
@@ -20,7 +20,6 @@ import { S } from "../../lib/strings";
import type { OmniMessage } from "@prismshadow/penguin-core/omnimessage";
import { formatTime, humanizeTokens } from "../../lib/format";
import { stopReasonTone } from "../../lib/stop-reason-tone";
-import { ZoomableImage } from "../../components/ui/image-zoom";
/** An event type as a badge: the session header stands out as a neutral solid tag. */
export function typeBadge(type: string): BadgeStyle {
diff --git a/packages/web/src/features/traces/trace-panel.tsx b/packages/web/src/features/traces/trace-panel.tsx
index 7696f4ce..80a08c09 100644
--- a/packages/web/src/features/traces/trace-panel.tsx
+++ b/packages/web/src/features/traces/trace-panel.tsx
@@ -15,7 +15,13 @@
*/
import { useEffect, useRef, useState } from "react";
import type { SessionInfo } from "@prismshadow/penguin-server/api";
-import { DownloadIcon, EmptyState, ICON_SIZE, Skeleton } from "@prismshadow/penguin-ui";
+import {
+ DownloadIcon,
+ EmptyState,
+ ICON_SIZE,
+ NoticeStrip,
+ Skeleton,
+} from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
@@ -28,7 +34,6 @@ import {
sortTraceFiles,
} from "./trace-refresh";
import type { TraceHighlight } from "./timeline-chart";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** File pills rendered before the "+N" overflow control expands them (a long Session can hold dozens of compaction shards). */
const FILE_PILL_CAP = 6;
diff --git a/packages/web/src/features/usage/errors-panel.tsx b/packages/web/src/features/usage/errors-panel.tsx
index 9d788169..7e13aae5 100644
--- a/packages/web/src/features/usage/errors-panel.tsx
+++ b/packages/web/src/features/usage/errors-panel.tsx
@@ -11,13 +11,11 @@
*/
import { useEffect, useState } from "react";
import type { UsageErrorItem, UsageErrors } from "@prismshadow/penguin-server/api";
-import { Badge } from "@prismshadow/penguin-ui";
+import { Badge, ConfirmModal, toastError, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
import { formatDateTime } from "../../lib/format";
-import { ConfirmModal } from "../../components/ui/confirm-modal";
-import { toastError, toastSuccess } from "../../components/ui/toast";
import { Empty } from "./usage-charts";
import { toneInk } from "../../lib/tone";
@@ -389,6 +387,7 @@ export function ErrorsPanel({
tone="danger"
title={S.usage.errorsClearTitle}
confirmLabel={S.usage.errorsClear}
+ cancelLabel={S.common.cancel}
busy={clearing}
onClose={() => setConfirmingClear(false)}
onConfirm={() => void runClear()}
diff --git a/packages/web/src/features/workflows/workflow-tabs.tsx b/packages/web/src/features/workflows/workflow-tabs.tsx
index a3b16729..11728a87 100644
--- a/packages/web/src/features/workflows/workflow-tabs.tsx
+++ b/packages/web/src/features/workflows/workflow-tabs.tsx
@@ -11,7 +11,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router";
import type { WorkflowInfo, WorkflowVersion } from "@prismshadow/penguin-server/api";
-import { Button } from "@prismshadow/penguin-ui";
+import { Button, NoticeStrip } from "@prismshadow/penguin-ui";
import * as api from "../../api/endpoints";
import { formatDateTime } from "../../lib/format";
import { useShortcutLabel } from "../../lib/shortcuts/use-keymap";
@@ -33,7 +33,6 @@ import {
import { useLocale } from "../../state/locale";
import { useTheme } from "../../state/theme";
import { localizedText } from "../chat/skill-use";
-import { NoticeStrip } from "../../components/ui/notice-strip";
/** The Agent's workflow tabs, kept fresh by the server's `workflow_updated` events. */
export function useWorkflowTabs(
@@ -119,7 +118,7 @@ export function WorkflowTabStrip({
{notices.map((n) => (
<NoticeStrip
key={n.workflowId}
- tone={n.error === null ? "muted" : "attention"}
+ tone={n.error === null ? "neutral" : "attention"}
role="status"
className="shrink-0 truncate px-3 py-1 text-xs"
data-tooltip={n.error ?? n.hints.join("\n")}
diff --git a/packages/web/src/lib/selection-menu.ts b/packages/web/src/lib/selection-menu.ts
index 8d206162..f04e74df 100644
--- a/packages/web/src/lib/selection-menu.ts
+++ b/packages/web/src/lib/selection-menu.ts
@@ -5,8 +5,8 @@
* keyboard asked for it, and what an excerpt becomes once it is added to the conversation.
* Kept free of the DOM so they can be tested in this package's node-only vitest environment.
*/
-import { isLongPressPointer } from "./context-menu";
-import type { AnchorRect } from "./context-menu";
+import { isLongPressPointer } from "@prismshadow/penguin-ui";
+import type { AnchorRect } from "@prismshadow/penguin-ui";
import type { ExcerptReference } from "./workspace-tree";
/** What the rules need to know about a gesture and the selection it found. */
diff --git a/packages/web/src/lib/shortcuts/dispatcher.ts b/packages/web/src/lib/shortcuts/dispatcher.ts
index e2fa76b1..57ef19ea 100644
--- a/packages/web/src/lib/shortcuts/dispatcher.ts
+++ b/packages/web/src/lib/shortcuts/dispatcher.ts
@@ -52,9 +52,10 @@ let blocker: (() => boolean) | null = null;
/**
* Installs the predicate that suspends global commands: while a dialog or a menu is open (the
- * Esc-layer stack in components/ui/modal.tsx), a command must not run behind it — ⌥⌘S would open
- * the sidebar search under the overlay and pull focus out of the dialog. The store stays free of
- * React, so the layer owner installs the predicate itself at module scope.
+ * UI package's Esc-layer stack, `hasEscLayers`), a command must not run behind it — ⌥⌘S would
+ * open the sidebar search under the overlay and pull focus out of the dialog. The store stays free
+ * of React and the package cannot import the app, so the entry (main.tsx) installs the predicate
+ * at module scope, before the mount.
*/
export function setShortcutBlocker(fn: (() => boolean) | null): void {
blocker = fn;
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index f0c6934d..7d33e6f4 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -798,6 +798,10 @@ export const en: Strings = {
moreInfo: "More info",
/** The same, named for what it explains — so the trigger never repeats the heading it sits in. */
moreInfoAbout: (subject: string) => `More info: ${subject}`,
+ /** The toast stack's name as a live region (the shared UI package's `Toaster`). */
+ notifications: "Notifications",
+ /** Read after a toast's text: pressing the toast dismisses it. */
+ dismiss: "Dismiss",
name: "Name",
username: "Username",
role: "Role",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index a7e3bbc9..4acbc2a8 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -851,6 +851,10 @@ export const zh = {
moreInfo: "说明",
/** The same, named for what it explains — so the trigger never repeats the heading it sits in. */
moreInfoAbout: (subject: string) => `说明:${subject}`,
+ /** The toast stack's name as a live region (the shared UI package's `Toaster`). */
+ notifications: "通知",
+ /** Read after a toast's text: pressing the toast dismisses it. */
+ dismiss: "关闭",
name: "名称",
username: "用户名",
role: "角色",
diff --git a/packages/web/src/lib/tone.ts b/packages/web/src/lib/tone.ts
index 5cfefcf0..7b003c15 100644
--- a/packages/web/src/lib/tone.ts
+++ b/packages/web/src/lib/tone.ts
@@ -96,22 +96,3 @@ export const toneDot: Record<Tone, string> = {
danger: "bg-red-500",
muted: "bg-gray-400 dark:bg-gray-600",
};
-
-/**
- * Border plus tinted background for the bordered notice strips (the degraded-mode banner, the
- * missing-placeholder alerts): a heavier treatment than `toneSurface`, for a notice that owns a
- * whole row rather than sitting inside one.
- */
-export const toneStrip: Record<Tone, string> = {
- busy: "border-emerald-300 bg-emerald-50 text-emerald-800 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300",
- attention:
- "border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-300",
- success:
- "border-emerald-300 bg-emerald-50 text-emerald-800 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300",
- // A filled tone box takes the neutral line: the tint alone says which tone it is.
- link: "border-gray-200 bg-blue-50 text-blue-800 dark:border-gray-800 dark:bg-blue-950/40 dark:text-blue-300",
- danger:
- "border-red-300 bg-red-50 text-red-800 dark:border-red-700 dark:bg-red-950/40 dark:text-red-300",
- muted:
- "border-gray-200 bg-gray-50 text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",
-};
diff --git a/packages/web/src/lib/ui-strings.ts b/packages/web/src/lib/ui-strings.ts
index 23a43976..852bd129 100644
--- a/packages/web/src/lib/ui-strings.ts
+++ b/packages/web/src/lib/ui-strings.ts
@@ -22,6 +22,8 @@ export function uiStringsOf(dict: Strings): UiStrings {
clearSearch: dict.chat.searchClear,
moreInfo: dict.common.moreInfo,
moreInfoAbout: dict.common.moreInfoAbout,
+ notifications: dict.common.notifications,
+ dismiss: dict.common.dismiss,
};
}
diff --git a/packages/web/src/lib/use-update-flow.ts b/packages/web/src/lib/use-update-flow.ts
index eeafcebd..b57da3c7 100644
--- a/packages/web/src/lib/use-update-flow.ts
+++ b/packages/web/src/lib/use-update-flow.ts
@@ -14,10 +14,10 @@
import { useEffect, useRef } from "react";
import { createStore, useStore } from "zustand";
import type { UpdateJobStatus } from "@prismshadow/penguin-server/api";
+import { toastError, toastInfo, toastSuccess } from "@prismshadow/penguin-ui";
import * as api from "../api/endpoints";
import { S } from "./strings";
import { apiErrorText } from "./api-error";
-import { toastError, toastInfo, toastSuccess } from "../components/ui/toast";
import {
clientFlow,
opensWithCheck,
diff --git a/packages/web/src/main.tsx b/packages/web/src/main.tsx
index c4183c6e..031acc50 100644
--- a/packages/web/src/main.tsx
+++ b/packages/web/src/main.tsx
@@ -21,11 +21,12 @@
*/
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
+import { hasEscLayers } from "@prismshadow/penguin-ui";
import { App } from "./app";
import { bootInstallScope, watchInstallScope } from "./lib/install-scope";
// The global shortcut dispatcher installs itself at module evaluation (a React effect would
// leave a post-paint window where a chord is dead); the import is what evaluates it.
-import "./lib/shortcuts/dispatcher";
+import { setShortcutBlocker } from "./lib/shortcuts/dispatcher";
// KaTeX's stylesheet and its woff2 faces, resolved out of node_modules so Vite emits them as local
// assets: the desktop app has to render math with no network, and a CDN <link> would leave every
// formula as unstyled markup offline. Imported before styles.css so the app's own `.katex` rules
@@ -33,6 +34,11 @@ import "./lib/shortcuts/dispatcher";
import "katex/dist/katex.min.css";
import "./styles.css";
+// No global command runs behind an open dialog or menu: they all join the UI package's Escape
+// layer stack, which is what the blocker reads. Installed here, before the mount, since the
+// package cannot reach the app's dispatcher.
+setShortcutBlocker(hasEscLayers);
+
const container = document.getElementById("root");
if (!container) throw new Error("#root mount point not found");
diff --git a/packages/web/src/pages/login.tsx b/packages/web/src/pages/login.tsx
index 977d264d..e62e48e3 100644
--- a/packages/web/src/pages/login.tsx
+++ b/packages/web/src/pages/login.tsx
@@ -10,7 +10,14 @@
*/
import { useEffect, useState } from "react";
import { useNavigate, useSearchParams } from "react-router";
-import { Button, Input, PasswordInput, PenguinLogo, Segmented } from "@prismshadow/penguin-ui";
+import {
+ Button,
+ Input,
+ Modal,
+ PasswordInput,
+ PenguinLogo,
+ Segmented,
+} from "@prismshadow/penguin-ui";
import { S } from "../lib/strings";
import { apiErrorText } from "../lib/api-error";
import { useDocumentTitle } from "../lib/use-document-title";
@@ -19,7 +26,6 @@ import { useLocale } from "../state/locale";
import type { LangPref } from "../state/locale";
import { useTheme } from "../state/theme";
import type { ThemeMode } from "../state/theme";
-import { Modal } from "../components/ui/modal";
import { LoginCircuit } from "./login-circuit";
/** Which advice a failed claim asks for; the server decides it from the deployment, not from the token. */
diff --git a/packages/web/src/state/company.tsx b/packages/web/src/state/company.tsx
index 61acf98c..8c6e1e61 100644
--- a/packages/web/src/state/company.tsx
+++ b/packages/web/src/state/company.tsx
@@ -59,10 +59,10 @@ import type {
} from "@prismshadow/penguin-server/api";
import { useStore } from "zustand/react";
import { createStore } from "zustand/vanilla";
+import { toastAttention } from "@prismshadow/penguin-ui";
import * as api from "../api/endpoints";
import { apiErrorText } from "../lib/api-error";
import { S } from "../lib/strings";
-import { toastAttention } from "../components/ui/toast";
import { markBetaNoticeShown, shouldShowBetaNotice } from "../features/company/beta-badge";
import { channelBadgeCounts } from "../features/company/channel-list";
import { orgKey, parseOrgKey } from "../features/company/company-nav";
diff --git a/packages/web/src/styles.css b/packages/web/src/styles.css
index ad0ee834..df64fc62 100644
--- a/packages/web/src/styles.css
+++ b/packages/web/src/styles.css
@@ -350,7 +350,7 @@
global `animation: none !important` block below disables the reveal outright, leaving the
ellipsis and the `title` tooltip that truncated.tsx hands back there (#570). Choosing between
the two is the only thing JS reads the preference for, and it reads it from one app-wide media
- query (use-reduced-motion.ts) — still nothing subscribed per row.
+ query (the UI package's usePrefersReducedMotion) — still nothing subscribed per row.
:focus-visible (not :focus-within) scopes the keyboard trigger to actual keyboard focus;
inside :is() its selector is forgiving, so engines without :has() keep the hover trigger. */
diff --git a/packages/web/test/account-menu.test.ts b/packages/web/test/account-menu.test.ts
index ee37d803..1a0e0394 100644
--- a/packages/web/test/account-menu.test.ts
+++ b/packages/web/test/account-menu.test.ts
@@ -133,8 +133,8 @@ describe("the account menu", () => {
expect(signOut).toBeGreaterThan(-1);
const gate = source.lastIndexOf("{!desktopMode && (", signOut);
expect(gate).toBeGreaterThan(-1);
- // Only sign-out's own <button> stands between that gate and the label it renders.
- expect(source.slice(gate, signOut).match(/<\w/g)).toEqual(["<b"]);
+ // Only sign-out's own <MenuItem> stands between that gate and the label it renders.
+ expect(source.slice(gate, signOut).match(/<\w+/g)).toEqual(["<MenuItem"]);
});
it("confirms before signing out, from a dialog the closing menu cannot take with it", () => {
diff --git a/packages/web/test/context-menu.test.ts b/packages/web/test/context-menu.test.ts
index c01a69f3..d8a10627 100644
--- a/packages/web/test/context-menu.test.ts
+++ b/packages/web/test/context-menu.test.ts
@@ -1,234 +1,20 @@
/**
- * context-menu.ts unit tests: the rules deciding which gesture asks for a row's context
- * menu and where the panel lands.
+ * How the app uses the row context menu (the UI package's `useRowContextMenu` and its gesture
+ * rules, under components/overlays/portal-panel/, driving a `Dropdown` in `anchorRect` mode). The
+ * rules, the hook's own guards and the Dropdown's scroll wiring are the package's
+ * `context-menu.test.ts`; what is pinned here spans the app.
*
- * Two things matter beyond the arithmetic. **Anchoring** has to distinguish a real
- * secondary click from the keyboard chord browsers synthesize a `contextmenu` event for,
- * because a keyboard user has no pointer and a pointer-anchored panel would open in the
- * corner of the screen. And the feature must not be mouse-only: touch screens have
- * neither hover nor a secondary button, which is exactly why
- * `design/specs/06-PROTOTYPE.md` requires touch to keep a path of its own.
- *
- * **Dismissal** is the third: the panel listens for scroll in the capture phase, which
- * reaches every scrolling container in the document, so the rule that closes a menu whose
- * anchor point has moved must not close one anchored somewhere that did not move. That rule,
- * `scrollMovesAnchor`, is the UI package's (its cases are in the package's
- * portal-panel.test.ts); what is pinned here is the menu consulting it.
- *
- * The last part pins **suppression scope** against the source text. Preventing the
- * browser's own menu is correct on the row and wrong everywhere else, and nothing in a
- * node-only suite (`environment: "node"`, no jsdom) would notice a `preventDefault` that
- * had crept onto a document-level listener — so the scan asserts there is no global
- * contextmenu listener in the package, and that the one handler doing the suppressing
- * lives in the hook the row spreads onto itself (title-reveal.test.ts convention).
+ * **Suppression scope**: preventing the browser's own menu is correct on the row and wrong
+ * everywhere else, and nothing in a node-only suite (`environment: "node"`, no jsdom) would notice
+ * a `preventDefault` that had crept onto a document-level listener — so the scan asserts there is
+ * no global contextmenu listener in either root. And the feature must not be mouse-only: the
+ * sidebar's Session rows spread all three openers (right-click, Shift+F10, press-and-hold) and
+ * name the anchor's owner, which the scroll rule needs to leave a menu open while an unrelated
+ * container scrolls.
*/
import { describe, expect, it } from "vitest";
-import {
- IDLE_HOLD,
- LONG_PRESS_MS,
- LONG_PRESS_SETTLE_MS,
- LONG_PRESS_SLOP_PX,
- contextMenuAnchor,
- isContextMenuKey,
- isLongPressPointer,
- isPointerContextMenu,
- longPressMoved,
- pointerAnchor,
- reduceHold,
- withinSettleWindow,
-} from "../src/lib/context-menu";
-import type { HoldEvent } from "../src/lib/context-menu";
import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";
-const ROW = { top: 100, bottom: 132, left: 8, right: 260 };
-
-describe("pointerAnchor", () => {
- it("is a zero-size box at the point, so the panel hangs off the click itself", () => {
- expect(pointerAnchor(420, 300)).toEqual({ top: 300, bottom: 300, left: 420, right: 420 });
- });
-});
-
-describe("isPointerContextMenu", () => {
- it("recognizes a secondary click", () => {
- expect(isPointerContextMenu({ button: 2, clientX: 420, clientY: 300 })).toBe(true);
- });
-
- it("rejects the keyboard-synthesized event, which reports no button", () => {
- expect(isPointerContextMenu({ button: 0, clientX: 130, clientY: 110 })).toBe(false);
- });
-
- it("rejects the (0, 0) coordinates some browsers report for the Menu key", () => {
- expect(isPointerContextMenu({ button: 2, clientX: 0, clientY: 0 })).toBe(false);
- });
-});
-
-describe("contextMenuAnchor", () => {
- it("opens at the pointer for a right-click", () => {
- expect(contextMenuAnchor({ button: 2, clientX: 420, clientY: 300 }, ROW)).toEqual(
- pointerAnchor(420, 300),
- );
- });
-
- it("falls back to the row's own box when the keyboard asked, not to the viewport corner", () => {
- expect(contextMenuAnchor({ button: 0, clientX: 0, clientY: 0 }, ROW)).toEqual(ROW);
- });
-});
-
-describe("isContextMenuKey", () => {
- it("is Shift+F10, the platform chord for the focused element's context menu", () => {
- expect(isContextMenuKey({ key: "F10", shiftKey: true })).toBe(true);
- });
-
- it("ignores a bare F10 and other shifted keys, so the row eats no ordinary typing", () => {
- expect(isContextMenuKey({ key: "F10", shiftKey: false })).toBe(false);
- expect(isContextMenuKey({ key: "F11", shiftKey: true })).toBe(false);
- expect(isContextMenuKey({ key: "Enter", shiftKey: true })).toBe(false);
- });
-});
-
-describe("press-and-hold (the touch path)", () => {
- it("holds for touch and pen only — a mouse has a secondary button and uses it", () => {
- expect(isLongPressPointer("touch")).toBe(true);
- expect(isLongPressPointer("pen")).toBe(true);
- expect(isLongPressPointer("mouse")).toBe(false);
- expect(isLongPressPointer("")).toBe(false);
- });
-
- it("tolerates a finger's jitter but treats real travel as a scroll", () => {
- const from = { x: 100, y: 200 };
- expect(longPressMoved(from, { x: 100, y: 200 })).toBe(false);
- expect(longPressMoved(from, { x: 100 + LONG_PRESS_SLOP_PX, y: 200 })).toBe(false);
- expect(longPressMoved(from, { x: 100, y: 200 + LONG_PRESS_SLOP_PX + 1 })).toBe(true);
- expect(longPressMoved(from, { x: 100 - LONG_PRESS_SLOP_PX - 1, y: 200 })).toBe(true);
- });
-
- it("waits long enough not to fire on an ordinary tap", () => {
- expect(LONG_PRESS_MS).toBeGreaterThanOrEqual(400);
- expect(LONG_PRESS_SETTLE_MS).toBeGreaterThan(0);
- });
-
- it("ignores a dismiss inside the grace window that started at the given moment", () => {
- const opened = 10_000;
- expect(withinSettleWindow(opened, opened)).toBe(true);
- expect(withinSettleWindow(opened, opened + LONG_PRESS_SETTLE_MS - 1)).toBe(true);
- expect(withinSettleWindow(opened, opened + LONG_PRESS_SETTLE_MS)).toBe(false);
- expect(withinSettleWindow(opened, opened + 5_000)).toBe(false);
- });
-});
-
-/**
- * The gesture lifecycle, driven as ordered sequences. This is where the interesting bugs
- * live — every one of the cases below is a real touch sequence, not a synthetic one — and
- * it is only reachable from a node-only suite because the decisions were kept pure.
- */
-describe("reduceHold", () => {
- /** Feed a sequence, returning each step's outcome. */
- const play = (events: HoldEvent[]) => {
- let state = IDLE_HOLD;
- return events.map((e) => {
- const out = reduceHold(state, e);
- state = out.state;
- return out;
- });
- };
-
- it("opens on the hold and swallows the click the lift replays", () => {
- const [, held, , click] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- { kind: "pointerup", at: 1_200 },
- { kind: "click" },
- ]);
- expect(held!.open).toBe("held");
- expect(click!.swallow).toBe(true);
- });
-
- it("measures the grace window from the LIFT, so reading the menu before lifting is safe", () => {
- // The whole point: the menu opens at 1s and the user studies it for two seconds before
- // lifting. The compatibility mousedown arrives at the lift, not at the open — anchoring
- // the window to the open time would dismiss the menu the gesture just produced.
- const [, , , dismiss] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- { kind: "pointerup", at: 3_000 },
- { kind: "dismiss", at: 3_010 },
- ]);
- expect(dismiss!.close).toBe(false);
- });
-
- it("believes a dismiss once the replayed events can no longer be in flight", () => {
- const [, , , dismiss] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- { kind: "pointerup", at: 3_000 },
- { kind: "dismiss", at: 3_000 + LONG_PRESS_SETTLE_MS },
- ]);
- expect(dismiss!.close).toBe(true);
- });
-
- it("treats a native contextmenu raised during a touch hold as the hold itself", () => {
- // Android raises its own contextmenu mid-hold and can beat our timer to it. If that is
- // not recognized as a hold, the lift's replayed click falls through and opens the
- // conversation on top of the menu.
- const [, native, , click] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "nativemenu", at: 1_000 },
- { kind: "pointerup", at: 1_100 },
- { kind: "click" },
- ]);
- expect(native!.open).toBe("event");
- expect(native!.state.held).toBe(true);
- expect(click!.swallow).toBe(true);
- });
-
- it("does not re-anchor an already-held menu when the browser raises its own afterwards", () => {
- const [, , native] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- { kind: "nativemenu", at: 1_050 },
- ]);
- expect(native!.open).toBeNull();
- });
-
- it("leaves a mouse right-click free of hold semantics", () => {
- const [, native, dismiss, click] = play([
- { kind: "pointerdown", pointerType: "mouse" },
- { kind: "nativemenu", at: 1_000 },
- { kind: "dismiss", at: 1_010 },
- { kind: "click" },
- ]);
- expect(native!.open).toBe("event");
- expect(native!.state.held).toBe(false);
- // No grace window for a mouse: the very next outside click closes the menu.
- expect(dismiss!.close).toBe(true);
- expect(click!.swallow).toBe(false);
- });
-
- it("clears a hold flag left over from a gesture whose replayed click never came", () => {
- const [, , down, click] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- // No click followed; the next gesture starts clean rather than eating its tap.
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "click" },
- ]);
- expect(down!.state.held).toBe(false);
- expect(click!.swallow).toBe(false);
- });
-
- it("swallows only one click per hold", () => {
- const [, , , first, second] = play([
- { kind: "pointerdown", pointerType: "touch" },
- { kind: "hold", at: 1_000 },
- { kind: "pointerup", at: 1_100 },
- { kind: "click" },
- { kind: "click" },
- ]);
- expect(first!.swallow).toBe(true);
- expect(second!.swallow).toBe(false);
- });
-});
-
/** Every .ts/.tsx under web and the shared UI package (test/helpers/roots.ts). */
const SCAN = scanSources([".ts", ".tsx"]);
@@ -244,14 +30,15 @@ function sourceFiles(): Array<[string, string]> {
return SCAN.files.map((file) => [file.id, file.text]);
}
-const DROPDOWN = "packages/web/src/components/ui/dropdown.tsx";
-const CONTEXT_MENU = "packages/web/src/components/ui/context-menu.tsx";
+const DROPDOWN = "packages/ui/src/components/overlays/dropdown/dropdown.tsx";
+const CONTEXT_MENU = "packages/ui/src/components/overlays/portal-panel/use-row-context-menu.ts";
+const RULES = "packages/ui/src/components/overlays/portal-panel/context-menu.ts";
const SIDEBAR = "packages/web/src/components/layout/sidebar.tsx";
describe("sourceFiles", () => {
it("scans every source root, and finds the menu modules in one place each", () => {
expectEveryRootScanned(SCAN);
- for (const id of [DROPDOWN, CONTEXT_MENU, "packages/web/src/lib/context-menu.ts"]) {
+ for (const id of [DROPDOWN, CONTEXT_MENU, RULES]) {
expectSingleHome(SCAN, id);
}
});
@@ -267,22 +54,6 @@ describe("sourceFiles", () => {
});
});
-describe("anchored dismissal wiring", () => {
- it("asks scrollMovesAnchor before dismissing an anchored panel", () => {
- // The rule's own cases are covered in the package against stand-in nodes. What a node-only
- // suite cannot reach is the component consulting it at all, and that is where this silently
- // breaks: drop the call and every assertion there still passes while the reported bug —
- // a streaming message list wiping a menu opened in the sidebar — comes straight back.
- const dropdown = sourceFiles().find(([path]) => path === DROPDOWN);
- expect(dropdown).toBeDefined();
- const onScroll = /const onScroll = \(e: Event\) => \{([\s\S]*?)\n {4}\};/.exec(dropdown![1]);
- expect(onScroll, "onScroll should be declared in dropdown.tsx").not.toBeNull();
- expect(onScroll![1]).toContain("scrollMovesAnchor(");
- // The owner is the element the anchorRect was measured from, read at event time.
- expect(onScroll![1]).toContain("anchorOwnerRef.current");
- });
-});
-
describe("native-menu suppression scope", () => {
it("registers no global contextmenu listener, so the browser's own menu survives off the row", () => {
// Matched on the TARGET, not on the call: suppressing the native menu page-wide is the
@@ -296,32 +67,6 @@ describe("native-menu suppression scope", () => {
expect(global.map(([path]) => path)).toEqual([]);
});
- it("calls preventDefault inside the contextmenu handler itself, not somewhere adjacent", () => {
- // Tied to the handler rather than to the file: preventDefault also appears in
- // onKeyDown, so file-level presence would prove nothing about the native menu.
- const hook = sourceFiles().find(([path]) => path === CONTEXT_MENU);
- expect(hook).toBeDefined();
- const handler = /onContextMenu:\s*\(e\)\s*=>\s*\{([\s\S]*?)\n {4}\},/.exec(hook![1]);
- expect(handler).not.toBeNull();
- expect(handler![1]).toContain("e.preventDefault()");
- });
-
- it("ignores events that bubbled out of the portaled panel rather than the row", () => {
- // React propagates through its own tree, so the Dropdown's body portal — a React child
- // of the row — would otherwise re-anchor the open menu when one of its items is
- // right-clicked. A DOM containment check separates the two trees.
- const hook = sourceFiles().find(([path]) => path === CONTEXT_MENU);
- const src = hook![1];
- expect(src).toContain("host.contains(e.target as Node)");
- for (const handler of ["onContextMenu", "onKeyDown", "onPointerDown"]) {
- const body = new RegExp(`${handler}:\\s*\\(e\\)\\s*=>\\s*\\{([\\s\\S]*?)\\n {4}\\},`).exec(
- src,
- );
- expect(body, `${handler} should exist`).not.toBeNull();
- expect(body![1], `${handler} should guard on fromRow`).toContain("if (!fromRow(e)) return;");
- }
- });
-
it("gives the sidebar row all three openers, so the menu is not mouse-only", () => {
const sidebar = sourceFiles().find(([path]) => path === SIDEBAR);
expect(sidebar).toBeDefined();
@@ -333,7 +78,7 @@ describe("native-menu suppression scope", () => {
it("names the anchor's owner alongside the anchor, so the scroll rule has one to test", () => {
// Without the wiring, scrollMovesAnchor is asked about a null owner on every scroll and
- // answers "dismiss" — the rule above would still pass while the bug was back.
+ // answers "dismiss" — the package's rule tests would still pass while the bug was back.
const sidebar = sourceFiles().find(([path]) => path === SIDEBAR);
expect(sidebar![1]).toContain("anchorOwner={ctx.anchorOwner}");
});
diff --git a/packages/web/test/control-size.test.ts b/packages/web/test/control-size.test.ts
index 8b129b86..74635c2d 100644
--- a/packages/web/test/control-size.test.ts
+++ b/packages/web/test/control-size.test.ts
@@ -45,7 +45,7 @@ const FAMILY: Record<string, string> = {
"input.tsx": "packages/ui/src/components/forms/input/input.tsx",
"select.tsx": "packages/ui/src/components/forms/select/select.tsx",
"option-menu.tsx": "packages/ui/src/components/forms/select/option-menu.tsx",
- "form-picker.tsx": "packages/web/src/components/ui/form-picker.tsx",
+ "form-picker.tsx": "packages/ui/src/components/forms/select/form-picker.tsx",
"search-input.tsx": "packages/ui/src/components/forms/search-input/search-input.tsx",
};
@@ -284,7 +284,7 @@ describe("control font size", () => {
expect(
findLooseFooterButtons(),
'A Button in a Modal footer passes size="sm", so the dialog\'s buttons read at the same ' +
- "size as its fields (compare components/ui/confirm-modal.tsx).",
+ "size as its fields (compare the UI package's ConfirmModal).",
).toEqual([]);
});
diff --git a/packages/web/test/deslop.test.ts b/packages/web/test/deslop.test.ts
index 46681759..28e1ebd4 100644
--- a/packages/web/test/deslop.test.ts
+++ b/packages/web/test/deslop.test.ts
@@ -34,10 +34,11 @@ const WEB = SCAN.files.filter((file) => file.root === "web");
/**
* The homes §3 names, as the web app spells them today. It has no Spinner of its own (the
- * package's is the one), and the chevron's rotation left with the chevron.
+ * package's is the one), the chevron's rotation left with the chevron, and the sheet's and the
+ * drawer's motion with them (W3).
*/
const POLICY: DeslopPolicy = {
- transformMotion: ["sheet.tsx", "drawer.tsx", "dock-launcher.tsx"],
+ transformMotion: ["dock-launcher.tsx"],
entranceMotion: [],
pulseHomes: ["dot.tsx", "streaming-caret.tsx"],
spinnerHomes: [],
@@ -57,18 +58,13 @@ const POLICY: DeslopPolicy = {
const ALLOWLIST: DeslopAllowlist = {
"components/account/update-modal.tsx": { 1: [1, "W4"], 3: [1, "W4"], 6: [1, "W4"] },
"components/layout/app-layout.tsx": { 1: [1, "W7"] },
- "components/layout/project-dialogs.tsx": { 13: [1, "W3"] },
"components/layout/sidebar.tsx": {
1: [3, "W7"],
12: [5, "W7"],
- 13: [3, "W7"],
+ 13: [2, "W7"],
14: [2, "W7"],
},
- "components/ui/confirm-modal.tsx": { 7: [1, "W3"] },
"components/ui/group-list.tsx": { 12: [1, "W4"], 13: [3, "W4"], 14: [2, "W4"] },
- "components/ui/paged-dialog.tsx": { 13: [1, "W3"], 14: [2, "W3"] },
- "components/ui/sheet.tsx": { 19: [1, "W3"] },
- "components/ui/toast.tsx": { 9: [4, "W4"] },
"features/agents/agent-settings-page.tsx": { 12: [3, "W4"] },
"features/agents/hooks-tab.tsx": { 12: [1, "W4"], 13: [2, "W4"] },
"features/agents/mcp-servers-section.tsx": { 13: [3, "W4"] },
@@ -80,8 +76,6 @@ const ALLOWLIST: DeslopAllowlist = {
"features/benchmark/benchmark-case-browser.tsx": { 13: [2, "W4"] },
"features/benchmark/benchmark-detail.tsx": { 13: [2, "W4"] },
"features/benchmark/benchmark-page.tsx": { 13: [1, "W4"], 18: [1, "W4"] },
- "features/benchmark/create-benchmark-modal.tsx": { 13: [1, "W3"] },
- "features/benchmark/evaluation-detail-modal.tsx": { 13: [2, "W3"] },
"features/builtin-browser/browser-tab-strip.tsx": { 12: [2, "W10"] },
"features/chat/agent-topology-view.tsx": { 12: [1, "W6"], 13: [3, "W6"] },
"features/chat/chat-input.tsx": { 7: [1, "W6"], 12: [7, "W6"], 13: [5, "W6"] },
@@ -90,7 +84,7 @@ const ALLOWLIST: DeslopAllowlist = {
"features/chat/context-gauge.tsx": { 12: [5, "W8"] },
"features/chat/conversation-outline.tsx": { 12: [1, "W6"] },
"features/chat/disclosure-row.tsx": { 13: [1, "W4"], 14: [2, "W4"] },
- "features/chat/draft-view.tsx": { 12: [1, "W6"], 13: [2, "W6"] },
+ "features/chat/draft-view.tsx": { 12: [1, "W6"], 13: [1, "W6"] },
"features/chat/drop-zone.tsx": { 18: [1, "W7"] },
"features/chat/live-duration.tsx": { 6: [1, "W4"] },
"features/chat/memory-view.tsx": { 13: [2, "W6"] },
@@ -114,7 +108,7 @@ const ALLOWLIST: DeslopAllowlist = {
"features/company/beta-badge.tsx": { 13: [1, "W4"] },
"features/company/calendar-page.tsx": { 12: [3, "W4"], 13: [10, "W4"] },
"features/company/channel-composer.tsx": { 13: [2, "W6"] },
- "features/company/channel-header.tsx": { 13: [4, "W6"] },
+ "features/company/channel-header.tsx": { 13: [3, "W6"] },
"features/company/channel-sidebar.tsx": { 12: [2, "W4"], 13: [6, "W4"], 14: [2, "W4"] },
"features/company/channel-view.tsx": { 12: [1, "W6"], 13: [6, "W6"] },
"features/company/chart-card.tsx": { 12: [1, "W8"], 13: [5, "W8"] },
@@ -127,7 +121,7 @@ const ALLOWLIST: DeslopAllowlist = {
"features/company/org-dialogs.tsx": { 13: [1, "W4"] },
"features/company/org-layout.tsx": { 12: [1, "W4"], 13: [2, "W4"], 14: [2, "W4"] },
"features/company/org-session-groups.tsx": { 12: [2, "W4+W10"], 13: [1, "W10"] },
- "features/company/org-switcher.tsx": { 13: [3, "W4"], 14: [2, "W4"] },
+ "features/company/org-switcher.tsx": { 13: [2, "W4"] },
"features/company/overview-page.tsx": { 12: [2, "W4"], 13: [2, "W4"], 14: [4, "W4"] },
"features/company/shared.tsx": { 13: [3, "W4"] },
"features/company/ticket-dialog.tsx": { 12: [6, "W4"], 13: [3, "W4"], 14: [2, "W4"] },
@@ -156,7 +150,6 @@ const ALLOWLIST: DeslopAllowlist = {
"features/traces/trace-file-view.tsx": { 12: [2, "W4"], 13: [5, "W4"], 15: [1, "W4"] },
"features/usage/usage-charts.tsx": { 13: [3, "W8"] },
"features/usage/usage-page.tsx": { 12: [1, "W8"] },
- "lib/tone.ts": { 9: [4, "W4"] },
"pages/login.tsx": { 9: [1, "W4"] },
};
diff --git a/packages/web/test/esc-layers.test.ts b/packages/web/test/esc-layers.test.ts
index e880c20d..d573baae 100644
--- a/packages/web/test/esc-layers.test.ts
+++ b/packages/web/test/esc-layers.test.ts
@@ -1,18 +1,19 @@
/**
- * Escape-layer stack (components/ui/modal.tsx): modals AND Dropdown menus register as
- * layers, and Escape only acts on the topmost one. This is what makes one Escape close a
- * menu opened inside a dialog while the dialog stays up (the next Escape closes it), and
- * keeps nested dialogs closing one at a time.
+ * Escape-layer stack (the UI package's src/components/overlays/esc-layers/esc-layers.ts):
+ * modals, drawers, sheets, the lightbox AND Dropdown menus register as layers, and Escape only
+ * acts on the topmost one. This is what makes one Escape close a menu opened inside a dialog
+ * while the dialog stays up (the next Escape closes it), and keeps nested dialogs closing one at
+ * a time.
*/
import { describe, expect, it } from "vitest";
-import { isTopEscLayer, popEscLayer, pushEscLayer } from "../src/components/ui/modal";
+import { hasEscLayers, isTopEscLayer, popEscLayer, pushEscLayer } from "@prismshadow/penguin-ui";
import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";
describe("esc layer sources", () => {
it("scan every source root, and find the stack in one place", () => {
const scan = scanSources();
expectEveryRootScanned(scan);
- expectSingleHome(scan, "packages/web/src/components/ui/modal.tsx");
+ expectSingleHome(scan, "packages/ui/src/components/overlays/esc-layers/esc-layers.ts");
});
});
@@ -20,6 +21,8 @@ describe("esc layer stack", () => {
it("only the topmost layer may act; popping restores the one below", () => {
const modal = pushEscLayer();
expect(isTopEscLayer(modal)).toBe(true);
+ // An open layer is what holds the app's global shortcuts back.
+ expect(hasEscLayers()).toBe(true);
// A menu opened inside the modal stacks above it: the first Escape belongs to the menu.
const menu = pushEscLayer();
expect(isTopEscLayer(menu)).toBe(true);
@@ -28,6 +31,7 @@ describe("esc layer stack", () => {
expect(isTopEscLayer(modal)).toBe(true);
popEscLayer(modal);
expect(isTopEscLayer(modal)).toBe(false);
+ expect(hasEscLayers()).toBe(false);
});
it("tolerates out-of-order removal (an outer layer unmounting first)", () => {
diff --git a/packages/web/test/group-list.test.ts b/packages/web/test/group-list.test.ts
index d5aab2fa..9f7cf16b 100644
--- a/packages/web/test/group-list.test.ts
+++ b/packages/web/test/group-list.test.ts
@@ -66,9 +66,9 @@ describe("list-options glyphs", () => {
// drift apart. Node-only suite, so this reads the sources (title-reveal.test.ts).
const sidebar = sourceFile(SCAN, "packages/web/src/components/layout/sidebar.tsx").text;
for (const mode of ["workspace", "agent", "time"] satisfies GroupMode[])
- expect(sidebar).toContain(`icon={GROUP_MODE_ICONS.${mode}}`);
+ expect(sidebar).toContain(`glyph={GROUP_MODE_ICONS.${mode}}`);
for (const mode of ["recent", "manual"] satisfies SessionSortMode[])
- expect(sidebar).toContain(`icon={SORT_MODE_ICONS.${mode}}`);
+ expect(sidebar).toContain(`glyph={SORT_MODE_ICONS.${mode}}`);
});
it("gives every row a glyph that differs, so an icon distinguishes rather than decorates", () => {
diff --git a/packages/web/test/menu-style.test.ts b/packages/web/test/menu-style.test.ts
index d83ff2cc..3028f5c3 100644
--- a/packages/web/test/menu-style.test.ts
+++ b/packages/web/test/menu-style.test.ts
@@ -2,8 +2,9 @@
* One look for every picker and menu: Select's panel, row states and check mark, which the UI
* package owns (`menuPanelClass`, `menuRowClass`, `menuRowTone`, `ChoiceCheck` in
* components/overlays/menu-panel/menu-panel.tsx), shared by Select, OptionMenu, Dropdown and the
- * pickers built on Dropdown. The pieces themselves are tested in the package; this suite checks
- * how the app uses them, as source, because the web suite renders no DOM.
+ * pickers built on Dropdown, and the Menu rows built on them. The pieces themselves are tested in
+ * the package; this suite checks how the app uses them, as source, because the web suite renders
+ * no DOM.
*/
import { describe, expect, it } from "vitest";
import { expectSingleHome, scanSources, sourceFile } from "./helpers/roots";
@@ -30,12 +31,22 @@ describe("menus and pickers", () => {
for (const id of [
"packages/ui/src/components/forms/select/select.tsx",
"packages/ui/src/components/forms/select/option-menu.tsx",
- "packages/web/src/components/ui/dropdown.tsx",
+ "packages/ui/src/components/overlays/dropdown/dropdown.tsx",
]) {
expect(text(id), id).toContain("${menuPanelClass}");
}
});
+ it("draw their rows with the Menu family, never a hand-built menu row", () => {
+ // The Session row's menu keeps its own rows until the sidebar's rows move into the package.
+ const pending = ["packages/web/src/components/ui/session-row-menu.tsx"];
+ const handBuilt = SCAN.files
+ .filter((file) => file.root === "web" && !pending.includes(file.id))
+ .filter((file) => /\bmenuRow(?:Class|Tone)\b/.test(file.text))
+ .map((file) => file.id);
+ expect(handBuilt).toEqual([]);
+ });
+
it("mark the current choice with Select's check, never a typed ✓", () => {
const typed = SCAN.files
.filter((file) => file.root === "web" && file.name.endsWith(".tsx"))
diff --git a/packages/web/test/modal-focus.test.ts b/packages/web/test/modal-focus.test.ts
index 65f8ce80..0c2563ed 100644
--- a/packages/web/test/modal-focus.test.ts
+++ b/packages/web/test/modal-focus.test.ts
@@ -1,8 +1,9 @@
/**
- * Focus behaviour of the Modal primitive (src/components/ui/modal.tsx), which every dialog in
- * the app inherits: focus enters the panel on open, Tab and Shift+Tab cycle inside it, and
- * focus returns to the trigger on close. The wiring lives in `useDialogLayer`, which the
- * command palette and the harness history overlay share with Modal, so what is pinned here
+ * Focus behaviour of the Modal primitive (the UI package's
+ * src/components/overlays/modal/modal.tsx), which every dialog in the app inherits: focus enters
+ * the panel on open, Tab and Shift+Tab cycle inside it, and focus returns to the trigger on close.
+ * The wiring lives in `useDialogLayer` (src/components/overlays/esc-layers/esc-layers.ts), which
+ * the command palette and the harness history overlay share with Modal, so what is pinned here
* holds for those two as well.
*
* `nextFocusIndex` is the arithmetic and is exercised directly. The wiring around it cannot
@@ -15,20 +16,26 @@
* is a dialog that hands focus back to itself.
*/
import { describe, expect, it } from "vitest";
-import { nextFocusIndex } from "../src/components/ui/modal";
+import { nextFocusIndex } from "@prismshadow/penguin-ui";
import { expectEveryRootScanned, expectSingleHome, scanSources, sourceFile } from "./helpers/roots";
const SCAN = scanSources();
-const MODAL = "packages/web/src/components/ui/modal.tsx";
-const DROPDOWN = "packages/web/src/components/ui/dropdown.tsx";
+const MODAL = "packages/ui/src/components/overlays/modal/modal.tsx";
+const LAYER = "packages/ui/src/components/overlays/esc-layers/esc-layers.ts";
+const DROPDOWN = "packages/ui/src/components/overlays/dropdown/dropdown.tsx";
const modal = sourceFile(SCAN, MODAL).text;
+const layer = sourceFile(SCAN, LAYER).text;
+/** `useDialogLayer`'s body: the focus wiring, without the Escape hook declared above it. */
+const dialogLayer = layer.slice(layer.indexOf("export function useDialogLayer("));
const dropdown = sourceFile(SCAN, DROPDOWN).text;
describe("the dialog primitives' sources", () => {
- it("scan every source root, and find Modal and Dropdown in one place each", () => {
+ it("scan every source root, and find Modal, its layer and Dropdown in one place each", () => {
expectEveryRootScanned(SCAN);
expectSingleHome(SCAN, MODAL);
+ expectSingleHome(SCAN, LAYER);
expectSingleHome(SCAN, DROPDOWN);
+ expect(layer).toContain("export function useDialogLayer(");
});
});
@@ -39,14 +46,14 @@ function panelTag(): string {
return tag![0];
}
-/** The `useEffect(...)` block containing `marker`, up to and including its dependency array. */
-function effectWith(marker: string): string {
- const at = modal.indexOf(marker);
- expect(at, `expected ${marker} in modal.tsx`).toBeGreaterThan(-1);
- const start = modal.lastIndexOf("useEffect(", at);
+/** The `useEffect(...)` block of `src` holding `marker`, up to and including its dependencies. */
+function effectWith(src: string, marker: string): string {
+ const at = src.indexOf(marker);
+ expect(at, `expected ${marker} in esc-layers.ts`).toBeGreaterThan(-1);
+ const start = src.lastIndexOf("useEffect(", at);
expect(start, `${marker} should sit inside a useEffect`).toBeGreaterThan(-1);
- const deps = modal.indexOf("}, [", at);
- return modal.slice(start, modal.indexOf(");", deps) + 2);
+ const deps = src.indexOf("}, [", at);
+ return src.slice(start, src.indexOf(");", deps) + 2);
}
describe("nextFocusIndex", () => {
@@ -97,11 +104,16 @@ describe("Modal dialog semantics", () => {
it("keeps the container focusable so a dialog with no controls can still hold focus", () => {
expect(panelTag()).toContain("tabIndex={-1}");
});
+
+ it("takes its keyboard wiring from the shared dialog layer", () => {
+ expect(modal).toContain("useDialogLayer(open, panelRef, onClose)");
+ expect(panelTag()).toContain("onKeyDown={onPanelKeyDown}");
+ });
});
describe("Modal focus containment", () => {
it("moves focus into the panel on open, yielding to a child that autofocused", () => {
- const effect = effectWith("FOCUSABLE_SELECTOR) ?? panel");
+ const effect = effectWith(dialogLayer, "FOCUSABLE_SELECTOR) ?? panel");
// A child with autoFocus is focused during the commit, before this effect runs; stealing
// focus back to the close button would undo it at every call site that uses autoFocus.
expect(effect).toContain("!panel.contains(document.activeElement)");
@@ -111,7 +123,7 @@ describe("Modal focus containment", () => {
it("returns focus on every close path", () => {
// Keyed on `open` alone, so the cleanup runs for Escape, the close button, the overlay
// mousedown, the prop going false, and an outright unmount alike.
- const effect = effectWith("restoreFocusRef.current?.focus()");
+ const effect = effectWith(dialogLayer, "restoreFocusRef.current?.focus()");
expect(effect).toContain("return () => restoreFocusRef.current?.focus();");
expect(effect).toContain("[open]");
});
@@ -119,14 +131,14 @@ describe("Modal focus containment", () => {
it("reads the element to return to during render, before any effect can run", () => {
// autoFocus fires in the same commit, so an effect-time read would capture a node inside
// the dialog and hand focus back to the dialog that just closed.
- const capture = modal.indexOf("restoreFocusRef.current =");
+ const capture = dialogLayer.indexOf("restoreFocusRef.current =");
expect(capture).toBeGreaterThan(-1);
- expect(capture).toBeLessThan(modal.indexOf("useEffect("));
+ expect(capture).toBeLessThan(dialogLayer.indexOf("useEffect("));
});
it("cycles Tab within the panel, and yields to the two things that own it first", () => {
- const handler = /const onPanelKeyDown = [\s\S]*?\n {2}\};/.exec(modal);
- expect(handler, "onPanelKeyDown should be declared in modal.tsx").not.toBeNull();
+ const handler = /const onPanelKeyDown = [\s\S]*?\n {2}\};/.exec(dialogLayer);
+ expect(handler, "onPanelKeyDown should be declared in useDialogLayer").not.toBeNull();
const body = handler![0];
expect(body).toContain("nextFocusIndex(");
expect(body).toContain("e.shiftKey");
@@ -140,13 +152,14 @@ describe("Modal focus containment", () => {
});
it("leaves Escape on the layer stack, so only the topmost dialog closes", () => {
- expect(effectWith("const id = pushEscLayer();")).toContain("isTopEscLayer(id)");
+ expect(dialogLayer).toContain("useEscLayer(open, onClose)");
+ expect(effectWith(layer, "const id = pushEscLayer();")).toContain("isTopEscLayer(id)");
});
});
describe("focusable selector", () => {
it("is shared with Dropdown rather than copied into it", () => {
- expect(modal).toContain("export const FOCUSABLE_SELECTOR =");
+ expect(layer).toContain("export const FOCUSABLE_SELECTOR =");
expect(dropdown).toContain("querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)");
expect(dropdown).not.toContain("a[href]");
});
@@ -155,7 +168,7 @@ describe("focusable selector", () => {
// The app's file pickers are hidden the `sr-only` way — position/clip, not `display:
// none` — specifically so they stay Tab-reachable (hidden-file-input.tsx). A selector
// narrowed to visible boxes would drop every "upload" and "import" control in a dialog.
- expect(modal).toContain("input:not([disabled])");
- expect(modal).not.toContain("offsetParent");
+ expect(layer).toContain("input:not([disabled])");
+ expect(layer).not.toContain("offsetParent");
});
});
diff --git a/packages/web/test/no-native-title.test.ts b/packages/web/test/no-native-title.test.ts
index be03346e..5c43832e 100644
--- a/packages/web/test/no-native-title.test.ts
+++ b/packages/web/test/no-native-title.test.ts
@@ -1,10 +1,11 @@
/**
* No native `title` tooltips in the Web App.
*
- * Every hover hint shows in the shared tooltip (components/ui/tooltip.tsx): through
- * `data-tooltip` on the element, read by the one `TooltipLayer`, or a `<Tooltip>` wrapper. A
- * native `title` waits about a second, cannot be themed and never shows on keyboard focus, so
- * one left behind is a hint that looks and behaves unlike every other in the app.
+ * Every hover hint shows in the shared tooltip (the UI package's overlays/tooltip/tooltip.tsx,
+ * whose own tests read a `data-tooltip` request): through `data-tooltip` on the element, read by
+ * the one `TooltipLayer`, or a `<Tooltip>` wrapper. A native `title` waits about a second, cannot
+ * be themed and never shows on keyboard focus, so one left behind is a hint that looks and
+ * behaves unlike every other in the app.
*
* The check parses the real JSX with the TypeScript parser, because whether `title` is an
* attribute of a DOM element or a prop of a component (a Modal's heading, an EmptyState's) is a
@@ -21,7 +22,6 @@ import ts from "typescript";
import { describe, expect, it } from "vitest";
import { expectEveryRootScanned, scanSources } from "./helpers/roots";
import type { SourceFile } from "./helpers/roots";
-import { tooltipRequest } from "../src/components/ui/tooltip";
/** Intrinsic elements whose `title` the platform needs. */
const TITLE_ALLOWED_ON = new Set(["iframe"]);
@@ -231,31 +231,3 @@ describe("native title tooltips", () => {
).toEqual([]);
});
});
-
-describe("a data-tooltip request", () => {
- const el = (attrs: Record<string, string>) => ({
- getAttribute: (name: string) => attrs[name] ?? null,
- });
-
- it("reads the text, the kind and the side, defaulting to a label below", () => {
- expect(tooltipRequest(el({ "data-tooltip": "Rename" }))).toEqual({
- label: "Rename",
- content: "label",
- placement: "bottom",
- });
- expect(
- tooltipRequest(
- el({
- "data-tooltip": "npm run dev",
- "data-tooltip-content": "code",
- "data-tooltip-placement": "right",
- }),
- ),
- ).toEqual({ label: "npm run dev", content: "code", placement: "right" });
- });
-
- it("asks for nothing when the text is missing or blank", () => {
- expect(tooltipRequest(el({}))).toBeNull();
- expect(tooltipRequest(el({ "data-tooltip": " " }))).toBeNull();
- });
-});
diff --git a/packages/web/test/notice-chart-hooks.test.ts b/packages/web/test/notice-chart-hooks.test.ts
index 59e8cca1..e3944a70 100644
--- a/packages/web/test/notice-chart-hooks.test.ts
+++ b/packages/web/test/notice-chart-hooks.test.ts
@@ -1,19 +1,28 @@
/**
- * The notice and chart hooks on the real app: every notice strip renders through NoticeStrip
- * (so it carries `ui-notice` and a `data-tone` in the hook's words), toasts carry the same hook,
- * and the charts' roots carry `ui-chart` with their parts named by literal `data-part` values.
+ * The notice and chart hooks on the real app: every notice renders through the package's
+ * NoticeStrip (so it carries `ui-notice` and a `data-tone` in the hook's words), the toast
+ * included, a mark a call site draws before a notice's text sits in its icon slot, and the charts'
+ * roots carry `ui-chart` with their parts named by literal `data-part` values.
*/
import ts from "typescript";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
-import { NOTICE_TONE, NoticeStrip } from "../src/components/ui/notice-strip";
-import { scanSources, sourceFile } from "./helpers/roots";
+import { NOTICE_TONE, NoticeStrip, ToastStack } from "@prismshadow/penguin-ui";
+import { expectSingleHome, scanSources, sourceFile } from "./helpers/roots";
const SCAN = scanSources();
const text = (id: string) => sourceFile(SCAN, `packages/web/src/${id}`).text;
+const NOTICE_STRIP = "packages/ui/src/components/feedback/notice/notice-strip.tsx";
+const TOASTER = "packages/ui/src/components/overlays/toaster/toaster.tsx";
+
describe("notices", () => {
+ it("live in the shared UI package, one copy each", () => {
+ expectSingleHome(SCAN, NOTICE_STRIP);
+ expectSingleHome(SCAN, TOASTER);
+ });
+
it("render the hook with the tone in the hook's words", () => {
const html = renderToStaticMarkup(
createElement(NoticeStrip, { tone: "attention", className: "px-3" }, "Heads up"),
@@ -25,14 +34,21 @@ describe("notices", () => {
);
});
- it("go through NoticeStrip, and toasts carry the hook too", () => {
- const inline = SCAN.files
- .filter((file) => file.root === "web" && file.name.endsWith(".tsx"))
- .filter((file) => !file.id.endsWith("components/ui/notice-strip.tsx"))
- .filter((file) => /toneStrip[.[]/.test(file.text.replace(/\/\*[\s\S]*?\*\//g, "")))
+ it("go through NoticeStrip, the toast included", () => {
+ // The strip is the one place a notice's box is spelled: no other file writes the hook.
+ const own = SCAN.files
+ .filter((file) => file.name.endsWith(".tsx") && file.id !== NOTICE_STRIP)
+ .filter((file) => /\bui-notice\b/.test(file.text.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "")))
.map((file) => file.id);
- expect(inline).toEqual([]);
- expect(text("components/ui/toast.tsx")).toContain("ui-notice");
+ expect(own).toEqual([]);
+ const html = renderToStaticMarkup(
+ createElement(ToastStack, {
+ items: [{ id: 1, kind: "error", text: "Connection failed" }],
+ onDismiss: () => {},
+ }),
+ );
+ expect(html).toContain("ui-notice");
+ expect(html).toContain('data-tone="danger"');
});
});
@@ -93,9 +109,7 @@ function unslottedMarks(file: { path: string; text: string; id: string }): strin
describe("a notice's own mark", () => {
it("sits in the icon slot, so a theme that draws its own can hide it", () => {
- const hits = SCAN.files
- .filter((file) => file.root === "web" && file.name.endsWith(".tsx"))
- .flatMap(unslottedMarks);
+ const hits = SCAN.files.filter((file) => file.name.endsWith(".tsx")).flatMap(unslottedMarks);
expect(hits).toEqual([]);
});
diff --git a/packages/web/test/stream-selection-menu.test.ts b/packages/web/test/stream-selection-menu.test.ts
index 6e35783c..8e3d55db 100644
--- a/packages/web/test/stream-selection-menu.test.ts
+++ b/packages/web/test/stream-selection-menu.test.ts
@@ -27,8 +27,8 @@ import { en } from "../src/lib/strings-en";
/** Toasts raised during a test (the real store would leave its dismiss timers running). */
const toasts = vi.hoisted(() => [] as string[]);
-vi.mock("../src/components/ui/toast", async (importOriginal) => {
- const actual = await importOriginal<typeof import("../src/components/ui/toast")>();
+vi.mock("@prismshadow/penguin-ui", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@prismshadow/penguin-ui")>();
return {
...actual,
toastSuccess: (text: string) => {
@@ -61,7 +61,7 @@ const EXCERPT = "Run the migration first.\nThen restart the server so it picks u
/** A selection as the stream captures it: the text as selected (a trailing newline included). */
const SELECTION: CapturedSelection = { text: `${EXCERPT}\n`, range: {} as Range };
-type Row = ReactElement<{ onClick: () => void; children: ReactNode }>;
+type Row = ReactElement<{ onSelect: () => void; label: ReactNode }>;
/** The rows as the component returns them, to reach their click handlers. */
function rows(props: Parameters<typeof SelectionMenuRows>[0]): Row[] {
@@ -75,12 +75,8 @@ function linkRows(props: Parameters<typeof LinkMenuRows>[0]): Row[] {
return ([] as ReactNode[]).concat(fragment.props.children).filter(isValidElement) as Row[];
}
-/** A row's visible label: its text children, without the glyph. */
-const label = (row: Row) =>
- ([] as ReactNode[])
- .concat(row.props.children)
- .filter((child): child is string => typeof child === "string")
- .join("");
+/** A row's visible label (the Menu row's own prop; the glyph is a separate one). */
+const label = (row: Row) => row.props.label;
afterEach(() => {
setActiveStrings(zh);
@@ -99,8 +95,8 @@ describe("SelectionMenuRows", () => {
onDone: () => {},
}),
);
- const copy = html.indexOf(`${S.common.copy}</button>`);
- const add = html.indexOf(`${S.files.addToChat}</button>`);
+ const copy = html.indexOf(`>${S.common.copy}</span>`);
+ const add = html.indexOf(`>${S.files.addToChat}</span>`);
expect(copy).toBeGreaterThan(-1);
expect(add).toBeGreaterThan(copy);
});
@@ -114,8 +110,8 @@ describe("SelectionMenuRows", () => {
onDone: () => {},
}),
);
- expect(html).toContain("Copy</button>");
- expect(html).toContain("Add to conversation</button>");
+ expect(html).toContain(">Copy</span>");
+ expect(html).toContain(">Add to conversation</span>");
});
});
@@ -133,7 +129,7 @@ describe("Add to conversation", () => {
const add = rows({ selection: SELECTION, onAddExcerpt: control.addReference, onDone }).find(
(row) => label(row) === S.files.addToChat,
);
- add!.props.onClick();
+ add!.props.onSelect();
// One reference, carried into the message as a blockquote; the draft itself is never filled.
expect(staged).toEqual([
@@ -168,7 +164,7 @@ describe("Copy", () => {
const copy = rows({ selection: SELECTION, onAddExcerpt: () => {}, onDone }).find(
(row) => label(row) === S.common.copy,
);
- copy!.props.onClick();
+ copy!.props.onSelect();
expect(writeClipboard).toHaveBeenCalledExactlyOnceWith(SELECTION.text);
expect(onDone).toHaveBeenCalledExactlyOnceWith(SELECTION);
@@ -181,7 +177,7 @@ describe("Copy", () => {
const copy = rows({ selection: SELECTION, onAddExcerpt: () => {}, onDone }).find(
(row) => label(row) === S.common.copy,
);
- copy!.props.onClick();
+ copy!.props.onSelect();
await writeClipboard.mock.results[0]?.value;
await Promise.resolve();
@@ -206,7 +202,7 @@ describe("LinkMenuRows", () => {
S.chat.linkMenu.openInBuiltinBrowser,
S.chat.linkMenu.openExternal,
S.chat.linkMenu.copyLink,
- ].map((name) => html.indexOf(`${name}</button>`));
+ ].map((name) => html.indexOf(`>${name}</span>`));
expect(at.every((i) => i > -1)).toBe(true);
expect([...at].sort((a, b) => a - b)).toEqual(at);
});
@@ -222,8 +218,8 @@ describe("LinkMenuRows", () => {
);
expect(html).not.toContain(S.chat.linkMenu.openInBuiltinBrowser);
expect(html).not.toContain(S.chat.linkMenu.openExternal);
- expect(html).toContain(`${S.chat.linkMenu.openInNewTab}</button>`);
- expect(html).toContain(`${S.chat.linkMenu.copyLink}</button>`);
+ expect(html).toContain(`>${S.chat.linkMenu.openInNewTab}</span>`);
+ expect(html).toContain(`>${S.chat.linkMenu.copyLink}</span>`);
});
it("follows the UI language", () => {
@@ -236,9 +232,9 @@ describe("LinkMenuRows", () => {
onDone: () => {},
}),
);
- expect(html).toContain("Open in built-in browser</button>");
- expect(html).toContain("Open in system browser</button>");
- expect(html).toContain("Copy link address</button>");
+ expect(html).toContain(">Open in built-in browser</span>");
+ expect(html).toContain(">Open in system browser</span>");
+ expect(html).toContain(">Copy link address</span>");
});
it("opens the link in the built-in browser through the browser's own new tab", () => {
@@ -246,7 +242,7 @@ describe("LinkMenuRows", () => {
const row = linkRows({ href: HREF, builtinBrowser: true, desktopShell: true, onDone }).find(
(r) => label(r) === S.chat.linkMenu.openInBuiltinBrowser,
);
- row!.props.onClick();
+ row!.props.onSelect();
expect(openedInBrowser).toEqual([HREF]);
expect(onDone).toHaveBeenCalledOnce();
});
@@ -258,7 +254,7 @@ describe("LinkMenuRows", () => {
const row = linkRows({ href: HREF, builtinBrowser: false, desktopShell: true, onDone }).find(
(r) => label(r) === S.chat.linkMenu.openExternal,
);
- row!.props.onClick();
+ row!.props.onSelect();
expect(open).toHaveBeenCalledExactlyOnceWith(HREF, "_blank", "noopener,noreferrer");
expect(openedInBrowser).toEqual([]);
expect(onDone).toHaveBeenCalledOnce();
@@ -270,7 +266,7 @@ describe("LinkMenuRows", () => {
const row = linkRows({ href: HREF, builtinBrowser: true, desktopShell: true, onDone }).find(
(r) => label(r) === S.chat.linkMenu.copyLink,
);
- row!.props.onClick();
+ row!.props.onSelect();
expect(writeClipboard).toHaveBeenCalledExactlyOnceWith(HREF);
expect(onDone).toHaveBeenCalledOnce();
await vi.waitFor(() => expect(toasts).toEqual([S.common.copied]));
diff --git a/packages/web/test/tone.test.ts b/packages/web/test/tone.test.ts
index 9cf66b5e..b3cee1b6 100644
--- a/packages/web/test/tone.test.ts
+++ b/packages/web/test/tone.test.ts
@@ -5,7 +5,7 @@
* in one file and `amber-500` in the next for the same "waiting" state.
*/
import { describe, expect, it } from "vitest";
-import { toneDot, toneInk, toneStrip, toneSurface } from "../src/lib/tone";
+import { toneDot, toneInk, toneSurface } from "../src/lib/tone";
import type { Tone } from "../src/lib/tone";
import { expectEveryRootScanned, expectSingleHome, scanSources, sourceFile } from "./helpers/roots";
@@ -36,7 +36,7 @@ describe("tone tokens", () => {
});
it("covers every tone in every map", () => {
- for (const map of [toneInk, toneSurface, toneDot, toneStrip]) {
+ for (const map of [toneInk, toneSurface, toneDot]) {
for (const tone of TONES) expect(map[tone]).toBeTruthy();
expect(Object.keys(map).sort()).toEqual([...TONES].sort());
}
diff --git a/packages/web/test/tooltip-geometry.test.ts b/packages/web/test/tooltip-geometry.test.ts
deleted file mode 100644
index a8d26f4c..00000000
--- a/packages/web/test/tooltip-geometry.test.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Where the styled Tooltip (src/components/ui/tooltip.tsx) hangs its panel, and how wide the
- * panel may grow before it would leave the screen.
- *
- * The panel is pinned by one horizontal edge and grows away from it, so the only width it can
- * safely take is the room between that edge and the viewport margin on the far side. A long
- * text — a background process's command, shown whole — wraps at that room instead of running
- * off a phone's screen; a short label never reaches it.
- */
-import { describe, expect, it } from "vitest";
-import { belowTrigger, besideTrigger } from "../src/components/ui/tooltip";
-
-const VIEWPORT = { width: 1000, height: 800 };
-
-/** A trigger box from its left/top corner and size. */
-const box = (left: number, top: number, width: number, height: number) => ({
- left,
- top,
- width,
- height,
- right: left + width,
- bottom: top + height,
-});
-
-describe("belowTrigger", () => {
- it("anchors by the right edge in the right half, with the room reaching back to the left margin", () => {
- // A command line near the right of the window: the panel grows leftward from its right edge.
- expect(belowTrigger(box(700, 100, 200, 20), VIEWPORT)).toEqual({
- top: 128,
- right: 100,
- room: 892,
- });
- });
-
- it("anchors by the left edge in the left half, with the room reaching to the right margin", () => {
- // A phone-width card: the room, not the panel's own cap, is what keeps the text on screen.
- expect(belowTrigger(box(40, 100, 200, 20), { width: 390, height: 800 })).toEqual({
- top: 128,
- left: 40,
- room: 342,
- });
- });
-
- it("keeps the anchored edge inside the viewport margin", () => {
- expect(belowTrigger(box(900, 0, 100, 20), VIEWPORT).right).toBe(8);
- expect(belowTrigger(box(-20, 0, 100, 20), VIEWPORT).left).toBe(8);
- });
-});
-
-describe("besideTrigger", () => {
- it("hangs to the right of a rail entry, centred on it, with the room to the right margin", () => {
- expect(besideTrigger(box(8, 200, 32, 32), VIEWPORT)).toEqual({ top: 216, left: 48, room: 944 });
- });
-
- it("clamps the centre into the viewport and never reports negative room", () => {
- const offscreen = besideTrigger(box(990, 900, 32, 32), VIEWPORT);
- expect(offscreen.top).toBe(792);
- expect(offscreen.room).toBe(0);
- });
-});
diff --git a/packages/web/test/tooltip-rule.test.ts b/packages/web/test/tooltip-rule.test.ts
deleted file mode 100644
index 5a1dbbca..00000000
--- a/packages/web/test/tooltip-rule.test.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * The tooltip rule (components/ui/tooltip.tsx): a hint shows for an element with no visible
- * text of its own, or one whose visible text is cut off — never for a label the reader can
- * already read in full.
- */
-import { describe, expect, it } from "vitest";
-import { hintAllowed, isCutOff } from "../src/components/ui/tooltip";
-
-const box = (scrollWidth: number, clientWidth: number, scrollHeight = 16, clientHeight = 16) => ({
- scrollWidth,
- clientWidth,
- scrollHeight,
- clientHeight,
-});
-
-describe("isCutOff", () => {
- it("reads overflow on either axis as cut off", () => {
- expect(isCutOff(box(240, 120))).toBe(true);
- expect(isCutOff(box(100, 100, 40, 20))).toBe(true);
- });
-
- it("forgives the pixel of overflow layout reports for text that fits", () => {
- expect(isCutOff(box(101, 100, 17, 16))).toBe(false);
- expect(isCutOff(box(100, 100))).toBe(false);
- });
-});
-
-describe("hintAllowed", () => {
- it("shows the hint of an element with no text of its own (an icon, a chart mark)", () => {
- expect(hintAllowed("", [box(24, 24)])).toBe(true);
- expect(hintAllowed(" ", [])).toBe(true);
- });
-
- it("shows the hint when the visible text is cut off anywhere inside", () => {
- expect(hintAllowed("A very long Session title", [box(200, 200), box(320, 180)])).toBe(true);
- });
-
- it("shows no hint for text that is fully visible, whatever the hint would add", () => {
- expect(hintAllowed("3 min ago", [box(60, 60), box(58, 60)])).toBe(false);
- expect(hintAllowed("Copy prompt", [])).toBe(false);
- });
-});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e57f7be1..5d4b309e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -499,6 +499,9 @@ importers:
'@fontsource/ibm-plex-sans-condensed':
specifier: ^5.3.0
version: 5.3.0
+ zustand:
+ specifier: ^5.0.15
+ version: 5.0.15(@types/[email protected])([email protected])
devDependencies:
'@types/node':
specifier: ^24.0.0
diff --git a/scripts/ui-migrate.json b/scripts/ui-migrate.json
index 4ae00730..1532c5c6 100644
--- a/scripts/ui-migrate.json
+++ b/scripts/ui-migrate.json
@@ -393,6 +393,200 @@
"names": ["SectionShell→SettingsSection"]
}
]
+ },
+ "W3": {
+ "packages/web/src/components/ui/modal": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/modal/modal.tsx",
+ "names": ["Modal", "ModalProps"]
+ },
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/esc-layers/esc-layers.ts",
+ "names": [
+ "pushEscLayer",
+ "popEscLayer",
+ "isTopEscLayer",
+ "FOCUSABLE_SELECTOR",
+ "nextFocusIndex",
+ "useDialogLayer"
+ ]
+ }
+ ],
+ "packages/web/src/components/ui/confirm-modal": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/confirm-modal/confirm-modal.tsx",
+ "names": ["ConfirmModal"]
+ },
+ {
+ "owner": "W3-B",
+ "target": "packages/web/src/features/agents/save-confirm",
+ "dest": "packages/web/src/features/agents/save-confirm.tsx",
+ "names": ["useSaveConfirm"]
+ }
+ ],
+ "packages/web/src/components/ui/paged-dialog": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/paged-dialog/paged-dialog.tsx",
+ "names": ["PagedDialog", "PagedDialogItem", "PagedDialogGroup"]
+ }
+ ],
+ "packages/web/src/components/ui/drawer": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/drawer/drawer.tsx",
+ "names": ["Drawer", "DrawerProps"]
+ }
+ ],
+ "packages/web/src/components/ui/sheet": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/drawer/sheet.tsx",
+ "names": ["Sheet", "SheetProps", "SheetSnap"]
+ }
+ ],
+ "packages/web/src/components/ui/image-zoom": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/lightbox/lightbox.tsx",
+ "names": ["ZoomableImage"]
+ }
+ ],
+ "packages/web/src/lib/spring": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/motion/spring.ts",
+ "names": [
+ "SPRING_DEFAULT",
+ "SPRING_MOMENTUM",
+ "stepSpring",
+ "isSettled",
+ "createSpringDriver",
+ "SpringConfig",
+ "SpringDriver"
+ ]
+ }
+ ],
+ "packages/web/src/lib/sheet-physics": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/motion/sheet-physics.ts",
+ "names": ["project", "rubberband", "nearestSnap"]
+ }
+ ],
+ "packages/web/src/components/ui/use-reduced-motion": [
+ {
+ "owner": "W3-B",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/motion/use-reduced-motion.ts",
+ "names": ["usePrefersReducedMotion"]
+ }
+ ],
+ "packages/web/src/components/ui/dropdown": [
+ {
+ "owner": "W3-A",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/dropdown/dropdown.tsx",
+ "names": ["Dropdown", "DropdownPortal"]
+ }
+ ],
+ "packages/web/src/components/ui/form-picker": [
+ {
+ "owner": "W3-A",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/forms/select/form-picker.tsx",
+ "names": ["FormPicker"]
+ }
+ ],
+ "packages/web/src/components/ui/context-menu": [
+ {
+ "owner": "W3-A",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/portal-panel/use-row-context-menu.ts",
+ "names": ["useRowContextMenu", "RowContextMenu", "ContextMenuRowProps"]
+ }
+ ],
+ "packages/web/src/lib/context-menu": [
+ {
+ "owner": "W3-A",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/portal-panel/context-menu.ts",
+ "names": [
+ "AnchorRect",
+ "ContextMenuEventLike",
+ "Point",
+ "pointerAnchor",
+ "isPointerContextMenu",
+ "contextMenuAnchor",
+ "isContextMenuKey",
+ "LONG_PRESS_MS",
+ "LONG_PRESS_SLOP_PX",
+ "LONG_PRESS_SETTLE_MS",
+ "isLongPressPointer",
+ "longPressMoved",
+ "withinSettleWindow",
+ "HoldState",
+ "IDLE_HOLD",
+ "HoldEvent",
+ "HoldOutcome",
+ "reduceHold"
+ ]
+ }
+ ],
+ "packages/web/src/components/ui/tooltip": [
+ {
+ "owner": "W3-A",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/tooltip/tooltip.tsx",
+ "names": [
+ "Tooltip",
+ "TooltipLayer",
+ "TooltipPlacement",
+ "TooltipContent",
+ "TOOLTIP_ATTR",
+ "ClipBox",
+ "isCutOff",
+ "hintAllowed",
+ "hintAllowedFor",
+ "TriggerRect",
+ "Viewport",
+ "PanelPosition",
+ "besideTrigger",
+ "belowTrigger",
+ "TooltipRequest",
+ "tooltipRequest",
+ "namedHint"
+ ]
+ }
+ ],
+ "packages/web/src/components/ui/toast": [
+ {
+ "owner": "W3-C",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/overlays/toaster/toaster.tsx",
+ "names": ["Toaster", "toastSuccess", "toastError", "toastInfo", "toastAttention"]
+ }
+ ],
+ "packages/web/src/components/ui/notice-strip": [
+ {
+ "owner": "W3-C",
+ "target": "@prismshadow/penguin-ui",
+ "dest": "packages/ui/src/components/feedback/notice/notice-strip.tsx",
+ "names": ["NoticeStrip", "NOTICE_TONE", "NoticeTone"]
+ }
+ ]
}
}
}