fix agent runner archive on web

This commit is contained in:
Alec Koifman
2025-12-12 11:15:44 -05:00
parent 813ede2dde
commit fade47afdc
2 changed files with 53 additions and 12 deletions

View File

@@ -12,7 +12,30 @@ export function createSessionsRoutes(agentService: AgentService): Router {
router.get("/", async (req: Request, res: Response) => {
try {
const includeArchived = req.query.includeArchived === "true";
const sessions = await agentService.listSessions(includeArchived);
const sessionsRaw = await agentService.listSessions(includeArchived);
// Transform to match frontend SessionListItem interface
const sessions = await Promise.all(
sessionsRaw.map(async (s) => {
const messages = await agentService.loadSession(s.id);
const lastMessage = messages[messages.length - 1];
const preview = lastMessage?.content?.slice(0, 100) || "";
return {
id: s.id,
name: s.name,
projectPath: s.projectPath || s.workingDirectory,
workingDirectory: s.workingDirectory,
createdAt: s.createdAt,
updatedAt: s.updatedAt,
isArchived: s.archived || false,
tags: s.tags || [],
messageCount: messages.length,
preview,
};
})
);
res.json({ success: true, sessions });
} catch (error) {
const message = error instanceof Error ? error.message : "Unknown error";