livebook-dev / kino_vega_lite

Vega-Lite (graphics) integration for Livebook
Apache License 2.0
26 stars 8 forks source link

Initial render of smart chart cell source code is incorrect #18

Closed aedwardg closed 2 years ago

aedwardg commented 2 years ago

Bug

When creating a new smart chart cell, the initial render of source code is incorrect when clicking on the "Toggle source" button. Joining the Livebook session in a new tab or converting the cell to a code cell fixes the rendered source code.

Not sure if this is specific to smart chart cells or a broader problem, but these are the only smart cells I've tried the "Toggle source" button on.

Minimal data used for reproducing bug

goals_test = [
  %{goals: 4, year: 1930},
  %{goals: 1, year: 1930},
  %{goals: 2, year: 1950},
  %{goals: 4, year: 1950},
  %{goals: 3, year: 1962},
  %{goals: 4, year: 1962}
]

Steps to reproduce

  1. Save minimal data as a variable
  2. Create new kino_vega_lite smart chart cell and fill out UI fields
  3. Click "Toggle source"
  4. See incorrect source code
  5. Convert cell to a code cell or join Livebook in a new tab
  6. See correct source code

System specs

Elixir: 1.13.4 Livebook: 0.6.3 kino_vega_lite: 0.1.3 Browsers: Firefox, Chrome OS: WSL2 Ubuntu 20.04

Screenshots

UI fields:

image

"Toggle source" clicked:

image

Two tabs opened to the same session side by side:

image

josevalim commented 2 years ago

Thanks for the great report!

I believe this is an issue related to newlines on Windows vs Unix. Right @jonatanklosko?

jonatanklosko commented 2 years ago

@josevalim changes to the source are applied as diffs, and multiple manipulations are multiple diffs, so this definitely seems like the newlines issue.

@aedwardg can you please try to run livebook from the main branch and verify that it's no longer an issue? :)

aedwardg commented 2 years ago

@jonatanklosko I'll try to take a look after work.

This morning I tried downloading Livebook main branch using Escript, but I got an error in the console saying it required Elixir 1.14.0rc. I then noticed that rebar2 support was removed in 1.14.0rc0. Does this mean I won't be able to follow the Escript installation instructions to download Livebook main branch, or will those still work?

jonatanklosko commented 2 years ago

@aedwardg do you mean you're forced to use rebar2? Otherwise it should all work fine. Alternatively you can try in using the Docker image.

josevalim commented 2 years ago

@aedwardg it should all just work. Rebar2 is no longer supported but everything uses Rebar3 nowadays. :)

aedwardg commented 2 years ago

@josevalim @jonatanklosko, yes it seems to work fine with everything updated to the newest versions:

Thanks for the help and sorry for the confusion!