KittyCAD / modeling-app

The KittyCAD modeling app.
https://kittycad.io/modeling-app/download
MIT License
315 stars 24 forks source link

executor cache #458

Open jessfraz opened 10 months ago

jessfraz commented 10 months ago

so a few examples of how this should work:

moving lines

The user has the following code:

const myNumber = 20
const part001 = startSketchAt([0, -10])
  |> line([0, myNumber], %)
  |> line([myNumber, 0], %) 
  |> line([0, -30], %) 
  |> line([-30, 0], %)
  |> close(%)
  |> extrude(10, %)

show(part001)

They change the variable myNumber. Okay so in the ast I know myNumberis referenced by callexpression line([0, myNumber], %) that has segment id 23123123 and call expression line([myNumber, 0], %) that has segment id akjsdnaksdn. (Yes I know the ids are uuids just bear w me.)

So I know what they changed and I know those segments. So I would just move both those to the new values with a websocket call each to change them. Of course now that I say this I have no idea what cmd that would be. But I assume we have the functionality for this if we can move lines in the ui.

deleting lines

The user has the following code:

const myNumber = 20
const part001 = startSketchAt([0, -10])
  |> line([0, myNumber], %)
  |> line([myNumber, 0], %) 
  |> line([0, -30], %) 
  |> line([-30, 0], %)
  |> close(%)
  |> extrude(10, %)

show(part001)

they delete line #2 of the sketch |> line([0, myNumber], %) now this one is a bit tricky just because lines are relative, so I would call a websocket call to delete the extrudePath, a websocket call to delete the closePath, a websocket call to delete all the segments after #2 and then I'd start re-executing the path from there. Obviously in this scenario we could be smart about it and just fucking clobber the sketch and start over (to which I would say I also need the clobber bool exposed to me on the rust end in the command) since its less calls, but wanted to just show how I'm thinking of reversing these things when things happen.

jessfraz commented 10 months ago

this will be easier once https://github.com/KittyCAD/modeling-app/issues/163 is complete as well, and the rust side owns all the state