Move rollout state loading into bridge

This commit is contained in:
Meta Vens 2026-05-14 08:20:53 +01:00
commit 473ba34390
6 changed files with 32 additions and 27 deletions

View file

@ -1,5 +1,28 @@
use std::path::Path;
use codex_core::CodexThread;
use codex_core::RolloutRecorder;
use codex_core::latest_epiphany_state_from_rollout_items;
use codex_protocol::protocol::EpiphanyThreadState;
use codex_protocol::protocol::InitialHistory;
pub async fn load_epiphany_state_from_rollout_path(
rollout_path: &Path,
) -> std::result::Result<Option<EpiphanyThreadState>, String> {
let items = match RolloutRecorder::get_rollout_history(rollout_path)
.await
.map_err(|err| {
format!(
"failed to load rollout `{}` for Epiphany state: {err}",
rollout_path.display()
)
})? {
InitialHistory::New | InitialHistory::Cleared => Vec::new(),
InitialHistory::Forked(items) => items,
InitialHistory::Resumed(resumed) => resumed.history,
};
Ok(latest_epiphany_state_from_rollout_items(&items))
}
pub async fn live_thread_epiphany_state(thread: &CodexThread) -> Option<EpiphanyThreadState> {
let mut epiphany_state = thread.epiphany_state().await;