Skip to content

[FEATURE]:add session list global cli #14561

Closed as not planned
Closed as not planned

Description

@zer0Black

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Retrieve the global session list

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Feb 21, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 21, 2026
  3. simpsonkorea commented on Feb 24, 2026

    @simpsonkorea

    +1 on this. I've been hitting the same limitation daily — managing multiple projects means I need to find and resume sessions across all directories, not just the current one.

    Current state

    opencode session list only shows sessions for the current working directory. opencode -s <id> works for resuming any session, but there's no way to discover sessions from other projects without manually querying the SQLite DB.

    Proposed CLI additions

    # List all sessions globally (cross-project), sorted by last updated
    opencode session list --global
    
    # Full-text search across session content
    opencode session search "amplitude API" --global
    
    # Combined: list + filter by project path
    opencode session list --global --directory "~/Projects/my-app"

    Why --global?

    The default (current directory only) is the right default — it's what you want 90% of the time. But power users working across multiple projects need a way to find "that session where I debugged the auth flow last week" without remembering which directory it was in.

    Why session search?

    Session titles are auto-generated and often not descriptive enough to find what you need. Being able to search message content (the part table with json_extract(data, '$.type') = 'text') would make sessions actually discoverable.

    Working proof of concept

    I built shell functions that query ~/.local/share/opencode/opencode.db directly as a workaround. They work well, but this belongs in the core CLI:

    # Lists all sessions across all projects with title, date, folder, and session ID
    oc-sessions() {
      local limit=${1:-20}
      sqlite3 "$HOME/.local/share/opencode/opencode.db" \
        "SELECT s.id, s.title, s.directory,
           strftime('%Y-%m-%d %H:%M', datetime(s.time_updated/1000, 'unixepoch', 'localtime'))
         FROM session s WHERE s.parent_id IS NULL
         ORDER BY s.time_updated DESC LIMIT $limit;" \
      | while IFS='|' read -r sid title dir ts; do
          echo "  ${title:0:50}"
          echo "    $ts  ${dir/#$HOME/\~}"
          echo "    opencode -s $sid"
          echo
        done
    }
    
    # Full-text search across session message content
    oc-search() {
      sqlite3 "$HOME/.local/share/opencode/opencode.db" \
        "SELECT s.title, p.session_id, json_extract(p.data, '$.text')
         FROM part p JOIN session s ON p.session_id = s.id
         WHERE p.data LIKE '%$1%' AND json_extract(p.data, '$.type') = 'text'
         ORDER BY p.time_created DESC LIMIT ${2:-10};"
    }

    Output looks like:

      1   Amplitude MCP setup and data analysis
            02-24 15:48  _sandbox/amplitude-mcp
            opencode -s ses_3757e6cbafferGgDFz54FXwRWF
    
      2   Blog layout and style bugfix
            02-24 15:47  operations/content/Blog
            opencode -s ses_371eac738ffev4hxJfa1h4Gszb
    

    Happy to contribute a PR if the team agrees on the CLI API shape.

    Related: #14163 (fixed the --max-count bug for local session list), code-yeongyu/oh-my-openagent#1902 (same request from the plugin side)

  4. ZoroGH commented on Mar 14, 2026

    @ZoroGH

    +1, i use too many sessions in different folder so that i can not remember them all.😢😢

  5. Xyz00777 commented on Apr 1, 2026

    @Xyz00777

    i also would really like that feature, especially because i yesterday deleted a git project and cloned it new and now im not able to get to my old sessions from that project anymore because for opencode this is a new project and so i need to search through the db now with in example opencode db "SELECT id, title, datetime(time_updated/1000, 'unixepoch', 'localtime') as updated FROM session ORDER BY time_updated DESC LIMIT 50;"
    this is really annoying and i also had the problem that i currently have an opencode.db and opencode-stable.db and i only get the ones from the stable db. this could be brougth together into the same pr or not, that im able to get also the old sessions back?

  6. SHL0MS commented on Apr 3, 2026

    @SHL0MS

    +1 — ran into this today. Was looking for a session where I'd been working on a video project but couldn't remember which directory I was in. Had to query the sqlite db directly to find it.

    The --global flag and session search proposals here would have solved it immediately. The current workaround (manually querying ~/.local/share/opencode/opencode.db) works but shouldn't be necessary.

  7. ChanifRusydi commented on Apr 10, 2026

    @ChanifRusydi

    +1, when I run opencode stats I have quite a number of sessions and I'm sure ,in my case, a few (if not most) of them is a stale or a short session (i.e short experimentation session, short learning session,etc). I couldn't remember all of the directory that I spawn opencode in. This feature would definitely useful

  8. assigned and unassigned on Apr 26, 2026
  9. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  10. kasbah commented on Jun 10, 2026

    @kasbah
    Contributor
  11. cccheng commented on Jun 25, 2026

    @cccheng

    As a workaround, I built a lightweight bash + fzf wrapper to query the OpenCode session database and list global sessions.
    You can find it here: https://github.com/cccheng/ocsz

  12. github-actions commented on Aug 25, 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