Skip to content

fix(work): make AI Work application undoable as a single editor edit #300

Closed

Description

@karaaslanz

Problem

The current single-document AI Work flow applies the returned modified_content through onDocumentChange(...). That updates application state, but it does not deliberately apply the AI result through Monaco's edit API or establish an undo boundary for the operation.

The merged AI Work Panel feasibility roadmap in #280 explicitly calls out preserving Monaco undo/redo history for AI Work and recommends applying full-document changes through editor.executeEdits(...) with stack boundaries.

The editor's per-tab Monaco model isolation was already addressed by #251, so this task is limited to how an AI Work result itself is applied.

Scope

  • Apply a successful, fresh AI Work result through the mounted Monaco editor when available.
  • Replace the current document as one deliberate editor operation (for example via editor.executeEdits("ai-work", ...)).
  • Use appropriate Monaco undo stack boundaries so one Undo restores the exact pre-Work document and Redo restores the AI-applied document.
  • Preserve the existing state/preview synchronization path through the editor change callback.
  • Keep a safe fallback for cases where the editor/model is unavailable.
  • Add focused regression coverage for the apply/undo grouping logic that can be exercised in the existing frontend test harness.

Acceptance criteria

  1. Applying an AI Work result to the unchanged active document remains functionally equivalent to today.
  2. A single Undo after the AI Work apply restores the exact pre-Work document content.
  3. Redo restores the AI-applied content.
  4. The change does not merge the AI Work replacement into the user's previous typing undo step.
  5. Existing per-tab model isolation remains intact.
  6. Focused regression coverage is added and frontend test/lint/build remain green.

Out of scope

Refs #274, #280, #251.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions