fix(webui): name the gateway sandbox launcher in setup guidance

This commit is contained in:
Xubin Ren committed 2026-11-08 14:29:46 +08:00
1 parent f5e5bd6ea0
commit 44d567e37c
31 files changed
+230 -86

No files matched your search

+5 -3
View File
@@ -31,8 +31,8 @@ function tool(receive: (event: InboundEvent) => void, values: Partial<ToolProgre
describe("Live sandbox guidance", () => {
it.each([
["sandbox_path_unavailable", "Check its location and access permissions"],
["sandbox_start_failed", "Check the installation and system restrictions"],
["sandbox_path_unavailable", "Check its full path and access permissions"],
["sandbox_start_failed", "Check the gateway installation and system restrictions"],
])("explains the known launcher failure %s", (error_code, copy) => {
const { client, receive } = createStreamClient();
render(<Harness client={client} />);
@@ -56,8 +56,10 @@ describe("Live sandbox guidance", () => {
expect(screen.getByRole("status")).toHaveAttribute("aria-live", "polite");
expect(draft).toHaveFocus();
expect(draft).toHaveValue("Keep my draft");
expect(screen.getByRole("status")).toHaveTextContent("sandbox launcher");
expect(screen.getByRole("status")).not.toHaveTextContent(/bwrap|sandbox-exec/);
expect(onOpen).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "Check settings" }));
fireEvent.click(screen.getByRole("button", { name: "Open sandbox settings" }));
expect(onOpen).toHaveBeenCalledOnce();
});
+10 -3
View File
@@ -26,7 +26,7 @@ describe("Saved sandbox settings", () => {
it("checks saved configuration explicitly without changing the isolation policy", async () => {
const sandbox = open();
expect(sandbox.getByText(/Launcher not found/)).toBeVisible();
expect(sandbox.getByText(/Bubblewrap \(bwrap\) was not found on the gateway/)).toBeVisible();
expect(requestMutationMock).not.toHaveBeenCalled();
requestMutationMock.mockResolvedValue({ sandbox: {
...payload().advanced.exec_sandbox_status, state: "passed", reason: "", launcher: "/usr/bin/bwrap",
@@ -37,13 +37,20 @@ describe("Saved sandbox settings", () => {
expect(sandbox.getByText(/Restart the gateway/)).toBeVisible();
});
it("opens the launcher editor from a recovery link without editing or checking automatically", () => {
renderSettingsView({ initialSection: "advanced", initialSettings: payload(), webuiCapabilities: capability,
it.each([
["bwrap", "Bubblewrap (bwrap)"],
["seatbelt", "macOS Seatbelt (sandbox-exec)"],
] as const)("opens the gateway's %s path editor without editing or checking automatically", (backend, launcher) => {
const settings = payload();
settings.runtime_config!["tools.exec.sandbox"] = backend;
settings.advanced.exec_sandbox_status!.supported_backend = backend;
renderSettingsView({ initialSection: "advanced", initialSettings: settings, webuiCapabilities: capability,
focusTarget: "sandbox-launcher" });
const sandbox = within(screen.getByRole("region", { name: "Command sandbox" }));
expect(sandbox.getByRole("button", { name: "Advanced options" })).toHaveAttribute("aria-expanded", "true");
expect(sandbox.getByRole("textbox", { name: "Trusted launcher path" })).toHaveFocus();
expect(sandbox.getByRole("textbox", { name: "Trusted launcher path" })).toHaveValue("");
expect(sandbox.getByText(/Usually leave this blank for system lookup of/)).toHaveTextContent(launcher);
expect(requestMutationMock).not.toHaveBeenCalled();
});
+38
View File
@@ -1705,6 +1705,44 @@ describe("ThreadShell", () => {
expect(await screen.findByText("backup")).toBeInTheDocument();
});
it.each([
["bwrap", "MacIntel", "Bubblewrap (bwrap)", "Configure bwrap path"],
["seatbelt", "Linux x86_64", "macOS Seatbelt (sandbox-exec)", "Configure sandbox-exec path"],
] as const)("uses the gateway's %s launcher and links to its path editor", async (backend, browserPlatform, launcher, action) => {
const platform = vi.spyOn(navigator, "platform", "get").mockReturnValue(browserPlatform);
try {
const client = makeClient();
const openSettings = vi.fn();
const settings = modelSettings("test-model", "deepseek");
settings.advanced.exec_sandbox_status = {
state: "unavailable", reason: "launcher_missing", launcher: null,
revision: "gateway-launcher", supported_backend: backend,
};
render(wrap(client, <ThreadShell session={session("sandbox-notice")} title="Sandbox notice"
onToggleSidebar={() => {}} settingsSnapshot={settings} onOpenSandboxSettings={openSettings}
/>, undefined, "tok", ["webui.sandbox-settings.v1"]));
const input = await screen.findByRole("textbox");
fireEvent.change(input, { target: { value: "Keep my draft" } });
input.focus();
act(() => {
client._emitChat("sandbox-notice", { event: "user_message", chat_id: "sandbox-notice",
turn_id: "sandbox-turn", starts_turn: true, text: "Run a command" });
client._emitChat("sandbox-notice", { event: "message", chat_id: "sandbox-notice", text: "",
turn_id: "sandbox-turn", kind: "progress", tool_events: [{
name: "exec", phase: "error", error_code: "sandbox_launcher_missing", call_id: "sandbox-command",
}] });
});
const banner = (await screen.findByRole("button", { name: action })).closest<HTMLElement>('[role="status"]')!;
expect(banner).toHaveTextContent(launcher);
expect(input).toHaveFocus();
fireEvent.click(within(banner).getByRole("button", { name: action }));
expect(openSettings).toHaveBeenCalledWith("sandbox-launcher");
expect(input).toHaveValue("Keep my draft");
} finally {
platform.mockRestore();
}
});
it("shows a dismissible, session-scoped fallback notice without changing the composer preset", async () => {
const client = makeClient();
const openSettings = vi.fn();