Browse Source

feat: the solution chat asks the design questions in the kit's question card and shows the answers as You said, marks step results with a check and the next step's prompt, rates and reports answers, ticks off entities while installing, gives estimates from usage, says in its head when it needs the person or failed, and fills the column beside the open pane; solutions in the chats list can be pinned and show their status; the platform uses the current Roboto and Roboto Mono variable fonts

pull/16833/head
Igor Kulikov 4 weeks ago
parent
commit
efad404d09
  1. 16
      application/src/main/java/org/thingsboard/server/controller/AiSolutionController.java
  2. 4
      application/src/main/java/org/thingsboard/server/service/ai/solution/AiSolutionService.java
  3. 13
      application/src/main/java/org/thingsboard/server/service/ai/solution/DefaultAiSolutionService.java
  4. 4
      ui-ngx/package.json
  5. 12
      ui-ngx/src/app/core/http/solutions-creator.service.ts
  6. 64
      ui-ngx/src/app/core/services/ai-solutions.service.ts
  7. 17
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html
  8. 45
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.scss
  9. 4
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts
  10. 76
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.html
  11. 108
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts
  12. 7
      ui-ngx/src/app/modules/home/components/ai/ai.module.ts
  13. 5
      ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.html
  14. 20
      ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.scss
  15. 1
      ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.ts
  16. 22
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.html
  17. 13
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.scss
  18. 238
      ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.ts
  19. 12
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.html
  20. 37
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.ts
  21. 48
      ui-ngx/src/app/shared/models/solution-creator.models.ts
  22. 18
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  23. 271
      ui-ngx/src/scss/roboto.scss
  24. 3
      ui-ngx/src/styles.scss
  25. 366
      ui-ngx/src/theme/ai-theme.scss
  26. 20
      ui-ngx/yarn.lock

16
application/src/main/java/org/thingsboard/server/controller/AiSolutionController.java

@ -110,6 +110,22 @@ public class AiSolutionController extends BaseController {
aiSolutionService.clearStep(solutionId, step, user);
}
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@PostMapping(value = "/{solutionId}/update", consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateSolution(@PathVariable UUID solutionId, @RequestBody JsonNode request) throws ThingsboardException {
SecurityUser user = getCurrentUser();
accessControlService.checkPermission(user, Resource.AI, Operation.WRITE);
aiSolutionService.updateSolution(solutionId, request, user);
}
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@GetMapping("/{solutionId}/progress")
public JsonNode getInstallProgress(@PathVariable UUID solutionId) throws ThingsboardException {
SecurityUser user = getCurrentUser();
accessControlService.checkPermission(user, Resource.AI, Operation.READ);
return aiSolutionService.getInstallProgress(solutionId, user);
}
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@PostMapping("/{solutionId}/install")
public JsonNode installSolution(@PathVariable UUID solutionId,

4
application/src/main/java/org/thingsboard/server/service/ai/solution/AiSolutionService.java

@ -31,4 +31,8 @@ public interface AiSolutionService {
void deleteSolution(UUID solutionId, SecurityUser user);
void updateSolution(UUID solutionId, JsonNode request, SecurityUser user);
JsonNode getInstallProgress(UUID solutionId, SecurityUser user);
}

13
application/src/main/java/org/thingsboard/server/service/ai/solution/DefaultAiSolutionService.java

@ -16,6 +16,7 @@ import org.thingsboard.ai.common.channel.SolutionChatRequest;
import org.thingsboard.ai.common.channel.SolutionDataRequest;
import org.thingsboard.ai.common.channel.SolutionOperationRequest;
import org.thingsboard.ai.common.channel.SolutionStepRequest;
import org.thingsboard.ai.common.channel.SolutionUpdateRequest;
import org.thingsboard.server.service.ai.TbAiService;
import org.thingsboard.server.service.ai.transport.TbAiOperation;
import org.thingsboard.server.service.ai.transport.TbAiOperations;
@ -100,4 +101,16 @@ public class DefaultAiSolutionService implements AiSolutionService {
new TbAiOperation(ChannelProtocol.SOLUTION_DELETE, new SolutionOperationRequest(solutionId)), user, tokenProvider), user, false);
}
@Override
public void updateSolution(UUID solutionId, JsonNode request, SecurityUser user) {
tbAiService.process(tokenProvider -> operations.execute(
new TbAiOperation(ChannelProtocol.SOLUTION_UPDATE, new SolutionUpdateRequest(solutionId, request)), user, tokenProvider), user, false);
}
@Override
public JsonNode getInstallProgress(UUID solutionId, SecurityUser user) {
return tbAiService.process(tokenProvider -> operations.execute(
new TbAiOperation(ChannelProtocol.SOLUTION_PROGRESS, new SolutionOperationRequest(solutionId)), user, tokenProvider), user, false);
}
}

4
ui-ngx/package.json

@ -26,6 +26,8 @@
"@auth0/angular-jwt": "^5.2.0",
"@flowjs/flow.js": "^2.14.1",
"@flowjs/ngx-flow": "20.0.2",
"@fontsource-variable/roboto": "^5.3.0",
"@fontsource-variable/roboto-mono": "^5.3.0",
"@fullcalendar/angular": "^6.1.20",
"@fullcalendar/core": "^6.1.20",
"@fullcalendar/daygrid": "^6.1.20",
@ -103,8 +105,6 @@
"tinycolor2": "^1.6.0",
"tooltipster": "^4.2.8",
"tslib": "^2.8.1",
"typeface-roboto": "^1.1.13",
"typeface-roboto-mono": "^1.1.13",
"yaml": "^2.6.1",
"zone.js": "~0.15.1"
},

12
ui-ngx/src/app/core/http/solutions-creator.service.ts

@ -9,8 +9,10 @@ import {
SolutionDataKey,
SolutionDataValues,
SolutionInfo,
SolutionInstallProgress,
SolutionInstallResult,
SolutionStep
SolutionStep,
SolutionUpdateRequest
} from '@shared/models/solution-creator.models';
@Injectable({
@ -64,4 +66,12 @@ export class SolutionsCreatorService {
public deleteSolution(solutionId: string, config?: RequestConfig): Observable<void> {
return this.http.delete<void>(`/api/ai/solution/${solutionId}`, defaultHttpOptionsFromConfig(config));
}
public updateSolution(solutionId: string, request: SolutionUpdateRequest, config?: RequestConfig): Observable<void> {
return this.http.post<void>(`/api/ai/solution/${solutionId}/update`, request, defaultHttpOptionsFromConfig(config));
}
public getInstallProgress(solutionId: string, config?: RequestConfig): Observable<SolutionInstallProgress> {
return this.http.get<SolutionInstallProgress>(`/api/ai/solution/${solutionId}/progress`, defaultHttpOptionsFromConfig(config));
}
}

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

@ -4,9 +4,16 @@ import { inject, Injectable, signal } from '@angular/core';
import { Observable, of } from 'rxjs';
import { map, switchMap, tap } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';
import { ChatLevel } from '@shared/models/ai-chat.models';
import { SolutionsCreatorService } from '@core/http/solutions-creator.service';
import { DialogService } from '@core/services/dialog.service';
import { SolutionCreatorInfo, SolutionInfo } from '@shared/models/solution-creator.models';
import {
SolutionCreatorInfo,
SolutionInfo,
SolutionInstallProgress,
SolutionStep,
SolutionUpdateRequest
} from '@shared/models/solution-creator.models';
@Injectable({providedIn: 'root'})
export class AiSolutionsService {
@ -19,6 +26,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 api = inject(SolutionsCreatorService);
private dialog = inject(DialogService);
@ -40,6 +48,9 @@ export class AiSolutionsService {
if (!solutionId || this._running().has(solutionId) === running) {
return;
}
if (running) {
this.update(solutionId, {status: undefined, statusReason: undefined});
}
this._running.update(set => {
const next = new Set(set);
if (running) {
@ -55,6 +66,43 @@ export class AiSolutionsService {
return this._running().has(solutionId);
}
setFailed(solutionId: string | undefined, reason: string | null): void {
if (!solutionId || this._failed().get(solutionId) === (reason ?? undefined)) {
return;
}
this._failed.update(map => {
const next = new Map(map);
if (reason) {
next.set(solutionId, reason);
} else {
next.delete(solutionId);
}
return next;
});
}
levelOf(solution: SolutionInfo, open = false): ChatLevel | null {
if (this._running().has(solution.id)) {
return 'running';
}
if (this._failed().has(solution.id)) {
return 'error';
}
if (open) {
return solution.status === 'FAILED' ? 'error' : null;
}
return solution.status === 'NEEDS_YOU' ? 'needs' : solution.status === 'RUNNING' ? 'running' : solution.status === 'FAILED' ? 'error' : null;
}
tipOf(solution: SolutionInfo, open = false): string {
const level = this.levelOf(solution, open);
if (!level) {
return '';
}
const reason = level === 'error' ? this._failed().get(solution.id) ?? solution.statusReason : undefined;
return reason || this.translate.instant('ai-assistant.status-tip-' + level);
}
find(solutionId: string | undefined): SolutionInfo | undefined {
return solutionId ? this._solutions().find(solution => solution.id === solutionId) : undefined;
}
@ -86,6 +134,20 @@ export class AiSolutionsService {
);
}
setPinned(solution: SolutionInfo, pinned: boolean): Observable<void> {
return this.api.updateSolution(solution.id, {pinned}, {ignoreLoading: true, ignoreErrors: true}).pipe(
tap(() => this.update(solution.id, {pinned}))
);
}
sendFeedback(solutionId: string, step: SolutionStep, feedback: SolutionUpdateRequest['feedback']): Observable<void> {
return this.api.updateSolution(solutionId, {step, feedback}, {ignoreLoading: true});
}
installProgress(solutionId: string): Observable<SolutionInstallProgress> {
return this.api.getInstallProgress(solutionId, {ignoreLoading: true, ignoreErrors: true});
}
confirmAndUninstall(solution: SolutionInfo): Observable<SolutionCreatorInfo | null> {
return this.dialog.confirm(
this.translate.instant('solution-creator.uninstall-solution-dialog-title', {name: this.titleOf(solution)}),

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

@ -8,7 +8,9 @@
@if (dayLines[$index]; as day) {
<div class="k-day" role="separator"><span>{{ day }}</span></div>
}
@if (msg.from === 'USER') {
@if (msg.from === 'USER' && msg.answers?.length) {
<tb-ai-question class="answers" [questions]="[]" [answered]="msg.answers" [time]="msg.time"></tb-ai-question>
} @else if (msg.from === 'USER') {
@if (msg.startedFrom) {
<tb-ai-started-from [from]="msg.startedFrom"></tb-ai-started-from>
}
@ -79,14 +81,23 @@
</div>
}
} @else {
<div class="agent" #answer>
<div class="agent" [class.done]="msg.done" #answer>
@if (msg.done) {
<mat-icon class="done-mark" aria-hidden="true">check</mat-icon>
}
<div class="agent-body">
<tb-markdown usePlainMarkdown [additionalStyles]="additionalStyles" [data]="parseResult(msg.content)" (ready)="decorateCode(answer)"></tb-markdown>
@if (msg.lead) {
<p class="lead">{{ msg.lead }}</p>
}
<tb-markdown usePlainMarkdown [additionalStyles]="additionalStyles" [data]="parseResult(msg.done !== undefined ? withoutDoneMark(msg.content) : msg.content)" (ready)="decorateCode(answer)"></tb-markdown>
@if (summaries[$index]; as entities) {
<tb-ai-run-summary [entities]="entities"></tb-ai-run-summary>
}
</div>
</div>
@if (msg.note) {
<p class="agent-note">{{ msg.note }}</p>
}
<div class="msg-foot agent-foot">
@if (msg.time) {
<time [matTooltip]="fullTime(msg.time)" matTooltipPosition="above">{{ msg.time | date:'HH:mm' }}</time>

45
ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.scss

@ -220,6 +220,43 @@
.agent-body {
min-width: 0;
}
&.done {
display: flex;
align-items: flex-start;
gap: 8px;
> .done-mark {
flex: none;
margin-top: 2px;
font-size: 20px;
width: 20px;
height: 20px;
line-height: 20px;
color: var(--tb-ok-text);
}
> .agent-body {
flex: 1;
}
}
.lead {
margin: 0 0 14px;
font-size: var(--chat-text);
line-height: var(--chat-text-lh);
letter-spacing: var(--chat-text-ls);
font-weight: 500;
color: var(--tb-ink);
}
}
.agent-note {
margin: 14px 0 4px;
letter-spacing: .25px;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
color: var(--k-grey);
}
.incomplete {
@ -311,6 +348,14 @@
margin: 0 0 0 6px;
}
&::ng-deep .ai .agent-body:has(> .lead) .tb-markdown-view [class*="tb-markdown-view-"] ol {
padding-left: 20px;
li + li {
margin-top: 6px;
}
}
&::ng-deep .ai .agent-body .tb-markdown-view {
font-family: var(--tb-font);
font-size: var(--chat-text);

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

@ -113,6 +113,10 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
this.unfolded.add(index);
}
withoutDoneMark(content: string): string {
return (content ?? '').replace(/^\s*(✅|🛠️|🛠|🤔|💡|🛑)\s*/u, '');
}
copyAnswer(answer: HTMLElement, index: number): void {
const text = (answer.querySelector<HTMLElement>('tb-markdown') ?? answer).innerText.trim();
if (this.clipboard.copyFromContent(text)) {

76
ui-ngx/src/app/modules/home/components/ai/ai-question.component.html

@ -0,0 +1,76 @@
<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
@if (answered(); as answers) {
<div class="k-ask answered">
<div class="k-head">
<mat-icon class="tb-mat-18" aria-hidden="true">help_outline</mat-icon>{{ 'ai-assistant.question.you-said' | translate }}
</div>
@if (time()) {
<time class="k-time">{{ time() | date:'HH:mm' }}</time>
}
@for (item of answers; track item.question.id) {
<div class="k-q">
<span class="k-qt">{{ item.question.question }}</span>
<span class="k-opts"><button type="button" class="ob-chip" aria-pressed="true" disabled>{{ item.answer }}</button></span>
</div>
}
</div>
} @else if (current(); as question) {
<div class="k-ask stepped">
<div class="k-head">
<mat-icon class="tb-mat-18" aria-hidden="true">help_outline</mat-icon>{{ 'ai-assistant.question.needs-answer' | translate }}
@if (questions().length > 1) {
<span class="k-sub k-count">{{ 'ai-assistant.question.count' | translate: {at: at() + 1, of: questions().length} }}</span>
}
</div>
@for (step of [question]; track step.id) {
<div class="k-step" [class.in-next]="move() === 'next'" [class.in-back]="move() === 'back'">
<div class="k-ask-q">
<b>{{ step.question }}</b>
@if (step.why) {
<span class="k-why">{{ step.why }}</span>
}
</div>
<div class="k-ask-a">
<div class="k-optcards" [class.list]="step.options.length >= 5" role="radiogroup" [attr.aria-label]="step.question"
[style.--n]="step.options.length">
@for (option of step.options; track option.label) {
<button type="button" role="radio" class="k-optcard" [attr.aria-checked]="!isOther(step) && valueOf(step) === option.label"
[disabled]="disabled()" (click)="pick(step, option.label)">
<span class="k-optdot"></span>
<span class="k-optbody"><b>{{ option.label }}</b>@if (option.hint) {<span>{{ option.hint }}</span>}</span>
</button>
}
<div class="k-optcard other" role="radio" [attr.aria-checked]="isOther(step)" (click)="otherArea.focus()">
<span class="k-optdot"></span>
<span class="k-optbody">
<b>{{ 'ai-assistant.question.other' | translate }}</b>
<textarea #otherArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
[value]="otherText(step)"
[placeholder]="'ai-assistant.question.other-hint' | translate"
[attr.aria-label]="step.question + ' · ' + ('ai-assistant.question.other' | translate)"
(focus)="pickOther(step)" (input)="type(step, otherArea)" (keydown.enter)="onEnter($event)"></textarea>
</span>
</div>
</div>
</div>
</div>
}
<div class="k-actions">
@if (at() > 0) {
<button mat-button type="button" (click)="back()">
<mat-icon>arrow_back</mat-icon>{{ 'action.back' | translate }}
</button>
}
<button mat-flat-button type="button" color="primary" [disabled]="disabled() || !ready(question)" (click)="next()">
<mat-icon>{{ last() ? 'check' : 'arrow_forward' }}</mat-icon>{{ (last() ? 'ai-assistant.question.done' : 'ai-assistant.question.next') | translate }}
</button>
<span class="tb-spacer"></span>
<button mat-button type="button" [disabled]="disabled()" (click)="skipAll()">{{ 'ai-assistant.question.skip' | translate }}</button>
</div>
</div>
}

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

@ -0,0 +1,108 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Component, computed, EventEmitter, input, Output, signal } from '@angular/core';
import { AiQuestion, AiQuestionAnswer } from '@shared/models/solution-creator.models';
@Component({
selector: 'tb-ai-question',
templateUrl: './ai-question.component.html',
standalone: false
})
export class AiQuestionComponent {
questions = input.required<AiQuestion[]>();
answered = input<AiQuestionAnswer[] | null>(null);
disabled = input(false);
time = input<number | undefined>(undefined);
@Output() done = new EventEmitter<AiQuestionAnswer[]>();
@Output() skip = new EventEmitter<AiQuestionAnswer[]>();
at = signal(0);
move = signal<'next' | 'back' | null>(null);
private picked = signal<Record<string, string>>({});
private typed = signal<Record<string, string>>({});
current = computed(() => this.questions()[Math.min(this.at(), this.questions().length - 1)]);
last = computed(() => this.at() >= this.questions().length - 1);
valueOf(question: AiQuestion): string {
const picked = this.picked()[question.id];
if (picked !== undefined) {
return picked;
}
return question.options.some(option => option.label === question.recommended) ? question.recommended : question.options[0]?.label ?? '';
}
isOther(question: AiQuestion): boolean {
return this.picked()[question.id] === null;
}
otherText(question: AiQuestion): string {
return this.typed()[question.id] ?? '';
}
ready(question: AiQuestion): boolean {
return this.isOther(question) ? !!this.otherText(question).trim() : !!this.valueOf(question);
}
pick(question: AiQuestion, label: string): void {
this.picked.update(values => ({...values, [question.id]: label}));
}
pickOther(question: AiQuestion): void {
if (!this.isOther(question)) {
this.picked.update(values => ({...values, [question.id]: null}));
}
}
type(question: AiQuestion, area: HTMLTextAreaElement): void {
this.pickOther(question);
this.typed.update(values => ({...values, [question.id]: area.value}));
area.style.height = 'auto';
area.style.height = area.scrollHeight + 'px';
}
next(): void {
const question = this.current();
if (!question || !this.ready(question) || this.disabled()) {
return;
}
if (this.last()) {
this.done.emit(this.answers());
} else {
this.move.set('next');
this.at.update(index => index + 1);
}
}
back(): void {
this.move.set('back');
this.at.update(index => Math.max(0, index - 1));
}
skipAll(): void {
if (!this.disabled()) {
this.skip.emit(this.questions().map(question => ({question, answer: this.defaultOf(question)})));
}
}
onEnter(event: Event): void {
const keyboard = event as KeyboardEvent;
if (!keyboard.shiftKey && !keyboard.isComposing) {
event.preventDefault();
this.next();
}
}
private answers(): AiQuestionAnswer[] {
return this.questions().map(question => ({
question,
answer: this.isOther(question) ? this.otherText(question).trim() : this.valueOf(question)
}));
}
private defaultOf(question: AiQuestion): string {
return question.options.some(option => option.label === question.recommended) ? question.recommended : question.options[0]?.label ?? '';
}
}

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

@ -23,6 +23,7 @@ import { AiRunSummaryComponent } from '@home/components/ai/ai-run-summary.compon
import { AiStartedFromComponent } from '@home/components/ai/ai-started-from.component';
import { AiAssistantButtonComponent } from '@home/components/ai/ai-assistant-button.component';
import { AiRecordComponent } from '@home/components/ai/ai-record.component';
import { AiQuestionComponent } from '@home/components/ai/ai-question.component';
import { AiSparkComponent } from '@home/components/ai/ai-spark.component';
@NgModule({
@ -47,7 +48,8 @@ import { AiSparkComponent } from '@home/components/ai/ai-spark.component';
AiStartedFromComponent,
AiAssistantButtonComponent,
AiRecordComponent,
AiSparkComponent
AiSparkComponent,
AiQuestionComponent
],
imports: [
CommonModule,
@ -67,7 +69,8 @@ import { AiSparkComponent } from '@home/components/ai/ai-spark.component';
AiCreditsComponent,
AiLoadingModalComponent,
AiNoTelemetryModalComponent,
AiAttachmentsComponent
AiAttachmentsComponent,
AiQuestionComponent
]
})
export class AiModule {}

5
ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.html

@ -4,7 +4,8 @@
SPDX-License-Identifier: BUSL-1.1
-->
@if (installed() && !bannerClosed()) {
@if (creating()) {
} @else if (installed() && !bannerClosed()) {
<div class="sol-done" role="status">
<span class="tb-ai-mark m44 sol-done-mark" aria-hidden="true"><mat-icon>check</mat-icon></span>
<div class="sol-done-t">
@ -24,7 +25,7 @@
} @else if (!installed()) {
<p class="sol-not-installed">{{ 'solution-creator.pane.not-installed' | translate }}</p>
}
<div class="sol-infos">
<div class="sol-infos" [class.creating]="creating()">
@for (section of sections(); track section.type) {
<div class="sol-sec-head"><h3>{{ section.title | translate }}</h3></div>
<table class="sol-table sol-installed-table">

20
ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.scss

@ -155,3 +155,23 @@
outline-offset: 1px;
}
}
.sol-infos.creating tbody tr {
animation: sol-row-in .2s cubic-bezier(.2, 0, 0, 1);
}
@keyframes sol-row-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.sol-infos.creating tbody tr {
animation: none;
}
}

1
ui-ngx/src/app/modules/home/components/ai/solution/pane/solution-installed.component.ts

@ -50,6 +50,7 @@ const SECTIONS: EntityType[] = [
export class SolutionInstalledComponent {
solution = input.required<SolutionCreatorInfo>();
creating = input(false);
@Output() openMain = new EventEmitter<void>();

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

@ -85,13 +85,21 @@
<div #chatArea class="sol-log">
<div class="sol-log-in">
<tb-ai-chat-messages
[messages]="messages()"
[messages]="viewMessages()"
[loading]="false"
[scrollContainer]="chatArea"
[feedback]="!!info()?.id"
initialScroll="bottom"
(rate)="onRate($event)"
(report)="onReport($event)"
(resourceError)="showErrorMessage($event)">
</tb-ai-chat-messages>
@if (skipInterviewAllowed() && !loading() && !isGenerating()) {
@if (pendingQuestions(); as questions) {
@if (questions.length) {
<tb-ai-question class="sol-ask" [questions]="questions" (done)="answerQuestions($event)" (skip)="skipQuestions($event)"></tb-ai-question>
}
}
@if (skipInterviewAllowed() && !loading() && !isGenerating() && !pendingQuestions().length) {
<div class="k-chips sol-chips">
<button type="button" class="ob-chip" (click)="skipInterview()">
<mat-icon fontSet="material-icons-round" aria-hidden="true">fast_forward</mat-icon>
@ -231,12 +239,14 @@
}
</div>
<div #paneBody class="sol-pane-body" [class.dark]="json()" (scroll)="onPaneScroll(paneBody)">
@if (making() && currentView() === making()) {
@if (making() === 'solution' && currentView() === 'solution' && progressInfo(); as progress) {
<tb-solution-installed [solution]="progress" [creating]="true"></tb-solution-installed>
} @else if (making() && currentView() === making()) {
<div class="sol-loading">
<span class="sol-loading-glow" aria-hidden="true"></span>
<span class="tb-ai-mark m64" aria-hidden="true"><tb-ai-spark></tb-ai-spark></span>
<p class="sol-loading-line">{{ work()?.words }}</p>
<p class="sol-loading-est">{{ ('solution-creator.pane.estimate-' + making()) | translate }}</p>
<p class="sol-loading-est">{{ estimateOf(making()) }}</p>
</div>
} @else if (json()) {
<tb-solution-json #jsonView class="sol-json" [value]="jsonValue()"
@ -289,12 +299,12 @@
</button>
}
} @else if (currentView() === 'overview') {
<span class="sol-foot-note">{{ 'solution-creator.pane.estimate-dashboards' | translate }}</span>
<span class="sol-foot-note">{{ estimateOf('dashboards') }}</span>
<button mat-flat-button type="button" [disabled]="loading()" (click)="nextStep()">
{{ 'solution-creator.next-dashboards' | translate }}
</button>
} @else {
<span class="sol-foot-note">{{ 'solution-creator.pane.estimate-solution' | translate }}</span>
<span class="sol-foot-note">{{ estimateOf('solution') }}</span>
<button mat-button type="button" [disabled]="loading()" (click)="back()">
<mat-icon fontSet="material-icons-round">arrow_back</mat-icon>{{ 'action.back' | translate }}
</button>

13
ui-ngx/src/app/modules/home/components/ai/solution/solution-chat.component.scss

@ -1081,3 +1081,16 @@
color: var(--k-grey);
}
}
.sol-ask {
display: block;
margin-top: var(--chat-turn-gap, 28px);
}
@media (min-width: 1100px) {
.sol-cols.with-pane {
.sol-log-in, .sol-composer {
max-width: none;
}
}
}

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

@ -15,13 +15,22 @@ import {
untracked,
ViewChild
} from '@angular/core';
import { AiChatMessagesComponent } from '@home/components/ai/ai-chat-messages.component';
import {
AiChatMessagesComponent,
AnswerRatingEvent,
AnswerReportEvent
} from '@home/components/ai/ai-chat-messages.component';
import { PageComponent } from '@shared/components/page.component';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import {
AiQuestion,
AiQuestionAnswer,
ChatMessage,
DashboardsOverview,
GeneralChatMessage,
SolutionEstimate,
SolutionInstallProgress,
NEW_SOLUTION_ID,
SolutionCreatorInfo,
SolutionDescriptor,
@ -43,7 +52,7 @@ import {
tap
} from 'rxjs/operators';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { EMPTY, Observable, of, Subject } from 'rxjs';
import { EMPTY, Observable, of, Subject, timer } from 'rxjs';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
import { DialogService } from '@core/services/dialog.service';
import { TranslateService } from '@ngx-translate/core';
@ -61,6 +70,30 @@ import { EntityId } from '@shared/models/id/entity-id';
export type SolutionView = 'overview' | 'dashboards' | 'solution';
function answersOf(content: string | undefined, questions: AiQuestion[] | undefined): AiQuestionAnswer[] | null {
if (!content || !questions?.length) {
return null;
}
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) {
return null;
}
answers.push({question, answer: line.slice(question.question.trim().length).trim()});
}
return answers.length ? answers : null;
}
function formatCredits(credits: number): string {
if (credits >= 1000) {
const thousands = credits / 1000;
return (thousands >= 10 ? Math.round(thousands) : Math.round(thousands * 10) / 10) + 'k';
}
return String(credits);
}
@Component({
selector: 'tb-solution-chat',
templateUrl: './solution-chat.component.html',
@ -105,9 +138,10 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
mainDashboard = signal<EntityId[]>([]);
level = computed<'running' | 'needs' | null>(() => this.loading() || this.isGenerating()
level = computed<'running' | 'needs' | 'error' | null>(() => this.loading() || this.isGenerating()
? 'running'
: this.isReadyStep() && this.creatorStep() === 'chat' && !this.built() ? 'needs' : null);
: this.failure() ? 'error'
: this.pendingQuestions().length || (this.isReadyStep() && this.creatorStep() === 'chat' && !this.built()) ? 'needs' : null);
info = signal<SolutionCreatorInfo | null>(null);
@ -122,6 +156,57 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
uninstalledAt = signal<number | null>(null);
failure = signal<string | null>(null);
installProgress = signal<SolutionInstallProgress | null>(null);
private messageSteps: SolutionStep[] = [];
progressInfo = computed<SolutionCreatorInfo | null>(() => {
const progress = this.installProgress();
const info = this.info();
if (!progress || !info || !Object.values(progress.entityResults ?? {}).some(results => results?.length)) {
return null;
}
return {...info, metadata: {built: true, installed: false, installResult: {createdEntities: [], entityResults: progress.entityResults as any}}};
});
viewMessages = computed<ChatMessage[]>(() => {
const messages = this.messages();
const lastAi = messages.map(message => message.from).lastIndexOf('AI');
const waiting = this.isReadyStep() && this.creatorStep() === 'chat' && !this.built() && !this.loading() && !this.isGenerating();
return messages.map((message, index) => {
if (message.from === 'AI') {
const general = message as GeneralChatMessage;
const patch: Partial<GeneralChatMessage> = {};
if (/^\s*(✅|🛠️|🛠)/u.test(general.content ?? '')) {
patch.done = true;
} else if (/^\s*(🤔|💡|🛑)/u.test(general.content ?? '')) {
patch.done = false;
}
if (general.questions?.length) {
patch.lead = this.translate.instant('solution-creator.assumptions');
}
if (waiting && index === lastAi) {
patch.note = this.translate.instant(this.solutionStep() === SolutionStep.DASHBOARDS_CONFIGURATION
? 'solution-creator.next-create' : 'solution-creator.next-dashboards-note');
}
return Object.keys(patch).length ? {...general, ...patch} : message;
}
if (message.from === 'USER') {
const previous = messages[index - 1] as GeneralChatMessage;
const answers = previous?.from === 'AI' ? answersOf((message as GeneralChatMessage).content, previous.questions) : null;
return answers ? {...message, answers} as GeneralChatMessage : message;
}
return message;
});
});
pendingQuestions = computed<AiQuestion[]>(() => {
const last = this.messages()[this.messages().length - 1] as GeneralChatMessage;
if (!last || last.from !== 'AI' || !last.questions?.length || this.loading() || this.isGenerating() || this.isReadyStep()
|| this.solutionStep() !== SolutionStep.INITIAL_CONFIGURATION) {
return [];
}
return last.questions;
});
readonly aboutFeatures = [
{icon: 'account_tree', title: 'solution-creator.about-design-title', line: 'solution-creator.about-design'},
@ -158,6 +243,12 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}, 50));
});
private failureEffect = effect(() => {
const id = this.info()?.id;
const failure = this.failure();
untracked(() => this.aiSolutions.setFailed(id, failure));
});
private runningEffect = effect(() => {
const id = this.info()?.id;
const running = this.loading() || this.isGenerating();
@ -245,7 +336,8 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
activePlaceholder = computed(() => this.isInitialEmpty()
? 'solution-creator.describe-solution-you-want'
: this.creatorStep() === 'result' ? 'solution-creator.ask-about-solution' : 'solution-creator.say-what-to-change');
: this.pendingQuestions().length ? 'solution-creator.type-the-answer'
: this.creatorStep() === 'result' ? 'solution-creator.ask-about-solution' : 'solution-creator.say-what-to-change');
activeStepIndex = computed(() => {
if (!this.creatorStep()) {
@ -603,7 +695,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
})),
tap(() => this.creatorStep.set('result')),
switchMap((solution) =>
this.solutionCreator.installSolution(this.solutionId, {ignoreLoading: true, ignoreErrors: true})
this.installWithProgress()
.pipe(map((installData) => {
if (!solution.metadata) {
solution.metadata = {} as SolutionMetadata;
@ -642,10 +734,15 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}
installSolution() {
const progressSubject = new Subject<void>();
this.dialogService.progress(progressSubject.asObservable(), this.translate.instant('solution-creator.installing'));
this.solutionCreator.installSolution(this.solutionId, {ignoreLoading: true, ignoreErrors: true}).pipe(
takeUntil(this.cancelPending$)
this.failure.set(null);
if (window.innerWidth >= SolutionChatComponent.NARROW_WIDTH) {
this.paneOpen.set(true);
}
const work = this.startWork([{text: 'solution-creator.step-loading-creating-entities', delay: 0}], 'install');
this.making.set('solution');
this.installWithProgress().pipe(
takeUntil(this.cancelPending$),
finalize(() => work.close())
).subscribe({
next: (value) => {
if (!this.solutionInfo.metadata) {
@ -658,8 +755,6 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
this.solutionInfo.metadata.installed = true;
this.solutionInfo = this.solutionInfo;
this.aiSolutions.update(this.solutionId, {installed: true});
progressSubject.next();
progressSubject.complete();
if (value.mainDashboardId) {
this.gotoMainDashboard(true);
} else {
@ -667,13 +762,111 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}
},
error: (err) => {
progressSubject.next();
progressSubject.complete();
this.reportFailure(err);
}
});
}
private installWithProgress(): Observable<SolutionInstallResult> {
const solutionId = this.solutionId;
const finished$ = new Subject<void>();
this.installProgress.set(null);
timer(800, 1200).pipe(
switchMap(() => this.aiSolutions.installProgress(solutionId).pipe(catchError(() => of(null)))),
takeUntil(finished$),
takeUntil(this.cancelPending$)
).subscribe(progress => {
if (progress?.running) {
this.installProgress.set(progress);
}
});
return this.solutionCreator.installSolution(solutionId, {ignoreLoading: true, ignoreErrors: true}).pipe(
finalize(() => {
finished$.next();
finished$.complete();
this.installProgress.set(null);
})
);
}
estimateOf(view: SolutionView): string {
const estimates = this.info()?.estimates;
const operations: Record<SolutionView, Array<keyof NonNullable<SolutionCreatorInfo['estimates']>>> = {
overview: ['INITIAL_CONFIGURATION'],
dashboards: ['DASHBOARDS_CONFIGURATION'],
solution: ['CREATE', 'INSTALL']
};
const known = operations[view].map(operation => estimates?.[operation]).filter((estimate): estimate is SolutionEstimate => !!estimate);
if (!known.length || known.length < operations[view].length) {
return this.translate.instant('solution-creator.pane.estimate-' + view);
}
const seconds = known.reduce((sum, estimate) => sum + estimate.seconds, 0);
const credits = known.reduce((sum, estimate) => sum + estimate.credits, 0);
const time = seconds < 50
? this.translate.instant('solution-creator.pane.about-seconds', {count: Math.max(10, Math.round(seconds / 10) * 10)})
: seconds < 90
? this.translate.instant('solution-creator.pane.estimate-solution')
: this.translate.instant('solution-creator.pane.about-minutes', {count: Math.round(seconds / 60)});
return credits > 0 ? time + ' · ' + this.translate.instant('solution-creator.pane.credits', {credits: formatCredits(credits)}) : time;
}
answerQuestions(answers: AiQuestionAnswer[]): void {
this.sendMsgFromUser({message: answers.map(item => item.question.question.trim() + ' ' + item.answer.trim()).join('\n'), resources: []});
}
skipQuestions(answers: AiQuestionAnswer[]): void {
if (this.skipInterviewAllowed()) {
this.skipInterview();
} else {
this.answerQuestions(answers);
}
}
onRate(event: AnswerRatingEvent): void {
const target = this.answerAt(event.index);
if (!target) {
return;
}
const before = target.answer.rating;
this.patchAnswer(event.index, {rating: event.rating === 'NONE' ? undefined : event.rating});
this.aiSolutions.sendFeedback(this.solutionId, target.step, {answer: target.answer.content, rating: event.rating}).subscribe({
error: () => {
this.patchAnswer(event.index, {rating: before});
this.showErrorMessage(this.translate.instant('ai-assistant.feedback.failed'));
}
});
}
onReport(event: AnswerReportEvent): void {
const target = this.answerAt(event.index);
if (!target) {
return;
}
this.patchAnswer(event.index, {reported: true});
this.aiSolutions.sendFeedback(this.solutionId, target.step, {answer: target.answer.content, problem: event.problem, comment: event.comment}).subscribe({
next: () => this.store.dispatch(new ActionNotificationShow({
message: this.translate.instant('ai-assistant.feedback.thanks'), type: 'success', modern: true,
target: 'solution-creator-chat', verticalPosition: 'bottom', horizontalPosition: 'center'
})),
error: () => {
this.patchAnswer(event.index, {reported: false});
this.showErrorMessage(this.translate.instant('ai-assistant.feedback.failed'));
}
});
}
private answerAt(index: number): {answer: GeneralChatMessage; step: SolutionStep} | null {
const message = this.messages()[index] as GeneralChatMessage;
if (!this.solutionId || message?.from !== 'AI' || !message.content) {
return null;
}
return {answer: message, step: this.messageSteps[index] ?? this.solutionStep()};
}
private patchAnswer(index: number, patch: Partial<GeneralChatMessage>): void {
this.messages.update(list => list.map((message, at) => at === index ? {...message, ...patch} as GeneralChatMessage : message));
}
uninstallSolution() {
this.dialogService.confirm(
this.translate.instant('solution-creator.uninstall-solution-dialog-title', {name: this.solutionInfo.data.solutionTitle}),
@ -703,6 +896,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
).subscribe({
next: () => {
this.messages.set([]);
this.messageSteps = [];
this.isReadyStep.set(false);
if (this.solutionStep() === SolutionStep.DASHBOARDS_CONFIGURATION) {
this.sendDashboardConfigurationMsg('<start/>');
@ -891,8 +1085,10 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
const steps = this.solutionStep() === SolutionStep.DASHBOARDS_CONFIGURATION
? [SolutionStep.INITIAL_CONFIGURATION, SolutionStep.DASHBOARDS_CONFIGURATION]
: [SolutionStep.INITIAL_CONFIGURATION];
this.messages.set(steps.flatMap(step => this.solutionInfo.states[step]?.messages ?? [])
.filter(msg => msg.from === 'AI' || (msg.from === 'USER' && !/^<[a-z-]+\/>$/.test((msg.content ?? '').trim()))));
const visible = (msg: ChatMessage) => msg.from === 'AI' || (msg.from === 'USER' && !/^<[a-z-]+\/>$/.test(((msg as GeneralChatMessage).content ?? '').trim()));
const tagged = steps.flatMap(step => (this.solutionInfo.states[step]?.messages ?? []).filter(visible).map(message => ({message, step})));
this.messageSteps = tagged.map(item => item.step);
this.messages.set(tagged.map(item => item.message));
const stepState = this.solutionInfo.states[this.solutionStep()];
if (stepState?.status === SolutionStepStatus.READY) {
this.solutionName = this.solutionInfo.data?.solutionTitle;
@ -933,6 +1129,7 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
this.skipInterviewAllowed.set(false);
this.solutionStep.set(SolutionStep.INITIAL_CONFIGURATION);
this.messages.set([]);
this.messageSteps = [];
this.stopLoadingState();
this.creatorStep.set(null);
this.promptInput?.reset();
@ -944,7 +1141,8 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}
private initPredefinedSolution(): void {
this.failure.set(null);
const listed = this.aiSolutions.find(this.solutionInfo?.id);
this.failure.set(listed?.status === 'FAILED' ? listed.statusReason ?? null : null);
if (this.solutionInfo.metadata?.built) {
if (this.solutionInfo.states[SolutionStep.DASHBOARDS_CONFIGURATION]) {
this.solutionStep.set(SolutionStep.DASHBOARDS_CONFIGURATION);
@ -1165,9 +1363,11 @@ export class SolutionChatComponent extends PageComponent implements OnInit, OnDe
}
sendMsgFromUser(prompt: AiPromptMessage): void {
const time = Date.now();
this.messageSteps = [...this.messageSteps, this.solutionStep()];
this.messages.update(list => [...list, prompt.resources.length
? {from: 'USER', content: prompt.message, resources: prompt.resources}
: {from: 'USER', content: prompt.message}]);
? {from: 'USER', content: prompt.message, resources: prompt.resources, time}
: {from: 'USER', content: prompt.message, time}]);
this.sendMessage(prompt.message, prompt.resources.map(resource => resource.id)).subscribe(() => {});
}

12
ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.html

@ -58,7 +58,7 @@
</div>
} @else {
<div class="ai-row" role="link" tabindex="0" [class.active]="isActive(chat)"
[class.attn]="!!chat.chat && aiChats.needsAttention(chat.chat)"
[class.attn]="needsAttention(chat)"
[attr.aria-current]="isActive(chat) ? 'page' : null"
(click)="selectRow(chat)" (keydown.enter)="selectRow(chat)">
<span class="ai-row-title" [matTooltip]="'ai-assistant.double-click-to-rename' | translate" matTooltipPosition="after"
@ -67,10 +67,8 @@
@if (chat.solution) {
<mat-icon class="ai-row-ic" fontSet="material-icons-round" aria-hidden="true">layers</mat-icon>
}{{ chat.title }}</span>
@if (chat.chat && aiChats.levelOf(chat.chat); as level) {
<span [class]="'tb-ai-status-mark ' + level" [matTooltip]="aiChats.tipOf(chat.chat)" matTooltipPosition="above"></span>
} @else if (chat.solution && aiSolutions.isRunning(chat.solution.id)) {
<span class="tb-ai-status-mark running" [matTooltip]="'ai-assistant.status-tip-running' | translate" matTooltipPosition="above"></span>
@if (levelOf(chat); as level) {
<span [class]="'tb-ai-status-mark ' + level" [matTooltip]="tipOf(chat)" matTooltipPosition="above"></span>
}
<button type="button" class="ai-row-menu" [matMenuTriggerFor]="chat.solution ? solutionMenu : chatMenu"
[matMenuTriggerData]="{chat: chat.chat, solution: chat.solution, row: chat}" (click)="$event.stopPropagation()"
@ -143,6 +141,10 @@
<mat-icon fontSet="material-icons-round">edit</mat-icon>
<span>{{ 'action.rename' | translate }}</span>
</button>
<button mat-menu-item (click)="togglePinnedSolution(solution)">
<mat-icon fontSet="material-icons-round">push_pin</mat-icon>
<span>{{ (solution.pinned ? 'ai-assistant.unpin' : 'ai-assistant.pin') | translate }}</span>
</button>
@if (solution.built) {
<button mat-menu-item (click)="editDesign(solution)">
<mat-icon fontSet="material-icons-round">design_services</mat-icon>

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

@ -23,7 +23,7 @@ import { AppState } from '@core/core.state';
import { AiChatsService } from '@core/services/ai-chats.service';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { isNotEmptyStr, parseHttpErrorMessage } from '@core/utils';
import { ChatInfo } from '@shared/models/ai-chat.models';
import { ChatInfo, ChatLevel } from '@shared/models/ai-chat.models';
import { DAY, WEEK } from '@shared/models/time/time.models';
import { AiChatComponent } from '@home/components/ai/ai-chat.component';
import { AiSolutionsService } from '@core/services/ai-solutions.service';
@ -89,7 +89,7 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
id: chat.id, title: chat.title, createdTime: chat.createdTime, pinned: !!chat.pinned, chat
})),
...this.aiSolutions.solutions().map(solution => ({
id: solution.id, title: this.aiSolutions.titleOf(solution), createdTime: solution.createdTime ?? 0, pinned: false, solution
id: solution.id, title: this.aiSolutions.titleOf(solution), createdTime: solution.createdTime ?? 0, pinned: !!solution.pinned, solution
}))
].sort((a, b) => b.createdTime - a.createdTime));
@ -115,28 +115,28 @@ 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) => row.chat && this.aiChats.needsAttention(row.chat) ? 0 : 1;
const needsFirst = (row: AiRailRow) => this.needsAttention(row) ? 0 : 1;
groups.forEach(group => group.chats.sort((a, b) => needsFirst(a) - needsFirst(b)));
return groups.filter(group => group.chats.length);
});
waiting = computed<ChatInfo[]>(() => {
const rank = (chat: ChatInfo) => this.aiChats.levelOf(chat) === 'needs' ? 0 : 1;
return this.aiChats.chats()
.filter(chat => this.aiChats.needsAttention(chat))
waiting = computed<AiRailRow[]>(() => {
const rank = (row: AiRailRow) => this.levelOf(row) === 'needs' ? 0 : 1;
return this.rows()
.filter(row => this.needsAttention(row))
.sort((a, b) => rank(a) - rank(b) || b.createdTime - a.createdTime);
});
waitItem = computed<{count: number; tip: string; label: string} | null>(() => {
const waiting = this.waiting();
if (!waiting.length || (waiting.length === 1 && waiting[0].id === this.chatId())) {
if (!waiting.length || (waiting.length === 1 && this.isActive(waiting[0]))) {
return null;
}
if (waiting.length === 1) {
const title = waiting[0].title || this.translate.instant('ai-assistant.new-chat');
return {
count: 1,
tip: this.translate.instant('ai-assistant.waiting-one-tip', {title, status: this.aiChats.tipOf(waiting[0])}),
tip: this.translate.instant('ai-assistant.waiting-one-tip', {title, status: this.tipOf(waiting[0])}),
label: this.translate.instant('ai-assistant.waiting-one', {title})
};
}
@ -313,10 +313,27 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
this.solutionId.set(solutionId);
}
levelOf(row: AiRailRow): ChatLevel | null {
return row.chat ? this.aiChats.levelOf(row.chat) : this.aiSolutions.levelOf(row.solution, this.isActive(row));
}
tipOf(row: AiRailRow): string {
return row.chat ? this.aiChats.tipOf(row.chat) : this.aiSolutions.tipOf(row.solution, this.isActive(row));
}
needsAttention(row: AiRailRow): boolean {
const level = this.levelOf(row);
return level === 'needs' || level === 'error';
}
togglePinnedSolution(solution: SolutionInfo): void {
this.aiSolutions.setPinned(solution, !solution.pinned).subscribe({error: err => this.showErrorMessage(err)});
}
openWaiting(): void {
const waiting = this.waiting();
if (waiting.length === 1) {
this.selectChat(waiting[0]);
this.selectRow(waiting[0]);
return;
}
this.setRailOpen(true);

48
ui-ngx/src/app/shared/models/solution-creator.models.ts

@ -17,6 +17,16 @@ export interface SolutionInfo {
solutionTitle?: string;
installed?: boolean;
built?: boolean;
pinned?: boolean;
status?: 'RUNNING' | 'NEEDS_YOU' | 'FAILED';
statusReason?: string;
}
export type SolutionOperation = 'INITIAL_CONFIGURATION' | 'DASHBOARDS_CONFIGURATION' | 'CREATE' | 'INSTALL';
export interface SolutionEstimate {
credits: number;
seconds: number;
}
export interface SolutionCreatorInfo {
@ -25,6 +35,39 @@ export interface SolutionCreatorInfo {
states: Record<SolutionStep, SolutionStepState>;
data: SolutionData;
metadata?: SolutionMetadata;
estimates?: Partial<Record<SolutionOperation, SolutionEstimate>>;
}
export interface SolutionInstallProgress {
running: boolean;
phase?: string;
entityResults: Partial<Record<EntityType, EntityResult[]>>;
}
export interface SolutionUpdateRequest {
title?: string;
pinned?: boolean;
step?: SolutionStep;
feedback?: {answer: string; rating?: 'UP' | 'DOWN' | 'NONE'; problem?: string; comment?: string};
}
export interface AiQuestionOption {
label: string;
hint?: string;
}
export interface AiQuestion {
id: string;
label?: string;
question: string;
why?: string;
options: AiQuestionOption[];
recommended?: string;
}
export interface AiQuestionAnswer {
question: AiQuestion;
answer: string;
}
export interface DashboardsOverview {
@ -192,6 +235,11 @@ export interface GeneralChatMessage {
startedFrom?: AiStartedFrom;
resources?: AiResourceInfo[];
time?: number;
questions?: AiQuestion[];
answers?: AiQuestionAnswer[];
done?: boolean;
lead?: string;
note?: string;
}
export interface ActionChatMessage {

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

@ -691,6 +691,17 @@
"use-system-mobile-settings": "Use system mobile settings"
},
"ai-assistant": {
"question": {
"needs-answer": "Needs an answer",
"count": "{{at}} of {{of}}",
"other": "Something else",
"other-hint": "type your answer",
"next": "Next",
"done": "Done",
"skip": "Skip",
"you-said": "You said",
"skipped": "You skipped"
},
"ai-assistant": "AI Assistant",
"configure-with-ai": "Configure with AI",
"follow-up-prompt-placeholder": "Add something, or ask what happened…",
@ -11748,6 +11759,9 @@
"estimate-overview": "About 30 seconds",
"estimate-dashboards": "About 30 seconds",
"estimate-solution": "About a minute",
"about-seconds": "About {{count}} seconds",
"about-minutes": "About {{count}} minutes",
"credits": "{{credits}} credits",
"get-started": "Get started",
"installed": "Solution installed",
"installed-line": "{ entities, plural, =1 {1 entity} other {# entities} } · { dashboards, plural, =1 {1 dashboard} other {# dashboards} } · live on simulated data",
@ -11824,6 +11838,10 @@
"issues-lead": "{ count, plural, =1 {One item needs a look} other {# items need a look} } after the install:",
"issues-tip-lead": "Tip:",
"issues-tip": "open the Solution view to see what went wrong with each, or ask about it here.",
"assumptions": "Assumptions",
"next-dashboards-note": "Say what to change, or go on to the dashboards.",
"next-create": "Say what to change, or create the solution.",
"type-the-answer": "Or type the answer here…",
"say-what-to-change": "Say what to change in the design…",
"ask-about-solution": "Ask about the solution…",
"next-dashboards": "Next: dashboards",

271
ui-ngx/src/scss/roboto.scss

@ -0,0 +1,271 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-cyrillic-ext-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-cyrillic-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-greek-ext-wght-normal.woff2') format('woff2-variations');
unicode-range: U+1F00-1FFF;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-greek-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-math-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0302-0303,U+0305,U+0307-0308,U+0310,U+0312,U+0315,U+031A,U+0326-0327,U+032C,U+032F-0330,U+0332-0333,U+0338,U+033A,U+0346,U+034D,U+0391-03A1,U+03A3-03A9,U+03B1-03C9,U+03D1,U+03D5-03D6,U+03F0-03F1,U+03F4-03F5,U+2016-2017,U+2034-2038,U+203C,U+2040,U+2043,U+2047,U+2050,U+2057,U+205F,U+2070-2071,U+2074-208E,U+2090-209C,U+20D0-20DC,U+20E1,U+20E5-20EF,U+2100-2112,U+2114-2115,U+2117-2121,U+2123-214F,U+2190,U+2192,U+2194-21AE,U+21B0-21E5,U+21F1-21F2,U+21F4-2211,U+2213-2214,U+2216-22FF,U+2308-230B,U+2310,U+2319,U+231C-2321,U+2336-237A,U+237C,U+2395,U+239B-23B7,U+23D0,U+23DC-23E1,U+2474-2475,U+25AF,U+25B3,U+25B7,U+25BD,U+25C1,U+25CA,U+25CC,U+25FB,U+266D-266F,U+27C0-27FF,U+2900-2AFF,U+2B0E-2B11,U+2B30-2B4C,U+2BFE,U+3030,U+FF5B,U+FF5D,U+1D400-1D7FF,U+1EE00-1EEFF;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-symbols-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0001-000C,U+000E-001F,U+007F-009F,U+20DD-20E0,U+20E2-20E4,U+2150-218F,U+2190,U+2192,U+2194-2199,U+21AF,U+21E6-21F0,U+21F3,U+2218-2219,U+2299,U+22C4-22C6,U+2300-243F,U+2440-244A,U+2460-24FF,U+25A0-27BF,U+2800-28FF,U+2921-2922,U+2981,U+29BF,U+29EB,U+2B00-2BFF,U+4DC0-4DFF,U+FFF9-FFFB,U+10140-1018E,U+10190-1019C,U+101A0,U+101D0-101FD,U+102E0-102FB,U+10E60-10E7E,U+1D2C0-1D2D3,U+1D2E0-1D37F,U+1F000-1F0FF,U+1F100-1F1AD,U+1F1E6-1F1FF,U+1F30D-1F30F,U+1F315,U+1F31C,U+1F31E,U+1F320-1F32C,U+1F336,U+1F378,U+1F37D,U+1F382,U+1F393-1F39F,U+1F3A7-1F3A8,U+1F3AC-1F3AF,U+1F3C2,U+1F3C4-1F3C6,U+1F3CA-1F3CE,U+1F3D4-1F3E0,U+1F3ED,U+1F3F1-1F3F3,U+1F3F5-1F3F7,U+1F408,U+1F415,U+1F41F,U+1F426,U+1F43F,U+1F441-1F442,U+1F444,U+1F446-1F449,U+1F44C-1F44E,U+1F453,U+1F46A,U+1F47D,U+1F4A3,U+1F4B0,U+1F4B3,U+1F4B9,U+1F4BB,U+1F4BF,U+1F4C8-1F4CB,U+1F4D6,U+1F4DA,U+1F4DF,U+1F4E3-1F4E6,U+1F4EA-1F4ED,U+1F4F7,U+1F4F9-1F4FB,U+1F4FD-1F4FE,U+1F503,U+1F507-1F50B,U+1F50D,U+1F512-1F513,U+1F53E-1F54A,U+1F54F-1F5FA,U+1F610,U+1F650-1F67F,U+1F687,U+1F68D,U+1F691,U+1F694,U+1F698,U+1F6AD,U+1F6B2,U+1F6B9-1F6BA,U+1F6BC,U+1F6C6-1F6CF,U+1F6D3-1F6D7,U+1F6E0-1F6EA,U+1F6F0-1F6F3,U+1F6F7-1F6FC,U+1F700-1F7FF,U+1F800-1F80B,U+1F810-1F847,U+1F850-1F859,U+1F860-1F887,U+1F890-1F8AD,U+1F8B0-1F8BB,U+1F8C0-1F8C1,U+1F900-1F90B,U+1F93B,U+1F946,U+1F984,U+1F996,U+1F9E9,U+1FA00-1FA6F,U+1FA70-1FA7C,U+1FA80-1FA89,U+1FA8F-1FAC6,U+1FACE-1FADC,U+1FADF-1FAE9,U+1FAF0-1FAF8,U+1FB00-1FBFF;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-vietnamese-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-latin-ext-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-latin-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-cyrillic-ext-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-cyrillic-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-greek-ext-wght-italic.woff2') format('woff2-variations');
unicode-range: U+1F00-1FFF;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-greek-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-math-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0302-0303,U+0305,U+0307-0308,U+0310,U+0312,U+0315,U+031A,U+0326-0327,U+032C,U+032F-0330,U+0332-0333,U+0338,U+033A,U+0346,U+034D,U+0391-03A1,U+03A3-03A9,U+03B1-03C9,U+03D1,U+03D5-03D6,U+03F0-03F1,U+03F4-03F5,U+2016-2017,U+2034-2038,U+203C,U+2040,U+2043,U+2047,U+2050,U+2057,U+205F,U+2070-2071,U+2074-208E,U+2090-209C,U+20D0-20DC,U+20E1,U+20E5-20EF,U+2100-2112,U+2114-2115,U+2117-2121,U+2123-214F,U+2190,U+2192,U+2194-21AE,U+21B0-21E5,U+21F1-21F2,U+21F4-2211,U+2213-2214,U+2216-22FF,U+2308-230B,U+2310,U+2319,U+231C-2321,U+2336-237A,U+237C,U+2395,U+239B-23B7,U+23D0,U+23DC-23E1,U+2474-2475,U+25AF,U+25B3,U+25B7,U+25BD,U+25C1,U+25CA,U+25CC,U+25FB,U+266D-266F,U+27C0-27FF,U+2900-2AFF,U+2B0E-2B11,U+2B30-2B4C,U+2BFE,U+3030,U+FF5B,U+FF5D,U+1D400-1D7FF,U+1EE00-1EEFF;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-symbols-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0001-000C,U+000E-001F,U+007F-009F,U+20DD-20E0,U+20E2-20E4,U+2150-218F,U+2190,U+2192,U+2194-2199,U+21AF,U+21E6-21F0,U+21F3,U+2218-2219,U+2299,U+22C4-22C6,U+2300-243F,U+2440-244A,U+2460-24FF,U+25A0-27BF,U+2800-28FF,U+2921-2922,U+2981,U+29BF,U+29EB,U+2B00-2BFF,U+4DC0-4DFF,U+FFF9-FFFB,U+10140-1018E,U+10190-1019C,U+101A0,U+101D0-101FD,U+102E0-102FB,U+10E60-10E7E,U+1D2C0-1D2D3,U+1D2E0-1D37F,U+1F000-1F0FF,U+1F100-1F1AD,U+1F1E6-1F1FF,U+1F30D-1F30F,U+1F315,U+1F31C,U+1F31E,U+1F320-1F32C,U+1F336,U+1F378,U+1F37D,U+1F382,U+1F393-1F39F,U+1F3A7-1F3A8,U+1F3AC-1F3AF,U+1F3C2,U+1F3C4-1F3C6,U+1F3CA-1F3CE,U+1F3D4-1F3E0,U+1F3ED,U+1F3F1-1F3F3,U+1F3F5-1F3F7,U+1F408,U+1F415,U+1F41F,U+1F426,U+1F43F,U+1F441-1F442,U+1F444,U+1F446-1F449,U+1F44C-1F44E,U+1F453,U+1F46A,U+1F47D,U+1F4A3,U+1F4B0,U+1F4B3,U+1F4B9,U+1F4BB,U+1F4BF,U+1F4C8-1F4CB,U+1F4D6,U+1F4DA,U+1F4DF,U+1F4E3-1F4E6,U+1F4EA-1F4ED,U+1F4F7,U+1F4F9-1F4FB,U+1F4FD-1F4FE,U+1F503,U+1F507-1F50B,U+1F50D,U+1F512-1F513,U+1F53E-1F54A,U+1F54F-1F5FA,U+1F610,U+1F650-1F67F,U+1F687,U+1F68D,U+1F691,U+1F694,U+1F698,U+1F6AD,U+1F6B2,U+1F6B9-1F6BA,U+1F6BC,U+1F6C6-1F6CF,U+1F6D3-1F6D7,U+1F6E0-1F6EA,U+1F6F0-1F6F3,U+1F6F7-1F6FC,U+1F700-1F7FF,U+1F800-1F80B,U+1F810-1F847,U+1F850-1F859,U+1F860-1F887,U+1F890-1F8AD,U+1F8B0-1F8BB,U+1F8C0-1F8C1,U+1F900-1F90B,U+1F93B,U+1F946,U+1F984,U+1F996,U+1F9E9,U+1FA00-1FA6F,U+1FA70-1FA7C,U+1FA80-1FA89,U+1FA8F-1FAC6,U+1FACE-1FADC,U+1FADF-1FAE9,U+1FAF0-1FAF8,U+1FB00-1FBFF;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-vietnamese-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-latin-ext-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-display: swap;
font-weight: 100 900;
src: url('../../node_modules/@fontsource-variable/roboto/files/roboto-latin-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-cyrillic-ext-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-cyrillic-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-greek-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-vietnamese-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-latin-ext-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-latin-wght-normal.woff2') format('woff2-variations');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-cyrillic-ext-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-cyrillic-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-greek-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-vietnamese-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-latin-ext-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
font-family: 'Roboto Mono';
font-style: italic;
font-display: swap;
font-weight: 100 700;
src: url('../../node_modules/@fontsource-variable/roboto-mono/files/roboto-mono-latin-wght-italic.woff2') format('woff2-variations');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

3
ui-ngx/src/styles.scss

@ -2,8 +2,7 @@
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
/* You can add global styles to this file, and also import other style files */
@import 'typeface-roboto/index.css';
@import 'typeface-roboto-mono/index.css';
@import './scss/roboto';
@import 'font-awesome/css/font-awesome.min.css';
@import './scss/constants';
@import './scss/animations';

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

@ -1557,3 +1557,369 @@ body.tb-ai-resizing, body.tb-ai-resizing * {
transition: none;
}
}
.k-ask {
position: relative;
display: grid;
gap: 12px;
padding: calc(var(--chat-card-pad) - 2px) var(--chat-card-pad);
background: var(--tb-surface);
border: 1px solid var(--k-stroke);
border-radius: 12px;
box-shadow: none;
font-family: var(--tb-font);
font-size: 14px;
line-height: 20px;
letter-spacing: .25px;
color: var(--tb-ink);
> .k-head {
display: flex;
align-items: center;
gap: 6px;
padding-right: 44px;
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
font-weight: 500;
color: var(--tb-ink);
> .mat-icon {
margin-top: 1px;
color: var(--tb-ink-54);
}
.k-sub {
font-weight: 400;
font-size: var(--chat-meta);
}
.k-count {
margin-left: 2px;
}
}
&.stepped {
gap: 14px;
.k-step {
display: grid;
gap: 12px;
&.in-next, &.in-back {
animation: k-fade-through .15s cubic-bezier(.2, 0, 0, 1);
}
}
}
.k-ask-q {
b {
display: block;
font-size: 17px;
line-height: 24px;
font-weight: 500;
color: var(--tb-ink);
}
.k-why {
display: block;
align-items: flex-start;
gap: 6px;
margin-top: 3px;
font-size: 14px;
line-height: 20px;
color: var(--tb-ink-76);
}
}
.k-ask-a > * + * {
margin-top: 10px;
}
.k-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
margin-top: 0;
.mat-mdc-button:not(:disabled) {
color: var(--tb-ink-76);
}
.tb-spacer {
flex: 1;
}
.mdc-button {
transition: opacity .15s ease, background-color .15s ease;
&:disabled {
opacity: .45;
cursor: default;
}
}
}
.k-optbody span {
font-size: 13.5px;
line-height: 18px;
color: var(--tb-ink-76);
}
.ob-chip:disabled {
cursor: default;
opacity: 1;
}
> .k-time {
position: absolute;
right: 16px;
top: 14px;
margin-left: 8px;
}
&.answered {
container-type: inline-size;
gap: 8px;
padding: 10px 16px;
background: var(--tb-surface);
box-shadow: none;
> .k-head {
color: var(--tb-ink-76);
}
.k-q {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
align-items: baseline;
gap: 10px;
}
.k-qt {
font-size: 14px;
line-height: 22px;
color: var(--tb-ink-76);
}
.k-opts {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.ob-chip[aria-pressed="true"] {
height: auto;
min-height: 0;
padding: 0;
border: 0;
border-radius: 0;
background: none;
box-shadow: none;
font-size: 15px;
line-height: 22px;
font-weight: 500;
color: var(--tb-ink);
white-space: normal;
text-align: left;
}
@container (max-width: 560px) {
.k-q {
grid-template-columns: minmax(0, 1fr);
gap: 1px;
}
.k-q + .k-q {
margin-top: 6px;
}
.k-qt {
font-size: 13px;
line-height: 18px;
}
.ob-chip[aria-pressed="true"] {
font-size: 14px;
line-height: 20px;
}
}
}
}
.k-optcards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(max(150px, calc((100% - (var(--n, 3) - 1) * 8px) / var(--n, 3))), 1fr));
gap: 8px;
&.list {
grid-template-columns: minmax(0, 1fr);
.k-optcard {
padding: 12px 14px;
}
.k-optbody b {
font-size: 15px;
line-height: 21px;
font-weight: 400;
}
.k-optcard[aria-checked="true"] .k-optbody b {
font-weight: 500;
}
}
> .k-optcard.other {
grid-column: 1 / -1;
}
}
.k-optcard {
display: grid;
grid-template-columns: 18px minmax(0, 1fr);
gap: 10px;
align-items: start;
padding: 10px 12px;
border: 1px solid var(--tb-line);
border-radius: 10px;
background: var(--tb-surface);
font: inherit;
letter-spacing: normal;
color: var(--tb-ink);
text-align: left;
cursor: pointer;
transition: background-color .1s cubic-bezier(.2, 0, 0, 1), border-color .1s cubic-bezier(.2, 0, 0, 1), box-shadow .1s cubic-bezier(.2, 0, 0, 1), color .1s cubic-bezier(.2, 0, 0, 1);
&:hover {
border-color: rgba(0, 0, 0, 0.25);
background: #fafbfb;
}
&:active {
background-color: rgba(0, 0, 0, 0.06);
}
&:focus-visible {
outline: 2px solid var(--ai-focus);
outline-offset: 2px;
}
&[aria-checked="true"] {
letter-spacing: .25px;
border-color: var(--ai-selected);
box-shadow: inset 0 0 0 1px var(--ai-selected);
background: var(--tb-surface);
.k-optdot {
border-color: var(--ai-selected);
&::after {
transform: scale(1);
}
}
.k-optbody b {
color: var(--tb-ink);
}
}
&.other {
cursor: text;
&:focus-within {
border-color: var(--ai-focus);
box-shadow: inset 0 0 0 1px var(--ai-focus);
}
}
}
.k-optdot {
position: relative;
width: 18px;
height: 18px;
margin-top: 1px;
box-sizing: border-box;
border: 2px solid var(--tb-ink-38);
border-radius: 50%;
transition: border-color .15s ease;
&::after {
content: '';
position: absolute;
inset: 3px;
border-radius: 50%;
background: var(--ai-teal-500);
transform: scale(0);
transition: transform .1s cubic-bezier(.2, 0, 0, 1);
}
}
.k-optbody {
b {
display: block;
font-size: 15px;
line-height: 20px;
font-weight: 500;
color: var(--tb-ink);
}
span {
display: block;
margin-top: 1px;
font-size: 12.5px;
line-height: 17px;
color: var(--tb-text-secondary);
}
}
.k-opt-input {
display: block;
width: 100%;
box-sizing: border-box;
margin-top: 3px;
padding: 3px 0 4px;
border: 0;
border-bottom: 1px solid var(--tb-line);
border-radius: 0;
background: transparent;
font: inherit;
font-size: 14px;
line-height: 20px;
color: var(--tb-ink);
outline: 0;
&::placeholder {
color: var(--tb-text-muted);
}
&:focus {
border-bottom-color: var(--tb-ink-54);
}
}
textarea.k-opt-input {
min-height: 27px;
resize: none;
overflow: hidden;
}
@keyframes k-fade-through {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.k-ask.stepped .k-step.in-next, .k-ask.stepped .k-step.in-back {
animation: none;
}
.k-optcard:active {
transform: none;
}
}

20
ui-ngx/yarn.lock

@ -835,6 +835,16 @@
dependencies:
tslib "^2.3.0"
"@fontsource-variable/roboto-mono@^5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@fontsource-variable/roboto-mono/-/roboto-mono-5.3.0.tgz#10c0f1c0c283a61fa1e0f24381a1e62ed6ad45fa"
integrity sha512-h5r+KY/6qy8JEOj33JgcrFO81YAnvrc1EAwMpl/EPJLb2OIvOy0/jmB5M7qs7x/uXk5JUP5Ux4LrkeOK7faHkQ==
"@fontsource-variable/roboto@^5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@fontsource-variable/roboto/-/roboto-5.3.0.tgz#3ddf845c018b0ea9d15b36e06515d0ebdb02f49e"
integrity sha512-BoaaZiQf8fgtxv07KXkTwx1bKz/EoqIlTXq2OOKKXINxp6qXWdnlChqV+hSaDANS49yyUASFl3OVBMMDTCIHFA==
"@fullcalendar/angular@^6.1.20":
version "6.1.22"
resolved "https://registry.yarnpkg.com/@fullcalendar/angular/-/angular-6.1.22.tgz#0820b2cd38154418b30278acd359f7be91206fc2"
@ -8444,16 +8454,6 @@ typed-array-length@^1.0.7:
possible-typed-array-names "^1.0.0"
reflect.getprototypeof "^1.0.6"
typeface-roboto-mono@^1.1.13:
version "1.1.13"
resolved "https://registry.yarnpkg.com/typeface-roboto-mono/-/typeface-roboto-mono-1.1.13.tgz#2af8662db8f9119c00efd55d6ed8877d2a69ec94"
integrity sha512-pnzDc70b7ywJHin/BUFL7HZX8DyOTBLT2qxlJ92eH1UJOFcENIBXa9IZrxsJX/gEKjbEDKhW5vz/TKRBNk/ufQ==
typeface-roboto@^1.1.13:
version "1.1.13"
resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-1.1.13.tgz#9c4517cb91e311706c74823e857b4bac9a764ae5"
integrity sha512-YXvbd3a1QTREoD+FJoEkl0VQNJoEjewR2H11IjVv4bp6ahuIcw0yyw/3udC4vJkHw3T3cUh85FTg8eWef3pSaw==
typescript-eslint@^8.72.0:
version "8.72.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.72.0.tgz#50a8fd6d4304ffd1e7fd375f8a439c6f15488071"

Loading…
Cancel
Save