mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-29 21:33:54 +00:00
fix(cli): session list --max-count not honored, shows too few sessions (#14162)
This commit is contained in:
parent
f8904e3972
commit
d27dbfe062
@ -85,26 +85,17 @@ export const SessionListCommand = cmd({
|
|||||||
},
|
},
|
||||||
handler: async (args) => {
|
handler: async (args) => {
|
||||||
await bootstrap(process.cwd(), async () => {
|
await bootstrap(process.cwd(), async () => {
|
||||||
const sessions = []
|
const sessions = [...Session.list({ roots: true, limit: args.maxCount })]
|
||||||
for await (const session of Session.list()) {
|
|
||||||
if (!session.parentID) {
|
|
||||||
sessions.push(session)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sessions.sort((a, b) => b.time.updated - a.time.updated)
|
if (sessions.length === 0) {
|
||||||
|
|
||||||
const limitedSessions = args.maxCount ? sessions.slice(0, args.maxCount) : sessions
|
|
||||||
|
|
||||||
if (limitedSessions.length === 0) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let output: string
|
let output: string
|
||||||
if (args.format === "json") {
|
if (args.format === "json") {
|
||||||
output = formatSessionJSON(limitedSessions)
|
output = formatSessionJSON(sessions)
|
||||||
} else {
|
} else {
|
||||||
output = formatSessionTable(limitedSessions)
|
output = formatSessionTable(sessions)
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldPaginate = process.stdout.isTTY && !args.maxCount && args.format === "table"
|
const shouldPaginate = process.stdout.isTTY && !args.maxCount && args.format === "table"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user