codepod-io / codepod

Codepod IDE: Scalable Interactive Coding
https://codepod.io
MIT License
75 stars 15 forks source link

feat: put runtime behind yjs #466

Closed lihebi closed 1 year ago

lihebi commented 1 year ago

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 commented 1 year ago

Several TODOs:

senwang86 commented 1 year ago

Awesome!