sigoden/aichat · error
No chat response to copy
Error message
No chat response to copy
What it means
The `.copy` REPL command copies the last chat response to the system clipboard; it requires the last message to have non-empty output. If there is no such response, it bails with 'No chat response to copy'. A subsequent clipboard failure is a separate error ('Failed to copy the last chat response').
Solutions
- Ensure at least one chat response exists in the current session before .copy
- Send a message and wait for the reply, then run .copy
- Use .last to verify there is a response to copy
Example fix
// before: .copy right after starting session .copy // after Explain Rc vs Arc .copy
Defensive patterns
Strategy: try-catch
Validate before calling
let has_output = session.last_message.as_ref()
.map(|m| !m.output.is_empty())
.unwrap_or(false);
if has_output { repl(".copy")?; } else { eprintln!("No response to copy yet"); } Type guard
fn has_copyable_output(last: Option<&LastMessage>) -> bool {
last.map(|m| !m.output.is_empty()).unwrap_or(false)
} Try / catch
match repl(".copy") {
Err(e) if e.to_string() == "No chat response to copy" => {
eprintln!("Ask a question first; .copy needs a prior response");
}
other => other?,
} Prevention
- Run .copy only after a chat response is visible
- Check clipboard tooling availability separately (copy can still fail after this check)
- Don't rely on .copy right after .empty session or role switches
When it happens
Trigger: Running `.copy` when the session has no last message, or when the last message's output is empty (e.g. filtered out by `.filter` on empty output).
Common situations: Typing .copy in a fresh session; copying after .empty session; a response that produced no visible output; running in a terminal/environment where last_message is absent after role switching.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Already in a session, please run '.exit session' first to…
- No session
- Unable to continue the response
- Unable to regenerate the response
- No need to compress since there are no messages in the…
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/d17a849c58f63f19.
Report an issue: GitHub.
Appendix: source
Thrown at src/repl/mod.rs:672
},
".delete" => match args {
Some(args) => {
Config::delete(config, args)?;
}
_ => {
println!("Usage: .delete <role|session|rag|macro|agent-data>")
}
},
".copy" => {
let output = match config
.read()
.last_message
.as_ref()
.filter(|v| !v.output.is_empty())
.map(|v| v.output.clone())
{
Some(v) => v,
None => bail!("No chat response to copy"),
};
set_text(&output).context("Failed to copy the last chat response")?;
}
".exit" => match args {
Some("role") => {
config.write().exit_role()?;
}
Some("session") => {
if config.read().agent.is_some() {
config.write().exit_agent_session()?;
} else {
config.write().exit_session()?;
}
}
Some("rag") => {
config.write().exit_rag()?;
}
Some("agent") => {View on GitHub (pinned to 82976d349a)