Repository navigation
fix(coderd/x/plugins): deliver plugin events only to the active link - #197
Conversation
DeleteChatWakeupByID, UpdateChatWakeupRunStatus and DeleteExpiredPluginLinkCodes have no production callers. Regenerate the sqlc output and drop the RBAC, metrics, mock and test cases that only existed for them. Part of #167.
TestChatWakeupRuns reached a delivered run through UpdateChatWakeupRunStatus and counted runs after DeleteChatWakeupByID; TestPluginLinkCodes counted rows to verify DeleteExpiredPluginLinkCodes. Both queries have no production callers and are removed (#167), so insert the delivered run directly and drop the purge-count assertion.
One Coder user may link several external identities to the same plugin, and each identity follows its own active chat. deliverChat broadcast every assistant reply and status change to all of the owner's links and then overwrote every link's active chat with the delivered chat, so a message from either external account continued the other account's conversation. Deliver only to the links whose active chat is the chat being delivered, and drop the by-user overwrite: the active chat is set per link when a chat is created. Remove the now-unused SetPluginUserLinksActiveChatByUser query and its RBAC, metrics, mock and test plumbing. Part of #172 (thread 3).
…eadline plugintest.BuildWasm shells out to go build and does not observe the context; a cold build on CI can outlast WaitSuperLong, so Load received an already-expired deadline. Build first, then start the clock.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d078523087
ℹ️ 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".
The by-user active-chat update pointed every link of a user at the chat it last delivered to, so upgraded deployments keep several links of one user on the same chat. Delivery now selects links by active_chat_id equality and that only reaches a single identity while duplicates remain. Keep the first link by external_id per chat and clear the rest; a cleared link re-points at the next chat started from it.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Breezy! 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". |
…hema TestSQLCSchemaOrder requires sqlc to read every fork node in graph order.
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8cef50262e
ℹ️ 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".
Clear every link of a group that shares an active chat instead of keeping one: nothing records which identity opened a shared chat. A partial unique index on (plugin_id, active_chat_id) holds the invariant, including against a replica still on the previous release during a rolling upgrade. Delivery reads the links and calls the plugin under callMu, the lock host calls run under when a webhook moves a link to a new chat, so a concurrent move cannot leave delivery on a stale link.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Swish! 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". |
…s-link-routing # Conflicts: # coderd/database/forkdb/plugins_test.go
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b88c501976
ℹ️ 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
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c844db5fe4
ℹ️ 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
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9df0731db2
ℹ️ 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".
…chat binding delivered without a rewrite
|
@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". |
Merged as a squash of head
|
Sends a plugin chat event only to the link that follows that chat, not to every link the chat owner has.
Before this change,
deliverChatsent each event to every plugin user link of the chat owner. ThenSetPluginUserLinksActiveChatByUserpointed all of the owner's links at the delivered chat. With two links on one plugin, both links got every event, and a message in one chat took over the other link's active chat.Now an event for chat X goes to the link whose active chat is X:
plugin_chat_bindings.deliveredflag stops the chat from going to any other link, because one owner's links can reach different people. Every binding that exists at upgrade starts as delivered.dedup_plugin_link_active_chatsclears the active chat of every link in a group that shares one active chat. The by-user update could leave groups like that. The migration also adds the partial unique indexplugin_user_links_active_chat_idx (plugin_id, active_chat_id), so at most one link follows a chat. A second migration,plugin_chat_binding_delivered, adds thedeliveredflag. Bindings that exist at upgrade start as delivered through the column default, so the table isn't rewritten. New bindings start undelivered.callMufrom the link lookup through the event call. Without it, a concurrent webhook host call could move the link between the two steps.The test plugin wasm is also built before the test deadline starts.
plugintest.BuildWasmrunsgo buildand ignores the context, so a cold CI build outlastsWaitSuperLongbeforeLoadstarts. In chat-tests that showed up ascontext deadline exceeded.Testing:
TestDeliverChatRoutesToActiveLinkloads the bridge plugin in-process. Its table cases cover: only the active link receives the event, a single idle link gets the chat and the event, several idle links get nothing, a plugin-started chat that no link follows gets nothing, and a chat that already reached a link gets nothing once no link follows it. Each case checks whether the cursor update records a delivery.TestPluginChatBindingschecks that the delivered flag survives a later update that reached no link. Breaking the idle-link count check, the plugin-label check, the delivered check, the delivery record, or the flag's persistence in SQL makes the matching test fail.TestPluginUserLinkActiveChatUnique(forkdb) checks the unique index.go test ./coderd/x/plugins/passes.Builds on #194 (merged). Part of #172.