fix(settings): align sandbox loading layouts for old and new hosts
This commit is contained in:
1 parent
5130f42901
commit
a666948509
5 files changed
+37
-12
No files matched your search
@@ -282,7 +282,7 @@ createRoot(document.getElementById("root")!).render(<TooltipProvider>
|
||||
: parameters.get("case") === "new-chat-skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><NewChatSkeletonFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton-additions"
|
||||
? <ClientProvider client={railClient} token="fixture"><SkeletonAdditionsFixture /></ClientProvider>
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={parameters.has("sandboxSettings") ? ["webui.sandbox-settings.v1"] : []}><SkeletonAdditionsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><SkeletonFixture surface={parameters.get("surface") ?? "skills"} loading={parameters.has("loading")} /></ClientProvider>
|
||||
: parameters.get("case") === "tools-catalog"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -773,7 +773,8 @@ export function SettingsPage({
|
||||
) : null}
|
||||
|
||||
{loading && !sectionReady ? (
|
||||
<SettingsSectionSkeleton section={activeSection} showRestart={!showSidebar} />
|
||||
<SettingsSectionSkeleton section={activeSection} showRestart={!showSidebar}
|
||||
sandboxSupported={webuiCapabilities.includes("webui.sandbox-settings.v1")} />
|
||||
) : error && !sectionReady ? (
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.status.loadError")}>
|
||||
|
||||
@@ -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 <div data-settings-skeleton-row className="settings-row">
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-32 max-w-full")} /></div>
|
||||
<div className="settings-control">
|
||||
{control === "feature" ? <div className={cn(block, "mr-3 h-3 w-14")} /> : null}
|
||||
{control === "idle-timeout" ? <div className="flex items-center gap-2">
|
||||
{control === "status" ? <StatusPill><span className="text-transparent">{t("settings.sandbox.states.off")}</span></StatusPill> : control === "idle-timeout" ? <div className="flex items-center gap-2">
|
||||
<div className={cn(block, "h-9 w-28 rounded-full")} /><div className={cn(block, "h-3 w-10")} />
|
||||
</div> : control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} className={cn(block,
|
||||
toggle ? "h-5 w-9 shrink-0 rounded-full" : control === "input" ? "h-9 w-full rounded-full"
|
||||
@@ -50,18 +51,34 @@ function ProxyGroup() {
|
||||
</SettingsGroup></section>;
|
||||
}
|
||||
|
||||
function RuntimeGroups({ page }: { page: RuntimeConfigPage }) {
|
||||
function SandboxGroup() {
|
||||
const { t } = useTranslation();
|
||||
return <section><Title /><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={
|
||||
|
||||
Reference in new issue
Block a user