fix: apply MCP server selection when editing a chat message - #28471
Conversation
Docs previewCheck 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. |
|
@codex review |
There was a problem hiding this comment.
💡 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".
Adds the required ARCHITECTURE.md TODO for the new EditMessage side effect and trims historical commentary from the new story JSDoc.
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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_idsat every layer (frontend request builder,codersdk.EditChatMessageRequest, thePATCH /chats/{chat}/messages/{message}handler, andchatd.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: addMCPServerIDs *[]uuid.UUIDtoEditChatMessageRequest, mirroringCreateChatMessageRequest(nil preserves the current selection).chatd: extract the send path's MCP update block into one sharedapplyRequestedMCPServerIDshelper (explore-subagent snapshot immutability guard plus Force On enforcement, Cure53 CDM-02-010) and call it from bothSendMessageandEditMessage, so enforcement cannot drift between the two paths.coderd: extract the send handler's request validation (dedupe, enabled-in-organization check, persisted-ID exemption) intonormalizeRequestedChatMCPServerIDsand wire it into the edit handler, which now threads the selection intoEditMessageOptions.mcp_server_ids: [...effectiveMCPServerIds], exactly like the send path, making the picker's displayed state real.make genartifacts (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):
TestEditMessage_MCPServerIDs): edit applies a provided selection, nil preserves it, an emptied list cannot remove aforce_onserver, and explore subagent chats keep the spawn-time snapshot.TestPatchChatMessage/MCPServerIDsApplied,MCPServerIDsInvalidRejected): persistence via the endpoint, omission preserves, unknown IDs get the same 400 as the send path.EditAppliesMCPServerSelection): toggling a server on during an edit puts it in the edit request payload.Note: the
AgentChatPage.stories.tsxstory "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.