Skip to content

Commit 6415d8f

Browse files
committed
Implement GUI
1 parent 6c9848d commit 6415d8f

File tree

24 files changed

+3106
-171
lines changed

24 files changed

+3106
-171
lines changed

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
9-
108
### Added
9+
- **GUI Implementation** (2025-10-10): Complete graphical user interface using Iced framework
10+
- Tabbed interface with Connection, Send, Receive, Settings, and History tabs
11+
- Connection management: Start listener or connect to peers with discovery support
12+
- Send tab: File/folder picker with browse buttons and transfer initiation
13+
- Receive tab: Output directory selection and auto-accept toggle
14+
- Settings tab: All CLI settings available (compression, window size, chunk size, bandwidth limit, etc.)
15+
- History tab: Display past transfers with statistics and completion status
16+
- Progress tracking: Real-time progress bar with speed, ETA, percentage, and bytes transferred
17+
- Dark theme UI with clean, intuitive design
18+
- Async-compatible architecture using tokio::Mutex for session management
19+
- **Modular GUI Architecture** (2025-10-10): Refactored GUI into organized module structure
20+
- Split monolithic 1224-line file into 10+ focused modules
21+
- Created module structure: app.rs, state.rs, message.rs, operations.rs, utils.rs, styles.rs, views/
22+
- Separated view rendering from business logic for better maintainability
23+
- Simplified styling to use Iced 0.12 built-in themes (Primary, Secondary, Destructive)
24+
- Added chrono dependency for timestamp handling in history view
25+
- Professional appearance with smaller text sizes (12-18px), consistent spacing, and card-like containers
1126
- **Chunk-level resume** (2025-10-10): Transfer now resumes from exact chunk where interrupted, not from beginning
1227
- Chunk completions tracked in memory during transfer
1328
- State automatically saved to disk when connection error detected (before reconnection attempt)

DESIGN.md

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

19122007
See [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

Comments
 (0)