Skip to content

Worktrees in Desktop are broken since Update to 1.3.2 #19085

Closed as not planned
Closed as not planned

Description

@LeonMueller-OneAndOnly

Description

In the left sidebar i don't see my real work trees anymore and instead only a single, non-deletable work tree - that doesn't even exist in git or my file storage anymore. It its only an artifact from the opencode db, that shouldnt be present in the ui anymore.

This issue occured with the new update from 1.3.0 to 1.3.2 today.

Plugins

None

OpenCode version

1.3.2

Steps to reproduce

Honestly no idea

Screenshot and/or share link

No response

Operating System

MacOS

Terminal

None

Activity

  1. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Steps to reproduce are missing (marked as "No response") — please describe what you did when the broken worktree appeared, e.g. how the worktree was originally created, what actions were taken before/after the update, etc.
    • Operating System is missing — please provide your OS and version.
    • Terminal is missing — please provide the terminal you are using.

    These fields help maintainers reproduce and diagnose the bug efficiently.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Mar 25, 2026
  3. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now includes the necessary details and looks good. We appreciate you taking the time to improve it.

  4. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets the contributing guidelines and has the required information. We appreciate you taking the time to provide the details.

  5. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    OpenCode/GPT found out how to fix this problem, here is the answer:


    I found the issue: OpenCode has stale GUI metadata, not a real git worktree.

    Real git worktrees are only /Users/admin/apps/FlowOffice and /Users/admin/apps/FlowOffice--org-wide-kanban.
    The fake entry comes from cached state in /Users/admin/Library/Application Support/ai.opencode.desktop/opencode.global.dat.
    That file still contains a dead sandbox /Users/admin/apps/FlowOffice--stechuhr-ux plus a duplicate FlowOffice project entry.
    I also hit the reason my earlier attempt “didn’t help”:

    this chat is running inside OpenCode, so the app process keeps rewriting its in-memory state back to disk while it is open.
    What I did now:

    I scheduled a cleanup job that waits for OpenCode to fully close, then removes the stale sandbox entry and the duplicate project metadata.
    It writes a backup first.
    What you need to do:

    Quit OpenCode completely once.
    Wait ~3-5 seconds.
    Open it again.
    If you want to check it worked:

    log: /tmp/opencode-fix-worktree.log
    backup: /Users/admin/Library/Application Support/ai.opencode.desktop/opencode.global.dat.bak-fix-...
    If the fake worktree is still there after one full restart, tell me and I’ll give you the exact post-close verification command or a stronger cleanup.

  6. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    The fixing script looked like this:

    python3 - <<'PY'
    import json
    import shutil
    import time
    
    TARGET = "/Users/admin/Library/Application Support/ai.opencode.desktop/opencode.global.dat"
    BACKUP = f"{TARGET}.bak-fix-{int(time.time())}"
    
    bad_paths = {
        "/Users/admin/apps/FlowOffice--stechuhr-ux",
        "/Users/admin/.local/share/opencode/worktree/748f9baa633206a19b0d37a02efcc0c910051564/quick-orchid",
        "/Users/admin/.local/share/opencode/worktree/748f9baa633206a19b0d37a02efcc0c910051564/hidden-star",
        "/Users/admin/.local/share/opencode/worktree/748f9baa633206a19b0d37a02efcc0c910051564/kind-wolf",
        "/Users/admin/.local/share/opencode/worktree/748f9baa633206a19b0d37a02efcc0c910051564/stellar-mountain",
    }
    
    duplicate_project_id = "031ae4e2a6141e39eda0769e1287e098ac7a01fa"
    
    with open(TARGET) as f:
        data = json.load(f)
    
    shutil.copy2(TARGET, BACKUP)
    
    layout = json.loads(data["layout.page"])
    projects_wrapper = json.loads(data["globalSync.project"])
    
    projects_wrapper["value"] = [
        {
            **project,
            "sandboxes": [s for s in project.get("sandboxes", []) if s not in bad_paths],
        }
        for project in projects_wrapper["value"]
        if project.get("id") != duplicate_project_id
    ]
    
    workspace_order = layout.get("workspaceOrder", {})
    for root, entries in list(workspace_order.items()):
        filtered = [entry for entry in entries if entry not in bad_paths]
        if filtered:
            workspace_order[root] = filtered
        else:
            workspace_order.pop(root, None)
    
    layout["workspaceName"] = {
        k: v for k, v in layout.get("workspaceName", {}).items() if k not in bad_paths
    }
    layout["lastProjectSession"] = {
        k: v for k, v in layout.get("lastProjectSession", {}).items() if k not in bad_paths
    }
    
    data["layout.page"] = json.dumps(layout, separators=(",", ":"))
    data["globalSync.project"] = json.dumps(projects_wrapper, separators=(",", ":"))
    
    with open(TARGET, "w") as f:
        json.dump(data, f, indent=2)
        f.write("\n")
    
    print("Patched:", TARGET)
    print("Backup:", BACKUP)
    PY
  7. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    Okay this worked for one restart. After closing + reopening again the same issue is present again sadly

  8. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    More investigation: this looks like an OpenCode persistence bug, not an actual git worktree problem.

    What I verified locally:

    • git worktree list --porcelain only shows the real worktrees:
      • /Users/admin/apps/FlowOffice
      • /Users/admin/apps/FlowOffice--org-wide-kanban
    • the fake entry is /Users/admin/apps/FlowOffice--stechuhr-ux
    • deleting stale GUI state from ~/Library/Application Support/ai.opencode.desktop/opencode.global.dat removes it temporarily
    • deleting the matching storage entries under ~/.local/share/opencode/storage/... also removes it temporarily
    • after starting OpenCode once, it still looks fixed
    • after closing + reopening OpenCode again, the stale entry is recreated by OpenCode itself

    Relevant stale project/session ids that keep coming back:

    • project id: 031ae4e2a6141e39eda0769e1287e098ac7a01fa
    • stale session id: ses_4349a7199ffeqxtA0cIrfLS97a

    Relevant files involved:

    • ~/Library/Application Support/ai.opencode.desktop/opencode.global.dat
    • ~/.local/share/opencode/storage/project/031ae4e2a6141e39eda0769e1287e098ac7a01fa.json
    • ~/.local/share/opencode/storage/session/031ae4e2a6141e39eda0769e1287e098ac7a01fa/...
    • ~/.local/share/opencode/storage/message/ses_4349a7199ffeqxtA0cIrfLS97a/...

    The strongest hint is in the desktop logs. OpenCode keeps trying to watch the deleted path on startup/restart:

    • ~/Library/Logs/ai.opencode.desktop/opencode-desktop_2026-03-25_09-44-05.log
    • log line: service=file.watcher dir=/Users/admin/apps/FlowOffice--stechuhr-ux cause=Error: No such file or directory

    So the behavior seems to be:

    1. stale sandbox metadata exists from an old sandbox/worktree
    2. manual cleanup removes it from disk
    3. OpenCode rehydrates/re-persistes the stale project internally
    4. next restart shows the fake worktree again

    Happy to provide a cleanup script or more logs if useful, but I think the actual fix needs to be in OpenCode's startup persistence / workspace rehydration logic.

  9. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    For anyone with the same problem: Nuking your local opencode databases solves this issue, but you lose all session etc.

    Here is a one liner to do this on macOS:

    mkdir -p ~/opencode-partial-backup && mv ~/.local/share/opencode ~/opencode-partial-backup/ 2>/dev/null && mv ~/Library/Logs/ai.opencode.desktop ~/opencode-partial-backup/ 2>/dev/null && mv ~/Library/Saved\ Application\ State/ai.opencode.desktop.savedState ~/opencode-partial-backup/ 2>/dev/null && find ~/Library/Application\ Support/ai.opencode.desktop -type f \( -name "*.dat" -o -name "*.json" \) ! -name "opencode.settings.dat" -exec sh -c 'for f do mkdir -p ~/opencode-partial-backup/"$(dirname "${f#$HOME/}")"; mv "$f" ~/opencode-partial-backup/"${f#$HOME/}"; done' sh {} +
    
  10. jacquesbh commented on Mar 25, 2026

    @jacquesbh

    I can confirm that I have this issue as well. I've downgraded to 1.3.0, version where I had no issue at all.

  11. LeonMueller-OneAndOnly commented on Mar 25, 2026

    @LeonMueller-OneAndOnly
    ContributorAuthor

    I can confirm that I have this issue as well. I've downgraded to 1.3.0, version where I had no issue at all.

    Okay thats definitely a better solution compared to nuking your local state :D

  12. lisongmin commented on Mar 26, 2026

    @lisongmin

    In my case, http://127.0.0.1:8088 works and http://localhost:8088 not work.

  13. jacquesbh commented on Apr 1, 2026

    @jacquesbh

    The issue is still present on 1.3.12 for me.
    I'm loosing some workspaces I was working on, so I go back to 1.3.0 again.

  14. jeffreyhaen commented on Apr 17, 2026

    @jeffreyhaen

    Worktrees are still not working on the Windows desktop OpenCode app v1.4.7 for me.

  15. removed
    bugSomething isn't working
    webRelates to opencode on web / desktop
    on May 3, 2026
  16. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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