fix(webui): allow switching Default permissions back to Full Access (#6175)

* fix(webui): allow authenticated access mode switching

* refactor(webui): remove constant full access eligibility helpers

* refactor(webui): remove obsolete full access policy parameter

* docs(webui): remove redundant access switching paragraph

* refactor(webui): remove obsolete full access capability
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-12 15:39:33 +08:00
1 parent ae186cb18d
commit 73af08efab
14 files changed
+87 -204

No files matched your search

-1
View File
@@ -1218,7 +1218,6 @@ describe("webui API helpers", () => {
},
controls: {
can_change_project: true,
can_use_full_access: true,
},
};
vi.mocked(fetch).mockResolvedValueOnce({
+3 -3
View File
@@ -1077,7 +1077,7 @@ describe("App layout", () => {
schema_version: 1,
default_access_mode: "full",
default_scope: { ...projectScope, project_path: "/tmp/workspace", project_name: "workspace" },
controls: { can_change_project: true, can_use_full_access: true },
controls: { can_change_project: true },
},
});
window.history.replaceState(null, "", "/#/chat/websocket%3Aexisting-chat");
@@ -1108,7 +1108,7 @@ describe("App layout", () => {
access_mode: "full",
restrict_to_workspace: false,
},
controls: { can_change_project: true, can_use_full_access: true },
controls: { can_change_project: true },
},
});
render(<App />);
@@ -1162,7 +1162,7 @@ describe("App layout", () => {
access_mode: "restricted",
restrict_to_workspace: true,
},
controls: { can_change_project: true, can_use_full_access: true, can_browse_directories: true, can_resolve_project: true },
controls: { can_change_project: true, can_browse_directories: true, can_resolve_project: true },
},
[directoryUrl("C:\\workspace")]: directory("C:\\workspace"),
[directoryUrl("C:\\workspace\\")]: directory("C:\\workspace"),
+13 -16
View File
@@ -17,7 +17,7 @@ function workspacePickerProps(scope: WorkspaceScopePayload) {
default_scope: scope,
recent_projects: [],
favorite_projects: [],
controls: { can_change_project: true, can_use_full_access: true },
controls: { can_change_project: true },
}),
onBrowseWorkspaceDirectories: async (path: string) => ({
path: resolvePath(path), parent: null, entries: [], partial: false,
@@ -1415,10 +1415,10 @@ describe("ThreadComposer", () => {
project_path: "/tmp/project", project_name: "project",
access_mode: "restricted", restrict_to_workspace: true,
};
const composer = (workspaceScope: WorkspaceScopePayload, canUseFullAccess = true) => (
const composer = (workspaceScope: WorkspaceScopePayload) => (
<ThreadComposer onSend={vi.fn()} placeholder="Type your message..."
workspaceScope={workspaceScope}
workspaceControls={{ can_change_project: true, can_use_full_access: canUseFullAccess }}
workspaceControls={{ can_change_project: true }}
onWorkspaceScopeChange={onWorkspaceScopeChange} />
);
const { rerender } = render(composer(restricted));
@@ -1434,11 +1434,10 @@ describe("ThreadComposer", () => {
expect(access).toHaveFocus();
await user.keyboard("{Enter}");
expect(onWorkspaceScopeChange).toHaveBeenLastCalledWith(restricted);
rerender(composer(restricted, false));
expect(access).toBeDisabled();
onWorkspaceScopeChange.mockClear();
rerender(composer(restricted));
expect(access).toBeEnabled();
await user.click(access);
expect(onWorkspaceScopeChange).not.toHaveBeenCalled();
expect(onWorkspaceScopeChange).toHaveBeenLastCalledWith(full);
});
it("exposes full and compact workspace labels for container-driven compression", () => {
@@ -1453,7 +1452,7 @@ describe("ThreadComposer", () => {
access_mode: "full",
restrict_to_workspace: false,
}}
workspaceControls={{ can_change_project: true, can_use_full_access: true }}
workspaceControls={{ can_change_project: true }}
onWorkspaceScopeChange={vi.fn()}
/>,
);
@@ -1490,7 +1489,7 @@ describe("ThreadComposer", () => {
}}
workspaceDefaultScope={defaultScope}
{...workspacePickerProps(defaultScope)}
workspaceControls={{ can_change_project: true, can_use_full_access: true, can_browse_directories: true, can_resolve_project: true }}
workspaceControls={{ can_change_project: true, can_browse_directories: true, can_resolve_project: true }}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
);
@@ -1555,7 +1554,7 @@ describe("ThreadComposer", () => {
workspaceScope={defaultScope}
workspaceDefaultScope={defaultScope}
{...workspacePickerProps(defaultScope)}
workspaceControls={{ can_change_project: true, can_use_full_access: true }}
workspaceControls={{ can_change_project: true }}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
);
@@ -1584,7 +1583,7 @@ describe("ThreadComposer", () => {
workspaceScope={defaultScope}
workspaceDefaultScope={defaultScope}
{...workspacePickerProps(defaultScope)}
workspaceControls={{ can_change_project: true, can_use_full_access: true }}
workspaceControls={{ can_change_project: true }}
onWorkspaceScopeChange={vi.fn()}
/>
);
@@ -1663,7 +1662,6 @@ describe("ThreadComposer", () => {
{...workspacePickerProps(defaultScope)}
workspaceControls={{
can_change_project: true,
can_use_full_access: true,
can_browse_directories: true,
can_resolve_project: true,
}}
@@ -1689,7 +1687,7 @@ describe("ThreadComposer", () => {
}));
});
it("selects an entered host path in Restricted mode when Full Access is unavailable", async () => {
it("preserves Full Access when selecting an entered host path", async () => {
const user = userEvent.setup();
const onWorkspaceScopeChange = vi.fn();
const defaultScope = {
@@ -1708,7 +1706,6 @@ describe("ThreadComposer", () => {
{...workspacePickerProps(defaultScope)}
workspaceControls={{
can_change_project: true,
can_use_full_access: false,
}}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
@@ -1726,8 +1723,8 @@ describe("ThreadComposer", () => {
expect(onWorkspaceScopeChange).toHaveBeenCalledWith(expect.objectContaining({
project_path: "/srv/nas-project",
access_mode: "restricted",
restrict_to_workspace: true,
access_mode: "full",
restrict_to_workspace: false,
}));
});
+2 -2
View File
@@ -13,7 +13,7 @@ const catalog: WorkspacesPayload = {
default_scope: scope,
recent_projects: [{ name: "alpha", path: "/srv/alpha" }, { name: "beta", path: "/srv/beta" }],
host: { name: "dev-server", platform: "Linux" },
controls: { can_change_project: true, can_use_full_access: false, can_browse_directories: true },
controls: { can_change_project: true, can_browse_directories: true },
};
const directory: WorkspaceDirectoriesPayload = {
path: "/srv/workspace", parent: "/srv", entries: [{ name: "alpha", path: "/srv/workspace/alpha" }],
@@ -419,7 +419,7 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const onBrowse = vi.fn();
const onResolve = vi.fn();
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={{ can_change_project: true, can_use_full_access: false }} onBrowseDirectories={onBrowse} onResolveProject={onResolve} onChange={onChange} />);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={{ can_change_project: true }} onBrowseDirectories={onBrowse} onResolveProject={onResolve} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(screen.queryByRole("option", { name: "Browse folders…" })).not.toBeInTheDocument();
await user.type(screen.getByRole("combobox"), "relative-path");