lightningrodlabs / rea-playspace

Holochain app to play with REA accounting
32 stars 7 forks source link

We need to allow people to select a plan or create a new one #172

Closed adaburrows closed 1 year ago

adaburrows commented 2 years ago

The Problem

Currently, when someone installs the playspace a 'bug' manifests itself. Here's the causal chain of events:

  1. The first person, Alice, installs the playspace.
  2. Alice's Holochain Launcher installs the rea-playspace hApp (the backend). It creates a cell on the Holochain Conductor running the DNA composed of the profile and project zomes. They become the first agent in existence in the network of cells that all share the same code.
  3. When Alice launches the UI (webhApp) and the UI makes a call to the project zome to retrieve the root object and see if there's a planID set. Since there is no data yet, the call returns no data since it hasn't been created yet.
  4. As Alice's UI sees there's no data, it creates a new Plan and a new root object with a planId set to the ID of the new Plan. It then makes a zome call to the project zome of Alice's cell to create those objects and the links between them.
  5. Alice uses the UI to continue adding data.
  6. The second person, Eve, installs the playspace.
  7. Eve's Holochain Launcher installs the rea-playspace hApp (the backend). It creates a cell on the Holochain Conductor running the DNA composed of the profile and project zomes. This is now the second cell on the network and this cell needs to synchronize on the DHT through the gossip protocol. Until it synchronizes, Eve's frontend will react as though it is the first cell in the network.
  8. Eve launches the UI and the UI makes a call to the project zome to retrieve the root object and see if there's a planID set. Since there is no data yet, the call returns no data since it hasn't synchronized.
  9. As Eve's UI sees there's no data (because too little time has elapsed fro synchronization to occur), it creates a new Plan and a new root object with a planId set to the ID of the new Plan. It then makes a zome call to the project zome of Eve's cell to create those objects and the links between them.
  10. Eve's cell gossips this new data to Alice's cell, which overwrites the Plan to which the root.planId is pointing.
  11. Both Alice and Eve see all the other data that was created by Alice, but the Plan canvas appears to be blank because they are both looking at a blank canvas of a new Plan, while their old plan is still sitting around.
  12. The old Plan is inaccessible because there is no way to surface it in the UI, even though it is present in the root.plan.* index.
  13. A person, X, installs the playspace; repeat steps 7-12 for each new person X.

The Solution

We should have the application show a list of Plans to select (for when plans have been synchronized between cells on the DHT). We should also allow creating a new Plan otherwise every UI will just sit there, waiting for something that will never happen.

This should happen after the Profiles dialog shows itself.

adaburrows commented 2 years ago

Additionally, the slow gossiping bug in Holochain core exacerbates this issue. It's possible that upgrading to holochain-v0.0.166 (we're at v0.0.162) could fix that part of the issue:

adaburrows commented 1 year ago

I've upgraded to Holochain v0.0.173. It should have most of the fixes in. It seems there's still on issue with large blob gossip, but that shouldn't impact us.