Feature hasn't been suggested before.
Describe the enhancement you want to request
Hi! I ran into an issue with OpenCode CLI when using Zed on Windows with a WSL Remote project.
Environment:
- OS: Windows 11
- Editor: Zed, project opened through WSL Remote
- Project path inside WSL:
/home/mmaks/Dev/kanban-flow
- OpenCode:
1.14.28
- Terminal: WSL Ubuntu
- Goal: use OpenCode CLI, not ACP / Zed Agent Panel
Problem: Zed DB path resolution fails in WSL
When OpenCode runs inside WSL, resolveZedDbPath() only checks Linux/macOS-style paths and does not automatically find the Windows Zed DB under %LOCALAPPDATA%\Zed\db\0-stable\db.sqlite. Setting OPENCODE_ZED_DB manually works in principle, but reading the live SQLite/WAL DB directly through /mnt/c/... can produce SQLite disk I/O error (10). Copying db.sqlite, db.sqlite-wal, and db.sqlite-shm into the WSL filesystem and pointing OPENCODE_ZED_DB to that local snapshot works.
Currently, a workaround is to mirror the Zed database in WSL before running OpenCode.
It would be great if OpenCode could use a more robust editor bridge for Zed Remote/WSL instead of relying solely on the active editor line in the SQLite database.
There is also a solution using a wrapper that mirrors the database so that OpenCode can read it in WSL (workaround).
Add to source
export PATH="$HOME/.local/bin:$PATH"
Wrapper
cat > ~/.local/bin/opencode-zed-wsl <<'EOF'
#!/usr/bin/env bash
set -u
CHANNEL="${ZED_CHANNEL:-stable}"
INTERVAL="${OPENCODE_ZED_MIRROR_INTERVAL:-0.75}"
WIN_LOCALAPPDATA="$(
powershell.exe -NoProfile -Command '[Environment]::GetFolderPath("LocalApplicationData")' \
| tr -d '\r'
)"
ZED_DB_DIR="$(wslpath -u "$WIN_LOCALAPPDATA")/Zed/db/0-${CHANNEL}"
BASE="$HOME/.cache/opencode-zed-db"
CURRENT="$BASE/current"
if [ ! -f "$ZED_DB_DIR/db.sqlite" ]; then
echo "Zed DB not found: $ZED_DB_DIR/db.sqlite" >&2
echo "Try: ZED_CHANNEL=preview opencode-zed-wsl" >&2
exit 1
fi
mkdir -p "$BASE"
if [ -e "$CURRENT" ] && [ ! -L "$CURRENT" ]; then
rm -rf "$CURRENT"
fi
mirror_once() {
local tmp snap
snap="$BASE/snap-$(date +%s%N)"
tmp="${snap}.tmp"
mkdir -p "$tmp" || return 1
cp "$ZED_DB_DIR"/db.sqlite* "$tmp"/ 2>/dev/null
if [ $? -ne 0 ] || [ ! -f "$tmp/db.sqlite" ]; then
rm -rf "$tmp"
return 1
fi
mv "$tmp" "$snap" || {
rm -rf "$tmp"
return 1
}
ln -sfn "$snap" "$CURRENT"
ls -dt "$BASE"/snap-* 2>/dev/null | tail -n +25 | xargs -r rm -rf
}
mirror_loop() {
while true; do
mirror_once >/dev/null 2>&1 || true
sleep "$INTERVAL"
done
}
mirror_once || {
echo "Could not create initial Zed DB snapshot from: $ZED_DB_DIR" >&2
exit 1
}
mirror_loop &
MIRROR_PID="$!"
cleanup() {
kill "$MIRROR_PID" 2>/dev/null || true
wait "$MIRROR_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
export OPENCODE_ZED_DB="$CURRENT/db.sqlite"
echo "Using Zed DB snapshot: $OPENCODE_ZED_DB"
echo "Mirror interval: ${INTERVAL}s"
echo "Keep Zed focused on an editor tab, not the integrated terminal."
echo
opencode "$@"
CODE=$?
echo
echo "opencode exited with code: $CODE"
exit "$CODE"
EOF
chmod +x ~/.local/bin/opencode-zed-wsl
Run
Feature hasn't been suggested before.
Describe the enhancement you want to request
Hi! I ran into an issue with OpenCode CLI when using Zed on Windows with a WSL Remote project.
Environment:
/home/mmaks/Dev/kanban-flow1.14.28Problem: Zed DB path resolution fails in WSL
When OpenCode runs inside WSL,
resolveZedDbPath()only checks Linux/macOS-style paths and does not automatically find the Windows Zed DB under%LOCALAPPDATA%\Zed\db\0-stable\db.sqlite. SettingOPENCODE_ZED_DBmanually works in principle, but reading the live SQLite/WAL DB directly through/mnt/c/...can produce SQLitedisk I/O error (10). Copyingdb.sqlite,db.sqlite-wal, anddb.sqlite-shminto the WSL filesystem and pointingOPENCODE_ZED_DBto that local snapshot works.Currently, a workaround is to mirror the Zed database in WSL before running OpenCode.
It would be great if OpenCode could use a more robust editor bridge for Zed Remote/WSL instead of relying solely on the active editor line in the SQLite database.
There is also a solution using a wrapper that mirrors the database so that OpenCode can read it in WSL (workaround).
Add to source
Wrapper
Run