aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 11:06:46 +01:00
parent df99318392
commit 86e7c72e5f
10383 changed files with 749164 additions and 749170 deletions

View File

@@ -0,0 +1,35 @@
//! Separate older history at every turn boundary; only successful turns gain completion metadata.
//! A page splitting a turn only adds completion metadata when it contains that turn's last item.
use akode_app_server_protocol::ThreadItemPayload;
use akode_app_server_protocol::Turn;
use akode_app_server_protocol::TurnStatus;
use std::collections::HashMap;
pub(super) fn group_completed_turn_items(
items: Vec<ThreadItemPayload>,
turns: &[Turn],
) -> Vec<(Vec<ThreadItemPayload>, Option<&Turn>)> {
let boundaries: HashMap<_, _> = turns
.iter()
.filter_map(|turn| turn.items.last().map(|item| (item.id(), turn)))
.collect();
let mut groups = Vec::new();
let mut pending = Vec::new();
for item in items {
let boundary = boundaries.get(item.id()).copied();
pending.push(item);
if let Some(turn) = boundary {
let completed_turn = (turn.status == TurnStatus::Completed).then_some(turn);
groups.push((std::mem::take(&mut pending), completed_turn));
}
}
if !pending.is_empty() {
groups.push((pending, None));
}
groups
}
#[cfg(test)]
#[path = "history_completion_tests.rs"]
mod tests;