Skip to content

feat: add user and group sharing for chat projects - #29597

Closed
f0ssel wants to merge 8 commits into
mainfrom
f0ssel/chat-project-sharing
Closed

f0ssel wants to merge 8 commits into
mainfrom
f0ssel/chat-project-sharing

Conversation

@f0ssel

@f0ssel f0ssel commented Sep 18, 2026 •

Copy link
Copy Markdown
Member
  • Adds user and group sharing for chat projects, mirroring chat sharing: user_acl/group_acl on chat_projects, single read role, GET/PATCH /api/experimental/chats/projects/{project}/acl.
  • Shared users and group members see the project and can start chats in it; existing chats inside stay independently private. Only the creator or org admin can share or manage.
  • Project list is filtered in SQL through the RBAC policy; CODER_DISABLE_CHAT_SHARING disables project sharing too.
  • New Chat Project Shared notification for directly added users, audited chat_project ACL writes, chat_project:share API key scope.
  • Stacked on feat: add chat projects API #29242 but parked outside the main stack for now; the memory PRs will rebase onto it when sharing lands.

Generated with Coder Agents on behalf of @f0ssel.

…cts experiment

Adds a lightweight chat_projects table and a nullable chats.project_id
binding so agent chats can be grouped inside an organization-scoped
project. Chats stay independent by default; deleting a project detaches
its chats instead of deleting them.

Backend: chat_project RBAC resource (org members read/create, creators
and org admins update/delete), audited CRUD under
/api/experimental/chats/projects, project_id on chat create/update and
list filter, codersdk client methods.

Frontend: experiment-gated Projects sidebar section with create/edit/
delete dialogs, /agents/projects/:projectId page, new-chat-in-project via
?project=, and a Move to project action in the chat menus.
Single-project responses previously scanned the organization's project
list to recover chat_count. A dedicated count query shares the list
predicate, and the converter now requires the count so no response can
silently report zero.
Silently dropping project_id returned every chat as if it were the
project's contents. The list now fails the same way create and update do.
# Conflicts:
#	docs/reference/api/schemas.md
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@f0ssel

f0ssel commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T13:57:05.286627Z 75a5667 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75a5667817

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

'[
{
"label": "Open project",
"url": "{{base_url}}/agents/projects/{{.Labels.project_id}}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point the notification at an existing project route

Every direct share sends this action, but the frontend router only defines /agents, settings routes, and /agents/:agentId; there is no /agents/projects/:projectId route anywhere in the repository. Selecting Open project therefore lands on an unmatched route, so every project-share notification has a broken call to action. Use a route or query parameter the Agents page already handles, or add the corresponding route.

Useful? React with 👍 / 👎.

Comment on lines +137 to +138
oldProject = current
oldProject.UserACL = maps.Clone(current.UserACL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clone the group ACL before mutating it

When GroupRoles adds or removes an entry, oldProject.GroupACL and current.GroupACL still reference the same map because only UserACL is cloned. The mutation therefore updates the audit request's old snapshot before aReq.New is assigned, causing the tracked group_acl diff to omit the change. Clone current.GroupACL into oldProject.GroupACL as well.

Useful? React with 👍 / 👎.

}
}

validErrs := acl.Validate(ctx, api.Database, ChatProjectACLUpdateValidator(req))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject ACL principals outside the project organization

When an owner supplies an existing user or group UUID from another organization, acl.Validate only checks global existence, so the foreign principal is stored. A foreign direct user is then notified about a project they cannot access, while a foreign group can grant access to its members who also belong to the project's organization because the RBAC policy matches the group UUID without validating the group's organization. Validate user membership and group ownership against project.OrganizationID, as the chat-model and MCP ACL handlers do.

Useful? React with 👍 / 👎.

delete(current.UserACL, id)
continue
}
current.UserACL[id] = database.ChatACLEntry{Permissions: db2sdk.ChatProjectRoleActions(role)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize UUID keys before storing ACL entries

When the request uses a valid noncanonical UUID spelling, such as uppercase hex, validation succeeds but the raw string is persisted as the ACL key. RBAC looks up the entry using the subject's canonical uuid.String(), so that user or group is reported as shared and may receive a notification but cannot read the project. Canonicalize both role maps before applying them and reject duplicate spellings that collapse to the same UUID.

Useful? React with 👍 / 👎.


var oldProject database.ChatProject
err := api.Database.InTx(func(tx database.Store) error {
current, err := tx.GetChatProjectByIDForUpdate(ctx, project.ID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Lock the project without requiring read permission

When an actor has chat_project:share but not chat_project:read, such as a low-level scoped API key or custom role, the handler's share authorization succeeds but this dbauthz getter uses the generic fetch wrapper and performs an additional read authorization, causing the transaction to return 404. This makes the newly added share action unusable independently; fetch the locked row under restricted system access after the handler check and rely on UpdateChatProjectACLByID to reauthorize sharing against the current row.

Useful? React with 👍 / 👎.

f0ssel added a commit that referenced this pull request Sep 21, 2026
Sharing (#29597) is parked; memory permissions follow the project owner
only and the memory migration returns to 000599.
f0ssel added a commit that referenced this pull request Sep 21, 2026
Sharing (#29597) is parked; the sharing popover is chat-only again.
@f0ssel

f0ssel commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 75a5667817

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jaaydenh

Copy link
Copy Markdown
Collaborator

@f0ssel Can we make it so that a project can shared while its being created? Also, It could be useful to share it with the entire organization the project is being created in.

@linear-code

linear-code Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

CODAGT-1041

CODAGT-1044

Base automatically changed from f0ssel/chat-projects to main October 1, 2026 15:49
@f0ssel f0ssel closed this Oct 6, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants