Commit Graph

23 Commits

Author SHA1 Message Date
0ff6c74871 FRE-709: Document duplicate recovery wake - FRE-635 already recovered via FRE-708 2026-04-26 20:23:14 -04:00
e7d7f455c6 FRE-588: Consolidate schema - add teams/project_members exports, fix FK references, update seed
- Export teams, teamMembers, projectMembers from schema index barrel
- Add missing FK: cohortMembers.userId → users.id
- Add missing FK: alerts.acknowledgedBy → users.id
- Update seed.ts to match current schema (characters/scenes use projectId, not scriptId)
2026-04-26 18:17:27 -04:00
ec215ae426 Implement waitlist landing page FRE-656
- Add waitlist tRPC router with signup mutation and count query
- Add referral code generation and tracking
- Register waitlist router in app router
- Add useWaitlistSignup, useWaitlistCount, useReferralCount hooks
- Update landing page with email capture form, live waitlist counter, referral sharing
- Add waitlist and referral CSS styles

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-26 07:57:29 -04:00
11a188c68e FRE-623: Build KPI dashboard with Mixpanel, GA4, Stripe panels and unified report
- Created KPIDashboard component with tab navigation (product/acquisition/revenue/report)
- Created MixpanelPanel for product KPIs linking to Mixpanel
- Created GA4Panel for acquisition KPIs linking to GA4
- Created StripePanel for revenue KPIs linking to Stripe dashboard
- Created UnifiedReport with KPI thresholds table and reporting schedule
- Added KPI dashboard route (/app/kpi) and sidebar navigation link
- Added KPI dashboard CSS styles (metric cards, tabs, table, info cards)
- Fixed pre-existing parse errors in Faq.tsx (unescaped apostrophes)
- Fixed pre-existing CSS import paths in routes.tsx

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-26 07:56:17 -04:00
a638b23c85 Add waitlist seed data to seed script (FRE-645) 2026-04-26 06:34:39 -04:00
67c3881dcf Add waitlist schema for marketing (FRE-635)
- Created waitlist_signups and waitlist_events tables
- Supports email, name, source tracking, and status management
- Enables VIP supporter list for Product Hunt launch
- Migration 0002_chemical_shocker.sql generated
- Fixed brand color in product-hunt-assets-brief.md (#518ac8)
2026-04-26 06:21:20 -04:00
1d39be2446 fix: resolve all collaboration layer test failures for FRE-605
- Fix snapshot restore to properly copy text and map content from Yjs docs
- Fix concurrent edit sync to use delta-based updates instead of full state
- Fix delete operation test with correct position offset
- Add selection and lastActive fields to CursorPosition interface
- Fix updateSelection to propagate selection to cursor object
- Fix idle detection test by manually setting lastActivityTime
- Fix batcher test expectations for auto-flush behavior
- Fix undo/redo test with correct captureTimeout setting

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 10:24:14 -04:00
Paperclip
14b78273f9 FRE-605: Fix Phase 4 tests and improve snapshot restore
- Fix validateMerge test: seed document with content before validation
- Fix IDB persistence test: remove browser-only code from Node.js test
- Improve restoreSnapshot: replace document state entirely instead of additive merge
2026-04-25 09:27:18 -04:00
4435a12dd7 feat: integrate tRPC client with Clerk authentication
- Update trpc-client.ts with auth token management
- Create comprehensive tRPC hooks for all project operations
- Store Clerk session token in localStorage for API auth
- Clear token on sign out
- Support integer IDs matching backend schema

Hooks created:
- Projects: useProjects, useProject, useCreateProject, useUpdateProject, useDeleteProject
- Characters: useCharacters, useCharacter, useCreateCharacter, useUpdateCharacter, useDeleteCharacter
- Relationships: useRelationships, useCharacterRelationships, useCreateRelationship, useUpdateRelationship, useDeleteRelationship
- Scenes: useScenes, useScene, useCreateScene, useUpdateScene, useDeleteScene
- Stats: useCharacterStats, useProjectCharacterStats

All 34 backend tests passing.
2026-04-25 08:31:05 -04:00
754fce269f fix: implement critical security remediation for authentication and authorization
- Add Clerk token verification to tRPC context (server/trpc/index.ts)
- Remove client-controlled authorId/reviewedById from revisions router
- Require JWT_SECRET environment variable, remove hardcoded fallback
- Add table name validation to prevent SQL injection in backup logic
- Fix TRPCContext type to use better-sqlite3 instead of LibSQL
- Update revisions router tests to use proper tRPC v11+ API
- Add resetInMemoryState function for test isolation

Security fixes address:
- Critical: Authentication bypass via missing token verification
- Critical: User impersonation via client-controlled IDs
- High: Insecure WebSocket defaults with hardcoded secrets
- High: SQL injection vulnerability in backup logic

All tests passing (24/24).
2026-04-25 08:24:45 -04:00
936430fb40 FRE-587 Phase 5: Add integration tests - COMPLETE
Phase 5 Polish & Optimization - COMPLETE:

Integration Tests (collaboration.test.ts - 440 lines):
- Multi-user sync flow tests
- Change tracking integration tests
- Merge logic integration tests
- Presence integration tests
- Persistence integration tests
- Performance integration tests
- End-to-end collaboration scenario tests
- Edge case tests (rapid updates, large docs, disconnection, undo/redo)

Coverage:
- 15+ test suites
- 25+ individual tests
- Tests all collaboration layer components
- Browser and Node.js compatible

Phase 5 Summary:
 IndexedDB persistence
 Change highlighting UI
 Version history panel
 WebSocket message batching
 Performance benchmarking
 Conflict detection alerts
 Integration tests

Files Created:
- src/lib/collaboration/collaboration.test.ts (440 lines)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:32:50 -04:00
e47debc2d7 FRE-587 Phase 5: Add performance optimization + conflict alerts
Phase 5 Polish & Optimization - Part 2:

Performance Optimization:
- Create UpdateBatcher class for WebSocket message batching
  - Batches multiple Yjs updates into single messages
  - Configurable batch size (default: 10) and wait time (default: 50ms)
  - Reduces network overhead significantly
  - Tracks statistics (updates sent, batches sent, avg batch size)

Benchmarking:
- Create CollaborationBenchmark class
  - Measures sync latency with percentile stats (p50, p95, p99)
  - Tracks memory usage (heap used/total)
  - Operation timing utilities
  - JSON export for analysis

UI Components:
- ConflictDetectionAlerts component - toast notifications for conflicts
  - Real-time conflict notifications
  - Three resolution options (Keep Mine, Accept Theirs, Review)
  - Auto-dismiss after 10 seconds (configurable)
  - Expandable for multiple conflicts
  - Color-coded by conflict type

Files Created:
- src/lib/collaboration/update-batcher.ts (130 lines)
- src/lib/collaboration/benchmark.ts (200 lines)
- src/components/collaboration/conflict-alerts.tsx (280 lines)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:28:07 -04:00
8c64318b9a FRE-587 Phase 5: Add offline persistence + UI components
Phase 5 Polish & Optimization - Part 1:

Offline Persistence:
- Create IDBPersistence class for IndexedDB storage
- Auto-save with configurable intervals (default 5s)
- Offline mode with update queuing
- Automatic flush when back online

UI Components:
- ChangeHighlighting component - visual change indicators
  - Color-coded by user
  - Auto-fade after 30s
  - Toggle visibility
- VersionHistoryPanel component - snapshot management
  - Chronological snapshot list
  - Relative timestamps
  - One-click restore
  - Manual snapshot creation

Documentation:
- analysis/fre587_phase5_polish_implementation.md

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:24:22 -04:00
298b2f5151 FRE-603: Fix code review blockers (memory leak + auth security)
- Fixed memory leak in PresenceManager: event handlers now use bound methods
  so they can be properly removed in shutdown()
- Removed auth token from URL query parameters (security: prevents token leakage
  to server logs and browser history)
- Fixed TypeScript errors: corrected WebsocketProvider import, removed unsupported
  send() calls, fixed type mismatches in presence callbacks
- All collaboration module files now type-check successfully

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:19:33 -04:00
b89575fb6e FRE-605: Implement Phase 4 Change Tracking & Merge Logic
- Create ChangeTracker class with full version history support
  - Document change recording with metadata
  - Snapshot creation and restoration
  - Change acceptance/rejection workflow
  - Change diff generation between snapshots
  - Event-based change notifications

- Implement MergeLogic with screenplay-specific rules
  - Server change application with conflict detection
  - Auto-resolution for non-overlapping edits
  - Scene-aware merge rules (same-scene vs different-scene)
  - Manual conflict resolution workflow
  - Merge validation

- Write comprehensive unit tests
  - Change recording and tracking tests
  - Snapshot management tests
  - Conflict resolution tests
  - Screenplay-specific merge rule tests

- Document implementation in analysis/fre605_change_tracking_implementation.md

Architecture: ChangeTracker integrates with Yjs document updates.
MergeLogic applies screenplay-specific rules for concurrent edits.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:14:54 -04:00
7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00
36f9b420f5 FRE-608: Add Turso database setup with Drizzle ORM
- Create schema for users, projects, scripts, characters, scenes, revisions
- Implement DatabaseManager with connection pooling
- Implement EdgeDatabaseManager for multi-region replicas
- Implement DatabaseBackupManager with automated scheduling
- Generate initial migration with 9 tables
- Add seed script and documentation
- Configure Drizzle Kit for migration management
- Add NPM scripts for database operations

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 15:41:03 -04:00
4d9b4ecf2a FRE-592: Address code review feedback
Fixes from review:
- Add DB-level unique constraint on character relationships
- Fix character stats to use sceneCharacters join table instead of text matching
- Add loading/error states to CharacterList, CharacterSearch, CharacterStatsPanel
- Add delete confirmation dialogs to CharacterProfile and CharacterRelationships

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 07:23:50 -04:00
ccbf3039d9 FRE-594: Implement revision tracking and version history system
Add complete revision tracking system for scripts with:
- Database schema for revisions and revision_changes tables
- Diff engine with color-coded change types (addition/deletion/modification)
- tRPC router with 14 endpoints (create/list/compare/rollback/branch/merge)
- SolidJS components: RevisionTimeline, DiffViewer, RevisionReview
- Unit tests for diff engine and router

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 05:54:06 -04:00
FrenoCorp Agent
8dc4827597 FRE-592: Implement character database and relationship mapping
Add full character management system with enriched profiles (bio, traits,
arcs, motivation, conflict, secrets), relationship mapping between
characters with types and strength, character search/filter by role and
arc type, and character statistics (scene count, dialogue, screen time).

Includes database schema, tRPC router procedures, SolidJS components,
API hooks, and unit tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 02:24:31 -04:00
Senior Engineer
adf453e245 FRE-586: Add core screenplay editor with auto-formatting engine
- types.ts: Screenplay element types, template configs, and interfaces
- format.ts: Auto-formatting engine with Standard, Sitcom, Podcast templates
- detect.ts: Element detection (scene headings, transitions, characters, parentheticals)
- ScreenplayEditor.tsx: Editor component with keyboard shortcuts and live formatting
- PreviewPanel.tsx: Real-time formatting preview panel
- detect.test.ts: 19 tests for element detection
- format.test.ts: 15 tests for formatting engine and templates
- Fixed transition regex to handle periods and other terminators
- All 34 tests passing
2026-04-23 07:42:58 -04:00
1c74a082e5 FRE-603: Add Presence & Visibility Layer UI components
- CollaboratorList: Display connected users with presence state
- RemoteCursorOverlay: Render remote cursors in editor
- EditingIndicator: Show active editors and their context
- Component index for clean imports
- Tests for CollaboratorList

Architecture:
- Polling-based presence updates (100ms for cursors, 500ms for editors)
- Color-coded user indicators
- Line:column cursor positioning
- Selection highlighting with transparency

Files:
- src/components/collaboration/collaborator-list.tsx
- src/components/collaboration/remote-cursor-overlay.tsx
- src/components/collaboration/editing-indicator.tsx
- src/components/collaboration/index.ts
- src/components/collaboration/collaborator-list.test.tsx

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-23 06:37:21 -04:00
ef1b15c9ea FRE-600: Implement Phase 1 WebSocket + Yjs CRDT foundation
- Create TypeScript and Vite configuration for SolidJS
- Implement Yjs document structure for screenplay collaboration
- Build WebSocket connection manager with exponential backoff reconnection
- Create CRDT document manager with undo/redo support
- Set up WebSocket sync server with JWT authentication
- Add SolidJS reactive bindings for Yjs shared types
- Build collaborative editor component
- Write unit tests for CRDT operations
- Document implementation in analysis/fre600_websocket_foundation.md

Architecture: Yjs chosen over Automerge for better ecosystem and
Tauri compatibility. WebSocket for sync, WebRTC for video.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-22 23:08:27 -04:00