feat(editor, inquire, cli, config): Add inline reply widget and unified editor backend#814
Open
JeanMertz wants to merge 1 commit into
Open
feat(editor, inquire, cli, config): Add inline reply widget and unified editor backend#814JeanMertz wants to merge 1 commit into
JeanMertz wants to merge 1 commit into
Conversation
…ed editor backend
JP now accepts replies inline — without requiring a configured external
editor. Choosing `r` while streaming or `s` while tools run opens a
rich, multi-line prompt built on `reedline` instead of spawning an
editor. `Ctrl+X` inside the widget escapes to the external editor and
re-seeds the inline buffer with the result; `Ctrl+C` cancels and returns
to the interrupt menu.
The same inline widget drives the tool argument-edit (`e`), result-edit
(`e` in the delivery confirmation), and skip-reasoning (`r`) flows in
`ToolPrompter`. These options are now always offered regardless of
whether `editor.cmd` is configured; the editor is the escape hatch, not
the only path.
Two new config keys control the new behaviour:
```toml
[editor.inline]
edit_mode = "emacs" # or "vi"
[interrupt.streaming]
reply_in_editor = false # open editor directly, skipping the widget
[interrupt.tool_call]
reply_in_editor = false
```
The `--edit` flag on `jp query` is simplified to a plain boolean
(`--edit` / `--no-edit` / `-E`); the previous `--edit=<cmd>` and
`--edit=false` forms are removed.
The `open-editor` crate is replaced by a new `EditorBackend` trait in
`jp_editor` with two methods: `edit_text` (ephemeral string-in/out via
a temp file) and `edit_file` (open the editor on caller-owned paths).
`EditOutcome` replaces the old success/error duality: a non-zero exit
now maps to `EditOutcome::Cancelled` rather than an error, letting
callers handle an aborted editor gracefully instead of propagating a
failure. `EditorConfig::path()` is removed; all call sites use
`build_editor_backend()`.
The `PromptBackend` trait's `text_input` method is replaced by
`inline_reply`, which returns a `ReplyOutcome` (`Submit`, `Cancelled`,
or `OpenEditor { current_text }`). `MockPromptBackend` gains
`with_reply_outcomes` to script full reply flows — including editor
escapes — in tests.
`Printer::owned_prompt_writer` is added so components that need to own
their output stream (the line editor) can get a `Box<dyn Write + Send>`
that still routes through the printer's serialized worker.
This implements RFD 088.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JP now accepts replies inline — without requiring a configured external editor. Choosing
rwhile streaming orswhile tools run opens a rich, multi-line prompt built onreedlineinstead of spawning an editor.Ctrl+Xinside the widget escapes to the external editor and re-seeds the inline buffer with the result;Ctrl+Ccancels and returns to the interrupt menu.The same inline widget drives the tool argument-edit (
e), result-edit (ein the delivery confirmation), and skip-reasoning (r) flows inToolPrompter. These options are now always offered regardless of whethereditor.cmdis configured; the editor is the escape hatch, not the only path.Two new config keys control the new behaviour:
The
--editflag onjp queryis simplified to a plain boolean (--edit/--no-edit/-E); the previous--edit=<cmd>and--edit=falseforms are removed.The
open-editorcrate is replaced by a newEditorBackendtrait injp_editorwith two methods:edit_text(ephemeral string-in/out via a temp file) andedit_file(open the editor on caller-owned paths).EditOutcomereplaces the old success/error duality: a non-zero exit now maps toEditOutcome::Cancelledrather than an error, letting callers handle an aborted editor gracefully instead of propagating a failure.EditorConfig::path()is removed; all call sites usebuild_editor_backend().The
PromptBackendtrait'stext_inputmethod is replaced byinline_reply, which returns aReplyOutcome(Submit,Cancelled, orOpenEditor { current_text }).MockPromptBackendgainswith_reply_outcomesto script full reply flows — including editor escapes — in tests.Printer::owned_prompt_writeris added so components that need to own their output stream (the line editor) can get aBox<dyn Write + Send>that still routes through the printer's serialized worker.This implements RFD 088.