Document return value semantics on cancellation (issue #191)

Add comments explaining that Harness::chat() returns an empty string
on Ctrl+C cancellation rather than std::unexpected. This preserves
the conversation state in the chat file, allowing users to resume
the conversation from the point of interruption.
This commit is contained in:
2026-08-05 23:43:28 +00:00
parent d2451f3484
commit f2cefd243b
+11
View File
@@ -84,6 +84,15 @@ std::expected<std::string, std::string> Harness::chat(const Message& user_messag
if (ctrlc_request)
{
// Cancellation (Ctrl+C): return empty string to indicate the chat was
// interrupted. The user message has already been pushed to history, so
// the conversation state will be saved to the chat file. This allows
// the user to resume the conversation from this point.
//
// Note: We return an empty string (success) rather than std::unexpected
// because cancellation is not an error condition - it's a deliberate
// user action to stop processing. Using std::unexpected would prevent
// the harness state from being saved, losing the user's input.
return "";
}
@@ -93,6 +102,8 @@ std::expected<std::string, std::string> Harness::chat(const Message& user_messag
while (!done)
{
if (ctrlc_request)
// Cancellation during API call: same semantics as above - return
// empty string to preserve conversation state in the chat file.
return "";
retries--;