test(cli-rs): guard message boundaries through transcript navigation

navigate::message_navigation_aligns_messages_with_the_top now includes
a reasoning-only response between two navigable messages. Check the
rendered row after stepping across it in both directions. The same
test already covers user-only jumps, viewport alignment, repeated
jumps at the head, and slack at the tail.

Remove boundaries_step_from_the_view_or_the_last_jump, which builds
another set of messages and calls the geometry helpers directly.
This commit is contained in:
Simon Klee
2026-11-18 20:55:10 +01:00
Unverified
parent 391d014451
commit 833acddc8e
2 changed files with 9 additions and 48 deletions
@@ -170,50 +170,3 @@ impl Inner {
after_layout(&tui.app, bind!(self.tui, |tui| continuation(&tui)));
}
}
#[cfg(test)]
mod tests {
use serde_json::json;
use super::*;
#[test]
fn boundaries_step_from_the_view_or_the_last_jump() {
let messages: Vec<SessionMessageInfo> = serde_json::from_value(json!([
{ "id": "msg_1", "type": "user", "text": "one", "time": { "created": 1 } },
{
"id": "msg_2", "type": "assistant", "agent": "build",
"model": { "providerID": "p", "id": "m" }, "time": { "created": 2 },
"content": [{ "type": "text", "text": "reply" }],
},
{
"id": "msg_3", "type": "assistant", "agent": "build",
"model": { "providerID": "p", "id": "m" }, "time": { "created": 3 },
"content": [{ "type": "reasoning", "text": "no text" }],
},
{ "id": "msg_4", "type": "user", "text": "two", "time": { "created": 4 } },
]))
.unwrap();
let anchors: Vec<(String, f64)> =
[("msg_1", 1.0), ("msg_2", 5.0), ("msg_2", 7.0), ("msg_3", 9.0), ("msg_4", 12.0)]
.iter()
.map(|(id, y)| ((*id).to_owned(), *y))
.collect();
let id = |boundary: Option<Boundary>| boundary.map(|boundary| (boundary.id, boundary.top));
// From the view's top; an assistant aligns one row above its first row.
assert_eq!(id(find_boundary(true, &anchors, &messages, 2.0, None, false)), Some(("msg_2".into(), 4.0)));
assert_eq!(id(find_boundary(false, &anchors, &messages, 12.0, None, false)), Some(("msg_2".into(), 4.0)));
// User only skips the reply; a message without text never counts.
assert_eq!(id(find_boundary(true, &anchors, &messages, 2.0, None, true)), Some(("msg_4".into(), 12.0)));
// From the last jump, whatever the view.
assert_eq!(
id(find_boundary(true, &anchors, &messages, 0.0, Some("msg_2"), false)),
Some(("msg_4".into(), 12.0))
);
assert_eq!(find_boundary(true, &anchors, &messages, 0.0, Some("msg_4"), false), None);
assert_eq!(find_boundary(false, &anchors, &messages, 0.0, Some("msg_1"), false), None);
assert_eq!(slack(30.0, 20.0, 40.0, 0.0), 10.0);
assert_eq!(slack(30.0, 20.0, 50.0, 10.0), 10.0);
assert_eq!(slack(5.0, 20.0, 40.0, 0.0), 0.0);
}
}
@@ -271,7 +271,9 @@ fn first_mounts_the_head_and_newer_rows_mount_on_the_way_down() {
#[test]
fn message_navigation_aligns_messages_with_the_top() {
let h = open(turns(30), Info::default());
let mut messages = turns(30);
messages[3]["content"] = json!([{ "type": "reasoning", "text": "thinking only" }]);
let h = open(messages, Info::default());
// A reply's first anchor is its first mounted part, so a closed exploration group does not count
// (`anchors.messagePositions`). The previous message above the view's top is turn 29's reply,
// aligned one row above its text.
@@ -300,6 +302,12 @@ fn message_navigation_aligns_messages_with_the_top() {
}
let screen = h.wait_for("┃ Question 1\n");
assert_eq!(Nav::row(&screen, "Question 1"), Some(TOP + 1), "{screen}");
for (direction, text) in
[("next", "Answer 1 one."), ("next", "Question 2"), ("next", "Question 3"), ("previous", "Question 2")]
{
let screen = settle(&h, h.dispatch(&format!("session.message.{direction}")));
assert_eq!(Nav::row(&screen, text), Some(TOP + 1), "{screen}");
}
}
#[test]