feat(tui): add /edit-last command to open last assistant message in external editor #8214

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

Originally created by @jung-ho-1231 on GitHub (Feb 1, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When LLM responses are long, it is helpful to open them in an external editor (vim/nvim/code) to read and understand better. Currently, users have to scroll through long responses in the terminal, which can be difficult to navigate.

Proposed Solution

Add a /edit-last slash command that:

  1. Opens the last assistant message in the external editor configured via VISUAL or EDITOR environment variable
  2. Allows users to edit the content if needed
  3. Loads the edited content back into the input prompt
  4. Users can then press Enter to send the edited message

Use Cases

  • Reading long code explanations or documentation generated by the AI
  • Editing or refining AI responses before sending follow-up questions
  • Better navigation of multi-page responses using familiar editor keybindings
  • Copying specific sections from the response more easily

Requirements

Users must have VISUAL or EDITOR environment variable set:

export EDITOR=vim    # or nvim, nano, code, etc.
export VISUAL=nvim   # takes precedence over EDITOR

Implementation Notes

  • Command should only be visible when editor is configured
  • Should handle edge cases (no assistant messages, no text content)
  • Should detect if changes were made (show "No changes made" if not)
  • Should detect empty content after editing

Alternatives Considered

  • Copy to clipboard and manually open editor (more steps)
  • Built-in pager (less familiar than user's preferred editor)
  • Export entire session (overkill for single message editing)
Originally created by @jung-ho-1231 on GitHub (Feb 1, 2026). Originally assigned to: @rekram1-node on GitHub. ## Description When LLM responses are long, it is helpful to open them in an external editor (vim/nvim/code) to read and understand better. Currently, users have to scroll through long responses in the terminal, which can be difficult to navigate. ## Proposed Solution Add a `/edit-last` slash command that: 1. Opens the last assistant message in the external editor configured via `VISUAL` or `EDITOR` environment variable 2. Allows users to edit the content if needed 3. Loads the edited content back into the input prompt 4. Users can then press Enter to send the edited message ## Use Cases - Reading long code explanations or documentation generated by the AI - Editing or refining AI responses before sending follow-up questions - Better navigation of multi-page responses using familiar editor keybindings - Copying specific sections from the response more easily ## Requirements Users must have `VISUAL` or `EDITOR` environment variable set: ```bash export EDITOR=vim # or nvim, nano, code, etc. export VISUAL=nvim # takes precedence over EDITOR ``` ## Implementation Notes - Command should only be visible when editor is configured - Should handle edge cases (no assistant messages, no text content) - Should detect if changes were made (show "No changes made" if not) - Should detect empty content after editing ## Alternatives Considered - Copy to clipboard and manually open editor (more steps) - Built-in pager (less familiar than user's preferred editor) - Export entire session (overkill for single message editing)
yindo added the opentui label 2026-02-16 18:09:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8214