Skip to content

Commit

Permalink
Merge pull request #45 from mlverse/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
edgararuiz authored Sep 7, 2023
2 parents 0131316 + 4f21426 commit 210cfb2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
13 changes: 12 additions & 1 deletion R/app_theme.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app_theme_style <- function(x = NULL) {
if (ide_is_rstudio() && !ch_debug_get()) {
if ((ide_is_rstudio() && !ch_debug_get()) | running_as_job()) {
ti <- getThemeInfo()
color_bg <- app_theme_rgb_to_hex(ti$background)
color_fg <- app_theme_rgb_to_hex(ti$foreground)
Expand Down Expand Up @@ -118,3 +118,14 @@ app_theme_rgb_to_hex <- function(x) {
x2 <- unlist(strsplit(x1, ","))
rgb(x2[1], x2[2], x2[3], maxColorValue = 255)
}

running_as_job <- function(x = NULL) {
if(!is.null(x)) {
ch_env$as_job <- x
} else {
if(is.null(ch_env$as_job)) {
ch_env$as_job <-FALSE
}
}
ch_env$as_job
}
3 changes: 2 additions & 1 deletion R/chattr-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' is set to TRUE.
#' @export
chattr_app <- function(viewer = c("viewer", "dialog"),
as_job = FALSE,
as_job = getOption("chattr.as_job", FALSE),
as_job_port = getOption("shiny.port", 7788),
as_job_host = getOption("shiny.host", "127.0.0.1")) {
td <- chattr_defaults(type = "chat")
Expand Down Expand Up @@ -51,6 +51,7 @@ chattr_app <- function(viewer = c("viewer", "dialog"),
}

app_interactive <- function(as_job = FALSE) {
running_as_job(as_job)
list(ui = app_ui(), server = app_server)
}

Expand Down
5 changes: 4 additions & 1 deletion R/ide.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ ide_is_rstudio <- function() {
if (ch_debug_get()) {
return(TRUE)
}
ide_current() == "rstudio"
check_rstudio <- try(RStudio.Version(), silent = TRUE)
!inherits(check_rstudio, "try-error")
}

globalVariables("RStudio.Version")

# -------------------------- UI Identification ---------------------------------

ui_current <- function() {
Expand Down
2 changes: 1 addition & 1 deletion man/chattr_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/_snaps/app_ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[6] " <div class=\"col-sm-11\" style=\"width: 85%;\">"
[7] " <div class=\"form-group shiny-input-container\" style=\"width: 100%;\">"
[8] " <label class=\"control-label shiny-label-null\" for=\"prompt\" id=\"prompt-label\"></label>"
[9] " <textarea id=\"prompt\" class=\"form-control\" style=\"width:width: 100%;;resize:none;\"></textarea>"
[9] " <textarea id=\"prompt\" class=\"shiny-input-textarea form-control\" style=\"width:100%;resize:none;\"></textarea>"
[10] " </div>"
[11] " </div>"
[12] " <div class=\"col-sm-1\" style=\"width: 15%;\">"
Expand Down Expand Up @@ -52,7 +52,7 @@
[6] " <hr/>"
[7] " <div class=\"form-group shiny-input-container\">"
[8] " <label class=\"control-label\" id=\"prompt2-label\" for=\"prompt2\">Prompt</label>"
[9] " <textarea id=\"prompt2\" class=\"form-control\">Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as main reference"
[9] " <textarea id=\"prompt2\" class=\"shiny-input-textarea form-control\">Use the 'Tidy Modeling with R' (https://www.tmwr.org/) book as main reference"
[10] "Use the 'R for Data Science' (https://r4ds.had.co.nz/) book as main reference"
[11] "Use tidyverse packages: readr, ggplot2, dplyr, tidyr"
[12] "For models, use tidymodels packages: recipes, parsnip, yardstick, workflows, broom"
Expand All @@ -63,16 +63,16 @@
[17] " <br/>"
[18] " <div class=\"form-group shiny-input-container\">"
[19] " <label class=\"control-label\" id=\"i_data-label\" for=\"i_data\">Max Data Frames</label>"
[20] " <input id=\"i_data\" type=\"text\" class=\"form-control\" value=\"0\"/>"
[20] " <input id=\"i_data\" type=\"text\" class=\"shiny-input-text form-control\" value=\"0\"/>"
[21] " </div>"
[22] " <div class=\"form-group shiny-input-container\">"
[23] " <label class=\"control-label\" id=\"i_files-label\" for=\"i_files\">Max Data Files</label>"
[24] " <input id=\"i_files\" type=\"text\" class=\"form-control\" value=\"0\"/>"
[24] " <input id=\"i_files\" type=\"text\" class=\"shiny-input-text form-control\" value=\"0\"/>"
[25] " </div>"
[26] " <div class=\"form-group shiny-input-container\">"
[27] " <div class=\"checkbox\">"
[28] " <label>"
[29] " <input id=\"i_history\" type=\"checkbox\" checked=\"checked\"/>"
[29] " <input id=\"i_history\" type=\"checkbox\" class=\"shiny-input-checkbox\" checked=\"checked\"/>"
[30] " <span>Include Chat History</span>"
[31] " </label>"
[32] " </div>"
Expand Down

0 comments on commit 210cfb2

Please sign in to comment.