feat(ai): add connection tree context
This commit is contained in:
15 files changed
+132
-4
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const appSource = readFileSync(new URL("../../../App.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("add to AI database context", () => {
|
||||
it("accepts database tree nodes with an empty database identifier", () => {
|
||||
const addToAiStart = appSource.indexOf("async function addToAi");
|
||||
const addToAiEnd = appSource.indexOf("function openAiPanel", addToAiStart);
|
||||
const addToAiSource = appSource.slice(addToAiStart, addToAiEnd);
|
||||
|
||||
expect(addToAiSource).toContain("else if (hasTreeNodeDatabaseContext(node))");
|
||||
expect(addToAiSource).not.toContain("else if (node.database)");
|
||||
});
|
||||
});
|
||||
@@ -92,6 +92,15 @@ export function supportsQueryExecution(dbType?: DatabaseType): boolean {
|
||||
return supportsDatabaseFeature(dbType, "queryExecution");
|
||||
}
|
||||
|
||||
/**
|
||||
* The AI assistant currently builds its context from database/table metadata.
|
||||
* Connection-only query targets (for example etcd and ZooKeeper) do not expose
|
||||
* that hierarchy, so they must not be offered by sidebar "Add to AI" actions.
|
||||
*/
|
||||
export function supportsAiAssistantContext(dbType?: DatabaseType): boolean {
|
||||
return supportsQueryExecution(dbType) && !usesConnectionOnlyQueryTarget(dbType);
|
||||
}
|
||||
|
||||
export function supportsConnectionScopedQueryExecution(dbType?: DatabaseType): boolean {
|
||||
return supportsRegisteredConnectionScopedQueryExecution(dbType);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user