Browse Source

feat: AI assistant labels, action details and the Version review type for read_versions, commit_version and restore_version; welcome examples on the version control page

pull/16833/head
Igor Kulikov 3 weeks ago
parent
commit
4d33b9b7be
  1. 30
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  2. 3
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  3. 2
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  4. 2
      ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts
  5. 30
      ui-ngx/src/assets/locale/locale.constant-en_US.json

30
ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts

@ -1143,6 +1143,36 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
}
return {hood: text('save-relations'), blocks};
}
case 'read_versions': {
const versions = isObject(result) && Array.isArray(result.versions) ? result.versions.filter(isObject) : undefined;
if (!versions) {
return {hood: text('read-versions'), blocks: generic(result, 'result')};
}
const rows = versions.slice(0, MAX_ROWS).map(version => [str(version.name), str(version.author),
str(version.time) ? new Date(version.time).toLocaleString() : undefined].filter(Boolean).join(' · '));
return {hood: text('read-versions'), blocks: rows.length ? [{type: 'list', rows}] : []};
}
case 'commit_version': {
const saved = isObject(result) ? result : {};
const rows: AiDetailFact[] = [];
if (str(saved.versionId)) {
rows.push({label: K + 'fact.version', value: saved.versionId, mono: true});
}
if (str(saved.branch)) {
rows.push({label: K + 'fact.branch', value: saved.branch});
}
for (const field of ['added', 'modified', 'removed']) {
if (typeof saved[field] === 'number') {
rows.push({label: K + 'fact.' + field, value: String(saved[field])});
}
}
return {hood: text('commit-version', {name: str(values.name) ?? '—'}), blocks: rows.length ? [{type: 'facts', rows}] : generic(result, 'result')};
}
case 'restore_version': {
const types = isObject(result) && Array.isArray(result.result) ? result.result.filter(isObject) : undefined;
const rows = (types ?? []).map(type => `${type.entityType}: +${type.created} · ~${type.updated} · −${type.deleted}`);
return {hood: text('restore-version', {version: String(values.versionId ?? '').slice(0, 8)}), blocks: types ? [{type: 'list', rows}] : generic(result, 'result')};
}
case 'read_platform_settings':
return {hood: text('read-platform-settings'), blocks: json('settings', result)};
case 'save_platform_settings':

3
ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts

@ -64,6 +64,7 @@ const TOOL_WORDS: Record<string, string> = {
save_image: 'save-image',
read_platform_settings: 'read-platform-settings',
save_relations: 'save-relations',
read_versions: 'read-versions',
save_platform_settings: 'save-platform-settings',
read_device_connect_commands: 'read-connection-settings',
search_web: 'search-web',
@ -77,6 +78,8 @@ const TOOL_WORDS: Record<string, string> = {
const GENERATING_TOOLS: Record<string, string> = {
set_dashboard_html_page: 'lay-out-dashboard',
reprocess_calculated_field: 'recalculate-history',
commit_version: 'commit-version',
restore_version: 'restore-version',
research_device_connectivity: 'research-device'
};

2
ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts

@ -51,7 +51,7 @@ const VALUE_TOKENS: Record<string, string[]> = {
const CODE_FIELDS = new Set(['arguments', 'expression', 'output']);
const OWN_TYPE_LABELS = new Set(['DASHBOARD_WIDGET', 'DASHBOARD_STATE', 'DASHBOARD_ENTITY_ALIAS', 'DASHBOARD_FILTER', 'NOTIFICATION', 'NOTIFICATION_SETTINGS', 'NOTIFICATION_PREFERENCES', 'IMAGE', 'PLATFORM_SETTINGS', 'RELATION']);
const OWN_TYPE_LABELS = new Set(['DASHBOARD_WIDGET', 'DASHBOARD_STATE', 'DASHBOARD_ENTITY_ALIAS', 'DASHBOARD_FILTER', 'NOTIFICATION', 'NOTIFICATION_SETTINGS', 'NOTIFICATION_PREFERENCES', 'IMAGE', 'PLATFORM_SETTINGS', 'RELATION', 'VERSION']);
const PROFILE_TYPES = new Set<string>([EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE]);

2
ui-ngx/src/app/modules/home/components/ai/ai-welcome.models.ts

@ -87,7 +87,7 @@ const WELCOMES: Partial<Record<AiAssistantViewType, AiWelcomeKind>> = {
[AiAssistantViewType.SELF_REGISTRATION]: {key: 'self-registration'},
[AiAssistantViewType.SECRETS]: {key: 'secrets', examples: ['create']},
[AiAssistantViewType.AUDIT_LOGS]: {key: 'audit-logs', examples: ['changes', 'logins']},
[AiAssistantViewType.VERSION_CONTROL]: {key: 'version-control'},
[AiAssistantViewType.VERSION_CONTROL]: {key: 'version-control', examples: ['save', 'history']},
[AiAssistantViewType.TASK_MANAGER]: {key: 'task-manager', examples: ['failed']},
[AiAssistantViewType.SCHEDULER]: {key: 'scheduler'},
[AiAssistantViewType.HOME_SETTINGS]: {key: 'home-settings', examples: ['set']},

30
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -880,6 +880,9 @@
"relations-added": "Added",
"relations-removed": "Removed",
"relations-failed": "Failed",
"read-versions": "Read the saved versions",
"commit-version": "Saved the version '{{name}}'",
"restore-version": "Restored from version {{version}}",
"read-platform-settings": "Read the platform settings",
"save-platform-settings": "Saved the platform settings",
"usage": {
@ -975,6 +978,11 @@
"no": "No",
"fact": {
"link": "Link",
"version": "Version",
"branch": "Branch",
"added": "Added",
"modified": "Modified",
"removed": "Removed",
"comment": "Comment",
"reference": "Reference",
"tested": "Tested before saving",
@ -1274,6 +1282,18 @@
"run": "Changing the relations",
"done": "Changed the relations"
},
"read-versions": {
"run": "Reading the versions",
"done": "Read the versions"
},
"commit-version": {
"run": "Saving a version",
"done": "Saved a version"
},
"restore-version": {
"run": "Restoring from the version",
"done": "Restored from the version"
},
"create-entity-view": {
"run": "Creating the entity view",
"done": "Created the entity view"
@ -1590,6 +1610,9 @@
"ask-again-message": "Ask me again for the same change.",
"field": {
"source": "Source",
"entities": "Entities",
"includes": "Also saves",
"removeOthers": "Delete what the version lacks",
"assignee": "Assignee",
"comment": "Comment",
"timeseries": "Telemetry",
@ -1665,6 +1688,7 @@
},
"type": {
"IMAGE": "Image",
"VERSION": "Version",
"RELATION": "Relations",
"PLATFORM_SETTINGS": "Platform settings",
"ENTITY_GROUP": "Group",
@ -2417,7 +2441,11 @@
"version-control": {
"title": "Ask about version control",
"line": "Keep your entities in Git and restore earlier versions.",
"suggestion": "How do I save my dashboards to Git?"
"suggestion": "How do I save my dashboards to Git?",
"example": {
"save": {"label": "Save a version", "message": "Save a version of all my dashboards."},
"history": {"label": "Recent versions", "message": "What versions were saved this week, and by whom?"}
}
},
"task-manager": {
"title": "Ask about the task manager",

Loading…
Cancel
Save