Skip to content

feat: put runtime behind yjs #466

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

Merged
merged 1 commit into from
Aug 20, 2023
Merged

feat: put runtime behind yjs #466

merged 1 commit into from
Aug 20, 2023

Conversation

lihebi
Copy link
Collaborator

@lihebi lihebi commented Aug 20, 2023

Changes:

  1. results are now saved to yDoc .getMap("rootMap").get("resultMap"), so that they sync with peers and are persisted
  2. runtime status is now saved to yDoc .getMap("rootMap").get("runtimeMap"), so that peers share the exact runtime and share real-time status.
  3. the connection to the runtime kernel is moved behind Yjs.
    • Detail: the frontend no longer directly connects to the runtime websocket. Instead, the Yjs server connects to runtime WS, receives and sets results in "resultMap", and sets runtime status in "runtimeMap".
    • Effect: if you have some long-running code, you can now safely close the page. The runtime will continue to run, and results will continue to be populated (with a TODO caveat below). When you reopen the page, you can reload the exact results and runtime status again.
      • Caveats (TODO): Although the runtime TTL is 12 hours, there's a 30s timeout to keep a YDoc in memory when no one is connected. These two TTLs shall be unified in the future.
  4. Now, you can create multiple runtimes and activate either one, see below screenshot:
Screenshot 2023-08-20 at 10 13 53 AM

@lihebi
Copy link
Collaborator Author

lihebi commented Aug 20, 2023

Several TODOs:

  • add text/html output
  • run auto-layout after result changes
    - we had this, but I disabled it in this PR. Shall be added back properly and performantly.

@lihebi lihebi merged commit 1735295 into codepod-io:main Aug 20, 2023
@senwang86
Copy link
Collaborator

Awesome!

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.

2 participants