stats --project '' flag does not filter by current project #7156

Closed
opened 2026-02-16 18:06:19 -05:00 by yindo · 1 comment
Owner

Originally created by @libardoram on GitHub (Jan 22, 2026).

Originally assigned to: @rekram1-node on GitHub.

Bug Description

The opencode stats --project '' command is documented to filter stats for the current project, but it shows global stats instead.

Steps to Reproduce

  1. Navigate to a project directory with OpenCode sessions:

    cd /path/to/project
    
  2. Run the stats command with empty project filter:

    opencode stats --project ''
    

Expected Behavior

According to opencode stats --help:

--project     filter by project (default: all projects, empty string: current project)

The command should show stats only for sessions in the current project directory.

Actual Behavior

The command shows stats for all 123 sessions globally, regardless of the current directory.

Additional Context

  • All sessions appear to have projectId: "global" when checked via opencode session list --format json
  • Even when running from different project directories, the stats remain the same
  • Using a full path like opencode stats --project /path/to/project returns 0 sessions

Environment

  • OpenCode version: 1.1.31
  • OS: macOS
  • Shell: zsh

Possible Cause

It appears that either:

  1. The project tracking isn't working correctly (all sessions marked as 'global')
  2. The --project '' flag filtering logic has a bug
  3. Projects need to be explicitly initialized with /init to be tracked properly (not documented)

Would appreciate clarification on the expected behavior and a fix for the filtering.

Originally created by @libardoram on GitHub (Jan 22, 2026). Originally assigned to: @rekram1-node on GitHub. ## Bug Description The `opencode stats --project ''` command is documented to filter stats for the current project, but it shows global stats instead. ## Steps to Reproduce 1. Navigate to a project directory with OpenCode sessions: ```bash cd /path/to/project ``` 2. Run the stats command with empty project filter: ```bash opencode stats --project '' ``` ## Expected Behavior According to `opencode stats --help`: ``` --project filter by project (default: all projects, empty string: current project) ``` The command should show stats only for sessions in the current project directory. ## Actual Behavior The command shows stats for all 123 sessions globally, regardless of the current directory. ## Additional Context - All sessions appear to have `projectId: "global"` when checked via `opencode session list --format json` - Even when running from different project directories, the stats remain the same - Using a full path like `opencode stats --project /path/to/project` returns 0 sessions ## Environment - OpenCode version: `1.1.31` - OS: macOS - Shell: zsh ## Possible Cause It appears that either: 1. The project tracking isn't working correctly (all sessions marked as 'global') 2. The `--project ''` flag filtering logic has a bug 3. Projects need to be explicitly initialized with `/init` to be tracked properly (not documented) Would appreciate clarification on the expected behavior and a fix for the filtering.
yindo closed this issue 2026-02-16 18:06:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 22, 2026):

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

  • #3551: Sessions are now mixed with home directory session list, disregarding which directory you're in
  • #9224: sessions and project files are confused
  • #9881: [FEATURE]: Filter TUI session list by current directory/worktree (related to current project filtering)

These issues describe similar problems with sessions being mixed across directories and the inability to filter by current project/directory. Your issue specifically focuses on the --project ''​ flag not filtering by current project, which may be related to these broader project/directory filtering challenges.

Feel free to ignore if your specific case differs from these issues.

@github-actions[bot] commented on GitHub (Jan 22, 2026): This issue might be a duplicate of existing issues. Please check: - #3551: Sessions are now mixed with home directory session list, disregarding which directory you're in - #9224: sessions and project files are confused - #9881: [FEATURE]: Filter TUI session list by current directory/worktree (related to current project filtering) These issues describe similar problems with sessions being mixed across directories and the inability to filter by current project/directory. Your issue specifically focuses on the `--project ''​` flag not filtering by current project, which may be related to these broader project/directory filtering challenges. Feel free to ignore if your specific case differs from these issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7156