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

use autosave rhs for spec #2143

Merged
merged 13 commits into from
Feb 19, 2025
Merged

Conversation

tintinthong
Copy link
Contributor

@tintinthong tintinthong commented Feb 13, 2025

@tintinthong tintinthong marked this pull request as draft February 13, 2025 14:49
Copy link

github-actions bot commented Feb 13, 2025

Host Test Results

    1 files  ±0      1 suites  ±0   22m 50s ⏱️ - 1m 17s
765 tests +1  763 ✔️ +1  2 💤 ±0  0 ±0 
770 runs  +1  768 ✔️ +1  2 💤 ±0  0 ±0 

Results for commit eed0784. ± Comparison against base commit 0d0443d.

♻️ This comment has been updated with latest results.

@tintinthong tintinthong requested review from FadhlanR, burieberry and a team February 17, 2025 03:42
@tintinthong tintinthong marked this pull request as ready for review February 17, 2025 03:42
@FadhlanR
Copy link
Contributor

FadhlanR commented Feb 17, 2025

The Playground panel also needs this mechanism. Could we add auto-save to the CodeSubmode component so it can be used by both the Playground panel and the Spec Preview? Or would it be better to have auto-save options in the card resource itself?

@tintinthong
Copy link
Contributor Author

The Playground panel also needs this mechanism. Could we add auto-save to the CodeSubmode component so it can be used by both the Playground panel and the Spec Preview? Or would it be better to have auto-save options in the card resource itself?

Ok I see. I feel pushing everything up to code-submode will make it cluttered as others have complained about this before. Presumably, we want some sort of abstraction to make the auto-save reusable.

Do you think its a good idea to use another resource to encapsulate getCard that contains all auto-save features? This resource will react with changes in id.

@FadhlanR
Copy link
Contributor

The Playground panel also needs this mechanism. Could we add auto-save to the CodeSubmode component so it can be used by both the Playground panel and the Spec Preview? Or would it be better to have auto-save options in the card resource itself?

Ok I see. I feel pushing everything up to code-submode will make it cluttered as others have complained about this before. Presumably, we want some sort of abstraction to make the auto-save reusable.

Do you think its a good idea to use another resource to encapsulate getCard that contains all auto-save features? This resource will react with changes in id.

I think it's a good idea. What do you think? @lukemelia @habdelra

@habdelra
Copy link
Contributor

habdelra commented Feb 17, 2025

The Playground panel also needs this mechanism. Could we add auto-save to the CodeSubmode component so it can be used by both the Playground panel and the Spec Preview? Or would it be better to have auto-save options in the card resource itself?

Ok I see. I feel pushing everything up to code-submode will make it cluttered as others have complained about this before. Presumably, we want some sort of abstraction to make the auto-save reusable.

Do you think its a good idea to use another resource to encapsulate getCard that contains all auto-save features? This resource will react with changes in id.

TBH, this sounds like a feature of the store. like when you use getCard() you should be able to say that it should be an autosaved card. based on the very latest store refactor that was just merged that autosave flag would be passed thru the to the store service, and the store service would be responsible for binding and unbinding the autosave handler on the card instance's change subscription.

Also a refactor like this would eliminate one of the TODO's noted in the CardResource, which is to remove the onCardInstanceChanged optional param in getCard as the only place that is used is to wire up the autosave. moving the auto save into the store seems like a really good refactor. Unsure though, if you want to do it as part of this PR tho...

Copy link
Contributor

@FadhlanR FadhlanR left a comment

Choose a reason for hiding this comment

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

Looks great!

@tintinthong
Copy link
Contributor Author

The Playground panel also needs this mechanism. Could we add auto-save to the CodeSubmode component so it can be used by both the Playground panel and the Spec Preview? Or would it be better to have auto-save options in the card resource itself?

Ok I see. I feel pushing everything up to code-submode will make it cluttered as others have complained about this before. Presumably, we want some sort of abstraction to make the auto-save reusable.
Do you think its a good idea to use another resource to encapsulate getCard that contains all auto-save features? This resource will react with changes in id.

TBH, this sounds like a feature of the store. like when you use getCard() you should be able to say that it should be an autosaved card. based on the very latest store refactor that was just merged that autosave flag would be passed thru the to the store service, and the store service would be responsible for binding and unbinding the autosave handler on the card instance's change subscription.

Also a refactor like this would eliminate one of the TODO's noted in the CardResource, which is to remove the onCardInstanceChanged optional param in getCard as the only place that is used is to wire up the autosave. moving the auto save into the store seems like a really good refactor. Unsure though, if you want to do it as part of this PR tho...

Thanks @habdelra for the input. I have excluded this refactor and @FadhlanR will take a first pass at it in his playground panel auto-save pr

Copy link
Contributor

@burieberry burieberry left a comment

Choose a reason for hiding this comment

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

Not the smoothest editing experience (sometimes autosave happens while still typing, and sometimes the spec panel disappears and comes back) but it works.

@tintinthong
Copy link
Contributor Author

Not the smoothest editing experience (sometimes autosave happens while still typing, and sometimes the spec panel disappears and comes back) but it works.

I'll see if I can refine this after integrating with store auto-save fadhlan is working on

@tintinthong tintinthong merged commit 07cd5c0 into main Feb 19, 2025
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.

4 participants