memoryd: recall's local items on one indented line, as Honcho's

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-29 09:17:05 -07:00
co-authored by ornith-1.5-35b-a3b
parent d8c396e691
commit a73d49c609
5 changed files with 279 additions and 40 deletions
+8 -21
View File
@@ -4,12 +4,11 @@
//! Pure: no I/O.
use bxcore::DataClass;
use bxcore::sanitize::neutralise;
use roncho::{Conclusion, Message};
use crate::honcho::read::Label;
use crate::index::class_name;
use crate::recall::{SNIPPET, when};
use crate::recall::{item, snippet, when};
/// One Honcho hit as `recall` shows it.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -29,13 +28,13 @@ impl Item {
/// {class}`, then its text on one line indented by two spaces, so that no text can begin a
/// line the way a header does.
pub fn render(&self, n: usize) -> String {
format!(
"[{n}] {} · {} · {}\n {}",
let header = format!(
"[{n}] {} · {} · {}",
self.tag,
self.from,
class_name(self.class),
self.text
)
class_name(self.class)
);
item(&header, &self.text)
}
}
@@ -53,21 +52,9 @@ pub fn relevant(query: &[String], text: &str) -> bool {
words(text).iter().any(|w| query.contains(w))
}
/// Text from Honcho as an item holds it: neutralised, every control character (a line break
/// among them) and every Unicode line or paragraph separator a space, then cut to its first
/// `SNIPPET` characters, as a local snippet is cut.
/// Text from Honcho as an item holds it: as a local hit's text is (`recall::snippet`).
pub fn clean(text: &str) -> String {
neutralise(text)
.chars()
.map(|c| {
if c.is_control() || c == '\u{2028}' || c == '\u{2029}' {
' '
} else {
c
}
})
.take(SNIPPET)
.collect()
snippet(text)
}
/// `{name}: {peer} said, {when}` for a message.