"Insert at Cursor" Behavior

Hi Posit team :heart:,

Thank you for including me in the Posit Assistant beta. I’ve been enjoying experimenting with it. I had a question about the intended behavior of “Insert at Cursor” when Assistant suggests code edits.

Currently, when suggesting changes, Assistant returns a unified diff-style block including diff hunk headers:


When “Insert at Cursor” is used, the entire block, including the diff hunk headers, is inserted into the script:

@@ -6,7 +6,7 @@
   y = rnorm(10)
 )

-ggplot(df_test_data_r) +
+ggplot(df_test_data_r, aes(x = x, y = y)) +
   geom_point(color = "red", fill = "purple", stroke = 2, shape = 21, size = 5) +
   geom_line(color = "black")

I was expecting behavior more similar to Positron, where the updated code replaces the existing code directly, e.g.:

ggplot(df_test_data_r, aes(x = x, y = y)) +
  geom_point(color = "red", fill = "purple", stroke = 2, shape = 21, size = 5) +
  geom_line(color = "black")

Is the current behavior intentional for this stage of the beta? Or is there a plan to support direct code replacement / integration similar to Positron’s Assistant workflow?

For reference:

System/Version Details

RStudio Edition: Desktop
RStudio Version: 2026.04.0-daily+279 (“Globemaster Allium”)
OS: Windows 11 (mingw32)
R: 4.5.2 (ucrt)
Assistant: 0.0.93

Thanks again. Super excited to see where this evolves!

Hi, thanks for participating in the Posit AI beta!

There were issues (bugs) with the “edit” tool (as shown in the screenshot).

"Edit" applies changes directly to the file, but a bug sometimes prevented those edits from appearing immediately in the editor (or at all) causing the two to get out of sync.

This has been fixed in the latest builds (you will need to update both RStudio and the Posit AI plugin). The tool now also supports undo, so you can press Ctrl/Cmd+Z to revert changes made by Posit AI.

Future updates will provide more control, such as the ability to accept or reject changes.

Hope this answers your question!

1 Like

Yes! Thank you so much for the response!