A local-first multi-agent app development platform, built on PenguinHarness
feat(web,ui): the permission menu leads each row with its level's shield (上游 #1007 移植)
lmliheng51a79a020bb5
diff --git a/changelog/unreleased/2026-10-10-ui-polish-batch.md b/changelog/unreleased/2026-10-10-ui-polish-batch.mdnew file mode 100644index 00000000..f6695548--- /dev/null+++ b/changelog/unreleased/2026-10-10-ui-polish-batch.md@@ -0,0 +1,18 @@+# Permission menu icons, no thinking-level footnote, and the Trace tab and file editor held to their width++- **Date:** 2026-10-10+- **Type:** fix+- **Scope:** `web`, `ui`++[中文版](2026-10-10-ui-polish-batch.zh.md)++This is ported from upstream PenguinHarness (#1007, commit `2604c5d2`), one part left out: the change that held the UI package's fold body to the fold's width, since this tree has no `Fold` component.++Four Web App touches: each row of the composer's permission menu was led by its level's shield, the session thinking-level menu lost its footnote, the Trace tab stopped cutting its rounds and its summary off on the right, and pressing Edit on a file stopped rewrapping its text.++## Details++- Each row of the composer's permission menu (the presets, or the approval modes while the Sandbox switch is off) showed, before its name, the shield the permission button takes once that row is picked, in the button's tone: amber for full access and partial permission, told apart by the glyph, green for read-only and muted for off. An unavailable row dimmed its shield with it. An administrator's **More…** row took a gear, so its name lines up with the rows above it, and the menu's minimum width grew by about the shield's width, so the longest built-in row keeps its whole name beside a note such as "Admin only".+- The session composer's thinking-level menu no longer ended with "Applies right away. Changing it invalidates the model's cached context — compacting first is recommended." A mid-chat change still opens the confirm dialog that says what the switch costs and offers to compact first. The string left both dictionaries.+- The Trace tab's overall summary set its three groups side by side only where its own card is wide enough for every label and value, measured on the card (a container query) rather than on the viewport. In a dock beside the conversation the three columns had cut most of the values short; a card narrower than that stacks the groups instead. Upstream's other cause of a Trace round being clipped — the fold body's `min-w-0` — is not in this tree, which has no `Fold` component: an open round here is not widened by it.+- With wrapping on, the file editor's text layer and textarea took the scroll box's width. An unbreakable run, such as a long token or URL, had widened both layers to its own length, so pressing Edit rewrapped every line at that width and changed the text's height. Editing now wraps exactly where the source view does.diff --git a/changelog/unreleased/2026-10-10-ui-polish-batch.zh.md b/changelog/unreleased/2026-10-10-ui-polish-batch.zh.mdnew file mode 100644index 00000000..2616fa9a--- /dev/null+++ b/changelog/unreleased/2026-10-10-ui-polish-batch.zh.md@@ -0,0 +1,18 @@+# 权限菜单加图标、去掉思考等级脚注,轨迹面板与文件编辑器不再超出宽度++- **Date:** 2026-10-10+- **Type:** fix+- **Scope:** `web`, `ui`++[English](2026-10-10-ui-polish-batch.md)++移植自上游 PenguinHarness(#1007,提交 `2604c5d2`),有一处未取:把 UI 包的折叠内容区限制在折叠区自身宽度内的那处 —— 本树没有 `Fold` 组件。++Web App 的四处修整:输入框权限菜单的每一行在名称前加上所对应等级的盾牌图标;会话中的思考等级菜单去掉了脚注;轨迹面板中的轮次与全局统计不再在右侧被截断;对文件按下「编辑」不再重新折行。++## 细节++- 输入框权限菜单的每一行(各预设;沙盒开关关闭时为各审批模式)在名称前显示选中该行后权限按钮将呈现的盾牌图标,色调与按钮一致:完全访问与部分权限为琥珀色(以图标形状区分),只读为绿色,关闭为弱化色。不可选的行,图标随整行一同变淡。管理员可见的「更多…」一行加上齿轮图标,使其名称与上方各行对齐;菜单的最小宽度约增加了一个图标的宽度,最长的内置行在带有「仅管理员」等备注时仍能完整显示名称。+- 会话输入框的思考等级菜单底部不再显示「立即生效。更换思考等级会使模型缓存失效,建议先压缩上下文。」对话中途更换等级时仍会弹出确认框,说明切换的代价并提供先压缩的选项。该文案已从两份词典中删除。+- 轨迹面板的全局统计只在所在卡片宽到足以完整显示每组的标签与数值时才把三组并排,宽度按卡片本身判断(容器查询),不再按视口判断。此前在对话旁的停靠栏里,三栏并排会把大部分数值截断;卡片不够宽时,三组改为上下排列。上游让轨迹轮次不再被裁掉的另一个原因 —— 折叠内容区的 `min-w-0` —— 不在本树里:本树没有 `Fold` 组件,展开的轮次不会因它被撑宽。+- 开启自动换行时,文件编辑器的文字层与文本框都取滚动区的宽度。此前一段无法断开的长串(如很长的令牌或 URL)会把两层都撑到自身的长度,按下「编辑」后每一行都按这个宽度重新折行,文字高度随之改变。现在编辑时的折行位置与源码视图完全一致。diff --git a/packages/ui/src/components/content/prose/prose.css b/packages/ui/src/components/content/prose/prose.cssindex ae1a6fdf..fd47ef4d 100644--- a/packages/ui/src/components/content/prose/prose.css+++ b/packages/ui/src/components/content/prose/prose.css@@ -218,6 +218,14 @@.code-editor > * {grid-area: 1 / 1;}+/* Wrapped, the cell is exactly the box's width, as the source view's block is. An `auto` column+ would grow to its items' min-content width, and `overflow-wrap: break-word` leaves an+ unbreakable run (a long token, a URL) whole in that measure — so one such line would widen+ both layers past the box, and Edit would rewrap every line at that width and change the+ text's height. Unwrapped, the column keeps sizing to the longest line, as the pre does. */+.code-editor.code-wrap {+ grid-template-columns: minmax(0, 1fr);+}.code-editor textarea {overflow: hidden;resize: none;diff --git a/packages/web/src/features/chat/chat-input.tsx b/packages/web/src/features/chat/chat-input.tsxindex de540e13..a77a629f 100644--- a/packages/web/src/features/chat/chat-input.tsx+++ b/packages/web/src/features/chat/chat-input.tsx@@ -231,7 +231,6 @@ function ThinkingLevelSelect({onChange,disabled,direction = "down",- note,}: {/** Level to display and mark selected ("" = none to show yet); null = the Agent config is still loading (draft). */value: string | null;@@ -239,8 +238,6 @@ function ThinkingLevelSelect({disabled: boolean;/** Popup direction: down for the draft card (room below), up for the bottom-docked session composer. */direction?: "down" | "up";- /** Footnote under the rows — the session variant's pre-pick reminder: a change applies right away but invalidates the model's cached context, so compacting first is recommended. */- note?: string;}) {const label =value === null ? "…" : (thinkingLevelLabel(S.chat.thinkingLevelNames, value) ?? "—");@@ -266,7 +263,6 @@ function ThinkingLevelSelect({options={options}value={value}onChange={onChange}- note={note}direction={direction}align="right"/>@@ -761,8 +757,8 @@ export function ChatInput({* user's pick for this session, else the Agent config's level" ("" = neither known yet),* so the picker auto-follows the config until touched. A pick is the parent's own state:* it pins the level on the Session (PATCH), and core applies it from the next LLM request- * (soft-limited; the menu note advises compacting first); nothing rides a task. Never- * written through to the Agent config (that behavior stays draft-only).+ * (soft-limited; a pick mid-chat is confirmed first, offering to compact); nothing rides a+ * task. Never written through to the Agent config (that behavior stays draft-only).*/turnThinkingLevel?: string;/** Session state: pins the thinking level on this session (effective from its next LLM request); also enables the editable picker. */@@ -2519,16 +2515,15 @@ export function ChatInput({{/* Session state: the Session's pinned thinking level (editable) — displays theuser's pick, else the Agent config's level (auto-follow; the parent resolvesit). A pick is pinned on the Session (PATCH) and applies from the next LLM- request (soft-limited): the menu's footnote reminds, before the pick, that the- change costs the model's cached context and compacting first is recommended —- never writing through to the Agent config. */}+ request (soft-limited): a pick mid-chat goes through the parent's confirm+ dialog, which says the change costs the model's cached context and offers to+ compact first — never writing through to the Agent config. */}{!onChangeModel && onChangeTurnThinkingLevel && (<ThinkingLevelSelectvalue={turnThinkingLevel ?? ""}onChange={onChangeTurnThinkingLevel}disabled={busy}direction="up"- note={S.chat.thinkingLevelChangeNote}/>)}{/* Left of the send button: the model selector. In draft state it picks the model thediff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsxindex 88d5eb64..1a3519ae 100644--- a/packages/web/src/features/chat/chat-page.tsx+++ b/packages/web/src/features/chat/chat-page.tsx@@ -655,8 +655,8 @@ export function ChatPage() {// applyTurnThinkingLevel): "" = never pinned, and the picker then displays the Agent// config's level (auto-follow — each model context reads the config, so Agent-config edits// keep taking effect). A pin is DURABLE: it survives a reload, shows up in a second tab,- // and core applies it from the Session's next LLM request on (soft-limited — the picker's- // menu advises compacting first, since the change invalidates the model's cached+ // and core applies it from the Session's next LLM request on (soft-limited — a pick mid-chat+ // is confirmed first, offering to compact, since the change invalidates the model's cached// context). It is still never written through to the Agent config (that stays draft-only).const turnThinkingLevel = selected?.thinkingLevel ?? "";// The Agent list may not carry this Session's Agent yet (an Agent an organization created@@ -1512,9 +1512,9 @@ export function ChatPage() {// Pins a picked level on the Session so it outlives this tab: PATCH, then swap the// returned row into the session store (the picker reads it back from there); it applies- // from the next LLM request (the picker's menu advises compacting first). Modeled on- // onChangePermission — a failed write surfaces as a toast and leaves the level as it- // was, rather than showing a level the server does not have.+ // from the next LLM request (a pick mid-chat reaches here through the confirm dialog, which+ // offers to compact first). Modeled on onChangePermission — a failed write surfaces as a+ // toast and leaves the level as it was, rather than showing a level the server does not have.const applyTurnThinkingLevel = useCallback((level: string) => {if (!selected) return;diff --git a/packages/web/src/features/chat/permission-select.tsx b/packages/web/src/features/chat/permission-select.tsxindex 1d7bd778..71619bd5 100644--- a/packages/web/src/features/chat/permission-select.tsx+++ b/packages/web/src/features/chat/permission-select.tsx@@ -2,9 +2,11 @@* The composer's permission button: an icon-only square like the + button, wearing lucide's* shield icon for the level (see lib/permission-level.ts) — a different icon per level, coloured* by it, so the level never depends on colour alone. The menu lists the server's sandbox presets- * that are in the menu — each a named mode, network level and approval mode — and, for an- * administrator, More…, which opens the Settings page's Sandbox card, where the presets are- * renamed, remapped and put in or out of the menu, and where the full settings stay.+ * that are in the menu — each a named mode, network level and approval mode, its name led by the+ * shield of the level it sets, so a row shows beforehand the mark the button takes once it is+ * picked — and, for an administrator, More…, which opens the Settings page's Sandbox card, where+ * the presets are renamed, remapped and put in or out of the menu, and where the full settings+ * stay.** A pick edits the Session's own policy and approval mode in one save: a Session keeps the* policy it was created with, so the Settings page only decides what NEW Sessions start from.@@ -15,7 +17,8 @@* (`aboveCeiling`), which the server would refuse: marked admin-only, unless it is the current one.** With the server's Sandbox switch off, new Sessions start unconfined and the menu lists the- * approval modes alone (permissionMenu); a pick changes only the approval mode.+ * approval modes alone (permissionMenu), each led by its level's shield the same way; a pick+ * changes only the approval mode.** The menu offers only presets whose approval mode is among the modes the composer passes in* (see approval-mode.ts): an organization's Session is not offered an `always-ask` preset unless@@ -33,6 +36,8 @@ import type {import {Dropdown,GlyphIcon,+ ICONS,+ ICON_SIZE,Menu,MenuItem,MenuRadioItem,@@ -46,6 +51,7 @@ import {approvalModePick,firstUnavailableBackend,matchPreset,+ menuRowLevel,permissionLevel,permissionMenu,presetBlock,@@ -54,19 +60,34 @@ import {presetsOf,sandboxSwitchOff,} from "../../lib/permission-level";-import type { PermissionPick, PresetBlock } from "../../lib/permission-level";+import type { PermissionLevel, PermissionPick, PresetBlock } from "../../lib/permission-level";import { useAuth } from "../../state/auth";import { useLocale } from "../../state/locale";import { localizedText } from "./skill-use";import { SettingsDialog } from "../settings/settings-dialog";/**- * One preset row: its name, and a check when it is the Session's level. Its tooltip says what- * it blocks and allows and whether this machine can enforce it; an unenforceable one stays- * listed, greyed out, with a short note.+ * A level's shield in the level's tone: the button's mark, and the mark ahead of each row's name.+ * Not decorative — the shape and the tone are the level, which the row's name does not say.+ */+function LevelGlyph({ level, size }: { level: PermissionLevel; size: number }) {+ return (+ <GlyphIcon+ d={PERMISSION_LEVEL_GLYPH[level]}+ size={size}+ className={toneInk[PERMISSION_LEVEL_TONE[level]]}+ />+ );+}++/**+ * One preset row: the shield of the level it sets, its name, and a check when it is the+ * Session's level. Its tooltip says what it blocks and allows and whether this machine can+ * enforce it; an unenforceable one stays listed, greyed out, with a short note.*/function Choice({label,+ level,selected,onPick,hint,@@ -74,6 +95,7 @@ function Choice({note,}: {label: string;+ level: PermissionLevel;selected: boolean;onPick: () => void;hint: string;@@ -82,6 +104,7 @@ function Choice({}) {return (<MenuRadioItem+ glyph={<LevelGlyph level={level} size={ICON_SIZE.inlineGlyph} />}label={label}checked={selected}disabled={unavailable}@@ -207,7 +230,10 @@ export function PermissionSelect({<Dropdownopen={open}setOpen={setOpen}- menuClass="w-max min-w-44"+ // A row's name does not widen a `w-max` panel (it sits in a `flex-1` column), so the+ // floor is what keeps the longest built-in row whole in Chinese: its shield, the+ // Workspace Write name, an "Admin only" note and the check.+ menuClass="w-max min-w-50"portal={{ direction, align: "left" }}button={<button@@ -224,11 +250,7 @@ export function PermissionSelect({>{/* Keyed by level: a new level mounts a new icon, which swaps in. */}<span key={level} className={animate ? "anim-icon-swap" : undefined}>- <GlyphIcon- d={PERMISSION_LEVEL_GLYPH[level]}- size={15}- className={toneInk[PERMISSION_LEVEL_TONE[level]]}- />+ <LevelGlyph level={level} size={ICON_SIZE.iconButton} /></span></button>}@@ -249,6 +271,9 @@ export function PermissionSelect({return (<MenuRadioItemkey={row.mode}+ glyph={+ <LevelGlyph level={menuRowLevel(row, sandbox)} size={ICON_SIZE.inlineGlyph} />+ }label={S.chat.approvalModeNames[row.mode] ?? row.mode}checked={row.mode === approvalMode}onSelect={() => pickMode(row.mode)}@@ -261,6 +286,7 @@ export function PermissionSelect({<Choicekey={p.id}label={nameOf(p)}+ level={menuRowLevel(row, sandbox)}selected={current?.id === p.id}hint={hintOf(p, block)}unavailable={block !== null}@@ -275,8 +301,18 @@ export function PermissionSelect({<><MenuSeparator />{/* More…: the presets table and the full settings (masked paths, the temp- directory, the backends) are on the Settings page's Sandbox card. */}+ directory, the backends) are on the Settings page's Sandbox card. Its gear keeps+ its name in the column the level rows' names start in — so it is a node, not a+ registry path: a path is drawn as a decorative mark, which a theme may drop+ (Console does), and the name would then step out of line. */}<MenuItem+ glyph={+ <GlyphIcon+ d={ICONS.gear}+ size={ICON_SIZE.inlineGlyph}+ className="text-fg-subtle"+ />+ }label={P.more}onSelect={() => {setOpen(false);diff --git a/packages/web/src/features/traces/trace-file-view.tsx b/packages/web/src/features/traces/trace-file-view.tsxindex e8d45a38..72656cf7 100644--- a/packages/web/src/features/traces/trace-file-view.tsx+++ b/packages/web/src/features/traces/trace-file-view.tsx@@ -574,14 +574,19 @@ export function TraceFileBody({{/* Global summary: split into three groups by nature (count / Tokenusage / duration·cost·TPS), separated by vertical rules — a dozenmetrics laid out in one row would read as a blur of digits; grouping lets you spot the kind you want at a glance. */}- <Card>+ <Card className="@container"><CardHeader title={S.traces.globalSummary} />{/* Three groups side by side as columns, each item within a grouptaking its own row (name on the left, value on the right): laidout in one row it's a blur of digits, while giving each group afull row only uses a small strip on the left and wastes the rest.- Splitting into columns fills the width and keeps it to three rows tall. */}- <div className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-3">+ Splitting into columns fills the width and keeps it to three rows tall.+ Side by side only where the card itself has the room — it is the container+ queried, not the viewport: the Trace tab is a dock panel, a few hundred pixels+ wide on a wide screen, where three columns cut every value short. `@2xl` leaves+ each column about a third wider than its longest label and value need; narrower,+ the groups stack. */}+ <div className="grid grid-cols-1 gap-x-6 gap-y-4 @2xl:grid-cols-3">{/* Counts */}<div>{/* Rounds = every round in the file (a compaction round counts asdiff --git a/packages/web/src/lib/permission-level.ts b/packages/web/src/lib/permission-level.tsindex 2c6082fc..7d57fee2 100644--- a/packages/web/src/lib/permission-level.ts+++ b/packages/web/src/lib/permission-level.ts@@ -1,7 +1,8 @@/**- * A Session's permission level, as the composer's button shows it: one colour for how much the- * Agent may do on its own. Derived from the two knobs that decide it — the approval mode, and- * the Session's sandbox policy — never stored.+ * A Session's permission level, as the composer's button shows it — and each row of its menu,+ * for the level that row's pick would set: one colour for how much the Agent may do on its own.+ * Derived from the two knobs that decide it — the approval mode, and the Session's sandbox+ * policy — never stored.** - `off`: every tool call is denied.* - `read-only`: commands cannot write anywhere.@@ -19,7 +20,10 @@ import type { Tone } from "./tone";export type PermissionLevel = "all" | "partial" | "read-only" | "off";-export function permissionLevel(approval: ApprovalMode, sandbox: SessionSandbox): PermissionLevel {+export function permissionLevel(+ approval: ApprovalMode,+ sandbox: Pick<SessionSandbox, "mode" | "network">,+): PermissionLevel {if (approval === "deny-all") return "off";if (sandbox.mode === "read-only") return "read-only";if (@@ -283,6 +287,20 @@ export function permissionMenu(}));}+/**+ * The level a menu row would leave the Session at, which the row wears before its name — the+ * mark the button takes once the row is picked: a preset's own three values, or (switch off) the+ * approval mode over the policy the Session keeps.+ */+export function menuRowLevel(+ row: PermissionMenuRow,+ sandbox: Pick<SessionSandbox, "mode" | "network">,+): PermissionLevel {+ return row.kind === "preset"+ ? permissionLevel(row.preset.approvalMode, row.preset)+ : permissionLevel(row.mode, sandbox);+}+/*** Why a preset cannot be picked: a `LevelBlock` (this server cannot enforce it), or* `above-ceiling` — wider than the server's sandbox settings, which only an administrator may godiff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex db51ed82..d66be05a 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -2675,8 +2675,6 @@ export const en: Strings = {},chat: {- thinkingLevelChangeNote:- "Applies right away. Changing it invalidates the model's cached context — compacting first is recommended.",newSessionMenu: "New chat",chooseAgent: "Choose agent",chooseModel: "Choose model",diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex dbab4a19..0c92b350 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2696,8 +2696,6 @@ export const zh = {},chat: {- /** Footnote of the session picker's menu — the pre-pick reminder: a change applies right away but costs the model's cached context, so compacting first is recommended. */- thinkingLevelChangeNote: "立即生效。更换思考等级会使模型缓存失效,建议先压缩上下文。",newSessionMenu: "新建对话",chooseAgent: "选择 Agent",chooseModel: "选择模型",diff --git a/packages/web/test/permission-level.test.ts b/packages/web/test/permission-level.test.tsindex 4c8bad51..c4669e0a 100644--- a/packages/web/test/permission-level.test.ts+++ b/packages/web/test/permission-level.test.ts@@ -6,22 +6,30 @@* sandbox limit makes it partial.* - It is read-only when commands cannot write, and off when every call is denied.* - Each level wears its own glyph, so the level never depends on colour alone.+ * - Each row of the menu wears, ahead of its name, the level the button takes once that row is+ * picked — a preset by its own values, an approval mode (switch off) over the policy the+ * Session keeps — whatever level the Session is at when the menu opens.*/import { describe, expect, it } from "vitest";import type { ApprovalMode, SessionSandbox } from "@lmliheng/penguin-server/api";import {BUILTIN_PRESETS,PERMISSION_LEVEL_GLYPH,+ approvalModePick,firstUnavailableBackend,fsModeBlock,matchPreset,menuPresets,+ menuRowLevel,networkBlock,permissionLevel,+ permissionMenu,presetBlock,presetEffects,+ presetPick,presetsOf,} from "../src/lib/permission-level";+import type { PermissionMenuRow } from "../src/lib/permission-level";import { APPROVAL_MODES, approvalModeChoices } from "../src/features/chat/approval-mode";const FULL: SessionSandbox = { mode: "danger-full-access", network: "open" };@@ -259,3 +267,25 @@ describe("the composer's presets", () => {expect(presetEffects({ ...byId("full-access"), network: "none" }).blocks).toEqual(["network"]);});});++describe("the mark ahead of each menu row", () => {+ /** The button's level once `row` is picked: its values laid over the Session's policy. */+ const levelAfterPick = (row: PermissionMenuRow, session: SessionSandbox) => {+ const pick = row.kind === "preset" ? presetPick(row.preset) : approvalModePick(row.mode);+ return permissionLevel(pick.approvalMode, { ...session, ...pick.sandbox });+ };++ it.each<[string, SessionSandbox]>([+ ["switch on, full access", { ...FULL, switchOn: true }],+ ["switch on, a read-only Session", { mode: "read-only", network: "none", switchOn: true }],+ ["switch off, unconfined", { ...FULL, switchOn: false }],+ [+ "switch off, a Session confined while it was on",+ { mode: "read-only", network: "open", switchOn: false },+ ],+ ])("with the %s, every row wears the level the button takes once it is picked", (_, session) => {+ const rows = permissionMenu(session, APPROVAL_MODES, null);+ expect(rows.length).toBeGreaterThan(0);+ for (const row of rows) expect(menuRowLevel(row, session)).toBe(levelAfterPick(row, session));+ });+});