Cross-platform maintenance & repair tool for the Open Code desktop app. Fixes stuck sessions, workspace issues, cache bloat, log accumulation, orphaned data — and resets to factory-fresh state.
Unofficial community tool. Not affiliated with or endorsed by the Open Code authors. It only touches app data (database, caches, local state), never the app binaries. Use at your own risk; automatic backups are taken before any destructive action.
- "Delete does nothing" / deleted sessions keep coming back. The app's renderer keeps stale copies in its HTTP cache and Local Storage and restores them as ghosts.
fix/clear-ui-stateclears it. - A workspace is stuck or half-deleted. If data was removed outside the app, database rows become orphans.
doctorflags them;fixprunes them. - You want a clean slate.
factory-resetwipes all app data so the next launch behaves like a first run. - Leftover data after uninstall.
backup,restore,list-backupsandfactory-resetwork even when the app itself is no longer installed.
| Platform | Requirement |
|---|---|
| Windows | PowerShell 5.1+ or Node.js 22+ |
| macOS | Node.js 22+ |
| Linux | Node.js 22+ |
No Python or other runtime needed. The database helper uses Node's built-in node:sqlite module (Node 22+).
npm install -g open-code-repair
# or from source:
npm install -g .Download the repo as ZIP and extract, or:
git clone https://github.com/dkhproject/open-code-repair.git
cd open-code-repairUse OpenCodeRepair.ps1 directly on Windows:
.\OpenCodeRepair.ps1 doctorIf scripts are blocked, use the .cmd launcher or:
powershell -NoProfile -ExecutionPolicy Bypass -File .\OpenCodeRepair.ps1 doctoroc-repair doctor # diagnose (read-only, safe)
oc-repair fix # repair detected problems
oc-repair factory-reset # wipe all app data, start fresh# Double-click OpenCodeRepair.cmd for menu
.\OpenCodeRepair.ps1 doctor
.\OpenCodeRepair.ps1 fix| Command | What it does |
|---|---|
doctor |
Read-only diagnosis: DB integrity, sessions (with prompt sizes), workspaces, log accumulation, cache sizes. |
fix |
Stops the app → backs up → vacuums database → clears renderer caches → verifies. |
clear-ui-state |
Clears only the renderer cache + Local/Session Storage. The targeted fix for "Delete does nothing". |
delete-session |
Deletes one conversation/session (state + document rows cascade, plus its runs and task inputs). Does not auto-create a replacement (the app UI does that). |
delete-workspace |
Deletes one workspace and all its sessions by --workspace <id> or --path <substring>. |
backup |
Snapshot data directory into the backup folder. |
restore |
Restore the newest backup, or a specific one via --backup-path. Takes a safety backup first. |
list-backups |
List available backups and sizes. |
factory-reset |
Deletes all app data → app starts as first run. Requires typing RESET. |
uninstall |
Runs the app's official uninstaller; optionally wipes data too. |
version |
Print tool version and detected app/data locations. |
| Flag | Effect |
|---|---|
--dry-run |
Show what would happen; change nothing. |
--yes |
Skip confirmation prompts (for scripting). |
--no-backup |
Skip the automatic backup (not recommended). |
--app-path <dir> |
Override the install location if auto-detection fails. |
--start-after |
Relaunch the app when the command finishes. |
oc-repair doctor
oc-repair fix
oc-repair delete-session --id ses_df6a5782effeS7iXoFgygK51xY
oc-repair delete-workspace --workspace QzpcVXNlcnNc.1wf4p7a
oc-repair factory-reset
oc-repair restore --backup-path "C:\Users\me\AppData\Roaming\Open Code\oc-repair-backups\opencode\20261123-185526-manual"These are the most frequently reported problems in the Open Code community:
| Issue | Symptoms | Root Cause |
|---|---|---|
| "Delete does nothing" / deleted sessions reappear | Session/workspace seems to stay after clicking Delete | Renderer cache (HTTP cache, LocalStorage, IndexedDB) holds stale "ghost" references. Database delete succeeds, but UI restores from cache. |
| Orphan workspaces/sessions | Workspace/session appears in UI but data missing on disk | External tool or crash removed data on disk, but database rows remain. |
| Stuck runs | Run shows "running" status indefinitely | Process crashed mid-run; status never updated to failed/completed. |
| Log accumulation | Hundreds of log folders consuming disk space | Each session creates a log folder; old ones never cleaned up. |
| Cache corruption after update/crash | UI shows stale data, missing workspaces, or glitches | Renderer caches (Cache, GPUCache, LocalStorage, etc.) become inconsistent after app update or crash. |
This tool addresses all of the above:
doctor→ Diagnoses all issues above (read-only, safe)fix→ Clears renderer caches, vacuums database, removes stale logsclear-ui-state→ Targeted cache/LocalStorage clearing for "delete does nothing"delete-session→ Permanently removes a sessiondelete-workspace→ Removes workspace and all its sessionsfactory-reset→ Complete wipe for clean slate
- Every destructive command stops the app first, then backs up data before changing anything (unless
--no-backup). - Destructive commands ask for confirmation;
factory-resetrequires typingRESET. doctor,version, and anything with--dry-runnever modify data.- Backups live in:
- Windows:
%APPDATA%\Open Code\oc-repair-backups\opencode\ - macOS:
~/Library/Application Support/Open Code\oc-repair-backups\opencode\ - Linux:
~/.config\Open Code\oc-repair-backups\opencode\
- Windows:
- Backups are never touched by
factory-reset, so you can always restore.
- Discovery: Auto-detects the install (
%LOCALAPPDATA%\Programs\ai.opencode.desktopon Windows;/Applications/Open Code.appon macOS;/opt/Open Codeon Linux) and the data root (%APPDATA%\ai.opencode.desktopon Windows;~/Library/Application Support/ai.opencode.desktopon macOS;~/.config/ai.opencode.desktopon Linux). Override with--app-path. - Database access:
lib/oc-data.mjsuses Node's built-innode:sqlitemodule (Node 22+). No native modules needed. - Ghost detection: Scans renderer state directories for session/workspace UUIDs that no longer exist in the database.
- Repair: Vacuums database, clears stale renderer state.
Tested against Open Code 2.4.0 on Windows 11. The helper is defensive about schema differences.
- "Open Code installation not found" — pass
--app-path "/path/to/Open Code". - "No Open Code data found" — the app has never been opened.
- Helper errors / no output — ensure the app is fully closed; re-run. Include the
doctoroutput when reporting issues. - Node 22 required —
node:sqliteis experimental in Node 22+. Usenvmor similar to upgrade.
Issues and PRs welcome. Please include your Open Code version, OS, and the doctor output.