You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code browser automatically opening when debugging R Shiny #12505
The code browser tab (it has two dots, see below for example) opens every time a line of code is run while debugging in R Shiny using browser() statements. This decreases the joy of debugging significantly due to having to constantly switch off the added tab and find where the debugging got to in the original tab for every code line being run.
Expected behaviour: During debugging, RStudio keeps focus where the user ran the code.
Current behaviour: Opens new tab and/or moves to another tab automatically each time a block of code is executed during debugging.
This issue has been raised here on 2020 and comments made suggested it had been already fixed #6740
@vfridkin Thank you for raising this! Rather than reopening one of the existing issues, lets use this issue. Did this behave as you'd like in any previous versions? There's some indication that the behavior changed in a previous release, but that's not consistent. I'm trying to determine if this is a regression or a continuing enhancement.
@ronblum Yes, this behaved as I (and my 100+ team 😄) liked in version 1.1.463. We moved our stuff to new servers and engineering updated our RStudio recently.
Please note, it seems that editing the code while debugging triggers the tabs opening - which is what I do 100% of the time when debugging.
My understanding is that during debugging, RStudio recognizes that the code being edited (edits) is different from the saved code (saved) and keeps opening or moving to the saved tab instead of staying in the edits tab.
@vfridkin Thanks! I tried to run the code in RStudio Desktop 1.1.463 with R 3.3.3. I'm not seeing the same behavior, but I might be following the same steps. However, I did notice that starting with version 1.4.1106, there's a bug in which the cursor loses focus—previously, it remained in the Console Pane.
@kevinushey What is the expected behavior? I might not be replicating the exact steps as @vfridkin which might explain the difference the @vfridkin and I are seeing even in 1.1.463.
FWIW, I used the following code, snatched from the previous issues:
a <- function() b()
b <- function() c()
c <- function() {
x <- 10
browser()
x
}
a()
myfun <- function(x) print(x)
debugonce(myfun)
myfun("test")
@ronblum I've used your example in both 2022.07.1 (new) and 1.1.463 (old). I was able to generate the issue in new and for the same test, it did not occur in old.
Here are the steps:
saved your code in a test.R file
with the code open, sourced the file
now in browse/debug mode, added a line after the browser() like this
execute the added line while still in browse mode
In new it opened a new tab to the original code without the added line.
In old it didn't open a new tab - this is the desired behaviour as it enables editing during debugging and seeing the effect of these edits with the variables defined in the debug state.
Maybe I'm misunderstanding, but it looks like this issue has been resolved in the latest daily builds? It's hard to be certain because we don't have a concrete reproducible example for Shiny in this issue. Here's the Shiny application I tried running:
library(shiny)
ui <- fluidPage(
titlePanel("Debugging with Shiny"),
textOutput("text")
)
server <- function(input, output) {
output$text <- renderText({
print(1 + 1)
browser()
print(2 + 2)
browser()
print(3 + 3)
"Hello, world!"
})
}
# Run the application
shinyApp(ui = ui, server = server)
When I start the Shiny application, the browser() breakpoint is hit. I can then switch to different editors, or run code in the console, and focus is never aggressively shifted back to the original source file. This is true even if I run the script by:
Highlighting the code and sending to console with Cmd + Enter (but we don't have srcrefs in this case),
Running the script via the Run App button,
Running the script with Cmd + Shift + S (to Source the script)
Is this an accurate description of the issue? If so, and if someone is still encountering this issue with the latest daily builds, could you please let us know? It could also help if you could share a screen cast of what behavior exactly you're seeing.
On MacOs: "2023.09.0-daily+410" and re: ticket #94715 - I think this is a separate issue more related to individual function debugging vs Shiny.
For #94715 - I am able to stay in the source file when editing that file, running code and assigning new variables, and the debug browser read only pane only opens up when I call a separate user-defined function.
It is still an issue with the version we are using:
RStudio 2023.06.1+524.pro1 "Mountain Hydrangea" Release (7025e95, 2023-07-06) for RHEL 8
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Please note, we are using Shiny modules throughout.
If it has been fixed in a subsequent version, please let me know.
@vfridkin We just released a new version of RStudio yesterday, version 2023.09.0+463. The problem should be (hopefully!) resolved in it. Can you try it out?
Activity
ronblum commentedon Dec 29, 2022
@vfridkin Thank you for raising this! Rather than reopening one of the existing issues, lets use this issue. Did this behave as you'd like in any previous versions? There's some indication that the behavior changed in a previous release, but that's not consistent. I'm trying to determine if this is a regression or a continuing enhancement.
Triage: Note earlier comments and upvotes.
vfridkin commentedon Dec 30, 2022
@ronblum Yes, this behaved as I (and my 100+ team 😄) liked in version 1.1.463. We moved our stuff to new servers and engineering updated our RStudio recently.

Please note, it seems that editing the code while debugging triggers the tabs opening - which is what I do 100% of the time when debugging.
My understanding is that during debugging, RStudio recognizes that the code being edited (edits) is different from the saved code (saved) and keeps opening or moving to the saved tab instead of staying in the edits tab.
ronblum commentedon Dec 30, 2022
@vfridkin Thanks! I tried to run the code in RStudio Desktop 1.1.463 with R 3.3.3. I'm not seeing the same behavior, but I might be following the same steps. However, I did notice that starting with version 1.4.1106, there's a bug in which the cursor loses focus—previously, it remained in the Console Pane.
@kevinushey What is the expected behavior? I might not be replicating the exact steps as @vfridkin which might explain the difference the @vfridkin and I are seeing even in 1.1.463.
FWIW, I used the following code, snatched from the previous issues:
vfridkin commentedon Jan 2, 2023
@ronblum I've used your example in both 2022.07.1 (new) and 1.1.463 (old). I was able to generate the issue in new and for the same test, it did not occur in old.
Here are the steps:
In new it opened a new tab to the original code without the added line.

In old it didn't open a new tab - this is the desired behaviour as it enables editing during debugging and seeing the effect of these edits with the variables defined in the debug state.

cm421 commentedon Jan 11, 2023
Linking customer ticket #84078 here because they seem to be experiencing a similar issue on Workbench 2022.07.1+554.pro3
kevinushey commentedon Jan 12, 2023
FWIW, I'm not able to reproduce in the latest RStudio release (2022.12.0).
mikebessuille commentedon Jan 17, 2023
@vfridkin can you please confirm if this problem exists in the latest release, 2022.12.0? We have been unable to reproduce this.
lachlansimpson commentedon Jan 18, 2023
Linking customer ticket #84410, I have asked for a reproduction in 2022.12.
itsshubhamsaxena commentedon Mar 21, 2023
Hi, I am also facing exactly same problem with 2022.12.0+353.pro20 Workbench (Elsbeth Geranium) for RHEL 8
rich-rstudio commentedon Mar 21, 2023
I was able to reproduce on RHEL 8 workbench 2023.03.1 Build 409.pro2 and 2022.12.1+366.pro6
lachlansimpson commentedon Apr 11, 2023
Ticket #88232 has this issue as well, this is a reproduction in 2022.12 from ticket #84078 mentioned in this comment above.
13 remaining items
lachlansimpson commentedon Sep 3, 2023
Ticket #94715 has asked about this issue.
kevinushey commentedon Sep 6, 2023
Maybe I'm misunderstanding, but it looks like this issue has been resolved in the latest daily builds? It's hard to be certain because we don't have a concrete reproducible example for Shiny in this issue. Here's the Shiny application I tried running:
When I start the Shiny application, the
browser()breakpoint is hit. I can then switch to different editors, or run code in the console, and focus is never aggressively shifted back to the original source file. This is true even if I run the script by:Is this an accurate description of the issue? If so, and if someone is still encountering this issue with the latest daily builds, could you please let us know? It could also help if you could share a screen cast of what behavior exactly you're seeing.
jthomasmock commentedon Sep 11, 2023
On MacOs: "2023.09.0-daily+410" and re: ticket
#94715- I think this is a separate issue more related to individual function debugging vs Shiny.For
#94715- I am able to stay in the source file when editing that file, running code and assigning new variables, and the debug browser read only pane only opens up when I call a separate user-defined function.vfridkin commentedon Sep 26, 2023
It is still an issue with the version we are using:
RStudio 2023.06.1+524.pro1 "Mountain Hydrangea" Release (7025e95, 2023-07-06) for RHEL 8
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Please note, we are using Shiny modules throughout.
If it has been fixed in a subsequent version, please let me know.
ronblum commentedon Sep 27, 2023
@vfridkin We just released a new version of RStudio yesterday, version 2023.09.0+463. The problem should be (hopefully!) resolved in it. Can you try it out?
jthomasmock commentedon Nov 9, 2023
Using Kevin's example and "Run App", I'm not able to reproduce the opening of a new View only browser view.
debug-shiny.mp4
kevinushey commentedon Nov 9, 2023
@vfridkin, the issue appears to be resolved on our end. If you can, please try testing one of the latest daily builds at https://dailies.rstudio.com. We're going to close this issue as resolved, but please feel free to re-open with more details if you're still having trouble.