# Offline Editing (https://yapl.app/en/docs/user-guides/plans/offline-editing)

# Working Offline

YAPL supports **full offline editing** for plans. Once you've loaded a plan while online, you can continue working on it even without internet connection. Your changes are automatically saved to your device and sync when you're back online.

## Quick Start

<Callout type="info">
**Preparing for offline work:**
1. Open the plan you'll need while online
2. Make a small change to create a local draft
3. You're ready to work offline!
</Callout>

## What Works Offline

### Full Functionality

These features work exactly the same offline:

| Feature | Description |
|---------|-------------|
| **Task editing** | Create, edit, delete, move tasks |
| **Gantt drag & drop** | Resize and reposition tasks on timeline |
| **Dependencies** | Draw, edit, and remove task connections |
| **Progress updates** | Drag progress bars to update completion |
| **Critical path** | Auto-calculation continues working |
| **Undo/Redo** | Full history with Ctrl+Z / Ctrl+Y |
| **Auto-save** | Changes save to your device every 500ms |
| **Calendar settings** | Adjust working days, hours, holidays |
| **Resource assignments** | Assign equipment and materials to tasks |
| **WBS structure** | Indent/outdent to reorganize tasks |
| **Baseline** | Set and clear baseline dates |

### Requires Internet

| Feature | Why |
|---------|-----|
| **First-time plan access** | Plan data must be downloaded initially |
| **Publishing drafts** | Saves to cloud database |
| **Creating new plans** | Server generates plan identifiers |
| **Loading published versions** | Fetches from cloud storage |
| **Real-time collaboration** | Requires live connection |
| **Team invitations** | Server-side operations |

## How It Works

### Automatic Draft Creation

When you edit a plan, YAPL automatically creates a local **draft** on your device:

1. **You make a change** - Any edit triggers draft creation
2. **Auto-save kicks in** - Changes save locally every 500ms
3. **Draft badge appears** - Version selector shows "Draft" indicator
4. **Work continues offline** - No network needed for editing

### Your Data Is Safe

YAPL uses multiple safeguards to protect your work:

- **Frequent auto-save** - Every 500ms after changes
- **Background save** - Saves when you switch browser tabs
- **Full snapshots** - Complete plan state saved, not just changes
- **Integrity checks** - Data verified on save and load
- **Safe version switching** - Pending changes saved before switching

<Callout type="success">
**Maximum data loss: 500 milliseconds of work.** Even if your device crashes or browser closes unexpectedly, you'll lose at most a half-second of edits.
</Callout>

## Working Offline Scenarios

### Scenario 1: Field Work Without Internet

**Before leaving:**
1. Open YAPL and navigate to your plan
2. Make a small edit (triggers draft creation)
3. Look for "Draft" indicator in version selector

**On the job site:**
- Edit tasks, update progress, adjust schedules
- Critical path calculations continue automatically
- All changes save to your device

**Back at the office:**
1. Connect to internet
2. Click **Publish** to save to cloud
3. Team members see your updates

### Scenario 2: Internet Drops Mid-Edit

**What happens:**
- You keep working normally
- Nothing appears different in the interface
- Changes continue saving locally
- Critical path keeps calculating

**When reconnected:**
- Just click **Publish** when ready
- No special recovery needed

### Scenario 3: Extended Offline Work

**Process:**
1. Prepare draft while online (open plan, make one edit)
2. Work offline for hours or days
3. Reconnect when convenient
4. Publish to sync with team

There's no time limit - offline drafts work indefinitely.

## Understanding Drafts

### Draft vs. Published

| Aspect | Draft | Published Version |
|--------|-------|-------------------|
| Location | Your device | Cloud database |
| Visibility | Only you | Team members |
| Editing | Full | Limited |
| Offline access | Yes | Requires download |
| Auto-save | Every 500ms | On publish |

### Finding Your Drafts

Drafts appear in the **Version Selector** dropdown with a "Draft" badge:

```
Version Selector
├── Current State (live)
├── v3 "Approved" (published)
├── v2 "Initial" (published)
└── v3 Draft 1 ← Your offline work
```

### Multiple Drafts

You can have multiple drafts for different versions:
- Each published version can have its own draft
- Drafts are independent and don't conflict
- Switch between drafts freely

## Critical Path Offline

The Critical Path Method (CPM) calculation works fully offline:

### How It Works

1. **Web Worker** - Calculations run in a background thread
2. **No Network Required** - All algorithms are bundled with the app
3. **Auto Calculation** - Updates after task changes (500ms delay)
4. **Manual Option** - "Recalculate" button available anytime

### CPM Modes

| Mode | Behavior | Use When |
|------|----------|----------|
| **Auto** | Recalculates after every change | Normal editing |
| **Single** | Calculate once when clicked | Large plans, performance |
| **Disabled** | No automatic calculation | Quick bulk edits |

Your CPM mode preference is saved with your draft.

## Installing YAPL (PWA)

For the best offline experience, install YAPL as an app:

### Desktop (Chrome/Edge)

1. Visit YAPL in Chrome
2. Click the install icon (⊕) in address bar
3. Click "Install YAPL"
4. App opens in its own window

### iOS (Safari)

1. Open YAPL in Safari
2. Tap Share button (□↗)
3. Tap "Add to Home Screen"
4. Tap "Add"

### Android (Chrome)

1. Open YAPL in Chrome
2. Tap menu (⋮)
3. Tap "Install app"
4. Follow prompts

### Benefits of Installation

| Feature | Browser Tab | Installed App |
|---------|-------------|---------------|
| Offline access | Limited | Full support |
| Storage space | Lower quota | Higher quota |
| Launch speed | Slower | Faster |
| Experience | Browser UI visible | Clean, app-like |

## Troubleshooting

### "Cannot load draft offline"

**Cause:** Draft was created before offline support (older version)

**Solution:**
1. Connect to internet
2. Open the plan
3. Make any small edit
4. A new draft with offline support is created

### "Draft not found"

**Cause:** Browser data was cleared, or different browser

**Solution:**
- Drafts are stored per browser/device
- Connect to internet and load the plan again
- Make a new edit to create fresh draft

### "Changes didn't publish"

**Cause:** Was offline when clicking Publish

**Solution:**
1. Check internet connection
2. Click Publish again
3. Wait for success confirmation

### Slow performance with large plans

**Tip:** Plans with 400+ tasks may feel slower offline

**Solutions:**
- Use CPM "Single" mode instead of "Auto"
- Close other browser tabs
- Install YAPL as PWA for better performance

## Best Practices

### Before Going Offline

1. **Prepare your drafts** - Open and edit each needed plan
2. **Verify draft creation** - Check for Draft badge
3. **Test offline** - Enable airplane mode briefly to confirm

### While Offline

1. **Work normally** - All editing features work
2. **Trust auto-save** - No need to manually save
3. **Use undo freely** - Full history available (Ctrl+Z)

### After Reconnecting

1. **Review changes** - Check your draft before publishing
2. **Publish promptly** - Don't leave drafts for too long
3. **Coordinate with team** - Let others know you're syncing

## Technical Details

### Storage

| Aspect | Detail |
|--------|--------|
| **Technology** | IndexedDB (browser database) |
| **Location** | Your device only |
| **Typical limit** | 50MB - 32GB (browser dependent) |
| **Data format** | Full snapshots, not incremental |

### Undo/Redo

| Aspect | Detail |
|--------|--------|
| **Stack size** | 50 operations maximum |
| **Persistence** | Saved with draft |
| **Per-draft** | Each draft has own history |

### Auto-Save Timing

| Event | Timing |
|-------|--------|
| After change | 500ms debounce |
| Tab loses focus | Immediate |
| Before version switch | Immediate flush |

## Related Topics

- [Plan Versions](/docs/user-guides/plans/plan-versions) - Version management
- [Publishing Plans](/docs/user-guides/plans/publishing-plans) - Syncing to cloud
- [Critical Path](/docs/user-guides/gantt/critical-path) - CPM details
- [Timeline View](/docs/user-guides/gantt/timeline-view) - Gantt editing