CoopAI

Edit mode

Generate search-replace patches from chat — slash commands, apply, undo, and selection context.

Last updated: 2026-07-10

Edit mode — highlight code, send /edit in chat, review the diff, then Apply patch or Reject

CoopAI edit mode turns natural-language instructions into search-replace patches you review and apply in VS Code. Use it when you want in-file changes without an autonomous agent rewriting your tree.

Edit mode ships in production. It uses the same chat composer as quick actions — no separate panel.

When to use edit mode

Use edit modeUse plain chat instead
Refactor a highlighted blockArchitecture or ownership questions
Fix a bug in the open fileCross-tool context (Slack, Jira)
Apply a localized change with reviewExploratory "what if" analysis

Edit mode routes to the code_edit use case and expects patch blocks in the model response — not prose-only answers.

Model: Coop assigns OpenAI GPT-5.1 for /edit, /patch, and /fix in production (balanced mutation model). See Model assignments.

Slash commands

Type / in the composer to see edit commands:

SlashAliasesWhat it does
/edit/patch, /fixGenerate search-replace patches for your instruction

Examples:

/edit add null check before dereferencing user
/patch rename handleError to onRequestError in this function
/fix off-by-one in the loop bounds

All three resolve to the same edit composer mode. Text after the command is your instruction.

Selection and file context

Coop attaches editor context automatically:

ContextSettingDefault
Selected linescoopAI.includeSelectiontrue
Active file pathcoopAI.includeActiveFiletrue

Best practice: highlight the code you want changed, then run /edit <instruction>. Selection focuses the model; edit mode still attaches the full active file (up to the local-file byte limit) so multi-hunk refactors can wire call sites. With no selection, Coop uses the active file and your instruction.

Workspace owner / repo / branch (Settings → Workspace) help resolve indexed-repo context when the repo is Deep-Indexed.

How it works

flowchart LR
  A["/edit instruction"] --> B[Chat streams patch]
  B --> C[Parse SEARCH/REPLACE blocks]
  C --> D["Notification: Apply"]
  D --> E[Apply to workspace]
  E --> F{User action}
  F -->|Undo| G[Restore prior content]
  1. Request — You send /edit … in chat. Coop emits edit.requested telemetry and streams a response using the code_edit system prompt.
  2. Parse — When the response completes, the extension parses File: headers and <<<<<<< SEARCH / >>>>>>> REPLACE hunks.
  3. Review — A VS Code notification shows Patch ready — N file(s) (M edits) with Apply and Reject. Dismissing the notification (X) keeps the patch pending — run CoopAI: Apply Patch later.
  4. Apply — Click Apply or run CoopAI: Apply Patch (coopAI.applyPatch). Changed files are written in the workspace. SEARCH blocks tolerate minor whitespace drift (indent/trim) when an exact match is not found.
  5. Undo — After apply, the success notification includes Undo, or run CoopAI: Undo Last Patch (coopAI.undoLastPatch).
  6. Retry — If apply fails, click Retry on the error notification or run CoopAI: Retry Last Patch (coopAI.retryLastPatch). Coop re-opens the pending patch or sends a follow-up /edit turn asking the model to fix SEARCH blocks.

If parsing fails, no patch is staged — check the chat response for valid patch formatting.

Patch format

The model returns one or more files with search-replace hunks:

File: src/auth/login.ts

<<<<<<< SEARCH
if (!user) {
  return null;
}
=======
if (!user) {
  throw new Error("User required");
}
>>>>>>> REPLACE
  • File: — Repository-relative path (backticks optional).
  • <<<<<<< SEARCH — Exact text to find (must match the file, including indentation).
  • ======= — Separator between search and replace.
  • >>>>>>> REPLACE — Replacement text.

Multi-file edits include multiple File: sections. Each file can have multiple hunks.

Apply and undo

Apply

MethodSurface
Apply buttonVS Code notification after patch is parsed
CoopAI: Apply PatchCommand Palette (coopAI.applyPatch)
Reject buttonNotification — clears pending patch
CoopAI: Reject PatchCommand Palette (coopAI.rejectPatch)
CoopAI: Retry Last PatchCommand Palette (coopAI.retryLastPatch) — re-show pending patch or regenerate after apply failure

Success: Notification shows Applied patch to N file(s). with an Undo action.

Undo

MethodSurface
Undo buttonOn the apply-success notification
CoopAI: Undo Last PatchCommand Palette (coopAI.undoLastPatch)

Undo restores file contents from before the last successful apply. Only the most recent apply is undoable.

Settings

SettingDefaultDescription
coopAI.includeSelectiontrueInclude the current editor selection in chat context
coopAI.includeActiveFiletrueInclude the active file path in chat context

See Extension settings for Workspace and Preferences.

Telemetry

EventWhen
edit.requested/edit, /patch, or /fix sent
edit.patch_parsedValid patch blocks parsed
edit.patch_appliedApply succeeded
edit.patch_undoneUndo succeeded
edit.patch_failedParse, apply, or undo error
edit.patch_rejectedUser explicitly rejected the patch (Reject or CoopAI: Reject Patch)

Org admins see edit metrics in the admin portal. Members see personal usage on My Usage.

Troubleshooting

ProblemFix
No Apply notificationModel response may lack valid File: + SEARCH/REPLACE blocks — rephrase or narrow the selection
Apply failed — search text not foundSEARCH block must match the file exactly; regenerate with the selection highlighted
No patch pendingRun /edit first; only one pending patch is held at a time
Nothing to undoUndo only covers the last successful apply
Wrong file editedConfirm selection and active file; check Workspace repo/branch

More fixes: Troubleshooting.

Next steps