[PR #11595] feat(tui): add /edit-last command to open last assistant message in editor #13855

Open
opened 2026-02-16 18:18:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11595

State: open
Merged: No


Fixes #11598

Summary

Adds a new slash command "/edit-last" that opens the last assistant message in an external editor (vim/nvim/code etc.) for editing.

What does this PR do?

When users type "/edit-last" or select it from the command dialog, the last assistant message will be opened in the external editor configured via VISUAL or EDITOR environment variable.

Changes

  • Added new command "Open last assistant message in editor" in session/index.tsx
  • Command is only visible when VISUAL or EDITOR environment variable is set
  • After editing and saving (:wq in vim), the edited content is loaded into the prompt input
  • If no changes are made (:q!), the original message remains unchanged
  • Users must press Enter to send the edited message

How did you verify your code works?

  • Typechecked with bun run typecheck - all 12 packages passed
  • Manual testing scenarios:
    1. Without EDITOR set: command does not appear in command palette
    2. With EDITOR=vim: /edit-last opens vim with last assistant message
    3. After :wq in vim: edited content appears in input prompt
    4. After :q! in vim: "No changes made" toast shown, input unchanged

Requirements

Users need to set the EDITOR or VISUAL environment variable:

export EDITOR=vim    # or nvim, nano, code, etc.
export VISUAL=nvim   # takes precedence over EDITOR
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11595 **State:** open **Merged:** No --- Fixes #11598 ## Summary Adds a new slash command "/edit-last" that opens the last assistant message in an external editor (vim/nvim/code etc.) for editing. ## What does this PR do? When users type "/edit-last" or select it from the command dialog, the last assistant message will be opened in the external editor configured via VISUAL or EDITOR environment variable. ## Changes - Added new command "Open last assistant message in editor" in session/index.tsx - Command is only visible when VISUAL or EDITOR environment variable is set - After editing and saving (`:wq` in vim), the edited content is loaded into the prompt input - If no changes are made (`:q!`), the original message remains unchanged - Users must press Enter to send the edited message ## How did you verify your code works? - Typechecked with `bun run typecheck` - all 12 packages passed - Manual testing scenarios: 1. Without EDITOR set: command does not appear in command palette 2. With EDITOR=vim: `/edit-last` opens vim with last assistant message 3. After `:wq` in vim: edited content appears in input prompt 4. After `:q!` in vim: "No changes made" toast shown, input unchanged ## Requirements Users need to set the EDITOR or VISUAL environment variable: ```bash export EDITOR=vim # or nvim, nano, code, etc. export VISUAL=nvim # takes precedence over EDITOR ```
yindo added the pull-request label 2026-02-16 18:18:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13855