feat(mcp): record SQL executions in query history
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user