mlverse / chattr

https://mlverse.github.io/chattr/
Other
193 stars 19 forks source link

a11y-light theme in RStudio returns wrong colors #43

Closed jthomasmock closed 1 year ago

jthomasmock commented 1 year ago

When using the a11y-light theme in RStudio, I think the inferred colors are inverted. Here's the theme info:

getThemeInfo()
$editor
[1] "a11y-light {rsthemes}"

$global
[1] "Modern"

$dark
[1] FALSE

$foreground
[1] "rgb(43, 43, 43)"

$background
[1] "rgb(254, 254, 254)"

image

And here's the raw output from the chattr:::app_theme_style() internal function.

In this case, I think that the submit button and the prompt text should actually be dark text.

chattr:::app_theme_style()
$color_bg
[1] "#FEFEFE"

$color_fg
[1] "#2B2B2B"

$color_top
[1] "#E1E2E5"

$color_user
[1] "#f1f6f8"

$ui_submit
[1] "font-size: 55%;padding-top: 3px;padding-bottom: 3px;padding-left: 5px;padding-right: 5px;color: #FEFEFE;background-color: #3E4A56;"

$ui_user
[1] "border-style: solid;border-width: 1px;margin-top: 10px;margin-bottom: 10px;margin-left: 50px;margin-right: 0px;padding-top: 5px;padding-bottom: 2px;padding-left: 0px;padding-right: 0px;font-size: 80%;color: #FEFEFE;background-color: #3E4A56;border-color: #E1E2E5;"

$ui_assistant
[1] "margin: 0px;padding: 0px;font-size: 80%;color: #2B2B2B;background-color: #f1f6f8;border-color: #FEFEFE;"

$ui_paste
[1] "padding-top: 4px;padding-bottom: 4px;padding-left: 10px;padding-right: 10px;font-size: 60%;color: #FEFEFE;background-color: #3E4A56;"

$ui_text
[1] "font-size: 80%;margin-left: 8px;padding: 5px;"

$ui_panel
[1] "z-index: 10;background-color: #E1E2E5;"

$ui_options
[1] "font-size: 90%;padding-top: 3px;padding-bottom: 3px;padding-left: 5px;padding-right: 5px;color: #FEFEFE;background-color: #3E4A56;"
edgararuiz commented 1 year ago

Finding and applying the theme was less self-explanatory than I thought 😅

Posting the steps needed to get the theme here:

remotes::install_github("gadenbuie/rsthemes")
install_rsthemes("light")
rstudioapi::applyTheme("a11y-light {rsthemes}")
edgararuiz commented 1 year ago

Hey, can you try again and let me know if you see the same issue? I am not seeing it

Screenshot 2023-09-05 at 3 34 23 PM

Also, can you confirm your version of RStudio? I'm on 2023.09.0 Build 349

jthomasmock commented 1 year ago

Ah sorry for the rabbithole Edgar, apologies for the lack of context. This is on:

packageVersion("chattr")
[1] '0.0.0.9005'

and RStudio desktop: "2023.09.0-daily+380"

jthomasmock commented 1 year ago

OK so the plot thickens, if I open the chat via the Add-in or via Console, it looks perfect!

image

It's only when you run it as a background job that it messes up the theme.

I believe that Background Jobs do not trigger chattr:::ide_is_rstudio() and you'll want to add a logic check at:

https://github.com/mlverse/chattr/blob/013131663a7a1d4d26aa0ad21ff5545937f81384/R/app_theme.R#L2

To also check if rstudioapi::isJob():

rstudioapi::isJob() |> print()
chattr:::ide_is_rstudio() |> print()

image