Skip to content

feat: add /edit command to cli for on-demand prompt editing#8566

Merged
alexhancock merged 1 commit into
aaif-goose:mainfrom
maxamillion:optional_prompt_editor
Apr 16, 2026
Merged

feat: add /edit command to cli for on-demand prompt editing#8566
alexhancock merged 1 commit into
aaif-goose:mainfrom
maxamillion:optional_prompt_editor

Conversation

@maxamillion
Copy link
Copy Markdown
Contributor

Summary

Add a /edit slash command that opens a configured editor for composing prompts on demand, with optional prefill text support.

  • Add /edit [text] command to open editor with optional prefill
  • Add resolve_editor_command() with GOOSE_PROMPT_EDITOR, $VISUAL, $EDITOR fallback
  • Add goose_prompt_editor_always config (default false) for always-on mode
  • Always-on mode restricts to explicit goose_prompt_editor config only
  • Extract build_template() to deduplicate template construction
  • Save history before editor launch for crash safety
  • Use output::render_error() and CMD_* constants for consistency

Preserve backward compatibility: users with GOOSE_PROMPT_EDITOR configured expect the editor on every prompt. The new GOOSE_PROMPT_EDITOR_ALWAYS flag defaults to true when GOOSE_PROMPT_EDITOR is set, allowing users to opt-in to the new behavior.

Testing

I've tested locally with:

$  cargo build -p goose-cli
$ GOOSE_PROMPT_EDITOR="vim" ./target/debug/goose session
$ GOOSE_PROMPT_EDITOR_ALWAYS="false" GOOSE_PROMPT_EDITOR="vim" ./target/debug/goose session

Everything behaved as expected.

Also added new unit tests that cover the new feature / code changes.

Screenshots/Demos (for UX changes)

Asciinema demo recording: https://asciinema.org/a/MI64j2tqmkzUyvhJ

Add a /edit slash command that opens a configured editor for composing
prompts on demand, with optional prefill text support.

- Add /edit [text] command to open editor with optional prefill
- Add resolve_editor_command() with GOOSE_PROMPT_EDITOR, $VISUAL, $EDITOR fallback
- Add goose_prompt_editor_always config (default false) for always-on mode
- Always-on mode restricts to explicit goose_prompt_editor config only
- Extract build_template() to deduplicate template construction
- Save history before editor launch for crash safety
- Use output::render_error() and CMD_* constants for consistency

Preserve backward compatibility: users with GOOSE_PROMPT_EDITOR
configured expect the editor on every prompt. The new
GOOSE_PROMPT_EDITOR_ALWAYS flag defaults to true when
GOOSE_PROMPT_EDITOR is set, allowing users to opt-in to the new
behavior.

Signed-off-by: Adam Miller <admiller@redhat.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 341f9a151b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +114 to +116
if editor_always {
if let Ok(Some(editor_cmd)) = config.get_goose_prompt_editor() {
if !editor_cmd.is_empty() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor editor-always mode with env fallback

When goose_prompt_editor_always is true, this branch still requires get_goose_prompt_editor() to be set before opening an editor, so users who rely on $VISUAL/$EDITOR never enter editor mode and silently fall back to inline input. That makes the new always-on flag ineffective for env-only editor setups, even though /edit supports those fallbacks via resolve_editor_command().

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is intended as it preserves the existing behavior for backwards compatibility.

@alexhancock alexhancock self-requested a review April 16, 2026 18:51
@alexhancock alexhancock added this pull request to the merge queue Apr 16, 2026
Merged via the queue into aaif-goose:main with commit fdd8ada Apr 16, 2026
19 checks passed
michaelneale added a commit that referenced this pull request Apr 17, 2026
* main: (37 commits)
  polish: refine sidebar activity indicators, add placeholder token, and tidy search field (#8606)
  feat: add /edit command to cli for on-demand prompt editing (#8566)
  docs(mcp): add Rendex MCP Server extension tutorial (#8541)
  Lifei/delete tauri backend acp (#8582)
  chore: set goose binaries as executable in package.json (#8589)
  feat: add Novita AI as declarative provider (#8432)
  feat: add Kimi Code provider with OAuth device flow authentication (#8466)
  fix: chat loading-state model placeholder (#8431)
  fix: expand tool calls by default when Response Style is Detailed (#8478)
  fix: create logs dir before writing llm request log (#8522)
  fix: enable token usage tracking and configurable stream timeout for Ollama provider (#8493)
  fix tauri-plugin-dialog version constraint to match other plugins (#8542)
  call goose serve from tauri frontend via goose-acp client (#8549)
  failed the script when bundle:default fails and cleanup "alpha"  (#8580)
  pass globally unique conversation identifier as sessionId in databricks api call (#8576)
  fix: use sqlx chrono decode for thread timestamps instead of manual parsing (#8575)
  docs: remove stale gemini-acp references (#8572)
  show individual untracked files in git changes widget (#8574)
  fix: update publishing flow to include new sdk dir (#8573)
  fix: remove double border on content in chat (#8545)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants