fix(webui): honor native host chrome

This commit is contained in:
Xubin Ren committed 2026-09-03 13:38:21 +08:00
1 parent fd67f5594c
commit ea57b80fb5
2 files changed
+40 -5

No files matched your search

+28
View File
@@ -310,6 +310,7 @@ describe("App layout", () => {
sessionUpdateHandlers.clear();
sidebarStateUpdateHandlers.clear();
window.history.replaceState(null, "", "/");
Reflect.deleteProperty(window, "nanobotHost");
setNavigatorPlatform("Linux x86_64");
localStorage.removeItem("nanobot-webui.sidebar");
localStorage.removeItem("nanobot-webui.sidebar.completed-runs.v1");
@@ -335,6 +336,7 @@ describe("App layout", () => {
afterEach(() => {
cleanup();
Reflect.deleteProperty(window, "nanobotHost");
vi.useRealTimers();
vi.unstubAllGlobals();
});
@@ -1655,6 +1657,32 @@ describe("App layout", () => {
await waitFor(() => expect(flowSidebar).toHaveStyle({ width: "272px" }));
});
it("uses native chrome when the host bridge overrides browser gateway metadata", async () => {
Reflect.set(window, "nanobotHost", { pickFolder: vi.fn() });
vi.mocked(fetchBootstrap).mockResolvedValue({
token: "tok",
api_token: "api-tok",
ws_path: "/",
expires_in: 300,
runtime_surface: "browser",
});
mockFetchRoutes({
"/api/settings": {
...baseSettingsPayload(),
surface: "browser",
runtime_surface: "browser",
},
});
render(<App />);
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
await waitFor(() => {
expect(screen.getByTestId("sidebar-brand-mark")).toHaveClass("mt-5");
});
expect(document.documentElement).toHaveClass("native-host");
});
it("switches to the next session when deleting the active chat", async () => {
mockSessions = [
{