rho-coding-agent 3.13.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use pretty_assertions::assert_eq;
use rho_protocol::{MessageOrigin, RhoNotice, SessionId};
use rho_sdk::{
    model::{ContentBlock, ImageContent},
    UserInput,
};

use super::stamp_origin;

// Covers: the model's copy of a message another session sent names that
// session, by id and the first line of its title, on a line of its own ahead
// of the text, and a message with no text gets the line as its own block;
// the person's and rho's messages are left as sent.
// Owner: session runtime model input.
#[test]
fn a_sessions_message_names_its_sender_for_the_model() {
    let id = SessionId::new("1f64ce0c-0000-4000-8000-000000000000");
    let titled = MessageOrigin::session(id.clone(), Some("ARCTIC loader\nsecond line".into()));
    let untitled = MessageOrigin::session(id, None);
    let restart = MessageOrigin::rho(RhoNotice::Restart);
    let image = ContentBlock::Image(ImageContent {
        data: "aGk=".into(),
        mime_type: "image/png".into(),
    });
    let cases = [
        (
            UserInput::text("PR 1 is ready"),
            Some(&titled),
            vec![ContentBlock::Text(
                "[from session 1f64ce0c-0000-4000-8000-000000000000 (ARCTIC loader)]\nPR 1 is ready"
                    .into(),
            )],
        ),
        (
            UserInput::content(vec![image.clone()]).unwrap(),
            Some(&untitled),
            vec![
                ContentBlock::Text("[from session 1f64ce0c-0000-4000-8000-000000000000]".into()),
                image,
            ],
        ),
        (
            UserInput::text("continue"),
            Some(&restart),
            vec![ContentBlock::Text("continue".into())],
        ),
        (
            UserInput::text("hi"),
            None,
            vec![ContentBlock::Text("hi".into())],
        ),
    ];
    for (input, origin, expected) in cases {
        assert_eq!(stamp_origin(input, origin).blocks(), expected.as_slice());
    }
}