Skip to content

feat(site): add a dialog that edits a chat project's templates - #32375

Draft
jaaydenh wants to merge 5 commits into
chat-project-templates/default-parametersfrom
chat-project-templates/templates-dialog
Draft

jaaydenh wants to merge 5 commits into
chat-project-templates/default-parametersfrom
chat-project-templates/templates-dialog

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Adds ProjectTemplatesDialog, the Edit templates dialog for an existing chat project. Nothing opens it yet: #30898 adds the Templates row of the project details that does, and the save.

  • The dialog reuses the template fields of the create dialog (feat(site): pick templates for chat projects #30756, feat(site): set a default template and preset for a chat project #32373, feat(site): set default parameter values for a chat project #32374): the templates multi-select with Select all, the limit switch, the default template, and its default preset or parameter values.
  • The draft starts from the templates saved when the dialog opens. Save hands the caller a ChatProjectTemplatesChange: the templates to attach, the templates to detach, and the limit and default template when either changed. Nothing is sent for what the draft leaves as it is, and clearing the default template sends the nil template ID.
  • A save is sent once. A rejected save shows its error, returns focus to Save, and can be sent again. Save uses aria-disabled, so it keeps focus while it waits.
  • The form skips native validation, as the create dialog's does. The default parameter fields carry the template's required and range constraints, and a project default may leave a required parameter empty.

projectTemplatesDraft.ts holds the pure helpers: the saved settings of a project, the change between saved and drafted settings, and the comparison that tells an edited draft from an untouched one.

Edit templates dialog with default parameter values

The screenshot is from a local instance with the whole stack. At this PR the dialog renders only in its stories and tests.

What this PR leaves out: the dialog does not yet notice templates saved elsewhere while it is open. #32376 and #32377 add that, and #32378 clears saved defaults that a new template version dropped.

Split out of #30898.

Stack (merge top to bottom):

ProjectTemplatesDialog edits a project's templates, the limit, and the
default template with the fields of the create project dialog. It
starts from the saved templates and hands its caller only what the
draft changes: the templates to attach, the templates to detach, and
the limit and default template when either changed.

Nothing opens the dialog yet. The project details do in the next pull
request of the stack.
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T08:13:26.114735Z f25d43f 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: f25d43fedf

ℹ️ 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 on lines +115 to +116
const canSave =
request !== undefined && !isDraftUntouched && !isSaveSent && !isSaving;

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 Compare the filtered draft before enabling Save

When the eligible-template query refreshes and drops a template the user just selected, isDraftUntouched remains false because it compares the raw form values, while request silently filters that template out. Save therefore stays enabled and calls onSave with an empty change, making the dialog appear to save a selection that was not persisted. Determine whether the draft changed from the filtered request/change instead, or reconcile the draft when eligibility changes.

AGENTS.md reference: site/AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

Comment on lines +133 to +138
export const Loading: Story = {
parameters: { queries: [] },
beforeEach: () => {
spyOn(API, "getTemplates").mockReturnValue(new Promise(() => {}));
},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Cover the initial template-query error state

Add a story for an initial getTemplates rejection without cached data. The new dialog has a distinct template-loading error branch that removes the selector and renders an alert, but the stories cover only loading, save failures, and a nested parameter-refetch failure, so Pixel never validates this user-visible error state.

AGENTS.md reference: site/AGENTS.md:L74-L75

Useful? React with 👍 / 👎.

const { user, props } = renderDialog();
await user.click(await screen.findByRole("button", { name: "Select all" }));
const save = screen.getByRole("button", { name: /Save/ });
await waitFor(() => expect(save).toHaveAttribute("aria-disabled", "false"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove DOM-attribute assertions from the behavior tests

These waits assert the implementation detail aria-disabled="false" directly, here and again in the unavailable-template test, despite both tests already asserting the observable onSave result. This makes the tests fail under behavior-preserving changes to how Save is gated and violates the frontend test contract to assert callbacks, requests, or state rather than rendered attributes.

AGENTS.md reference: site/AGENTS.md:L74-L76

Useful? React with 👍 / 👎.

jaaydenh added a commit that referenced this pull request Nov 18, 2026
Adds the API for attaching workspace templates to a chat project, on the
schema and queries in #32309. A project can attach templates, turn on a
limit that restricts its chats to them, and set a default template with
either a default preset or default parameter values. Attaching a
template never grants access to it: every reader is checked against the
template's own sharing. This PR stores and returns `limit_templates`;
#32310 enforces it.

- The limit is opt-in. `limit_templates` is off unless a request turns
it on, which is what every existing project gets.
- Templates are attached and detached one at a time with `PUT` and
`DELETE /chats/projects/{project}/templates/{template}`, so a caller
never replaces a list they can only partly see. Attaching needs project
`update` and template `use`. Detaching needs project `update` and
template `read`, and a template the caller cannot read is reported as
not found. `POST /chats/projects` accepts `template_ids`,
`limit_templates`, and `default_template` for the new project.
- `PATCH /chats/projects/{project}` sets `limit_templates` and
`default_template`, and no longer changes which templates are attached.
The default must be an attached template the caller can read, and its
preset must belong to the template's active version. Default parameter
names and values are checked against that version for templates on the
classic parameter flow; dynamic parameters are checked when a workspace
is built. Detaching the default template clears the default.
- Project responses list only the attached templates the caller can
read, as `templates`, and count the rest as `hidden_template_count`.
`default_template` is omitted when the caller cannot read it. Deleted,
deprecated, and agent-disabled templates are left out and are not
counted as hidden.
- Editing uses `chat_project:update`, which the project owner and the
project `admin` ACL role have.
- Attaching and detaching are audited as writes to the project, with the
template list before and after, including the templates attached while
creating a project. Changes to `limit_templates` and the default
template are part of the project's own audit diff.

Not included: showing which project members lack access to an attached
template, and MCP server attachments.

Stack (merge top to bottom):
- #32309
- #30754 👈
- #32310
- #30755
- #32371
- #32372
- #30756
- #32373
- #32374
- #32375
- #30898
- #32376
- #32377
- #32378
- #32379

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