diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts index c6377a8787..b29d4db17c 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts @@ -1074,6 +1074,16 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail description: str(item.description)}]}] : generic(result, 'result') }; } + case 'read_iot_hub_device': + case 'install_iot_hub_device': { + const item = isObject(result) && (str(result.name) ?? str(result.installed)) ? result : null; + const name = str(item?.name) ?? str(item?.installed); + return { + hood: text('iot-hub-read', {name: name ?? '…'}), + blocks: item && str(values.versionId) ? [{type: 'hub', rows: [{id: values.versionId, name, vendor: str(item.vendor), + description: str(item.description)}]}] : generic(result, 'result') + }; + } case 'search_entities': return searchEntities(values, result, names); case 'read_entity': { diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts index 5806e07216..4005f165f7 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts @@ -16,7 +16,8 @@ import { aiEntityKind, aiActionDuration, aiActionText, - aiActionWords + aiActionWords, + HUB_INSTALL_TOOLS } from '@home/components/ai/ai-action.models'; @Component({ @@ -41,7 +42,7 @@ export class AiActionLineComponent { hubVersionId = computed(() => { const action = this.action(); - const id = action.tool === 'install_iot_hub_item' && action.status !== 'RUNNING' ? (action.arguments as {versionId?: unknown})?.versionId : null; + const id = HUB_INSTALL_TOOLS.has(action.tool) && action.status !== 'RUNNING' ? (action.arguments as {versionId?: unknown})?.versionId : null; return typeof id === 'string' && id ? id : null; }); diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts b/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts index a5e8c87c3d..1a1a3164c6 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts @@ -54,8 +54,10 @@ const TOOL_WORDS: Record = { search_iot_hub_devices: 'search-iot-hub', search_iot_hub: 'search-iot-hub', read_iot_hub_item: 'read-iot-hub-item', + read_iot_hub_device: 'read-iot-hub-device', list_installed_iot_hub_items: 'list-installed-iot-hub-items', install_iot_hub_item: 'install-iot-hub-item', + install_iot_hub_device: 'install-iot-hub-device', update_group_members: 'update-group-members', change_owner: 'change-owner', share_entity_group: 'share-group', @@ -248,6 +250,8 @@ export const PROPOSE_PLAN_TOOL = 'propose_plan'; export const CITE_SOURCES_TOOL = 'cite_sources'; +export const HUB_INSTALL_TOOLS: ReadonlySet = new Set(['install_iot_hub_item', 'install_iot_hub_device']); + export interface AiSource { url: string; title: string; diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts index 69aabaf19d..9f71414f4e 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts @@ -28,7 +28,7 @@ import { ToolExecutionRequested, ToolExecutionResult } from '@shared/models/ai-chat.models'; -import { AiAction } from '@home/components/ai/ai-action.models'; +import { AiAction, HUB_INSTALL_TOOLS } from '@home/components/ai/ai-action.models'; import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models'; import { MailTemplate, mailTemplateTranslations } from '@shared/models/settings.models'; @@ -277,7 +277,7 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked { } get hubVersionId(): string | null { - const id = this.data?.tool === 'install_iot_hub_item' ? (this.data.arguments as {versionId?: unknown})?.versionId : null; + const id = HUB_INSTALL_TOOLS.has(this.data?.tool) ? (this.data.arguments as {versionId?: unknown})?.versionId : null; return typeof id === 'string' && id ? id : null; } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 886d065747..cc8bd48bba 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1456,6 +1456,10 @@ "run": "Reading the IoT Hub item", "done": "Read the IoT Hub item" }, + "read-iot-hub-device": { + "run": "Reading the device's IoT Hub package", + "done": "Read the device's IoT Hub package" + }, "list-installed-iot-hub-items": { "run": "Checking what is installed from IoT Hub", "done": "Checked what is installed from IoT Hub" @@ -1464,6 +1468,10 @@ "run": "Installing from IoT Hub", "done": "Installed from IoT Hub" }, + "install-iot-hub-device": { + "run": "Installing the device from IoT Hub", + "done": "Installed the device from IoT Hub" + }, "read-connection-settings": { "run": "Looking up the connection settings", "done": "Looked up the connection settings" @@ -2710,6 +2718,17 @@ "size": "Size", "defaultDashboard": "Default dashboard", "homeDashboard": "Home dashboard", + "hub-model": "Model", + "hub-connection": "Connects", + "hub-profile": "Device profile", + "hub-device": "Device", + "hub-gateway": "Gateway", + "hub-connector": "Connector", + "hub-dashboard": "Dashboard", + "hub-ruleChain": "Rule chain", + "hub-integration": "Integration", + "hub-converter": "Converter", + "hub-reused": "Kept as they are", "email": "Email", "firstName": "First name", "lastName": "Last name",