MCPcopy Create free account
hub / github.com/WJX20/claude-code / getSessionFilesLite

Function getSessionFilesLite

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

Source from the content-addressed store, hash-verified

4974 * visible sessions with firstPrompt, gitBranch, customTitle, etc.
4975 */
4976export async function getSessionFilesLite(
4977 projectDir: string,
4978 limit?: number,
4979 projectPath?: string,
4980): Promise<LogOption[]> {
4981 const sessionFilesMap = await getSessionFilesWithMtime(projectDir)
4982
4983 // Sort by mtime descending and apply limit
4984 let entries = [...sessionFilesMap.entries()].sort(
4985 (a, b) => b[1].mtime - a[1].mtime,
4986 )
4987 if (limit && entries.length > limit) {
4988 entries = entries.slice(0, limit)
4989 }
4990
4991 const logs: LogOption[] = []
4992
4993 for (const [sessionId, fileInfo] of entries) {
4994 logs.push({
4995 date: new Date(fileInfo.mtime).toISOString(),
4996 messages: [],
4997 isLite: true,
4998 fullPath: fileInfo.path,
4999 value: 0,
5000 created: new Date(fileInfo.ctime),
5001 modified: new Date(fileInfo.mtime),
5002 firstPrompt: '',
5003 messageCount: 0,
5004 fileSize: fileInfo.size,
5005 isSidechain: false,
5006 sessionId,
5007 projectPath,
5008 })
5009 }
5010
5011 // logs are freshly pushed above — safe to mutate in place
5012 const sorted = sortLogs(logs)
5013 sorted.forEach((log, i) => {
5014 log.value = i
5015 })
5016 return sorted
5017}
5018
5019/**
5020 * Enriches a lite log with metadata from its JSONL file.

Callers 3

fetchLogsFunction · 0.85

Calls 3

getSessionFilesWithMtimeFunction · 0.85
sortLogsFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected