From 624143d6b69fa2ca095f252d98942401b6b2f0a9 Mon Sep 17 00:00:00 2001 From: Ashley Baldry Date: Thu, 5 Feb 2026 11:47:03 +0000 Subject: [PATCH 1/2] Ignore argument names when extracting pre-requisites --- R/call_chunk_generic.R | 1 + shinyrepro.Rproj => shinyreprex.Rproj | 0 2 files changed, 1 insertion(+) rename shinyrepro.Rproj => shinyreprex.Rproj (100%) diff --git a/R/call_chunk_generic.R b/R/call_chunk_generic.R index d7d05a7..412ff69 100644 --- a/R/call_chunk_generic.R +++ b/R/call_chunk_generic.R @@ -51,6 +51,7 @@ S7::method(repro_call_chunk, S7::class_any) <- function(x, repro_code = Repro(), repro_code@prerequisites <- repro_args[!(reactive_calls | variable_calls)] |> purrr::map("prerequisites") |> purrr::discard(identical, list()) |> + unname() |> unlist(recursive = FALSE) if (rlang::is_call(x[[1]], "::")) pkg <- as.character(x[[1]][[2]]) else pkg <- NULL diff --git a/shinyrepro.Rproj b/shinyreprex.Rproj similarity index 100% rename from shinyrepro.Rproj rename to shinyreprex.Rproj From 4c97661f05f24bc3ccfcf5db6fb07af3640b593f Mon Sep 17 00:00:00 2001 From: Ashley Baldry Date: Thu, 5 Feb 2026 11:50:22 +0000 Subject: [PATCH 2/2] Add test checking for duplicate naming --- tests/testthat/test-reprex_reactive.R | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/testthat/test-reprex_reactive.R b/tests/testthat/test-reprex_reactive.R index db8a5c2..5586f15 100644 --- a/tests/testthat/test-reprex_reactive.R +++ b/tests/testthat/test-reprex_reactive.R @@ -318,3 +318,35 @@ test_that("When a reactive feeds is bound by an event, the reprex only updates w } ) }) + +test_that("Reproducible reactives aren't rendered twice when referenced twice in a reactive", { + reactiveTabServer <- function(id) { + moduleServer(id, function(input, output, session) { + iris_react <- reactive(iris[iris$Species == "versicolor", ]) + + table_code <- reactive({ + + sum( + iris_react()$Sepal.Width, + iris_react()$Sepal.Length, + na.rm = anyNA(iris_react()) + ) + + widths * lengths + }) + + table_reprex <- reactive(reprex_reactive(table_code)) + + output$code <- shiny::renderText(table_reprex()) + output$table <- shiny::renderTable(table_code()) + }) + } + + shiny::testServer( + reactiveTabServer, + expr = { + expect_match(table_reprex(), "iris_react <-") + expect_no_match(table_reprex(), "iris_react <-.*iris_react <-") + } + ) +})