fix(webui): support remote project paths and honor picker capabilities (#5673)

* fix(webui): honor remote workspace picker capability

* feat(webui): allow remote project path selection

* test(webui): isolate native picker availability from host platform
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-14 13:14:00 +08:00
1 parent 15976ac559
commit ddd6b302c9
9 files changed
+358 -44

No files matched your search

+56 -1
View File
@@ -1477,7 +1477,11 @@ describe("ThreadComposer", () => {
variant="hero"
workspaceScope={defaultScope}
workspaceDefaultScope={defaultScope}
workspaceControls={{ can_change_project: true, can_use_full_access: true }}
workspaceControls={{
can_change_project: true,
can_use_full_access: true,
can_pick_folder: true,
}}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
);
@@ -1494,6 +1498,57 @@ describe("ThreadComposer", () => {
}));
});
it("does not use a native host picker when the gateway disallows folder picking", async () => {
const user = userEvent.setup();
const onWorkspaceScopeChange = vi.fn();
const pickFolder = vi.fn().mockResolvedValue("/Users/test/native-project");
const onPickWorkspaceFolder = vi.fn().mockResolvedValue("/srv/nas-project");
const defaultScope = {
project_path: "/srv/nanobot/workspace",
project_name: "workspace",
access_mode: "full" as const,
restrict_to_workspace: false,
};
Object.defineProperty(window, "nanobotHost", {
configurable: true,
value: { pickFolder },
});
render(
<ThreadComposer
onSend={vi.fn()}
placeholder="Ask anything..."
variant="hero"
workspaceScope={defaultScope}
workspaceDefaultScope={defaultScope}
workspaceControls={{
can_change_project: true,
can_use_full_access: false,
can_pick_folder: false,
}}
onPickWorkspaceFolder={onPickWorkspaceFolder}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
);
await user.click(screen.getByRole("button", { name: "Choose project" }));
expect(await screen.findByLabelText("Paste path")).toBeInTheDocument();
expect(pickFolder).not.toHaveBeenCalled();
expect(onPickWorkspaceFolder).not.toHaveBeenCalled();
fireEvent.change(screen.getByLabelText("Paste path"), {
target: { value: "/srv/nas-project" },
});
fireEvent.click(screen.getByRole("button", { name: "Use Path" }));
expect(onWorkspaceScopeChange).toHaveBeenCalledWith(expect.objectContaining({
project_path: "/srv/nas-project",
access_mode: "restricted",
restrict_to_workspace: true,
}));
});
it("uses the gateway folder picker for a locally hosted WebUI", async () => {
const onWorkspaceScopeChange = vi.fn();
const pickFolder = vi.fn().mockResolvedValue("/Users/test/gateway-project");