feat(mcp): record SQL executions in query history

This commit is contained in:
ccq authored and GitHub committed 2026-09-18 22:50:26 +08:00
1 parent 1c47062cdd
commit 0f6db4b2c7
7 files changed
+264 -6

No files matched your search

@@ -0,0 +1,14 @@
import { describe, expect, it } from "vitest";
import { historyEntrySource } from "@/lib/history/historyEntrySource";
describe("historyEntrySource", () => {
it("identifies MCP entries from history details", () => {
expect(historyEntrySource({ details_json: '{"source":"mcp"}' })).toBe("MCP");
});
it("ignores other, missing, or invalid details", () => {
expect(historyEntrySource({ details_json: '{"source":"desktop"}' })).toBeNull();
expect(historyEntrySource({ details_json: null })).toBeNull();
expect(historyEntrySource({ details_json: "{" })).toBeNull();
});
});
@@ -0,0 +1,11 @@
import type { HistoryEntry } from "@/lib/backend/api";
export function historyEntrySource(entry: Pick<HistoryEntry, "details_json">): "MCP" | null {
if (!entry.details_json) return null;
try {
const details = JSON.parse(entry.details_json) as { source?: unknown };
return details.source === "mcp" ? "MCP" : null;
} catch {
return null;
}
}