Skip to content

feat(cli): add --all to session list - #60895

Open
ColonelToad wants to merge 1 commit into
anomalyco:devfrom
ColonelToad:session-list-all
Open

ColonelToad wants to merge 1 commit into
anomalyco:devfrom
ColonelToad:session-list-all

Conversation

@ColonelToad

@ColonelToad ColonelToad commented Oct 31, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #59004

Type of change

  • New feature

What does this PR do?

Adds --all to opencode session list.

Today the command always resolves the current directory's project and filters the list to it, so sessions from other projects can only be found by changing directory first. With --all the command skips the location lookup and omits the project filter, which session.list already treats as optional. The default is unchanged: top-level sessions in the current project, newest first.

--max-count and --format json compose with the flag. JSON rows already include projectId and directory, so results from different projects stay distinguishable. In the default table output, --all adds the session's directory as a fourth column, because id, title and updated time alone do not say which project a row belongs to. The table without --all is unchanged.

I also clarified the command description now that the scope can change.

How did you verify your code works?

  • New packages/cli/test/session-list.test.ts: the default listing scopes to the current project; --all does not resolve the location and sends no project key (asserting absence, because SessionStore.list filters whenever the key is present); --max-count becomes limit; the table keeps its three columns by default and gains the directory with --all.
  • The --all test fails if project is passed as undefined instead of omitted.
  • Built the CLI and seeded a private server with sessions in two directories: the default table listed only the current project with three columns, --all listed both with the directory as a fourth column, and --all --format json kept the same fields as before.
  • bun run check passes (35/35 tasks).

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" role="img" aria-label="opencode session list scoped to the current project, then with --all showing sessions from every project">
  <style>
    text {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 7.5px;
      fill: currentColor;
    }
    .muted { opacity: 0.55; }
    .faint { opacity: 0.35; }
    .scope { animation: scope 8s ease-in-out infinite; }
    .all { opacity: 0; animation: all 8s ease-in-out infinite; }
    .cursor { animation: blink 1s steps(1) infinite; }
    @keyframes scope {
      0%, 38% { opacity: 1; }
      46%, 92% { opacity: 0; }
      100% { opacity: 1; }
    }
    @keyframes all {
      0%, 38% { opacity: 0; transform: translateY(3px); }
      50%, 92% { opacity: 1; transform: translateY(0); }
      100% { opacity: 0; transform: translateY(3px); }
    }
    @keyframes blink {
      0%, 49% { opacity: 1; }
      50%, 100% { opacity: 0; }
    }
    @media (prefers-reduced-motion: reduce) {
      .scope, .all, .cursor { animation: none; }
      .all { opacity: 0; }
      .cursor { opacity: 1; }
    }
  </style>
  <rect x="1" y="1" width="238" height="70" rx="5" fill="none" stroke="currentColor" stroke-opacity="0.25"/>

  <g class="scope">
    <text x="12" y="20">$ opencode session list</text>
    <rect class="cursor" x="118" y="14" width="4" height="8" fill="currentColor"/>
    <text class="muted" x="12" y="31">this project</text>
    <text x="12" y="42">ses_9c1b</text>
    <text x="62" y="42">Fix theme preview lag</text>
    <text class="faint" x="228" y="42" text-anchor="end">opencode</text>
    <text x="12" y="54">ses_8a2f</text>
    <text x="62" y="54">Daily usage panel</text>
    <text class="faint" x="228" y="54" text-anchor="end">opencode</text>
  </g>

  <g class="all">
    <text x="12" y="20">$ opencode session list --all</text>
    <rect class="cursor" x="144" y="14" width="4" height="8" fill="currentColor"/>
    <text class="muted" x="12" y="31">all projects</text>
    <text x="12" y="42">ses_9c1b</text>
    <text x="62" y="42">Fix theme preview lag</text>
    <text class="faint" x="228" y="42" text-anchor="end">opencode</text>
    <text x="12" y="51">ses_8a2f</text>
    <text x="62" y="51">GEP unmerge nuw</text>
    <text class="faint" x="228" y="51" text-anchor="end">llvm-project</text>
    <text x="12" y="60">ses_4d10</text>
    <text x="62" y="60">Clock domain crossing</text>
    <text class="faint" x="228" y="60" text-anchor="end">verilator</text>
    <text x="12" y="69">ses_77ac</text>
    <text x="62" y="69">Lazy frame join</text>
    <text class="faint" x="228" y="69" text-anchor="end">polars</text>
  </g>
</svg>

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #38451, #57635

Public API: adds the --all flag to opencode session list (backwards compatible)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag works as described. I ran a local server with sessions in four directories across three projects (two share the global project). On the base, session list --all is rejected as an unrecognized flag. With this PR, the default listing still shows only the current project, --all lists every project newest first, and -n and --format json work with it. The new test passes, and tsc -b in packages/cli is clean.

Public API: adds the --all boolean flag (default false) to opencode session list, and the help text changes. It is backwards compatible: existing invocations behave the same.

One thing worth fixing: with --all, the default table output (formatList) still prints only id, title and updated time. When sessions from several projects are listed together, you can't tell which project each one belongs to unless you switch to --format json. The visual in the description shows a project column, but table rendering isn't changed in this PR. Adding the session's directory (or project) as a column when --all is set would make the table output usable.

This also edits the same handler and command spec as #59784 (--search), so expect a merge conflict whichever lands second.

Related: #38451, #57635

@ColonelToad

Copy link
Copy Markdown
Author

Added the session directory as a fourth column in the table output when --all is set, with a test; the default table is unchanged. Amended the commit and updated the description.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My earlier point is addressed: with --all, the table now shows each session's directory as a fourth column, and the table without --all is unchanged. I checked this against a local server with sessions in several projects: without --all the output matches the base, and --all (with or without -n) shows the directory on every row. The tests pass and tsc -b in packages/cli is clean.

Public API: adds the --all flag to opencode session list; table output gains a directory column only when --all is set. This is backwards compatible.

No new concerns.

@maxime-peim

Copy link
Copy Markdown

Hi!
This feature would be very nice! I think it would be even nicer if the we could load the next pages if maxCount is greater than the number of elements on one page; and we could have an option to just load every sessions without limit.

What do you think about that?

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add --all flag to opencode session list command to list all sessions everywhere

2 participants