feat(sidebar): batch actions for multi selected nodes

This commit is contained in:
Mo-Moore authored and GitHub committed 2026-09-01 00:22:02 +08:00
1 parent 2f71a1a8aa
commit 69a032ed63
37 files changed
+1302 -159

No files matched your search

+7 -3
View File
@@ -944,8 +944,10 @@ function sendSelectionToAi(sql: string) {
let addToAiRequestId = 0;
async function addToAi(node: TreeNode) {
if ((node.type !== "connection" && node.type !== "database" && node.type !== "table") || !node.connectionId) return;
async function addToAi(nodesInput: TreeNode | TreeNode[]) {
const nodes = Array.isArray(nodesInput) ? nodesInput : [nodesInput];
const node = nodes[0];
if (!node || (node.type !== "connection" && node.type !== "database" && node.type !== "table") || !node.connectionId) return;
const connection = connectionStore.getConfig(node.connectionId);
if (!connection) return;
const requestId = ++addToAiRequestId;
@@ -984,10 +986,12 @@ async function addToAi(node: TreeNode) {
queryStore.createTab(node.connectionId, target.database, undefined, "query", target.schema, undefined, target.catalog);
}
const tableMentions = nodes.filter((entry) => entry.type === "table" && !!entry.label).map((entry) => ({ schema: entry.schema, table: entry.label }));
openRightSidebarPanel("ai");
invokeWhenAiReady((handle) => {
if (contextChanged) handle.clearContextReferences();
if (node.type === "table") handle.addTableMention({ schema: node.schema, table: node.label });
for (const mention of tableMentions) handle.addTableMention(mention);
});
} catch (e: any) {
toast(t("connection.connectFailed", { message: translateBackendError(t, e) }), 5000);