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