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
10 changes: 4 additions & 6 deletions crates/jp_cli/src/cmd/conversation/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ impl Show {
let conversation = ctx.workspace.metadata(&handle)?;
let events = ctx.workspace.events(&handle)?;

let config = events.config().map_err(ConversationError::from)?;

let mut attachments = vec![];
for attachment in events
.config()
.map_err(ConversationError::from)?
.conversation
.attachments
{
for attachment in &config.conversation.attachments {
attachments.push(attachment_detail_item(&attachment.to_url()?));
}

Expand All @@ -52,6 +49,7 @@ impl Show {
.with_event_count(events.len())
.with_turn_count(events.iter_turns().len())
.with_title(conversation.title.as_ref())
.with_model(config.assistant.model.id.resolved().to_string())
.with_last_activated_at(Some(conversation.last_activated_at))
.with_pinned_flag(conversation.is_pinned())
.with_local_flag(local)
Expand Down
19 changes: 19 additions & 0 deletions crates/jp_cli/src/format/conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub struct DetailsFmt {
/// The conversation title.
pub title: Option<String>,

/// The model the conversation is configured to use, as `provider/name`.
pub model: Option<String>,

/// The number of events in the conversation.
pub message_count: usize,

Expand Down Expand Up @@ -72,6 +75,7 @@ impl DetailsFmt {
heading: None,
assistant_name: None,
title: None,
model: None,
message_count: 0,
turn_count: 0,
pinned: None,
Expand Down Expand Up @@ -141,6 +145,12 @@ impl DetailsFmt {
self
}

#[must_use]
pub fn with_model(mut self, model: impl Into<String>) -> Self {
self.model = Some(model.into());
self
}

/// Set the line rendered above the rows.
#[must_use]
pub fn with_heading(mut self, heading: impl Into<String>) -> Self {
Expand Down Expand Up @@ -206,6 +216,7 @@ impl DetailsFmt {
"id": self.id.to_string(),
"title": self.title,
"assistant": self.assistant_name,
"model": self.model,
"active": self.active,
"pinned": self.pinned,
"local": self.local,
Expand Down Expand Up @@ -249,6 +260,10 @@ impl DetailsFmt {
rows.push(self.scalar("Assistant", name));
}

if let Some(model) = self.model.clone() {
rows.push(self.scalar("Model", model));
}

if self.message_count > 0 {
rows.push(self.scalar("Events", self.message_count.to_string()));
}
Expand Down Expand Up @@ -351,3 +366,7 @@ impl fmt::Display for DetailsFmt {
write!(f, "{}", details(self.heading(), self.rows()))
}
}

#[cfg(test)]
#[path = "conversation_tests.rs"]
mod tests;
39 changes: 39 additions & 0 deletions crates/jp_cli/src/format/conversation_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::time::Duration;

use chrono::{DateTime, Utc};
use serde_json::json;

use super::*;

fn make_id(secs: u64) -> ConversationId {
ConversationId::try_from(DateTime::<Utc>::UNIX_EPOCH + Duration::from_secs(secs)).unwrap()
}

#[test]
fn details_show_the_model_beneath_the_title() {
let details = DetailsFmt::new(make_id(1000))
.with_title(Some("Rework the config pipeline"))
.with_model("anthropic/claude-sonnet-4-5")
.with_pretty_printing(false);

assert_eq!(
details.to_string(),
" ID jp-c10000\n Title Rework the config pipeline\n Model \
anthropic/claude-sonnet-4-5"
);
assert_eq!(
details.json()["model"],
json!("anthropic/claude-sonnet-4-5")
);
}

/// The payload keeps every key present, so a consumer reads `model: null`
/// rather than a missing key when no model was set.
#[test]
fn json_reports_a_missing_model_as_null() {
let details = DetailsFmt::new(make_id(1000));

let json = details.json();

assert_eq!(json.get("model"), Some(&serde_json::Value::Null));
}
Loading