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
sess integration lost when VS Code restores an R terminal #1799
After reopening VS Code with an R terminal still present, sess may fail to reconnect. View() and plots then open in native windows instead of VS Code. This reproduces on macOS as described below.
Open a directory in VS Code - be sure there are no active terminals.
Create an R terminal r.createRTerm. [sess] Connected to VS Code should be printed. View() and plot() should work as expected.
Quit VS Code without closing the active R terminal. Or swap to a different directory workbench.action.openRecent (ctrl + r) without closing the active R terminal.
Open VS Code again or ctrl + r back to the original directory, sess shows an IPC error.
Run the same commands as earlier. Now, XQuartz pops up instead.
As I mentioned earlier, I can fix it by killing the old terminal and then making a new R terminal. Oddly, I cannot reproduce this on Windows. The same error occurs using both arf (above) and the base R console.
How does you R process survive after closing VS Code?
Cannot speak for arf, but I don't think R's native console can survive from VS Code shutdown and reopen. The behaviour is expected because the sess connection is gone completely in this case.
At the moment, I think sess reconnection is only for VS Code reload, not VS Code completely restart.
You're right: R does not survive a full VS Code shutdown. VS Code restores the terminal, not the R process itself.
VS Code distinguishes process reconnection on window reload from process revive on application restart. With persistent terminal sessions enabled, revival relaunches the terminal process using its saved environment. In this case that starts a new R process, whose profile calls sess::connect() with the old SESS_DISCOVERY_FILE. The file may still name the previous extension host's IPC endpoint, or the new endpoint may not be listening yet. The one-shot startup connection fails, leaving View() and plots outside VS Code. So this is a startup/recovery problem as well as the existing live-process reconnection case.
#1805 / #1830 now provide persistent arf Interactive sessions that retain their R process and history across full VS Code exit/reopen. That is available for workflows needing process persistence.
The original terminal-revival problem here remains distinct: VS Code starts a new R process with saved environment/discovery metadata. In current sess::connect(), an initial socket connection failure still returns without starting the reconnect loop. The reconnect tests cover a previously connected process losing its endpoint; they do not establish recovery from this initial revival failure.
Keeping this open for automatic recovery of an ordinary restored R/arf terminal.
Activity
Fred-Wu commentedon Sep 29, 2026
How does you R process survive after closing VS Code?
Cannot speak for
arf, but I don't think R's native console can survive from VS Code shutdown and reopen. The behaviour is expected because thesessconnection is gone completely in this case.At the moment, I think
sessreconnection is only for VS Code reload, not VS Code completely restart.grcatlin commentedon Sep 29, 2026
You're right: R does not survive a full VS Code shutdown. VS Code restores the terminal, not the R process itself.
VS Code distinguishes process reconnection on window reload from process revive on application restart. With persistent terminal sessions enabled, revival relaunches the terminal process using its saved environment. In this case that starts a new R process, whose profile calls
sess::connect()with the oldSESS_DISCOVERY_FILE. The file may still name the previous extension host's IPC endpoint, or the new endpoint may not be listening yet. The one-shot startup connection fails, leavingView()and plots outside VS Code. So this is a startup/recovery problem as well as the existing live-process reconnection case.Fred-Wu commentedon Oct 3, 2026
So the fix is to connect to a new R session automatically without emitting the message.
renkun-ken commentedon Oct 4, 2026
#1805 implements a native vscode Interactive window for R that survives full vscode reload and restart.
renkun-ken commentedon Oct 6, 2026
#1805 / #1830 now provide persistent arf Interactive sessions that retain their R process and history across full VS Code exit/reopen. That is available for workflows needing process persistence.
The original terminal-revival problem here remains distinct: VS Code starts a new R process with saved environment/discovery metadata. In current sess::connect(), an initial socket connection failure still returns without starting the reconnect loop. The reconnect tests cover a previously connected process losing its endpoint; they do not establish recovery from this initial revival failure.
Keeping this open for automatic recovery of an ordinary restored R/arf terminal.