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

Function getSessionFilesLite

source code/utils/sessionStorage.ts:4977–5018  ·  view source on GitHub ↗
(
  projectDir: string,
  limit?: number,
  projectPath?: string,
)

Source from the content-addressed store, hash-verified

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