Diff-Apply Workflow
The diff-apply workflow allows you to review AI-suggested changes before they're applied to your codebase, giving you full control over what gets modified.
How It Works
When the AI suggests code changes, Roflow presents them as a unified diff that you can:
- Review - See exactly what will change
- Accept - Apply the changes to your code
- Reject - Discard the changes
- Modify - Edit the suggestions before applying
All AI-suggested changes require your explicit approval. Nothing is automatically applied to your codebase without your review.
Viewing Diffs
In Chat Panel
When the AI suggests code changes in the chat:
- Changes appear as a diff block with syntax highlighting
- Green lines (starting with
+) show additions - Red lines (starting with
-) show deletions - White lines show unchanged context
Split View
Click "View Diff" to open a side-by-side comparison:
- Left: Your current code
- Right: Proposed changes
- Highlighted: Lines that will change
Applying Changes
Apply Entire Diff
Click the "Apply" button to accept all changes:
✓ Applied changes to src/services/PlayerService.lua
The AI will:
- Update the specified file(s)
- Preserve your formatting and indentation
- Create an undo point
Apply Partial Changes
To apply only some changes:
- Click "Select Changes"
- Check the boxes next to changes you want
- Click "Apply Selected"
You can accept some suggestions and reject others. The AI will remember what you accepted for context in future suggestions.
Rejecting Changes
Reject Entire Diff
Click "Reject" or press Esc to discard all suggestions.
Why Reject?
Common reasons to reject:
- The changes don't match your requirements
- You want to try a different approach
- The AI misunderstood the context
- You need to provide more information first
After rejecting, you can:
- Provide more context in the chat
- Ask the AI to try a different approach
- Manually implement the changes yourself
Multi-File Changes
When changes span multiple files:
Changes to apply:
src/services/PlayerService.lua +12 -4
src/controllers/GameController.lua +8 -2
src/types/Player.lua +5 -0
You can:
- Apply All: Accept all file changes
- Review Each: Go through files one by one
- Select Files: Choose which files to update
Conflict Resolution
When Conflicts Occur
If you've edited a file since the AI's suggestion:
The file has changed since this suggestion was made. Review carefully before applying.
Options:
- Review Diff - Check if changes still make sense
- Regenerate - Ask AI for updated suggestions
- Apply Anyway - Proceed with original suggestion
- Reject - Keep your current code
Manual Resolution
If the diff can't be applied automatically:
- AI will show you the conflicting sections
- You can manually copy and integrate the changes
- Or ask the AI to regenerate considering your edits
Undo Changes
Immediate Undo
After applying changes, use:
- Keyboard:
Cmd+Z/Ctrl+Z - Menu:
Edit > Undo - Command: "Undo AI Changes"
This reverts to before the diff was applied.
History
View all AI-applied changes:
- Open Command Palette (
Cmd+Shift+P/Ctrl+Shift+P) - Type "AI Change History"
- Select changes to review or revert
Best Practices
Before Applying
✓ Do:
- Read through all changes carefully
- Ensure you understand what will change
- Check that it matches your requirements
- Test after applying (if possible)
✗ Don't:
- Blindly accept without reviewing
- Apply changes you don't understand
- Skip testing after major changes
Working with Large Diffs
For changes affecting many lines:
- Use Split View - Easier to review side-by-side
- Apply Incrementally - Accept file by file
- Test Between Applications - Catch issues early
- Use Version Control - Commit before applying large changes
Iterative Refinement
The diff-apply workflow supports iteration:
- Apply initial changes
- Test/review the results
- Ask AI to refine
- Review new diff
- Apply refinements
Diff Viewer Features
Syntax Highlighting
Diffs maintain syntax highlighting for easier reading:
- local player = game.Players.LocalPlayer
+ local Players = game:GetService("Players")
+ local player = Players.LocalPlayer
Context Lines
By default, shows 3 lines of context above and below changes. Adjust in settings:
{
"roflow.diff.contextLines": 5
}
Inline vs. Side-by-Side
Switch between views:
- Inline: Changes shown in one panel
- Side-by-Side: Split view with before/after
Press Cmd+Shift+D / Ctrl+Shift+D to toggle.
Keyboard Shortcuts
Quick actions while reviewing diffs:
| Action | macOS | Windows/Linux |
|--------|-------|---------------|
| Apply All | Cmd+Enter | Ctrl+Enter |
| Reject | Esc | Esc |
| Next Change | F7 | F7 |
| Previous Change | Shift+F7 | Shift+F7 |
| Toggle View | Cmd+Shift+D | Ctrl+Shift+D |
Common Scenarios
Scenario 1: Accepting a Bug Fix
AI: I've identified and fixed the issue:
function calculateDamage(power, defense)
- return power - defense
+ return math.max(0, power - defense)
end
Action: Review → Apply ✓
Scenario 2: Rejecting Overengineering
AI: I've refactored this into a more modular structure:
[Shows 200+ line diff with new abstractions]
Action: Reject → Ask for simpler approach
Scenario 3: Partial Application
AI: I've added type annotations and fixed the bug:
Action:
- Accept the bug fix
- Reject some type annotations (prefer manual addition)
Integration with Git
Pre-Commit Review
Before committing AI changes:
- Use
git diffto review all modifications - Stage changes selectively with
git add -p - Commit with descriptive message mentioning AI assistance
Revert if Needed
If issues arise after deploying:
# Revert specific commit
git revert <commit-hash>
# Reset to before AI changes
git reset --hard HEAD~1
Always use version control when working with AI suggestions. It provides an additional safety net for reverting changes.
Troubleshooting
Diff Won't Apply
Symptoms: "Unable to apply diff" error
Solutions:
- File was modified after suggestion
- Ask AI to regenerate with current file
- File encoding issue
- Check file uses UTF-8 encoding
- Line ending mismatch
- Configure consistent line endings (LF or CRLF)
Changes Look Wrong
If applied changes don't look right:
- Undo immediately (
Cmd+Z/Ctrl+Z) - Check if file was saved properly
- Ask AI to explain what changed
- Regenerate suggestions with more context
Lost Suggestions
Can't find the diff you wanted to apply?
- Scroll up in chat history
- Use Command Palette: "Show AI Suggestions"
- Check "AI Change History" for recent suggestions
Next Steps
- Chat Panel - Learn to chat with the AI
- Tool Use - Understand AI agent actions
- Prompt Guide - Write better requests