diff options
| author | Mike Harris <[email protected]> | 2026-02-18 11:56:37 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-18 10:56:37 -0600 |
| commit | d27dbfe062b18f832acf958357e175ed18ab98d9 (patch) | |
| tree | 0187c8e5d4904191094c227531bc080d99f21fd2 | |
| parent | f8904e3972fba3d9fc3b08fa2531da8fca378dd1 (diff) | |
| download | opencode-d27dbfe062b18f832acf958357e175ed18ab98d9.tar.gz opencode-d27dbfe062b18f832acf958357e175ed18ab98d9.zip | |
fix(cli): session list --max-count not honored, shows too few sessions (#14162)
| -rw-r--r-- | packages/opencode/src/cli/cmd/session.ts | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/packages/opencode/src/cli/cmd/session.ts b/packages/opencode/src/cli/cmd/session.ts index 1803f8495..8239b0bcb 100644 --- a/packages/opencode/src/cli/cmd/session.ts +++ b/packages/opencode/src/cli/cmd/session.ts @@ -85,26 +85,17 @@ export const SessionListCommand = cmd({ }, handler: async (args) => { await bootstrap(process.cwd(), async () => { - const sessions = [] - for await (const session of Session.list()) { - if (!session.parentID) { - sessions.push(session) - } - } - - sessions.sort((a, b) => b.time.updated - a.time.updated) - - const limitedSessions = args.maxCount ? sessions.slice(0, args.maxCount) : sessions + const sessions = [...Session.list({ roots: true, limit: args.maxCount })] - if (limitedSessions.length === 0) { + if (sessions.length === 0) { return } let output: string if (args.format === "json") { - output = formatSessionJSON(limitedSessions) + output = formatSessionJSON(sessions) } else { - output = formatSessionTable(limitedSessions) + output = formatSessionTable(sessions) } const shouldPaginate = process.stdout.isTTY && !args.maxCount && args.format === "table" |
