read_session_preview

Function read_session_preview 

Source
fn read_session_preview(
    filestore: &FileStore,
    block_id: &str,
) -> (String, usize)
Expand description

Read the per-block output.state.json snapshot from filestore and extract a (preview, node_count) pair for the AgentPicker’s “Recent sessions” list.

The snapshot shape is owned by the frontend (see frontend/app/view/agent/agent-view.tsx::writeSnapshotNow): { schemaVersion, savedAt, highWaterMark, historyOffset, nodes: [DocumentNode...] }. We only touch two fields:

  • nodes.lengthnode_count.
  • The first node with type === "user_message", message field → preview (trimmed, newlines collapsed, max 240 chars).

On any error (snapshot missing, malformed JSON, no user message), returns ("", 0). Callers treat that the same as “no preview”.