Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/jp_cli/src/cmd/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ impl Query {
};

// If a query is provided, and editing is not explicitly requested, or
// in addition to the query, stdin contains data, we omit opening the
// editor.
if (self.query.as_ref().is_some_and(|v| !v.is_empty()) || !piped)
// in addition to the query, stdin contains data, or editing was
// explicitly suppressed with `--no-edit`, we omit opening the editor.
if (self.query.as_ref().is_some_and(|v| !v.is_empty()) || !piped || self.force_no_edit())
&& !self.force_edit()
&& !request.is_empty()
{
Expand Down
32 changes: 32 additions & 0 deletions crates/jp_cli/src/cmd/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,38 @@ fn edit_message_quote_without_editor_is_synthesized() {
assert!(partial.is_empty());
}

#[test]
fn edit_message_skips_editor_when_no_edit_with_piped_stdin() {
// Regression: `--no-edit` must skip the editor even when piped stdin
// content makes the request non-empty. Previously the explicit override
// was only checked when the request was still empty, so `--no-edit` was
// silently ignored whenever stdin was piped without a query argument.
let config = AppConfig::new_test();
let root = Utf8Path::new("/tmp");
let query = Query {
no_edit: true,
..Default::default()
};

let mut request = ChatRequest::from("hi");
let stream = ConversationStream::new_test();
let mut pending_trim = PendingStreamTrim::default();
let (source, partial) = query
.edit_message(
&mut request,
&stream,
&mut pending_trim,
true,
&config,
root,
)
.unwrap();

assert_eq!(source, QuerySource::Inline);
assert_eq!(request.content, "hi");
assert!(partial.is_empty());
}

#[test]
fn picker_new_item_gated_by_new_incompatible_flags() {
// The picker may only offer "start a new conversation" when `--new` would
Expand Down
Loading