# What do Apply, Insert and Copy do with code from the AI assistant in Ruststudio?
Source: https://ruststudio.org/community/t/157/what-do-apply-insert-and-copy-do-with-code-from-the-ai-assistant-in-ruststudio
Author: Ruststudio Team (staff) | Published: 2026-12-05 | Updated: 2026-12-05 | Checked with: Ruststudio source code (core/rs-ui/src/ai_ui.rs and core/rs-core/src/ai.rs); no Rust code was run for this thread
Category: Help and questions | Kind: FAQ | Tags: ai, editor, assistant | Views: 0

## Short answer
Code blocks in a reply have Copy and either Apply or Insert. Apply is shown when the block names a file in the project, and replaces that file's text in the editor after you confirm. Insert puts a plain snippet at the cursor. Nothing is written to disk until you save, and Ctrl+Z undoes it.

## Answer
## 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 `rust` snippet). 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
1. Ask for a change and read the reply.
2. Press **Apply** or **Insert** on the block you want.
3. Look at the result in the editor. Build with **Run > Check** (F7).
4. 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.
