Skip to content

feat: move chats between projects through the chat update API - #30894

Open
ibetitsmike wants to merge 1 commit into
mike/move-chats-chatdfrom
mike/move-chats-api
Open

ibetitsmike wants to merge 1 commit into
mike/move-chats-chatdfrom
mike/move-chats-api

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

PATCH /api/v2/chats/{chat} now takes project_id. A project ID moves the chat into that project, and uuid.Nil removes it from its project.

Stack (moving chats between projects, bottom first):

  1. feat: move a chat family between projects in chatd #30893: the move in chatd
  2. This PR: the chat update API takes project_id
  3. feat(site/src): move chats between projects from the chat menu #30895: Move to project in the chat menu
  4. feat(site/src/pages/AgentsPage/components): drag chats onto project folders in the sidebar #30795: drag a chat onto a project folder in the sidebar

Why: #30893 can move a chat family, and the UI layers above need an endpoint to call.

  • A move accepts the same projects as chat creation, through validateChatProjectSelection(), which this PR extracts from postChats() without a change in behavior.
  • A project that the chat's owner does not own gives 404, even for an admin. So an admin cannot put a member's chat into another user's project and expose its memory.
  • A child chat, an archived chat or a disabled chat-projects experiment gives 400. A family that is not idle gives 409 ("Cannot move an active chat. Interrupt or wait for the chat to finish first."). A project deleted between the check and the move gives 404.
  • The move is the last write in patchChat(), so a refused move keeps the earlier writes of the same request, as a refused archive does.

What to scrutinize: the owner check in validateChatProjectSelection() and the order of the refusals in patchChat() (coderd/exp_chats.go).

Generated (make gen): coderd/apidoc, docs/reference/api/chats.md, docs/reference/api/schemas.md and typesGenerated.ts come from UpdateChatRequest.ProjectID in codersdk/chats.go.

Testing

  • make pre-commit passes, and so does go test ./coderd -run TestPatchChatProject (14 subtests).
  • TestPatchChatProject/AnotherOwnersProject fails without the owner check. MoveBackWaitsForAPendingMove ends in the wrong project when the handler skips the move before the lock. ActiveFamilyReturnsConflict checks the 409 for a running, interrupting or action-waiting root and for a running subagent. PublishesProjectChange and AuditsTheMove cover the watch event and the audit entry.
  • Untested: the 404 when the project is deleted between the check and the move.

Xum opened this PR on behalf of @ibetitsmike.

PATCH /api/v2/chats/{chat} now accepts project_id. A UUID moves an idle
root chat into a project of its owner and organization; uuid.Nil removes
it from its project. The project checks are the ones of chat creation,
now shared by validateChatProjectSelection.

A project that the chat's owner does not own gives 404 even for an
admin, so an admin cannot put a member's chat into another user's
project and expose its memory. A child chat, an archived chat or a
disabled experiment gives 400, and a busy family gives 409. The move is
the last write of the request, so a refused move keeps the earlier
writes, as a refused archive does.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-10-16T14:04:51.785599Z 15a49ca Draft marked ready
ℹ️ 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.

@nickvigilante nickvigilante left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docs LGTM

@pr-queue-manager
pr-queue-manager Bot requested a review from ThomasK33 October 16, 2026 14:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants