feat(ai): add plugin recommendations and agent context
This commit is contained in:
43 files changed
+1210
-118
No files matched your search
@@ -184,6 +184,7 @@ import ExternalSqlFileChangeDialog from "@/components/editor/ExternalSqlFileChan
|
||||
import { resolveWindowContext } from "@/lib/app/windowContext";
|
||||
import { openDetachedTabWindow } from "@/lib/app/detachedTabWindow";
|
||||
import { OPEN_PLUGIN_AI_CONVERSATION, type AiPluginConversationRequest } from "@/lib/ai/aiPluginConversation";
|
||||
import type { PluginAiRecommendationHostUpdate } from "@/lib/plugins/pluginHostBridge";
|
||||
|
||||
const AiAssistant = defineAsyncComponent(() => import("@/components/editor/AiAssistant.vue"));
|
||||
const PluginWorkbenchTab = defineAsyncComponent(() => import("@/components/plugins/PluginWorkbenchTab.vue"));
|
||||
@@ -491,6 +492,20 @@ const blockingAiRunCount = computed(() => (isDesktop ? blockingDesktopAiRunsForQ
|
||||
let aiRunsQuitConfirmed = false;
|
||||
|
||||
const activeTab = computed(() => queryStore.tabs.find((t) => t.id === queryStore.activeTabId));
|
||||
const pluginAiRecommendationsByTab = ref<Record<string, PluginAiRecommendationHostUpdate>>({});
|
||||
const activePluginAiRecommendations = computed(() => {
|
||||
const tab = activeTab.value;
|
||||
if (!tab || tab.mode !== "plugin-workbench" || !tab.pluginWorkbench) return undefined;
|
||||
return pluginAiRecommendationsByTab.value[tab.id];
|
||||
});
|
||||
|
||||
function updatePluginAiRecommendations(tabId: string, update: PluginAiRecommendationHostUpdate): void {
|
||||
const tab = queryStore.tabs.find((candidate) => candidate.id === tabId);
|
||||
if (!tab?.pluginWorkbench || tab.pluginWorkbench.pluginId !== update.pluginId || tab.pluginWorkbench.contributionId !== update.contributionId) return;
|
||||
const expectedWorkbenchId = typeof tab.pluginWorkbench.context?.workbenchId === "string" ? tab.pluginWorkbench.context.workbenchId : undefined;
|
||||
if (expectedWorkbenchId && update.workbenchId && expectedWorkbenchId !== update.workbenchId) return;
|
||||
pluginAiRecommendationsByTab.value = { ...pluginAiRecommendationsByTab.value, [tabId]: update };
|
||||
}
|
||||
// Plugin workbench tabs stay mounted once opened (hidden via v-show): an
|
||||
// iframe moved out of the DOM reloads from scratch, so KeepAlive/ContentArea
|
||||
// remounts flash the whole webview and drop its live session state.
|
||||
@@ -4461,6 +4476,7 @@ onUnmounted(() => {
|
||||
:contribution-id="workbenchTab.pluginWorkbench!.contributionId"
|
||||
:context="workbenchTab.pluginWorkbench!.context"
|
||||
@close-tab="queryStore.closeTab(workbenchTab.id)"
|
||||
@recommendations="updatePluginAiRecommendations(workbenchTab.id, $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4482,6 +4498,7 @@ onUnmounted(() => {
|
||||
:tab="activeTab"
|
||||
:connection="activeConnection"
|
||||
:maximized="isAiPanelMaximized"
|
||||
:plugin-recommendations="activePluginAiRecommendations"
|
||||
@append-sql="onAiAppendSql"
|
||||
@execute-sql="onAiExecuteSql"
|
||||
@temp-run-sql="onAiTempRunSql"
|
||||
|
||||
Reference in new issue
Block a user