GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `opencode sessions` command fails to list historical sessions when run inside a Git repository · Issue #15678 · anomalyco/opencode

opencode sessions command fails to list historical sessions when run inside a Git repository #15678

New issue
Copy link
New issue
Copy link
Closed
#16814
Closed
opencode sessions command fails to list historical sessions when run inside a Git repository#15678
#16814
Copy link
Assignees
thdxr
Labels
bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Description

@lightrao
lightrao
opened on Mar 2, 2026
Issue body actions

Description

I have discovered that the presence of a .git directory in the current working directory prevents opencode sessions (or opencode session list) from displaying global session history.

The Bug:

  • When running the command in a non-git directory (e.g., ~/Documents/test), all global historical sessions are displayed correctly.

  • When running the command inside a Git repository (where a .git folder exists), the session list returns empty, even if those sessions were created globally.

  • Renaming .git to something else (e.g., gitbak) immediately restores the visibility of the session history.

Expected Behavior:

The tool should either merge global sessions with project-specific sessions or provide a flag (like --global) to access history regardless of the current Git context.

Plugins

No response

OpenCode version

1.2.15

Steps to reproduce

  1. Open a terminal in a directory that is a Git repo (ls -a shows .git).

  2. Run opencode session list. Result: Empty. (or use /sessions command)

  3. Move out of the directory or rename .git.

  4. Run opencode session list. Result: All sessions appear. (or use /sessions command)

Screenshot and/or share link

No response

Operating System

macOS (MacBook Air M2) version 26.3

Terminal

zsh

Activity

  1. lightrao
    added
    bugSomething isn't working
    on Mar 2, 2026
  2. github-actions
    assigned
    thdxr
    on Mar 2, 2026
  3. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 2, 2026
  4. github-actions commented on Mar 2, 2026

    @github-actions
    github-actionsBot
    on Mar 2, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • session_list tool only returns current session, not all historical sessions #14668: session_list tool only returns current session, not all historical sessions — similar symptom (session list not showing historical sessions), though that issue focuses on a different root cause

    If this is the same underlying issue (sessions being scoped/filtered by directory context), please add any additional info there or confirm if your issue differs.

  5. lightrao commented on Mar 2, 2026

    @lightrao
    lightrao
    on Mar 2, 2026
    Author
    More actions

    Thanks for the heads-up, @github-actions.

    I want to clarify that my issue (#15678) is distinct from #14668. While the symptoms are similar, I have identified a specific trigger: workspace isolation logic tied to the presence of a .git directory.

    In my tests:

    1. In a non-git directory, session list works perfectly.

    2. Once a .git folder is present, the list becomes empty.

    3. Renaming .git immediately fixes the visibility.

    This suggests the core logic is filtering sessions by the repository root, but fails to fallback to or include global sessions when a repo is detected.

  6. lightrao commented on Mar 2, 2026

    @lightrao
    lightrao
    on Mar 2, 2026
    Author
    More actions

    One more crucial detail regarding the reproduction steps:
    In my project directory, I actually used opencode first (which successfully created and listed sessions). It was only after those sessions existed that I ran git init in the same directory.
    The behavior change was immediate: > * **Pre-git init**: opencode sessions displayed all historical sessions (global context).

    • **Post-git init**: opencode sessions returned an empty list, even though the sessions were created in the exact same physical path.

    This suggests that once a directory is initialized as a Git repository, the tool strictly scopes its session lookups to the newly defined "Workspace ID" (or repo root), effectively "orphaning" or hiding sessions created in that directory before it was a Git repo.

  7. lightrao commented on Mar 2, 2026

    @lightrao
    lightrao
    on Mar 2, 2026
    Author
    More actions

    Update on my findings:

    After further testing, I noticed something very strange: not every directory with a .git folder triggers this issue. >

    In some of my other Git-enabled project directories, opencode sessions correctly lists the global history.

    However, in this specific project (Hp450G4SshAccess), the presence of .git consistently hides all sessions.

    This suggests the bug isn't just triggered by "any" .git folder, but perhaps by a specific configuration or metadata within certain Git repositories (e.g., repository depth, origin URL format, or nested structures).

  8. lightrao commented on Mar 2, 2026

    @lightrao
    lightrao
    on Mar 2, 2026
    Author
    More actions

    Deep Dive: Root Cause Identified (ProjectID Hash Shift)

    I’ve conducted a detailed comparison between a "working" repo and a "broken" repo, including an inspection of the opencode binary logic. I have identified the exact cause of this behavior.

    The Underlying Mechanism

    OpenCode (v1.2.15) generates a projectID for workspace isolation by executing:

    git rev-list --max-parents=0 --all

    (This retrieves the hash of the root commit).

    The Bug Trigger Sequence:

    1. Phase 1 (Unborn Branch): In a newly initialized repo with 0 commits, the above command returns nothing. OpenCode falls back to a default ID (likely based on the absolute folder path). All sessions created at this stage are linked to this "Fallback ID".

    2. Phase 2 (Initial Commit): As soon as the first commit is made, git rev-list suddenly returns a valid root commit hash (e.g., b5c3cd4...).

    3. Phase 3 (The ID Shift): OpenCode immediately switches the active projectID to this new commit hash (and caches it in .git/opencode).

    4. The Result: Because the ID has shifted from the "Fallback ID" to the "Commit-based ID", all sessions created before the first commit are instantly orphaned. They still exist in the database but are no longer queryable under the new workspace identity.

    Proof:

    • Deleting .git forces OpenCode to fail the Git check, revert to the "Fallback ID", and the "lost" sessions instantly reappear.

    • Empty .git (no commits) works because it stays on the "Fallback ID".

    Suggested Fix:

    OpenCode should consistently use the repository's root absolute path for the projectID, or implement a migration logic that transfers sessions from the "unborn" state to the "first-commit" state once the root hash becomes available.

  9. lightrao commented on Mar 2, 2026

    @lightrao
    lightrao
    on Mar 2, 2026
    Author
    More actions

    Conclusion for maintainers:
    The workspace identity is non-deterministic during the transition from an empty repository to the first commit. This causes a permanent loss of visibility for any sessions created in that "pre-commit" window.

  10. zoe531
    added a commit that references this issue on Mar 2, 2026

    fix: list all sessions regardless of git context (anomalyco#15678)

    b98df9b
  11. andreagroferreira
    added a commit that references this issue on Mar 9, 2026

    fix(session): scope session list to current directory to prevent cros…

    This issue will close once commit dc90982 is merged into the 'dev' branch.
    dc90982
  12. rekram1-node
    closed this as completedin #16814on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.