Skip to content
5 changes: 5 additions & 0 deletions .changeset/cool-students-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Add dev container persistence for threads and settings
87 changes: 87 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Kilo Code Development Container

This development container provides a standardized environment for developing Kilo Code.

## Persistence

Kilo Code stores thread conversations, settings, and caches in the following locations:

- **Threads/Conversations**: `~/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/`
- **Settings**: `~/.vscode-remote/data/User/settings/`
- **Cache**: `~/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/cache/`
- **Vector Store**: `~/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/vector/`

### Volume Mounts

The dev container is configured with named volumes to persist this data across container rebuilds:

| Volume | Target | Purpose |
| ------------------------- | ----------------------------------------------------------------- | ---------------------------- |
| `kilocode-global-storage` | `/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code` | Threads, cache, vector store |
| `kilocode-settings` | `/root/.vscode-remote/data/User/settings` | VS Code settings |

### Preserving Threads Across Rebuilds

When you rebuild the dev container, these volumes persist your data:

1. **Before rebuilding**: Your threads are automatically preserved in the named volumes
2. **After rebuilding**: Threads restore automatically when you reopen the container
3. **If threads disappear**: Check that the volumes are still attached

### Troubleshooting Thread Recovery

If threads don't appear after a container rebuild:

1. **Verify volumes exist**:

```bash
docker volume ls | grep kilocode
```

2. **Inspect volume contents**:

```bash
docker volume inspect kilocode-global-storage
```

3. **Reattach volumes**: If volumes were detached, rebuild with:

```bash
devcontainer rebuild
```

4. **Manual recovery**: If volumes are lost, threads cannot be recovered. Start new conversations and consider backing up important threads.

### Backing Up Threads

To back up your threads:

1. Copy the global storage directory:

```bash
cp -r ~/.vscode-remote/data/User/globalStorage/kilocode.kilo-code ~/kilocode-backup
```

2. Store the backup outside the dev container environment.

### Custom Storage Path

If you need threads stored in a different location, configure a custom storage path in VS Code settings:

1. Open VS Code settings (`Ctrl+,` or `Cmd+,`)
2. Search for "Kilo Code: Custom Storage Path"
3. Enter an absolute path that's mounted into the container

Example `devcontainer.json` mount for custom path:

```json
"mounts": [
{
"source": "/path/on/host/kilocode-data",
"target": "/home/vscode/kilocode-data",
"type": "bind"
}
]
```

Then set the custom storage path to `/home/vscode/kilocode-data`.
12 changes: 11 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,15 @@
"remoteUser": "root",
"containerUser": "root",

"mounts": ["source=${localWorkspaceFolder}/.git,target=/workspace/.git,type=bind,consistency=cached"]
// Mounts for persisting Kilo Code state across container rebuilds
// These mounts preserve threads, settings, and caches
"mounts": [
"source=${localWorkspaceFolder}/.git,target=/workspace/.git,type=bind,consistency=cached",
"source=kilocode-global-storage,target=/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code,type=volume",
"source=kilocode-settings,target=/root/.vscode-remote/data/User,type=volume"
],

// Configure custom properties for workspace storage
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"workspaceFolder": "/workspace"
}
107 changes: 107 additions & 0 deletions apps/kilocode-docs/docs/getting-started/devcontainer-persistence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Dev Container Persistence
description: How to preserve Kilo Code threads and settings in dev containers
---

# Dev Container Persistence

When using Kilo Code in development containers (VS Code Dev Containers, GitHub Codespaces, etc.), your threads and settings can persist across container rebuilds by properly configuring volume mounts.

## Why Persistence Matters

Dev containers are ephemeral by default - when you rebuild the container, all data is lost unless explicitly persisted. Kilo Code stores important data including:

- **Conversation threads**: Your ongoing discussions with Kilo Code
- **Settings**: API configurations, custom modes, and preferences
- **Cache**: Vector store for code indexing and browser tool data

## Required Configuration

The Kilo Code dev container is pre-configured with named volumes to preserve your data. If you're setting up your own dev container, add these mounts to your `devcontainer.json`:

```json
{
"name": "Your Project",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"mounts": [
{
"source": "kilocode-global-storage",
"target": "/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code",
"type": "volume"
},
{
"source": "kilocode-settings",
"target": "/root/.vscode-remote/data/User/settings",
"type": "volume"
}
]
}
```

## Storage Locations

| Data Type | Container Path |
| ------------ | ------------------------------------------------------------------------- |
| Threads | `/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/tasks/` |
| Settings | `/root/.vscode-remote/data/User/settings/` |
| Cache | `/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/cache/` |
| Vector Store | `/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code/vector/` |

## Troubleshooting

### Threads Don't Appear After Rebuild

1. **Check volume attachment**: Ensure the dev container has the volumes attached
2. **Verify volume contents**: Check that the volume contains your data
3. **Rebuild with volumes**: Use `devcontainer rebuild` instead of `devcontainer up --rebuild`

### Volumes Lost

If named volumes are accidentally deleted:

1. Threads cannot be automatically recovered
2. Start new conversations with Kilo Code
3. Consider implementing a backup strategy for important threads

### Manual Backup

To manually back up your threads:

```bash
# Copy thread data from the container
docker cp <container-name>:/root/.vscode-remote/data/User/globalStorage/kilocode.kilo-code ./kilocode-backup
```

## Custom Storage Path

For advanced configurations, you can specify a custom storage path:

1. Add a bind mount to your `devcontainer.json`:

```json
"mounts": [
{
"source": "${localWorkspaceFolder}/.kilocode-data",
"target": "/home/vscode/kilocode-data",
"type": "bind"
}
]
```

2. Set the custom storage path in VS Code settings:
- Open Settings (`Ctrl+,` or `Cmd+,`)
- Search for "Kilo Code: Custom Storage Path"
- Enter: `/home/vscode/kilocode-data`

## Best Practices

1. **Use named volumes** for automatic persistence
2. **Back up important threads** before major container changes
3. **Avoid deleting volumes** during cleanup
4. **Test persistence** by rebuilding and verifying threads remain

## GitHub Codespaces

GitHub Codespaces automatically persists your VS Code settings and extensions. For Kilo Code threads, the pre-configured dev container includes the necessary volume mounts.

If using a custom Codespace configuration, ensure the mounts from the Required Configuration section are included.
Loading