Skip to content

feat(editor, inquire, cli, config): Add inline reply widget and unified editor backend#814

Open
JeanMertz wants to merge 1 commit into
mainfrom
rfd-088-impl
Open

feat(editor, inquire, cli, config): Add inline reply widget and unified editor backend#814
JeanMertz wants to merge 1 commit into
mainfrom
rfd-088-impl

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

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:

[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.

…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>
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