MCPcopy
hub / github.com/codeaashu/claude-code / listSessionsImpl

Function listSessionsImpl

src/utils/listSessionsImpl.ts:439–454  ·  view source on GitHub ↗
(
  options?: ListSessionsOptions,
)

Source from the content-addressed store, hash-verified

437 * as the original implementation).
438 */
439export async function listSessionsImpl(
440 options?: ListSessionsOptions,
441): Promise<SessionInfo[]> {
442 const { dir, limit, offset, includeWorktrees } = options ?? {}
443 const off = offset ?? 0
444 // Only stat when we need to sort before reading (won't read all anyway).
445 // limit: 0 means "no limit" (see applySortAndLimit), so treat it as unset.
446 const doStat = (limit !== undefined && limit > 0) || off > 0
447
448 const candidates = dir
449 ? await gatherProjectCandidates(dir, includeWorktrees ?? true, doStat)
450 : await gatherAllCandidates(doStat)
451
452 if (!doStat) return readAllAndSort(candidates)
453 return applySortAndLimit(candidates, limit, off)
454}
455

Callers

nothing calls this directly

Calls 4

gatherProjectCandidatesFunction · 0.85
gatherAllCandidatesFunction · 0.85
readAllAndSortFunction · 0.85
applySortAndLimitFunction · 0.85

Tested by

no test coverage detected