From b8e623adf1feba6dc77ad7be9aedf00cc0802369 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 20 Nov 2026 18:51:02 +0200 Subject: [PATCH] feat: the AI button is the AI's mark, one component with the chat's welcome and header marks: its colour held back at rest and coming up under the pointer, on focus and while a closed chat works, a dot when a chat waits or failed, readable on a primary-coloured bar; the first time, the button glows and a popup introduces the docked chat in the page's own words, with its first suggestion and the / shortcut, shown on every page until the person answers it; the introduction's steps (welcome, assistant tour, AI button, Home) are kept per user in the user settings --- ui-ngx/src/app/core/auth/auth.actions.ts | 11 +- ui-ngx/src/app/core/auth/auth.effects.ts | 11 +- ui-ngx/src/app/core/auth/auth.reducer.ts | 10 + ui-ngx/src/app/core/auth/auth.selectors.ts | 14 +- .../ai/ai-assistant-button.component.ts | 176 +++++++++++- .../ai/ai-assistant-context.service.ts | 58 ++++ .../ai/ai-assistant-panel.component.ts | 55 +--- .../ai/ai-button-intro.component.ts | 39 +++ .../ai/ai-chat-messages.component.html | 2 +- .../home/components/ai/ai-chat.component.html | 106 +++---- .../home/components/ai/ai-mark.component.ts | 74 +++++ .../home/components/ai/ai-welcome.models.ts | 6 +- .../modules/home/components/ai/ai.module.ts | 6 + .../pane/solution-installed.component.html | 2 +- .../ai/solution/solution-chat.component.html | 4 +- .../app/shared/models/user-settings.models.ts | 10 + .../assets/locale/locale.constant-en_US.json | 12 + ui-ngx/src/theme/ai-theme.scss | 268 ++++++++++++++++-- 18 files changed, 712 insertions(+), 152 deletions(-) create mode 100644 ui-ngx/src/app/modules/home/components/ai/ai-assistant-context.service.ts create mode 100644 ui-ngx/src/app/modules/home/components/ai/ai-button-intro.component.ts create mode 100644 ui-ngx/src/app/modules/home/components/ai/ai-mark.component.ts diff --git a/ui-ngx/src/app/core/auth/auth.actions.ts b/ui-ngx/src/app/core/auth/auth.actions.ts index 328f2e06da..60501f9472 100644 --- a/ui-ngx/src/app/core/auth/auth.actions.ts +++ b/ui-ngx/src/app/core/auth/auth.actions.ts @@ -4,7 +4,7 @@ import { Action } from '@ngrx/store'; import { AuthUser, User } from '@shared/models/user.model'; import { AuthPayload } from '@core/auth/auth.models'; -import { UserSettings } from '@shared/models/user-settings.models'; +import { AiTourStep, UserSettings } from '@shared/models/user-settings.models'; export enum AuthActionTypes { AUTHENTICATED = '[Auth] Authenticated', @@ -16,6 +16,7 @@ export enum AuthActionTypes { UPDATE_HAS_REPOSITORY = '[Auth] Change Has Repository', UPDATE_MOBILE_QR_ENABLED = '[Auth] Update Mobile QR Enabled', UPDATE_OPENED_MENU_SECTION = '[Preferences] Update Opened Menu Section', + UPDATE_AI_TOUR = '[Preferences] Update AI tour', PUT_USER_SETTINGS = '[Preferences] Put user settings', DELETE_USER_SETTINGS = '[Preferences] Delete user settings', UPDATE_LICENSE_PARAMS = '[Auth] Update License Parameters', @@ -73,6 +74,12 @@ export class ActionPreferencesUpdateOpenedMenuSection implements Action { constructor(readonly payload: { path: string; opened: boolean }) {} } +export class ActionPreferencesUpdateAiTour implements Action { + readonly type = AuthActionTypes.UPDATE_AI_TOUR; + + constructor(readonly payload: { step: AiTourStep; seen: boolean }) {} +} + export class ActionPreferencesPutUserSettings implements Action { readonly type = AuthActionTypes.PUT_USER_SETTINGS; @@ -93,5 +100,5 @@ export class ActionUpdateLicenseParams implements Action { export type AuthActions = ActionAuthAuthenticated | ActionAuthUnauthenticated | ActionAuthLoadUser | ActionAuthUpdateUserDetails | ActionAuthUpdateLastPublicDashboardId | ActionAuthUpdateHasRepository | - ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings | + ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesUpdateAiTour | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings | ActionAuthUpdateAuthUser | ActionUpdateMobileQrCodeEnabled | ActionUpdateLicenseParams; diff --git a/ui-ngx/src/app/core/auth/auth.effects.ts b/ui-ngx/src/app/core/auth/auth.effects.ts index 1b006fd4f1..e7f56d2050 100644 --- a/ui-ngx/src/app/core/auth/auth.effects.ts +++ b/ui-ngx/src/app/core/auth/auth.effects.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 { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { select, Store } from '@ngrx/store'; @@ -26,6 +27,14 @@ export class AuthEffects { mergeMap(([action, state]) => this.userSettingsService.putUserSettings({ openedMenuSections: state.userSettings.openedMenuSections })) ), {dispatch: false}); + persistAiTour = createEffect(() => this.actions$.pipe( + ofType( + AuthActionTypes.UPDATE_AI_TOUR, + ), + withLatestFrom(this.store.pipe(select(selectAuthState))), + mergeMap(([action, state]) => this.userSettingsService.putUserSettings({ aiTour: state.userSettings.aiTour ?? {} })) + ), {dispatch: false}); + putUserSettings = createEffect(() => this.actions$.pipe( ofType( AuthActionTypes.PUT_USER_SETTINGS, diff --git a/ui-ngx/src/app/core/auth/auth.reducer.ts b/ui-ngx/src/app/core/auth/auth.reducer.ts index 8fa0d1d2ac..4eadd67641 100644 --- a/ui-ngx/src/app/core/auth/auth.reducer.ts +++ b/ui-ngx/src/app/core/auth/auth.reducer.ts @@ -97,6 +97,16 @@ export const authReducer = ( userSettings = {...state.userSettings, ...{ openedMenuSections: Array.from(openedMenuSections)}}; return { ...state, ...{ userSettings }}; + case AuthActionTypes.UPDATE_AI_TOUR: + const aiTour = {...state.userSettings.aiTour}; + if (action.payload.seen) { + aiTour[action.payload.step] = Date.now(); + } else { + delete aiTour[action.payload.step]; + } + userSettings = {...state.userSettings, aiTour}; + return { ...state, ...{ userSettings }}; + case AuthActionTypes.PUT_USER_SETTINGS: userSettings = {...state.userSettings, ...action.payload}; return { ...state, ...{ userSettings }}; diff --git a/ui-ngx/src/app/core/auth/auth.selectors.ts b/ui-ngx/src/app/core/auth/auth.selectors.ts index 399fe27183..02b8578b7d 100644 --- a/ui-ngx/src/app/core/auth/auth.selectors.ts +++ b/ui-ngx/src/app/core/auth/auth.selectors.ts @@ -1,12 +1,13 @@ // 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 { createFeatureSelector, createSelector, select, Store } from '@ngrx/store'; import { AppState } from '../core.state'; import { AuthState } from './auth.models'; import { take } from 'rxjs/operators'; import { AuthUser } from '@shared/models/user.model'; -import { UserSettings } from '@shared/models/user-settings.models'; +import { AiTourStep, UserSettings } from '@shared/models/user-settings.models'; import { getDescendantProp } from '@core/utils'; export const selectAuthState = createFeatureSelector< AuthState>( @@ -90,6 +91,15 @@ export const selectOpenedMenuSections = createSelector( (state: AuthState) => state.userSettings.openedMenuSections ); +export const selectAiTour = createSelector( + selectAuthState, + (state: AuthState) => state.userSettings?.aiTour ?? {} +); + +export const selectAiTourStepSeen = (step: AiTourStep) => createSelector( + selectAiTour, + aiTour => !!aiTour[step] +); export const getCurrentAuthState = (store: Store): AuthState => { let state: AuthState; diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-assistant-button.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-button.component.ts index 36508fbbae..12b3d277fe 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-assistant-button.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-button.component.ts @@ -1,31 +1,57 @@ // SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. // SPDX-License-Identifier: BUSL-1.1 -import { ChangeDetectionStrategy, Component, computed, HostListener, inject } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + effect, + ElementRef, + HostListener, + inject, + Renderer2, + signal, + untracked, + viewChild, + ViewContainerRef +} from '@angular/core'; +import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; +import { NavigationEnd, NavigationStart, Router } from '@angular/router'; +import { filter } from 'rxjs/operators'; import { TranslateService } from '@ngx-translate/core'; import { AiChatsService } from '@core/services/ai-chats.service'; import { ChatLevel } from '@shared/models/ai-chat.models'; import { MatDialog } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; -import { getCurrentAuthState } from '@core/auth/auth.selectors'; +import { getCurrentAuthState, selectAiTourStepSeen } from '@core/auth/auth.selectors'; +import { ActionPreferencesUpdateAiTour } from '@core/auth/auth.actions'; +import { AiTourStep } from '@shared/models/user-settings.models'; import { Authority } from '@shared/models/authority.enum'; import { UserPermissionsService } from '@core/http/user-permissions.service'; import { Operation, Resource } from '@shared/models/security.models'; import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service'; +import { TbPopoverService } from '@shared/components/popover.service'; +import { TbPopoverComponent } from '@shared/components/popover.component'; +import { AiAssistantContextService } from '@home/components/ai/ai-assistant-context.service'; +import { AiButtonIntroComponent } from '@home/components/ai/ai-button-intro.component'; +import { AiMarkCue } from '@home/components/ai/ai-mark.component'; + +const INTRO_DELAY_MS = 900; + +const intro: { owner: AiAssistantButtonComponent | null } = {owner: null}; @Component({ selector: 'tb-ai-assistant-button', template: ` @if (available && !panelService.open() && !panelService.suppressed()) { @let status = cue(); -
@@ -49,7 +75,9 @@ export class AiAssistantButtonComponent { panelService = inject(AiAssistantPanelService); - private readonly authState = getCurrentAuthState(inject(Store)); + private store = inject(Store); + + private readonly authState = getCurrentAuthState(this.store); readonly available = this.authState.aiEnabled && this.authState.authUser?.authority === Authority.TENANT_ADMIN @@ -61,12 +89,30 @@ export class AiAssistantButtonComponent { private translate = inject(TranslateService); + private context = inject(AiAssistantContextService); + + private popoverService = inject(TbPopoverService); + + private renderer = inject(Renderer2); + + private viewContainerRef = inject(ViewContainerRef); + + private buttonRef = viewChild('aiButton', {read: ElementRef}); + + private introSeen = toSignal(this.store.select(selectAiTourStepSeen(AiTourStep.AI_BUTTON)), {initialValue: true}); + + readonly introOpen = signal(false); + + private introPopover: TbPopoverComponent | null = null; + + private introTimer: ReturnType | null = null; + readonly cue = computed<{level: ChatLevel; tip: string} | null>(() => { const chats = this.chats.statusChats(); const titleOf = (title: string) => title || this.translate.instant('ai-assistant.new-chat'); const attention = chats.filter(chat => this.chats.needsAttention(chat)); if (attention.length) { - const level: ChatLevel = attention.some(chat => this.chats.levelOf(chat) === 'needs') ? 'needs' : 'error'; + const level: AiMarkCue = attention.some(chat => this.chats.levelOf(chat) === 'needs') ? 'needs' : 'error'; return { level, tip: attention.length === 1 @@ -86,10 +132,45 @@ export class AiAssistantButtonComponent { return null; }); + readonly markCue = computed(() => { + const level = this.cue()?.level; + return level === 'needs' || level === 'error' ? level : null; + }); + + private introWanted = computed(() => this.available && !this.introSeen() && this.cue()?.level !== 'running' && !this.panelService.open() + && !this.panelService.suppressed() && !!this.buttonRef()); + + private introEffect = effect(() => { + const wanted = this.introWanted(); + untracked(() => { + this.clearIntroTimer(); + if (wanted && !this.introOpen()) { + this.introTimer = setTimeout(() => this.showIntro(), INTRO_DELAY_MS); + } else if (!wanted && this.introOpen()) { + this.hideIntro(); + } + }); + }); + constructor() { if (this.available) { this.chats.watchStatus(); } + inject(Router).events.pipe( + filter(event => event instanceof NavigationStart || event instanceof NavigationEnd), + takeUntilDestroyed() + ).subscribe(event => { + this.clearIntroTimer(); + if (event instanceof NavigationStart) { + this.hideIntro(); + } else if (this.introWanted()) { + this.introTimer = setTimeout(() => this.showIntro(), INTRO_DELAY_MS); + } + }); + inject(DestroyRef).onDestroy(() => { + this.clearIntroTimer(); + this.hideIntro(); + }); } @HostListener('document:keydown', ['$event']) @@ -101,11 +182,84 @@ export class AiAssistantButtonComponent { return; } event.preventDefault(); - this.panelService.openPanel(); + this.openChat(); } toggle($event: Event): void { $event.stopPropagation(); + this.openChat(); + } + + private openChat(): void { + if (this.introOpen()) { + this.closeIntro(); + } this.panelService.openPanel(); } + + private showIntro(): void { + this.introTimer = null; + const trigger: HTMLElement | undefined = this.buttonRef()?.nativeElement; + if (!this.introWanted() || !trigger || intro.owner || this.dialog.openDialogs.length || !this.visible(trigger)) { + return; + } + intro.owner = this; + const welcome = this.context.welcome(); + const example = welcome.examples[0]?.label?.trim(); + this.introOpen.set(true); + this.introPopover = this.popoverService.displayPopover({ + trigger, + renderer: this.renderer, + componentType: AiButtonIntroComponent, + hostView: this.viewContainerRef, + preferredPlacement: ['bottomRight', 'bottom', 'bottomLeft'], + hideOnClickOutside: false, + showCloseButton: false, + context: { + title: welcome.title || this.translate.instant('ai-assistant.panel-title'), + lead: this.translate.instant(`ai-assistant.intro.lead-${welcome.place}${example ? '-example' : ''}`, {example}), + keyboard: matchMedia('(hover: hover) and (pointer: fine)').matches + }, + visibleFn: visible => { + if (!visible && this.introOpen()) { + this.introPopover = null; + this.hideIntro(); + } + } + }); + this.introPopover.tbOverlayClassName = 'tb-ai-intro-popover'; + this.introPopover.updateStyles(); + const instance = this.introPopover.tbComponentRef.instance; + instance.dismiss.subscribe(() => this.closeIntro()); + instance.openChat.subscribe(() => this.openChat()); + } + + private closeIntro(): void { + this.hideIntro(); + if (!this.introSeen()) { + this.store.dispatch(new ActionPreferencesUpdateAiTour({step: AiTourStep.AI_BUTTON, seen: true})); + } + } + + private hideIntro(): void { + if (intro.owner === this) { + intro.owner = null; + } + this.introOpen.set(false); + const popover = this.introPopover; + this.introPopover = null; + popover?.hide(); + } + + private clearIntroTimer(): void { + if (this.introTimer) { + clearTimeout(this.introTimer); + this.introTimer = null; + } + } + + private visible(element: HTMLElement): boolean { + const rect = element.getBoundingClientRect(); + return rect.width > 0 && rect.height > 0 && (element.checkVisibility?.({visibilityProperty: true}) ?? element.offsetParent !== null); + } } diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-assistant-context.service.ts b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-context.service.ts new file mode 100644 index 0000000000..f17294b9d0 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-context.service.ts @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { computed, inject, Injectable } from '@angular/core'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { NavigationEnd, Router } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { filter, map, startWith } from 'rxjs/operators'; +import { aiPageView, AiChatClientContext } from '@shared/models/ai-chat.models'; +import { getDefaultTimezone } from '@shared/models/time/time.models'; +import { BreadCrumb } from '@shared/components/breadcrumb'; +import { BreadcrumbService } from '@core/services/breadcrumb.service'; +import { UtilsService } from '@core/services/utils.service'; +import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service'; +import { aiWelcome } from '@home/components/ai/ai-welcome.models'; + +@Injectable({providedIn: 'root'}) +export class AiAssistantContextService { + + private panelService = inject(AiAssistantPanelService); + private translate = inject(TranslateService); + private utils = inject(UtilsService); + private router = inject(Router); + + private pageTitle = toSignal(inject(BreadcrumbService).breadcrumbs$.pipe( + map(crumbs => crumbs.map(crumb => this.crumbLabel(crumb)).filter(label => !!label).join(' › ')) + ), {initialValue: ''}); + + readonly pagePath = toSignal(this.router.events.pipe( + filter((event): event is NavigationEnd => event instanceof NavigationEnd), + map(event => event.urlAfterRedirects), + startWith(this.router.url), + map(url => (url || '/').split(/[?#]/)[0]) + ), {initialValue: '/'}); + + readonly clientContext = computed(() => { + const context = this.panelService.clientContext(); + if (context) { + const name = this.panelService.viewName(); + return context.view?.entityId && name && !context.view.title ? {...context, view: {...context.view, title: name}} : context; + } + const title = this.pageTitle(); + const path = this.pagePath(); + const type = aiPageView(path); + return title || path !== '/' ? {view: {type, title, path}, timeZone: getDefaultTimezone()} : undefined; + }); + + readonly welcome = computed(() => aiWelcome(this.clientContext()?.view, this.panelService.viewName(), this.panelService.config(), + this.translate)); + + private crumbLabel(crumb: BreadCrumb): string { + try { + return crumb.labelFunction ? crumb.labelFunction() : crumb.customTranslate ? this.utils.customTranslation(crumb.label, crumb.label) + : this.translate.instant(crumb.label); + } catch { + return ''; + } + } +} diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts index 4179aefccd..5035130ad1 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/ai/ai-assistant-panel.component.ts @@ -1,21 +1,11 @@ // SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. // SPDX-License-Identifier: BUSL-1.1 -import { aiPageView, AiChatClientContext } from '@shared/models/ai-chat.models'; -import { getDefaultTimezone } from '@shared/models/time/time.models'; -import { BreadCrumb } from '@shared/components/breadcrumb'; -import { UtilsService } from '@core/services/utils.service'; -import { BreadcrumbService } from '@core/services/breadcrumb.service'; -import { filter, map, startWith } from 'rxjs/operators'; -import { toSignal } from '@angular/core/rxjs-interop'; -import { Router, NavigationEnd } from '@angular/router'; -import { aiWelcome } from '@home/components/ai/ai-welcome.models'; import { Component, computed, effect, ElementRef, inject, NgZone, signal, untracked, ViewChild } from '@angular/core'; import { MatTooltip } from '@angular/material/tooltip'; -import { AiAssistantPromptExample } from '@shared/models/ai-chat.models'; import { AiAssistantPanelService } from '@core/services/ai-assistant-panel.service'; -import { TranslateService } from '@ngx-translate/core'; import { AiChatsService } from '@core/services/ai-chats.service'; import { AiChatComponent } from '@home/components/ai/ai-chat.component'; +import { AiAssistantContextService } from '@home/components/ai/ai-assistant-context.service'; @Component({ selector: 'tb-ai-assistant-panel', @@ -38,8 +28,6 @@ export class AiAssistantPanelComponent { panelService = inject(AiAssistantPanelService); - private translate = inject(TranslateService); - @ViewChild(AiChatComponent) chat: AiChatComponent; @ViewChild('gripTip', {read: MatTooltip}) gripTip: MatTooltip; @@ -83,37 +71,11 @@ export class AiAssistantPanelComponent { chatId = signal(undefined); - private router = inject(Router); - - private utils = inject(UtilsService); - - private pageTitle = toSignal(inject(BreadcrumbService).breadcrumbs$.pipe( - map(crumbs => crumbs.map(crumb => this.crumbLabel(crumb)).filter(label => !!label).join(' › ')) - ), {initialValue: ''}); - - private pagePath = toSignal(this.router.events.pipe( - filter((event): event is NavigationEnd => event instanceof NavigationEnd), - map(event => event.urlAfterRedirects), - startWith(this.router.url), - map(url => (url || '/').split(/[?#]/)[0]) - ), {initialValue: '/'}); - - clientContext = computed(() => { - const context = this.panelService.clientContext(); - if (context) { - const name = this.panelService.viewName(); - return context.view?.entityId && name && !context.view.title ? {...context, view: {...context.view, title: name}} : context; - } - const title = this.pageTitle(); - const path = this.pagePath(); - const type = aiPageView(path); - return title || path !== '/' ? {view: {type, title, path}, timeZone: getDefaultTimezone()} : undefined; - }); + private context = inject(AiAssistantContextService); - promptExamples = computed(() => this.panelService.config()?.promptExamples ?? []); + clientContext = this.context.clientContext; - welcome = computed(() => aiWelcome(this.clientContext()?.view, this.panelService.viewName(), this.panelService.config(), - this.translate)); + welcome = this.context.welcome; private chats = inject(AiChatsService); private elementRef = inject(ElementRef); @@ -303,15 +265,6 @@ export class AiAssistantPanelComponent { }); } - private crumbLabel(crumb: BreadCrumb): string { - try { - return crumb.labelFunction ? crumb.labelFunction() : crumb.customTranslate ? this.utils.customTranslation(crumb.label, crumb.label) - : this.translate.instant(crumb.label); - } catch { - return ''; - } - } - close(): void { this.panelService.close(); } diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-button-intro.component.ts b/ui-ngx/src/app/modules/home/components/ai/ai-button-intro.component.ts new file mode 100644 index 0000000000..0c8cfc2299 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/ai/ai-button-intro.component.ts @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; + +@Component({ + selector: 'tb-ai-button-intro', + template: ` +
+

{{ title }}

+ +

+ {{ lead }} + @if (keyboard) { + {{ 'ai-assistant.intro.press' | translate }} / {{ 'ai-assistant.intro.on-any-page' | translate }} + } +

+
+ + +
+
+ `, + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class AiButtonIntroComponent { + + @Input() title: string; + + @Input() lead: string; + + @Input() keyboard = false; + + @Output() dismiss = new EventEmitter(); + + @Output() openChat = new EventEmitter(); +} diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html b/ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html index fc521c250e..edc2614af2 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html +++ b/ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html @@ -268,7 +268,7 @@ } @else if (work) { } @else { - +
{{ 'ai-assistant.thinking' | translate }}
diff --git a/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html b/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html index ffec69170a..1aeaa65fea 100644 --- a/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html +++ b/ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html @@ -10,7 +10,7 @@ (fullscreenChanged)="onFullscreenChanged($event)"> @if (variant() === 'panel') { - + } @@ -96,7 +96,7 @@
} @else if (!chatId() && docked()) {
- +

{{ startTitle() || ('ai-assistant.panel-title' | translate) }}

{{ startLine() || ('ai-assistant.panel-line' | translate) }}

@if (prompts().length) { @@ -113,7 +113,7 @@
} @else if (!chatId()) {
- + @if (variant() === 'panel') {

{{ startTitle() || ('ai-assistant.panel-title' | translate) }}

{{ startLine() || ('ai-assistant.panel-line' | translate) }}

@@ -238,60 +238,62 @@
- @if (fileMarks(); as marks) { -
- - {{ (marks.from === marks.to ? 'ai-assistant.file.line' : 'ai-assistant.file.lines-range') | translate: {from: marks.from, to: marks.to} }} - {{ 'ai-assistant.file.marked' | translate }} - - - - - -
- } @else { -
- - @if (fileBody()?.editing()) { - @if (fileBody()?.dirty()) { - {{ 'ai-assistant.file.unsaved' | translate }} + + @if (fileMarks(); as marks) { +
+ + {{ (marks.from === marks.to ? 'ai-assistant.file.line' : 'ai-assistant.file.lines-range') | translate: {from: marks.from, to: marks.to} }} + {{ 'ai-assistant.file.marked' | translate }} + + + + + +
+ } @else { +
+ + @if (fileBody()?.editing()) { + @if (fileBody()?.dirty()) { + {{ 'ai-assistant.file.unsaved' | translate }} + } @else { + {{ 'ai-assistant.file.editing' | translate }} + } + @if (fileBody()?.caret(); as caret) { + + {{ 'ai-assistant.file.position' | translate: {line: caret.line, col: caret.col} }}@if (caret.selected) { ({{ 'ai-assistant.file.selected' | translate: {count: caret.selected} }})} + } + } @else if (fileBody()?.saved()) { + {{ 'ai-assistant.file.saved' | translate }} } @else { - {{ 'ai-assistant.file.editing' | translate }} - } - @if (fileBody()?.caret(); as caret) { + {{ 'ai-assistant.file.lines' | translate: {count: file.lines} }} - {{ 'ai-assistant.file.position' | translate: {line: caret.line, col: caret.col} }}@if (caret.selected) { ({{ 'ai-assistant.file.selected' | translate: {count: caret.selected} }})} + {{ file.size }} + @if (file.edited) { + + {{ 'ai-assistant.file.edited-in-chat' | translate }} + } } - } @else if (fileBody()?.saved()) { - {{ 'ai-assistant.file.saved' | translate }} - } @else { - {{ 'ai-assistant.file.lines' | translate: {count: file.lines} }} - - {{ file.size }} - @if (file.edited) { - - {{ 'ai-assistant.file.edited-in-chat' | translate }} - } - } - - - @if (fileBody()?.editing()) { - @if (fileBody()?.dirty()) { - - + + } @else { + + } + } @else if (chatId()) { + - } @else { - } - } @else if (chatId()) { - - } - -
- } +
+
+ } +