MCPcopy
hub / github.com/claude-code-best/claude-code / getSessionFilesLite

Function getSessionFilesLite

src/utils/sessionStorage.ts:5088–5129  ·  view source on GitHub ↗
(
  projectDir: string,
  limit?: number,
  projectPath?: string,
)

Source from the content-addressed store, hash-verified

5086 * visible sessions with firstPrompt, gitBranch, customTitle, etc.
5087 */
5088export async function getSessionFilesLite(
5089 projectDir: string,
5090 limit?: number,
5091 projectPath?: string,
5092): Promise<LogOption[]> {
5093 const sessionFilesMap = await getSessionFilesWithMtime(projectDir)
5094
5095 // Sort by mtime descending and apply limit
5096 let entries = [...sessionFilesMap.entries()].sort(
5097 (a, b) => b[1].mtime - a[1].mtime,
5098 )
5099 if (limit && entries.length > limit) {
5100 entries = entries.slice(0, limit)
5101 }
5102
5103 const logs: LogOption[] = []
5104
5105 for (const [sessionId, fileInfo] of entries) {
5106 logs.push({
5107 date: new Date(fileInfo.mtime).toISOString(),
5108 messages: [],
5109 isLite: true,
5110 fullPath: fileInfo.path,
5111 value: 0,
5112 created: new Date(fileInfo.ctime),
5113 modified: new Date(fileInfo.mtime),
5114 firstPrompt: '',
5115 messageCount: 0,
5116 fileSize: fileInfo.size,
5117 isSidechain: false,
5118 sessionId,
5119 projectPath,
5120 })
5121 }
5122
5123 // logs are freshly pushed above — safe to mutate in place
5124 const sorted = sortLogs(logs)
5125 sorted.forEach((log, i) => {
5126 log.value = i
5127 })
5128 return sorted
5129}
5130
5131/**
5132 * Enriches a lite log with metadata from its JSONL file.

Callers 3

fetchLogsFunction · 0.85

Calls 4

getSessionFilesWithMtimeFunction · 0.85
sortLogsFunction · 0.85
entriesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected