feat: add organization scoping to chats (#23827)

Fixes https://github.com/coder/internal/issues/1436

* Adds organization_id to chats with backfill (workspace org → user org membership → default org)
* No support yet for ACLs (follow-up issue)
- Cross-org workspace binding rejected (both in `CreateChatRequest` and in `create_workspace` tool
- Adds `OrganizationAutocomplete` to `AgentCreateForm`
- Docs updated with `organization_id` in chats-api.md

> 🤖 Written by a Coder Agent. Reviewed by many humans and many agents.

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
Cian Johnston
2026-04-13 12:31:25 +01:00
committed by GitHub
co-authored by Mathias Fredriksson
parent cb0b84a2d3
commit 22062ec52e
58 changed files with 1533 additions and 581 deletions
+1
View File
@@ -80,6 +80,7 @@ const makeChat = (
overrides?: Partial<TypesGen.Chat>,
): TypesGen.Chat => ({
id,
organization_id: "test-org-id",
owner_id: "owner-1",
last_model_config_id: "model-1",
mcp_server_ids: [],
+2
View File
@@ -1186,6 +1186,7 @@ export interface ChangePasswordWithOneTimePasscodeRequest {
*/
export interface Chat {
readonly id: string;
readonly organization_id: string;
readonly owner_id: string;
readonly workspace_id?: string;
readonly build_id?: string;
@@ -2488,6 +2489,7 @@ export interface CreateChatProviderConfigRequest {
* CreateChatRequest is the request to create a new chat.
*/
export interface CreateChatRequest {
readonly organization_id: string;
readonly content: readonly ChatInputPart[];
readonly system_prompt?: string;
readonly workspace_id?: string;