|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +## [Unreleased] |
| 6 | + |
| 7 | +### Added - Saved Repos Feature |
| 8 | + |
| 9 | +#### Frontend |
| 10 | +- **Zustand Store**: Created `useSavedProjectsStore` with localStorage persistence |
| 11 | + - Stores saved repositories with key `oss_saved_repos_v1` |
| 12 | + - Actions: `addProject`, `removeProject`, `toggleProject`, `clearAllSaved`, `setAll`, `isSaved` |
| 13 | + - Automatic persistence across page reloads |
| 14 | + |
| 15 | +- **UI Components**: |
| 16 | + - `SaveToggle`: Star icon button in project rows to save/unsave repositories |
| 17 | + - `SavedProjectsPanel`: Side panel for managing saved repos |
| 18 | + - Export saved repos to JSON file |
| 19 | + - Import saved repos from JSON file |
| 20 | + - Clear all saved repos with confirmation |
| 21 | + - View all saved repos with metadata |
| 22 | + |
| 23 | +- **Projects Table**: Added "Save" column as first column in OSS Projects table |
| 24 | +- **Header Button**: Added "Saved Projects" button with count badge in projects page header |
| 25 | + |
| 26 | +#### Backend |
| 27 | +- **Database**: Added `saved_repos` JSONB column to `User` model (default: `[]`) |
| 28 | +- **Service Layer**: Created `savedReposService` with: |
| 29 | + - `getSavedRepos`: Retrieve user's saved repos |
| 30 | + - `mergeSavedRepos`: Merge local and server repos with conflict resolution |
| 31 | + - `updateSavedRepos`: Update saved repos with add/remove/replace actions |
| 32 | + - Maximum 100 saved repos per user enforcement |
| 33 | + |
| 34 | +- **API Endpoints** (tRPC): |
| 35 | + - `user.getSavedRepos`: Get user's saved repos (protected, feature flag: `FEATURE_SAVED_REPOS_DB`) |
| 36 | + - `user.updateSavedRepos`: Update saved repos with merge logic (protected, feature flag: `FEATURE_SAVED_REPOS_DB`) |
| 37 | + - Conflict resolution: Newer `savedAt` timestamp wins |
| 38 | + |
| 39 | +#### Shared Types |
| 40 | +- Created `SavedRepo` type definition in `@opensox/shared` |
| 41 | +- Created `SavedReposAction` and `SavedReposUpdateInput` types |
| 42 | + |
| 43 | +### Configuration |
| 44 | +- **Feature Flag**: `FEATURE_SAVED_REPOS_DB` - Enable/disable database sync (default: disabled) |
| 45 | + - When disabled: Client-only mode with localStorage |
| 46 | + - When enabled: Full sync across devices with merge logic |
| 47 | + |
| 48 | +### Migration |
| 49 | +- Migration file: `add_saved_repos` - Adds `saved_repos` JSONB column to User table |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## How to Use |
| 54 | + |
| 55 | +### For Users |
| 56 | +1. Navigate to `/dashboard/projects` |
| 57 | +2. Click "Find projects" to search for repositories |
| 58 | +3. Click the star icon on any project to save it |
| 59 | +4. Click "Saved Projects" button to view/manage saved repos |
| 60 | +5. Export/import saved repos as JSON for backup |
| 61 | + |
| 62 | +### For Developers |
| 63 | +1. **Client-only mode** (default): Works out of the box with localStorage |
| 64 | +2. **Database sync mode**: Set `FEATURE_SAVED_REPOS_DB=true` in `apps/api/.env` |
| 65 | +3. Run migration: `cd apps/api && npx prisma migrate dev` |
| 66 | +4. Restart API server |
| 67 | + |
| 68 | +### API Usage (when feature flag enabled) |
| 69 | +```typescript |
| 70 | +// Get saved repos |
| 71 | +const savedRepos = await trpc.user.getSavedRepos.query(); |
| 72 | + |
| 73 | +// Add repos |
| 74 | +await trpc.user.updateSavedRepos.mutate({ |
| 75 | + action: 'add', |
| 76 | + repos: [{ id: '123', name: 'repo', url: 'https://...', savedAt: new Date().toISOString() }] |
| 77 | +}); |
| 78 | + |
| 79 | +// Sync with merge |
| 80 | +await trpc.user.updateSavedRepos.mutate({ |
| 81 | + action: 'replace', |
| 82 | + repos: serverRepos, |
| 83 | + localRepos: clientRepos // Will merge and resolve conflicts |
| 84 | +}); |
| 85 | +``` |
0 commit comments