Repository navigation
session: unable to resume a session after its directory is removed (Session location unavailable) #55035
Description
Summary
After upgrading from OpenCode 1.x to 2.0.27, sessions whose working directory no longer exists on disk cannot be opened at all: the client shows "Session location unavailable" and only offers to move the session to another directory. In V1 the same sessions could still be opened with a missing directory, so this looks like a behavior regression introduced by V2's location/worktree resolution.
Environment
- opencode version: 2.0.27
- OS: Windows 10.0.26200 (win32 x64)
- Terminal: Windows Terminal + PowerShell (env vars not set)
- Shell: PowerShell 5.1 (
ComSpec=C:\Windows\system32\cmd.exe) - Install/channel: npm global, channel
latest(major upgrade 1.19.0 → 2.0.27) - Active plugins: none server-side (only a CLI plugin configured)
Reproduction
- On OpenCode 1.x, create a session whose working directory is
D:\work\proj(the session'sdirectory= that path). - Delete or move
D:\work\proj. - Upgrade to OpenCode 2.0.27 (the V1→V2 migration runs).
- Try to open/resume that session.
A V2-only reproduction (no upgrade required) should be: create a session in directory X, delete X, then reopen the session.
Expected Behavior
The session should still be openable, at minimum read-only, with a graceful fallback for a missing directory (for example, falling back to the home directory or a "read-only transcript" view). A missing directory should not make the session permanently inaccessible, or it should at least be clearly explained.
Actual Behavior
- Opening the session shows the panel titled "Session location unavailable" with the body "Choose another directory to continue this session."
- The client throws
Error("Location unavailable")after resolving the session location; the location layer surfacesWorktree.DirectoryUnavailableError. - The only recovery offered is moving the session to another directory (or recreating the missing directory externally).
Additional Context
- No data is lost:
opencode session export <id>still works and the database is intact. - In my database, 3 sessions pointed to a directory I had deleted; recreating the directory made them openable again, which confirms the trigger is directory existence.
- After the migration, all 76 legacy sessions have
project_id = 'global'andworkspace_id = NULL(i.e. not associated with their real project/directory), whereas freshly created V2 sessions appear to get a real project id. This may be relevant to which location-resolution path legacy sessions take. - The
worktreemigration (20260812213948_worktree) andclear_v1_session_permissionwere applied exactly at the V1→V2 upgrade. - Observed consistently for every session whose
directoryis missing. - Workaround: restore the missing directory, or use the client's "Choose directory" move action.
Related Issues
- tui: false "Session location unavailable" prompt after upgrade reconnect #49352 — tui: false "Session location unavailable" prompt after upgrade reconnect (different: that one is a false prompt for a valid directory; this report is about a genuinely missing directory with no way to open the session)
- tui: agent keeps running while user is trapped in false location-unavailable modal #43415 — tui: agent keeps running while user is trapped in false location-unavailable modal
- sessions: POST /api/session/{id}/move stores a bogus path and hides the session from the project list #53454 — sessions: POST /api/session/{id}/move stores a bogus path and hides the session from the project list
Activity
opencode-agent commentedon Oct 13, 2026
Thanks for the detailed report!
What you're asking for: when a session's working directory has been deleted, it should still open with a sensible fallback (for example the home directory, or a clearly labelled read-only transcript) instead of requiring a move to another directory first.
In v2, the "Session location unavailable" prompt is how a missing directory is meant to be handled. The session history should still be shown; only the message input is replaced by the prompt to move the session (see #46215 and #53268). The
Location unavailableerror you found comes from the session picker's search, which falls back to the local session list, so it shouldn't stop the session from opening. If you're using the TUI or desktop app and the history does not appear at all, please say which one you're using. That would be a separate bug.An automatic fallback directory or an explicit read-only mode would be a change to how this works, so I've marked this as a feature request for the maintainers to consider. Related issues:
project_id = 'global'you sawUntil then, recreating the directory or using Choose directory are the ways to continue these sessions, and
opencode session export <id>still gives you the full transcript.thehaven commentedon Oct 14, 2026
Same failure mode, slightly different sub-case: worktree-removed sessions in
the v2 CLI TUI (
opencode22.0.28 on Linux, not the desktop client).Repro follows your steps 1-3, but the missing path is a removed
git worktreerather than a deleted/moved project directory. The orphansandboxes have a distinctive shape on this host:
The inner contents (opencode2's per-worktree data) are still on disk; it's
the git worktree itself that's gone, and the opencode2 sqlite session DB
still has rows whose
directoryfield points to the now-missing path.opencode2 session list --format jsonconfirms it: every row carriesthe
directoryof the cwd it was created in.Workaround that worked here:
git worktree add <same-path> <branch>recreates the path, and
opencode2 -c(or-s <id>) then resumescleanly. The session is bound to the path, not to git's worktree-id
hash, so the mismatch between the original
60843dand whatever newworktree-id git assigns is fine.
Pre-emptive config that helped on the prevention side: setting
session.new_location: "launch"in~/.config/opencode/cli.jsonmeansnew sessions in this CLI no longer inherit the active session's CWD; they
stop binding to a soon-to-die worktree path. That doesn't recover
already-orphaned sessions, just reduces the rate of new ones, and the
underlying recovery UX you describe is the real gap.
Pinning this here rather than filing a duplicate. Happy to file a
separate feature request for a
session.fallback_on_missingconfig(
launch | home | prompt | skip) if that would help; let me know.