Skip to content

MBTI-PDF-RESULT-SNAPSHOT-CONTENT-06: inject snapshot desktop clone content#1503

Merged
fermatmind merged 1 commit into
mainfrom
codex/mbti-pdf-result-snapshot-content-06
Jul 1, 2026
Merged

MBTI-PDF-RESULT-SNAPSHOT-CONTENT-06: inject snapshot desktop clone content#1503
fermatmind merged 1 commit into
mainfrom
codex/mbti-pdf-result-snapshot-content-06

Conversation

@fermatmind

@fermatmind fermatmind commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Server-prefetch MBTI desktop clone content in the result /print bootstrap and pass it into the snapshot render tree.
  • Add a snapshot content contract that validates fullCode, locale, career/growth/relationships visible content, and placeholder contamination before allowing PDF readiness.
  • Add snapshot strict resolver behavior so missing storage content fails closed instead of returning placeholder slots.
  • Keep ordinary /result/{id} behavior on the existing client-side desktop clone fetch path.

Contract Answers

  1. Snapshot content authority source: personality desktop clone storage content via /api/v0.5/personality/{type}/desktop-clone.
  2. /print route server-prefetches desktop clone content: yes, after report-access/report bootstrap derives the MBTI fullCode.
  3. Snapshot v3 no longer depends on client hydration to get formal desktop clone content.
  4. Placeholder in snapshot mode fails closed and does not set PDF_READY.
  5. zh-CN behavior: formal desktop clone content can be injected server-side and marked data-pdf-content-ready="true".
  6. en missing behavior: fails closed with DESKTOP_CLONE_CONTENT_MISSING; no zh-CN or placeholder fallback.
  7. This PR does not clean Cookie/header/footer/sidebar; that remains PR-C.
  8. This PR does not guarantee final PDF download success; PR-C blockers can still keep PDF fail-closed.
  9. Ordinary /result page behavior should remain unchanged.
  10. Follow-ups: PR-C Print Route Desktop Snapshot Shell / Runtime Pollutant Removal; PR-D Rendered PDF Smoke / Quality Gate; PR-E Visual Polish / Pagination.

Validation

  • ./node_modules/.bin/vitest run tests/contracts/mbti-desktop-clone-snapshot-content.contract.test.ts tests/contracts/result-client-view-state.contract.test.tsx tests/contracts/result-gotenberg-print-route.contract.test.ts
  • ./node_modules/.bin/vitest run tests/contracts/mbti-desktop-storage-cutover.contract.test.ts tests/contracts/personality-desktop-clone-api.contract.test.ts
  • pnpm test:contract
  • pnpm typecheck
  • git diff --check

Deferred

  • No fap-api changes. fap-web uses the existing desktop clone API; snapshot-only helper allows en lookup while the ordinary page helper remains zh-only.
  • No content import, no server/env changes, no deploy.
  • No CookieBanner/SiteChrome/footer/sidebar cleanup or PDF visual polish in this PR.

@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: 5aa588f8a1

ℹ️ 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 on lines +931 to +933
if (normalized === "en" || normalized === "en-us") {
return "en";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Scope English CMS fetch to updated contracts

This new English branch makes fetchPersonalityDesktopCloneContent("INFJ-A", "en") hit /desktop-clone?locale=en, but the existing API contract still requires non-zh locales to return null without any network call and normalizeDesktopCloneApiLocale("en") to stay null. I verified this with ./node_modules/.bin/vitest run tests/contracts/personality-desktop-clone-api.contract.test.ts tests/contracts/mbti-desktop-storage-cutover.contract.test.ts, which fails at tests/contracts/personality-desktop-clone-api.contract.test.ts:623 and :717; because pnpm test:contract runs the whole contracts directory, CI remains broken unless these contracts are updated or English fetching is isolated from the existing public adapter contract.

Useful? React with 👍 / 👎.

const isZh = locale === "zh";
const language = isZh ? "zh" : "en";
const content = isZh ? storageContent : null;
const content = storageContent;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve normal English resolver fallback

Dropping the zh-only guard here means any normal resolver call with locale: "en" and storageContent now returns meta.contentSource === "storage" and renders authored desktop-clone slots, even though the existing storage-cutover contract still asserts English remains on the placeholder/null path outside the snapshot flow. The same verified contract run fails at tests/contracts/mbti-desktop-storage-cutover.contract.test.ts:482, so pnpm test:contract/verify:pr will fail unless this storage adoption is made snapshot-only or the cutover contract is deliberately updated.

Useful? React with 👍 / 👎.

@fermatmind fermatmind force-pushed the codex/mbti-pdf-result-snapshot-content-06 branch from 5aa588f to 0cf87e4 Compare July 1, 2026 01:43

@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: 0cf87e485e

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

zhTitle: "你可能会喜欢的职业选择",
source: null,
fallback: MBTI_DESKTOP_CLONE_PLACEHOLDER_SLOTS_ZH.chapters.career.lockedBlocks[0],
fallback: slots.chapters.career.lockedBlocks[0],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep locked teaser fallbacks redacted outside snapshots

For a locked zh result after desktop-clone storage loads through the normal MbtiResultShell path, this now feeds CMS lockedBlocks into MbtiClonePremiumTeaserBlock; that component renders each blurredItems title/body into the DOM and only applies CSS blur, so any non-redacted locked preview items returned by the API become extractable to users who have not unlocked the report. Before this change the locked chapter teasers always used the local placeholder blocks, so the storage-backed locked copy was not exposed on ordinary /result pages; keep these fallbacks placeholder/redacted unless the render is the strict snapshot path.

Useful? React with 👍 / 👎.

@fermatmind fermatmind merged commit 38974cf into main Jul 1, 2026
6 checks passed
@fermatmind fermatmind deleted the codex/mbti-pdf-result-snapshot-content-06 branch July 1, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant