docs: add documentation and screenshots for session pins, server health, and schedule features, fix migration-runner version mismatch detection
No files matched your search
@@ -24,9 +24,28 @@ function ensureMigrationsTable(db: Database): void {
|
||||
`)
|
||||
}
|
||||
|
||||
function getAppliedVersions(db: Database): Set<number> {
|
||||
const rows = db.prepare('SELECT version FROM schema_migrations ORDER BY version').all() as MigrationRecord[]
|
||||
return new Set(rows.map(r => r.version))
|
||||
function getAppliedMigrations(db: Database): Map<number, string> {
|
||||
const rows = db.prepare('SELECT version, name FROM schema_migrations ORDER BY version').all() as MigrationRecord[]
|
||||
return new Map(rows.map(r => [r.version, r.name]))
|
||||
}
|
||||
|
||||
/**
|
||||
* Surfaces version-number collisions where a recorded migration's name differs
|
||||
* from the code migration registered under the same version. The runner keys on
|
||||
* version number alone, so a reused version silently skips the real migration
|
||||
* (e.g. an ADD COLUMN), producing later runtime errors that are hard to trace.
|
||||
* This converts that silent skip into a loud, actionable warning.
|
||||
*/
|
||||
function warnOnVersionNameMismatch(applied: Map<number, string>, migrations: Migration[]): void {
|
||||
for (const migration of migrations) {
|
||||
const recordedName = applied.get(migration.version)
|
||||
if (recordedName !== undefined && recordedName !== migration.name) {
|
||||
logger.warn(
|
||||
`Migration version ${migration.version} is recorded as "${recordedName}" but the code defines "${migration.name}". ` +
|
||||
`This migration was skipped; its schema changes may be missing. Verify the database schema and apply the changes manually if needed.`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function markApplied(db: Database, migration: Migration): void {
|
||||
@@ -37,7 +56,8 @@ function markApplied(db: Database, migration: Migration): void {
|
||||
export function migrate(db: Database, migrations: Migration[]): void {
|
||||
ensureMigrationsTable(db)
|
||||
|
||||
const applied = getAppliedVersions(db)
|
||||
const applied = getAppliedMigrations(db)
|
||||
warnOnVersionNameMismatch(applied, migrations)
|
||||
const sorted = [...migrations].sort((a, b) => a.version - b.version)
|
||||
const pending = sorted.filter(m => !applied.has(m.version))
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Database } from 'bun:sqlite'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { migrate, type Migration } from '../../src/db/migration-runner'
|
||||
import { logger } from '../../src/utils/logger'
|
||||
|
||||
function makeMigration(version: number, name: string, up: () => void): Migration {
|
||||
return { version, name, up, down: () => {} }
|
||||
}
|
||||
|
||||
describe('migrate - version/name mismatch guard', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('warns and skips when an applied version was recorded under a different name', () => {
|
||||
const db = new Database(':memory:')
|
||||
db.run('CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, name TEXT NOT NULL, applied_at INTEGER NOT NULL)')
|
||||
db.run("INSERT INTO schema_migrations (version, name, applied_at) VALUES (15, 'repos-add-name', 0)")
|
||||
|
||||
const warnSpy = vi.spyOn(logger, 'warn').mockImplementation(() => {})
|
||||
const up = vi.fn()
|
||||
|
||||
migrate(db, [makeMigration(15, 'schedule-worktree-isolation', up)])
|
||||
|
||||
expect(up).not.toHaveBeenCalled()
|
||||
expect(warnSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Migration version 15 is recorded as "repos-add-name" but the code defines "schedule-worktree-isolation"'),
|
||||
)
|
||||
})
|
||||
|
||||
it('does not warn when recorded names match', () => {
|
||||
const db = new Database(':memory:')
|
||||
db.run('CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, name TEXT NOT NULL, applied_at INTEGER NOT NULL)')
|
||||
db.run("INSERT INTO schema_migrations (version, name, applied_at) VALUES (15, 'schedule-worktree-isolation', 0)")
|
||||
|
||||
const warnSpy = vi.spyOn(logger, 'warn').mockImplementation(() => {})
|
||||
|
||||
migrate(db, [makeMigration(15, 'schedule-worktree-isolation', vi.fn())])
|
||||
|
||||
expect(warnSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('applies pending migrations and records them', () => {
|
||||
const db = new Database(':memory:')
|
||||
const up = vi.fn()
|
||||
|
||||
migrate(db, [makeMigration(1, 'base', up)])
|
||||
|
||||
expect(up).toHaveBeenCalledTimes(1)
|
||||
const row = db.prepare('SELECT version, name FROM schema_migrations WHERE version = 1').get() as { version: number; name: string }
|
||||
expect(row).toEqual({ version: 1, name: 'base' })
|
||||
})
|
||||
})
|
||||
@@ -44,6 +44,8 @@ You can switch models at any point during a session without losing context. The
|
||||
|
||||
Configure API keys or OAuth for AI providers.
|
||||
|
||||

|
||||
|
||||
### API Key Method
|
||||
|
||||
1. Go to **Settings > Providers**
|
||||
|
||||
@@ -40,6 +40,8 @@ When the assistant self-edits its agent definition (e.g., to refine behavior or
|
||||
3. A welcome prompt is automatically sent to orient the agent
|
||||
4. Subsequent visits resume the most recent session
|
||||
|
||||

|
||||
|
||||
No manual setup is required. The workspace directory and all managed files are created automatically.
|
||||
|
||||
## Session Views
|
||||
|
||||
@@ -19,6 +19,8 @@ Messages stream in real-time using Server-Sent Events (SSE):
|
||||
- No waiting for complete responses
|
||||
- Can interrupt generation if needed
|
||||
|
||||

|
||||
|
||||
## Model Selection
|
||||
|
||||
Click the **model name** in the chat prompt area to open the quick model switcher. From there you can:
|
||||
@@ -142,6 +144,8 @@ Access your sessions from the sidebar:
|
||||
- Most recent sessions appear first
|
||||
- Click a session to resume
|
||||
|
||||

|
||||
|
||||
### Searching Sessions
|
||||
|
||||
Find sessions by content:
|
||||
@@ -150,6 +154,16 @@ Find sessions by content:
|
||||
2. Type your search query
|
||||
3. Results show sessions with matching content
|
||||
|
||||
### Pinning Sessions
|
||||
|
||||
Pin important sessions to the top of your session list:
|
||||
|
||||
1. Open the session actions menu (three dots on the session card)
|
||||
2. Select **Pin to top**
|
||||
3. The session moves to a **Pinned** section above the **Recent** section
|
||||
|
||||
Pinned sessions stay at the top regardless of age or activity. Unpin anytime from the same menu. See [Session Pinning](session-pins.md) for details.
|
||||
|
||||
### Deleting Sessions
|
||||
|
||||
Remove sessions you no longer need:
|
||||
|
||||
@@ -13,6 +13,8 @@ The file browser displays your repository as an expandable tree:
|
||||
- Icons indicate file types
|
||||
- Modified files are highlighted
|
||||
|
||||

|
||||
|
||||
### Breadcrumbs
|
||||
|
||||
Navigate quickly using the breadcrumb path at the top:
|
||||
|
||||
@@ -16,11 +16,13 @@ MCP (Model Context Protocol) allows AI models to interact with external tools an
|
||||
|
||||
Local servers run as processes on your machine:
|
||||
|
||||
1. Go to **Settings > MCP Servers**
|
||||
1. Open a repository and click **MCP** in the sidebar
|
||||
2. Click **Add Server**
|
||||
3. Select **Local**
|
||||
4. Configure:
|
||||
|
||||

|
||||
|
||||
```json
|
||||
{
|
||||
"name": "filesystem",
|
||||
|
||||
@@ -11,6 +11,8 @@ The UI is optimized for mobile devices:
|
||||
- Adaptive components
|
||||
- Gesture support
|
||||
|
||||

|
||||
|
||||
## Installing as PWA
|
||||
|
||||
### iOS
|
||||
|
||||
@@ -47,6 +47,8 @@ Apple's Push Notification Service (APNs) has strict requirements:
|
||||
|
||||
### 1. Generate VAPID Keys
|
||||
|
||||

|
||||
|
||||
Generate VAPID public/private key pair:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -30,6 +30,7 @@ OpenCode Manager provides a comprehensive web interface for managing OpenCode AI
|
||||
- **File Mentions** - Reference files with `@filename` autocomplete
|
||||
- **Plan/Build Modes** - Toggle between read-only and file-change modes
|
||||
- **Per-Agent Model Selection** — Each agent retains its own model selection independently
|
||||
- **Session Pinning** — Pin important sessions to a dedicated section at the top of the session list
|
||||
- **Mermaid Diagrams** - Visual diagram rendering in chat
|
||||
|
||||
[Learn more →](chat.md)
|
||||
@@ -103,3 +104,12 @@ OpenCode Manager provides a comprehensive web interface for managing OpenCode AI
|
||||
- **Session Continuity** — Navigating to the assistant always resumes the most recent session or creates one automatically
|
||||
|
||||
[Learn more →](assistant-mode.md)
|
||||
|
||||
### OpenCode Server Health
|
||||
|
||||
- **Live Status** — Server health indicator in Settings (Healthy/Unhealthy/Starting)
|
||||
- **Graceful Restart** — Active sessions are aborted and resumed with `continue` after restart
|
||||
- **Auto-Recovery** — Configurable health monitoring with automatic recovery on failure
|
||||
- **Version Management** — View current versions and trigger OpenCode upgrades from the UI
|
||||
|
||||
[Learn more →](server-health.md)
|
||||
@@ -67,6 +67,65 @@ Schedules can run with:
|
||||
|
||||
If a requested model is no longer available, OpenCode Manager falls back to a valid configured model for that provider so the run can still start when possible.
|
||||
|
||||
## Skills
|
||||
|
||||
Each schedule can optionally attach skill slugs and notes. Skills modify the agent's behavior during the run — for example, you could attach a review-focused skill to a weekly code review schedule.
|
||||
|
||||

|
||||
|
||||
The **Skills** tab in the schedule dialog lets you:
|
||||
|
||||
- Select one or more **skill slugs** from a multi-select input
|
||||
- Add free-form **notes** (max 2000 characters) that the agent receives as additional context
|
||||
|
||||
Skill metadata is passed to the OpenCode workspace config when the run starts, making the selected skills available to the agent for that run only.
|
||||
|
||||
## Worktree Isolation
|
||||
|
||||
Each scheduled run executes in a **throwaway git worktree** — an isolated working copy branched off the repository's base branch. This provides two key guarantees:
|
||||
|
||||
- **No side effects on the main working tree** — file changes, branch switches, and experimentations during the run are confined to the worktree.
|
||||
- **Clean state per run** — every run starts from a fresh branch (`schedule/{jobId}/run-{runId}`) based off the latest remote state.
|
||||
|
||||
When the run completes or fails, the worktree is cleaned up automatically. The worktree is **never auto-pushed** — any changes an agent makes during a scheduled run stay local and are discarded after the run finishes. The real safety boundary is this disposal: modifications affect only the throwaway worktree and are not propagated back to the repository.
|
||||
|
||||
### Branch Configuration
|
||||
|
||||
By default, runs branch off the repository's default branch. You can override this by specifying a **base branch** in the schedule settings — the worktree branches off your chosen branch instead.
|
||||
|
||||

|
||||
|
||||
## Permission Configuration
|
||||
|
||||
Every schedule includes a **Permissions** section in the General tab. These settings control what the agent can access and execute during unattended runs.
|
||||
|
||||

|
||||
|
||||
### Allow Access Outside the Working Directory
|
||||
|
||||
When **disabled** (the default), the agent's file operations are confined to the isolated worktree. Enable this if the schedule requires reading or writing files elsewhere on the system (e.g., accessing a shared configuration directory).
|
||||
|
||||
### Blocked Bash Commands
|
||||
|
||||
The following bash command patterns are always blocked by default:
|
||||
|
||||
```
|
||||
git push --force*
|
||||
git push -f *
|
||||
sudo *
|
||||
dd *
|
||||
mkfs*
|
||||
shutdown*
|
||||
reboot*
|
||||
halt*
|
||||
kill -9 *
|
||||
killall *
|
||||
```
|
||||
|
||||
These patterns prevent dangerous commands whose blast radius escapes the throwaway worktree. File-mutating commands (`rm -rf`, `git reset --hard`, etc.) are intentionally omitted because they only affect the disposable worktree.
|
||||
|
||||
You can customize the deny list by adding or removing glob patterns. One pattern per line. Changes apply to all future runs of that schedule.
|
||||
|
||||
## Run History
|
||||
|
||||
Each schedule stores a run history panel with:
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# OpenCode Server Health & Restart
|
||||
|
||||
Monitor the managed OpenCode server's status and control restarts and upgrades from the Settings UI.
|
||||
|
||||
## Overview
|
||||
|
||||
OpenCode Manager runs a supervised OpenCode server process to handle agent sessions. The **OpenCode** tab in Settings shows the server's current status, version information, and provides controls for restarting or upgrading the server without bringing down the Manager itself.
|
||||
|
||||

|
||||
|
||||
## Server Status
|
||||
|
||||
| Indicator | Meaning |
|
||||
|-----------|---------|
|
||||
| **Healthy** | The OpenCode server is running and responding to health checks |
|
||||
| **Unhealthy** | The server is not responding. The Manager will attempt automatic recovery. |
|
||||
| **Starting** | The server is being initialized after a restart or Manager startup |
|
||||
|
||||
The panel also displays:
|
||||
|
||||
- **OpenCode version** — The installed version of the OpenCode server (e.g., `v1.17.11`)
|
||||
- **Manager version** — The current OpenCode Manager version (e.g., `v0.14.5`)
|
||||
|
||||
## Health Monitoring
|
||||
|
||||
The Manager periodically polls the OpenCode server's health endpoint. If the server becomes unresponsive:
|
||||
|
||||
1. The Manager logs the failure and increments a failure counter
|
||||
2. After a configurable number of consecutive failures (default: 2), automatic recovery begins
|
||||
3. Recovery restarts the OpenCode server process
|
||||
4. In-flight sessions are aborted and resumed once the server is healthy again
|
||||
|
||||
### Configuration
|
||||
|
||||
Health monitoring is configured through environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `OPENCODE_HEALTH_WATCH_ENABLED` | `true` | Enable health watcher and recovery (`false` in tests) |
|
||||
| `OPENCODE_HEALTH_POLL_MS` | `30000` | Poll interval in milliseconds |
|
||||
| `OPENCODE_HEALTH_FAILURE_THRESHOLD` | `2` | Failed checks before recovery starts |
|
||||
|
||||
## Restart with Session Resume
|
||||
|
||||
When you restart the OpenCode server (manually or through an upgrade), active sessions are handled gracefully:
|
||||
|
||||
1. **Capture** — The Manager captures all active user sessions (excluding subagent and scheduled-run sessions)
|
||||
2. **Abort** — Active sessions are aborted cleanly on the running server
|
||||
3. **Restart** — The OpenCode server process is stopped and started fresh
|
||||
4. **Resume** — Once healthy, a `continue` prompt is automatically sent to each previously active session
|
||||
|
||||
### Confirmation
|
||||
|
||||
If there are active sessions when you click **Restart**, a confirmation dialog shows how many sessions will be interrupted. You can proceed or cancel.
|
||||
|
||||
## Upgrading OpenCode
|
||||
|
||||
Click **Update** to check for and install the latest OpenCode version. The process:
|
||||
|
||||
1. Checks the currently installed version against the latest available release
|
||||
2. Downloads and installs the update if available
|
||||
3. Restarts the server using the same session-resume flow described above
|
||||
4. The new version is displayed in the status panel after restart
|
||||
|
||||
If the upgrade fails but the server recovers to a usable state, a recovery notice is shown with the fallback version.
|
||||
|
||||
## Manual Restart Triggers
|
||||
|
||||
Besides the explicit **Restart** button, the server is automatically restarted when:
|
||||
|
||||
- **OpenCode configuration is saved** — Changes to models, agents, commands, or MCP servers that require a server restart
|
||||
- **Assistant workspace is reloaded** — Via the `POST /assistant/reload` internal API endpoint
|
||||
- **Config import completes** — Importing a standalone OpenCode config into the workspace
|
||||
- **Version upgrade** — After installing a new OpenCode version
|
||||
|
||||
Configuration changes that only affect non-process settings (e.g., environment variable passthrough, AGENTS.md) use a non-disruptive config reload instead, which does not interrupt active sessions.
|
||||
@@ -0,0 +1,41 @@
|
||||
# Session Pinning
|
||||
|
||||
Pin important sessions to the top of your session list so you can find them quickly without searching.
|
||||
|
||||
## Overview
|
||||
|
||||
Session pinning lets you mark any session as "pinned" — it moves to a dedicated **Pinned** section above your **Recent** sessions, regardless of how old it is. This is useful for:
|
||||
|
||||
- Active feature branches you switch between throughout the day
|
||||
- Long-running investigations or debugging sessions
|
||||
- Sessions with important context you want to keep accessible
|
||||
|
||||
## Pinning a Session
|
||||
|
||||
Each session card has an actions menu (three dots or swipe gesture); the first entry toggles pinning:
|
||||
|
||||

|
||||
|
||||
The pinned session appears in a **Pinned** section above the **Recent** section. Unpinned sessions stay in **Recent** sorted by last activity.
|
||||
|
||||

|
||||
|
||||
Pin state persists across page reloads and browser sessions. Pinned sessions remain at the top until you unpin them.
|
||||
|
||||
## Managing Pins
|
||||
|
||||
| Action | How |
|
||||
|--------|-----|
|
||||
| **Pin a session** | Open the session actions menu and select **Pin to top** |
|
||||
| **Unpin a session** | Open the session actions menu and select **Unpin** — it moves back to the Recent section |
|
||||
| **Bulk operations** | Pin/unpin is per-session. Bulk delete and other management tools work as normal on pinned sessions |
|
||||
|
||||
## What Happens When a Pinned Session is Deleted
|
||||
|
||||
If a pinned session is deleted (manually or by context cleanup), it is removed from the Pinned section automatically. No stale pin entries remain.
|
||||
|
||||
## Notes
|
||||
|
||||
- Pinning is independent of session activity — a pinned session stays pinned even when new sessions push older ones out of the Recent view.
|
||||
- The Pinned section supports any number of pinned sessions.
|
||||
- Pinning is per-user and stored server-side, so it follows you across devices.
|
||||
@@ -40,7 +40,9 @@ Skill names must match the pattern `^[a-z0-9]+(-[a-z0-9]+)*$`:
|
||||
|
||||
## Managing Skills
|
||||
|
||||
Skills are managed through the Settings UI under the Skills section, or via the API.
|
||||
Skills are managed per-repository through the Skills panel in the sidebar, or via the API.
|
||||
|
||||

|
||||
|
||||
### API Endpoints
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ Dictate messages to AI agents using voice input.
|
||||
|
||||
OpenCode Manager supports two STT providers:
|
||||
|
||||

|
||||
|
||||
1. **Built-in Browser** - Uses your browser's Web Speech API
|
||||
2. **External API** - OpenAI-compatible STT endpoints (Whisper)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ Listen to AI responses with built-in or external TTS.
|
||||
|
||||
OpenCode Manager supports two TTS providers:
|
||||
|
||||

|
||||
|
||||
1. **Built-in Browser** - Uses your browser's Web Speech API
|
||||
2. **External API** - OpenAI-compatible TTS endpoints
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 187 KiB |
|
After Width: | Height: | Size: 193 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 175 KiB |
|
After Width: | Height: | Size: 159 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 164 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 87 KiB |
@@ -46,8 +46,10 @@ OpenCode Manager runs as a pnpm workspace:
|
||||
- **Chat & Sessions** — Real-time SSE streaming, slash commands, `@file` mentions, Plan/Build modes, Mermaid diagrams — [Learn more](features/chat.md)
|
||||
- **Files** — Directory browser with tree view, syntax highlighting, create/rename/delete, ZIP download — [Learn more](features/files.md)
|
||||
- **Schedules** — Recurring repo jobs with reusable prompts, run history, linked sessions — [Learn more](features/schedules.md)
|
||||
- **Session Pinning** — Pin important sessions to the top of the session list — [Learn more](features/session-pins.md)
|
||||
- **Assistant Mode** — Dedicated AI workspace with auto-provisioned skills for schedule management, notifications, settings, and repo listing — [Learn more](features/assistant-mode.md)
|
||||
- **AI Configuration** — Model/provider setup, OAuth for Anthropic/GitHub Copilot, custom agents — [Learn more](features/ai-config.md)
|
||||
- **Server Health & Restart** — Monitor server status, graceful restarts with session resume, auto-recovery — [Learn more](features/server-health.md)
|
||||
- **MCP Servers** — Add local or remote MCP servers with OAuth support — [Learn more](features/mcp.md)
|
||||
- **Skills** — Skill support for extended agent capabilities — [Learn more](features/skills.md)
|
||||
- **Mobile & PWA** — Responsive UI, installable on any device, iOS-optimized — [Learn more](features/mobile.md)
|
||||
|
||||
@@ -31,6 +31,7 @@ nav:
|
||||
- Repository & Git: features/git.md
|
||||
- File Browser: features/files.md
|
||||
- Chat & Sessions: features/chat.md
|
||||
- Session Pinning: features/session-pins.md
|
||||
- Schedules & Recurring Jobs: features/schedules.md
|
||||
- AI Configuration: features/ai-config.md
|
||||
- Skills: features/skills.md
|
||||
@@ -41,6 +42,7 @@ nav:
|
||||
- Text-to-Speech: features/tts.md
|
||||
- Speech-to-Text: features/stt.md
|
||||
- Push Notifications: features/notifications.md
|
||||
- OpenCode Server Health: features/server-health.md
|
||||
- Mobile & PWA: features/mobile.md
|
||||
- Configuration:
|
||||
- Environment Variables: configuration/environment.md
|
||||
|
||||