mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Addresses #23181 ## Why Renamed threads can share names, so hints that suggest resuming directly by name are ambiguous. Issue #23181 asks for the picker hint to include the thread name and thread ID in parens so users can disambiguate safely. ## What - Adds a shared resume hint formatter for named threads: run `codex resume`, then select `<name> (<thread-id>)`. - Uses that hint for /rename confirmations, TUI session summaries, and CLI/TUI exit messages. - Keeps direct `codex resume <thread-id>` guidance for unnamed threads. ## Verification Manually verified that message after `/rename` and after `/exit` include session ID in parens. --------- Co-authored-by: Felipe Coury <felipe.coury@openai.com>
93 lines
2.6 KiB
Rust
93 lines
2.6 KiB
Rust
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[tokio::test]
|
|
async fn session_summary_skips_when_no_usage_or_resume_hint() {
|
|
assert!(
|
|
session_summary(
|
|
TokenUsage::default(),
|
|
/*thread_id*/ None,
|
|
/*thread_name*/ None,
|
|
/*rollout_path*/ None,
|
|
)
|
|
.is_none()
|
|
);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn session_summary_skips_resume_hint_until_rollout_exists() {
|
|
let usage = TokenUsage::default();
|
|
let conversation = ThreadId::from_string("123e4567-e89b-12d3-a456-426614174000").unwrap();
|
|
let temp_dir = tempdir().expect("temp dir");
|
|
let rollout_path = temp_dir.path().join("rollout.jsonl");
|
|
|
|
assert!(
|
|
session_summary(
|
|
usage,
|
|
Some(conversation),
|
|
/*thread_name*/ None,
|
|
Some(&rollout_path),
|
|
)
|
|
.is_none()
|
|
);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn session_summary_includes_resume_hint_for_persisted_rollout() {
|
|
let usage = TokenUsage {
|
|
input_tokens: 10,
|
|
output_tokens: 2,
|
|
total_tokens: 12,
|
|
..Default::default()
|
|
};
|
|
let conversation = ThreadId::from_string("123e4567-e89b-12d3-a456-426614174000").unwrap();
|
|
let temp_dir = tempdir().expect("temp dir");
|
|
let rollout_path = temp_dir.path().join("rollout.jsonl");
|
|
std::fs::write(&rollout_path, "{}\n").expect("write rollout");
|
|
|
|
let summary = session_summary(
|
|
usage,
|
|
Some(conversation),
|
|
/*thread_name*/ None,
|
|
Some(&rollout_path),
|
|
)
|
|
.expect("summary");
|
|
assert_eq!(
|
|
summary.usage_line,
|
|
Some("Token usage: total=12 input=10 output=2".to_string())
|
|
);
|
|
assert_eq!(
|
|
summary.resume_hint,
|
|
Some("codex resume 123e4567-e89b-12d3-a456-426614174000".to_string())
|
|
);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn session_summary_names_picker_item_when_thread_has_name() {
|
|
let usage = TokenUsage {
|
|
input_tokens: 10,
|
|
output_tokens: 2,
|
|
total_tokens: 12,
|
|
..Default::default()
|
|
};
|
|
let conversation = ThreadId::from_string("123e4567-e89b-12d3-a456-426614174000").unwrap();
|
|
let temp_dir = tempdir().expect("temp dir");
|
|
let rollout_path = temp_dir.path().join("rollout.jsonl");
|
|
std::fs::write(&rollout_path, "{}\n").expect("write rollout");
|
|
|
|
let summary = session_summary(
|
|
usage,
|
|
Some(conversation),
|
|
Some("my-session".to_string()),
|
|
Some(&rollout_path),
|
|
)
|
|
.expect("summary");
|
|
assert_eq!(
|
|
summary.resume_hint,
|
|
Some(
|
|
"codex resume, then select my-session (123e4567-e89b-12d3-a456-426614174000)"
|
|
.to_string()
|
|
)
|
|
);
|
|
}
|