Skip to content

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

Closed as not planned

Description

@rahmadar-if

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 event → session.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

Activity

  1. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions