()
| 187 | * Preloads recent conversations for display in Logo v2 |
| 188 | */ |
| 189 | export async function getRecentActivity(): Promise<LogOption[]> { |
| 190 | // Return existing promise if already loading |
| 191 | if (cachePromise) { |
| 192 | return cachePromise |
| 193 | } |
| 194 | |
| 195 | const currentSessionId = getSessionId() |
| 196 | cachePromise = loadMessageLogs(10) |
| 197 | .then(logs => { |
| 198 | cachedActivity = logs |
| 199 | .filter(log => { |
| 200 | if (log.isSidechain) return false |
| 201 | if (log.sessionId === currentSessionId) return false |
| 202 | if (log.summary?.includes('I apologize')) return false |
| 203 | |
| 204 | // Filter out sessions where both summary and firstPrompt are "No prompt" or missing |
| 205 | const hasSummary = log.summary && log.summary !== 'No prompt' |
| 206 | const hasFirstPrompt = |
| 207 | log.firstPrompt && log.firstPrompt !== 'No prompt' |
| 208 | return hasSummary || hasFirstPrompt |
| 209 | }) |
| 210 | .slice(0, 3) |
| 211 | return cachedActivity |
| 212 | }) |
| 213 | .catch(() => { |
| 214 | cachedActivity = [] |
| 215 | return cachedActivity |
| 216 | }) |
| 217 | |
| 218 | return cachePromise |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Gets cached activity synchronously |
no test coverage detected