anomalyco / anomalyco/opencode

Bug Report - Sessions & projects point to a stale absolute path after the project folder is moved/renamed

Open
#49,476 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Sep 17, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Bug Report — Sessions & projects point to a stale absolute path after the project folder is moved/renamed

Reported by: Rahmad Arif — linkedin.com/in/rahmadar-if

Title

When a project folder is moved or renamed, existing sessions (and the project record) keep the old absolute directory/path/worktree. The old path no longer exists on disk, so "Reveal in Explorer" / reveal folder fails, and there is no UI/config setting to rebase a session to the current project location.

Environment

  • Platform: Windows (win32), PowerShell 5.1
  • App: opencode Desktop OpenCode.exe, version 1.18.31 (core data version 1.18.30)
  • Storage: SQLite database %USERPROFILE%\.local\share\opencode\opencode.db

Steps to reproduce

  1. Have a Git repo project at D:\_RAHMAD\_2026\Al Wildan\portal_wali_murid.
  2. Move the whole folder (repo included) to a new location, e.g. D:\_RAHMAD\_2026\_Portal Wali Murid\portal_wali_murid; delete the old path.
  3. Open the project from its new location and continue old sessions from the session list (e.g. a session titled Tambah murid & dummy data Kelas 1 Inter 2).
  4. The old sessions still resolve to the stale path:
    • Prompt / working directory shows PS D:\_RAHMAD\_2026\Al Wildan\portal_wali_murid>.
    • "Reveal folder" tries to open the old (non-existent) directory and fails.
  5. There is no way via UI, config, or command to point those sessions to the new path.

What happens in the database (root cause)

opencode stores the working directory in several places inside opencode.db (event-sourced):

  • Table session → columns project_id, directory, path:
    id=ses_f526c9830ffe...  title="Tambah murid & dummy data Kelas 1 Inter 2"
    project_id="global"    directory="D:/_RAHMAD/_2026/Al Wildan/portal_wali_murid"    path="D:/_RAHMAD/_2026/Al Wildan/portal_wali_murid"
    
  • Table eventsession.created.1 / session.updated.1 JSON payload info:
    {"info":{"projectID":"global","directory":"D:\\_RAHMAD\\_2026\\Al Wildan\\portal_wali_murid","path":"D:/_RAHMAD/_2026/Al Wildan/portal_wali_murid", ...}}
    
  • Table project keeps a stale worktree even after the repo moved, and the project is auto-renamed to "<name> OLD":
    -- project id        worktree                                     name
    -- bccf36a3...       D:/_RAHMAD/_2026/Al Wildan/portal_wali_murid  portal_wali_murid OLD
    -- while table project_directory already points to the NEW path:
    -- bccf36a3...       D:/_RAHMAD/_2026/_Portal Wali Murid/portal_wali_murid
    
  • No "path setting" exists anywhere in the project files or opencode config — the path lives only inside the database, so users cannot fix it without editing SQLite directly.

Expected behavior

  • After the worktree location changes, sessions kept under the old path should either be rebased automatically (e.g. detect that session.directory no longer exists on disk and the session belongs to a project whose project_directory was resolved elsewhere, then ask "Move N sessions to ?") or be offered an explicit action "Move to current folder".
  • project.worktree should be updated when project_directory resolves to a new path (treat it as authoritative), instead of getting a misleading "<name> OLD" label.
  • "Reveal in Explorer" should never navigate to a directory that no longer exists.

Suggested fix

  1. On session open / project resolve: if session.directory does not exist on disk, fall back to the resolved project_directory and prompt to rebase the session (update session.project_id/directory/path and the event-sourced session.created.1/session.updated.1 payloads).
  2. When the repo root differs from project.worktree, update project.worktree (and drop the OLD suffix).
  3. Optionally expose a command such as /project:move <old-path> or a settings entry to manually rebase a stored path.

Workaround used

With opencode closed, edit opencode.db in a single transaction:

  • UPDATE session SET project_id=:new_pid, directory=:new_dir, path='' WHERE directory LIKE 'D:/_RAHMAD/_2026/Al Wildan/%';
  • Rewrite the same fields inside the JSON data of event rows of type session.created.1/session.updated.1.
  • UPDATE project SET worktree=:new_dir, name=:name WHERE id=:pid;

Then restart opencode.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.