Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: apply MCP server selection when editing a chat message - #28471

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/chat-edit-mcp-server-ids
Aug 24, 2026
Merged

fix: apply MCP server selection when editing a chat message#28471
ibetitsmike merged 3 commits into
mainfrom
mike/chat-edit-mcp-server-ids

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

Problem

Editing a user message in an Agent chat silently dropped the MCP server selection. The composer renders the MCP picker in edit mode and toggles update local client state, so the picker displayed the new selection, but the edit request omitted mcp_server_ids at every layer (frontend request builder, codersdk.EditChatMessageRequest, the PATCH /chats/{chat}/messages/{message} handler, and chatd.EditMessage). The chat's persisted selection never changed and the regenerated turn ran without the newly enabled MCP tools. Two dogfood users hit this within hours; there is no error anywhere and the UI shows the opposite of the server state.

Changes

  • codersdk: add MCPServerIDs *[]uuid.UUID to EditChatMessageRequest, mirroring CreateChatMessageRequest (nil preserves the current selection).
  • chatd: extract the send path's MCP update block into one shared applyRequestedMCPServerIDs helper (explore-subagent snapshot immutability guard plus Force On enforcement, Cure53 CDM-02-010) and call it from both SendMessage and EditMessage, so enforcement cannot drift between the two paths.
  • coderd: extract the send handler's request validation (dedupe, enabled-in-organization check, persisted-ID exemption) into normalizeRequestedChatMCPServerIDs and wire it into the edit handler, which now threads the selection into EditMessageOptions.
  • Frontend: the edit request now includes mcp_server_ids: [...effectiveMCPServerIds], exactly like the send path, making the picker's displayed state real.
  • make gen artifacts (swagger, API docs, typesGenerated.ts).

Tests

Each layer is covered and was proven with independent red toggles (removing one layer's wiring fails only that layer's tests):

  • chatd (TestEditMessage_MCPServerIDs): edit applies a provided selection, nil preserves it, an emptied list cannot remove a force_on server, and explore subagent chats keep the spawn-time snapshot.
  • API (TestPatchChatMessage/MCPServerIDsApplied, MCPServerIDsInvalidRejected): persistence via the endpoint, omission preserves, unknown IDs get the same 400 as the send path.
  • Storybook (EditAppliesMCPServerSelection): toggling a server on during an edit puts it in the edit request payload.

Note: the AgentChatPage.stories.tsx story "Queued For Capacity After Polling" fails locally on current main as well (verified against the main baseline with this branch's changes reverted); it is unrelated to this diff.

Remote dogfood UAT ran on the exact head and passed, including proof that the regenerated turn actually gains the newly enabled MCP server's tools.

🤖 Xum acted on Mike's (@ibetitsmike) behalf. • Model: anthropic:claude-fable-5

@github-actions

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.

@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: fa871b0e74

ℹ️ 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/x/chatd/chatd.go
Comment thread site/src/pages/AgentsPage/AgentChatPage.stories.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentChatPage.tsx
Adds the required ARCHITECTURE.md TODO for the new EditMessage side
effect and trims historical commentary from the new story JSDoc.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 730a633b2e

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: 6987b3d50c

ℹ️ 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/x/chatd/chatd.go
@ibetitsmike
ibetitsmike marked this pull request as ready for review August 24, 2026 15:12
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6987b3d50c

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

@ibetitsmike
ibetitsmike merged commit b6d7653 into main Aug 24, 2026
35 of 36 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chat-edit-mcp-server-ids branch August 24, 2026 15:39
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 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