* feat: complete database migration system overhaul
BREAKING CHANGE: Legacy SQL-based migration system removed in favor of TypeScript/Umzug migrations
This PR completely overhauls Crystal's database migration system, replacing the legacy SQL file-based approach with a modern, testable, and maintainable TypeScript migration framework using Umzug.
1. **Monolithic 288-line migration** - Split into 7 atomic, focused migrations
2. **No test coverage** - Added comprehensive test suite with Jest
3. **Manual SQL file management** - Automated with TypeScript and proper tooling
4. **No rollback support** - Full up/down migration support
5. **Race conditions** - Added migration locking mechanism
6. **Poor developer experience** - Added CLI tools, templates, and documentation
- Implemented Umzug-based migration framework with TypeScript
- Created DatabaseAdapter pattern for database portability
- Separate ProductionMigrator for packaged Electron apps
- Migration locking to prevent concurrent execution
- Comprehensive helper functions (tableExists, columnExists)
- 001-core-tables: Projects, sessions, session_outputs
- 002-conversation-system: Conversation messages
- 003-execution-tracking: Execution diffs, prompt markers
- 004-project-management: Run commands, folders
- 005-ui-persistence: UI state, app opens, preferences
- 006-indexes-and-constraints: Performance indexes
- 007-session-git-tracking: Git tracking columns
- npm scripts: db:migrate, db:rollback, db:status, db:reset
- Migration creation CLI: db:create-migration
- Migration templates for common patterns
- Comprehensive test suite (migration.test.ts)
- Detailed documentation (README.md, MIGRATION_GUIDE.md)
- SQL injection protection in PRAGMA queries
- Migration locking prevents race conditions
- Defensive column/table existence checks
- Idempotent migrations (can run multiple times safely)
- ✅ All migration lifecycle tests pass
- ✅ Fresh install creates all tables correctly
- ✅ Existing databases upgrade smoothly
- ✅ No duplicate migrations on repeated runs
- ✅ Performance: <15ms startup time
- ✅ Real Crystal app tested successfully
- Removed all legacy SQL migration files
- Removed legacy migration code from DatabaseService
- Migration system now runs automatically on startup
- No manual migration steps required
- Enhanced CLI with better error messages
- More migration templates
- Progress indicators for long migrations
- Migration squashing for old migrations
This represents a major improvement in code quality, maintainability, and developer experience for the Crystal project.
* ci: ensure database migration checks run on all PRs
- Remove path filters from database-migrations workflow to ensure it runs
- Add note about CI checks to README
- This ensures the database migration tests run for this PR
* ci: add database tests to existing quality workflow
- Add database-tests job to quality.yml workflow
- Tests run in parallel with existing quality checks
- Includes all database migration safety tests:
- Migration validation
- Fresh installation
- Idempotency testing
- Legacy database upgrades
- Uses existing workflow to ensure tests run on PR
* fix: correct test script path in package.json
- Remove extra ../ from script path
- Script is located at main/scripts/ not ../scripts/
* fix: use correct build command in test script
- Use 'pnpm run build' instead of 'pnpm run build:main' since we're already in the main directory
* fix: rebuild better-sqlite3 for correct Node version in CI
- Add rebuild step to ensure native modules match ts-node's Node version
- Fixes NODE_MODULE_VERSION mismatch error
* fix: use npm rebuild in main directory for native modules
- Use npm rebuild instead of pnpm to rebuild better-sqlite3 in correct location
- Ensures native module is built for ts-node's Node version
* fix: resolve CI failures after reorganization
- Fix package.json main field path (remove extra 'main/' prefix)
- Update Migrator to load both .js and .ts files for ts-node compatibility
- Add TypeScript detection for proper migration path resolution
* fix: remove legacy migration code and fix migration locking test
- Remove all legacy manual database migration code from database.ts
- Fix migration locking test to handle expected concurrent behavior
- All database changes now handled by proper migration system
* ci: trigger CI checks
* fix: correct main entry point path in package.json
The merge incorrectly changed the main field from "main/dist/main/src/index.js"
to "dist/main/src/index.js", causing electron-builder to fail during packaging.
This fixes the build configuration to point to the correct location where the
compiled main process file is actually created.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: add missing database columns for legacy compatibility
Added commit_mode columns to migration 001-core-tables.ts and created
migration 008-legacy-columns.ts to handle legacy database compatibility.
This fixes CI test failures by ensuring all expected columns exist:
- commit_mode, commit_structured_prompt_template, commit_checkpoint_prefix
- display_order for projects and sessions
- archived, is_main_repo for sessions
- created_at, updated_at timestamps
Properly handles SQLite constraints when adding columns to existing tables
by using separate ALTER TABLE and UPDATE statements instead of DEFAULT clauses.
All 4 CI database tests now pass.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: correct main entry point path in package.json
* fix: Update pnpm-lock.yaml to match merged package.json dependencies
- Sync lockfile with merged package.json after resolving conflicts
- Adds missing umzug and ts-node dependencies from db-migrations branch
- Updates better-sqlite3 from ^11.7.0 to ^12.2.0 to match main branch
- Fixes frozen-lockfile CI error
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Jordan Bentley <jordan@bentleyconsulting.ai>
Co-authored-by: Claude <noreply@anthropic.com>
* feat: Add git status indicators to session sidebar
- Add GitStatusIndicator component with visual status badges
- Show commit count, file changes, and branch status for each session
- Display states: clean, modified, ahead, behind, diverged, ready to merge
- Clickable indicators that switch to View Diff tab for detailed changes
- Real-time git status updates via IPC events
- Enhanced session list with at-a-glance project status
The git status feature provides immediate visual feedback about the state
of each worktree session, helping users understand what needs attention:
- Green: Synced with main or ready to merge
- Yellow: Active uncommitted changes
- Blue: Commits ahead of main
- Orange: Behind main branch
- Purple: Diverged from main
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix visual bug in git status
* fix: Remove 'planning' from ViewMode and keep 'dashboard' as per upstream
* checkpoint: > rimraf dist && tsc && npm run copy:assets && ...
* feat: Improve git status UX and reduce logging noise
- Add isUserInitiated flag to control loading spinners
- Only show spinners for manual refreshes and initial loads
- Hide spinners during automatic 60s polling to reduce distraction
- Improve git status label positioning and alignment
- Move git status labels before branch names for better scanning
- Use fixed-width containers (55px) for perfect alignment
- Center labels within containers for cleaner appearance
- Increase default sidebar width to 500px to accommodate labels
- Reduce logging noise in both dev and production
- Create GitStatusLogger for grouped backend logging
- Add console wrapper to filter verbose git logs
- Summarize poll cycles instead of logging each session
- Track error patterns and only log after threshold
- Fix TypeScript definitions
- Add missing onGitStatusLoading event type
This significantly improves the git status feature UX by making it less
intrusive while maintaining full functionality.
* feat: Improve git status UX and reduce logging noise
- Add visual git status indicator in session list items
- Implement git status monitoring with rate limiting (30s interval)
- Add proper cleanup for git status manager on session deletion
- Reduce console logging by wrapping non-essential logs
- Fix session deletion to properly handle git status cleanup
- Improve error handling in git operations
The git status is now shown as colored dots next to session names:
- Green: Clean (no changes)
- Yellow: Modified files
- Red: Error retrieving status
This provides better visibility into worktree states without
cluttering the logs with frequent status checks.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test: Add comprehensive test coverage for git status functionality
- Add unit tests for GitStatusManager service with 100% coverage
- Add Playwright E2E tests for git status UI indicators
- Improve test reliability by replacing hardcoded waits with proper conditions
- Extract common test setup into reusable helper functions
- Ensure proper cleanup with try-finally blocks for timer restoration
- Remove console.log statements from tests for cleaner output
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Add missing dashboard API to fix TypeScript build errors
- Add dashboard.getProjectStatus to preload script
- Add dashboard API wrapper in frontend API utils
- Update TypeScript definitions for electronAPI
- Fixes CI build failure due to missing API method
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Remove unused error variables to reduce linting warnings
- Remove unused error parameters in catch blocks
- Use catch without parameter when error is not used
- Reduces linting warnings from 43 to 40
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Remove duplicate GitStatusManager imports causing TypeScript errors
- Remove duplicate import statement in index.ts
- Remove duplicate variable declaration for gitStatusManager
- Fixes CI build failure due to TypeScript compilation errors
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* checkpoint: This PR adds a bunch of icons, can you add a gu...
* checkpoint: I meant hte modal with the heading "Status Indi...
* fix: Add auto-install-peers=false to .npmrc to match lockfile
- Fixes pnpm lockfile configuration mismatch in CI
- The lockfile expects autoInstallPeers to be false
- This was causing "ERR_PNPM_LOCKFILE_CONFIG_MISMATCH" in CI
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* checkpoint: I have created the following plan after thoroug...
* checkpoint: I'm not seeing the current worktree displayed u...
* checkpoint: 1. I still can't see it should look like this. ...
* refactor: Simplify version display and extract duplicated worktree utility
- Simplify version display by removing [NO-WT] debug marker in Sidebar
- Extract duplicated getCurrentWorktreeName function into shared utility module
- Update imports in main/src/index.ts and main/src/ipc/updater.ts
These changes improve code maintainability by following DRY principles and
cleaning up the UI display.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* checkpoint: I have created the following plan after thoroug...
* feat: Improve git status badge spacing and display
- Reduced badge width from 8.5ch to 5.5ch for more compact display
- Added star (★) indicator for counts above 9 to maintain single-digit width
- Improved spacing between badges by using gap-2 in session list
- Center icons when no count is displayed
- Updated legend component to match new badge styling
- Made icon and number positioning tighter with gap-0.5
- Consistent styling across all badge states including loading
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
Co-authored-by: Jordan Bentley <jordan@bentleyconsulting.ai>
* feat: implement multi-mode auto-commit system
Add comprehensive auto-commit functionality with three distinct modes:
- Claude creates conventional commits with proper messages
- Appends commit instructions to all user prompts
- Uses configurable prompt template for commit guidelines
- Supports Conventional Commits format (feat:, fix:, docs:, etc.)
- Automatically commits changes after each prompt completion
- Uses configurable commit message prefix (default: "checkpoint: ")
- Provides automatic backup of work progress
- Handles git errors gracefully with user feedback
- No automatic commits - fully manual control
- Preserves existing workflow for users who prefer manual commits
- Dropdown selector in session input area
- Visual indicators for each mode (colored badges)
- Settings dialog for advanced configuration
- Optimized positioning and z-index handling
- Per-project default configurations
- Custom prompt templates for structured mode
- Checkpoint prefix customization
- Project-specific recommendations based on detected tooling
- Mode selection in create session dialog
- Real-time mode switching during active sessions
- Visual status indicators in session headers
- `commit_mode` column in sessions/projects tables
- `commit_mode_settings` JSON column for configuration
- Migration from legacy `auto_commit` boolean field
- Enhanced ExecutionTracker for post-prompt processing
- CommitManager service for different commit strategies
- ProjectDetection service for intelligent mode recommendations
- Graceful degradation when git operations fail
- User-visible error messages in session output
- Automatic retry logic for transient failures
- TypeScript types for all commit mode interfaces
- Modular architecture for easy extension
- IPC-based communication between frontend/backend
Fixes build configuration issues and improves overall commit workflow UX.
* feat: implement multi-mode auto-commit system
Add comprehensive auto-commit functionality with three distinct modes:
## Features
### 1. Structured Mode
- Claude creates conventional commits with proper messages
- Appends commit instructions to all user prompts
- Uses configurable prompt template for commit guidelines
- Supports Conventional Commits format (feat:, fix:, docs:, etc.)
### 2. Checkpoint Mode
- Automatically commits changes after each prompt completion
- Uses configurable commit message prefix (default: "checkpoint: ")
- Provides automatic backup of work progress
- Handles git errors gracefully with user feedback
### 3. Disabled Mode
- No automatic commits - fully manual control
- Preserves existing workflow for users who prefer manual commits
## UI Components
### CommitModeToggle
- Dropdown selector in session input area
- Visual indicators for each mode (colored badges)
- Settings dialog for advanced configuration
- Optimized positioning and z-index handling
### CommitModeSettings
- Per-project default configurations
- Custom prompt templates for structured mode
- Checkpoint prefix customization
- Project-specific recommendations based on detected tooling
### Session Integration
- Mode selection in create session dialog
- Real-time mode switching during active sessions
- Visual status indicators in session headers
## Technical Implementation
### Database Schema
- `commit_mode` column in sessions/projects tables
- `commit_mode_settings` JSON column for configuration
- Migration from legacy `auto_commit` boolean field
### Execution Tracking
- Enhanced ExecutionTracker for post-prompt processing
- CommitManager service for different commit strategies
- ProjectDetection service for intelligent mode recommendations
### Error Handling
- Graceful degradation when git operations fail
- User-visible error messages in session output
- Automatic retry logic for transient failures
## Developer Experience
- TypeScript types for all commit mode interfaces
- Modular architecture for easy extension
- IPC-based communication between frontend/backend
Fixes build configuration issues and improves overall commit workflow UX.
* can you poll CI on the upstream to confirm all ...
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: include frontend and main build steps in CI scripts
The CI build scripts were missing the build:frontend and build:main
steps, causing electron-builder to fail because the main entry file
wasn't compiled. This fixes the CI build failure by ensuring the
main process is built before packaging.
Fixes the error: "Application entry file main/dist/main/src/index.js
does not exist" in CI builds.
---------
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
* feat: implement multi-mode auto-commit system
Add comprehensive auto-commit functionality with three distinct modes:
- Claude creates conventional commits with proper messages
- Appends commit instructions to all user prompts
- Uses configurable prompt template for commit guidelines
- Supports Conventional Commits format (feat:, fix:, docs:, etc.)
- Automatically commits changes after each prompt completion
- Uses configurable commit message prefix (default: "checkpoint: ")
- Provides automatic backup of work progress
- Handles git errors gracefully with user feedback
- No automatic commits - fully manual control
- Preserves existing workflow for users who prefer manual commits
- Dropdown selector in session input area
- Visual indicators for each mode (colored badges)
- Settings dialog for advanced configuration
- Optimized positioning and z-index handling
- Per-project default configurations
- Custom prompt templates for structured mode
- Checkpoint prefix customization
- Project-specific recommendations based on detected tooling
- Mode selection in create session dialog
- Real-time mode switching during active sessions
- Visual status indicators in session headers
- `commit_mode` column in sessions/projects tables
- `commit_mode_settings` JSON column for configuration
- Migration from legacy `auto_commit` boolean field
- Enhanced ExecutionTracker for post-prompt processing
- CommitManager service for different commit strategies
- ProjectDetection service for intelligent mode recommendations
- Graceful degradation when git operations fail
- User-visible error messages in session output
- Automatic retry logic for transient failures
- TypeScript types for all commit mode interfaces
- Modular architecture for easy extension
- IPC-based communication between frontend/backend
Fixes build configuration issues and improves overall commit workflow UX.
* feat: implement multi-mode auto-commit system
Add comprehensive auto-commit functionality with three distinct modes:
## Features
### 1. Structured Mode
- Claude creates conventional commits with proper messages
- Appends commit instructions to all user prompts
- Uses configurable prompt template for commit guidelines
- Supports Conventional Commits format (feat:, fix:, docs:, etc.)
### 2. Checkpoint Mode
- Automatically commits changes after each prompt completion
- Uses configurable commit message prefix (default: "checkpoint: ")
- Provides automatic backup of work progress
- Handles git errors gracefully with user feedback
### 3. Disabled Mode
- No automatic commits - fully manual control
- Preserves existing workflow for users who prefer manual commits
## UI Components
### CommitModeToggle
- Dropdown selector in session input area
- Visual indicators for each mode (colored badges)
- Settings dialog for advanced configuration
- Optimized positioning and z-index handling
### CommitModeSettings
- Per-project default configurations
- Custom prompt templates for structured mode
- Checkpoint prefix customization
- Project-specific recommendations based on detected tooling
### Session Integration
- Mode selection in create session dialog
- Real-time mode switching during active sessions
- Visual status indicators in session headers
## Technical Implementation
### Database Schema
- `commit_mode` column in sessions/projects tables
- `commit_mode_settings` JSON column for configuration
- Migration from legacy `auto_commit` boolean field
### Execution Tracking
- Enhanced ExecutionTracker for post-prompt processing
- CommitManager service for different commit strategies
- ProjectDetection service for intelligent mode recommendations
### Error Handling
- Graceful degradation when git operations fail
- User-visible error messages in session output
- Automatic retry logic for transient failures
## Developer Experience
- TypeScript types for all commit mode interfaces
- Modular architecture for easy extension
- IPC-based communication between frontend/backend
Fixes build configuration issues and improves overall commit workflow UX.
* can you poll CI on the upstream to confirm all ...
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: include frontend and main build steps in CI scripts
The CI build scripts were missing the build:frontend and build:main
steps, causing electron-builder to fail because the main entry file
wasn't compiled. This fixes the CI build failure by ensuring the
main process is built before packaging.
Fixes the error: "Application entry file main/dist/main/src/index.js
does not exist" in CI builds.
---------
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
* feat: Add Project Dashboard - replaces non-worktree session creation
## Summary
- Introduces a new Project Dashboard view that displays when clicking on a project in the sidebar
- Replaces the previous dialog for creating sessions without worktrees
- Provides comprehensive git status overview including multi-origin support
## Features
### Multi-Origin Git Status Display
- Visual cascade showing: upstream → origin/fork → local main → session branches
- Automatically detects and displays multiple remotes (upstream, origin)
- Color-coded status indicators for at-a-glance understanding
- Shows ahead/behind counts for each remote
### Session Management
- Comprehensive table showing all session branches with their status
- Quick filtering: All Sessions, Stale Only, With Changes, With PR
- Status summary cards showing up-to-date, stale, and sessions with changes
- Click any session to navigate directly to it
### Visual Improvements
- Full viewport utilization for better space usage
- Skeleton loading states when switching between projects
- Clear visual hierarchy with cards and proper spacing
- Status legend for understanding icons at a glance
### Fixes
- Project name now displays correctly in dashboard header
- Sessions table scrolls properly when many sessions exist
- Sidebar session navigation restored
- Loading states properly shown when switching projects
## Technical Details
- New IPC endpoint for fetching comprehensive project status
- Caching layer for dashboard data to improve performance
- Fetches from all remotes to show complete git status
- Responsive design that adapts to different screen sizes
This change fundamentally improves how users interact with projects by providing immediate visibility into the state of all sessions and remotes without needing to create a new session first.
* fix: Remove unused functions to fix typecheck errors
---------
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
- Add parent_folder_id column to folders table for hierarchical structure
- Implement folder nesting with drag-and-drop support
- Add circular reference detection and depth validation
- Update UI to display nested folder tree structure
- Add folder move functionality for reorganizing hierarchy
- Support up to 5 levels of nesting depth
- Maintain backward compatibility with existing flat folder structure
Closes#69
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
Co-authored-by: Jordan Bentley <jordan@bentleyconsulting.ai>
Implement comprehensive archive sessions feature allowing users to preserve
session history while cleaning up workspace and removing git worktrees.
Key Features:
- Archive sessions instead of permanent deletion
- Preserve conversation history and output in database
- Clean up git worktrees when archiving to free disk space
- Expandable archived sessions view in sidebar
- Clear UI messaging for archived session limitations
UI/UX Improvements:
- Replace "Delete" with "Archive" throughout interface
- Add expandable "Archived Sessions" section in project tree
- Show informative messages instead of blank terminals for archived sessions
- Hide inappropriate actions (run script, star/unstar) for archived sessions
- Remove non-functional restore capability
Technical Implementation:
- Add 'archived' boolean field to session database schema
- Implement archive checks across IPC handlers (git, file, script operations)
- Suppress expected error logging for archived session operations
- Add debounced toggle for archived sessions view
- Maintain session output and conversation history for archived sessions
- Prevent terminal, file operations, and git commands on archived sessions
Error Handling:
- Graceful handling of missing worktrees for archived sessions
- Clear user messaging instead of cryptic console errors
- Suppress expected ENOENT and terminal errors for archived sessions
This feature allows users to maintain a clean active workspace while
preserving important session history for future reference.
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>
Co-authored-by: Jordan Bentley <151466993+jordan-BAIC@users.noreply.github.com>
This refactors the Create Session dialog to reduce cognitive overload and improve the user experience:
- **Progressive disclosure**: Hide advanced options behind "More options" toggle, showing only essential fields by default
- **Compact model selector**: Replace verbose dropdown with visual 3-column grid featuring icons (Target/Brain/Zap)
- **Smart defaults**: Remember last used model per project, auto-commit enabled by default
- **Improved visual hierarchy**: Cleaner spacing, better field grouping, and clear primary/secondary actions
- **Session name visibility**: Move required session name field from advanced options to main area
- **Better branch selector**: Fix icon alignment for consistency with other form elements
- **Keyboard shortcuts**: Add Cmd/Ctrl+Enter support with visual hint in footer
- **Project context**: Show project name clearly in dialog title
The dialog now displays only 3 essential fields by default (prompt, model, session name) while maintaining access to all advanced features. This reduces time-to-create for the 80% use case while preserving power user functionality.
Technical changes:
- Add `lastUsedModel` field to projects table with database migration
- Update project types and IPC handlers to support model persistence
- Refactor CreateSessionDialog component with cleaner state management
Co-authored-by: Erick Shaffer <erick.shaffer@meraki.net>