feat(history): add unified MCP execution history
This commit is contained in:
39 files changed
+1261
-87
No files matched your search
@@ -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 });
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user