Skip to content

Regression: /sessions command no longer filters by current working directory #19532

Closed as not planned

Description

@jimicze

Description

The /sessions command (and session list in the TUI) no longer filters sessions by the current working directory/project path. Previously, sessions were scoped to the directory where they were created, so switching to a project directory would only show that project's sessions.

Current Behavior

/sessions shows all sessions for the current project regardless of the directory they were created in. This makes it difficult to find relevant sessions when working across multiple directories/projects.

Expected Behavior

/sessions should filter sessions by the current working directory, as it did previously. Sessions created in /path/to/projectA should only appear when OpenCode is launched from that directory.

Root Cause

In packages/opencode/src/cli/cmd/session.ts:93, the Session.list() call does not pass the directory parameter:

const sessions = [...Session.list({ roots: true, limit: args.maxCount })]

The Session.list() function supports a directory parameter for filtering, and sessions store a directory field in the database (SessionTable.directory), but the CLI/TUI command simply doesn't use it.

Suggested Fix

Pass the current working directory as the directory parameter when listing sessions:

const sessions = [...Session.list({ roots: true, limit: args.maxCount, directory: process.cwd() })]

The same fix should be applied wherever session listing is called from the TUI.

Environment

  • OS: macOS
  • OpenCode: latest

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 28, 2026
  2. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

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

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

Metadata

Metadata

Assignees

Labels

coreAnything 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