@@ -1907,16 +1907,114 @@ test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured
19071907
19081908---
19091909
1910+ ## GUI Architecture
1911+
1912+ ### Implementation Overview (October 2025)
1913+
1914+ The GUI is implemented using the ** Iced framework** for cross-platform support with a reactive, Elm-inspired architecture. The design separates UI state from transfer operations while maintaining async compatibility.
1915+
1916+ ### Architecture Components
1917+
1918+ ```
1919+ ┌────────────────────────────────────────────────────────────┐
1920+ │ P2PTransferApp (Main State) │
1921+ │ • current_tab: Active tab selection │
1922+ │ • connection_state: Connection management │
1923+ │ • send_state: File/folder send state │
1924+ │ • receive_state: Download settings │
1925+ │ • settings: Transfer configuration │
1926+ │ • session: Arc<tokio::Mutex<P2PSession>> │
1927+ │ • transfer_progress: Real-time stats │
1928+ │ • history: Arc<std::Mutex<TransferHistory>> │
1929+ └────────────────────────────────────────────────────────────┘
1930+ │
1931+ ┌──────────────────┼──────────────────┐
1932+ │ │ │
1933+ ┌───▼───┐ ┌────▼────┐ ┌────▼────┐
1934+ │Message│ │ Command │ │ View │
1935+ │ Types │ │Handlers │ │ Layer │
1936+ └───────┘ └─────────┘ └─────────┘
1937+ ```
1938+
1939+ ### Key Design Decisions
1940+
1941+ 1 . ** Hybrid Mutex Strategy**
1942+ - ` tokio::Mutex<P2PSession> ` : Async operations (send/receive)
1943+ - ` std::Mutex<TransferHistory> ` : Synchronous view rendering
1944+ - Rationale: Avoid async in view() while maintaining Send/Sync
1945+
1946+ 2 . ** Tab-Based Navigation**
1947+ - Connection: Session establishment (listen/connect)
1948+ - Send: File/folder picker and transfer initiation
1949+ - Receive: Output directory and auto-accept settings
1950+ - Settings: All transfer configuration (compression, window, bandwidth)
1951+ - History: Past transfers with statistics
1952+
1953+ 3 . ** Progress Tracking**
1954+ - Real-time progress bar with ETA, speed, percentage
1955+ - Bytes transferred and total size display
1956+ - Separate progress for send vs receive operations
1957+
1958+ 4 . ** Async Command Pattern**
1959+ - Connection operations return ` Command<Message> `
1960+ - Background tasks use ` tokio::spawn ` for async execution
1961+ - Results sent back as messages (success/failure)
1962+
1963+ ### Message Flow
1964+
1965+ ```
1966+ User Action (Button Click)
1967+ ↓
1968+ Message Generated (e.g., StartSend)
1969+ ↓
1970+ update() Method Handles Message
1971+ ↓
1972+ Command::perform() Spawns Async Task
1973+ ↓
1974+ Async Operation (send_path, etc.)
1975+ ↓
1976+ Result Message (SendComplete/SendFailed)
1977+ ↓
1978+ update() Updates State
1979+ ↓
1980+ view() Re-renders UI
1981+ ```
1982+
1983+ ### Integration with Core Library
1984+
1985+ - ** Session Management** : Uses ` P2PSession::establish() ` and ` P2PSession::accept() `
1986+ - ** Send Operation** : Calls ` session.send_path() ` with reconnect config
1987+ - ** Receive Operation** : Uses ` session.run_event_loop() ` for incoming transfers
1988+ - ** Progress Callbacks** : Future enhancement to update GUI progress in real-time
1989+
1990+ ### File Dialog Integration
1991+
1992+ - ** rfd crate** : Async file/folder dialogs for cross-platform support
1993+ - Browse buttons trigger ` rfd::AsyncFileDialog `
1994+ - Selected paths update application state via messages
1995+
1996+ ### Theme and Styling
1997+
1998+ - ** Dark Theme** : Default theme for better visibility
1999+ - ** Color-coded Status** : Visual feedback for connection, transfers, errors
2000+ - ** Responsive Layout** : Adapts to different window sizes
2001+ - ** Progress Bars** : Iced's native progress_bar widget
2002+
2003+ ---
2004+
19102005## Future Enhancements
19112006
19122007See [ TODO.md] ( TODO.md ) for complete roadmap.
19132008
19142009** Highlights** :
2010+ - Real-time progress callbacks to GUI (currently uses placeholders)
2011+ - Multi-transfer queue support
2012+ - Drag-and-drop file selection
2013+ - Tray icon for background operation
2014+ - Connection profiles (save frequently used peers)
19152015- Benchmarking suite for windowed vs sequential
19162016- Security layer (TLS, authentication)
1917- - Advanced features (adaptive compression, transfer history)
19182017- Full UDP hole punching with rendezvous server
1919- - GUI with Iced framework
19202018- Mobile support (iOS, Android)
19212019
19222020---
0 commit comments