-
Notifications
You must be signed in to change notification settings - Fork 483
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
Marlowe Playground Frontend: Separate simulator from marlowe editor #2560
Conversation
for_ mCode \code -> do | ||
selectView MarloweEditor | ||
assign _workflow (Just Marlowe) | ||
toMarloweEditor $ MarloweEditor.handleAction settings $ ME.InitMarloweProject code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels like we should have a function for taking a HalogenM action that returns a Maybe and doing an action on the possible result
with (query _blocklySlot unit $ H.request Blockly.GetCode) \code -> do ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is best to do this in a separate commit. I created a comment referencing this
-- A user can start with a haskell/javascript example that eventually gets compiled into | ||
-- marlowe/blockly and runned in the simulator, or can create a marlowe/blockly contract directly, | ||
-- which can be used interchangeably. This is used all across the site to know what are the posible | ||
-- transitions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/runned/run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does Nothing
represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 - replaced
2 - flow not selected. For example if you just started or if you return to home (forgot to add the second one, just added it)
@@ -259,6 +290,9 @@ _hasUnsavedChanges' = prop (SProxy :: SProxy "hasUnsavedChanges") | |||
_hasUnsavedChanges :: Lens' State Boolean | |||
_hasUnsavedChanges = _Newtype <<< _hasUnsavedChanges' | |||
|
|||
_workflow :: Lens' State (Maybe Lang) | |||
_workflow = _Newtype <<< prop (SProxy :: SProxy "workflow") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactoring note (not for this PR). Do we still need to newtype the mainframe state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhmhmh, not sure why it was added in the first place 🧐.
Maybe we can revisit this when we change settings
to be a MonadAsk
let | ||
env = (emptyEnvironment unreachablePaths) | ||
in | ||
CMS.execState (lintContract env contract) mempty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth mentioning in the PR that we are removing Semantics.State
from the linting because we will now not lint a partially simulated contract. Especially for the attention of @palas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added
runAjax action = RemoteData.fromEither <$> runExceptT action | ||
|
||
editorResize :: forall state action msg m. HalogenM state action ChildSlots msg m Unit | ||
editorResize = void $ query _marloweEditorPageSlot unit (Monaco.Resize unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krisajenkins is there some query_
or something, I can't find it anywhere but it feels like it should exist (possibly with a better name since "query" suggests returning something)
editorSetMarkers :: forall m. MonadEffect m => Array IMarker -> HalogenM State Action ChildSlots Void m Unit | ||
editorSetMarkers markers = do | ||
let | ||
warnings = filter (\{ severity } -> isWarning severity) markers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe partition is better:
{ yes: warnings, no: errors } = partition (\{ severity } -> isWarning severity) markers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are four different severities possible: https://microsoft.github.io/monaco-editor/api/enums/monaco.markerseverity.html
let | ||
warnings = filter (\{ severity } -> isWarning severity) markers | ||
|
||
trimHoles = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we do this again? maybe need a comment since I have forgotten!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleAction settings StartSimulation = do | ||
maybeInitialSlot <- peruse (_currentMarloweState <<< _executionState <<< _SimulationNotStarted <<< _initialSlot) | ||
for_ maybeInitialSlot \initialSlot -> do | ||
-- FIXME: there is currently bug with the UNDO button on the first step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this an existing bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes and no 😅... It didn't manifest visually as it does now, so the user would not perceive it as a bug. Frankly, I'm not sure what change made this visible.
There were a couple of problems. The hasHistory
function inside the Simulator always returned true, that is why I changed from
hasHistory :: forall s. { marloweState :: NonEmptyList MarloweState | s } -> Boolean
hasHistory state = has (_marloweState <<< _Tail) state
to
hasHistory :: forall s. { marloweState :: NonEmptyList MarloweState | s } -> Boolean
hasHistory state = case state ^. (_marloweState <<< _Tail) of
Nil -> false
Cons _ _ -> true
That was not visible because there weren't any CSS indication of the button being disabled. Now the button is disabled when hasHistory
returns false instead of firing Nothing as an action
But the other problem that still persists, and it may make sense to fix in a different PR is that when you start the simulation you have two entries in the NonEmptyList. The first one is the one that causes "the visual bug" that is shown in the screenshot, and the second one is what I think should be the first step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I solved the problem in this commit but I think we should revisit the StartSimulation, ResetSimulation actions. cc @palas
* Add the notion of "input" to the subcomponents, similar to what Halogen components do | ||
* we can reduce functionality and just say "Edit source" | ||
We opted for the last one as it's the simplest and least conflicting. In January the frontend | ||
team should meet to discuss the alternatives. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krisajenkins @merivale please make a note of this
where | ||
title = | ||
if party == otherActionsParty then | ||
-- QUESTION: if we only have "move to slot", could we rename this to "Slot Actions"? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am neutral on this, so for me leave it as it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good so far, just a few ideas
61c0f3c
to
2775252
Compare
The bottom panel in the MarloweEditor is commented as it’s very tied to the simulation. It will be restored in a future commit of this refactor
7e73dcc
to
ab1b119
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Right contract -> do | ||
assign _errorMessage Nothing | ||
raise <<< CurrentCode <<< show <<< pretty $ contract | ||
pure $ Just next | ||
pure $ Just $ next $ show $ pretty $ contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last dollar sign is not necessary ( ͡° ͜ʖ ͡°)
…2560) * Created a new view for MarloweEditor * Fixed keybinding selector for marlowe editor * Moved linter, holes and initial marker logic from simulation to marlowe editor * Fix double provider information * Renamed Simulation modules * Separated simulation bottom panel and actions The bottom panel in the MarloweEditor is commented as it’s very tied to the simulation. It will be restored in a future commit of this refactor * Fix bottom panel in marlowe editor * Fix simulation language color * Make the simulation editor readonly * Renamed _marloweEditorSlot to _simulatorEditorSlot * Reimplement workflow buttons * Move select hole to MarloweEditor * Fix simulation state on refresh * Remove unused code from Marlowe editor bottom panel * redesign simulation right pane * Fix file actions not being shown in Marlowe editor * Remove isValidContract from the simulation as it should always be valid * Fix undo button problem * Improved how we show a slot range
* Moving around some CSS files. There are no actual changes here. Just file-tidying. * WIP: UI Redux. * Frontend: Enabling Vim mode will now show a statusline. * Adding some JSLine config lines to Marlowe. * Git-ignoring your local playground config files. * Fixing the gitignore rules for the frontend `generated` directories. We were git-ignoring `/generated/`. That works as expected when `generated` is a directory, but not when it’s a symlink to a directory. * Fixing some new SCSS variables that were missing from plutus-scb-client. * Refactoring View.purs, in preparation for moving things around and restyling. * Restyling header and footer, swapping PNG logo for SVG, and tidying CSS a bit. * Moving gist controls to the subheader, shifting editor preferences to the right, and adding a second compile button above the editor. * fixup! Frontend: Enabling Vim mode will now show a statusline. * Restyling the editor and tidying up some CSS. * Renaming simulation tab to 'simulations', and changing simulation selection buttons to tabs. * Splitting the common Gists module into types and views. * Separating Bootstrap imports out of . * Refactoring the chain.scss to abstract out the colour choices. * Fixing fontawesome times/close icon class (fontawesome 5 removed the 'close' alias). * Restyling the editor and simulator to (start to) match the new designs (and temporarily breaking the transactions view in the process). * Simplifying gistControls view. * Adding a missing full stop in a comment. * Modifying simulations view, and separating the actionsPane into its own module. * Getting the simulations view closer to the target. * Removing unnecessary action argument from editor buttons. * Tidying the transactions view and getting it closer to the new UX specification. * Tidying simulations and transactions headers, styling Gist error popup. * Making editor feedback pane minimisable. * Making demo files menu toggle open/closed (not styled yet). * FE: Triggering a re-layout whenever Monaco's keybindings change. ...as this can change parts of the display like the status line. * Removing some unused references. * Plutus Playground: Fixing keybinding tracking. The localstorage setting was updated correctly, but the in-memory flag was not. * FE: Disabling the minimap. * Moving the evaluation errors pane out of the main view and into the simulations view, and making it look a bit nicer. * Further modifying the Gist widget to bring it closer to the UX specification. * Removing '#'s from simulation/wallet/slot names. * Removing text from under evaluate/transactions buttons. * Improving compilation status bar look and behaviour. * Changed successful compilation message. * Restyled small screen demo files menu. * Disabling transaction button when simulation changes. * Finishing styling of simlation tabs. * Restyling all over to make sure everything matches the design exactly. * Improving simulations tabs, and fixing event propogation bug introduced by moving the close button inside the tab. * A couple of little modifications to the transactions view. * FE: Adding a utility to call JS's window.scrollIntoView. * Simplifying editorWrapper code. * Scrolling simulation errors and transactions into view on (un)successful evaluation. * Removing some unnecessary comments that helped me find my way around when I started. * Better fudging of the problem caused by only have one set of transactions in the model. * Making empty strings valid (because `Nothing` and `Just ""` are indistinguishable in the browser). * Improving action wallet validation. * Removing some unnecessary imports. * Disabling simulate button when code changes after successful compilation. * Adding another case to the editor feedback text. * fixup! Scrolling simulation errors and transactions into view on (un)successful evaluation. * Making Gist ajax error pane closeable. * Removing hashes and arrows from blockchain visualisation. * Making the blockchain visualisation a bit nicer to look at. * Highlighting current demo file. * Switching to editor view when Gist is loaded. * fixup! Making Gist ajax error pane closeable. * Improving temporary fudge to make simulations/transactions UX sensible, in advance of proper remodelling of the state. * fixup! Disabling simulate button when code changes after successful compilation. * Adding isValid function to Validation.purs. * Refactoring and improving action validation. * Tidying and rationalising view function arguments and type signatures. * Tidying actions view a bit. * Making it impossible to create more than 10 wallets in simulations. * Running fix-purty. * Making assorted improvements in response to review comments. * Running fix-purty and removing an unused function. * One fix, one tiny bit of tidying. * SCP-1541 Implement the redesign of "open project" dialog (#2551) * Marlowe playground FE: Implement redesign of open project * Marlowe playground FE: Make modal header sticky * Fix open project modal padding * Add global loading indicator * Fix error when you have gists but that are not playground gists * Make the open project dialog full width always * Global loading indicator should not appear in saving as modal * Make the open project modal always to occupy full width * Applied PR feedback * Applied PR feedback * niv pre-commit-hooks.nix: update d16e007e -> ac3a4ca0 ## Changelog for pre-commit-hooks.nix: Branch: master Commits: [cachix/git-hooks.nix@d16e007e...ac3a4ca0](cachix/git-hooks.nix@d16e007...ac3a4ca) * [`908bbd60`](cachix/git-hooks.nix@908bbd6) Add Fourmolu * [`5fa5c3a5`](cachix/git-hooks.nix@5fa5c3a) Add hunspell to check for spelling mistakes * Breaks compilation with haddock enabled. * niv-updater: also blacklist nixpkgs See comment in the workflow. It's basically always a mass-rebuild, and it doesn't gain us much. I considered just making the updater action run less frequently, but I don't think we even want to update it every month! * Analytics name fix (#2569) * Renaming handleActionWithAnalyticsTracking to withAnalytics. * Replacing some PP analytics functions with ones from web-common. * Renaming handleAction' to handler. * SCP-1517 unsaturated builtins for extrinsically typed syntax/semantics (#2556) * removing saturated builtins from Extrinsic syntax + ren/sub * some signature equipment * progress: term arg saturation step * progress: beta-builtin * progress: type applications * interleaved telescopes * progress: ival * progress * CK: computation case * CK * erasure + removing old builtins from typechecker * semantics of builtins * removing old builtin semantics * Renaming module Playground.Schema to Schema.View. (#2567) * niv easy-purescript-nix: update 860a95cb -> c8c32741 ## Changelog for easy-purescript-nix: Branch: master Commits: [justinwoo/easy-purescript-nix@860a95cb...c8c32741](justinwoo/easy-purescript-nix@860a95c...c8c3274) * [`c5d989d5`](justinwoo/easy-purescript-nix@c5d989d) Spago 0.18.1 * niv mvn2nix: update a4c9ec1c -> 9348fc40 ## Changelog for mvn2nix: Branch: master Commits: [fzakaria/mvn2nix@a4c9ec1c...9348fc40](fzakaria/mvn2nix@a4c9ec1...9348fc4) * [`9348fc40`](fzakaria/mvn2nix@9348fc4) Updated github actions ([fzakaria/mvn2nix#32](http://r.duckduckgo.com/l/?uddg=https://github.com/fzakaria/mvn2nix/issues/32)) * niv pre-commit-hooks.nix: update ac3a4ca0 -> c7e3896e ## Changelog for pre-commit-hooks.nix: Branch: master Commits: [cachix/git-hooks.nix@ac3a4ca0...c7e3896e](cachix/git-hooks.nix@ac3a4ca...c7e3896) * [`fcfb9450`](cachix/git-hooks.nix@fcfb945) Add html-tidy for HTML validation * [`f29bddb9`](cachix/git-hooks.nix@f29bddb) Add documentation for custom user defined hooks * Fix annoyance in output of serialised code in PLC command * webghc (and docker image) was broken (#2577) * Marlowe Playground Frontend: Separate simulator from marlowe editor (#2560) * Created a new view for MarloweEditor * Fixed keybinding selector for marlowe editor * Moved linter, holes and initial marker logic from simulation to marlowe editor * Fix double provider information * Renamed Simulation modules * Separated simulation bottom panel and actions The bottom panel in the MarloweEditor is commented as it’s very tied to the simulation. It will be restored in a future commit of this refactor * Fix bottom panel in marlowe editor * Fix simulation language color * Make the simulation editor readonly * Renamed _marloweEditorSlot to _simulatorEditorSlot * Reimplement workflow buttons * Move select hole to MarloweEditor * Fix simulation state on refresh * Remove unused code from Marlowe editor bottom panel * redesign simulation right pane * Fix file actions not being shown in Marlowe editor * Remove isValidContract from the simulation as it should always be valid * Fix undo button problem * Improved how we show a slot range * Add NFData instances for Tx and ChainState * Correcting an out-of-date reference in the PR template. * Adding a few lines to frontend .gitignore files. (#2559) * Adding a few lines to frontend .gitignore files. * Removing playground and web-common .gitignore files, and generalising root .gitignore file instead. * Removing redundant SCB client .gitignore file. * Putting back (regimented) frontend .gitignore files for now, to satisfy CI. * Fixing some problems caused by a bad merge resolution. * Fixing some problems with out UUID types being invalid. The UUID validation rules are not as simple as we first thought. * Correcting the JSON instances for Plutus.Trace.Tag. Co-authored-by: Kris Jenkins <kris.jenkins@tweag.io> Co-authored-by: Hernan Rajchert <hrajchert@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Radu Ometita <radu.ometita@gmail.com> Co-authored-by: Michael Peyton Jones <michael.peyton-jones@iohk.io> Co-authored-by: James Chapman <james.chapman@iohk.io> Co-authored-by: kwxm <kenneth.mackenzie@iohk.io> Co-authored-by: David Smith <shmish111+github@gmail.com>
This PR separates the simulator from the marlowe editor so we can later use the simulator with Blockly among other things.
This feature was done in pair programming sessions with @shmish111. We set the following roadmap that must be completed before we're able to merge:
Pre-submit checklist:
$(nix-build default.nix -A pkgsLocal.updateMaterialized)
to update the materialized Nix fileshie-*.yaml
files if needed$(nix-shell shell.nix --run fix-stylish-haskell)
to fix any formatting issues$(nix-shell shell.nix --run fix-purty)
to fix any formatting issuesPre-merge checklist: