Skip to content

feat(composer): Ctrl+X opens $EDITOR with the current input#661

Merged
esengine merged 1 commit into
mainfrom
feature/issue-647-external-editor
May 11, 2026
Merged

feat(composer): Ctrl+X opens $EDITOR with the current input#661
esengine merged 1 commit into
mainfrom
feature/issue-647-external-editor

Conversation

@esengine

Copy link
Copy Markdown
Owner

Composes a long prompt in the user's preferred editor instead of typing it inside the TUI. Matches opencode <C-x>e and codex <C-g> — issue #647.

Changes

  • New src/cli/edit/external-editor.ts — resolves the editor via GIT_EDITOR → VISUAL → EDITOR (Unix precedence), writes the current buffer to a temp file, spawns the editor inheriting the TTY, reads back on exit, strips one trailing newline.
  • multiline-keys.ts — new pure action flag openExternalEditor: true on Ctrl+X, so the reducer stays testable.
  • PromptInput.tsx — new onOpenExternalEditor callback prop.
  • App.tsx — wires the callback: flips raw-mode off around the spawn so the editor owns cooked line-buffered input, restores raw-mode on exit, and replaces the composer value with the result. Missing-editor and non-zero-exit cases surface as a warning card in the chat log.
  • Spawn uses shell: true so EDITOR="nvim --noplugin" and EDITOR="code --wait" split correctly cross-platform (same shape as the existing commit.ts invocation).

Refs #647 — the picker-keymap half of that issue (Ctrl+N/P navigating the slash picker) is a separate change, coming next.

Test plan

  • npm run verify — 2609 passed (added 8), 2 skipped
  • tests/external-editor.test.ts covers env-var precedence + trim + empty-string handling
  • tests/multiline-keys.test.ts covers Ctrl+X → action flag, plain x still inserts
  • Manual: export EDITOR=nano, hit Ctrl+X in the composer, type, save+exit, verify input replaced

Composes a long prompt in the user's preferred editor instead of
typing it inside the TUI. Match for opencode's `<C-x>e` and codex's
`<C-g>` (issue #647).

Editor resolution follows the standard Unix precedence: $GIT_EDITOR →
$VISUAL → $EDITOR. Picked an explicit GIT_EDITOR-style fallback over
hardcoding nano/notepad so the user's existing shell config carries
through. Missing-editor and non-zero-exit cases surface as a warning
card in the chat log; on success the buffer is replaced with whatever
the user saved (one trailing newline stripped, since most editors
auto-append one).

Implementation notes:
- New action flag in multiline-keys (`openExternalEditor: true`) so the
  pure reducer stays testable and PromptInput just signals up.
- App.tsx flips raw-mode off around the spawn so the editor can use
  cooked line-buffered input; bracketed-paste / alt-screen are managed
  by the editor itself via DEC mode 1049.
- Spawn uses `shell: true` so $EDITOR strings like `nvim --noplugin`
  or `code --wait` split correctly across platforms (same shape as the
  existing `commit.ts` editor invocation).

Refs #647 (the picker-keymap half of that issue is a separate change).
@esengine esengine merged commit f3a4251 into main May 11, 2026
3 checks passed
@esengine esengine deleted the feature/issue-647-external-editor branch May 11, 2026 08:39
@esengine esengine mentioned this pull request May 11, 2026
6 tasks
esengine added a commit that referenced this pull request May 11, 2026
Hotfix for 0.39.0 install failure: the `postinstall: patch-package`
hook + missing `patch-package` runtime dep + missing `patches/` in the
files array meant fresh `npm install` / `npx reasonix@latest` runs
crashed before the binary was usable. 0.39.0 has been deprecated on
npm and `latest` rolled back to 0.38.0.

Removes the patch-package machinery entirely — it can't work for a
published library since npm hoists `ink` out of reasonix's own
`node_modules`. The ink alt-screen render fix (#639) will return via
a forked ink + `npm:` alias (#663) in a later release.

Piggybacks three PRs that landed since 0.39.0:
- #632 fix(web): actionable web_search / web_fetch errors
- #661 feat(composer): Ctrl+X opens \$EDITOR
- #662 feat(composer): Ctrl+P / Ctrl+N picker navigation
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…#661)

Composes a long prompt in the user's preferred editor instead of
typing it inside the TUI. Match for opencode's `<C-x>e` and codex's
`<C-g>` (issue esengine#647).

Editor resolution follows the standard Unix precedence: $GIT_EDITOR →
$VISUAL → $EDITOR. Picked an explicit GIT_EDITOR-style fallback over
hardcoding nano/notepad so the user's existing shell config carries
through. Missing-editor and non-zero-exit cases surface as a warning
card in the chat log; on success the buffer is replaced with whatever
the user saved (one trailing newline stripped, since most editors
auto-append one).

Implementation notes:
- New action flag in multiline-keys (`openExternalEditor: true`) so the
  pure reducer stays testable and PromptInput just signals up.
- App.tsx flips raw-mode off around the spawn so the editor can use
  cooked line-buffered input; bracketed-paste / alt-screen are managed
  by the editor itself via DEC mode 1049.
- Spawn uses `shell: true` so $EDITOR strings like `nvim --noplugin`
  or `code --wait` split correctly across platforms (same shape as the
  existing `commit.ts` editor invocation).

Refs esengine#647 (the picker-keymap half of that issue is a separate change).
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
Hotfix for 0.39.0 install failure: the `postinstall: patch-package`
hook + missing `patch-package` runtime dep + missing `patches/` in the
files array meant fresh `npm install` / `npx reasonix@latest` runs
crashed before the binary was usable. 0.39.0 has been deprecated on
npm and `latest` rolled back to 0.38.0.

Removes the patch-package machinery entirely — it can't work for a
published library since npm hoists `ink` out of reasonix's own
`node_modules`. The ink alt-screen render fix (esengine#639) will return via
a forked ink + `npm:` alias (esengine#663) in a later release.

Piggybacks three PRs that landed since 0.39.0:
- esengine#632 fix(web): actionable web_search / web_fetch errors
- esengine#661 feat(composer): Ctrl+X opens \$EDITOR
- esengine#662 feat(composer): Ctrl+P / Ctrl+N picker navigation
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.

1 participant