mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
fix agent runner archive on web
This commit is contained in:
@@ -245,8 +245,12 @@ export function SessionManager({
|
|||||||
// Archive session
|
// Archive session
|
||||||
const handleArchiveSession = async (sessionId: string) => {
|
const handleArchiveSession = async (sessionId: string) => {
|
||||||
const api = getElectronAPI();
|
const api = getElectronAPI();
|
||||||
if (!api?.sessions) return;
|
if (!api?.sessions) {
|
||||||
|
console.error("[SessionManager] Sessions API not available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const result = await api.sessions.archive(sessionId);
|
const result = await api.sessions.archive(sessionId);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
// If the archived session was currently selected, deselect it
|
// If the archived session was currently selected, deselect it
|
||||||
@@ -254,17 +258,31 @@ export function SessionManager({
|
|||||||
onSelectSession(null);
|
onSelectSession(null);
|
||||||
}
|
}
|
||||||
await loadSessions();
|
await loadSessions();
|
||||||
|
} else {
|
||||||
|
console.error("[SessionManager] Archive failed:", result.error);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[SessionManager] Archive error:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unarchive session
|
// Unarchive session
|
||||||
const handleUnarchiveSession = async (sessionId: string) => {
|
const handleUnarchiveSession = async (sessionId: string) => {
|
||||||
const api = getElectronAPI();
|
const api = getElectronAPI();
|
||||||
if (!api?.sessions) return;
|
if (!api?.sessions) {
|
||||||
|
console.error("[SessionManager] Sessions API not available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const result = await api.sessions.unarchive(sessionId);
|
const result = await api.sessions.unarchive(sessionId);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
await loadSessions();
|
await loadSessions();
|
||||||
|
} else {
|
||||||
|
console.error("[SessionManager] Unarchive failed:", result.error);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[SessionManager] Unarchive error:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,30 @@ export function createSessionsRoutes(agentService: AgentService): Router {
|
|||||||
router.get("/", async (req: Request, res: Response) => {
|
router.get("/", async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const includeArchived = req.query.includeArchived === "true";
|
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 });
|
res.json({ success: true, sessions });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : "Unknown error";
|
const message = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
|||||||
Reference in New Issue
Block a user