codex-mobile-bridge 0.2.11

Remote bridge and service manager for codex-mobile.
Documentation
use super::*;

impl BridgeState {
    pub(super) fn thread_response_payload(
        &self,
        runtime_id: &str,
        result: &Value,
        archived: bool,
    ) -> Result<Value> {
        let thread_value = result.get("thread").context("返回缺少 thread 字段")?;
        let thread = normalize_thread(runtime_id, thread_value, archived)?;
        self.storage.upsert_thread_index(&thread)?;
        let _ = self.storage.record_directory_usage(Path::new(&thread.cwd));
        let _ = self.emit_directory_state();
        let thread = self.storage.get_thread_index(&thread.id)?.unwrap_or(thread);

        let mut entries = timeline_entries_from_thread(runtime_id, thread_value)?;
        if entries.is_empty() {
            entries = timeline_entries_from_events(&self.storage.load_thread_events(&thread.id)?);
        }
        let render_snapshot = build_thread_render_snapshot(runtime_id, thread_value)?;
        self.cache_thread_render_snapshot(render_snapshot.clone());

        Ok(json!({
            "runtimeId": runtime_id,
            "thread": thread,
            "renderSnapshot": render_snapshot,
            "entries": entries,
        }))
    }
}