Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a2d3bc9
feat(site): show project members in the project details panel
jaaydenh Oct 24, 2026
3f729aa
fix(site/src/pages/AgentsPage/components/ProjectPage): address member…
jaaydenh Oct 24, 2026
6319455
test(site/src/pages/AgentsPage/components/ProjectPage): type the acce…
jaaydenh Oct 24, 2026
760277a
fix(site/src/pages/AgentsPage/components/ProjectPage): address member…
jaaydenh Oct 24, 2026
6c2fec3
feat(site): manage project access from the project details panel
jaaydenh Oct 24, 2026
256c6d5
fix(site): address manage access UAT findings
jaaydenh Oct 24, 2026
8e9d08a
fix(site): fit the manage access table on phones
jaaydenh Oct 24, 2026
ace00da
test(site): tighten project members tests
jaaydenh Oct 24, 2026
81a74d8
refactor(site): simplify manage access mutations and address review
jaaydenh Oct 24, 2026
ee2e029
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
5b294b9
fix(site): keep focus on the changed access row
jaaydenh Oct 24, 2026
bcccfbd
feat: include the owner in the chat project ACL response
jaaydenh Oct 24, 2026
e74cb8d
Merge branch 'chat-project-access/owner-in-acl' into chat-project-acc…
jaaydenh Oct 24, 2026
d58f3bf
feat(site): show the project owner from the ACL response
jaaydenh Oct 24, 2026
d0b3fbc
fix(site): address project members review and UAT findings
jaaydenh Oct 24, 2026
bed59f1
test(site): cover the unknown project owner label
jaaydenh Oct 24, 2026
1efb092
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
1d56b98
fix(site): address project members CI and review findings
jaaydenh Oct 24, 2026
923fda4
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
59ed106
feat(site/src/api): add the chat project ACL update client
jaaydenh Oct 24, 2026
a11212b
fix(site): address project members Codex review
jaaydenh Oct 24, 2026
eba3e97
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
a86e682
fix(site): address manage access Codex review
jaaydenh Oct 24, 2026
5cc30fb
refactor(site): share the chat project ACL fixture
jaaydenh Oct 24, 2026
81340f1
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
8219c12
fix(site): adapt manage access to the shared ACL fixture
jaaydenh Oct 24, 2026
001452a
fix(site): address manage access Codex review round 2
jaaydenh Oct 24, 2026
90af5b0
refactor(site): drop single-use project ACL helpers
jaaydenh Oct 24, 2026
702bb53
docs(site/src/pages/AgentsPage/components/ProjectPage): tighten proje…
jaaydenh Oct 24, 2026
9b36182
test(site): cover retrying the project members request
jaaydenh Oct 24, 2026
6a3f395
fix(site): fit the project members row on narrow screens
jaaydenh Oct 24, 2026
0b1fdac
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
b62535b
refactor(site/src/pages/AgentsPage/components/ProjectPage): address m…
jaaydenh Oct 24, 2026
f1e6a1b
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
1ab8474
fix(site): announce the selected user or group
jaaydenh Oct 24, 2026
112bfde
fix(site): size the project members row to its card
jaaydenh Oct 24, 2026
6127bba
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
eca0996
refactor(site): scope the member tooltip click-through to its call site
jaaydenh Oct 24, 2026
a540171
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
3d484b2
test(site): cover retrying from the project access dialog
jaaydenh Oct 24, 2026
4023806
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 24, 2026
bc93f37
test(site): retry from the manage access dialog in the panel test
jaaydenh Oct 24, 2026
6a69e3f
chore(site/src/api/queries): shorten the ACL refresh comment
jaaydenh Oct 24, 2026
c719f47
fix(site): tighten the project members row
jaaydenh Oct 26, 2026
a03f87a
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 26, 2026
d9ecccf
fix(site): default the project access add role to member
jaaydenh Oct 26, 2026
9c8d82e
Merge branch 'main' into chat-project-access/owner-in-acl
jaaydenh Oct 29, 2026
c68d712
Merge branch 'chat-project-access/owner-in-acl' into chat-project-acc…
jaaydenh Oct 29, 2026
0498e00
Merge branch 'chat-project-access/members-summary' into chat-project-…
jaaydenh Oct 29, 2026
ee4769c
chore: replace focusbyid
jaaydenh Nov 4, 2026
afe88cb
Merge commit 'e26c1934a5f^' into resolve-31246
jaaydenh Nov 4, 2026
2779f40
Merge branch 'main' into chat-project-access/manage-access
jaaydenh Nov 4, 2026
600d3ce
chore: remove runMutation
jaaydenh Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3446,6 +3446,17 @@ class ExperimentalApiMethods {
return response.data;
};

updateChatProjectACL = async (
organizationId: string,
projectId: string,
req: TypesGen.UpdateChatProjectACL,
): Promise<void> => {
await this.axios.patch(
`/api/experimental/organizations/${organizationId}/chats/projects/${projectId}/acl`,
req,
);
};

getChat = async (
chatId: string,
signal?: AbortSignal,
Expand Down
74 changes: 72 additions & 2 deletions site/src/api/queries/chatProjects.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { describe, expect, it } from "vitest";
import { MockChatProject } from "#/testHelpers/entities";
import { MutationObserver } from "react-query";
import { afterEach, describe, expect, it, vi } from "vitest";
import { API } from "#/api/api";
import type { ChatProjectRole } from "#/api/typesGenerated";
import { MockChatProject, mockApiError } from "#/testHelpers/entities";
import { createTestQueryClient } from "#/testHelpers/renderHelpers";
import {
chatProject,
chatProjectACLKey,
chatProjectInstructionsKey,
chatProjectsKey,
createChatProject,
deleteChatProject,
setChatProjectRole,
updateChatProject,
} from "./chatProjects";
import {
Expand Down Expand Up @@ -70,3 +76,67 @@ describe("chat project mutations", () => {
expect(isInvalidated(queryClient, messagesKey)).toBe(false);
});
});

type Principal = { kind: "user" | "group"; id: string };

describe("setChatProjectRole", () => {
const refreshedKeys = [
chatProjectsKey,
chatProjectACLKey(MockChatProject.id),
];
const otherKeys = [
chatProjectInstructionsKey(MockChatProject.id),
chatProjectACLKey("other-project"),
];
const setup = () => {
const queryClient = createTestQueryClient();
for (const key of [...refreshedKeys, ...otherKeys]) {
queryClient.setQueryData(key, {});
}
const updateACL = vi
.spyOn(API.experimental, "updateChatProjectACL")
.mockResolvedValue();
const mutate = (principal: Principal, role: ChatProjectRole) =>
new MutationObserver(queryClient, setChatProjectRole(queryClient)).mutate(
{ project: MockChatProject, principal, role },
);
return { queryClient, updateACL, mutate };
};

afterEach(() => {
vi.restoreAllMocks();
});

it("sends user and group role changes", async () => {
const { updateACL, mutate } = setup();

await mutate({ kind: "user", id: "user-1" }, "admin");
await mutate({ kind: "group", id: "group-1" }, "");

const { organization_id, id } = MockChatProject;
expect(updateACL.mock.calls).toEqual([
[organization_id, id, { user_roles: { "user-1": "admin" } }],
[organization_id, id, { group_roles: { "group-1": "" } }],
]);
});

it("refreshes the project and its access after a change, even a forbidden one", async () => {
for (const forbidden of [false, true]) {
const { queryClient, updateACL, mutate } = setup();
if (forbidden) {
updateACL.mockRejectedValue({ ...mockApiError({}), status: 403 });
}

await mutate({ kind: "user", id: "user-1" }, "use").catch((error) =>
expect(error).toMatchObject({ status: 403 }),
);

for (const key of refreshedKeys) {
expect(queryClient.getQueryState(key)?.isInvalidated).toBe(true);
}
for (const key of otherKeys) {
expect(queryClient.getQueryState(key)?.isInvalidated).toBe(false);
}
}
});
});
33 changes: 33 additions & 0 deletions site/src/api/queries/chatProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,39 @@ export const chatProjectACL = (project: TypesGen.ChatProject) =>
API.experimental.getChatProjectACL(project.organization_id, project.id),
});

type SetChatProjectRoleVariables = {
project: TypesGen.ChatProject;
principal: { readonly kind: "user" | "group"; readonly id: string };
role: TypesGen.ChatProjectRole;
};

/** Sets a user's or group's project role; an empty role removes access. */
export const setChatProjectRole = (queryClient: QueryClient) =>
mutationOptions({
mutationFn: ({ project, principal, role }: SetChatProjectRoleVariables) =>
API.experimental.updateChatProjectACL(
project.organization_id,
project.id,
{
[principal.kind === "group" ? "group_roles" : "user_roles"]: {
[principal.id]: role,
},
},
),
// Also refresh the project: a change or a 403 can revoke the viewer's admin.
onSettled: (_data, _error, { project }) =>
Promise.all([
queryClient.invalidateQueries({
queryKey: chatProjectsKey,
exact: true,
}),
queryClient.invalidateQueries({
queryKey: chatProjectACLKey(project.id),
exact: true,
}),
]),
});

export const updateChatProjectInstructions = (
queryClient: QueryClient,
project: TypesGen.ChatProject,
Expand Down
7 changes: 7 additions & 0 deletions site/src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type AutocompleteProps<TOption> = {
className?: string;
triggerAriaInvalid?: boolean;
triggerAriaDescribedBy?: string;
triggerAriaLabelledBy?: string;
triggerRef?: React.Ref<HTMLButtonElement>;
id?: string;
"data-testid"?: string;
};
Expand Down Expand Up @@ -70,6 +72,8 @@ export function Autocomplete<TOption>({
className,
triggerAriaInvalid,
triggerAriaDescribedBy,
triggerAriaLabelledBy,
triggerRef,
id,
"data-testid": testId,
}: AutocompleteProps<TOption>) {
Expand Down Expand Up @@ -265,6 +269,7 @@ export function Autocomplete<TOption>({
aria-haspopup="listbox"
aria-invalid={triggerAriaInvalid}
aria-describedby={triggerAriaDescribedBy}
aria-labelledby={triggerAriaLabelledBy}
disabled={disabled}
placeholder={placeholder}
value={inlineInputValue}
Expand Down Expand Up @@ -362,11 +367,13 @@ export function Autocomplete<TOption>({
<PopoverTrigger asChild disabled={disabled}>
<button
type="button"
ref={triggerRef}
id={id}
data-testid={testId}
aria-expanded={isOpen}
aria-haspopup="listbox"
aria-describedby={triggerAriaDescribedBy}
aria-labelledby={triggerAriaLabelledBy}
disabled={disabled}
className={cn(
`flex h-10 w-full items-center justify-between gap-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ type UserOrGroupAutocompleteProps = {
organizationId: string;
exclude: ExcludableOption[];
className?: string;
id?: string;
clearable?: boolean;
triggerAriaLabelledBy?: string;
triggerRef?: React.Ref<HTMLButtonElement>;
};

const normalizeMember = (
Expand All @@ -34,7 +38,17 @@ const normalizeMember = (

export const UserOrGroupAutocomplete: React.FC<
UserOrGroupAutocompleteProps
> = ({ value, onChange, organizationId, exclude, className = "w-80" }) => {
> = ({
value,
onChange,
organizationId,
exclude,
className = "w-80",
id,
clearable,
triggerAriaLabelledBy,
triggerRef,
}) => {
const [inputValue, setInputValue] = useState("");
const [open, setOpen] = useState(false);

Expand Down Expand Up @@ -131,7 +145,10 @@ export const UserOrGroupAutocomplete: React.FC<
placeholder="Search for user or group"
noOptionsText="No users or groups found"
className={className}
id="workspace-user-or-group-autocomplete"
id={id ?? "workspace-user-or-group-autocomplete"}
clearable={clearable}
triggerAriaLabelledBy={triggerAriaLabelledBy}
triggerRef={triggerRef}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn } from "storybook/test";
import { fn, screen, userEvent } from "storybook/test";
import type { ChatProjectACL } from "#/api/typesGenerated";
import {
MockChatProject,
MockChatProjectACL,
MockUserMember,
mockApiError,
} from "#/testHelpers/entities";
import { pixelWithPhone } from "#/testHelpers/pixel";
import { ProjectAccessDialog } from "./ProjectAccessDialog";
import { buildAccessEntries } from "./projectAccess";

const mockACL: ChatProjectACL = {
...MockChatProjectACL,
users: [
...MockChatProjectACL.users,
{
...MockUserMember,
name: "Maximiliana Bartholomea Featherstonehaugh",
role: "admin",
},
{
...MockUserMember,
id: "sharee-2",
Expand All @@ -34,6 +40,14 @@ const meta: Meta<typeof ProjectAccessDialog> = {
isRetrying: false,
onRetry: fn(),
onCloseAutoFocus: fn(),
canManage: false,
organizationId: MockChatProject.organization_id,
currentUserId: MockChatProjectACL.owner.id,
onAdd: fn(),
onChangeRole: fn(),
onRemove: fn(),
pendingPrincipalId: undefined,
mutationError: undefined,
},
};

Expand Down Expand Up @@ -73,3 +87,70 @@ export const RefetchError: Story = {
error: mockApiError({ message: "Failed to get chat project ACL." }),
},
};

export const Manage: Story = {
args: { canManage: true },
};

export const ManageOwnerOnly: Story = {
args: {
canManage: true,
entries: buildAccessEntries({ ...mockACL, users: [], groups: [] }),
},
};

/** A project admin cannot change their own role. */
export const ManageAsAdmin: Story = {
args: { canManage: true, currentUserId: MockUserMember.id },
};

export const ManageRoleOptions: Story = {
args: { canManage: true },
play: async () => {
await userEvent.click(
await screen.findByRole("combobox", { name: "Role for grace" }),
);
},
};

export const ManageRowMenu: Story = {
args: { canManage: true },
play: async () => {
await userEvent.click(
await screen.findByRole("button", { name: "Open menu for grace" }),
);
},
};

export const ManagePendingChange: Story = {
args: { canManage: true, pendingPrincipalId: "sharee-2" },
};
Comment thread
jaaydenh marked this conversation as resolved.
Resolved

export const ManageChangeError: Story = {
args: {
canManage: true,
mutationError: mockApiError({
message: "Failed to update chat project ACL.",
}),
},
};

/** A 403 skips the generic detail about viewing content. */
export const ManageForbiddenError: Story = {
args: {
canManage: true,
mutationError: {
...mockApiError({
message: "Forbidden.",
detail: "You don't have permission to view this content.",
}),
status: 403,
},
},
};

/** Rows stack on phones, and long names truncate. */
export const ManageOnPhone: Story = {
args: { canManage: true },
parameters: { pixel: { matrix: pixelWithPhone } },
};
Loading
Loading