Browse Source

Merge pull request #16860 from thingsboard/rc

Merge rc into master
pull/16830/merge
Vladyslav Prykhodko 4 days ago
committed by GitHub
parent
commit
ef0c697d15
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      application/src/main/resources/thingsboard.yml
  2. 2
      integration/executor/src/main/resources/tb-integration-executor.yml
  3. 39
      ui-ngx/src/app/core/auth/auth.service.ts
  4. 4
      ui-ngx/src/app/core/services/ai-chats.service.ts
  5. 3
      ui-ngx/src/app/core/services/ai-slash.service.ts
  6. 26
      ui-ngx/src/app/core/services/ai-solutions.service.ts
  7. 93
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html
  8. 30
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.ts
  9. 140
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  10. 6
      ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts
  11. 2
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.html
  12. 10
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  13. 1
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html
  14. 2
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts
  15. 1
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html
  16. 72
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts
  17. 3
      ui-ngx/src/app/modules/home/components/ai/ai-code-block.ts
  18. 12
      ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.html
  19. 41
      ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.ts
  20. 16
      ui-ngx/src/app/modules/home/components/ai/ai-date-panel.component.ts
  21. 10
      ui-ngx/src/app/modules/home/components/ai/ai-hand-over.component.html
  22. 2
      ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.ts
  23. 26
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts
  24. 21
      ui-ngx/src/app/modules/home/components/ai/ai-question.models.ts
  25. 7
      ui-ngx/src/app/modules/home/components/ai/ai-references.ts
  26. 42
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.ts
  27. 1
      ui-ngx/src/app/modules/home/components/alarm/alarm-filter-config.component.html
  28. 4
      ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html
  29. 2
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html
  30. 9
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  31. 9
      ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.html
  32. 14
      ui-ngx/src/app/modules/home/components/entity/entity-details-page.component.ts
  33. 5
      ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts
  34. 2
      ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarm-count-basic-config.component.html
  35. 2
      ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarms-table-basic-config.component.html
  36. 7
      ui-ngx/src/app/modules/home/components/widget/config/basic/common/widget-actions-panel.component.html
  37. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/custom-action-pretty-editor.component.html
  38. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style.component.html
  39. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-toggle-custom-style.component.html
  40. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.html
  41. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/date-format-select.component.html
  42. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.html
  43. 9
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/html/html-container-settings.component.html
  44. 2
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html
  45. 3
      ui-ngx/src/app/modules/home/pages/admin/mail-templates.component.ts
  46. 5
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.ts
  47. 2
      ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts
  48. 5
      ui-ngx/src/app/modules/home/pages/widget/widget-editor.component.ts
  49. 4
      ui-ngx/src/app/shared/components/dashboard-select.component.ts
  50. 5
      ui-ngx/src/app/shared/components/json-object-edit.component.html
  51. 1
      ui-ngx/src/app/shared/components/user-menu.component.ts
  52. 1
      ui-ngx/src/app/shared/models/ai-chat.models.ts
  53. 52
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  54. 226
      ui-ngx/src/theme/ai-theme.scss

2
application/src/main/resources/thingsboard.yml

@ -2556,7 +2556,7 @@ queue:
# Statistics printing interval for Edge services
print-interval-ms: "${TB_QUEUE_EDGE_STATS_PRINT_INTERVAL_MS:60000}"
integration:
# Name of hash function used for consistent hash ring in Cluster Mode. See architecture docs for more details. Valid values - murmur3_32, murmur3_128 or sha256
# Number of partitions in each integration queue; there is one queue per integration type. Must match TB_QUEUE_INTEGRATION_PARTITIONS on the Integration Executors, otherwise downlinks, integration validation and Check connection may not reach the executor that runs the integration.
partitions: "${TB_QUEUE_INTEGRATION_PARTITIONS:3}"
# For high-priority notifications that require minimum latency and processing time
notifications_topic: "${TB_QUEUE_INTEGRATION_NOTIFICATIONS_TOPIC:tb_integration_executor.notifications}"

2
integration/executor/src/main/resources/tb-integration-executor.yml

@ -334,7 +334,7 @@ queue:
pause-between-retries: "${TB_QUEUE_RE_SQ_PROCESSING_STRATEGY_RETRY_PAUSE:5}" # Time in seconds to wait in consumer thread before retries;
max-pause-between-retries: "${TB_QUEUE_RE_SQ_PROCESSING_STRATEGY_MAX_RETRY_PAUSE:5}" # Max allowed time in seconds for pause between retries.
integration:
# Name of hash function used for consistent hash ring in Cluster Mode. See architecture docs for more details. Valid values - murmur3_32, murmur3_128 or sha256
# Number of partitions in each integration queue; there is one queue per integration type. Integrations that run on only one executor at a time (MQTT, OPC-UA, Kafka and similar) are distributed across executors by partition, so executors above this number stay idle for those types. When you add executors, set it to at least the number of executors that run the same integration types, and use the same value on the ThingsBoard nodes.
partitions: "${TB_QUEUE_INTEGRATION_PARTITIONS:3}"
# For high-priority notifications that require minimum latency and processing time
notifications_topic: "${TB_QUEUE_INTEGRATION_NOTIFICATIONS_TOPIC:tb_integration_executor.notifications}"

39
ui-ngx/src/app/core/auth/auth.service.ts

@ -10,7 +10,7 @@ import { catchError, map, mergeMap, tap } from 'rxjs/operators';
import { setEdqsEnabled, setNullsOrderStrategy } from '@shared/models/page/page-link';
import { LoginRequest, LoginResponse, PublicLoginRequest } from '@shared/models/login.models';
import { Router, UrlTree } from '@angular/router';
import { PRIMARY_OUTLET, Router, UrlTree } from '@angular/router';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from '../http/http-utils';
import { UserService } from '../http/user.service';
import { Store } from '@ngrx/store';
@ -281,24 +281,12 @@ export class AuthService {
} else if (authState.authUser.authority === Authority.MFA_CONFIGURATION_TOKEN) {
result = this.router.parseUrl('login/force-mfa');
} else if (!path || path === 'login' || this.forceDefaultPlace(authState, path, params)) {
if (this.redirectUrl) {
const redirectUrl = this.redirectUrl;
this.redirectUrl = null;
const redirectUrl = this.redirectUrl;
this.redirectUrl = null;
if (redirectUrl && !authState.authUser.isPublic && this.isDeepLink(redirectUrl)) {
result = this.router.parseUrl(redirectUrl);
} else {
result = this.router.parseUrl('home');
}
if (authState.authUser.authority === Authority.TENANT_ADMIN || authState.authUser.authority === Authority.CUSTOMER_USER) {
if (this.userHasDefaultDashboard(authState)) {
const dashboardId = authState.userDetails.additionalInfo.defaultDashboardId;
if (authState.forceFullscreen) {
result = this.router.parseUrl(`dashboard/${dashboardId}`);
} else {
result = this.router.parseUrl(`dashboards/${dashboardId}`);
}
} else if (authState.authUser.isPublic && authState.lastPublicDashboardId) {
result = this.router.parseUrl(`dashboard/${authState.lastPublicDashboardId}`);
}
result = this.defaultPlaceUrl(authState);
}
}
} else {
@ -339,6 +327,23 @@ export class AuthService {
}));
}
private defaultPlaceUrl(authState: AuthState): UrlTree {
if (authState.authUser.authority === Authority.TENANT_ADMIN || authState.authUser.authority === Authority.CUSTOMER_USER) {
if (this.userHasDefaultDashboard(authState)) {
const dashboardId = authState.userDetails.additionalInfo.defaultDashboardId;
return this.router.parseUrl(authState.forceFullscreen ? `dashboard/${dashboardId}` : `dashboards/${dashboardId}`);
} else if (authState.authUser.isPublic && authState.lastPublicDashboardId) {
return this.router.parseUrl(`dashboard/${authState.lastPublicDashboardId}`);
}
}
return this.router.parseUrl('home');
}
private isDeepLink(url: string): boolean {
const segments = this.router.parseUrl(url).root.children[PRIMARY_OUTLET]?.segments.map(segment => segment.path) ?? [];
return segments.length > 0 && segments[0] !== 'login' && !(segments.length === 1 && segments[0] === 'home');
}
private loadUser(doTokenRefresh): Observable<AuthPayload> {
const authUser = getCurrentAuthUser(this.store);
if (!authUser) {

4
ui-ngx/src/app/core/services/ai-chats.service.ts

@ -144,7 +144,7 @@ export class AiChatsService {
});
}
levelOf(chat: ChatInfo): ChatLevel | null {
levelOf(chat: ChatInfo, ignoreOpen = false): ChatLevel | null {
if (this._waiting().has(chat.id)) {
return 'needs';
}
@ -154,7 +154,7 @@ export class AiChatsService {
if (this._failed().has(chat.id)) {
return 'error';
}
if (this._open().has(chat.id)) {
if (!ignoreOpen && this._open().has(chat.id)) {
return chat.status === 'FAILED' ? 'error' : null;
}
return chat.status === 'NEEDS_YOU' ? 'needs' : chat.status === 'NO_DATA' ? 'nodata' : chat.status === 'RUNNING' ? 'running' : chat.status === 'FAILED' ? 'error' : null;

3
ui-ngx/src/app/core/services/ai-slash.service.ts

@ -50,7 +50,8 @@ export class AiSlashService {
private onKeydown(event: KeyboardEvent): void {
if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey || event.defaultPrevented || this.dialog.openDialogs.length
|| (event.target as HTMLElement)?.closest?.('input, textarea, select, [contenteditable]')) {
|| (event.target as HTMLElement)?.closest?.('input, textarea, select, [contenteditable], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"]')
|| document.querySelector('.cdk-overlay-container .mat-mdc-select-panel, .cdk-overlay-container .mat-mdc-menu-panel, .cdk-overlay-container .mat-mdc-autocomplete-panel')) {
return;
}
const visible = Array.from(this.composers)

26
ui-ngx/src/app/core/services/ai-solutions.service.ts

@ -35,6 +35,7 @@ export class AiSolutionsService {
private _running = signal<ReadonlySet<string>>(new Set());
readonly running = this._running.asReadonly();
private _failed = signal<ReadonlyMap<string, string>>(new Map());
private _needs = signal<ReadonlySet<string>>(new Set());
private api = inject(SolutionsCreatorService);
private dialog = inject(DialogService);
@ -110,11 +111,29 @@ export class AiSolutionsService {
).subscribe();
}
setNeeds(solutionId: string | undefined, needs: boolean): void {
if (!solutionId || this._needs().has(solutionId) === needs) {
return;
}
if (needs && !['FAILED', 'RUNNING'].includes(this.find(solutionId)?.status)) {
this.update(solutionId, {status: 'NEEDS_YOU', statusReason: undefined});
}
this._needs.update(set => {
const next = new Set(set);
if (needs) {
next.add(solutionId);
} else {
next.delete(solutionId);
}
return next;
});
}
setRunning(solutionId: string | undefined, running: boolean): void {
if (!solutionId || this._running().has(solutionId) === running) {
return;
}
if (running) {
if (running && this.find(solutionId)?.status !== 'RUNNING') {
this.update(solutionId, {status: undefined, statusReason: undefined});
}
this._running.update(set => {
@ -126,6 +145,9 @@ export class AiSolutionsService {
}
return next;
});
if (!running && this.find(solutionId)?.status === 'RUNNING') {
this.followRunning();
}
}
isRunning(solutionId: string): boolean {
@ -155,7 +177,7 @@ export class AiSolutionsService {
return 'error';
}
if (open) {
return solution.status === 'FAILED' ? 'error' : null;
return solution.status === 'FAILED' ? 'error' : this._needs().has(solution.id) ? 'needs' : null;
}
return solution.status === 'NEEDS_YOU' ? 'needs' : solution.status === 'RUNNING' ? 'running' : solution.status === 'FAILED' ? 'error' : null;
}

93
ui-ngx/src/app/modules/home/components/ai/ai-action-detail.component.html

@ -52,25 +52,49 @@
}
}
@case ('values') {
@if (block.label) {
@if (block.entity) {
<p class="k-group-h">{{ entityName(block.entity) }}</p>
} @else if (block.label) {
<div class="k-detail-label">{{ say(block.label) }}</div>
}
<div class="k-tels">
<dl class="k-vals">
@for (row of block.rows; track $index) {
<span class="k-tel" [matTooltip]="row.time ? time(row.time) : ''" [matTooltipDisabled]="!row.time" matTooltipPosition="above"><code class="k-tel-key">{{ row.key }}</code><span class="k-tel-val">{{ row.value }}</span></span>
<dt><span class="k-key">{{ row.key }}</span></dt>
<dd [matTooltip]="row.time ? time(row.time) : ''" [matTooltipDisabled]="!row.time" matTooltipPosition="above">{{ row.value }}</dd>
}
</div>
</dl>
}
@case ('series') {
<div class="k-series">
@for (row of block.rows; track row.key) {
<div class="k-series-row">
<code class="k-tel-key">{{ row.key }}</code>
<svg class="k-series-spark" viewBox="0 0 96 20" preserveAspectRatio="none" aria-hidden="true"><path [attr.d]="row.path"></path></svg>
<span class="k-series-meta">{{ 'ai-assistant.detail.series' | translate:{points: row.points, min: number(row.min), max: number(row.max), last: number(row.last)} }}</span>
</div>
}
</div>
@if (block.entity) {
<p class="k-group-h">{{ entityName(block.entity) }}</p>
}
<table class="k-hist">
<thead>
<tr>
<th scope="col"><span class="tb-ai-sr-only">{{ 'ai-assistant.detail.history-key' | translate }}</span></th>
<th scope="col"><span class="tb-ai-sr-only">{{ 'ai-assistant.detail.history-curve' | translate }}</span></th>
<th scope="col" class="n">{{ 'ai-assistant.detail.history-last' | translate }}</th>
<th scope="col">{{ 'ai-assistant.detail.history-range' | translate }}</th>
</tr>
</thead>
<tbody>
@for (row of block.rows; track row.key) {
<tr>
<th scope="row"><span class="k-key">{{ row.key }}</span></th>
<td class="c">
<div class="tb-spark" role="img" [attr.aria-label]="row.key">
<svg class="tb-spark-svg" viewBox="0 0 300 60" preserveAspectRatio="none" aria-hidden="true"><path [attr.d]="row.path"></path></svg>
<span class="tb-spark-dot" [style.top]="'calc(' + row.dot + '% - 3px)'"></span>
</div>
</td>
<td class="n">{{ row.lastText ?? number(row.last) }}</td>
<td class="q">{{ row.changes !== undefined
? ('ai-assistant.detail.history-changes' | translate: {count: row.changes})
: ('ai-assistant.detail.history-span' | translate: {min: number(row.min), max: number(row.max)}) }}</td>
</tr>
}
</tbody>
</table>
}
@case ('keys') {
@if (block.label) {
@ -83,8 +107,43 @@
</div>
}
@case ('facts') {
@if (changeRows(block.rows); as changes) {
@if (changes.length) {
<div class="k-diff">
@for (change of changes; track $index) {
<div class="k-diff-f" [class.long]="change.long">
<div class="k-diff-l">{{ label(change) }}</div>
@if (change.images; as pair) {
<div class="k-diff-v k-img">
@if (pair.current) {
<img tbAiFadeIn [src]="pair.current | image: {preview: true, ignoreLoadingImage: true} | async" alt="">
} @else {
<span class="k-img-none"></span>
}
<mat-icon class="tb-mat-18" aria-hidden="true">arrow_forward</mat-icon>
<span class="tb-ai-sr-only">{{ 'ai-assistant.review.changes-to' | translate }}</span>
@if (pair.value) {
<img tbAiFadeIn [src]="pair.value | image: {preview: true, ignoreLoadingImage: true} | async" alt="">
} @else {
<span class="k-img-none"></span>
}
</div>
} @else {
<div class="k-diff-v" [class.mono]="change.mono">
<span class="k-diff-was">{{ change.was }}</span>
<span class="k-diff-to" aria-hidden="true">→</span>
<span class="tb-ai-sr-only">{{ 'ai-assistant.review.changes-to' | translate }}</span>
<span class="k-diff-now">{{ factValue(change) }}</span>
</div>
}
</div>
}
</div>
}
}
@if (plainRows(block.rows).length) {
<dl class="k-fields k-detail-facts">
@for (fact of block.rows; track $index) {
@for (fact of plainRows(block.rows); track $index) {
<dt>{{ label(fact) }}</dt>
<dd [class.mono]="fact.mono">
@if (fact.images; as pair) {
@ -121,6 +180,7 @@
</dd>
}
</dl>
}
}
@case ('list') {
@if (block.label) {
@ -139,7 +199,7 @@
@if (block.title) {
<div class="k-detail-label">{{ ('ai-assistant.action.' + block.title) | translate }}</div>
}
<pre><code [class]="'language-' + (block.lang || block.label.toLowerCase())" [attr.data-label]="block.lang ? codeLabel(block.label) : null">{{ block.text }}</code></pre>
<pre><code [class]="'language-' + (block.lang || block.label.toLowerCase())" [attr.data-label]="block.lang ? codeLabel(block.label) : null" data-fold>{{ block.text }}</code></pre>
}
@case ('links') {
<div class="k-detail-links">
@ -174,6 +234,9 @@
@case ('warning') {
<div class="k-warn-block" role="note"><span class="tb-ai-sr-only">{{ 'ai-assistant.detail.heads-up' | translate }}</span>@if (block.label) {<b>{{ say(block.label) }}</b> }@for (row of block.rows; track $index) {<span>{{ rowText(row) }}</span>@if (!$last) {<span>; </span>}}</div>
}
@case ('found') {
<p class="k-found">{{ say(block.text) }}</p>
}
@case ('note') {
<p class="k-detail-note">{{ say(block.text) }}</p>
}

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

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { aiTrueMinus } from '@home/components/ai/ai-text';
import { afterRenderEffect, ChangeDetectionStrategy, Component, computed, DestroyRef, effect, ElementRef, inject, input, signal, untracked } from '@angular/core';
import { ClipboardService } from 'ngx-clipboard';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@ -196,8 +197,11 @@ export class AiActionDetailComponent {
return new Date(ts).toLocaleString([], {dateStyle: 'short', timeStyle: 'short'});
}
number(value: number): string {
return Number.isInteger(value) ? String(value) : String(Math.round(value * 100) / 100);
number(value?: number): string {
if (value === undefined) {
return '';
}
return aiTrueMinus(Number.isInteger(value) ? String(value) : String(Math.round(value * 100) / 100));
}
private rememberedTab(): string | null {
@ -208,10 +212,22 @@ export class AiActionDetailComponent {
writeStored(PROTOCOL_KEY, label);
}
changeRows(rows: AiDetailFact[]): AiDetailFact[] {
return rows.filter(row => row.change);
}
plainRows(rows: AiDetailFact[]): AiDetailFact[] {
return rows.filter(row => !row.change);
}
entityName(entity: AiDetailEntity): string {
return this.nameOf(entity) ?? this.translate.instant('ai-assistant.detail.this', {what: this.typeWord(entity.entityType)});
}
private entityText(entity: AiDetailEntity): string {
const name = this.nameOf(entity);
if (name) {
return `'${name}'`;
return name;
}
return this.translate.instant('ai-assistant.detail.this', {what: this.typeWord(entity.entityType)});
}
@ -236,7 +252,13 @@ export class AiActionDetailComponent {
}
};
Object.values(view.hood?.params ?? {}).forEach(value => typeof value === 'object' && !isAiWordList(value) && want(value));
view.blocks.forEach(block => block.type === 'facts' && block.rows.forEach(fact => want(fact.entity)));
view.blocks.forEach(block => {
if (block.type === 'facts') {
block.rows.forEach(fact => want(fact.entity));
} else if (block.type === 'values' || block.type === 'series') {
want(block.entity);
}
});
if (!wanted.size) {
return;
}

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

@ -50,12 +50,15 @@ export interface AiDetailValue {
export interface AiDetailSeries {
key: string;
points: number;
min: number;
max: number;
last: number;
min?: number;
max?: number;
last?: number;
lastText?: string;
changes?: number;
from: number;
to: number;
path: string;
dot: number;
}
export interface AiDetailFact {
@ -68,6 +71,9 @@ export interface AiDetailFact {
secret?: boolean;
images?: {current?: string; value?: string};
chip?: {icon?: string; image?: string};
change?: boolean;
was?: string;
long?: boolean;
}
export interface AiDetailCommand {
@ -85,8 +91,8 @@ export interface AiDetailLink {
export type AiDetailBlock =
| {type: 'records'; label?: AiDetailText; rows: AiDetailRecord[]; total?: number}
| {type: 'hub'; rows: AiDetailHubItem[]}
| {type: 'values'; label?: AiDetailText; rows: AiDetailValue[]}
| {type: 'series'; rows: AiDetailSeries[]}
| {type: 'values'; label?: AiDetailText; entity?: AiDetailEntity; rows: AiDetailValue[]}
| {type: 'series'; entity?: AiDetailEntity; rows: AiDetailSeries[]}
| {type: 'keys'; label?: AiDetailText; keys: string[]}
| {type: 'facts'; rows: AiDetailFact[]}
| {type: 'list'; label?: AiDetailText; rows: Array<string | AiDetailText>}
@ -95,6 +101,7 @@ export type AiDetailBlock =
| {type: 'markdown'; text: string}
| {type: 'code'; label: string; text: string; lang?: string; title?: string}
| {type: 'note'; text: AiDetailText}
| {type: 'found'; text: AiDetailText}
| {type: 'text'; text: string}
| {type: 'json'; label: string; text: string}
| {type: 'images'; rows: AiDetailImage[]}
@ -121,8 +128,10 @@ export interface AiStepView {
const ASKED_FOR: Record<string, string> = {
'search-named': 'named', 'search-typed': 'typed', 'search-text': 'text', 'search-related-from': 'related-from',
'search-related-to': 'related-to', 'search-alarms-of': 'alarms-of', 'read-attributes-scope': 'attributes-scope',
'search-alarms': 'alarms', 'search-alarms-on': 'alarms-on', 'search-alarms-filter-on': 'alarms-filter-on', 'search-alarms-window': 'alarms-window',
'search-alarms-filter-window': 'alarms-filter-window', 'search-alarms-on-window': 'alarms-on-window', 'search-alarms-filter-on-window': 'alarms-filter-on-window',
'read-history': 'history', 'read-history-keys': 'history-keys', 'read-latest-keys': 'latest-keys', 'iot-hub-query': 'query',
'search-web': 'query'
'search-web': 'query', 'read-widget-parts': 'widget'
};
export function aiStepView(action: AiAction, names: AiDetailNames): AiStepView {
@ -144,6 +153,8 @@ export function aiStepView(action: AiAction, names: AiDetailNames): AiStepView {
const K = 'ai-assistant.detail.';
const ALARM_FILTER_WORDS = new Set(['ACTIVE', 'CLEARED', 'ACK', 'UNACK', 'CRITICAL', 'MAJOR', 'MINOR', 'WARNING', 'INDETERMINATE']);
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const OK_ID = /^OK:\s*([0-9a-z_-]+)/i;
@ -414,38 +425,64 @@ function timeOf(ts: unknown): number | undefined {
return typeof value === 'number' && Number.isFinite(value) && value > 1e11 ? value : undefined;
}
function sparkPath(values: number[], times: number[]): {path: string; dot: number} {
const width = 300;
const height = 60;
const pad = 6;
const from = times[0];
const span = times[times.length - 1] - from || 1;
const min = Math.min(...values);
const range = Math.max(...values) - min || 1;
const y = (value: number) => height - pad - (value - min) / range * (height - 2 * pad);
const path = values.map((value, index) =>
`${index ? 'L' : 'M'}${((times[index] - from) / span * width).toFixed(1)} ${y(value).toFixed(1)}`).join('');
return {path, dot: Math.round(y(values[values.length - 1]) / height * 100)};
}
function series(key: string, points: Array<[number, number]>): AiDetailSeries {
const sorted = [...points].sort((a, b) => a[0] - b[0]);
const values = sorted.map(point => point[1]);
const min = Math.min(...values);
const max = Math.max(...values);
const from = sorted[0][0];
const to = sorted[sorted.length - 1][0];
const width = 96;
const height = 20;
const span = to - from || 1;
const range = max - min || 1;
const path = sorted.map(([ts, value], index) =>
`${index ? 'L' : 'M'}${((ts - from) / span * width).toFixed(1)} ${(height - 1 - (value - min) / range * (height - 2)).toFixed(1)}`).join('');
return {key, points: sorted.length, min, max, last: sorted[sorted.length - 1][1], from, to, path};
}
function telemetry(result: Values): AiDetailBlock[] {
const times = sorted.map(point => point[0]);
return {key, points: sorted.length, min: Math.min(...values), max: Math.max(...values), last: values[values.length - 1],
from: times[0], to: times[times.length - 1], ...sparkPath(values, times)};
}
function changesSeries(key: string, points: Array<[number, unknown]>): AiDetailSeries {
const sorted = [...points].sort((a, b) => a[0] - b[0]);
const words = sorted.map(point => aiValueText(point[1]));
const levels = [...new Set(words)];
const changes = words.filter((word, index) => index && word !== words[index - 1]).length;
const times = sorted.map(point => point[0]);
return {key, points: sorted.length, lastText: words[words.length - 1], changes, from: times[0], to: times[times.length - 1],
...sparkPath(words.map(word => levels.indexOf(word)), times)};
}
function telemetry(result: Values, entityOf?: (id: string) => AiDetailEntity): AiDetailBlock[] {
const ids = Object.keys(result);
if (entityOf && ids.length && ids.every(id => UUID.test(id) && isObject(result[id]))) {
return ids.flatMap(id => telemetry(result[id] as Values).map(block =>
block.type === 'values' || block.type === 'series' ? {...block, entity: entityOf(id)} : block));
}
const latest: AiDetailValue[] = [];
const history: AiDetailSeries[] = [];
const other: AiDetailValue[] = [];
const add = (key: string, points: Array<[number, unknown]>) => {
const numbers = points.map(([ts, value]) => [ts, typeof value === 'boolean' ? NaN : Number(value)] as [number, number]);
if (points.length > 1 && numbers.every(([, value]) => Number.isFinite(value))) {
history.push(series(key, numbers));
} else if (points.length > 1) {
history.push(changesSeries(key, points));
} else if (points.length) {
latest.push({key, value: aiValueText(points[0][1]), time: points[0][0]});
}
};
for (const [key, data] of Object.entries(result)) {
if (isObject(data) && 'value' in data) {
latest.push({key, value: aiValueText(data.value), time: timeOf(data.ts)});
continue;
}
if (Array.isArray(data) && data.every(point => isObject(point) && 'ts' in point)) {
const numbers = data.map(point => [timeOf(point.ts), Number(point.value)] as [number, number]).filter(([ts, value]) => ts && Number.isFinite(value));
if (numbers.length > 1) {
history.push(series(key, numbers));
} else if (data.length) {
latest.push({key, value: aiValueText(data[0].value), time: timeOf(data[0].ts)});
}
add(key, data.map(point => [timeOf(point.ts), point.value] as [number, unknown]).filter(([ts]) => !!ts));
continue;
}
if (!isObject(data)) {
@ -453,12 +490,8 @@ function telemetry(result: Values): AiDetailBlock[] {
continue;
}
const entries = Object.entries(data).filter(([ts]) => timeOf(ts));
const numbers = entries.map(([ts, value]) => [timeOf(ts), Number(value)] as [number, number]).filter(([, value]) => Number.isFinite(value));
if (entries.length > 1 && numbers.length === entries.length) {
history.push(series(key, numbers));
} else if (entries.length) {
const [ts, value] = entries.sort((a, b) => Number(b[0]) - Number(a[0]))[0];
latest.push({key, value: aiValueText(value), time: timeOf(ts)});
if (entries.length) {
add(key, entries.map(([ts, value]) => [timeOf(ts), value] as [number, unknown]));
} else {
other.push({key, value: aiValueText(data)});
}
@ -513,6 +546,16 @@ function recordOf(row: Values, entityType: string): AiDetailRecord | null {
return {entityType: entityType === 'ALARM_RULE' ? 'ALARM_RULE' : entityType, id: idOf(row.id), name, meta: meta || undefined};
}
function withoutCommonMeta(rows: AiDetailRecord[]): AiDetailRecord[] {
if (rows.length < 2) {
return rows;
}
const counts = new Map<string, number>();
rows.forEach(row => row.meta && counts.set(row.meta, (counts.get(row.meta) ?? 0) + 1));
const common = [...counts].find(([, count]) => count > rows.length / 2)?.[0];
return common ? rows.map(row => row.meta === common ? {...row, meta: undefined} : row) : rows;
}
function searchEntities(values: Values, result: unknown, names: AiDetailNames): AiDetailView {
const filter = isObject(values.entityFilter) ? values.entityFilter : {};
const type = searchType(values);
@ -534,9 +577,18 @@ function searchEntities(values: Values, result: unknown, names: AiDetailNames):
} else if (str(values.pageLink?.textSearch)) {
key = 'search-text';
params.text = values.pageLink.textSearch;
} else if (values.filterType === 'alarm' && Array.isArray(filter.originatorIds) && filter.originatorIds.length === 1) {
key = 'search-alarms-of';
params.entity = entity(filter.originatorIds[0], filter.originatorType, names);
} else if (values.filterType === 'alarm') {
const words = [...(Array.isArray(filter.severityList) ? filter.severityList : []), ...(Array.isArray(filter.statusList) ? filter.statusList : [])]
.map(word => str(word)?.toUpperCase()).filter(word => !!word && ALARM_FILTER_WORDS.has(word)).map(word => K + 'alarm-filter.' + word);
const one = Array.isArray(filter.originatorIds) && filter.originatorIds.length === 1;
const window = timeOf(filter.startTs) ? `${dateText(timeOf(filter.startTs))} – ${endText(filter.endTs)}` : undefined;
const parts = [words.length ? 'filter' : '', one ? 'on' : '', window ? 'window' : ''].filter(Boolean);
if (parts.length) {
key = parts.length === 1 && parts[0] === 'filter' ? 'search-alarms' : 'search-alarms-' + parts.join('-');
params.filter = {words, commas: true};
params.entity = one ? entity(filter.originatorIds[0], filter.originatorType, names) : '';
params.window = window ?? '';
}
}
const sections = searchSections(result);
if (!sections.length) {
@ -548,13 +600,13 @@ function searchEntities(values: Values, result: unknown, names: AiDetailNames):
const data: unknown[] = Array.isArray(section.page.data) ? section.page.data : [];
if (!data.length) {
if (sections.length === 1) {
blocks.push({type: 'note', text: text('nothing-found')});
blocks.push({type: 'found', text: text(entityType === 'ALARM' ? 'no-alarms' : 'nothing-found')});
}
continue;
}
const groupType = entityType === 'ENTITY_GROUP' ? str(filter.groupType)?.toUpperCase() : undefined;
const rows = data.filter(isObject).map(row => recordOf(row, entityType)).filter(Boolean).slice(0, MAX_ROWS)
.map(row => groupType ? {...row, groupType} : row);
const rows = withoutCommonMeta(data.filter(isObject).map(row => recordOf(row, entityType)).filter(Boolean).slice(0, MAX_ROWS)
.map(row => groupType ? {...row, groupType} : row));
const total = typeof section.page.totalElements === 'number' ? section.page.totalElements : data.length;
blocks.push(rows.length
? {type: 'records', label: sections.length > 1 ? text('what-found.' + (SEARCHED[entityType] ?? 'entities')) : undefined, rows, total}
@ -1160,10 +1212,14 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
return {hood: text('read-relations', {entity: target}), blocks: relations(result)};
case 'read_timeseries': {
const keys = Array.isArray(values.keys) ? values.keys.join(', ') : '';
const ids = Array.isArray(values.entityIds) ? values.entityIds.map(idOf).filter(Boolean) : [];
const subject: AiDetailParam = ids.length > 1
? {words: ids.map(id => names.get(id)?.name).every(Boolean) ? ids.map(id => names.get(id).name) : ['ai-assistant.detail.several'], commas: true}
: ids.length ? of(ids[0], values.entityType) : target;
const hood = values.mode === 'HISTORY' || values.startTime
? text(keys ? 'read-history-keys' : 'read-history', {entity: target, keys, from: dateText(values.startTime), to: endText(values.endTime)})
: text(keys ? 'read-latest-keys' : 'read-latest', {entity: target, keys});
const blocks = isObject(result) ? telemetry(result) : generic(result, 'result');
? text(keys ? 'read-history-keys' : 'read-history', {entity: subject, keys, from: dateText(values.startTime), to: endText(values.endTime)})
: text(keys ? 'read-latest-keys' : 'read-latest', {entity: subject, keys});
const blocks = isObject(result) ? telemetry(result, id => of(id, values.entityType)) : generic(result, 'result');
return {hood, blocks: isObject(result) && !Object.keys(result).length ? [{type: 'note', text: text('no-data')}] : blocks};
}
case 'read_timeseries_keys': {
@ -1788,7 +1844,7 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
return {hood, blocks: generic(raw, 'result')};
}
const warnings = Array.isArray(raw.warnings) ? raw.warnings.map(item => String(item)) : [];
const rows = facts(raw, ['typeParameters', 'warnings', 'note', 'next']);
const rows = facts(raw, ['typeParameters', 'warnings', 'note', 'next', 'id', 'name', 'fqn', 'type']);
return {hood, blocks: [...(rows.length ? [{type: 'facts' as const, rows}] : []),
...(warnings.length ? [{type: 'list' as const, label: text('widget-warnings'), rows: warnings.slice(0, MAX_ROWS)}] : [])]};
}

6
ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts

@ -183,8 +183,12 @@ export class AiActionLineComponent {
const facts = this.facts();
const stages = this.action().stages ?? [];
const done = this.action().status === 'SUCCESS' && this.action().progress ? [...stages, this.action().progress] : stages;
const labelOf = (fact: AiDetailFact) => (fact.raw ? fact.label : this.translate.instant(fact.label) as string).trim().toLowerCase();
const changed = new Set(facts.filter(fact => fact.change).map(labelOf));
const own = changed.size ? view.blocks.map(block => block.type === 'facts' ? {...block, rows: block.rows.filter(fact => !changed.has(labelOf(fact)))} : block)
.filter(block => block.type !== 'facts' || block.rows.length) : view.blocks;
const blocks = [...(done.length ? [{type: 'list' as const, label: {key: 'ai-assistant.detail.stages'}, rows: done}] : []),
...view.blocks, ...(facts.length ? [{type: 'facts' as const, rows: facts}] : [])];
...own, ...(facts.length ? [{type: 'facts' as const, rows: facts}] : [])];
return {...view, blocks};
});

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

@ -43,7 +43,7 @@
@for (change of changes; track $index) {
<div class="k-diff-f" [class.long]="isLongChange(change)">
<div class="k-diff-l">@if (change.labelCode) { <code>{{ change.label }}</code> } @else { {{ change.label }} }</div>
<div class="k-diff-v">
<div class="k-diff-v" [class.pics]="change.image || change.currentImage">
<span class="k-diff-was">@if (change.currentImage) { <img tbAiFadeIn class="k-img was" [src]="change.current | image: {preview: true, ignoreLoadingImage: true} | async" alt=""> } @else { {{ change.current }} }</span>
<span class="k-diff-to" aria-hidden="true">→</span>
<span class="tb-ai-sr-only">{{ 'ai-assistant.review.changes-to' | translate }}</span>

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

@ -219,6 +219,8 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
@Input() completedExecution: ToolExecutionResult | null = null;
@Input() durationMs?: number;
@Input() autoApprove = false;
@Input() answered = false;
@ -269,6 +271,9 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
this.denying = false;
this.state = 'denied';
}
if (changes.durationMs && this.handedOver && !changes.completedExecution) {
this.handedOver = {...this.handedOver, durationMs: this.durationMs};
}
if (changes.completedExecution && this.completedExecution?.executionId === this.data.executionId) {
const result = this.completedExecution;
if (result.approvalStatus === ToolApprovalResult.TIMEOUT) {
@ -285,6 +290,7 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
result: result.result,
status: result.executionStatus,
startedAt: this.data.time ?? Date.now(),
durationMs: this.durationMs ?? result.durationMs,
affectedEntities: result.affectedEntities ?? []
};
this.handedFacts = DETAILED_TOOLS.has(this.data.tool ?? '') ? [] : this.reviewFacts();
@ -398,8 +404,8 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
...this.rows('FACT', field => !isBlock(field)).map(row => row.image ? {label: row.label, raw: true, images: {value: row.value}}
: {label: row.label, raw: true, value: row.value, mono: row.valueCode, chip: row.chip}),
...this.rows('CHANGE', field => !isBlock(field)).map(row => row.image || row.currentImage
? {label: row.label, raw: true, images: {current: row.currentImage ? row.current : undefined, value: row.image ? row.value : undefined}}
: {label: row.label, raw: true, value: `${row.current ?? '—'} → ${row.value}`, mono: row.valueCode})
? {label: row.label, raw: true, change: true, images: {current: row.currentImage ? row.current : undefined, value: row.image ? row.value : undefined}}
: {label: row.label, raw: true, change: true, was: row.current ?? '—', value: row.value, mono: row.valueCode, long: this.isLongChange(row)})
];
}

1
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html

@ -137,6 +137,7 @@
<tb-ai-approval-card
[data]="getApprovalData(msg)"
[completedExecution]="getCompletedExecution(msg)"
[durationMs]="toolDurations[msg.data.executionId]"
[autoApprove]="autoApprove"
[answered]="!!denyReasons[getApprovalData(msg).executionId]"
[busy]="loading"

2
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts

@ -100,6 +100,8 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
@Input() loading = false;
@Input() additionalStyles: string[];
@Input() completedExecutions: Record<string, ToolExecutionResult> = {};
@Input() toolDurations: Record<string, number> = {};
@Input() autoApprove = false;
@Input() scrollContainer: HTMLElement;
@Input() initialScroll: 'lastUserMessage' | 'bottom' = 'lastUserMessage';

1
ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html

@ -72,6 +72,7 @@
[messages]="messages()"
[loading]="loading()"
[completedExecutions]="completedExecutions()"
[toolDurations]="toolDurations()"
[autoApprove]="autoApprove()"
[additionalStyles]="markdownStyles"
[scrollContainer]="chatArea"

72
ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts

@ -93,6 +93,11 @@ interface AiGetStartedExample {
file?: boolean;
}
interface AiRefusal {
undo: () => void;
rerun?: boolean;
}
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'tb-ai-chat',
@ -184,6 +189,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
historyLoading = signal(false);
completedExecutions = signal<Record<string, ToolExecutionResult>>({});
toolDurations = signal<Record<string, number>>({});
chat = computed(() => {
const id = this.chatId();
@ -397,7 +403,6 @@ export class AiChatComponent implements OnInit, OnDestroy {
});
private answeredApprovals = signal<ReadonlySet<string>>(new Set());
private rerun: (() => void) | null = null;
dockShown = signal(false);
@ -507,6 +512,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.fileOpen.set(false);
}
this.unlisting.set(null);
this.newChatAutoApprove.set(false);
this.unlisted.set(new Set(AiChatComponent.storedList(chatId ? AiChatComponent.UNLISTED_KEY + chatId : null)));
this.show(chatId);
});
@ -877,13 +883,18 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.sendWhileWorking(prompt, userMessage);
return;
}
this.sendMessage(prompt).subscribe({
const closed = this.closeWaitingCards();
this.sendMessage(prompt, undefined, {undo: () => {
this.reopenWaitingCards(closed);
this.restoreLastPrompt();
}}).subscribe({
error: err => {
if (this.isConnectionLost(err) && this.chatId()) {
this.setNotice('warn', 'wifi_off', 'connection-lost');
this.resumeTurn(this.chatId(), true);
return;
}
this.reopenWaitingCards(closed);
this.onSendFailed(err, userMessage);
}
});
@ -914,6 +925,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.messages.set([]);
this.limitOut.set(null);
this.completedExecutions.set({});
this.toolDurations.set({});
this.denyReasons.set({});
this.answeredApprovals.set(new Set());
this.historyLoading.set(!!chatId);
@ -935,18 +947,17 @@ export class AiChatComponent implements OnInit, OnDestroy {
const failed = again === 'retry' ? this.messages().filter(message => (message as GeneralChatMessage).status === 'INCOMPLETE') : [];
const marker: GeneralChatMessage | null = again === 'retry' || again === 'resume'
? {from: 'AI', content: '', status: again === 'retry' ? 'RETRIED' : 'RESUMED', time: Date.now()} : null;
const closed = again === 'retry' || again === 'resume' ? this.closeWaitingCards() : [];
const undo = () => {
this.messages.update(list => [...list.filter(message => message !== marker), ...failed]);
this.reopenWaitingCards(closed);
if (executionId) {
this.reopenCard(executionId);
}
};
this.clearPassingNotice();
this.messages.update(list => [...list.filter(message => !failed.includes(message)), ...(marker ? [marker] : [])]);
this.rerun = undo;
this.sendMessage({message: '', resources: []}, {again, executionId, reason}).pipe(
finalize(() => this.rerun = null)
).subscribe({
this.sendMessage({message: '', resources: []}, {again, executionId, reason}, {undo, rerun: true}).subscribe({
error: err => {
if (this.isConnectionLost(err) && this.chatId()) {
this.setNotice('warn', 'wifi_off', 'connection-lost');
@ -979,7 +990,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.chats.clearFailure(chatId);
this.startLoading();
}
return this.handleChatEvent(event);
return this.handleChatEvent(event, {undo: () => this.restoreMessage(userMessage)});
}),
finalize(() => {
if (ownTurn) {
@ -1038,7 +1049,8 @@ export class AiChatComponent implements OnInit, OnDestroy {
return request;
}
private sendMessage(prompt: AiPromptMessage, again?: {again: AiRunAgain; executionId?: string; reason?: string}): Observable<ChatEvent> {
private sendMessage(prompt: AiPromptMessage, again?: {again: AiRunAgain; executionId?: string; reason?: string},
refused?: AiRefusal): Observable<ChatEvent> {
this.messageCancelled = false;
const startOrContinue$ = this.chatId()
? of(null)
@ -1051,9 +1063,6 @@ export class AiChatComponent implements OnInit, OnDestroy {
);
const request = this.chatRequest(prompt);
this.limitOut.set(null);
if (!again || again.again === 'retry' || again.again === 'resume') {
this.closeWaitingCards();
}
if (again) {
request.again = again.again;
if (again.executionId) {
@ -1072,7 +1081,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
}),
switchMap(() => this.aiChat.sendChatMessage(this.chatId(), request, {ignoreLoading: true, ignoreErrors: true})),
takeUntil(this.cancelMessage$),
concatMap(event => this.handleChatEvent(event)),
concatMap(event => this.handleChatEvent(event, refused)),
finalize(() => this.stopLoading())
);
}
@ -1138,7 +1147,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
});
}
private handleChatEvent(event: ChatEvent): Observable<ChatEvent> {
private handleChatEvent(event: ChatEvent, refused?: AiRefusal): Observable<ChatEvent> {
if (event.event && event.event !== 'error' && event.event !== 'chatTitleGenerated') {
this.freshChatId = null;
}
@ -1212,13 +1221,13 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.messages.update(list => [...this.endStreaming(list), {from: 'AI', content: '', status: 'INCOMPLETE',
failure: {reason: 'CREDITS_USED_UP'}, time: Date.now()}]);
} else if (event.event === 'error' && event.data?.code) {
if (this.rerun) {
this.rerun();
if (refused) {
refused.undo();
} else {
this.restoreLastPrompt();
}
if (event.data.code === 'CREDITS_USED_UP') {
if (!this.rerun) {
if (!refused?.rerun) {
this.discardFreshChat();
}
this.creditsOut.set('POOL');
@ -1475,8 +1484,9 @@ export class AiChatComponent implements OnInit, OnDestroy {
}
private finishAction(finished: ToolFinished): void {
this.toolDurations.update(map => ({...map, [finished.executionId]: finished.durationMs}));
const known = this.messages().find(message => message.from === 'ACTION' && message.data.executionId === finished.executionId);
if (known?.from === 'ACTION' && known.data.status !== 'RUNNING') {
if (known?.from === 'ACTION' && known.data.status !== 'RUNNING' && (known.data.result !== undefined || !isKitCardTool(known.data.tool))) {
return;
}
if (finished.status === 'SUCCESS') {
@ -1517,11 +1527,21 @@ export class AiChatComponent implements OnInit, OnDestroy {
}
}
private closeWaitingCards(): void {
this.completedExecutions.update(map => {
const waiting = Object.keys(map).filter(id => map[id]?.approvalStatus === ToolApprovalResult.TIMEOUT);
return waiting.length ? {...map, ...Object.fromEntries(waiting.map(id => [id, {...map[id], approvalStatus: ToolApprovalResult.DENIED}]))} : map;
});
private closeWaitingCards(): string[] {
const map = this.completedExecutions();
const waiting = Object.keys(map).filter(id => map[id]?.approvalStatus === ToolApprovalResult.TIMEOUT);
if (waiting.length) {
this.completedExecutions.set({...map, ...Object.fromEntries(waiting.map(id => [id, {...map[id], approvalStatus: ToolApprovalResult.DENIED}]))});
}
return waiting;
}
private reopenWaitingCards(ids: string[]): void {
if (!ids.length) {
return;
}
this.completedExecutions.update(map => ({...map, ...Object.fromEntries(ids.filter(id => map[id])
.map(id => [id, {...map[id], approvalStatus: ToolApprovalResult.TIMEOUT}]))}));
}
private handleToolApproval(event: ToolExecutionRequestedEvent): void {
@ -1653,6 +1673,14 @@ export class AiChatComponent implements OnInit, OnDestroy {
return messages.slice(last + 1).some(message => message.from === 'ACTION' || message.from === 'APPROVAL');
}
private restoreMessage(userMessage: ChatMessage): void {
const content = (userMessage as GeneralChatMessage).content;
this.messages.update(list => list.filter(message => message !== userMessage));
if (content) {
setTimeout(() => this.promptInput?.setValue(content));
}
}
private restoreLastPrompt(): void {
const messages = this.messages();
const last = messages.map(message => message.from).lastIndexOf('USER');

3
ui-ngx/src/app/modules/home/components/ai/ai-code-block.ts

@ -200,6 +200,7 @@ function decorate(pre: HTMLElement, translate: TranslateService, copy: (text: st
const text = (pre.textContent ?? '').replace(/\n$/, '');
const file = pre.querySelector('code')?.getAttribute('data-file');
const noCopy = pre.querySelector('code')?.hasAttribute('data-nocopy');
const alwaysFolds = !!pre.querySelector('code')?.hasAttribute('data-fold');
const language = languageOf(pre);
const lang = language?.lang ?? 'text';
const shell = lang === 'shell' || lang === 'powershell';
@ -217,7 +218,7 @@ function decorate(pre: HTMLElement, translate: TranslateService, copy: (text: st
pre.className = 'tb-code';
pre.replaceChildren(code);
const lineCount = text.split('\n').length;
const folds = lineCount > FOLD_LINES && lang !== 'diff';
const folds = (lineCount > FOLD_LINES || alwaysFolds) && lang !== 'diff';
const block = element('div', 'tb-codeblock');
const wrapper = pre.closest('.code-wrapper');
if (wrapper) {

12
ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.html

@ -30,10 +30,14 @@
[value]="digits()" [disabled]="disabled()" [attr.aria-invalid]="wrong() || null"
[attr.aria-label]="'ai-assistant.question.hex-label' | translate: {question: question().question, label: ('ai-assistant.question.other-color-short' | translate)}"
(input)="typeHex(hexInput)" (blur)="checkHex(hexInput)" (keydown.enter)="hexEnter($event, hexInput)">
<button mat-icon-button type="button" [disabled]="disabled()"
[matTooltip]="'ai-assistant.question.pick-color' | translate" matTooltipPosition="above"
[attr.aria-label]="'ai-assistant.question.pick-color' | translate"
(click)="openPicker($any($event.currentTarget), hexInput)"><mat-icon>colorize</mat-icon></button>
<span class="k-hexf-pick">
<button mat-icon-button type="button" [disabled]="disabled()"
[matTooltip]="'ai-assistant.question.pick-color' | translate" matTooltipPosition="above"
[attr.aria-label]="'ai-assistant.question.pick-color' | translate"
(click)="openPicker(picker, hexInput)"><mat-icon>colorize</mat-icon></button>
<input #picker type="color" tabindex="-1" aria-hidden="true" [value]="hex() ?? '#000000'"
(input)="pickColor(picker, hexInput)">
</span>
</span>
</div>
@if (wrong()) {

41
ui-ngx/src/app/modules/home/components/ai/ai-color-field.component.ts

@ -1,10 +1,7 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, input, model, output, Renderer2, signal, ViewContainerRef } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, input, model, output, signal } from '@angular/core';
import { AiQuestion } from '@shared/models/solution-creator.models';
import { TbPopoverService } from '@shared/components/popover.service';
import { ColorPickerPanelComponent } from '@shared/components/color-picker/color-picker-panel.component';
import tinycolor from 'tinycolor2';
import { aiColorOf, aiHexOf, aiIsFree } from '@home/components/ai/ai-question.models';
export function aiColorReady(question: AiQuestion, value: string): boolean {
@ -29,9 +26,6 @@ export class AiColorFieldComponent {
enter = output<Event>();
private elementRef: ElementRef<HTMLElement> = inject(ElementRef);
private popoverService = inject(TbPopoverService);
private renderer = inject(Renderer2);
private viewContainerRef = inject(ViewContainerRef);
readonly colorOf = aiColorOf;
readonly wrong = signal(false);
@ -81,31 +75,20 @@ export class AiColorFieldComponent {
}
}
openPicker(trigger: HTMLElement, field: HTMLInputElement): void {
openPicker(picker: HTMLInputElement, field: HTMLInputElement): void {
if (this.disabled()) {
return;
}
if (this.popoverService.hasPopover(trigger)) {
this.popoverService.hidePopover(trigger);
return;
picker.value = aiHexOf(field.value) ?? '#000000';
try {
picker.showPicker();
} catch {
picker.click();
}
const popover = this.popoverService.displayPopover({
trigger,
renderer: this.renderer,
hostView: this.viewContainerRef,
componentType: ColorPickerPanelComponent,
preferredPlacement: ['bottomLeft', 'bottom', 'topLeft', 'top'],
context: {color: this.hex() ?? '#305680', disableAlpha: true, colorCancelButton: true},
showCloseButton: false,
popoverContentStyle: {padding: '12px 4px 12px 12px'},
isModal: true
});
popover.tbComponentRef.instance.popover = popover;
popover.tbComponentRef.instance.colorSelected.subscribe((color: string) => {
popover.hide();
field.value = tinycolor(color).toHex().toUpperCase();
this.typeHex(field);
});
popover.tbComponentRef.instance.colorCancelDialog.subscribe(() => popover.hide());
}
pickColor(picker: HTMLInputElement, field: HTMLInputElement): void {
field.value = picker.value.slice(1).toUpperCase();
this.typeHex(field);
}
}

16
ui-ngx/src/app/modules/home/components/ai/ai-date-panel.component.ts

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, inject } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, ViewChild } from '@angular/core';
import { MatCalendar } from '@angular/material/datepicker';
import { TbPopoverComponent } from '@shared/components/popover.component';
import { aiReadTime } from '@home/components/ai/ai-question.models';
@ -15,7 +16,9 @@ export interface AiPickedDay {
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class AiDatePanelComponent {
export class AiDatePanelComponent implements AfterViewInit {
@ViewChild(MatCalendar) calendar: MatCalendar<Date>;
selected: Date;
time = '9:00';
@ -26,6 +29,15 @@ export class AiDatePanelComponent {
timeWrong = false;
private cd = inject(ChangeDetectorRef);
private host: ElementRef<HTMLElement> = inject(ElementRef);
ngAfterViewInit(): void {
setTimeout(() => this.calendar?.focusActiveCell());
}
hasFocus(): boolean {
return this.host.nativeElement.contains(document.activeElement);
}
select(date: Date): void {
this.selected = date;

10
ui-ngx/src/app/modules/home/components/ai/ai-hand-over.component.html

@ -98,7 +98,7 @@
}
</ol>
}
@if (handOver().test; as test) {
@if (!handOver().waitFor && handOver().test; as test) {
<tb-ai-disclosure class="k-test" variant="section" [summary]="'ai-assistant.hand-over.test-first' | translate">
@if (test.hint) {
<p class="ob-hint">{{ test.hint }}</p>
@ -153,6 +153,14 @@
</button>
}
</div>
@if (handOver().test; as test) {
<tb-ai-disclosure class="k-test" variant="section" [summary]="'ai-assistant.hand-over.test-here' | translate">
@if (test.hint) {
<p class="ob-hint">{{ test.hint }}</p>
}
<div class="k-test-slot"></div>
</tb-ai-disclosure>
}
</div>
} @else if (waiting()) {
<div class="k-waitrow">

2
ui-ngx/src/app/modules/home/components/ai/ai-number-field.component.ts

@ -37,7 +37,7 @@ export class AiNumberFieldComponent {
const current = aiReadNumber(field.value, this.locale());
const base = isNaN(current) ? (this.question().number?.suggested ?? 0) : current;
const decimals = Math.max(aiStepDecimals(this.step()), isNaN(current) ? 0 : aiStepDecimals(current));
field.value = aiSayNumber(+(base + direction * this.step()).toFixed(decimals));
field.value = aiSayNumber(+(base + direction * this.step()).toFixed(decimals), this.locale());
this.touched.set(false);
this.value.set(field.value);
field.focus();

26
ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts

@ -16,8 +16,6 @@ import {
import { aiColorAnswer, aiColorReady } from '@home/components/ai/ai-color-field.component';
import { AiDatePanelComponent, AiPickedDay } from '@home/components/ai/ai-date-panel.component';
export { aiColorOf } from '@home/components/ai/ai-question.models';
const MULTI_SEPARATOR = ', ';
export function aiAnswersText(answers: AiQuestionAnswer[]): string {
@ -44,15 +42,23 @@ export function aiAnswersOf(content: string | undefined, questions: AiQuestion[]
const lines = content.split('\n').map(line => line.trim()).filter(Boolean);
const answers: AiQuestionAnswer[] = [];
for (const line of lines) {
const question = questions.find(item => line.startsWith(item.question.trim() + ' '));
if (!question) {
const found = questions.map(question => ({question, asked: askedPrefix(question).exec(line)})).find(item => !!item.asked);
if (!found) {
return null;
}
answers.push({question, answer: line.slice(question.question.trim().length).trim()});
answers.push({question: found.question, answer: line.slice(found.asked[0].length).trim()});
}
return answers.length ? answers : null;
}
function askedPrefix(question: AiQuestion): RegExp {
const escape = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const asked = question.parts?.length
? question.parts.map(part => part.severity ? '.+?' : escape(part.text ?? '')).join('')
: escape(question.question.trim());
return new RegExp('^' + asked.trim() + ' ');
}
function recommendedOf(question: AiQuestion): string[] {
const recommended = Array.isArray(question.recommended) ? question.recommended : question.recommended ? [question.recommended] : [];
return recommended.filter(label => question.options.some(option => option.label === label));
@ -130,7 +136,7 @@ export class AiQuestionComponent {
return typed;
}
const suggested = aiIsNumber(question) ? question.number?.suggested : undefined;
return suggested !== undefined && suggested !== null ? aiSayNumber(suggested) : '';
return suggested !== undefined && suggested !== null ? aiSayNumber(suggested, this.locale()) : '';
}
otherLabel(question: AiQuestion): string {
@ -182,7 +188,12 @@ export class AiQuestionComponent {
isModal: true
});
this.dayOpen.set(question.id);
popover.tbHideStart.subscribe(() => this.dayOpen.set(null));
popover.tbHideStart.subscribe(() => {
this.dayOpen.set(null);
if (popover.tbComponentRef?.instance.hasFocus() || document.activeElement === document.body) {
chip.focus();
}
});
popover.tbComponentRef.instance.popover = popover;
popover.tbComponentRef.instance.applied.subscribe((day: AiPickedDay) => {
this.days[question.id] = day;
@ -190,7 +201,6 @@ export class AiQuestionComponent {
this.typed.update(values => ({...values, [question.id]:
`${day.date.toLocaleDateString(this.locale(), {weekday: 'long', day: 'numeric', month: 'short'})}, ${day.time}`}));
popover.hide();
chip.focus();
});
}

21
ui-ngx/src/app/modules/home/components/ai/ai-question.models.ts

@ -51,18 +51,23 @@ export function aiKindOf(question: AiQuestion): AiQuestionKind {
return question.kind ?? aiQuestionKind(question);
}
export function aiSayNumber(value: number): string {
return String(value).replace('-', MINUS);
function commaDecimal(locale?: string): boolean {
return (1.5).toLocaleString(locale).charAt(1) === ',';
}
export function aiSayNumber(value: number, locale?: string): string {
const text = String(value).replace('-', MINUS);
return commaDecimal(locale) ? text.replace('.', ',') : text;
}
export function aiReadNumber(text: string, locale?: string): number {
let normalized = String(text ?? '').trim().replace(/[\s  ]/g, '').replace(MINUS, '-');
const commaDecimal = (1.5).toLocaleString(locale).charAt(1) === ',';
const thousands = /^-?\d{1,3}(,\d{3})+(\.\d+)?$/.test(normalized);
if (normalized.includes(',') && !normalized.includes('.') && (commaDecimal || !thousands)) {
normalized = normalized.replace(',', '.');
let normalized = String(text ?? '').trim().replace(/[\s\u00a0\u202f']/g, '').replace(MINUS, '-');
if (commaDecimal(locale)) {
const grouped = normalized.includes(',') || /^-?\d{1,3}(\.\d{3})+$/.test(normalized);
normalized = (grouped ? normalized.replace(/\./g, '') : normalized).replace(',', '.');
} else {
normalized = normalized.replace(/,/g, '');
const thousands = /^-?\d{1,3}(,\d{3})+(\.\d+)?$/.test(normalized);
normalized = normalized.includes(',') && !normalized.includes('.') && !thousands ? normalized.replace(',', '.') : normalized.replace(/,/g, '');
}
return /^[-+]?(\d+\.?\d*|\.\d+)$/.test(normalized) ? parseFloat(normalized) : NaN;
}

7
ui-ngx/src/app/modules/home/components/ai/ai-references.ts

@ -236,6 +236,13 @@ function replaceMatches(node: Text, pattern: RegExp, chip: (match: RegExpExecArr
export function decorateSeverities(root: HTMLElement, severities: string[] | undefined, label: (severity: string) => string): void {
if (aiHasSeverityMarks(root.textContent ?? '')) {
const lone = new RegExp('^\\s*' + SEVERITY_MARK.source + '\\s*$');
root.querySelectorAll('code').forEach(code => {
const match = !code.closest('pre') ? lone.exec(code.textContent ?? '') : null;
if (match) {
code.replaceWith(severityChip(match[1], label));
}
});
textNodes(root, MARK_SKIP).forEach(node => replaceMatches(node, SEVERITY_MARK, match => severityChip(match[1], label)));
decorateAlarmTables(root);
return;

42
ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.ts

@ -540,6 +540,13 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
untracked(() => this.aiSolutions.setRunning(id, running));
});
private needsEffect = effect(onCleanup => {
const id = this.info()?.id;
const needs = this.level() === 'needs';
untracked(() => this.aiSolutions.setNeeds(id, needs));
onCleanup(() => untracked(() => this.aiSolutions.setNeeds(id, false)));
});
mainUser = computed<{id: string; name: string} | null>(() => {
const result = this.info()?.metadata?.installResult;
const main = result?.mainDashboardId?.id;
@ -1361,6 +1368,11 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}
}
this.freshSolutionId = null;
if (err?.status === 0 && this.solutionId && this.solutionId !== NEW_SOLUTION_ID) {
this.setNotice('warn', 'wifi_off', 'connection-lost');
this.recoverDroppedMessage(msg);
return EMPTY;
}
if (!this.wasStopped(err, () => this.sendMessage(msg, resources).subscribe(() => {})) && !this.noticeFor(err)) {
this.showErrorMessage(err);
}
@ -1640,6 +1652,36 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
});
}
private recoverDroppedMessage(msg: string): void {
const solutionId = this.solutionId;
const step = this.solutionStep();
const sent = this.messages().filter((message, at) => message.from === 'USER' && this.messageSteps[at] === step).length;
timer(0, SolutionChatComponent.DESIGN_POLL_MS).pipe(
take(SolutionChatComponent.DESIGN_POLL_LIMIT),
switchMap(() => forkJoin([
this.solutionCreator.getSolutionById(solutionId, {ignoreLoading: true, ignoreErrors: true}),
this.aiSolutions.load()
]).pipe(catchError(() => EMPTY))),
take(1),
takeUntil(this.cancelPending$),
takeUntilDestroyed(this.destroyRef)
).subscribe(([solution]) => {
if (this.solutionId !== solutionId) {
return;
}
this.notice.set(null);
const received = (solution.states?.[step]?.messages ?? []).filter(message => message.from === 'USER').length >= sent;
if (!received) {
this.restorePrompt(msg);
this.setNotice('warn', 'wifi_off', 'connection-failed');
return;
}
this.solutionInfo = solution;
this.aiSolutions.upsert(solution);
this.initPredefinedSolution();
});
}
private designStillRunning(): boolean {
return this.stepAwaitingReply(this.solutionInfo, this.solutionStep());
}

1
ui-ngx/src/app/modules/home/components/alarm/alarm-filter-config.component.html

@ -13,6 +13,7 @@
matTooltip="{{buttonDisplayValue}}"
matTooltipPosition="above"
mat-stroked-button
type="button"
(click)="toggleAlarmFilterPanel($event)">
<mat-icon>filter_list</mat-icon>{{buttonDisplayValue}}
</button>

4
ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html

@ -6,6 +6,8 @@
-->
<form class="tb-add-widget-dialog" [formGroup]="widgetFormGroup">
<!-- Disabled default button: stops Enter in a field from submitting the form -->
<button type="submit" disabled hidden></button>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<div class="tb-add-widget-toolbar">
<h2>{{'widget.add' | translate}}:</h2>
@ -52,6 +54,7 @@
[previewHeight]="widgetConfig.typeParameters.previewHeight">
<div class="tb-preview-panel-content">
<button mat-button
type="button"
(click)="previewMode = false">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
@ -79,6 +82,7 @@
</button>
}
<button mat-raised-button color="primary"
type="button"
(click)="add()"
[disabled]="!widgetFormGroup.valid">
{{ 'action.add' | translate }}

2
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html

@ -434,7 +434,7 @@
}
@if (!readonly && (hideToolbar || widgetEditMode)) {
<section data-html2canvas-ignore class="tb-header-buttons tb-enter-edit-mode flex flex-row flex-wrap items-end justify-start" *ngIf="!readonly && (hideToolbar || widgetEditMode)">
<button [class.!hidden]="isEdit"
<button [class.!hidden]="isEdit || aiAssistantPanelOpen"
color="tb-primary"
mat-mini-fab
class="tb-btn-header tb-btn-edit"

9
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { DashboardSelectComponent } from '@shared/components/dashboard-select.component';
import {
AfterViewInit,
ChangeDetectionStrategy,
@ -361,6 +362,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
@ViewChild('dashboardWidgetSelect') dashboardWidgetSelectComponent: DashboardWidgetSelectComponent;
@ViewChild(DashboardSelectComponent) dashboardSelect: DashboardSelectComponent;
private changeMobileSize = new Subject<boolean>();
constructor(protected store: Store<AppState>,
@ -435,6 +438,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.panelService.updatedDataBatches$.subscribe(affected => {
const dashboards = affected.filter(entityId => entityId.entityType === EntityType.DASHBOARD);
if (dashboards.length) {
this.dashboardSelect?.reload();
if (dashboards.some(dashboard => dashboard.id === this.currentDashboardId)) {
if (this.isEdit && !(this.editedWhileEmpty && this.dashboardUtils.isEmptyDashboard(this.dashboard))) {
this.panelService.keepEdits('dashboard', () => {
@ -444,7 +448,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} else {
this.reloadDashboard();
}
} else {
} else if (!this.isEdit) {
this.currentDashboardIdChanged(dashboards[0].id);
}
}
@ -707,6 +711,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.openAiAssistant = false;
this.isFullscreen = false;
if (this.isEdit) {
this.panelService.clearKeptEdits('dashboard');
}
this.isEdit = false;
this.isEditingWidget = false;
this.isEditingWidgetClosed = true;

9
ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.html

@ -1,10 +1,12 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<form [formGroup]="widgetFormGroup">
<button type="submit" disabled hidden aria-hidden="true"></button>
<fieldset [disabled]="isLoading$ | async">
<tb-widget-config
#widgetConfigComponent
@ -19,6 +21,7 @@
<div class="tb-widget-config-header-prefix">
@if (previewMode) {
<button mat-button
type="button"
(click)="previewMode = false">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
@ -29,6 +32,7 @@
class="gt-sm:!hidden"
[disabled]="!widgetFormGroup.valid"
mat-button color="primary"
type="button"
(click)="previewMode = true">
<mat-icon>visibility</mat-icon>
{{ 'widget-config.preview' | translate }}
@ -41,6 +45,7 @@
class="lt-md:!hidden"
[disabled]="!widgetFormGroup.valid"
mat-button color="primary"
type="button"
(click)="previewMode = true">
<mat-icon>visibility</mat-icon>
{{ 'widget-config.preview' | translate }}
@ -49,12 +54,14 @@
<div class="flex flex-row items-center justify-start gap-3">
<button [disabled]="!widgetFormGroup.dirty"
mat-stroked-button color="primary"
type="button"
(click)="onRevertWidgetConfig()">
<mat-icon>close</mat-icon>
{{ 'action.decline' | translate }}
</button>
<button [disabled]="!widgetFormGroup.valid || !widgetFormGroup.dirty"
mat-flat-button color="primary"
type="button"
(click)="onApplyWidgetConfig()">
<mat-icon>done</mat-icon>
{{ 'action.apply' | translate }}

14
ui-ngx/src/app/modules/home/components/entity/entity-details-page.component.ts

@ -97,6 +97,20 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
this.reload();
}
}));
this.subscriptions.push(this.panelService.updatedData$.subscribe(affected => {
const id = this.currentEntityId?.id;
if (!id || !affected.some(entityId => entityId.id === id)) {
return;
}
if (this.isEdit) {
this.panelService.keepEdits('entity', () => {
this.onToggleDetailsEditMode();
this.reload();
});
} else {
this.reload();
}
}));
this.subscriptions.push(this.route.paramMap.subscribe( paramMap => {
if (this.entitiesTableConfig) {
const entityType = this.entitiesTableConfig.entityType;

5
ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service';
import {
AfterViewInit,
@ -97,6 +98,8 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
this.currentEntityId = entityId;
if (this.currentEntityId) {
this.reloadEntity();
} else {
this.isEdit = false;
}
}
}

2
ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarm-count-basic-config.component.html

@ -18,7 +18,7 @@
<div class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

2
ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarms-table-basic-config.component.html

@ -16,7 +16,7 @@
<div class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

7
ui-ngx/src/app/modules/home/components/widget/config/basic/common/widget-actions-panel.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-form-panel" [class.stroked]="strokedPanel" (click)="manageWidgetActions()" style="cursor: pointer;">
@ -18,12 +19,12 @@
}
</mat-chip-listbox>
@if (!hasWidgetActions) {
<button mat-stroked-button color="primary">
<button type="button" mat-stroked-button color="primary">
{{ 'widget-config.add-action' | translate }}
</button>
}
@if (hasWidgetActions) {
<button mat-icon-button color="primary">
<button type="button" mat-icon-button color="primary">
<mat-icon>add</mat-icon>
</button>
}

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/custom-action-pretty-editor.component.html

@ -1,13 +1,14 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-custom-action-pretty" tb-fullscreen [fullscreen]="fullscreen">
<div class="tb-action-expand-button flex flex-row items-center justify-end" [class.tb-fullscreen-editor]="fullscreen">
@if (!fullscreen) {
<button
<button type="button"
class="lt-md:!hidden"
mat-icon-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
@ -17,7 +18,7 @@
</button>
}
@if (fullscreen) {
<button
<button type="button"
mat-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
matTooltipPosition="above"

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-widget-button-custom-style">
@ -17,7 +18,7 @@
[disabled]="state === widgetButtonState.disabled">
</tb-widget-button>
@if (modelValue) {
<button
<button type="button"
mat-icon-button
[matTooltip]="'widgets.button.clear-style' | translate"
matTooltipPosition="above"
@ -27,7 +28,7 @@
</button>
}
</div>
<button mat-icon-button
<button type="button" mat-icon-button
class="tb-mat-32"
#matIconButton
(click)="openButtonCustomStylePopup($event, matIconButton)">

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-toggle-custom-style.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-widget-button-custom-style">
@ -16,7 +17,7 @@
[disabled]="state === widgetButtonToggleState.disabled">
</tb-widget-button-toggle>
@if (modelValue) {
<button
<button type="button"
mat-icon-button
[matTooltip]="'widgets.button.clear-style' | translate"
matTooltipPosition="above"
@ -26,7 +27,7 @@
</button>
}
</div>
<button mat-icon-button
<button type="button" mat-icon-button
class="tb-mat-32"
#matIconButton
(click)="openButtonCustomStylePopup($event, matIconButton)">

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.html

@ -98,7 +98,7 @@
}
</div>
<div class="tb-add-color-range">
<button mat-stroked-button
<button type="button" mat-stroked-button
(click)="addRange()">
<mat-icon>add</mat-icon>
</button>

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/date-format-select.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<mat-form-field appearance="outline" subscriptSizing="dynamic" style="width: 100%;">
@ -11,13 +12,13 @@
}
</mat-select>
@if (dateFormatFormControl.value?.custom) {
<button #customFormatButton
<button type="button" #customFormatButton
matSuffix mat-icon-button (click)="openDateFormatSettingsPopup($event, customFormatButton)">
<tb-icon>edit</tb-icon>
</button>
}
@if (dateFormatFormControl.value?.auto && !dateFormatFormControl.value?.custom) {
<button #autoFormatButton
<button type="button" #autoFormatButton
matSuffix mat-icon-button (click)="openAutoFormatSettingsPopup($event, autoFormatButton)">
<tb-icon>edit</tb-icon>
</button>

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<ng-container [formGroup]="gradientFormGroup">
@ -83,7 +84,7 @@
</div>
</div>
}
<button class="tb-add-gradient"
<button type="button" class="tb-add-gradient"
mat-stroked-button
(click)="addGradient()">
<mat-icon>add</mat-icon>
@ -175,7 +176,7 @@
</div>
</div>
}
<button class="tb-add-gradient"
<button type="button" class="tb-add-gradient"
mat-stroked-button
(click)="addGradient(true)">
<mat-icon>add</mat-icon>

9
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/html/html-container-settings.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<ng-container [formGroup]="htmlContainerSettingsForm">
@ -14,7 +15,7 @@
</div>
<div class="tb-html-container-settings-panel flex flex-1 flex-col" tb-fullscreen [fullscreen]="fullscreen">
<div class="tb-action-expand-button flex flex-row items-center justify-end">
<button mat-stroked-button
<button type="button" mat-stroked-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
matTooltipPosition="above"
(click)="toggleFullScreen()">
@ -51,7 +52,7 @@
{{ 'widget.resource-is-extension' | translate }}
</mat-checkbox>
}
<button mat-icon-button color="primary"
<button type="button" mat-icon-button color="primary"
(click)="removeResource(i)"
matTooltip="{{'widget.remove-resource' | translate}}"
matTooltipPosition="above">
@ -64,7 +65,7 @@
class="tb-prompt flex items-center justify-center">widgets.html-container.no-resources</span>
}
<div>
<button mat-raised-button color="primary"
<button type="button" mat-raised-button color="primary"
(click)="addResource()"
matTooltip="{{'widget.add-resource' | translate}}"
matTooltipPosition="above">

2
ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

@ -272,7 +272,7 @@
<div [formGroup]="dataSettings" class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

3
ui-ngx/src/app/modules/home/pages/admin/mail-templates.component.ts

@ -60,7 +60,8 @@ export class MailTemplatesComponent extends PageComponent implements OnInit, Has
ngOnInit() {
this.hugeRteOptions = defaultHugeRteOptions({
height: 450,
content_style: 'body { margin: 0; }'
content_style: 'body { margin: 0; }',
object_resizing: 'img'
});
if (this.readonly) {

5
ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.ts

@ -131,7 +131,10 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
const index = chat.pinned ? 0 : chat.createdTime >= today ? 1 : chat.createdTime >= today - DAY ? 2 : chat.createdTime >= today - WEEK ? 3 : 4;
groups[index].chats.push(chat);
}
const needsFirst = (row: AiRailRow) => this.needsAttention(row) ? 0 : 1;
const needsFirst = (row: AiRailRow) => {
const level = row.chat ? this.aiChats.levelOf(row.chat, true) : this.aiSolutions.levelOf(row.solution);
return level === 'needs' || level === 'error' ? 0 : 1;
};
groups.forEach(group => group.chats.sort((a, b) => needsFirst(a) - needsFirst(b)));
groups[0].chats.sort((a, b) => (b.pinnedTime ?? b.createdTime) - (a.pinnedTime ?? a.createdTime));
return groups.filter(group => group.chats.length);

2
ui-ngx/src/app/modules/home/pages/notification/template/configuration/notification-template-configuration.component.ts

@ -79,7 +79,7 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
'| numlist bullist | outdent indent | removeformat | code | fullscreen',
toolbar_mode: 'sliding',
height: 400,
content_style: 'body { margin: 0; }'
content_style: 'body { margin: 0; padding: 0 6px; }'
});
private propagateChange = null;

5
ui-ngx/src/app/modules/home/pages/widget/widget-editor.component.ts

@ -28,7 +28,7 @@ import {
widgetTypesData
} from '@shared/models/widget.models';
import { ActivatedRoute, Router } from '@angular/router';
import { deepClone } from '@core/utils';
import { deepClone, isEqual } from '@core/utils';
import { HasDirtyFlag } from '@core/guards/confirm-on-exit.guard';
import { AuthUser } from '@shared/models/user.model';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
@ -251,7 +251,8 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, Afte
this.panelService.setEditorDraftProvider(() => this.aiEditorDraft());
this.updateAiClientContext();
this.rxSubscriptions.push(this.panelService.updatedData$.subscribe(affected => {
if (!this.widgetTypeDetails && affected.some(entityId => entityId.entityType === EntityType.WIDGET_TYPE)) {
if (!this.widgetTypeDetails && affected.some(entityId => entityId.entityType === EntityType.WIDGET_TYPE)
&& isEqual(this.widget, this.origWidget)) {
this.isDirty = false;
}
}));

4
ui-ngx/src/app/shared/components/dashboard-select.component.ts

@ -105,9 +105,11 @@ export class DashboardSelectComponent implements ControlValueAccessor, OnInit {
}
ngOnInit() {
this.reload();
}
reload(): void {
const pageLink = new PageLink(100, 0, null, {property: 'title', direction: Direction.ASC});
this.dashboards$ = this.getDashboards(pageLink).pipe(
map((pageData) => pageData.data),
share()

5
ui-ngx/src/app/shared/components/json-object-edit.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-json-object flex flex-col" style="background: #fff;" [class.fill-height]="fillHeight"
@ -26,7 +27,7 @@
</button>
}
<ng-content select="[toolbarSuffixButton]"></ng-content>
<button mat-icon-button class="tb-mat-32" (click)="fullscreen = !fullscreen"
<button mat-icon-button class="tb-mat-32" type="button" (click)="fullscreen = !fullscreen"
matTooltip="{{(fullscreen ? 'fullscreen.exit' : 'fullscreen.expand') | translate}}"
matTooltipPosition="above">
<mat-icon class="material-icons">{{ fullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>

1
ui-ngx/src/app/shared/components/user-menu.component.ts

@ -136,6 +136,7 @@ export class UserMenuComponent {
logout(): void {
this.menuClicked.emit();
this.authService.redirectUrl = null;
this.authService.logout();
}

1
ui-ngx/src/app/shared/models/ai-chat.models.ts

@ -146,6 +146,7 @@ export interface ToolExecutionResult extends BaseChatToolEventData {
affectedEntities?: Array<EntityId>;
reason?: string;
result?: string;
durationMs?: number;
}
export interface ToolExecutionResultEvent extends BaseChatEvent {

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

@ -709,12 +709,9 @@
"type-secret": "Paste it here; it stays hidden",
"higher": "Higher by {{step}}",
"lower": "Lower by {{step}}",
"today": "{{day}}, today",
"time-wrong": "A time such as 9:30, from 0:00 to 23:59.",
"apply": "Apply",
"time": "Time",
"month-after": "The month after",
"month-before": "The month before",
"another-day": "Another day",
"hide": "Hide",
"show": "Show",
@ -791,6 +788,25 @@
"all-visible": "The customer can see every entity this dashboard shows.",
"alarm-meta": "{{severity}}, {{status}} · since {{since}}",
"asked-for": "Asked for",
"several": "several entities",
"history-key": "Key",
"history-curve": "Over time",
"history-last": "Last",
"history-range": "Range",
"history-changes": "{{count}} changes",
"history-span": "{{min}} to {{max}}",
"no-alarms": "No alarms",
"alarm-filter": {
"ACTIVE": "active",
"CLEARED": "cleared",
"ACK": "acknowledged",
"UNACK": "not acknowledged",
"CRITICAL": "critical",
"MAJOR": "major",
"MINOR": "minor",
"WARNING": "warning",
"INDETERMINATE": "indeterminate"
},
"heads-up": "Heads-up",
"stages": "Stages",
"asked": {
@ -800,11 +816,19 @@
"related-from": "what {{entity}} points to",
"related-to": "what points to {{entity}}",
"alarms-of": "{{entity}}",
"alarms": "{{filter}}",
"alarms-on": "on {{entity}}",
"alarms-filter-on": "{{filter}}, on {{entity}}",
"alarms-window": "{{window}}",
"alarms-filter-window": "{{filter}}, {{window}}",
"alarms-on-window": "on {{entity}}, {{window}}",
"alarms-filter-on-window": "{{filter}}, on {{entity}}, {{window}}",
"attributes-scope": "the {{scope}} of {{entity}}",
"history": "{{entity}}, {{from}} – {{to}}",
"history-keys": "{{keys}} on {{entity}}, {{from}} – {{to}}",
"latest-keys": "{{keys}} of {{entity}}",
"query": "'{{query}}'"
"query": "'{{query}}'",
"widget": "{{name}}"
},
"alarm-status": {
"ACTIVE_UNACK": "active, not acknowledged",
@ -1224,7 +1248,6 @@
"now": "now",
"cut-short": "Cut short: only the start of it was reported.",
"more": "and {{count}} more",
"series": "{{points}} points · {{min}} – {{max}} · last {{last}}",
"installs": "{{count}} installs",
"hub-device": "Device",
"on-iot-hub": "On IoT Hub",
@ -1348,8 +1371,8 @@
"done": "Looked up gateways"
},
"search-alarms": {
"run": "Looking up alarms",
"done": "Looked up alarms"
"run": "Searching alarms",
"done": "Searched alarms"
},
"search-alarm-rules": {
"run": "Looking up alarm rules",
@ -2368,6 +2391,7 @@
"stopped-at": "Stopped listening at {{time}}",
"listen-again": "Listen again",
"test-first": "Test from this computer first",
"test-here": "Test from this computer",
"send-test": "Send a test value",
"send-test-tip": "Sends one value as the device, marked as a test; the wait keeps listening for the device itself",
"test-sent": "Sent a test value at {{time}}; it is on the latest telemetry. The wait goes on for the device itself.",
@ -3052,7 +3076,7 @@
"NOTIFICATION_PREFERENCES": "Notification preferences"
},
"kind": {
"ADMIN_SETTINGS": "an admin settings",
"ADMIN_SETTINGS": "the admin settings",
"AGENT": "an agent",
"AGENT_APPLICATION": "an application",
"AGENT_APP_EVENT": "an agent app event",
@ -3064,7 +3088,7 @@
"ALARM": "an alarm",
"ALARM_RULE": "an alarm rule",
"API_KEY": "an API key",
"API_USAGE_STATE": "an API Usage State",
"API_USAGE_STATE": "the API usage state",
"ASSET": "an asset",
"ASSET_PROFILE": "an asset profile",
"BLOB_ENTITY": "a blob entity",
@ -3082,9 +3106,9 @@
"DEVICE_PROFILE": "a device profile",
"DOMAIN": "a domain",
"EDGE": "an edge",
"ENTITY_GROUP": "an entity Group",
"ENTITY_VIEW": "an entity View",
"GROUP_PERMISSION": "a group Permission",
"ENTITY_GROUP": "an entity group",
"ENTITY_VIEW": "an entity view",
"GROUP_PERMISSION": "a group permission",
"IMAGE": "an image",
"INTEGRATION": "an integration",
"JOB": "a task",
@ -3107,7 +3131,7 @@
"OTA_PACKAGE": "an OTA package",
"PLATFORM_SETTINGS": "the platform settings",
"QUEUE": "a queue",
"QUEUE_STATS": "a queue statistics",
"QUEUE_STATS": "the queue statistics",
"RELATION": "relations",
"REPORT": "a report",
"REPORT_COMPONENT": "a report component",
@ -3121,7 +3145,7 @@
"SCADA_SYMBOL": "a SCADA symbol",
"SCHEDULED_REPORT": "a scheduled report",
"SCHEDULER_EVENT": "a scheduler event",
"SECRET": "a secret storage",
"SECRET": "a secret",
"TB_RESOURCE": "a resource",
"TENANT": "a tenant",
"TENANT_PROFILE": "a tenant profile",

226
ui-ngx/src/theme/ai-theme.scss

@ -1555,6 +1555,21 @@
display: grid;
gap: 10px;
}
.k-diff-v.pics {
display: flex;
align-items: center;
gap: 10px;
.k-diff-to {
margin: 0;
}
.k-img {
width: 72px;
height: 54px;
}
}
}
.k-actions {
@ -4712,6 +4727,23 @@ cursor: pointer;
}
}
.k-ask .k-hexf-pick {
position: relative;
display: inline-flex;
> input[type="color"] {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: 0;
opacity: 0;
pointer-events: none;
}
}
.k-ask .k-hexf-hash {
font-family: var(--tb-mono);
font-size: var(--chat-code);
@ -5137,10 +5169,8 @@ tb-ai-action-detail.k-detail {
.k-detail-recs,
.k-tels,
.k-series,
.k-made,
.k-detail-links,
.k-detail-facts {
.k-detail-links {
max-height: 214px;
overflow-y: auto;
overscroll-behavior: contain;
@ -5256,49 +5286,179 @@ tb-ai-action-detail.k-detail {
}
}
.k-series {
display: grid;
.k-diff {
margin-top: 8px;
gap: 6px;
margin-top: 10px;
.k-diff-v {
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
}
.k-diff-v.mono {
font-family: var(--tb-mono);
font-size: var(--chat-code);
}
.k-diff-l {
font-size: var(--chat-meta);
color: var(--tb-text-secondary);
}
}
.k-series-row {
display: grid;
grid-template-columns: max-content 96px minmax(0, 1fr);
.k-img {
display: flex;
align-items: center;
gap: 10px;
code.k-tel-key {
padding: 2px 7px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.06);
font-family: var(--tb-mono);
font-size: 13px;
line-height: 20px;
color: var(--tb-ink);
img, .k-img-none {
display: block;
width: 72px;
height: 54px;
box-sizing: border-box;
object-fit: contain;
border: 1px solid var(--tb-line);
border-radius: 6px;
background: var(--tb-surface);
}
> .mat-icon {
color: var(--tb-ink-38);
}
}
.k-series-spark {
width: 96px;
height: 20px;
overflow: visible;
.k-found {
margin: 4px 0 0;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
color: var(--tb-ink);
}
path {
fill: none;
stroke: var(--ai-teal-500);
stroke-width: 1.5;
stroke-linejoin: round;
vector-effect: non-scaling-stroke;
.k-group-h {
margin: 20px 0 0;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
font-weight: 500;
color: var(--tb-ink);
&:first-child {
margin-top: 0;
}
+ * {
margin-top: 2px;
}
}
.k-series-meta {
.k-key {
font-family: var(--tb-mono);
font-size: 12px;
line-height: 18px;
color: var(--k-grey);
font-variant-numeric: tabular-nums;
font-size: var(--chat-code);
}
.k-vals {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
align-items: baseline;
column-gap: 16px;
row-gap: 2px;
margin: 10px 0 0;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
dt {
font-size: var(--chat-meta);
line-height: var(--chat-line-lh);
color: var(--tb-text-secondary);
}
dd {
margin: 0;
min-width: 0;
overflow-wrap: anywhere;
color: var(--tb-ink);
}
}
.k-hist {
margin-top: 10px;
border-collapse: collapse;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
th, td {
padding: 2px 16px 2px 0;
text-align: left;
vertical-align: middle;
font-weight: 400;
}
:is(th, td):last-child {
padding-right: 0;
}
thead th {
padding-bottom: 4px;
font-size: var(--chat-meta);
line-height: var(--chat-meta-lh);
color: var(--tb-text-muted);
}
.k-key {
color: var(--tb-text-secondary);
}
td.c {
width: 112px;
}
.tb-spark {
position: relative;
width: 112px;
height: 20px;
}
.tb-spark-svg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
path {
fill: none;
stroke: var(--tb-ink-54);
stroke-width: 2;
stroke-linejoin: round;
stroke-linecap: round;
vector-effect: non-scaling-stroke;
}
}
.tb-spark-dot {
position: absolute;
right: -3px;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--tb-ink-54);
box-shadow: 0 0 0 2px var(--tb-surface);
}
:is(td, th).n {
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
td.n {
color: var(--tb-ink);
}
td.q {
white-space: nowrap;
font-variant-numeric: tabular-nums;
color: var(--tb-text-secondary);
}
}
.k-detail-facts {
@ -7451,7 +7611,7 @@ tb-ai-action-line .k-det tb-ai-action-detail.k-detail {
padding: 0 6px 0 14px;
cursor: pointer;
> tb-ai-spin {
.tb-ai-step-mark > tb-ai-spin {
--spin: 20px;
flex: none;
}

Loading…
Cancel
Save