Skip to content

Commit 5198d3b

Browse files
committed
Update CLAUDE.md to current state
1 parent 3b7dfea commit 5198d3b

File tree

1 file changed

+174
-21
lines changed

1 file changed

+174
-21
lines changed

CLAUDE.md

Lines changed: 174 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ SharpSync is a **pure .NET file synchronization library** with no native depende
135135

136136
### Platform-Specific Optimizations
137137

138-
- **Nextcloud**: Native chunking v2 API support
139-
- **OCIS**: TUS protocol preparation
138+
- **Nextcloud**: Native chunking v2 API support (fully implemented)
139+
- **OCIS**: TUS protocol preparation (NOT YET IMPLEMENTED - falls back to generic upload)
140140
- **Generic WebDAV**: Fallback with progress reporting
141141

142142
### Design Patterns
@@ -198,6 +198,146 @@ var options = new SyncOptions { ConflictResolver = new SmartConflictResolver() }
198198
var result = await syncEngine.SyncAsync(options);
199199
```
200200

201+
## Nimbus Desktop Client Integration
202+
203+
SharpSync serves as the core sync library for **Nimbus**, an accessible Nextcloud desktop client alternative for Windows. This section documents the integration architecture and recommendations.
204+
205+
### Architecture: Library vs Application Responsibilities
206+
207+
**SharpSync (Library) Provides:**
208+
- Sync engine with bidirectional sync, conflict detection, progress reporting
209+
- WebDAV storage with Nextcloud-specific optimizations (chunking v2, server detection)
210+
- OAuth2 token management abstraction (`IOAuth2Provider`)
211+
- Conflict resolution with rich analysis (`SmartConflictResolver`)
212+
- Sync state persistence (`ISyncDatabase`)
213+
- Pattern-based filtering (`ISyncFilter`)
214+
215+
**Nimbus (Application) Handles:**
216+
- Desktop UI (WPF/WinUI/Avalonia)
217+
- System tray integration
218+
- Filesystem monitoring (`FileSystemWatcher`)
219+
- Credential storage (Windows Credential Manager)
220+
- Background sync scheduling
221+
- Virtual files (Windows Cloud Files API)
222+
- User preferences and settings
223+
224+
### Current API Strengths for Desktop Clients
225+
226+
| Feature | Status | Notes |
227+
|---------|--------|-------|
228+
| Progress events | Excellent | `ProgressChanged` event with percentage, item counts, current file |
229+
| Conflict events | Excellent | `ConflictDetected` with rich `ConflictAnalysis` data |
230+
| Sync preview | Excellent | `GetSyncPlanAsync()` returns detailed plan before execution |
231+
| OAuth2 abstraction | Good | `IOAuth2Provider` interface for app-specific implementation |
232+
| Conflict resolution | Excellent | `SmartConflictResolver` with UI callback delegate |
233+
| Nextcloud support | Good | Chunking v2, server detection, ETag handling |
234+
235+
### Nimbus Integration Pattern
236+
237+
```csharp
238+
// 1. Nimbus implements IOAuth2Provider with Windows-specific auth
239+
public class NimbusOAuth2Provider : IOAuth2Provider
240+
{
241+
public async Task<OAuth2Result> AuthenticateAsync(OAuth2Config config, ...)
242+
{
243+
// Open system browser to authorization URL
244+
// Listen on localhost for OAuth callback
245+
// Exchange authorization code for tokens
246+
// Store tokens in Windows Credential Manager
247+
return result;
248+
}
249+
}
250+
251+
// 2. Create storage and engine instances
252+
var localStorage = new LocalFileStorage(localSyncPath);
253+
var remoteStorage = new WebDavStorage(nextcloudUrl, nimbusOAuthProvider);
254+
var database = new SqliteSyncDatabase(Path.Combine(appDataPath, "sync.db"));
255+
var engine = new SyncEngine(localStorage, remoteStorage, database);
256+
257+
// 3. Wire up UI binding via events
258+
engine.ProgressChanged += (s, e) => {
259+
Dispatcher.Invoke(() => {
260+
ProgressBar.Value = e.Progress.Percentage;
261+
StatusLabel.Text = $"Syncing: {e.Progress.CurrentItem}";
262+
ItemCountLabel.Text = $"{e.Progress.ProcessedItems}/{e.Progress.TotalItems}";
263+
});
264+
};
265+
266+
// 4. Implement conflict resolution with UI dialogs
267+
var resolver = new SmartConflictResolver(
268+
conflictHandler: async (analysis, ct) => {
269+
// analysis contains: LocalSize, RemoteSize, LocalModified, RemoteModified,
270+
// DetectedNewer, Recommendation, ReasonForRecommendation
271+
return await Dispatcher.InvokeAsync(() => ShowConflictDialog(analysis));
272+
},
273+
defaultResolution: ConflictResolution.Ask
274+
);
275+
276+
// 5. Preview changes before sync (optional UI feature)
277+
var plan = await engine.GetSyncPlanAsync();
278+
// plan.Downloads, plan.Uploads, plan.Deletes, plan.Conflicts, plan.Summary
279+
280+
// 6. Nimbus handles FileSystemWatcher independently
281+
_watcher = new FileSystemWatcher(localSyncPath);
282+
_watcher.Changed += async (s, e) => await TriggerSyncAsync();
283+
_watcher.EnableRaisingEvents = true;
284+
```
285+
286+
### Current API Gaps (To Be Resolved in v1.0)
287+
288+
| Gap | Impact | Status |
289+
|-----|--------|--------|
290+
| No selective folder sync API | Can't sync single folders on demand | Planned: `SyncFolderAsync()`, `SyncFilesAsync()` |
291+
| No pause/resume | Long syncs can't be paused | Planned: `PauseAsync()`, `ResumeAsync()` |
292+
| No incremental change notification | FileSystemWatcher triggers full scan | Planned: `NotifyLocalChangeAsync()` |
293+
| No virtual file awareness | Can't track placeholder vs downloaded | Planned: `VirtualFileCallback` |
294+
| Single-threaded engine | One sync at a time per instance | By design - create separate instances if needed |
295+
| No bandwidth throttling | Can saturate network | Planned: `SyncOptions.MaxBytesPerSecond` |
296+
| OCIS TUS not implemented | Falls back to generic upload | Planned for v1.0 |
297+
298+
### Required SharpSync API Additions (v1.0)
299+
300+
These APIs are required for v1.0 release to support Nimbus desktop client:
301+
302+
**Selective Sync:**
303+
1. `SyncFolderAsync(string path)` - Sync a specific folder without full scan
304+
2. `SyncFilesAsync(IEnumerable<string> paths)` - Sync specific files on demand
305+
3. `NotifyLocalChangeAsync(string path, ChangeType type)` - Accept FileSystemWatcher events for incremental sync
306+
307+
**Protocol Support:**
308+
4. OCIS TUS protocol implementation (`WebDavStorage.cs:547` currently falls back)
309+
310+
**Sync Control:**
311+
5. `SyncOptions.MaxBytesPerSecond` - Built-in bandwidth throttling
312+
6. `PauseAsync()` / `ResumeAsync()` - Pause and resume long-running syncs
313+
7. `GetPendingOperationsAsync()` - Inspect sync queue for UI display
314+
315+
**Progress & History:**
316+
8. Per-file progress events (currently only per-sync-operation)
317+
9. `GetRecentOperationsAsync()` - Operation history for activity feed
318+
319+
**Virtual Files:**
320+
10. `SyncOptions.VirtualFileCallback` - Hook for virtual file systems (Windows Cloud Files API)
321+
322+
### API Readiness Score for Nimbus
323+
324+
**Current State (Pre-v1.0):**
325+
326+
| Component | Score | Notes |
327+
|-----------|-------|-------|
328+
| Core sync engine | 9/10 | Production-ready, well-tested |
329+
| Nextcloud WebDAV | 8/10 | Missing OCIS TUS protocol |
330+
| OAuth2 abstraction | 9/10 | Clean interface, Nimbus implements |
331+
| UI binding (events) | 9/10 | Excellent progress/conflict events |
332+
| Conflict resolution | 9/10 | Rich analysis, extensible callbacks |
333+
| Selective sync | 4/10 | Filter-only, no folder/file API |
334+
| Pause/Resume | 2/10 | Not implemented |
335+
| Desktop integration hooks | 6/10 | Good abstraction, missing some hooks |
336+
337+
**Current Overall: 7/10** - Solid foundation, gaps identified
338+
339+
**Target for v1.0: 9.5/10** - All gaps resolved, ready for Nimbus development
340+
201341
## Version 1.0 Release Readiness
202342

203343
### Current Status: ~75% Complete
@@ -338,22 +478,35 @@ The core library is production-ready, but several critical items must be address
338478

339479
**Current Score: 5/9 (56%)** - S3 implementation complete!
340480

341-
### 🎯 Post-v1.0 Roadmap (Future Versions)
342-
343-
**v1.0** ✅ All Major Storage Backends Implemented!
344-
- ✅ SFTP storage implementation (DONE!)
345-
- ✅ FTP/FTPS storage implementation (DONE!)
346-
- ✅ S3 storage implementation with AWS S3 and S3-compatible services (DONE!)
347-
- ✅ Integration test infrastructure with Docker for SFTP, FTP, and S3/LocalStack (DONE!)
348-
349-
**v1.1**
350-
- Code coverage reporting
351-
- Performance benchmarks
352-
- Multi-platform CI testing (Windows, macOS)
353-
- Additional conflict resolution strategies
354-
- Advanced filtering (regex support)
355-
356-
**v2.0**
357-
- Breaking changes if needed
358-
- API improvements based on user feedback
359-
- Performance optimizations
481+
### 🎯 v1.0 Roadmap (Pre-Release)
482+
483+
**✅ Completed**
484+
- ✅ SFTP storage implementation
485+
- ✅ FTP/FTPS storage implementation
486+
- ✅ S3 storage implementation with AWS S3 and S3-compatible services
487+
- ✅ Integration test infrastructure with Docker for SFTP, FTP, and S3/LocalStack
488+
489+
**🚧 Required for v1.0 Release**
490+
491+
Documentation & Testing:
492+
- [ ] Rewrite README.md with correct API documentation
493+
- [ ] WebDavStorage integration tests
494+
- [ ] Multi-platform CI testing (Windows, macOS)
495+
- [ ] Code coverage reporting
496+
- [ ] Examples directory with working samples
497+
498+
Desktop Client APIs (for Nimbus):
499+
- [ ] `SyncFolderAsync(string path)` - Sync specific folder without full scan
500+
- [ ] `SyncFilesAsync(IEnumerable<string> paths)` - Sync specific files on demand
501+
- [ ] `NotifyLocalChangeAsync(string path, ChangeType type)` - Accept FileSystemWatcher events for incremental sync
502+
- [ ] OCIS TUS protocol implementation (currently falls back to generic upload at `WebDavStorage.cs:547`)
503+
- [ ] `SyncOptions.MaxBytesPerSecond` - Built-in bandwidth throttling
504+
- [ ] `PauseAsync()` / `ResumeAsync()` - Pause and resume long-running syncs
505+
- [ ] `GetPendingOperationsAsync()` - Inspect sync queue for UI display
506+
- [ ] Per-file progress events (currently only per-sync-operation)
507+
- [ ] `SyncOptions.VirtualFileCallback` - Hook for virtual file systems (Windows Cloud Files API)
508+
- [ ] `GetRecentOperationsAsync()` - Operation history for activity feed
509+
510+
Performance & Polish:
511+
- [ ] Performance benchmarks with BenchmarkDotNet
512+
- [ ] Advanced filtering (regex support)

0 commit comments

Comments
 (0)