Skip to content

Title: /sessions lists all sessions globally — no project scoping #33113

Closed

Description

@phuongtung0801

Description

Problem
The /sessions command lists all sessions across every project without any filtering by the current project/workspace. This makes it hard to find sessions relevant to the project you're currently working in.
Root Cause
Looking at the SQLite database (opencode.db), almost all sessions are assigned project_id = 'global' even when they were created from different project directories:
Sessions per project:
global (worktree=/): 60 sessions
ca926cea... (worktree=/path/to/viis-iot-web-v2): 1 session
Sessions were created from multiple distinct directories (/home/user/ravid, /home/user/demeter, /home/user/viis/fe-be) but the project_id was not resolved from the working directory at session creation time.
The directory field does correctly reflect where each session was run from, so the data exists — it's just not being linked to the proper project.
Expected Behavior

  • When opening /sessions from a project directory, only show sessions belonging to that project (matched by worktree/directory)
  • At minimum, group or label sessions by project so users can distinguish them
  • Sessions created from ~/ravid should have project_id pointing to the ravid project, not global
    Environment
  • opencode version: 1.17.8
  • OS: Linux (Ubuntu)
  • Database: ~/.local/share/opencode/opencode.db

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 Jun 20, 2026

    @github-actions
    Contributor

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

    Both issues describe the same root cause: Session.list() is called without scoping to the current directory, causing sessions from unrelated projects to appear together under the global project bucket.

  2. Necmttn commented on Jun 21, 2026

    @Necmttn

    Project identity should be resolved at session creation, then kept as durable metadata. Store cwd, git root or workspace root, project id source, and fallback reason when the session lands in global.

    /sessions from a project directory can default to that project while offering an explicit all-projects view. For existing rows, a migration can backfill likely project ids from the recorded directory, with collision/unknown cases labeled instead of hidden.


    Generated with ax.

  3. elxecutor commented on Jul 24, 2026

    @elxecutor

    I am still having this issue with opencode, sessions in a specific project folder suddenly disappear but is available in ~

  4. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    In the OpenCode v2 TUI, the /sessions dialog can be scoped to the current project. Press ctrl+a in the dialog to switch between current-directory sessions and all projects; the choice is remembered. tabs.scope ("cwd" or "global") in tui.json sets the default.

    Added in 488445a.

    Closing as completed. If something doesn't work on v2, please open a new issue.

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