Dual-Channel Architecture
PiCrust uses a dual-channel approach for conversation data: 1. Stream (Ephemeral)- Real-time output via broadcast channels
- Fast, in-memory
- Lost if no subscribers
- Disk-based storage (
history.json) - Durable, always available
- Source of truth for conversation state
The Critical Pattern
The Foolproof UI Pattern
This pattern works for all frontend frameworks:1
Load historical messages on page load
2
Subscribe before sending
3
Spawn stream processor
4
Send user input
Write-Through Persistence
Messages are written to disk immediately after each agent turn. This ensures crash recovery and consistency — disk is always the source of truth.Multiple Agent Turns
A single user input can trigger multiple LLM calls (e.g., “Write hello.rs and run it” causes write, execute, and report turns). Handle this by processing untilDone:
Stream vs History Content
If you miss stream data, fall back to history:
Tauri Integration
Backend (Rust)
Frontend (TypeScript)
Next Steps
Message Flow
Communication patterns
Tauri Integration
Complete Tauri setup guide
OutputChunk Reference
All output chunk types