Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve way to verify is a skill card in spec #2239

Merged
merged 5 commits into from
Mar 11, 2025

Conversation

richardhjtan
Copy link
Contributor

@richardhjtan richardhjtan commented Mar 4, 2025

Refer to https://linear.app/cardstack/issue/CS-8056/cover-boxel-spec-for-skill

This PR is to improve the identification of skill cards in the spec preview component

We would determine the skill card when:

  • the code ref is module under https://cardstack.com/base/skill-card
  • the code ref name is SkillCard
  • also cover the class that skill card is a subclass for another card - finding under the chain of card type

@richardhjtan richardhjtan requested review from tintinthong and a team March 4, 2025 09:56
Copy link

github-actions bot commented Mar 4, 2025

Host Test Results

    1 files  ±0      1 suites  ±0   24m 15s ⏱️ +3s
798 tests +5  796 ✔️ +5  2 💤 ±0  0 ±0 
803 runs  +5  801 ✔️ +5  2 💤 ±0  0 ±0 

Results for commit 693f9cc. ± Comparison against base commit 1e9a06f.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@lukemelia lukemelia left a comment

Choose a reason for hiding this comment

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

This seems like it would not cover a skill that is a subclass of another skill.

Comment on lines 450 to 453
selectedDeclaration.cardType.type &&
isResolvedCodeRef(selectedDeclaration.cardType.type.codeRef) &&
selectedDeclaration.cardType.type.codeRef.name === 'SkillCard' &&
selectedDeclaration.cardType.type.codeRef.module ===
Copy link
Contributor

@tintinthong tintinthong Mar 5, 2025

Choose a reason for hiding this comment

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

The original code was clearer that it didn't do much.

A possible way to fix this is to introduce specType data in card-type resource. Another way is to just recurse the chain on read and make a stopping condition based on the type data that is already

I'd recommend the 2nd way unless that is visibly inefficient

The test should have a 1-level super and a 2-level super

@richardhjtan
Copy link
Contributor Author

Thanks @lukemelia @tintinthong for the feedback. I switch the approach by finding the chain in cardType.typeCache that consists the boxel based skill card module

@richardhjtan richardhjtan requested review from tintinthong, lukemelia and a team March 6, 2025 07:11
Copy link
Contributor

@lukemelia lukemelia left a comment

Choose a reason for hiding this comment

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

Is this typeCache guaranteed to be populated when this check is performed?

@richardhjtan
Copy link
Contributor Author

richardhjtan commented Mar 7, 2025

Is this typeCache guaranteed to be populated when this check is performed?

To be assured, I introduce a function to find the class matches the desired codeRef at the first level or recursively.

693f9cc

@richardhjtan richardhjtan requested a review from lukemelia March 8, 2025 05:08
@richardhjtan richardhjtan merged commit db1aaed into main Mar 11, 2025
47 of 48 checks passed
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.

3 participants