feat(email): preview provider tokens with labeled sample values (Issue #70 Slice 3) - #92
Merged
Merged
Conversation
…#70 Slice 3) The compiled preview showed provider-resolved tokens as raw {{cb:...}} text. Token_Preview now derives a separate, display-only sample view from a successful artifact using each token's preview behavior: sample tokens show fixed synthetic values (Alex, Sample, reserved example.com links), omit tokens such as subscriber.email are removed, and literal tokens stay canonical. Nothing reads subscriber data, options, or providers. The preview endpoint returns the view as `sample` next to the unchanged canonical html, text, and fingerprint, so preview and download stay byte-identical and review fingerprints are unaffected. The preview modal labels the sample view and offers a toggle back to the tokens; source and download always use the canonical artifact. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Slice 3 of #70. Builds on Slice 2 (#91: canonical token resolution and snapshot provenance). This does not close #70.
What this slice does
The compiled preview showed provider-resolved tokens as raw
{{cb:...}}text. The preview can now show a clearly labeled sample view with synthetic values, while the canonical artifact stays exactly as it is.Domain/Email/Token/Token_Preview(pure) derives the sample view from a successful artifact, using each token's registered preview behavior:samplesubscriber.first_name,subscriber.last_name,campaign.view_online_url,campaign.unsubscribe_urlAlex,Sample,https://example.com/campaignbridge-preview/...omitsubscriber.emailliteralexample.comdomain.SAMPLE_VALUESin step with the registry.Artifact stays canonical
POST /campaignbridge/v1/previewadds one field,sample:{ html, text }, ornullwhen the compile failed or no token needs a sample.html,text, andfingerprintare unchanged. So:matches_review()fingerprints are unaffected;COMPILER_VERSIONis unchanged (output is identical).Editor preview
The preview modal shows a Personalization toggle, Sample values / Tokens, only when a sample view exists. It defaults to samples and shows a note: "Sample values stand in for each subscriber's data. Source and download keep the tokens." The iframe title names the sample view for assistive tech. The Source pane always shows the canonical HTML.
Tests
Token_Preview_Test: sample/registry parity, reserved domain, the compiled artifact's sample view (HTML escaping, VML + HTML button hrefs, plain text), the artifact left unchanged, literal/omit behavior, construction failure, and CampaignBridge-resolved tokens left alone.Preview_Route_Test:sampleis null without tokens and on failure, and it personalizes whilehtmlandtextkeep the tokens.preview-personalization.spec.ts: a real editor → preview → sample → tokens round trip.Not in this slice
organization.*values, so templates using them reporttoken.unresolvedin preview. Supplying sample organization values would put samples into the artifact and break byte-identity, so this waits for that source.🤖 Generated with Claude Code