Skip to content

fix(og): rewrite custom components and subtractions before composing cards - #1088

Merged
mkpoli merged 1 commit into
mainfrom
fix/og-custom-components
Dec 2, 2026
Merged

mkpoli merged 1 commit into
mainfrom
fix/og-custom-components

Conversation

@mkpoli

@mkpoli mkpoli commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

TL;DR: OG custom-component rewriting — bundle custom-components.json.gz into OG assets and rewrite custom components and subtractions (such as ㇯雋隹 → X-00033) via custom.drawable() before composing share cards, bumping CARD_VERSION to v21.

ELI5

When someone shares ㇯雋隹 (or IDS bot renders a link preview for it), the card renderer used to pass ㇯雋隹 straight to the composer, which tried a raw subtraction of 雋 minus 隹 and produced a mangled glyph. Now the OG worker looks up custom-components.json.gz first, rewrites ㇯雋隹 (and {33}, &CDP-8DDF;, &X-00033;) to its custom-component drawing form (X-00033), and renders the clean pre-cut glyph instead.

Before / After (og/㇯雋隹.png)

Before (v20) After (v21)
Before After

Flow

flowchart LR
  A["Incoming card sequence"] --> B["waysToDraw"]
  B --> C{"Has custom or subtraction"}
  C -->|"Yes"| D["Load custom-components.json.gz"]
  D --> E["Rewrite via custom.drawable"]
  C -->|"No"| F["Keep sequence"]
  E --> G["UCV form and plainText"]
  F --> G
  G --> H["Compose with custom-forms.json.gz"]
  H --> I["Render OG PNG card v21"]
Loading

Root Cause

  • scripts/og-assets.mjs copied custom-forms.json.gz into dist/og/data/, but did not copy data/custom-components.json.gz.
  • worker/render.js never loaded custom-components.json.gz or called custom.drawable(sequence) in waysToDraw(), so custom-component subtractions like ㇯雋隹 bypassed the custom component table and fell through to raw subtraction.
  • worker/card-version.js stayed at v20, keeping previously rendered broken cards cached at the edge.

Verification

  • bun test tests/card-units.test.js (8/8 pass, including waysToDraw rewriting ㇯雋隹, {33}, &CDP-8DDF;, &X-00033; → ).
  • bun run build:site succeeds and packages dist/og/data/custom-components.json.gz.
  • Rendered og/㇯雋隹.png locally via worker/render.js + dist/og/ and confirmed visually.

Summary by CodeRabbit

  • New Features
    • Card drawings now support custom components and their subtraction forms, displaying them with the appropriate drawing sequence.
    • Custom-component data is included with generated card assets, helping ensure it is available when rendering these drawings.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The OG asset generation script now includes compressed custom-component data. The worker loads this data and uses it to resolve drawing sequences. Tests cover several custom-component forms, and the card version changes from v20 to v21.

Changes: Custom-component drawing resolution

Layer / File(s) Summary
Bundle custom-component data
scripts/og-assets.mjs
The asset script copies custom-components.json.gz into the output data directory and includes it in the generated-data log.
Load and resolve custom components
worker/render.js, worker/card-version.js, tests/card-units.test.js
The worker loads the custom-components index and uses its drawable result for supported sequences, falling back to the original sequence when the data is unavailable. Tests check four input forms. The card version changes to v21.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Renderer as waysToDraw
  participant Asset as custom-components asset
  participant Index as custom-components index
  Renderer->>Asset: Load compressed data when needed
  Asset-->>Renderer: Return data or loading/parsing failure
  Renderer->>Index: Create index from loaded data
  Index-->>Renderer: Return drawable result
Loading

Possibly related PRs

  • mkpoli/ids-input#1087: Both PRs bundle custom-component data and address custom-component subtraction rendering.
  • mkpoli/ids-input#645: This PR changes the same CARD_VERSION constant used for cache handling and image URLs.
Merge Risk: Minimal · up to 5b3b0

Open Graph cards for custom-component subtractions should now render the intended glyph, and cached cards are refreshed by the version bump. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: custom components and subtractions are rewritten before OG cards are composed. The raw summary shows waysToDraw in worker/render.js rewriting sequences via the custom-…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: custom components and subtractions are rewritten before OG cards are composed. The raw summary shows waysToDraw in worker/render.js rewriting sequences via the custom-components index, and the bundled custom-components.json.gz in the OG script. The title is specific and matches the changeset and PR objectives.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 15066c42-ede7-430f-b1ef-33f6c0d5ff0f
Commits

Reviewing files that changed from the base of the PR and between 97e5444 and 5b3b0de.

Files selected for processing: 4

  • scripts/og-assets.mjs
  • tests/card-units.test.js
  • worker/card-version.js
  • worker/render.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@mkpoli
mkpoli merged commit 1b917a6 into main Dec 2, 2026
1 of 2 checks passed
@mkpoli
mkpoli deleted the fix/og-custom-components branch December 2, 2026 01:12
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