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

Runtime Discovery Editor #551

Merged
merged 17 commits into from
Jul 11, 2023
Merged

Runtime Discovery Editor #551

merged 17 commits into from
Jul 11, 2023

Conversation

nerik
Copy link
Contributor

@nerik nerik commented Jun 5, 2023

Screenshot 2023-06-05 at 14 48 36

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 472d40c
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/64ac213a96915e0008bdec14
😎 Deploy Preview https://deploy-preview-551--veda-ui.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nerik nerik force-pushed the spike/runtime-mdx-renderin branch from 26ec046 to 20cedd3 Compare June 8, 2023 12:41
@nerik
Copy link
Contributor Author

nerik commented Jun 8, 2023

This is the state of things:

Untitled.mov

I'd be interested in hearing your thoughts about the approach @danielfdsilva @hanbyul-here ... Now to tackle error handling :trollface:

@hanbyul-here
Copy link
Collaborator

hanbyul-here commented Jun 9, 2023

It is amazing to see how you approached this problem. Such an exciting prototype with a relatively small amount of code 👯 A few thoughts after playing with it. (Maybe too detailed at this point?)

I tried to make errors in various ways. I have found two ways to make errors so far. 1. MDX syntax level (ex. <> in the middle of the paragraph): error message displays below the code mirror editor 2. Component level error (ex. giving a wrong dataset id to Map component, give a not allowed combination to Block): this displays hinted error, leaving other parts of the page intact. As you said, a good next step will be error handling, including consolidating how these errors are handled. (A real quick workaround for 2. will be having a button like 'try again', but it prob goes against 'real-time' editing principle.)

A draggable code editor is a brilliant idea to work around some problems quickly. But while trying to edit, I realized that dragging is also needed for editing (duh) 🤔 maybe some mechanisms to unlock/lock the code editors dragging?

How do you picture the output of this editing process to be saved? Local files? GitHub?

hanbyul-here added a commit that referenced this pull request Jun 14, 2023
…#556)

This is a fix for an overdue bug. (that can help
#551) We want to suppress cra
overlay for errors already handled on the component level, and this
suppression was not working because the style selector was not correct.
(I realized that this is not the main problem for mdx editor. We would
need some sort of logic to clear out errors when an error is fixed. but
this one is a good one to fix anyway.)

I sneaked in a little documentation change and other little code
changes. Since we enforce users to wrap everything with `<Block>`,
Figure doesn't need to be wrapped with error boundary.
@nerik nerik changed the title Runtime MDX Editor Runtime Discovery Editor Jun 19, 2023
@danielfdsilva
Copy link
Collaborator

danielfdsilva commented Jun 20, 2023

@nerik This is quite an interesting approach and it's nice to get the immediate preview! :D

I spent some time thinking about the error handling, but it is not straightforward to do with the current block scoped approach.
I think the error handling for the MDX editor should be different from the rest. The whole error handling should happen at a higher level so it can be cleared once the content changes. (An idea that you had already mentioned) Each block would render their own error, but they would be captured and stored higher up.

I tried to see if we could compare the props of a given block and clear the error if they were different, but since the mdx get evaluated on every render, the components are always different even if the content did not change, so this approach is a no go.

@nerik
Copy link
Contributor Author

nerik commented Jun 21, 2023

@hanbyul-here @danielfdsilva This is ready for review. And merge if we all agree on #559 (comment)

This is new since we spoke last time:

  • Content is stored on local storage to persist on page reload
  • Added option to reset editor contents
  • Block-level errors are properly handled: any error at this level will be caught by an ErrorBoundary, reported at the block site, and reset at each editor content update (and if the content is still faulty, the block will simply throw right away again)
  • Global errors making the whole thing crash could in theory happen.
    • The only manner I managed to get this was when changing from no content to any content (or the opposite), because of a rules of hooks error. I've added a specific hack for this case (no empty string is allowed on the editor), there is a more elegant fix for sure, but this does the trick.
    • Any putative global error will lead to a fallback screens which offers to do a full page refresh with or without the currently saved content

@nerik nerik marked this pull request as ready for review June 21, 2023 11:29
Copy link
Collaborator

@hanbyul-here hanbyul-here left a comment

Choose a reason for hiding this comment

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

Such an exciting change 👯

We can consolidate the diverged approaches to achieve a similar goal inside the applications. ex. Analysis page and MDX editor use both local storage but in different ways. + I wonder if we can just use ErrorBlockBoundary component for block error handling.

But I think it is more important to test this idea fast. so if you want to consider the integration with the existing architecture later, I am down with it.

app/scripts/components/sandbox/mdxEditor/MDX.tsx Outdated Show resolved Hide resolved
app/scripts/components/sandbox/mdxEditor/MDX.tsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
app/scripts/components/sandbox/mdxEditor/index.tsx Outdated Show resolved Hide resolved
@nerik
Copy link
Contributor Author

nerik commented Jun 22, 2023

@hanbyul-here

We can consolidate the diverged approaches to achieve a similar goal inside the applications. ex. Analysis page and MDX editor use both local storage but in different ways.

Interesting, we might even be able to have a pseudo "user parameters" page where a user could see saved AoIs, analysis params, discovery draft, etc... With the obvious caveat that this is tied to the current browser, which must be clearky communicated.

But I think it is more important to test this idea fast. so if you want to consider the integration with the existing architecture later, I am down with it.

Cool! Let's also see what comes out of #561

@nerik nerik requested a review from hanbyul-here June 22, 2023 09:13
Copy link
Collaborator

@danielfdsilva danielfdsilva left a comment

Choose a reason for hiding this comment

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

nitpick: all files and folders on veda follow the kebab-case syntax. Would be good to maintain consistency

Copy link
Collaborator

@danielfdsilva danielfdsilva left a comment

Choose a reason for hiding this comment

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

The CRA overlay is still popping up. I'd suggest we change the selector to the following one so it is more generic. It is very unlikely that this would interfere with any other piece

body > iframe:last-of-type {

@nerik
Copy link
Contributor Author

nerik commented Jun 22, 2023

The CRA overlay is still popping up. I'd suggest we change the selector to the following one so it is more generic. It is very unlikely that this would interfere with any other piece

@danielfdsilva Fixed, although I was not able to replicate this.

Copy link
Collaborator

@hanbyul-here hanbyul-here left a comment

Choose a reason for hiding this comment

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

Not a blocker, just a note so we know the quirks.

  • the components that use the internal files (chart, image) don't work in the editor.
  • the editor gets 'scrolled away' with scrolly map component.

but an exciting change! I look forward to getting some feedbacks.

@nerik nerik requested a review from danielfdsilva June 22, 2023 15:59
@nerik nerik force-pushed the spike/runtime-mdx-renderin branch from bcd5977 to 7b0ef01 Compare June 25, 2023 12:05
@nerik nerik force-pushed the spike/runtime-mdx-renderin branch from 7b0ef01 to fc37360 Compare June 25, 2023 12:50
@nerik nerik merged commit 014b1aa into main Jul 11, 2023
8 checks passed
@nerik nerik deleted the spike/runtime-mdx-renderin branch July 11, 2023 13:33
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