Repository navigation
fix: derive {component} key placeholder from instances - #103
Conversation
Text nodes inside a component instance did not resolve the {component}
placeholder because getAllParents only matched COMPONENT / COMPONENT_SET
parents, not INSTANCE. Keys generated for instances lost the component
name (e.g. "-log-in" instead of "component-log-in").
Now when an INSTANCE parent is encountered, resolve its main component
(using the component set name when the main component is a variant).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe ChangesInstance-based component resolution
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/main/utils/nodeParents.tsOops! Something went wrong! :( ESLint: 9.39.3 Error: ESLint configuration in --config » eslint-config-preact is invalid:
Referenced from: /.eslintrc.json 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. Comment |
v2 replaces the Preact codebase entirely, so every conflict was the same shape: a file this branch deleted and main went on to edit. All of them are resolved by keeping the deletion. The fixes main made in the meantime are not lost — each already has a native implementation here: - #103 (derive {component} from instances) → nodes/nodeParents.ts, which resolves the main component of an instance and adds {instance} as a variable of its own - #105 (key format cursor) → ui/lib/components/ui/keyFormatInput.svelte - #100/#98 (scan and font caching) → stores/app.svelte.ts, api/pageNodes.ts cypress/ and docs/superpowers/ are left out for the same reason: the rewrite dropped Cypress for Playwright, so a Cypress spec and the design notes for a Preact fix would document code that no longer exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Problem
When generating a key for a text node that lives inside a component instance, the
{component}placeholder was left empty. Keys came out missing the component name — e.g.-log-ininstead ofcomponent-log-in. A customer reported this.The cause:
getAllParentsonly matched parents of typeCOMPONENT/COMPONENT_SET. An instance node has typeINSTANCE, so the component parent was never found for instances.Fix
When an
INSTANCEparent is encountered while walking the node hierarchy, resolve its main component and use its name. If the main component is a variant inside a component set, the set name is used so the key gets the recognizable component name.src/main/utils/nodeParents.ts.mainComponentis read synchronously, consistent with the existing synchronousfigma.getNodeByIdusage. No measurable performance impact.Note
This uses the synchronous
mainComponentgetter, which matches the plugin's current (nondynamic-page) document access mode. If the plugin ever switches todocumentAccess: "dynamic-page", this and the existingfigma.getNodeByIdcall would both need to move to their async equivalents.🤖 Generated with Claude Code
Summary by CodeRabbit