Skip to content
Merged

2.0.0 #109

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,149 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2025-10-09

### Added

- **Real-time Collaboration Infrastructure**: Complete real-time collaboration system for all document types

- WebSocket-based real-time updates using Supabase Realtime channels
- Live presence indicators showing active users and their cursor positions
- Broadcast-first architecture for immediate UI updates before database saves
- Conflict detection and resolution with version-based optimistic locking
- User avatars and activity indicators in collaboration toolbar
- Connection status monitoring with automatic reconnection
- Save status indicators (saving, saved, error states) with retry functionality
- Version history modal showing all document changes with timestamps and authors
- Document activity logging for audit trails and collaboration tracking

- **Shared Edit Links**: Anonymous editing capabilities for all document types

- Secure share codes for view-only and edit access
- Anonymous users can edit documents via shared edit links without authentication
- RLS-bypassing RPC function (`update_shared_resource`) with SECURITY DEFINER for anonymous saves
- Share link access tracking (last accessed timestamps, access counts)
- Seamless integration with real-time collaboration for shared users

- **Document Versioning System**: Comprehensive version tracking and history

- Automatic version increments on every save with optimistic locking
- Full document history tables for all document types (patch sheets, stage plots, technical riders, run of shows, production schedules, pixel maps, corporate mic plots, theater mic plots)
- Database triggers for automatic history capture on updates
- `last_edited` timestamp tracking on all documents
- Metadata JSONB columns for extensible document properties

- **Collaboration Components**: Rich UI components for collaboration features

- `CollaborationToolbar`: Unified toolbar showing save status, active users, connection status, and history access
- `SaveIndicator`: Real-time save status with spinning indicators and error messages
- `PresenceIndicator`: Avatar stack showing all active users with tooltips
- `ConnectionStatus`: Connection health indicator with automatic reconnection
- `ConflictResolution`: Modal for resolving version conflicts with side-by-side comparison
- `History` components: Version history viewer with diff capabilities

- **Offline Support Infrastructure**: Queue-based offline editing capabilities

- `pending_saves` table for queuing saves when offline
- Automatic retry logic when connection is restored
- Local state persistence using browser storage
- Optimistic UI updates with background synchronization

- **Document Locks**: Optimistic locking to prevent concurrent edit conflicts
- `document_locks` table tracking active editors
- Lock expiration (5 minutes) to prevent stale locks
- Visual indicators showing who is currently editing
- Automatic lock cleanup on disconnect or timeout

### Changed

- **PatchSheetEditor**: Integrated real-time collaboration

- Added broadcast calls for all input/output channel changes
- Fixed infinite re-render loop in PatchSheetOutputs component
- Counter-based remote update detection to handle React Strict Mode
- Real-time propagation of channel additions, deletions, and property changes

- **StagePlotEditor**: Complete collaboration integration

- Added broadcast calls for all 13 state-changing operations (add element, drag, rotate, resize, delete, duplicate, property changes, stage size, background image, name)
- Moved CollaborationToolbar to Header component for consistent UI
- Real-time element synchronization across all collaborators
- Shared edit link support with anonymous user editing

- **TheaterMicPlotEditor**: Enabled real-time collaboration

- Added broadcast calls for all actor management operations (add, update, delete, name changes)
- Fixed 406 errors for anonymous users by adding shareCode parameter to useAutoSave
- Real-time actor list synchronization

- **CorporateMicPlotEditor**: Enabled real-time collaboration

- Added broadcast calls for all presenter management operations (add, update, delete, name changes)
- Fixed 406 errors for anonymous users by adding shareCode parameter to useAutoSave
- Real-time presenter list synchronization

- **Database Schema**: Major collaboration infrastructure additions

- Added `version` and `last_edited` columns to all document tables
- Created 8 history tables (one per document type) with automatic triggers
- Added `document_activity` table for audit logging
- Added `pending_saves` table for offline queue
- Added `document_locks` table for editing locks
- Added `metadata` JSONB columns to all document tables
- Enabled Supabase Realtime replication for all document tables
- Created 166+ RLS policies for collaboration tables

- **Hooks**: New collaboration-focused React hooks

- `useCollaboration`: Central hook managing realtime subscriptions, broadcasts, and remote update handling
- `usePresence`: Manages user presence tracking and active user list
- `useAutoSave`: Enhanced with shareCode support for anonymous editing and version conflict detection

- **Libraries**: New collaboration utility libraries

- `collaboration.ts`: Core collaboration logic (broadcasts, subscriptions, conflict resolution)
- `autoSave.ts`: Enhanced with RPC routing for shared edit links
- `offlineQueue.ts`: Queue management for offline editing support

- **Web App Version**: Updated to `2.0.0` (major version bump for collaboration features)

### Fixed

- **PatchSheetOutputs Infinite Loop**: Eliminated infinite re-render cycles

- Removed unnecessary ref tracking logic that caused circular dependencies
- Simplified useEffect structure to match working PatchSheetInputs pattern
- Fixed state synchronization between parent and child components

- **Shared Edit Link Saves**: Fixed 406 errors for anonymous users

- Added shareCode parameter routing through `update_shared_resource` RPC function
- RPC function uses SECURITY DEFINER to bypass RLS policies
- Anonymous users can now save edits on all shared edit documents

- **JSONB Data Handling**: Fixed data corruption in shared resource updates
- Created helper functions (`is_jsonb_column`, `pg_typeof_column`) to detect JSONB columns
- Used `->` operator for JSONB columns (preserves structure), `->>` for other types
- Changed RETURNING clause from `to_jsonb()` to `row_to_json()` to prevent double-serialization
- Ensured JSONB columns maintain their structure through save/load cycles

### Database Migrations

- `20251007100000_add_version_columns_to_documents.sql` - Version tracking columns
- `20251007110000_create_document_history_tables.sql` - History tables for all document types
- `20251007120000_create_document_activity_table.sql` - Activity audit logging
- `20251007130000_create_pending_saves_table.sql` - Offline save queue
- `20251007140000_create_document_locks_table.sql` - Document locking system
- `20251007145000_add_metadata_columns_to_documents.sql` - Extensible metadata storage
- `20251007150000_add_automatic_history_triggers.sql` - Automatic history capture
- `20251007160000_enable_realtime_replication.sql` - Realtime replication for collaboration
- `20251007170000_add_rls_policies_for_collaboration.sql` - Security policies for collaboration tables
- `20251008180000_add_update_shared_resource_rpc.sql` - RPC function for shared edit links
- `20251008190000_fix_update_shared_resource_jsonb_extraction.sql` - JSONB extraction fix (attempt 1)
- `20251008204809_fix_jsonb_extraction_in_update_shared_resource.sql` - JSONB extraction fix (attempt 2)
- `20251008210000_fix_update_shared_resource_returning.sql` - RETURNING clause fix using row_to_json()

## [1.5.6.8] - 2025-09-30

### Added
Expand Down
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sounddocs/web",
"private": true,
"version": "1.5.6.8",
"version": "2.0.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -16,6 +16,7 @@
"@radix-ui/react-radio-group": "^1.3.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-tooltip": "^1.2.8",
"@sounddocs/analyzer-lite": "workspace:*",
"@sounddocs/analyzer-protocol": "workspace:*",
"@supabase/supabase-js": "^2.49.4",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function App() {
return (
<div className="bg-gray-900 min-h-screen text-white">
<AuthProvider>
<Router>
<Router future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
<Routes>
<Route path="/" element={<Landing />} />
<Route path="/signup" element={<SignUp />} />
Expand Down
Loading
Loading