MCPcopy Create free account
hub / github.com/Noumena-Network/code / getSessionFilesLite

Function getSessionFilesLite

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

Source from the content-addressed store, hash-verified

5243 * visible sessions with firstPrompt, gitBranch, customTitle, etc.
5244 */
5245export async function getSessionFilesLite(
5246 projectDir: string,
5247 limit?: number,
5248 projectPath?: string,
5249): Promise<LogOption[]> {
5250 const sessionFilesMap = await getSessionFilesWithMtime(projectDir)
5251
5252 // Sort by mtime descending and apply limit
5253 let entries = [...sessionFilesMap.entries()].sort(
5254 (a, b) => b[1].mtime - a[1].mtime,
5255 )
5256 if (limit && entries.length > limit) {
5257 entries = entries.slice(0, limit)
5258 }
5259
5260 const logs: LogOption[] = []
5261
5262 for (const [sessionId, fileInfo] of entries) {
5263 logs.push({
5264 date: new Date(fileInfo.mtime).toISOString(),
5265 messages: [],
5266 isLite: true,
5267 fullPath: fileInfo.path,
5268 value: 0,
5269 created: new Date(fileInfo.ctime),
5270 modified: new Date(fileInfo.mtime),
5271 firstPrompt: '',
5272 messageCount: 0,
5273 fileSize: fileInfo.size,
5274 isSidechain: false,
5275 sessionId,
5276 projectPath,
5277 })
5278 }
5279
5280 // logs are freshly pushed above — safe to mutate in place
5281 const sorted = sortLogs(logs)
5282 sorted.forEach((log, i) => {
5283 log.value = i
5284 })
5285 return sorted
5286}
5287
5288/**
5289 * 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