feat(cli): add -a global mode for session list#15178
Conversation
Add a -a/--all option to session list so users can view sessions across projects without relying on current directory detection. Include a Project ID column in table output for global lists and add coverage for formatting and global root filtering.
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR:
The current PR (#15178) is building upon this related work by adding a way to explicitly show all sessions across projects when needed, rather than just showing sessions in the current directory context. |
There was a problem hiding this comment.
Pull request overview
This PR adds a -a/--all flag to the opencode session list command to enable viewing sessions across all projects, addressing issue #14561. The default behavior (without -a) continues to scope session listings to the current project context, fixing the issue reported in #8836.
Changes:
- Add
-a/--allCLI option to list sessions globally across all projects - Conditionally display a "Project ID" column in table output when using
-aflag - Add comprehensive tests for CLI formatting functions and global session filtering
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/opencode/src/cli/cmd/session.ts | Added -a/--all option, conditional routing to Session.listGlobal(), and exported formatting functions with project ID column support |
| packages/opencode/test/cli/session-list.test.ts | New test file for CLI formatting functions verifying Project ID column visibility and JSON output |
| packages/opencode/test/server/global-session-list.test.ts | Added test verifying root session filtering works correctly across multiple projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const lines: string[] = [] | ||
|
|
||
| const maxIdWidth = Math.max(20, ...sessions.map((s) => s.id.length)) | ||
| const maxProjectWidth = Math.max(10, ...sessions.map((s) => s.projectID.length)) |
There was a problem hiding this comment.
The maxProjectWidth calculation on line 138 is performed even when all is false/undefined, meaning it's computed but never used. Consider moving this calculation inside the conditional block where all is true to avoid unnecessary computation when displaying the default table format.
There was a problem hiding this comment.
Good call. Addressed in 4eb2755: maxProjectWidth is now computed only when --all is enabled.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Addressed feedback:
|
|
Addressed feedback:
|
|
is there some kind of a roadblocker here currently or something that needs to be tested/finished/etc? |
|
This project has nearly 2000 pull requests at this point and a pull request is simply an exercise in futility. It’s just where code goes to die. The contributor model is sadly broken. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
this should be stayed open and merged, it a really good feature! bad bot :D |
Issue for this PR
Closes #14561
Related: #8836
Type of change
What does this PR do?
Adds
-a/--alltoopencode session listso users can list sessions across all projects.Without
-a, behavior stays project-scoped as before.When
-ais used with table output, the list includes aProject IDcolumn to make cross-project results readable.How did you verify your code works?
Ran:
bun test test/cli/session-list.test.ts test/server/global-session-list.test.ts test/server/session-list.test.tsfrompackages/opencodeAll tests passed.
Screenshots / recordings
N/A (CLI output change only)
Checklist