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

@@ -2386,7 +2386,6 @@ export function ThreadComposer({
<WorkspaceAccessToggle
scope={workspaceScope}
disabled={interactionDisabled || workspaceScopeDisabled}
canUseFullAccess={workspaceControls?.can_use_full_access !== false}
isHero={isHero}
onChange={onWorkspaceScopeChange}
/>
@@ -421,11 +421,10 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
const trimmed = path.trim();
if (!base || !onChange) return;
if (!trimmed || !isAbsoluteWorkspacePath(trimmed)) { setPathError(t("workspace.dialog.absolutePathRequired")); return; }
const accessMode = controls?.can_use_full_access === false && !sameWorkspacePath(trimmed, base.project_path) ? "restricted" : base.access_mode;
onChange({ ...base, project_path: trimmed, project_name: name || projectNameFromPath(trimmed), access_mode: accessMode, restrict_to_workspace: accessMode === "restricted" });
onChange({ ...base, project_path: trimmed, project_name: name || projectNameFromPath(trimmed) });
setPathError(null);
setOpen(false);
}, [controls?.can_use_full_access, defaultScope, onChange, scope, t]);
}, [defaultScope, onChange, scope, t]);
const chooseProject = useCallback(async (path: string, name?: string) => {
const session = pickerSession.current;
@@ -683,13 +682,11 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
export function WorkspaceAccessToggle({
scope,
disabled,
canUseFullAccess,
isHero,
onChange,
}: {
scope: WorkspaceScopePayload;
disabled?: boolean;
canUseFullAccess: boolean;
isHero: boolean;
onChange?: (scope: WorkspaceScopePayload) => void;
}) {
@@ -712,7 +709,7 @@ export function WorkspaceAccessToggle({
variant={null}
aria-label={accessAriaLabel}
aria-pressed={isFull}
disabled={disabled || !onChange || (!isFull && !canUseFullAccess)}
disabled={disabled || !onChange}
onClick={() => onChange?.(scopeWithAccessMode(scope, isFull ? "restricted" : "full"))}
className={cn(
"settings-hover thread-composer-access touch-target min-w-0 max-w-[min(12.5rem,42vw)] whitespace-nowrap rounded-control border border-transparent font-semibold shadow-none",
-1
View File
@@ -497,7 +497,6 @@ export interface WorkspacesPayload {
host?: { name: string; platform: string };
controls: {
can_change_project: boolean;
can_use_full_access: boolean;
can_browse_directories?: boolean;
can_resolve_project?: boolean;
can_manage_favorites?: boolean;
-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");