You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(og): rewrite custom components and subtractions before composing cards - #1088
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)
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
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.
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.
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
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.
TL;DR: OG custom-component rewriting — bundle
custom-components.json.gzinto OG assets and rewrite custom components and subtractions (such as雋隹→X-00033) viacustom.drawable()before composing share cards, bumpingCARD_VERSIONtov21.ELI5
When someone shares
雋隹(orIDS botrenders 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 upcustom-components.json.gzfirst, 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)v20)v21)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"]Root Cause
scripts/og-assets.mjscopiedcustom-forms.json.gzintodist/og/data/, but did not copydata/custom-components.json.gz.worker/render.jsnever loadedcustom-components.json.gzor calledcustom.drawable(sequence)inwaysToDraw(), so custom-component subtractions like雋隹bypassed the custom component table and fell through to raw subtraction.worker/card-version.jsstayed atv20, keeping previously rendered broken cards cached at the edge.Verification
bun test tests/card-units.test.js(8/8 pass, includingwaysToDrawrewriting雋隹,{33},&CDP-8DDF;,&X-00033;→).bun run build:sitesucceeds and packagesdist/og/data/custom-components.json.gz.og/雋隹.pnglocally viaworker/render.js+dist/og/and confirmed visually.Summary by CodeRabbit