feat(history): add unified MCP execution history

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-26 22:18:38 +08:00
1 parent dd82d948a9
commit 5c0ce7e4dc
39 files changed
+1261 -87

No files matched your search

+10
View File
@@ -9,6 +9,7 @@ vi.mock("@/lib/backend/api", () => ({
saveHistory: vi.fn(),
deleteHistoryEntry: vi.fn(),
clearHistory: vi.fn(),
clearHistoryBySource: vi.fn(),
loadHistoryConnectionOptions: vi.fn(),
}));
@@ -92,6 +93,15 @@ describe("historyStore", () => {
expect(store.nextCursor).toBeNull();
});
it("clears only the requested history source", async () => {
vi.mocked(api.clearHistoryBySource).mockResolvedValue(undefined);
const store = useHistoryStore();
await store.clear("mcp");
expect(api.clearHistoryBySource).toHaveBeenCalledWith("mcp");
expect(api.clearHistory).not.toHaveBeenCalled();
expect(api.loadHistoryConnectionOptions).toHaveBeenCalled();
});
it("ignores a search started while deletion is pending", async () => {
const stored = entry();
vi.mocked(api.searchHistory).mockResolvedValueOnce({ entries: [stored], total: 1, next_cursor: null });
+4 -2
View File
@@ -175,10 +175,11 @@ export const useHistoryStore = defineStore("history", () => {
void loadConnectionOptions().catch(() => {});
}
async function clear() {
async function clear(source?: string) {
beginDestructiveMutation();
try {
await api.clearHistory();
if (source) await api.clearHistoryBySource(source);
else await api.clearHistory();
} finally {
endDestructiveMutation();
}
@@ -186,6 +187,7 @@ export const useHistoryStore = defineStore("history", () => {
connectionOptions.value = [];
total.value = 0;
nextCursor.value = null;
if (source) void loadConnectionOptions().catch(() => {});
}
return {