From a666948509f2583cbabed6d7e180e5912cdfe0c0 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:14:40 +0800 Subject: [PATCH] fix(settings): align sandbox loading layouts for old and new hosts --- webui/browser/fixture.tsx | 2 +- webui/browser/skeleton-additions-fixture.tsx | 5 +++ webui/browser/skeleton-additions.spec.ts | 8 +++-- .../src/components/settings/SettingsPage.tsx | 3 +- .../shared/SettingsSectionSkeleton.tsx | 31 ++++++++++++++----- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index 508ed742e..b94bef670 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -282,7 +282,7 @@ createRoot(document.getElementById("root")!).render( : parameters.get("case") === "new-chat-skeleton" ? : parameters.get("case") === "skeleton-additions" - ? + ? : parameters.get("case") === "skeleton" ? : parameters.get("case") === "tools-catalog" diff --git a/webui/browser/skeleton-additions-fixture.tsx b/webui/browser/skeleton-additions-fixture.tsx index 6f59f655b..cb8cdc9be 100644 --- a/webui/browser/skeleton-additions-fixture.tsx +++ b/webui/browser/skeleton-additions-fixture.tsx @@ -45,6 +45,11 @@ const previewSettings: SettingsPayload = { ])), }; let detailState = "loaded"; +if (new URLSearchParams(location.search).has("sandboxSettings")) { + previewSettings.advanced.exec_sandbox_status = { + state: "off", reason: "", launcher: null, revision: "fixture", supported_backend: "bwrap", + }; +} export function installSkeletonPreviewApi() { // Windows headless Chromium can report denied even after a context permission grant. diff --git a/webui/browser/skeleton-additions.spec.ts b/webui/browser/skeleton-additions.spec.ts index 9af17291d..2b2e4049f 100644 --- a/webui/browser/skeleton-additions.spec.ts +++ b/webui/browser/skeleton-additions.spec.ts @@ -55,8 +55,9 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) { }); test("settings sections preserve their loaded row layout", async ({ page }, testInfo) => { - for (const section of ["notifications", "capabilities", "runtime", "advanced", "overview", "models", "about"]) { - const extra = `§ion=${section}${section === "notifications" ? "¬ificationPermission=granted" : ""}`; + for (const surface of ["notifications", "capabilities", "runtime", "advanced", "sandbox", "overview", "models", "about"]) { + const section = surface === "sandbox" ? "advanced" : surface; + const extra = `§ion=${section}${section === "notifications" ? "¬ificationPermission=granted" : ""}${surface === "sandbox" ? "&sandboxSettings" : ""}`; await page.goto(fixture("settings", "loaded", extra)); const target = page.locator("[data-settings-section]"); if (section === "notifications") { @@ -72,7 +73,8 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) { } if (section === "runtime") await expect(page.locator('[data-settings-section] button').filter({ hasText: locale === "en" ? "Start API server" : "启动 API 服务" })).toBeVisible(); await settle(page); - const selector = section === "overview" ? "section button.group" : section === "models" ? '[data-testid^="model-call-order-row"], .settings-footer' : section === "about" ? ".settings-list-row" : ".settings-row"; + // Collapsed options remain mounted for drafts but do not occupy the visible layout. + const selector = section === "overview" ? "section button.group" : section === "models" ? '[data-testid^="model-call-order-row"], .settings-footer' : section === "about" ? ".settings-list-row" : ".settings-row:not([inert] *)"; const notificationDetails = section === "notifications" ? ", .settings-list-inset > .border-t, section > p" : ""; const proxyForm = section === "advanced" ? ", [data-shared-proxy-editor]" : ""; const loaded = await boxes(target.locator(selector + notificationDetails + proxyForm)); diff --git a/webui/src/components/settings/SettingsPage.tsx b/webui/src/components/settings/SettingsPage.tsx index 095c6fcd5..bc4a9fe74 100644 --- a/webui/src/components/settings/SettingsPage.tsx +++ b/webui/src/components/settings/SettingsPage.tsx @@ -773,7 +773,8 @@ export function SettingsPage({ ) : null} {loading && !sectionReady ? ( - + ) : error && !sectionReady ? ( diff --git a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx index 4d733bda5..c6a63cf5a 100644 --- a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx +++ b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx @@ -3,12 +3,12 @@ import { useTranslation } from "react-i18next"; import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts"; import { AboutSettingsLayout } from "@/components/settings/overview/AboutSettingsView"; -import { SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls"; +import { SettingsGroup, SettingsRow, StatusPill } from "@/components/settings/shared/SettingsControls"; import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus"; import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields"; import { cn } from "@/lib/utils"; -type Control = "switch" | "input" | "duration" | "idle-timeout" | "segments" | "edit" | "text" | "feature"; +type Control = "switch" | "input" | "duration" | "idle-timeout" | "segments" | "edit" | "text" | "feature" | "status"; const block = "rounded bg-muted-foreground/20"; function Title({ heading = false }: { heading?: boolean }) { @@ -18,12 +18,13 @@ function Title({ heading = false }: { heading?: boolean }) { } function Row({ control }: { control: Control }) { + const { t } = useTranslation(); const toggle = control === "switch" || control === "feature"; return
{control === "feature" ?
: null} - {control === "idle-timeout" ?
+ {control === "status" ? {t("settings.sandbox.states.off")} : control === "idle-timeout" ?
: control === "duration" ?
:
; } -function RuntimeGroups({ page }: { page: RuntimeConfigPage }) { +function SandboxGroup() { + const { t } = useTranslation(); + return
<SettingsGroup> + <Row control="switch" /><Row control="input" /><Row control="status" /> + <div className="settings-list-inset pb-4 pt-1"> + <div className="flex items-start gap-2 text-ui leading-6"> + <div className={cn(block, "mt-1 h-4 w-4 shrink-0")} /> + <p className="text-transparent">{t("settings.sandbox.help.off")}</p> + </div> + <p className="mt-2 text-caption leading-5 text-transparent">{t("settings.sandbox.scope")}</p> + </div> + <div className="settings-list-inset flex min-h-12 items-center"><div className={cn(block, "h-3 w-24")} /></div> + </SettingsGroup></section>; +} + +function RuntimeGroups({ page, sandboxSupported = false }: { page: RuntimeConfigPage; sandboxSupported?: boolean }) { return <>{RUNTIME_CONFIG_GROUPS.filter((group) => group.page === page).map((group) => group.id === "chat" ? <Group key={group.id} controls={["switch", "segments"]} /> : group.id === "proxy" ? <ProxyGroup key={group.id} /> - : <Group key={group.id} controls={RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group.id && (!field.when || field.when.value === true)).flatMap<Control>((field) => + : group.id === "shell" && sandboxSupported ? <SandboxGroup key={group.id} /> + : <Group key={group.id} controls={RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group.id && field.path !== "tools.exec.sandbox_launcher" && (!field.when || field.when.value === true)).flatMap<Control>((field) => field.kind === "idle-compaction" ? ["switch", "idle-timeout"] : [ field.kind === "boolean" || field.kind === "toggle" ? "switch" : field.kind === "list" ? "edit" : field.kind === "duration" ? "duration" : "input", ], )} />)}</>; } -export function SettingsSectionSkeleton({ section, showRestart = false }: { section: SettingsSectionKey; showRestart?: boolean }) { +export function SettingsSectionSkeleton({ section, showRestart = false, sandboxSupported = false }: { section: SettingsSectionKey; showRestart?: boolean; sandboxSupported?: boolean }) { const { t } = useTranslation(); let content: ReactNode = null; if (isCapabilitySection(section)) content = <> @@ -105,7 +122,7 @@ export function SettingsSectionSkeleton({ section, showRestart = false }: { sect content = <><RuntimeGroups page="runtime" /><Group controls={["input", "segments", "input", "input"]} /><Group controls={["input"]} /><Group controls={showRestart ? ["text", "text", "input"] : ["text", "text"]} /></>; break; case "advanced": - content = <RuntimeGroups page="advanced" />; + content = <RuntimeGroups page="advanced" sandboxSupported={sandboxSupported} />; break; case "about": content = <AboutSettingsLayout starLink={null} versionCheck={