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

improvement: Realtime Markdown rendering #2138

Merged
merged 11 commits into from
Sep 3, 2024
Merged

improvement: Realtime Markdown rendering #2138

merged 11 commits into from
Sep 3, 2024

Conversation

wasimsandhu
Copy link
Collaborator

📝 Summary

Completes #2137.

🔍 Description of Changes

realtime markdown

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

📜 Reviewers

@akshayka OR @mscolnick

@wasimsandhu wasimsandhu self-assigned this Aug 28, 2024
Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2024 10:00pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2024 10:00pm

@wasimsandhu wasimsandhu requested a review from mscolnick August 28, 2024 03:01
@wasimsandhu wasimsandhu changed the title Improve/realtime markdown improvement: Realtime markdown rendering Aug 28, 2024
@wasimsandhu wasimsandhu changed the title improvement: Realtime markdown rendering improvement: Realtime Markdown rendering Aug 28, 2024
@@ -87,6 +88,8 @@ export const setupCodeMirror = (opts: CodeMirrorSetupOpts): Extension[] => {
// Cell editing
cellMovementBundle(cellId, cellMovementCallbacks, hotkeys),
cellCodeEditingBundle(cellId, cellCodeCallbacks, hotkeys),
// Markdown autorun
markdownAutoRunExtension(cellMovementCallbacks),
Copy link
Contributor

@mscolnick mscolnick Aug 28, 2024

Choose a reason for hiding this comment

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

Would this be better in the MarkdownLanguageAdapter class? Better separation of concerns and no need to do the if check

@dmadisetti
Copy link
Collaborator

Nice! Might be worth seeing how this interacts with the VSCode plugin which already does this

@mscolnick
Copy link
Contributor

@dmadisetti - its essentially the exact same logic, but they won't overlap or effect each other.

@akshayka
Copy link
Contributor

@wasimsandhu , this is awesome!!

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

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

I don't remember if we "debounce"/deduplicate run requests in the backend. I think we might not, in which case if the kernel were busy while you were typing in a markdown cell, it's possible that hundreds of run requests would get queued and then run serially.

Might be something to test -- do time.sleep(10) in one cell, then start typing a bunch of text in a markdown cell and see what happens. I can help improve the BE if this is indeed an issue.

@wasimsandhu
Copy link
Collaborator Author

wasimsandhu commented Aug 29, 2024

Ah that's a good point. Let me check it out and report back.

@akshayka update:

@mscolnick
Copy link
Contributor

@wasimsandhu - its ok if the markdown is queued and doesn't update. but the worry is if after the sleep is done, will it run 30 requests (one for each char) through the kernel or 1. ideally its 1, if that is not the case, I will dedupe RunRequests in another PR.

@wasimsandhu
Copy link
Collaborator Author

@mscolnick Ahhh gotcha. If it's alright, I'd love to take a stab at it

@mscolnick
Copy link
Contributor

Totally - go for it! Thanks

@wasimsandhu
Copy link
Collaborator Author

wasimsandhu commented Sep 2, 2024

Just finished implementing @akshayka's de-duplication logic only to realize run requests were not getting duplicated to begin with... the markdown cell is stale while other cells are running, and it does not autorun after the time.sleep cell finishes executing.

I guess I must have hallucinated it the first time I observed it? I was positive I saw tons of duplicated requests, but now I'm unable to reproduce it lol. Can someone test on their machine and confirm that requests are not being duplicated as the branch currently stands?

I have my deduplication logic stashed and ready to push in case I'm wrong.

@wasimsandhu
Copy link
Collaborator Author

wasimsandhu commented Sep 2, 2024

Looks like I misled myself. After trying some different things, I realized that:

  1. multiple run requests are NOT being sent to the server after blocking cell runs
  2. run requests WERE being sent to the server on every interaction with the cell (click, drag, etc.)

This is the reason I "hallucinated" duplicated requests when I was testing... just clicking a few times after the blocking cell run sent 10-15 requests all at once. Updated extensions.ts so that a run only occurs if the cell's code was changed 😅

@akshayka
Copy link
Contributor

akshayka commented Sep 2, 2024

Sounds good. I will review tomorrow

@mscolnick
Copy link
Contributor

/marimo create-test-release

Copy link

github-actions bot commented Sep 3, 2024

🚀 Starting test release process...

@mscolnick
Copy link
Contributor

@wasimsandhu i just tested it. you are correct, it works as expected and we aren't sending additional requests

Copy link
Contributor

@mscolnick mscolnick left a comment

Choose a reason for hiding this comment

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

amazing! such a nice change

@mscolnick mscolnick merged commit 49d0dd4 into marimo-team:main Sep 3, 2024
27 of 28 checks passed
Copy link

github-actions bot commented Sep 3, 2024

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.8.8-dev19

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