Social: render connection template in per-network preview#48603
Merged
manzoorwanijk merged 4 commits intotrunkfrom May 7, 2026
Merged
Social: render connection template in per-network preview#48603manzoorwanijk merged 4 commits intotrunkfrom
manzoorwanijk merged 4 commits intotrunkfrom
Conversation
In per-network mode, the form prefills the message field with `connection.template` when no per-post override is set, but the preview pipeline still resolved messages via `connection.message ?? globalMessage`, so the rendered preview ignored the connection template. Mirror the form's fallback chain in `useRenderMessageItems` (the items POSTed to `wpcom/v2/publicize/render-messages`) and in the `baseMessage` of `useConnectionPreviewData` (the non-rendered fallback shown while the rendered batch is loading or when templates are disabled). Also remove a leftover `console.log`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`syncConnections` runs when per-network mode is enabled and copies the global share message + media into each connection that has no existing customization. For connections that have their own `template` set, that copy was overwriting the template with the global message (or with `''`), preventing the connection-template fallback from ever taking effect in per-network mode. Skip writing `message` for connections that have a `template`, so `connection.message` stays undefined and the form / preview fall back to the connection template. Media fields still sync as before since per-network mode forces attachment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The earlier render-pipeline fix applied the `connection.template` fallback unconditionally, so in global mode the preview started rendering the connection template instead of the global share message. Gate the template fallback on `isPerNetworkMode` so global mode falls through to `globalMessage` as it did before. `connection.message` priority is preserved in both modes, matching the existing tests and `useConnectionPreviewData`'s rendered-batch behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
gmjuhasz
approved these changes
May 7, 2026
Contributor
gmjuhasz
left a comment
There was a problem hiding this comment.
Code seems straight forward and I cant reproduce the bleed with the changes
Code Coverage SummaryCoverage changed in 3 files.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #48568 (SOCIAL-453).
Proposed changes
#48568 prefilled the per-network editor's message field with
connection.templatewhen no per-post override was set, but only in the form input. This PR aligns the rest of the pipeline with that behavior:useRenderMessageItems: in per-network mode, fall back toconnection.template(thenglobalMessage) whenconnection.messageis empty, so the items POSTed towpcom/v2/publicize/render-messagesmatch what the form displays. Global mode is unchanged (connection.message ?? globalMessage).useConnectionPreviewData: apply the same fallback tobaseMessageso the non-rendered fallback (templates-disabled sites, or while the rendered batch is loading) also shows the connection template.usePerNetworkCustomization.syncConnections: when toggling per-network mode on, do not overwriteconnection.messagefor connections that have their owntemplate— leaving itundefinedlets the editor and preview fall back to the connection template instead of clobbering it with the global share message.Does this pull request change what data or activity we track or use?
No.
Testing instructions
Prerequisites: site features include
social-enhanced-publishingandsocial-message-templates, plus a Jetpack Social paid plan (so per-network customization is available).Connection template flows through to the per-network preview
Hi from {network}: {post_title}) for one connection in connection management.Toggling per-network mode preserves the connection template
Switching back to global mode does not bleed the connection template
No regression for connections without a template
Automated checks
pnpm --filter @automattic/jetpack-publicize typecheckpnpm --filter @automattic/jetpack-publicize test