feat: auto-delete old conversations, and stop a tool call that repeats

This commit is contained in:
2026-10-05 16:59:38 +08:00
parent 576c5946f7
commit d27c4374fe
25 changed files with 2004 additions and 55 deletions
+20 -2
View File
@@ -1,7 +1,9 @@
import { Action, ActionPanel, Clipboard, Icon, List, useNavigation } from "@vicinae/api";
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect, useMemo, useState } from "react";
import { runAutoDelete } from "./lib/cleanup";
import { ChatView } from "./lib/components/ChatView";
import { sessionToPlainText } from "./lib/markdown";
import { getLamPreferences } from "./lib/preferences";
import { clearSessions, deleteSession, listSessions, loadSession } from "./lib/sessions";
import type { SessionSummary } from "./lib/types";
import { formatRelativeTime, truncate } from "./lib/utils";
@@ -16,6 +18,7 @@ import { formatRelativeTime, truncate } from "./lib/utils";
export default function SessionsCommand() {
const { push } = useNavigation();
const [sessions, setSessions] = useState<SessionSummary[] | undefined>(undefined);
const preferences = useMemo(() => getLamPreferences(), []);
const refresh = useCallback(() => {
void listSessions()
@@ -23,7 +26,22 @@ export default function SessionsCommand() {
.catch(() => setSessions([]));
}, []);
useEffect(refresh, [refresh]);
// Opening the list is the other moment the user is asking about their history,
// so it is the other moment expired conversations should be gone. No `keepId`:
// nothing is open here to spare. The refresh afterwards is what stops the list
// rendering a row that was just deleted from underneath it.
useEffect(() => {
let cancelled = false;
void (async () => {
await runAutoDelete({ maxAgeMs: preferences.autoDeleteMs });
if (!cancelled) refresh();
})();
return () => {
cancelled = true;
};
}, [preferences.autoDeleteMs, refresh]);
const openSession = useCallback(
(id: string) => {