Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/opencode/src/cli/cmd/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const SessionListCommand = cmd({
describe: "limit to N most recent sessions",
type: "number",
})
.option("global", {
alias: "g",
describe: "list sessions across all projects",
type: "boolean",
default: false,
})
.option("format", {
describe: "output format",
type: "string",
Expand All @@ -86,18 +92,15 @@ export const SessionListCommand = cmd({
},
handler: async (args) => {
await bootstrap(process.cwd(), async () => {
const sessions = [...Session.list({ roots: true, limit: args.maxCount })]
const sessions = args.global
? [...Session.listGlobal({ limit: args.maxCount })]
: [...Session.list({ roots: true, limit: args.maxCount })]

if (sessions.length === 0) {
return
}

let output: string
if (args.format === "json") {
output = formatSessionJSON(sessions)
} else {
output = formatSessionTable(sessions)
}
const output = args.format === "json" ? formatSessionJSON(sessions) : formatSessionTable(sessions)

const shouldPaginate = process.stdout.isTTY && !args.maxCount && args.format === "table"

Expand Down
Loading