feat(ai): run suggested code before accepting (#5196) - #10458
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Allows previewing AI suggestion output while keeping the completion panel open; reject restores the session baseline. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Align with upstream reject behavior while still restoring the session baseline when a suggestion was preview-run. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep preview baseline restore and adopt main's reject-keeps-prompt-open behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
This PR adds a “preview run” path for AI completion suggestions in the editor: users can manually run the suggested code without accepting it, then either accept to keep it or reject/close to restore the pre-session baseline, keeping the AI panel/prompt available for iteration.
Changes:
- Adds baseline-capture/restore helpers to support running suggested code before acceptance, with restoration on reject/close/resubmit.
- Introduces a new Run button for AI completions and wires it into the completion banner and inline action row.
- Adds Vitest coverage for the new helpers and the Run button behavior.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/components/editor/ai/completion-preview.ts | Adds small helper functions to track baseline and decide when/how to restore or render merge “original” code after preview runs. |
| frontend/src/components/editor/ai/completion-handlers.tsx | Adds RunCompletionButton UI component used to preview-run suggestions. |
| frontend/src/components/editor/ai/ai-completion-editor.tsx | Implements preview-run flow (baseline capture, run, restore on reject/close, correct merge original after preview). |
| frontend/src/components/editor/ai/tests/completion-preview.test.ts | Tests baseline/restore/merge-original helper logic. |
| frontend/src/components/editor/ai/tests/completion-handlers.test.tsx | Tests RunCompletionButton click and disabled state. |
| .gitignore | Ignores local .worktrees/ directories. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ahnaf Labib <105464161+AhnfLabib@users.noreply.github.com>
for more information, see https://pre-commit.ci
|
could you share a video? @AhnfLabib |
marimo_ahnaf_demo.mov@Light2Dark Here's a demo of the manual Run-before-accept flow:
Happy to adjust based on feedback! |
This pull request was authored by a coding agent.
What does this PR do?
Adds a manual Run action on AI cell completions so users can execute the suggested code, see output, and then Accept or Reject while the AI panel stays open. Reject restores the pre-session cell baseline. Accept keeps the suggestion. Accept+▶ (accept-then-run) is unchanged. Suggestions are never auto-executed when they arrive.
Why was this PR needed?
Related to #5196 (continued from discussion #5037). Users often need cell output to judge AI suggestions; requiring Accept first breaks iteration and loses the prompt. Maintainers flagged auto-run as dangerous; this implements the safer manual run-before-accept path. Note: Accept-and-run already ships in
main; this PR addresses the remaining gap.What are the relevant issue numbers?
Related to #5196
(Issue is still labeled
needs discussion, so this is a draft for review rather thanCloses.)Screenshots / Recordings (if applicable)
Manual QA recommended: AI completion → Run → output appears with panel open → Reject restores / Accept keeps.
Does this PR meet the acceptance criteria?
📝 Summary (upstream template)
Related to #5196.
Adds manual preview-run for AI cell suggestions without accepting, with baseline restore on reject/close.
📋 Pre-Review Checklist
needs discussion— seeking maintainer guidance)✅ Merge Checklist
Safety
Manual Run only — never executes on completion stream finish.