Answer#
The assistant never edits your files by itself. A reply is text; the buttons under each code block are the only way it reaches the editor.
What each button does#
- Copy puts the block's text on the clipboard.
- Apply appears on a block whose first line names a file, such as a block marked
file:src/main.rs. Ruststudio asks the assistant for whole files in this form. After you press Apply, a confirmation asks "Replace the contents of src/main.rs in the editor with the assistant's version?" and states that the file on disk changes only when you save and that Ctrl+Z undoes it. For a file that does not exist yet, the question is "Create ... with the assistant's code?" and the file is created when you save. - Insert appears on other blocks (an ordinary
rustsnippet). It puts the text at the cursor in the open file as a single undo step, and the tab shows as unsaved. If no file is open it tells you to open one.
Safety rules built into Apply#
- A path that points outside the project folder is refused with a message, and nothing is changed.
- Applying replaces the whole file text, so compare before you save: check the difference in Git before you commit, or press Ctrl+Z to go back.
How to do it#
- Ask for a change and read the reply.
- Press Apply or Insert on the block you want.
- Look at the result in the editor. Build with Run > Check (F7).
- Save with Ctrl+S when you are happy, or undo with Ctrl+Z when not.
Common mistakes#
- Applying a full-file block over a file with edits you have not saved. Save or commit first.
- Applying and building without reading. See the thread on reviewing AI-written code.