Skip to content

Commit 3ed27d5

Browse files
committed
fix(cli): emit JSON for /history in --output-format json --resume mode
Previously claw --output-format json --resume <session> /history emitted prose text regardless of the output format flag. Now emits structured JSON: {"kind":"history","total":N,"showing":M,"entries":[{"timestamp_ms":...,"text":"..."},...]} Mirrors the parity pattern established in ROADMAP #26 for other resume commands. 159 CLI tests pass, fmt clean.
1 parent e1ed30a commit 3ed27d5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • rust/crates/rusty-claude-cli/src

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2760,10 +2760,19 @@ fn run_resume_command(
27602760
let limit = parse_history_count(count.as_deref())
27612761
.map_err(|error| -> Box<dyn std::error::Error> { error.into() })?;
27622762
let entries = collect_session_prompt_history(session);
2763+
let shown: Vec<_> = entries.iter().rev().take(limit).rev().collect();
27632764
Ok(ResumeCommandOutcome {
27642765
session: session.clone(),
27652766
message: Some(render_prompt_history_report(&entries, limit)),
2766-
json: None,
2767+
json: Some(serde_json::json!({
2768+
"kind": "history",
2769+
"total": entries.len(),
2770+
"showing": shown.len(),
2771+
"entries": shown.iter().map(|e| serde_json::json!({
2772+
"timestamp_ms": e.timestamp_ms,
2773+
"text": e.text,
2774+
})).collect::<Vec<_>>(),
2775+
})),
27672776
})
27682777
}
27692778
SlashCommand::Unknown(name) => Err(format_unknown_slash_command(name).into()),

0 commit comments

Comments
 (0)