Description
When a project directory is renamed or moved, existing sessions become invisible in the session list. The directory field stored on each session is an absolute path that is never updated when the project's worktree changes. The sessions remain in the database but are effectively orphaned — they cannot be accessed through the normal /sessions UI.
In case 1, fromDirectory() updates the project's worktree in the database, but the directory on existing sessions still points to the old path.
In case 2, the automatic migration in project.ts only matches sessions where session.directory === project.worktree exactly, which fails when the directory was renamed.
Plugins
None
OpenCode version
v1.4.7+
Steps to reproduce
Case 1: Renaming an existing Git repository (simplest)
- Create a Git repository with at least one commit in
~/prog/foo
- Open OpenCode in
~/prog/foo and create a session
- Close OpenCode
- Rename the directory:
mv ~/prog/foo ~/prog/bar
- Open OpenCode in
~/prog/bar
- Open
/sessions — the previous session is not visible
Case 2: Renaming a non-git directory followed by git init
- Open OpenCode in
~/prog/orphan-test (no Git repository)
- Create a session (stored under
project_id = "global" with directory = ~/prog/orphan-test)
- Close OpenCode
- Rename:
mv ~/prog/orphan-test ~/prog/orphan-test2
- Run
git init && git add -A && git commit -m "init" in ~/prog/orphan-test2
- Open OpenCode in
~/prog/orphan-test2
- The session remains orphaned under
project_id = "global" with the old directory path
Screenshot and/or share link
No response
Operating System
Linux
Terminal
Alacritty
Description
When a project directory is renamed or moved, existing sessions become invisible in the session list. The
directoryfield stored on each session is an absolute path that is never updated when the project's worktree changes. The sessions remain in the database but are effectively orphaned — they cannot be accessed through the normal/sessionsUI.In case 1,
fromDirectory()updates the project'sworktreein the database, but thedirectoryon existing sessions still points to the old path.In case 2, the automatic migration in
project.tsonly matches sessions wheresession.directory === project.worktreeexactly, which fails when the directory was renamed.Plugins
None
OpenCode version
v1.4.7+
Steps to reproduce
Case 1: Renaming an existing Git repository (simplest)
~/prog/foo~/prog/fooand create a sessionmv ~/prog/foo ~/prog/bar~/prog/bar/sessions— the previous session is not visibleCase 2: Renaming a non-git directory followed by
git init~/prog/orphan-test(no Git repository)project_id = "global"withdirectory = ~/prog/orphan-test)mv ~/prog/orphan-test ~/prog/orphan-test2git init && git add -A && git commit -m "init"in~/prog/orphan-test2~/prog/orphan-test2project_id = "global"with the old directory pathScreenshot and/or share link
No response
Operating System
Linux
Terminal
Alacritty