# Epic Branch Merge Plan

## Current Situation Analysis

### Branch Status

**Main Branch HEAD:** `2cb5418` - "prd updates"

**Epic Branches to Merge:**

1. **epic/demo-experience-ui**
   - HEAD: `13659da` (same as origin/main!)
   - Status: **ALREADY MERGED** - This branch is actually BEHIND main
   - No unique commits to merge

2. **epic/slidev-control-mvp**
   - HEAD: `90151a6`
   - Status: **NEEDS MERGING** - Has 16 commits ahead of main
   - Contains all Slidev implementation work

### Key Insight: Demo-Experience-UI is Already Merged!

Looking at the git graph, `epic/demo-experience-ui` (commit `13659da`) is actually IN the main branch history. The current `main` HEAD (`2cb5418`) is a descendant of `13659da`.

**This means:**
- demo-experience-ui work is already in main
- Only slidev-control-mvp needs to be merged

---

## Merge Plan

### Option 1: Direct Merge (Recommended)

Since demo-experience-ui is already merged, you only need to merge slidev-control-mvp:

```bash
# 1. Switch to main
git checkout main

# 2. Merge slidev-control-mvp
git merge epic/slidev-control-mvp -m "Merge epic: Slidev Control MVP with GitHub Pages hosting

Implements Slidev presentation generation and control:
- GitHub Pages hosting (zero cost)
- Dynamic deck generation via API
- Supabase Realtime control
- GitHub Actions auto-deployment
- Template processing system

Tasks completed: #94-#103
Issues: https://github.com/BuzzTrail/video-extension/issues/93"

# 3. Push to main
git push origin main
```

**Expected Result:**
- Fast-forward or clean merge (very likely)
- All 16 slidev commits added to main
- No merge conflicts expected (new code in new directories)

---

### Option 2: Squash Merge (Alternative)

If you want a cleaner history:

```bash
# 1. Switch to main
git checkout main

# 2. Squash merge
git merge --squash epic/slidev-control-mvp

# 3. Create single commit
git commit -m "Implement Slidev Control MVP (#93)

Complete implementation of Slidev presentation system:

Features:
- Generate Slidev decks from templates
- Push to buzztrail-presentations GitHub repo
- GitHub Actions builds and deploys to Pages
- Control slides via Supabase Realtime
- Zero hosting costs (GitHub Pages)

Architecture:
- libs/slidev: Core generation and publishing logic
- apps/motia-api: REST API endpoints
- apps/slidev-templates: Template storage
- GitHub Actions: Auto-build and deploy

Components:
- Deck generation with placeholder replacement
- GitHub publisher using Octokit
- Control API with rate limiting
- Supabase integration for metadata

Tasks: #94, #95, #96, #97, #98, #99, #100, #101, #102, #103
Epic: https://github.com/BuzzTrail/video-extension/issues/93"

# 4. Push to main
git push origin main
```

**Expected Result:**
- Single commit with all changes
- Cleaner history
- Easier to revert if needed

---

## Pre-Merge Checklist

Before merging, verify:

- ✅ All tests pass: `pnpm nx run-many -t test`
- ✅ Linting passes: `pnpm nx run-many -t lint`
- ✅ Build works: `pnpm nx run-many -t build`
- ✅ Manual testing: Test deck generation (we already did this!)
- ✅ Documentation: All docs are complete
- ✅ Epic branch pushed: `git push origin epic/slidev-control-mvp`

---

## Post-Merge Steps

### 1. Clean Up Epic Branch (Optional)

After successful merge:

```bash
# Delete local worktree
git worktree remove /Users/lars/mycode/buzztrail/epic-slidev-control-mvp

# Delete local branch
git branch -d epic/slidev-control-mvp

# Delete remote branch (if you want)
git push origin --delete epic/slidev-control-mvp
```

### 2. Update Demo-Experience-UI Worktree

```bash
# The demo-experience-ui worktree is outdated (behind main)
cd /Users/lars/mycode/buzztrail/epic-demo-experience-ui

# Update to latest main
git fetch origin
git merge origin/main

# Or delete the worktree if not needed
cd ..
git worktree remove /Users/lars/mycode/buzztrail/epic-demo-experience-ui
git branch -d epic/demo-experience-ui
```

### 3. Deploy to Railway

After merge to main, deploy the updated code:

```bash
# Option A: Railway auto-deploys from main (if configured)
# Just push to main and Railway will deploy

# Option B: Manual Railway deployment
cd /Users/lars/mycode/buzztrail/extension
railway link  # Link to your motia-api service
railway up  # Deploy latest main branch
```

---

## Detailed Commit Analysis

### Slidev-Control-MVP Branch (16 commits to merge)

All commits are clean, well-documented, and ready to merge:

1. `4f81bb4` - Issue #97: Supabase schema
2. `7378c21` - Issue #94: Slidev template library
3. `9e742dd` - Issue #96: Slide server NX app
4. `1a868c3` - Issue #95: Deck ID and template utilities
5. `b93b71a` - Issue #95: Build orchestration
6. `c5f6f90` - Issue #95: Supabase integration
7. `b02182d` - Issue #96: ASSETS_PATH fix
8. `25a429b` - Issue #98: Core API route (Stream A)
9. `782a6d5` - Issue #98: Rate limiting and docs (Stream B)
10. `e22166e` - Issue #99: HMAC auth (later removed)
11. `308ca8f` - Issue #99: Control validation
12. `cdf7c90` - Issue #99: Control API endpoint
13. `028cf28` - Issue #100: Railway config (later removed)
14. `4329b02` - Issue #100: Production build config (later removed)
15. `487f9c6` - Issue #100: Remove slide-server and Railway config
16. `90151a6` - Issue #100: GitHub Pages implementation

**Note:** Some commits add code that later commits remove (slide-server, Railway config). This is fine - it shows the evolution and pivot to GitHub Pages.

---

## Conflict Resolution Strategy

**Expected Conflicts:** NONE

**Reasoning:**
- Slidev code is in new directories (`libs/slidev`, `apps/motia-api`, `apps/slidev-templates`)
- Main branch doesn't have these directories
- No overlapping file modifications
- Both branches share common ancestor (`13659da`)

**If conflicts occur:**
1. Accept incoming changes (from slidev-control-mvp)
2. Or manually resolve - but unlikely needed

---

## Rollback Plan

If something goes wrong after merge:

```bash
# Option 1: Revert the merge commit
git revert -m 1 <merge-commit-sha>
git push origin main

# Option 2: Hard reset (DANGEROUS - only if not pushed)
git reset --hard HEAD~1

# Option 3: Create revert commit
git checkout <commit-before-merge>
git checkout -b revert-slidev
# Make a PR to main with the reverted state
```

---

## Recommended Approach

**I recommend Option 1 (Direct Merge)** because:

1. ✅ Preserves full commit history
2. ✅ Shows the evolution and pivot to GitHub Pages
3. ✅ Each commit is well-documented
4. ✅ Easy to bisect if issues arise
5. ✅ Standard practice for feature branches
6. ✅ No loss of context

**Avoid Option 2 (Squash Merge)** unless:
- You want a very clean main branch history
- You don't care about individual commit details
- You want easier revert capability

---

## Timeline

**Estimated Time:** 5-10 minutes

1. Pre-merge verification: 2 min
2. Merge execution: 1 min
3. Push to main: 1 min
4. Verify on GitHub: 1 min
5. Deploy to Railway: 5 min (if manual)

---

## Summary

### What's Happening:
- **epic/demo-experience-ui**: Already merged, no action needed
- **epic/slidev-control-mvp**: Needs merge to main

### What to Do:
```bash
git checkout main
git merge epic/slidev-control-mvp
git push origin main
```

### What You Get:
- Complete Slidev implementation in main
- GitHub Pages hosting working
- Ready for Railway deployment
- Clean, tested, documented code

**Ready to proceed?**
