Skip to content

feat: restrict chat project templates - #30754

Draft
jaaydenh wants to merge 8 commits into
mainfrom
chat-project-templates/api
Draft

jaaydenh wants to merge 8 commits into
mainfrom
chat-project-templates/api

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Lets a chat project define which of its organization's workspace templates its chats may use, plus an optional default template with either a default preset or default parameter values. An empty list means the project's chats get no templates (they rely on MCP servers and skills once projects support them).

  • chat_projects gains template_ids uuid[] (following chats.mcp_server_ids), default_template_id, default_template_version_preset_id, and default_parameters jsonb. CHECK constraints keep the default inside the list and allow a preset or parameters, not both.
  • POST/PATCH /chats/projects accept templates; PATCH replaces the object as a whole and leaves it untouched when omitted. Templates are looked up as the requester and must be in the project's organization, allow agents, and not be deprecated. The default preset must belong to the default template's active version and parameter names must exist on it.
  • Attaching a workspace whose template is outside the list is rejected, at chat creation and on PATCH /chats/{chat} workspace_id. Chats that already have a workspace keep it.
  • Editing stays on chat_project:update (the owner today); project editor roles will extend that check in a later PR.

Stack (merge top to bottom):

Projects store the templates their chats may use and an optional default
template with either a default preset or default parameter values. An
empty list means the project's chats get no templates. Creating a chat
with, or patching a chat to, a workspace whose template is outside the
project's list is rejected; already bound workspaces are unaffected.
@github-actions

github-actions Bot commented Oct 14, 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.

@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-16T12:30:20.222577Z a4d1629 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: 8570509f81

ℹ️ 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".

Comment thread coderd/exp_chats.go
Comment thread codersdk/chats.go
…s/api

# Conflicts:
#	coderd/database/dump.sql
#	coderd/database/models.go
#	coderd/database/queries.sql.go
#	enterprise/audit/table.go
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@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: f68e904cf1

ℹ️ 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".

Comment thread coderd/chat_projects.go Outdated
Comment thread coderd/chat_projects.go Outdated
Comment thread coderd/exp_chats.go Outdated
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 286c8d6281

ℹ️ 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".

Comment thread coderd/chat_projects.go
@jaaydenh
jaaydenh added this pull request to stack #30892 October 16, 2026 12:17
Dynamic parameters can appear based on other values, so the stored
parameter rows cannot tell whether a default name is valid. Only
classic-flow templates are checked; the build validates dynamic
defaults when a workspace is created.
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@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: a4d16299ec

ℹ️ 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".

Comment thread coderd/chat_projects.go
Comment on lines +242 to +245
TemplateIDs: templates.templateIDs,
DefaultTemplateID: templates.defaultTemplateID,
DefaultTemplateVersionPresetID: templates.defaultPresetID,
DefaultParameters: templates.defaultParameters,

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 Preserve omitted template settings during concurrent PATCHes

When a PATCH omits templates, these values come from the project snapshot loaded before the handler runs and are then written unconditionally. If another request updates the project's templates after that snapshot but before this update, a concurrent name, description, or icon-only PATCH restores the old template IDs and defaults, violating the documented behavior that omitted templates remain untouched. Update the template columns only when req.Templates is present, or merge them atomically from the current database row.

Useful? React with 👍 / 👎.

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.

1 participant