Features

Code Review

Review AI-generated changes with the diff view

Code Review

Every change AI suggests goes through a review process. You're always in control of what gets applied to your code.

The Diff View

When AI generates or modifies code, the changes appear in a diff view that shows:

  • Red lines - Code that will be removed
  • Green lines - Code that will be added
  • Gray lines - Unchanged context
FUNCTION_BLOCK FB_Motor
VAR_INPUT
    bStart : BOOL;
    bStop : BOOL;
+   bReset : BOOL;  // New input added by AI
END_VAR

VAR_OUTPUT
    bRunning : BOOL;
-   bError : BOOL;
+   bError : BOOL;
+   nErrorCode : INT;  // New output for error details
END_VAR

Review Workflow

Step 1: Review the Changes

Carefully examine each change:

  • Does the code do what you asked?
  • Are the variable names appropriate?
  • Is the logic correct?
  • Does it follow your coding standards?

Step 2: Make a Decision

You have three options for each change:

ActionDescription
AcceptApply the changes to your code
RejectDiscard the changes entirely
EditModify the changes before accepting

Step 3: Accept or Reject

  • Click Accept to apply all changes
  • Click Reject to discard all changes
  • Use the edit feature to make modifications first

Editing Before Accepting

Sometimes AI gets it mostly right, but you want to make small adjustments:

  1. Click Edit in the diff view
  2. Make your modifications in the editor
  3. Click Accept to apply your edited version

This is useful for:

  • Fixing variable names
  • Adjusting constants
  • Adding comments
  • Minor logic tweaks

Partial Acceptance

For larger changes, you may want to accept some parts and reject others:

  1. Review the complete diff
  2. Use the section controls to accept/reject individual hunks
  3. Each hunk can be handled independently

Review Best Practices

Take Your Time

Don't rush through reviews. AI can generate plausible-looking code that has subtle bugs.

Check Logic Flow

Verify that:

  • Conditions are correct (AND vs OR, > vs >=)
  • Edge cases are handled
  • State transitions make sense

Verify Data Types

Ensure:

  • Variable types match their usage
  • No implicit conversions that could cause issues
  • Array bounds are appropriate

Look for Common Issues

Watch out for:

  • Infinite loops
  • Missing initialization
  • Unhandled error conditions
  • Off-by-one errors

History

PLC Studio AI keeps a history of all changes:

  1. Go to History in the sidebar
  2. See all accepted and rejected changes
  3. Revert changes if needed

Reverted changes will need to be re-applied in CODESYS to take effect.

Keyboard Shortcuts

ShortcutAction
EnterAccept changes
EscapeReject changes
EEdit changes
NNext change
PPrevious change

See the keyboard shortcuts reference for more.

Next Steps

On this page