Skip to content

feat: share chat projects with users, groups, and organizations - #30431

Closed
f0ssel wants to merge 263 commits into
mainfrom
f0ssel/chat-projects-sharing
Closed

f0ssel wants to merge 263 commits into
mainfrom
f0ssel/chat-projects-sharing

Conversation

@f0ssel

@f0ssel f0ssel commented Oct 6, 2026

Copy link
Copy Markdown
Member

Backend for sharing chat projects (experiment chat-projects), stacked on #29583. It follows chat and workspace sharing: an owner can share a project with a user, a group, or the whole organization. To share with the whole organization, add a group entry for the organization's Everyone group. Its group ID is the organization ID, and RBAC already handles it as a special case.

  • API: GET and PATCH /api/experimental/organizations/{organization}/chats/projects/{project}/acl take the same request and response shapes as /chats/{chat}/acl, plus SDK client methods.
  • Roles:
    • use: view the project and its memories, and start chats in it. The agents in those chats read and write the project's memories.
    • admin: everything use can do, plus edit and share the project. Only the owner can delete it, as with workspace sharing.
  • What gets shared: the project's details and its memories. Chats in the project stay private to their owners. A sharee sees their own chats there, plus any chats shared with them separately.
  • Memories: memory permissions come from the project ACL. Anyone who can read the project can create, read, and delete its memories. This lets a sharee's chat agents use memory under the sharee's own permissions.
  • Chat creation: a chat can join a project only if its owner can read the project and create memories in it. Before this change, the chat owner had to own the project. If a sharee loses access, their existing chats lose memory quietly, using the existing resolveProjectMemory fallback.
  • Listing: GET /chats/projects now returns projects the caller owns plus projects shared with them. Site owners still don't see other users' projects in this list.
  • Disable switch: --disable-chat-sharing turns off project sharing too. The endpoints return 403, stored grants are ignored, and roles deny chat_project:share.
  • Validation: a group from another organization is rejected. Otherwise its members who also belong to this organization would get access.

Not included: share notifications (chats send TemplateChatShared; projects would need a new template) and an /acl/available endpoint for the picker.

Generated by Coder Agents.

Implementation notes
  • Migration 000614: adds user_acl and group_acl jsonb columns to chat_projects (typed as ChatACL) and adds the chat_project:share API key scope.
  • New queries:
    • GetChatProjectsAccessibleByUserID replaces GetChatProjectsByOwnerID. It returns owned projects plus ACL matches for org members, and dbauthz post-filters the results.
    • GetChatProjectByIDForUpdate
    • UpdateChatProjectACLByID (dbauthz requires share)
  • ChatProject.RBACObject and ChatProjectMemoryRBACObject attach ACLs unless rbac.ChatACLDisabled().
  • Audit: chat_projects.user_acl and group_acl are tracked.
  • Tests: TestChatProjectSharing covers user/use, admin, group, Everyone (including a member of another org), revocation, and validation. TestChatSharingDisabled covers projects. dbauthz and roles tests are updated.

…olidate memories in the background

The system prompt keeps only the memory guidance so it stays stable across
turns; the read_memory tool description carries the current index. After
extraction, a detached consolidation pass merges duplicates and prunes
superseded memories under strict caps (8 mutations, 24h debounce, per
scope advisory lock, fresh memories protected) and records each run in
chat_memory_consolidations, pruned to the newest 20 per scope.
…solidation in the memory section

Adds mock-based tests for the consolidation debounce, lock, cap, protect
window, journaling, pruning, and failure paths, and surfaces the newest
successful consolidation as a one-line summary under the memory list.
…tion tests

Revalidation now reads rows FOR UPDATE inside the apply transaction so an
edit committed after the reread cannot be overwritten. Candidates are the
unprotected memories oldest first, so the input cap trims recent entries
rather than the stale duplicates consolidation exists to remove. At the
cap only a run that shrank the scope bypasses the debounce. Journal
mutations are always an array.

Extraction tests use an afterMemoryExtraction seam instead of spawning
consolidation goroutines against strict mocks.
Sidebar project list with create, edit, and delete gated on the
authcheck result, a project page at /agents/projects/:projectId, new
chat in project, and move-to-project from the chat menu. Behind the
chat-projects experiment.
Collapsed memory rows expand to show the description, body, and edit
and delete controls. Delete failures surface an error alert.
Adds /agents/settings/memory with the personal memory toggle and the
per-organization memory list, and generalizes the project memory
components to serve both scopes.
Summarizes the newest successful consolidation run in one line under
the memory list.
# Conflicts:
#	docs/reference/api/schemas.md
# Conflicts:
#	coderd/database/db2sdk/db2sdk.go
#	coderd/database/dbauthz/dbauthz.go
#	coderd/database/dbmetrics/querymetrics.go
#	coderd/database/dbmock/dbmock.go
#	coderd/database/modelmethods.go
#	coderd/database/querier.go
#	coderd/database/querier_test.go
#	coderd/database/queries.sql.go
…ories

# Conflicts:
#	coderd/database/dbauthz/dbauthz.go
#	coderd/database/dbmetrics/querymetrics.go
#	coderd/database/querier.go
#	coderd/database/querier_test.go
#	coderd/database/queries.sql.go
#	coderd/x/chatd/memory_extract_internal_test.go
#	coderd/x/chatd/projectmemory_extract.go
…olidation

# Conflicts:
#	coderd/database/dbauthz/dbauthz.go
#	coderd/database/dbmetrics/querymetrics.go
#	coderd/database/querier.go
#	coderd/x/chatd/memory_extract.go
jaaydenh and others added 24 commits October 6, 2026 09:26
…stories, assert submits in tests

Move the project denial copy checks from Vitest into Pixel stories
(unlisted organization, product-wide, no permitted organization) and
drop the assertion-only play function. Assert the project draft, MCP,
and loading tests through the onCreateChat payload instead of
rendered output.
# Conflicts:
#	site/src/pages/AgentsPage/components/ChatsSidebar/dialogs/ChatProjectDialog.stories.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/dialogs/ChatProjectDialog.test.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/dialogs/ChatProjectDialog.tsx
…ers-resync

# Conflicts:
#	site/src/pages/AgentsPage/components/ChatsSidebar/chats/ChatsPanel.tsx
…ct folder review feedback

- Show an empty state when every visible chat is filed in a project.
- Reuse the chat list empty-state copy for empty folders.
- Make the projects loading and error props required.
- Rename ProjectDialogMode to ProjectDialogState.
- Add mock prefixes to new test fixtures.
- Add stories for loading, error, and empty emoji-icon folder states.
…lar empty state when every chat is in a project

Project chats live only in their folders, so the Chats section uses its
usual empty-state copy when nothing outside a project remains.
…folders open when navigating between projects

A folder that was open because its project was active now stays open
when the user opens a chat in another project. Only an explicit toggle
collapses a folder.
…t folders with the chat list

The Projects section no longer has its own bounded scroll area. It sits
in the sidebar's scroll area above the Chats section, so expanding a
folder pushes the chats down.
…coder/coder into f0ssel/chat-projects-ui-folders

# Conflicts:
#	site/src/pages/AgentsPage/components/ChatsSidebar/chats/ChatsPanel.tsx
…s empty state while projects load

When every chat belongs to a project, those chats are held back until
the project list loads. The Chats section showed "No agents yet" in the
meantime, which falsely told users their chats did not exist.
@github-actions

github-actions Bot commented Oct 6, 2026

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.

Base automatically changed from f0ssel/chat-projects-ui-folders to main October 6, 2026 15:57
@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