Browse Source

feat: ThingsBoard CLI guide's hero leads to Get started over a coding agent's window that plays three sessions on tabs (office-sensor, smart-retail, freezer-limits) under the ASCII wordmark and the thingsboard-cli 4.4.0.2.post1 banner, with a typed request, a numbered menu answer, Thinking then Done, tool runs and their results, turning after a 6 s hold that waits on hover, out of view or a hidden page and stops on a click or a key, still under reduced motion; How it works with the agent tiles, the commit over the tree and tb validate with the deploy menu; phase icons on squircles; Explore the docs with three links; Home's Use the CLI opens the guide with the chats folded and copies nothing; the chat's content follows Uplink: an entity chip on white with a hairline in one chip and key box, a chip that opens ends in a chevron, a card is one link with Open as a 36 px filled icon, the compact card and line in a narrow chat, a page's source on the record card's anatomy, a link that leaves the product ends in a north-east arrow, every Copy turns into a check for 1.5 s and is announced, tables in a hairline box with entity chips and a sticky first column when docked, one keyboard key rule with its quiet form; the hand-over card and the out-of-limit card in the chat

pull/16848/head
Igor Kulikov 1 week ago
parent
commit
ff535b9c81
  1. 2
      ui-ngx/src/app/core/services/ai-chats.service.ts
  2. 2
      ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.html
  3. 121
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  4. 27
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.html
  5. 119
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.scss
  6. 54
      ui-ngx/src/app/modules/home/components/ai/ai-chat-messages.component.ts
  7. 2
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.html
  8. 7
      ui-ngx/src/app/modules/home/components/ai/ai-chat.component.ts
  9. 45
      ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.html
  10. 592
      ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.scss
  11. 65
      ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.ts
  12. 380
      ui-ngx/src/app/modules/home/components/ai/ai-cli-term.ts
  13. 109
      ui-ngx/src/app/modules/home/components/ai/ai-cli.models.ts
  14. 31
      ui-ngx/src/app/modules/home/components/ai/ai-code-block.ts
  15. 116
      ui-ngx/src/app/modules/home/components/ai/ai-hand-over.component.html
  16. 125
      ui-ngx/src/app/modules/home/components/ai/ai-hand-over.component.ts
  17. 47
      ui-ngx/src/app/modules/home/components/ai/ai-limit-out.component.html
  18. 179
      ui-ngx/src/app/modules/home/components/ai/ai-limit-out.component.ts
  19. 16
      ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.scss
  20. 7
      ui-ngx/src/app/modules/home/components/ai/ai-record-card.component.ts
  21. 58
      ui-ngx/src/app/modules/home/components/ai/ai-references.ts
  22. 2
      ui-ngx/src/app/modules/home/components/ai/ai-started-from.component.ts
  23. 6
      ui-ngx/src/app/modules/home/components/ai/ai.module.ts
  24. 2
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.html
  25. 16
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.scss
  26. 14
      ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.ts
  27. 17
      ui-ngx/src/app/modules/home/pages/home-page/components/ai-start-home.component.ts
  28. 22
      ui-ngx/src/app/shared/models/ai-chat.models.ts
  29. 344
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  30. 766
      ui-ngx/src/theme/ai-theme.scss

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

@ -161,7 +161,7 @@ export class AiChatsService {
if (this._open().has(chat.id)) {
return chat.status === 'FAILED' ? 'error' : null;
}
return chat.status === 'NEEDS_YOU' ? 'needs' : chat.status === 'RUNNING' ? 'running' : chat.status === 'FAILED' ? 'error' : null;
return chat.status === 'NEEDS_YOU' ? 'needs' : chat.status === 'NO_DATA' ? 'nodata' : chat.status === 'RUNNING' ? 'running' : chat.status === 'FAILED' ? 'error' : null;
}
needsAttention(chat: ChatInfo): boolean {

2
ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.html

@ -14,7 +14,7 @@
@default {
<div class="out">
<mat-icon class="mark" aria-hidden="true">{{ action().status === 'FAILURE' ? 'error_outline' : 'check' }}</mat-icon>
<span class="say">@if (outcomeChip(); as chip) {{{ chip.before }}@if (chip.link) {<a class="tb-chiplink" [routerLink]="chip.link"><code class="k-ent" [attr.data-pal]="chip.palette"><span class="mat-icon notranslate material-icons mat-ligature-font k-ent-ic" aria-hidden="true">{{ chip.icon }}</span>{{ chip.name }}</code></a>} @else {<code class="k-ent" [attr.data-pal]="chip.palette"><span class="mat-icon notranslate material-icons mat-ligature-font k-ent-ic" aria-hidden="true">{{ chip.icon }}</span>{{ chip.name }}</code>}{{ chip.after }}} @else {{{ outcome() }}}</span>
<span class="say">@if (outcomeChip(); as chip) {{{ chip.before }}@if (chip.link) {<a class="tb-chiplink" [routerLink]="chip.link"><code class="k-ent" [attr.data-pal]="chip.palette"><span class="mat-icon notranslate material-icons mat-ligature-font k-ent-ic" aria-hidden="true">{{ chip.icon }}</span>{{ chip.name }}<span class="mat-icon notranslate material-icons mat-ligature-font tb-chip-go" aria-hidden="true">chevron_right</span></code></a>} @else {<code class="k-ent" [attr.data-pal]="chip.palette"><span class="mat-icon notranslate material-icons mat-ligature-font k-ent-ic" aria-hidden="true">{{ chip.icon }}</span>{{ chip.name }}</code>}{{ chip.after }}} @else {{{ outcome() }}}</span>
@if (duration()) {
<span class="dur">{{ duration() }}</span>
}

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

@ -32,6 +32,9 @@ const TOOL_WORDS: Record<string, string> = {
delete_attributes: 'delete-attributes',
read_entity_relations: 'read-relations',
read_device_credentials: 'read-credentials',
save_device_credentials: 'save-credentials',
test_converter: 'test-converter',
read_converter_library: 'read-converter-library',
create_dashboard: 'create-dashboard',
update_dashboard: 'update-dashboard',
add_dashboard_state: 'add-dashboard-state',
@ -168,6 +171,9 @@ const SAVED_KINDS: Record<string, [string, string]> = {
save_entity_view: ['entity-view', ''],
save_asset: ['asset', ''],
save_asset_profile: ['asset-profile', ''],
save_device_profile: ['device-profile', ''],
save_converter: ['converter', ''],
save_integration: ['integration', ''],
save_secret: ['secret', ''],
save_ai_model: ['ai-model', ''],
save_resource: ['resource', '']
@ -210,6 +216,9 @@ const DELETED_TARGETS: Record<string, string> = {
IMAGE: 'delete-image',
ENTITY_VIEW: 'delete-entity-view',
ASSET_PROFILE: 'delete-asset-profile',
DEVICE_PROFILE: 'delete-device-profile',
INTEGRATION: 'delete-integration',
CONVERTER: 'delete-converter',
SECRET: 'delete-secret',
AI_MODEL: 'delete-ai-model',
RESOURCE: 'delete-resource',
@ -286,7 +295,115 @@ export function aiSourcesOf(args: unknown): AiSource[] {
export const UPDATE_PLAN_TOOL = 'update_plan';
const KIT_CARD_TOOLS = new Set([SUGGEST_PROMPTS_TOOL, ASK_USER_TOOL, PROPOSE_PLAN_TOOL, UPDATE_PLAN_TOOL, 'write_file', 'create_file', CITE_SOURCES_TOOL, 'show_records']);
export const HAND_OVER_TOOL = 'hand_over';
export const CHECK_CONNECTION_TOOL = 'check_connection';
const KIT_CARD_TOOLS = new Set([SUGGEST_PROMPTS_TOOL, ASK_USER_TOOL, PROPOSE_PLAN_TOOL, UPDATE_PLAN_TOOL, 'write_file', 'create_file', CITE_SOURCES_TOOL, 'show_records',
HAND_OVER_TOOL]);
export interface AiHandOverValue {
label: string;
value: string;
secret: boolean;
icon: string;
}
export interface AiHandOverStep {
title: string;
detail?: string;
markdown?: string;
values: AiHandOverValue[];
done: boolean;
}
export interface AiHandOverOption {
id: string;
label: string;
icon?: string;
text: string;
}
export interface AiHandOver {
title: string;
text?: string;
choice?: {question: string; icon: string; value: string; options: AiHandOverOption[]};
steps: AiHandOverStep[];
waitFor?: 'message' | 'uplink' | 'gateway';
intervalSeconds?: number;
}
const text = (value: unknown): string | undefined => typeof value === 'string' && value.trim() ? value.trim() : undefined;
const ICON_NAME = /^[a-z0-9_]{2,40}$/;
const iconOf = (value: unknown, fallback: string): string => typeof value === 'string' && ICON_NAME.test(value) ? value : fallback;
export function aiHandOverOf(args: unknown): AiHandOver | null {
const values = (args ?? {}) as Record<string, any>;
const title = text(values.title);
if (!title) {
return null;
}
const steps: AiHandOverStep[] = (Array.isArray(values.steps) ? values.steps : [])
.filter(step => text(step?.title))
.slice(0, 6)
.map(step => ({
title: text(step.title),
detail: text(step.detail),
markdown: text(step.markdown),
done: step.done === true,
values: (Array.isArray(step.values) ? step.values : [])
.filter(value => text(value?.label) && typeof value?.value === 'string' && value.value)
.slice(0, 4)
.map(value => ({label: text(value.label), value: value.value, secret: value.secret === true,
icon: iconOf(value.icon, value.secret === true ? 'key' : /^https?:\/\//.test(value.value) ? 'link' : 'label')}))
}));
const options: AiHandOverOption[] = (Array.isArray(values.choice?.options) ? values.choice.options : [])
.filter(option => text(option?.id) && text(option?.label))
.slice(0, 4)
.map(option => ({id: text(option.id), label: text(option.label), icon: typeof option.icon === 'string' && ICON_NAME.test(option.icon) ? option.icon : undefined,
text: text(option.text) ?? ''}));
const choice = options.length >= 2 ? {
question: text(values.choice.question) ?? '',
icon: iconOf(values.choice.icon, 'tune'),
value: options.some(option => option.id === values.choice.value) ? values.choice.value : options[0].id,
options
} : undefined;
const waitFor = ['message', 'uplink', 'gateway'].includes(values.waitFor) ? values.waitFor : undefined;
const interval = Number(values.intervalSeconds);
return {title, text: text(values.text), choice, steps, waitFor,
intervalSeconds: Number.isFinite(interval) && interval > 0 ? interval : undefined};
}
export interface AiConnectionCheck {
dataArriving: boolean;
failedStep?: string;
name?: string;
note?: string;
readings: {key: string; value: string}[];
}
export function aiConnectionCheckOf(result: unknown): AiConnectionCheck | null {
let values: any = result;
if (typeof result === 'string') {
try {
values = JSON.parse(result);
} catch {
return null;
}
}
if (!values || typeof values !== 'object' || !values.steps) {
return null;
}
const readings: {key: string; value: string}[] = [];
const add = (telemetry: unknown) => Object.entries(telemetry && typeof telemetry === 'object' ? telemetry : {})
.forEach(([key, item]) => readings.push({key, value: String((item as any)?.value ?? '')}));
add(values.telemetry);
(Array.isArray(values.devices) ? values.devices : []).forEach(device => add(device?.telemetry));
return {dataArriving: values.steps.dataArriving === true, failedStep: text(values.failedStep), name: text(values.name),
note: text(values.note), readings: readings.slice(0, 6)};
}
export const isKitCardTool = (tool: string): boolean => KIT_CARD_TOOLS.has(tool);
@ -442,6 +559,8 @@ export function aiActionWords(tool: string, args: unknown): AiActionWords {
return {key: ACTION_PREFIX + telemetryWords(values), kind: 'think'};
case 'delete':
return {key: ACTION_PREFIX + (DELETED_TARGETS[values.targetType] ?? 'delete-other'), kind: 'think'};
case 'check_connection':
return {key: ACTION_PREFIX + (Number(values.waitSeconds) > 0 ? 'wait-for-data' : 'check-connection'), kind: 'think'};
case 'fetch_web_page': {
const site = siteOf(values.url);
return site ? {key: ACTION_PREFIX + 'read-site', params: {site}, kind: 'think'} : {key: ACTION_PREFIX + 'read-page', kind: 'think'};

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

@ -83,12 +83,16 @@
<tb-ai-plan [steps]="plan.steps" [progress]="plan.progress" [gate]="plan.gate" [autoApprove]="autoApprove"
(run)="runPlan.emit({run: $event, steps: plan.steps})" (change)="changePlan.emit()"></tb-ai-plan>
</div>
} @else if (msg.from === 'ACTION' && handOvers[$index]; as card) {
<div class="ai hand">
<tb-ai-hand-over [handOver]="card.handOver" [wait]="card.wait" [time]="msg.data.startedAt" (prompt)="prompt.emit($event)"></tb-ai-hand-over>
</div>
} @else if (msg.from === 'ACTION' && asking?.index === $index) {
<div class="ai ask">
<tb-ai-question [questions]="asking.questions" [time]="msg.data.startedAt" (done)="answerQuestions($event)" (skip)="answerQuestions($event)"></tb-ai-question>
</div>
} @else if (msg.from === 'ACTION') {
@if (isListedAction(msg) && (msg.data.status !== 'RUNNING' || $index === runningLead)) {
@if (isListedAction(msg, $index) && (msg.data.status !== 'RUNNING' || $index === runningLead)) {
<div class="ai action">
<tb-ai-action-line [action]="msg.data" [names]="detailNames" [more]="$index === runningLead ? runningCount - 1 : 0"></tb-ai-action-line>
@if ($index === retryIndex) {
@ -167,15 +171,18 @@
@if (sources[$index]; as cited) {
<div class="k-docs agent-docs">
@for (source of cited; track source.url) {
<div class="k-doc" [class.ext]="source.external">
<span class="k-doc-tile"><mat-icon aria-hidden="true">{{ source.icon }}</mat-icon></span>
<span class="k-doc-t">
<a class="k-doc-title" [href]="source.url" target="_blank" rel="noopener noreferrer">{{ source.title }}@if (source.external) {<mat-icon class="k-ext" aria-hidden="true">open_in_new</mat-icon>}</a>
<span class="k-doc-from">{{ source.from }}</span>
@if (source.quote) {
<q>{{ source.quote }}</q>
}
</span>
<div class="tb-rec card source" [class.ext]="source.external">
<div class="tb-rec-row">
<span class="tb-rec-tile"><mat-icon aria-hidden="true">{{ source.icon }}</mat-icon></span>
<div class="tb-rec-body">
<a class="tb-rec-title" [href]="source.url" target="_blank" rel="noopener noreferrer">{{ source.title }}<span class="tb-ai-sr-only"> {{ 'ai-assistant.opens-new-tab' | translate }}</span></a>
<span class="tb-rec-meta">{{ source.from }}</span>
</div>
<span class="tb-rec-side"><span class="tb-open" aria-hidden="true"><mat-icon class="tb-mat-18">open_in_new</mat-icon></span></span>
</div>
@if (source.quote) {
<div class="tb-rec-det"><q class="tb-rec-note">{{ source.quote }}</q></div>
}
</div>
}
</div>

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

@ -438,12 +438,12 @@
code:not([class*=language-]):not(.k-ent):not(pre code) {
display: inline-block;
white-space: nowrap;
padding: 2px 7px;
padding: var(--chat-chip-pad, 1px) 7px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.06);
font-family: var(--tb-mono);
font-size: 14px;
line-height: 18px;
font-size: var(--chat-chip-mono, 14px);
line-height: var(--chat-chip-lh, 18px);
color: var(--tb-ink);
}
@ -456,22 +456,37 @@
display: inline-block;
max-width: 100%;
box-sizing: border-box;
padding: 2px 7px;
padding: var(--chat-chip-pad, 1px) 7px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.05);
font: 400 14px/18px var(--tb-font);
background: var(--tb-surface);
box-shadow: inset 0 0 0 1px var(--tb-line);
font: 400 var(--chat-chip, 14px)/var(--chat-chip-lh, 18px) var(--tb-font);
color: var(--tb-ink);
white-space: nowrap;
}
a .k-ext {
width: 14px;
height: 14px;
margin-left: 4px;
font-size: 14px;
line-height: 14px;
vertical-align: -2px;
color: var(--tb-ink-38);
a.tb-chiplink > code.k-ent {
padding-right: 2px;
}
a.tb-chiplink:hover > code.k-ent, a.tb-chiplink:focus-visible > code.k-ent {
box-shadow: inset 0 0 0 1px var(--tb-ink-38);
}
.k-ext-tail {
white-space: nowrap;
}
.k-ext-tail > .k-ext {
display: inline-block;
width: 13px;
height: 13px;
margin-left: 1px;
font-size: 13px;
line-height: 13px;
vertical-align: -1px;
opacity: .82;
text-decoration: none;
}
a:not(.tb-chiplink) {
@ -490,13 +505,17 @@
> table {
display: block;
width: auto;
width: fit-content;
max-width: 100%;
box-sizing: border-box;
overflow-x: auto;
scrollbar-width: thin;
margin: 14px 0 0;
border: 0;
border-radius: 0;
border-collapse: collapse;
border: 1px solid var(--tb-line);
border-radius: 8px;
background: var(--tb-surface);
border-collapse: separate;
border-spacing: 0;
table-layout: auto;
font-size: 14px;
line-height: 20px;
@ -506,11 +525,12 @@
background: none;
> tr > th {
padding: 0 20px 6px 0;
padding: 8px 20px 8px 0;
font-size: 12.5px;
line-height: 16px;
font-weight: 500;
color: var(--tb-text-secondary);
border: 0;
border-bottom: 1px solid var(--tb-line);
text-align: left;
white-space: nowrap;
@ -522,6 +542,7 @@
font-size: 14px;
line-height: 20px;
color: var(--tb-ink);
border: 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
vertical-align: top;
white-space: nowrap;
@ -529,11 +550,14 @@
> tbody > tr:last-child > td {
border-bottom: 0;
padding-bottom: 0;
}
th:first-child, td:first-child {
padding-left: 12px;
}
th:last-child, td:last-child {
padding-right: 0;
padding-right: 12px;
}
td.long {
@ -548,6 +572,59 @@
th[align="center"], td[align="center"] {
text-align: center;
}
td code.k-ent {
padding: 0;
background: none;
box-shadow: none;
font-weight: 500;
}
td .tb-chip-go {
display: none;
}
td a.tb-chiplink > code.k-ent {
padding: 0;
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
text-decoration-color: color-mix(in srgb, currentColor 28%, transparent);
transition: text-decoration-color .12s ease;
}
td a.tb-chiplink:hover > code.k-ent, td a.tb-chiplink:focus-visible > code.k-ent {
box-shadow: none;
text-decoration-color: currentColor;
}
@container k-col (max-width: 480px) {
th:first-child, td:first-child {
position: sticky;
left: 0;
z-index: 1;
padding-left: 8px;
padding-right: 10px;
background: var(--tb-surface);
border-right: 1px solid var(--tb-line);
white-space: normal;
}
th:nth-child(2), td:nth-child(2) {
padding-left: 12px;
}
th:last-child, td:last-child {
padding-right: 8px;
}
td:first-child > .k-md-lead {
display: inline-block;
width: max-content;
max-width: 172px;
vertical-align: top;
}
}
}
@include ai-code-blocks;

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

@ -30,6 +30,11 @@ import {
isHiddenAiAction,
isKitCardTool,
PROPOSE_PLAN_TOOL,
HAND_OVER_TOOL,
CHECK_CONNECTION_TOOL,
AiHandOver,
aiHandOverOf,
aiConnectionCheckOf,
SUGGEST_PROMPTS_TOOL,
UPDATE_PLAN_TOOL
} from '@home/components/ai/ai-action.models';
@ -57,7 +62,8 @@ export interface AnswerReportEvent {
problem: AnswerProblem;
comment?: string;
}
import { decorateCodeBlocks, decorateTables, fileLanguage } from '@home/components/ai/ai-code-block';
import { announceCopied, decorateCodeBlocks, decorateTables, fileLanguage } from '@home/components/ai/ai-code-block';
import { AiHandOverWait } from '@home/components/ai/ai-hand-over.component';
import { aiDetailNames, AiDetailNames } from '@home/components/ai/ai-action-detail.models';
import { decorateFileChips, decorateHints, decorateLinks, decorateReferences, decorateSeverities, decorateValues } from '@home/components/ai/ai-references';
import { AlarmSeverity, alarmSeverityTranslations } from '@shared/models/alarm.models';
@ -141,6 +147,8 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
made: Record<number, string[]> = {};
plans: Record<number, {steps: AiPlanStep[]; progress: AiPlanProgress | null; gate: boolean}> = {};
handOvers: Record<number, {handOver: AiHandOver; wait: AiHandOverWait | null}> = {};
private waitsInCards = new Set<number>();
private keptAsking = new Set<number>();
@ -151,7 +159,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
private dayTimer: ReturnType<typeof setTimeout>;
private static readonly PIN_TO_BOTTOM_MS = 1500;
private static readonly COPIED_MS = 1200;
private static readonly COPIED_MS = 1500;
private static readonly FOLD_LINES = 6;
private static readonly FOLD_CHARS = 600;
@ -210,6 +218,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
copyText(text: string, index: number): void {
if (this.clipboard.copyFromContent(text)) {
this.copiedIndex = index;
announceCopied(this.translate.instant('ai-assistant.copied'));
clearTimeout(this.copiedTimeout);
this.copiedTimeout = setTimeout(() => this.copiedIndex = -1, AiChatMessagesComponent.COPIED_MS);
}
@ -225,7 +234,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
decorateTables(answer);
decorateSections(answer, this.sectionScope(message));
decorateReferences(answer, (message as GeneralChatMessage)?.references);
decorateLinks(answer);
decorateLinks(answer, this.translate.instant('ai-assistant.opens-new-tab'));
decorateHints(answer);
decorateValues(answer, (message as GeneralChatMessage)?.readings);
decorateFileChips(answer, this.latestFiles, this.shownFileName());
@ -274,6 +283,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
const text = (answer.querySelector<HTMLElement>('tb-markdown') ?? answer).innerText.trim();
if (this.clipboard.copyFromContent(text)) {
this.copiedIndex = index;
announceCopied(this.translate.instant('ai-assistant.copied'));
clearTimeout(this.copiedTimeout);
this.copiedTimeout = setTimeout(() => this.copiedIndex = -1, AiChatMessagesComponent.COPIED_MS);
}
@ -404,6 +414,7 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
setTimeout(() => this.keepAskInView());
}
this.plans = this.findPlans();
this.handOvers = this.findHandOvers();
this.files = this.findFiles();
this.latestFiles = new Map(Object.values(this.files).map(file => [file.name, file]));
this.madeFiles = this.findMadeFiles();
@ -613,8 +624,9 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
return summaries;
}
isListedAction(message: ChatMessage): boolean {
return message.from === 'ACTION' && !isKitCardTool(message.data.tool) && !isHiddenAiAction(message.data.tool);
isListedAction(message: ChatMessage, index = -1): boolean {
return message.from === 'ACTION' && !isKitCardTool(message.data.tool) && !isHiddenAiAction(message.data.tool)
&& !(index >= 0 && this.waitsInCards.has(index));
}
answerQuestions(answers: AiQuestionAnswer[]): void {
@ -800,6 +812,38 @@ export class AiChatMessagesComponent implements OnChanges, OnDestroy {
return files;
}
private findHandOvers(): Record<number, {handOver: AiHandOver; wait: AiHandOverWait | null}> {
const cards: Record<number, {handOver: AiHandOver; wait: AiHandOverWait | null}> = {};
const waits = new Set<number>();
let current = -1;
this.messages.forEach((message, index) => {
if (message.from === 'USER') {
current = -1;
return;
}
if (message.from !== 'ACTION') {
return;
}
if (message.data.tool === HAND_OVER_TOOL) {
const handOver = aiHandOverOf(message.data.arguments);
if (handOver) {
cards[index] = {handOver, wait: null};
current = index;
}
} else if (message.data.tool === CHECK_CONNECTION_TOOL && current >= 0 && cards[current].handOver.waitFor
&& Number((message.data.arguments as {waitSeconds?: unknown})?.waitSeconds) > 0) {
const running = message.data.status === 'RUNNING' && this.loading;
cards[current].wait = {running, startedAt: message.data.startedAt, progress: message.data.progress,
check: running ? null : aiConnectionCheckOf(message.data.result)};
if (running) {
waits.add(index);
}
}
});
this.waitsInCards = waits;
return cards;
}
private findPlans(): Record<number, {steps: AiPlanStep[]; progress: AiPlanProgress | null; gate: boolean}> {
const plans: Record<number, {steps: AiPlanStep[]; progress: AiPlanProgress | null; gate: boolean}> = {};
let current = -1;

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

@ -142,6 +142,8 @@
}
@if (creditsOut(); as limitType) {
<tb-ai-credits-out [limitType]="limitType" (dismissed)="creditsOut.set(null)"></tb-ai-credits-out>
} @else if (limitOut(); as platformLimit) {
<tb-ai-limit-out [platformLimit]="platformLimit" (dismissed)="limitOut.set(null)"></tb-ai-limit-out>
} @else if (notice(); as current) {
<div class="k-notice k-notice-edge" [class]="'k-notice k-notice-edge ' + (current.kind === 'block' ? 'blocking' : current.kind)" [attr.role]="current.kind === 'block' ? 'alert' : 'status'">
<mat-icon aria-hidden="true">{{ current.icon }}</mat-icon><span>{{ current.text }}</span>

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

@ -48,6 +48,7 @@ import { ActionChatMessage, AiStartedFrom, ApprovalChatMessage, ChatMessage, Gen
import {
AiAssistantPromptExample,
AiChatClientContext,
AiPlatformLimit,
AiLinesQuote,
AiNotice,
AiPromptMessage,
@ -353,6 +354,8 @@ export class AiChatComponent implements OnInit, OnDestroy {
creditsOut = signal<AiCreditsLimitType | null>(null);
limitOut = signal<AiPlatformLimit | null>(null);
private freshChatId: string | null = null;
private noticeTimer: ReturnType<typeof setTimeout>;
@ -872,6 +875,7 @@ export class AiChatComponent implements OnInit, OnDestroy {
this.shownChatId = chatId;
this.resetLogPosition(0);
this.messages.set([]);
this.limitOut.set(null);
this.completedExecutions.set({});
this.denyReasons.set({});
this.answeredApprovals.set(new Set());
@ -1096,6 +1100,9 @@ export class AiChatComponent implements OnInit, OnDestroy {
case 'toolFinished':
this.finishAction(event.data);
break;
case 'limitReached':
this.limitOut.set(event.data);
break;
case 'turnStopped':
this.messages.update(list => [...this.endStreaming(list), {from: 'AI', content: this.translate.instant('ai-assistant.stopped'), status: 'STOPPED', time: Date.now()}]);
break;

45
ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.html

@ -29,32 +29,18 @@
<h1 class="ob-title">{{ 'ai-assistant.cli.hero.title' | translate }}</h1>
<p class="ob-lead">{{ 'ai-assistant.cli.hero.lead' | translate }}</p>
</div>
<div class="ai-cli-hero-set ai-cli-cta">
<div class="ai-cli-seg" role="group" [attr.aria-label]="'ai-assistant.cli.how-to-set-up' | translate">
@for (item of ways; track item) {
<button type="button" [attr.data-way]="item" [attr.aria-pressed]="way() === item" (click)="pickWay(item, $event)">
<b>{{ ('ai-assistant.cli.way.' + item) | translate }}</b>
</button>
}
</div>
@if (way() === 'terminal') {
<div class="ai-cli-slot" data-kind="install-hero"></div>
} @else {
<div class="ai-cli-clamp" [class.shut]="!promptOpen()">
<div class="ai-cli-slot" data-kind="prompt-hero"></div>
<button type="button" class="ai-cli-alt ai-cli-more-t" [attr.aria-expanded]="promptOpen()" (click)="togglePrompt($event)">
<span>{{ (promptOpen() ? 'ai-assistant.cli.show-less' : 'ai-assistant.cli.show-more') | translate }}</span>
<mat-icon fontSet="material-icons-round" aria-hidden="true">{{ promptOpen() ? 'expand_less' : 'expand_more' }}</mat-icon>
</button>
</div>
}
<div class="ai-cli-foot">
<p class="ai-cli-prompt-note">{{ (way() === 'terminal' ? 'ai-assistant.cli.note-terminal' : 'ai-assistant.cli.note-agent') | translate }}</p>
<button type="button" class="ai-cli-alt" (click)="toSteps()">
<span>{{ 'ai-assistant.cli.step-by-step' | translate }}</span>
<div class="ai-cli-hero-set">
<div class="ai-cli-acts">
<button type="button" class="ai-cli-start" (click)="toSteps()">
{{ 'ai-assistant.cli.hero.start' | translate }}
<mat-icon fontSet="material-icons-round" aria-hidden="true">arrow_downward</mat-icon>
</button>
<a class="ai-cli-alt" [href]="docs" target="_blank" rel="noopener">
<span>{{ 'ai-assistant.cli.hero.docs' | translate }}</span>
<mat-icon fontSet="material-icons-round" aria-hidden="true">arrow_outward</mat-icon>
</a>
</div>
<div class="ai-cli-slot" data-kind="term"></div>
</div>
</div>
</div>
@ -66,7 +52,8 @@
<li>
<div class="ai-cli-pic agents">
@for (agent of agents; track agent.id) {
<a class="ai-cli-logo" [href]="agent.get" target="_blank" rel="noopener" [attr.title]="agent.name" [attr.aria-label]="agent.name">
<a class="ai-cli-logo" [href]="agent.get" target="_blank" rel="noopener" [attr.title]="agent.name" [attr.aria-label]="agent.name"
[style.--glow]="agent.glow">
<img [src]="'assets/ai/agents/' + agent.id + '.svg'" alt="" width="34" height="34">
</a>
}
@ -77,8 +64,13 @@
<li>
<div class="ai-cli-pic tree" aria-hidden="true">
<div class="ai-cli-tree">
<span class="commit">
<mat-icon fontSet="material-icons-round">commit</mat-icon>
<b>a3f9c21</b>
<span>{{ 'ai-assistant.cli.how.files.commit' | translate }}</span>
</span>
@for (row of tree; track row.name) {
<span class="row" [class.last]="row.last" [style.--d]="row.depth">
<span class="row" [class.top]="!row.depth" [class.last]="row.last" [class.first]="row.first" [style.--d]="row.depth">
<mat-icon fontSet="material-icons-round" [class]="row.tone ? 'tone-' + row.tone : ''">{{ row.icon }}</mat-icon>
<span>{{ row.name }}</span>
</span>
@ -91,8 +83,9 @@
<li>
<div class="ai-cli-pic ask" aria-hidden="true">
<div class="ai-cli-ask">
<span class="chk"><i>✔</i><span>tb validate</span></span>
<span class="q">{{ 'ai-assistant.cli.how.deploy.question' | translate }}</span>
<span class="opt on"><i>❯</i><span>{{ 'ai-assistant.cli.how.deploy.yes' | translate }}</span></span>
<span class="opt on"><i>❯</i><span>{{ 'ai-assistant.cli.how.deploy.yes' | translate }}</span><span class="enter">↵</span></span>
<span class="opt"><i></i><span>{{ 'ai-assistant.cli.how.deploy.no' | translate }}</span></span>
</div>
</div>

592
ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.scss

@ -175,6 +175,7 @@ $hero-bg: #1b252c;
margin: 0;
font-size: 16px;
line-height: 24px;
max-width: 56ch;
letter-spacing: 0.15px;
color: #b4bec6;
text-wrap: pretty;
@ -223,50 +224,57 @@ $hero-bg: #1b252c;
}
.ai-cli-hero-set {
position: relative;
display: grid;
justify-items: start;
gap: 12px;
gap: 24px;
max-width: 680px;
margin: 20px auto 0;
}
.ai-cli-seg {
display: inline-flex;
padding: 2px;
border-radius: 100px;
background: rgba(255, 255, 255, 0.08);
.ai-cli-acts {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 20px;
padding-left: 72px;
}
button {
height: 30px;
padding: 0 14px;
border: 0;
border-radius: 100px;
background: none;
color: #b4bec6;
font-family: inherit;
font-size: var(--chat-line);
line-height: 1;
cursor: pointer;
transition: background-color $motion $ease, color $motion $ease;
.ai-cli-start {
display: inline-flex;
align-items: center;
gap: 6px;
height: 40px;
padding: 0 14px 0 18px;
border: 0;
border-radius: 10px;
background: var(--ai-dark-accent);
color: var(--ai-on-dark-accent);
font-family: inherit;
font-size: var(--chat-text);
font-weight: 500;
line-height: 1;
letter-spacing: normal;
cursor: pointer;
transition: background-color $motion $ease;
b {
font-weight: 500;
}
.mat-icon {
font-size: var(--chat-icon);
width: var(--chat-icon);
height: var(--chat-icon);
color: inherit;
transition: transform $motion $ease;
}
&:hover {
color: #fff;
}
&:hover {
background: var(--ai-dark-accent-hover);
&[aria-pressed="true"] {
background: var(--ai-dark-accent);
color: var(--ai-on-dark-accent);
.mat-icon {
transform: translateY(2px);
}
}
&:focus-visible {
outline: 2px solid var(--ai-dark-accent-pale);
outline-offset: 2px;
}
&:focus-visible {
outline: 2px solid var(--ai-dark-accent-pale);
outline-offset: 2px;
}
}
@ -274,21 +282,6 @@ $hero-bg: #1b252c;
display: contents;
}
.ai-cli-clamp {
position: relative;
justify-self: stretch;
min-width: 0;
display: grid;
> .ai-cli-more-t {
position: absolute;
left: 50%;
bottom: 10px;
transform: translateX(-50%);
height: 28px;
}
}
.ai-cli-alt {
display: inline-flex;
align-items: center;
@ -312,6 +305,15 @@ $hero-bg: #1b252c;
height: 18px;
}
&, &:hover, &:focus {
border-bottom: 0;
text-decoration: none;
}
&:is(a) {
letter-spacing: inherit;
}
&:hover {
color: var(--ai-dark-accent-pale);
}
@ -327,24 +329,6 @@ $hero-bg: #1b252c;
}
}
.ai-cli-foot {
justify-self: stretch;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 4px 16px;
min-width: 0;
}
.ai-cli-prompt-note {
margin: 0;
font-size: 13px;
line-height: 19px;
color: #9fadb7;
text-wrap: balance;
}
.ai-cli {
max-width: 680px;
margin: 24px auto 0;
@ -354,10 +338,14 @@ $hero-bg: #1b252c;
text-wrap: pretty;
}
:is(h2, p, .ai-cli-body > b, .ai-cli-step-head > b, .ai-cli-subs > li > b) {
:is(h2, p, .ai-cli-body > b, .ai-cli-step-head > b, .ai-cli-subs > li > b), .ai-cli-flow > li > :is(b, p) {
text-wrap: balance;
}
p {
letter-spacing: inherit;
}
code {
padding: 1px 5px;
border-radius: 4px;
@ -426,7 +414,7 @@ $hero-bg: #1b252c;
}
.ai-cli-pic {
height: 136px;
height: 120px;
box-sizing: border-box;
min-width: 0;
padding: 0 16px;
@ -452,7 +440,7 @@ $hero-bg: #1b252c;
border: 0;
border-radius: 18px;
background: var(--tb-surface);
box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.06), 0 8px 20px rgba(16, 24, 40, 0.1);
box-shadow: 0 1px 3px color-mix(in srgb, var(--glow) 16%, transparent), 0 12px 26px -8px color-mix(in srgb, var(--glow) 46%, transparent);
animation: ai-cli-rise $breathe ease-in-out infinite alternate;
& + .ai-cli-logo {
@ -477,15 +465,49 @@ $hero-bg: #1b252c;
font-family: var(--tb-mono);
font-size: 12.5px;
font-weight: 500;
line-height: 22px;
line-height: 20px;
color: var(--tb-ink);
.commit {
display: flex;
align-items: center;
gap: 6px;
height: 20px;
min-width: 0;
margin-bottom: 6px;
font-size: var(--chat-meta);
font-weight: 400;
white-space: nowrap;
color: var(--tb-ink-54);
.mat-icon {
flex: none;
font-size: 15px;
width: 15px;
height: 15px;
line-height: 15px;
color: var(--ai-selected);
}
b {
flex: none;
font-weight: 500;
color: var(--ai-selected);
}
> span:last-child {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
}
.row {
position: relative;
display: flex;
align-items: center;
gap: 6px;
height: 22px;
height: 20px;
min-width: 0;
padding-left: calc(var(--d) * 18px);
white-space: nowrap;
@ -511,35 +533,53 @@ $hero-bg: #1b252c;
&.tone-view {
color: var(--entity-view-fg);
}
&.tone-rule {
color: var(--entity-rule-fg);
}
}
&:not(:first-child)::before {
&:not(.top)::before {
content: '';
position: absolute;
left: calc((var(--d) - 1) * 18px + 7px);
top: -4px;
width: 8px;
height: 15px;
box-sizing: border-box;
border-left: 1px solid var(--k-stroke-hover);
border-bottom: 1px solid var(--k-stroke-hover);
border-bottom-left-radius: 5px;
top: 10px;
width: 9px;
border-top: 1px solid var(--k-stroke-hover);
}
&:not(:first-child):not(.last)::after {
&:not(.top):not(.last)::after {
content: '';
position: absolute;
left: calc((var(--d) - 1) * 18px + 7px);
top: 6px;
bottom: -4px;
top: 0;
bottom: 0;
border-left: 1px solid var(--k-stroke-hover);
}
&.last:not(.top)::before {
top: 0;
height: 11px;
box-sizing: border-box;
border-top: 0;
border-left: 1px solid var(--k-stroke-hover);
border-bottom: 1px solid var(--k-stroke-hover);
border-bottom-left-radius: 5px;
}
&.first:not(.last)::after, &.first.last::before {
top: -1px;
}
&.first.last::before {
height: 12px;
}
}
}
.ai-cli-ask {
display: grid;
gap: 4px;
gap: 2px;
min-width: 0;
font-family: var(--tb-mono);
font-size: 12.5px;
@ -547,15 +587,29 @@ $hero-bg: #1b252c;
line-height: 18px;
color: var(--tb-ink-76);
.q {
.chk {
display: grid;
grid-template-columns: 12px minmax(0, 1fr);
gap: 4px;
margin-bottom: 4px;
font-weight: 400;
color: var(--tb-ink-54);
> i {
font-style: normal;
color: var(--ai-selected);
}
}
.q {
margin-bottom: 2px;
font-weight: 600;
color: var(--tb-ink);
}
.opt {
display: grid;
grid-template-columns: 12px minmax(0, 1fr);
grid-template-columns: 12px minmax(0, 1fr) auto;
gap: 4px;
margin: 0 -6px;
padding: 2px 6px;
@ -567,6 +621,11 @@ $hero-bg: #1b252c;
animation: ai-cli-lit $breathe ease-in-out infinite alternate;
}
.enter {
color: var(--ai-selected);
opacity: 0.7;
}
&.on {
background: var(--ai-selected-wash);
color: var(--ai-selected-text);
@ -622,7 +681,7 @@ $hero-bg: #1b252c;
z-index: 1;
width: 44px;
height: 44px;
border-radius: 50%;
border-radius: 13px;
display: inline-flex;
align-items: center;
justify-content: center;
@ -792,7 +851,6 @@ $hero-bg: #1b252c;
.ai-cli-keys {
height: 36px;
margin-top: 6px;
border-color: var(--k-stroke);
color: var(--tb-ink-76);
@ -965,72 +1023,350 @@ $hero-bg: #1b252c;
margin-top: 10px;
}
.ai-cli-cta {
.tb-codeblock {
justify-self: stretch;
min-width: 0;
margin: 0;
border-radius: 8px;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
.ai-cli-term {
--term-bg: color-mix(in srgb, #{$hero-bg} 58%, #000);
--term-fg: var(--tb-code-fg);
--term-text: #9fadb7;
--term-muted: #7d8c96;
--term-faint: #5f6f7a;
--term-hover: #b4bec6;
--term-rule: rgba(255, 255, 255, 0.07);
--term-art: linear-gradient(90deg in oklab, var(--ai-dark-accent), var(--ai-light-lilac), var(--ai-light-peach));
min-width: 0;
.banner {
display: grid;
color: var(--term-muted);
.art {
justify-self: start;
max-width: 100%;
margin-bottom: 10px;
overflow: hidden;
white-space: pre;
font-size: 12px;
line-height: 13px;
color: var(--ai-dark-accent-soft);
}
.tb-code {
white-space: pre-wrap;
b {
font-weight: 500;
color: var(--term-fg);
}
i {
font-style: normal;
color: var(--ai-dark-accent);
}
}
.tb-codeblock-head {
color: var(--ai-dark-accent);
border-bottom-color: color-mix(in srgb, var(--ai-dark-accent) 16%, transparent);
.r {
display: grid;
grid-template-columns: 2ch minmax(0, 1fr);
min-width: 0;
overflow-wrap: anywhere;
> .tb-codeblock-label {
> i {
font-style: normal;
color: var(--ai-dark-accent);
font-weight: 500;
}
.tb-codecopy.labelled {
&.past {
opacity: 0.5;
}
&.think {
color: var(--term-muted);
> i {
display: inline-block;
transform: scale(1.5);
transform-origin: 30% 55%;
}
&.done > i {
color: var(--term-faint);
}
}
&.out.run .t {
color: var(--term-faint);
}
&:is(.you, .tool, .say, .think) {
margin-top: var(--chat-line-lh);
}
&.you {
color: #fff;
}
&:is(.tool, .say, .ask) {
color: var(--term-fg);
}
&.tool b {
font-weight: 500;
color: var(--ai-dark-accent);
font: 500 12.5px/1 var(--tb-font);
.mat-icon {
font-size: 16px;
width: 16px;
height: 16px;
color: currentColor;
opacity: 1;
}
&:is(.out, .ok, .ask) {
padding-left: 2ch;
}
&.out > i {
color: var(--term-faint);
}
&.say > i {
color: #fff;
}
}
.caret {
display: inline-block;
width: 1ch;
height: 1.15em;
vertical-align: text-bottom;
background: var(--ai-dark-accent);
animation: ai-cli-lit $breathe ease-in-out infinite alternate;
&.typing {
animation: none;
}
}
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
.ai-cli-term .banner .art {
background: var(--term-art);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
}
@media (forced-colors: active) {
.ai-cli-term .banner .art {
background: none;
color: CanvasText;
}
}
.ai-cli-term-bar {
display: flex;
align-items: flex-end;
min-width: 0;
.dots {
flex: none;
display: flex;
gap: 6px;
margin: 0 4px 12px 14px;
i {
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.1);
}
}
.tabs {
display: flex;
gap: 2px;
min-width: 0;
padding: 0 18px 0 10px;
overflow-x: auto;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
[role="tab"] {
position: relative;
flex: none;
height: 32px;
padding: 0 14px;
border: 0;
border-radius: 8px 8px 0 0;
background: none;
color: var(--term-muted);
font-family: var(--tb-mono);
font-size: var(--chat-meta);
line-height: 1;
letter-spacing: normal;
cursor: pointer;
transition: color $motion $ease;
&:hover {
background: rgba(255, 255, 255, 0.04);
color: var(--term-hover);
}
&[aria-selected="true"] {
background: var(--term-bg);
color: var(--term-fg);
&::before, &::after {
content: '';
position: absolute;
bottom: 0;
width: 8px;
height: 8px;
pointer-events: none;
}
&:hover {
background: color-mix(in srgb, var(--ai-dark-accent) 12%, transparent);
color: var(--ai-dark-accent-hover);
&::before {
left: -8px;
background: radial-gradient(circle at 0 0, transparent 8px, var(--term-bg) 8.5px);
}
&.done {
background: color-mix(in srgb, var(--ai-dark-accent) 16%, transparent);
color: var(--ai-dark-accent-pale);
&::after {
right: -8px;
background: radial-gradient(circle at 100% 0, transparent 8px, var(--term-bg) 8.5px);
}
}
&:focus-visible {
outline: 2px solid var(--ai-dark-accent-pale);
outline-offset: -2px;
}
}
}
.ai-cli-clamp {
> .tb-codeblock {
min-width: 0;
.ai-cli-term-body {
height: 268px;
display: flex;
flex-direction: column;
border-radius: 10px;
background: var(--term-bg);
box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.55);
overflow: hidden;
&:focus-visible {
outline: 2px solid var(--ai-dark-accent-pale);
outline-offset: 2px;
}
}
.ai-cli-term-view {
flex: 1;
min-height: 0;
box-sizing: border-box;
padding: 12px 16px 10px;
display: flex;
flex-direction: column;
overflow: hidden;
&.full {
justify-content: flex-end;
-webkit-mask-image: linear-gradient(transparent, #000 30px);
mask-image: linear-gradient(transparent, #000 30px);
}
}
.ai-cli-term-rows {
display: grid;
font-family: var(--tb-mono);
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
color: var(--term-text);
transition: opacity .24s cubic-bezier(.05, .7, .1, 1);
> .r:first-child {
margin-top: 0;
}
&.out {
opacity: 0;
transition: opacity .16s cubic-bezier(.3, 0, .8, .15);
}
}
.ai-cli-term-input {
flex: none;
display: grid;
grid-template-columns: 2ch minmax(0, 1fr);
padding: 10px 16px 12px;
box-shadow: inset 0 1px 0 var(--term-rule);
font-family: var(--tb-mono);
font-size: var(--chat-line);
line-height: var(--chat-line-lh);
color: #fff;
overflow-wrap: anywhere;
> i {
font-style: normal;
color: var(--ai-dark-accent);
}
.tb-code {
padding-bottom: 48px;
&.menu .t {
display: grid;
}
&.shut .tb-code {
$fade: linear-gradient(#000 calc(100% - 132px), rgba(0, 0, 0, 0.82) calc(100% - 108px), rgba(0, 0, 0, 0.5) calc(100% - 82px),
rgba(0, 0, 0, 0.2) calc(100% - 58px), rgba(0, 0, 0, 0.05) calc(100% - 40px), transparent calc(100% - 26px));
max-height: 204px;
.opt {
color: var(--term-muted);
&.on {
color: var(--ai-dark-accent);
}
&.press {
color: var(--ai-dark-accent-pale);
}
}
}
@container (min-width: 640px) {
.ai-cli-term {
width: 100%;
max-width: 600px;
margin-left: 72px;
box-sizing: border-box;
overflow: hidden;
-webkit-mask-image: $fade;
mask-image: $fade;
}
}
@container (max-width: 639px) {
.ai-cli-term-bar {
.dots {
display: none;
}
.tabs {
padding: 0 10px;
}
}
.ai-cli-term .banner .art {
font-size: 9.5px;
line-height: 10px;
}
}
@media (prefers-reduced-motion: reduce) {
.ai-cli-term .caret, .ai-cli-term-rows {
animation: none;
transition: none;
}
}
}
@container (max-width: 480px) {
.ai-cli-start .mat-icon {
font-size: 18px;
width: 18px;
height: 18px;
}
}
@media (max-width: 720px) {
.ai-cli-head .ob-title {
font-size: 22px;
line-height: 28px;
}
}
@media (prefers-reduced-motion: reduce) {

65
ui-ngx/src/app/modules/home/components/ai/ai-cli-guide.component.ts

@ -9,7 +9,7 @@ import {
ElementRef,
inject,
Injector,
input,
NgZone,
output,
signal
} from '@angular/core';
@ -39,17 +39,18 @@ import {
CliOs,
CliWay
} from '@home/components/ai/ai-cli.models';
import { cliTerm, CliTerm } from '@home/components/ai/ai-cli-term';
interface CliPicks {
way?: CliWay;
build?: CliBuild;
open?: boolean;
}
interface CliTreeRow {
depth: number;
name: string;
last: boolean;
first: boolean;
icon: string;
tone?: string;
}
@ -69,8 +70,6 @@ export class AiCliGuideComponent {
private static readonly PICKS_KEY = 'tb-ai-cli';
copiedUntil = input<number>(0);
closed = output<void>();
readonly docs = CLI_DOCS;
@ -88,11 +87,10 @@ export class AiCliGuideComponent {
readonly url = window.location.origin;
readonly tree: CliTreeRow[] = [
{depth: 0, name: 'thingsboard-project', last: true, icon: 'folder'},
{depth: 1, name: 'solutions/office', last: true, icon: 'folder'},
{depth: 2, name: 'devices', last: false, icon: 'memory', tone: 'device'},
{depth: 2, name: 'dashboards', last: false, icon: 'dashboard', tone: 'view'},
{depth: 2, name: 'device-profiles', last: true, icon: 'category', tone: 'device'}
{depth: 0, name: 'smart-retail', last: true, first: false, icon: 'folder'},
{depth: 1, name: 'devices', last: false, first: true, icon: 'memory', tone: 'device'},
{depth: 1, name: 'dashboards', last: false, first: false, icon: 'dashboard', tone: 'view'},
{depth: 1, name: 'alarm-rules', last: true, first: false, icon: 'rule', tone: 'rule'}
];
private readonly picks = AiCliGuideComponent.readPicks();
@ -101,8 +99,6 @@ export class AiCliGuideComponent {
build = signal<CliBuild>(CLI_BUILDS.some(item => item.id === this.picks.build) ? this.picks.build : 'sensor');
promptOpen = signal(!!this.picks.open);
os = signal<CliOs>(AiCliGuideComponent.storedOs());
fullscreen = signal(false);
@ -114,12 +110,17 @@ export class AiCliGuideComponent {
private router = inject(Router);
private injector = inject(Injector);
private host = inject<ElementRef<HTMLElement>>(ElementRef);
private zone = inject(NgZone);
private term: CliTerm | null = null;
readonly hostElement = this.host.nativeElement;
constructor() {
const stop = onCodeTabGroup(CLI_OS_GROUP, id => this.os.set(id === 'windows' ? 'windows' : 'unix'));
inject(DestroyRef).onDestroy(stop);
inject(DestroyRef).onDestroy(() => {
stop();
this.term?.destroy();
});
afterRenderEffect(() => {
this.way();
this.build();
@ -150,22 +151,6 @@ export class AiCliGuideComponent {
this.savePicks();
}
togglePrompt(event: Event): void {
const control = event.currentTarget as HTMLElement;
const top = control.getBoundingClientRect().top;
const open = !this.promptOpen();
this.promptOpen.set(open);
this.savePicks();
if (!open) {
afterNextRender(() => {
const scroller = this.scroller();
if (scroller) {
scroller.scrollTop += control.getBoundingClientRect().top - top;
}
}, {injector: this.injector});
}
}
toSteps(): void {
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
this.hostElement.querySelector('#ai-cli-steps')?.scrollIntoView({behavior: reduce ? 'auto' : 'smooth', block: 'start'});
@ -194,7 +179,7 @@ export class AiCliGuideComponent {
private fillSlots(): void {
this.hostElement.querySelectorAll<HTMLElement>('.ai-cli-slot').forEach(slot => {
const key = slot.dataset.kind + ':' + (slot.dataset.key ?? '') + (slot.dataset.kind === 'prompt-hero' ? ':' + this.copiedUntil() : '');
const key = slot.dataset.kind + ':' + (slot.dataset.key ?? '');
if (slot.dataset.built !== key) {
slot.dataset.built = key;
slot.replaceChildren(this.blockFor(slot.dataset.kind, slot.dataset.key));
@ -206,13 +191,10 @@ export class AiCliGuideComponent {
const copy = (text: string) => this.clipboard.copyFromContent(text);
const say = (word: string) => this.translate.instant('ai-assistant.cli.' + word);
switch (kind) {
case 'install-hero':
return this.installBlock(true);
case 'term':
return this.termBlock();
case 'install':
return this.installBlock(false);
case 'prompt-hero':
return labelledCodeBlock(say('setup-prompt'), say('setup-prompt-label'), 'text', this.translate, copy,
{labelledCopy: true, classes: 'wrap', copiedFor: Math.max(0, this.copiedUntil() - Date.now())});
return this.installBlock();
case 'prompt':
return labelledCodeBlock(say('setup-prompt'), say('setup-prompt-label'), 'text', this.translate, copy,
{check: true, classes: 'wrap'});
@ -234,14 +216,19 @@ export class AiCliGuideComponent {
}
}
private installBlock(hero: boolean): HTMLElement {
private termBlock(): HTMLElement {
this.term?.destroy();
this.term = this.zone.runOutsideAngular(() => cliTerm((key, params) => this.translate.instant(key, params)));
return this.term.element;
}
private installBlock(): HTMLElement {
return codeTabsBlock([
{id: 'unix', label: this.translate.instant('ai-assistant.cli.mac-linux'), text: CLI_INSTALL.unix, lang: 'shell'},
{id: 'windows', label: this.translate.instant('ai-assistant.cli.windows'), text: CLI_INSTALL.windows, lang: 'powershell'}
], 'shell', this.translate, text => this.clipboard.copyFromContent(text), this.os() === 'windows' ? 1 : 0,
tab => this.os.set(tab.id === 'windows' ? 'windows' : 'unix'),
{group: CLI_OS_GROUP, label: this.translate.instant('ai-assistant.cli.terminal'), icon: false,
labelledCopy: hero, check: !hero});
{group: CLI_OS_GROUP, label: this.translate.instant('ai-assistant.cli.terminal'), icon: false, check: true});
}
private agentBlock(text: (agent: CliAgentInfo) => string): HTMLElement {
@ -251,7 +238,7 @@ export class AiCliGuideComponent {
}
private savePicks(): void {
const picks: CliPicks = {way: this.way(), build: this.build(), open: this.promptOpen()};
const picks: CliPicks = {way: this.way(), build: this.build()};
try {
localStorage.setItem(AiCliGuideComponent.PICKS_KEY, JSON.stringify(picks));
} catch {

380
ui-ngx/src/app/modules/home/components/ai/ai-cli-term.ts

@ -0,0 +1,380 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import {
CLI_ART,
CLI_TERM_HOLD,
CLI_TERM_SESSIONS,
CLI_TERM_WAIT,
CLI_VERSION,
CliTermRow,
CliTermSession
} from '@home/components/ai/ai-cli.models';
export interface CliTerm {
element: HTMLElement;
destroy: () => void;
}
const MARK: Record<string, string> = {you: '❯', tool: '●', out: '└', say: '●', ok: '✔', ask: '', think: '⠿'};
const SPIN = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏';
let shownTab = 0;
let turning = true;
let termCount = 0;
type Kid = Node | string | null;
function el(tag: string, cls?: string, ...kids: Kid[]): HTMLElement {
const node = document.createElement(tag);
if (cls) {
node.className = cls;
}
kids.forEach(kid => {
if (kid != null) {
node.append(kid);
}
});
return node;
}
const jitter = (lo: number, hi: number) => lo + Math.random() * (hi - lo);
export function cliTerm(say: (key: string, params?: Record<string, unknown>) => string): CliTerm {
const calm = matchMedia('(prefers-reduced-motion: reduce)').matches;
const uid = 'ai-cli-term-' + (++termCount);
const t = (key: string) => say('ai-assistant.cli.term.' + key);
const list = el('div', 'ai-cli-term-rows');
list.setAttribute('role', 'img');
const view = el('div', 'ai-cli-term-view', list);
const typed = document.createTextNode('');
const caret = el('span', 'caret');
const line = el('span', 't', typed, caret);
const input = el('div', 'ai-cli-term-input', el('i', null, '❯'), line);
input.setAttribute('aria-hidden', 'true');
const body = el('div', 'ai-cli-term-body', view, input);
body.setAttribute('role', 'tabpanel');
body.id = uid + '-panel';
body.tabIndex = 0;
const touch = () => {
turning = false;
};
const pickTab = (k: number) => {
touch();
if (k !== shownTab) {
play(k);
}
};
const tabs = CLI_TERM_SESSIONS.map((session, k) => {
const tab = el('button', null, session.tab) as HTMLButtonElement;
tab.type = 'button';
tab.setAttribute('role', 'tab');
tab.id = `${uid}-tab-${k}`;
tab.setAttribute('aria-controls', body.id);
tab.addEventListener('click', () => pickTab(k));
return tab;
});
const strip = el('div', 'tabs', ...tabs);
strip.setAttribute('role', 'tablist');
strip.setAttribute('aria-label', t('label'));
strip.addEventListener('keydown', (event: KeyboardEvent) => {
const k = tabs.indexOf(document.activeElement as HTMLButtonElement);
const n = tabs.length;
const to = ({ArrowRight: k + 1, ArrowLeft: k - 1 + n, Home: 0, End: n - 1} as Record<string, number>)[event.key];
if (k < 0 || to == null) {
return;
}
event.preventDefault();
pickTab(to % n);
tabs[to % n].focus();
});
const dots = el('span', 'dots', el('i'), el('i'), el('i'));
dots.setAttribute('aria-hidden', 'true');
const root = el('div', 'ai-cli-term', el('div', 'ai-cli-term-bar', dots, strip), body);
root.addEventListener('click', touch);
let run = 0;
let spin: ReturnType<typeof setInterval> | null = null;
let thinking: HTMLElement | null = null;
let t0 = 0;
let seen = true;
let hover = false;
let started = false;
let told = false;
let io: IntersectionObserver | null = null;
let fallback: ReturnType<typeof setTimeout> | null = null;
const timers = new Set<ReturnType<typeof setTimeout>>();
const later = (ms: number, fn: () => void) => {
const r = run;
const id = setTimeout(() => {
timers.delete(id);
if (r === run && root.isConnected) {
fn();
}
}, ms);
timers.add(id);
};
const stopSpin = () => {
if (spin) {
clearInterval(spin);
spin = null;
}
};
const setInput = (text: string) => {
typed.data = text;
line.replaceChildren(typed, caret);
input.classList.remove('menu');
caret.classList.toggle('typing', !!text);
};
const stop = () => {
run += 1;
timers.forEach(clearTimeout);
timers.clear();
stopSpin();
thinking = null;
setInput('');
};
const fit = () => {
const room = view.clientHeight;
if (room) {
view.classList.toggle('full', list.offsetHeight > room - 16);
}
};
const row = (kind: string, ...kids: Kid[]) => {
const r = el('span', 'r ' + kind, el('i', null, MARK[kind.split(' ')[0]]), el('span', 't', ...kids));
list.insertBefore(r, thinking);
fit();
return r;
};
const toolRow = (item: CliTermRow) => row('tool', el('b', null, item.tool), `(${item.arg})`);
const think = () => {
t0 = Date.now();
thinking = el('span', 'r think', el('i', null, SPIN[0]), el('span', 't', t('thinking')));
list.append(thinking);
fit();
let f = 0;
const glyph = thinking.firstChild as HTMLElement;
spin = setInterval(() => {
if (!root.isConnected) {
stopSpin();
return;
}
f += 1;
glyph.textContent = SPIN[f % SPIN.length];
}, 90);
};
const done = () => {
if (!thinking) {
return;
}
stopSpin();
thinking.classList.add('done');
thinking.firstChild.textContent = '⠿';
thinking.lastChild.textContent = say('ai-assistant.cli.term.done', {seconds: Math.max(1, Math.round((Date.now() - t0) / 1000))});
thinking = null;
};
const send = (text: string, next: () => void) => {
setInput('');
row('you', text);
think();
later(jitter(900, 1500), next);
};
const type = (text: string, next: () => void) => {
let n = 0;
const tick = () => {
n += 1;
typed.data = text.slice(0, n);
caret.classList.add('typing');
const ch = text[n - 1];
if (n < text.length) {
later(ch === ' ' ? jitter(45, 120) : /[.,:]/.test(ch) ? jitter(140, 280) : jitter(30, 75), tick);
} else {
later(420, () => send(text, next));
}
};
tick();
};
const pick = (options: string[], next: () => void) => {
input.classList.add('menu');
line.replaceChildren(...options.map((option, j) => el('span', 'opt' + (j ? '' : ' on'), `${j + 1}. ${option}`)));
later(1400, () => {
(line.firstChild as HTMLElement).classList.add('press');
later(240, () => send(options[0], next));
});
};
const stream = (node: HTMLElement, text: string, next: () => void) => {
const words = text.split(' ');
let n = 0;
const tick = () => {
n = Math.min(words.length, n + 1 + Math.floor(Math.random() * 3));
node.textContent = words.slice(0, n).join(' ');
fit();
if (n < words.length) {
later(jitter(45, 100), tick);
} else {
next();
}
};
tick();
};
const step = (rows: CliTermRow[], i: number) => {
if (i >= rows.length) {
done();
if (turning) {
later(CLI_TERM_HOLD, advance);
}
return;
}
const item = rows[i];
const go = () => later(CLI_TERM_WAIT[(rows[i + 1] ?? {kind: 'you'}).kind], () => step(rows, i + 1));
if (item.kind === 'you') {
done();
type(t(item.text), () => step(rows, i + 1));
return;
}
if (item.kind === 'pick') {
done();
pick(item.options.map(t), () => step(rows, i + 1));
return;
}
if (item.kind === 'tool') {
toolRow(item);
go();
return;
}
if (item.kind === 'out') {
const r = row('out run', t('running'));
later(item.ms || 1200, () => {
r.classList.remove('run');
r.lastChild.textContent = t(item.text);
fit();
go();
});
return;
}
stream(row(item.kind).lastChild as HTMLElement, t(item.text), go);
};
const advance = () => {
if (!turning) {
return;
}
if (hover || !seen || document.hidden) {
later(600, advance);
return;
}
play((shownTab + 1) % CLI_TERM_SESSIONS.length);
};
const intro = (session: CliTermSession) => {
if (session.banner) {
list.append(el('div', 'banner', el('span', 'art', CLI_ART), el('b', null, CLI_VERSION),
el('span', null, el('i', null, '✔'), ' ' + t('connected')), el('span', null, el('i', null, '✔'), ' ' + t('detected'))));
fit();
return;
}
(session.intro ?? []).forEach(item => {
const r = item.kind === 'done' ? row('think done', say('ai-assistant.cli.term.done', {seconds: item.seconds}))
: item.kind === 'tool' ? toolRow(item) : row(item.kind, t(item.text));
r.classList.add('past');
});
};
const still = (rows: CliTermRow[]) => rows.forEach(item => {
if (item.kind === 'tool') {
toolRow(item);
} else if (item.kind === 'pick') {
row('you', t(item.options[0]));
} else {
row(item.kind, t(item.text));
}
});
const mark = (k: number) => {
shownTab = k;
tabs.forEach((tab, j) => {
tab.setAttribute('aria-selected', String(j === k));
tab.tabIndex = j === k ? 0 : -1;
});
if (strip.scrollWidth > strip.clientWidth) {
strip.scrollLeft += tabs[k].getBoundingClientRect().left - strip.getBoundingClientRect().left - 10;
}
body.setAttribute('aria-labelledby', tabs[k].id);
list.setAttribute('aria-label', say('ai-assistant.cli.term.picture', {about: t(CLI_TERM_SESSIONS[k].tab + '.about')}));
};
const opening = (k: number) => {
list.replaceChildren();
view.classList.remove('full');
intro(CLI_TERM_SESSIONS[k]);
if (calm) {
still(CLI_TERM_SESSIONS[k].rows);
}
};
const begin = (k: number) => later(CLI_TERM_WAIT.you, () => step(CLI_TERM_SESSIONS[k].rows, 0));
function play(k: number): void {
stop();
mark(k);
started = true;
const go = () => {
list.classList.remove('out');
opening(k);
if (!calm) {
begin(k);
}
};
if (list.firstChild && !calm) {
list.classList.add('out');
later(260, go);
} else {
go();
}
}
const refit = () => {
if (root.isConnected) {
fit();
}
};
shownTab = Math.min(shownTab, CLI_TERM_SESSIONS.length - 1);
mark(shownTab);
opening(shownTab);
requestAnimationFrame(refit);
const destroy = () => {
stop();
io?.disconnect();
if (fallback) {
clearTimeout(fallback);
}
};
if (calm) {
return {element: root, destroy};
}
root.addEventListener('pointerenter', (event: PointerEvent) => {
if (event.pointerType === 'mouse') {
hover = true;
}
});
root.addEventListener('pointerleave', () => {
hover = false;
});
const start = () => {
if (!started) {
started = true;
begin(shownTab);
}
};
if ('IntersectionObserver' in window) {
io = new IntersectionObserver(entries => {
told = true;
seen = entries[entries.length - 1].isIntersecting;
if (seen) {
start();
}
}, {threshold: 0.2});
io.observe(root);
}
fallback = setTimeout(() => {
fallback = null;
if (!told && root.isConnected) {
seen = true;
start();
}
}, 1500);
return {element: root, destroy};
}

109
ui-ngx/src/app/modules/home/components/ai/ai-cli.models.ts

@ -13,8 +13,6 @@ export const CLI_OS_GROUP = 'cli-os';
export const CLI_AGENT_GROUP = 'cli-agent';
export const CLI_COPIED_MS = 4000;
export const CLI_DOCS = 'https://thingsboard.io/docs/cli/';
export const CLI_INSTALL: Record<CliOs, string> = {
@ -28,11 +26,12 @@ export interface CliAgentInfo {
run: string;
restart: string;
get: string;
glow: string;
}
export const CLI_AGENTS: CliAgentInfo[] = [
{id: 'claude', name: 'Claude Code', run: 'claude', restart: 'claude --continue', get: 'https://claude.com/claude-code'},
{id: 'antigravity', name: 'Antigravity', run: 'agy', restart: 'agy', get: 'https://antigravity.google/'}
{id: 'claude', name: 'Claude Code', run: 'claude', restart: 'claude --continue', get: 'https://claude.com/claude-code', glow: '#D97757'},
{id: 'antigravity', name: 'Antigravity', run: 'agy', restart: 'agy', get: 'https://antigravity.google/', glow: '#3186FF'}
];
export interface CliBuildInfo {
@ -72,6 +71,108 @@ export const CLI_DOCS_LINKS: CliDocsLink[] = [
{key: 'all', icon: 'menu_book', path: ''}
];
export type CliTermKind = 'you' | 'pick' | 'tool' | 'out' | 'say' | 'ok' | 'ask' | 'done';
export interface CliTermRow {
kind: CliTermKind;
text?: string;
tool?: string;
arg?: string;
ms?: number;
options?: string[];
seconds?: number;
}
export interface CliTermSession {
tab: string;
banner?: boolean;
intro?: CliTermRow[];
rows: CliTermRow[];
}
export const CLI_VERSION = 'thingsboard-cli 4.4.0.2.post1';
export const CLI_ART = [
' _____ _ _ ____ _ ',
'|_ _| |__ (_)_ __ __ _ ___| __ ) ___ __ _ _ __ __| |',
' | | | \'_ \\| | \'_ \\ / _` / __| _ \\ / _ \\ / _` | \'__/ _` |',
' | | | | | | | | | | (_| \\__ \\ |_) | (_) | (_| | | | (_| |',
' |_| |_| |_|_|_| |_|\\__, |___/____/ \\___/ \\__,_|_| \\__,_|',
' |___/ '
].join('\n');
export const CLI_TERM_WAIT: Record<string, number> = {you: 1200, pick: 300, tool: 380, out: 60, say: 520, ok: 110, ask: 260};
export const CLI_TERM_HOLD = 6000;
export const CLI_TERM_SESSIONS: CliTermSession[] = [
{
tab: 'office-sensor',
banner: true,
rows: [
{kind: 'you', text: 'office-sensor.you'},
{kind: 'tool', tool: 'Skill', arg: 'create-solution'},
{kind: 'out', text: 'office-sensor.written', ms: 2600},
{kind: 'say', text: 'office-sensor.ready'},
{kind: 'ok', text: 'office-sensor.device'},
{kind: 'ok', text: 'office-sensor.alarm'},
{kind: 'ok', text: 'office-sensor.dashboard'},
{kind: 'ask', text: 'office-sensor.ask'},
{kind: 'pick', options: ['office-sensor.stream', 'office-sensor.deploy-only', 'office-sensor.not-now']},
{kind: 'tool', tool: 'Bash', arg: 'tb push office'},
{kind: 'out', text: 'office-sensor.deployed', ms: 1500},
{kind: 'tool', tool: 'Bash', arg: 'tb emulator run --duration 5m'},
{kind: 'out', text: 'office-sensor.streaming', ms: 1100}
]
},
{
tab: 'smart-retail',
intro: [
{kind: 'tool', tool: 'Bash', arg: 'tb device list'},
{kind: 'out', text: 'smart-retail.devices'},
{kind: 'say', text: 'smart-retail.connected'},
{kind: 'done', seconds: 6}
],
rows: [
{kind: 'you', text: 'smart-retail.you'},
{kind: 'tool', tool: 'Skill', arg: 'design-solution-architecture'},
{kind: 'out', text: 'smart-retail.designed', ms: 2800},
{kind: 'say', text: 'smart-retail.approve'},
{kind: 'pick', options: ['smart-retail.step', 'smart-retail.whole']},
{kind: 'say', text: 'smart-retail.first'},
{kind: 'ok', text: 'smart-retail.overview'},
{kind: 'ok', text: 'smart-retail.store'},
{kind: 'ask', text: 'smart-retail.build'},
{kind: 'pick', options: ['smart-retail.yes', 'smart-retail.not-yet']},
{kind: 'tool', tool: 'Skill', arg: 'create-solution'},
{kind: 'out', text: 'smart-retail.built', ms: 3000},
{kind: 'say', text: 'smart-retail.next'}
]
},
{
tab: 'freezer-limits',
intro: [
{kind: 'tool', tool: 'Skill', arg: 'create-solution'},
{kind: 'out', text: 'smart-retail.built'},
{kind: 'say', text: 'smart-retail.next'},
{kind: 'done', seconds: 41}
],
rows: [
{kind: 'you', text: 'freezer-limits.you'},
{kind: 'tool', tool: 'Skill', arg: 'update-solution'},
{kind: 'out', text: 'freezer-limits.updated', ms: 2400},
{kind: 'say', text: 'freezer-limits.done'},
{kind: 'ok', text: 'freezer-limits.attribute'},
{kind: 'ok', text: 'freezer-limits.alarm'},
{kind: 'ok', text: 'freezer-limits.dashboard'},
{kind: 'ask', text: 'freezer-limits.ask'},
{kind: 'pick', options: ['freezer-limits.push', 'freezer-limits.not-now']},
{kind: 'tool', tool: 'Bash', arg: 'tb push smart-retail --profile dev'},
{kind: 'out', text: 'freezer-limits.deployed', ms: 1600}
]
}
];
export function cliOs(): CliOs {
const nav = navigator as Navigator & {userAgentData?: {platform?: string}};
return /win/i.test(nav.userAgentData?.platform || navigator.platform || '') ? 'windows' : 'unix';

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

@ -157,7 +157,6 @@ export interface CodeBlockOptions {
icon?: boolean;
check?: boolean;
labelledCopy?: boolean;
copiedFor?: number;
classes?: string;
}
@ -409,17 +408,13 @@ function copyBtn(text: string | (() => string), translate: TranslateService, cop
done(LABELLED_COPIED_MS);
}
});
if (options.copiedFor > 0) {
done(options.copiedFor);
}
return button;
}
if (options.check) {
button.append(icon('check', 'tb-mat-16 tb-copy-ok'));
}
button.append(icon('check', 'tb-mat-16 tb-copy-ok'));
button.addEventListener('click', () => {
if (copy(typeof text === 'function' ? text() : text)) {
button.classList.add('copied');
announceCopied(translate.instant('ai-assistant.copied'));
clearTimeout(timer);
timer = setTimeout(() => button.classList.remove('copied'), COPIED_MS);
}
@ -427,6 +422,20 @@ function copyBtn(text: string | (() => string), translate: TranslateService, cop
return button;
}
let copiedRegion: HTMLElement | null = null;
export function announceCopied(words: string): void {
if (!copiedRegion?.isConnected) {
copiedRegion = element('div', 'tb-ai-sr-only');
copiedRegion.setAttribute('role', 'status');
copiedRegion.setAttribute('aria-live', 'polite');
document.body.append(copiedRegion);
}
const region = copiedRegion;
region.textContent = '';
setTimeout(() => region.textContent = words, 30);
}
function icon(name: string, size: string): HTMLElement {
const glyph = element('span', `mat-icon material-icons notranslate ${size}`);
glyph.setAttribute('aria-hidden', 'true');
@ -790,4 +799,12 @@ export function decorateTables(root: HTMLElement): void {
root.querySelectorAll('table td, table th').forEach((cell: HTMLElement) => {
cell.classList.toggle('long', (cell.textContent ?? '').trim().length > LONG_CELL);
});
root.querySelectorAll('table td:first-child').forEach((cell: HTMLElement) => {
if (cell.firstElementChild?.classList.contains('k-md-lead') && cell.childNodes.length === 1) {
return;
}
const lead = element('span', 'k-md-lead');
lead.append(...Array.from(cell.childNodes));
cell.append(lead);
});
}

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

@ -0,0 +1,116 @@
<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
<section class="k-hand" [class.folded]="folded()" [attr.aria-label]="'ai-assistant.hand-over.needs-you' | translate">
@if (folded()) {
<button type="button" class="k-hand-fold" (click)="open.set(true)" [attr.aria-expanded]="false">
<mat-icon class="tb-mat-18" aria-hidden="true">check_circle</mat-icon>
<span>{{ handOver().title }}</span>
<mat-icon class="tb-mat-18 k-hand-fold-tg" aria-hidden="true">expand_more</mat-icon>
</button>
} @else {
<div class="k-head">
<mat-icon class="tb-mat-18" aria-hidden="true">person</mat-icon>{{ 'ai-assistant.hand-over.needs-you' | translate }}
<span class="k-sub">{{ handOver().title }}</span>
@if (arrived()) {
<button mat-icon-button type="button" class="k-hand-close" (click)="open.set(false)"
[attr.aria-label]="'ai-assistant.hand-over.fold' | translate"><mat-icon>expand_less</mat-icon></button>
}
</div>
<div class="k-body">
@if (handOver().text) {
<tb-markdown usePlainMarkdown [data]="handOver().text"></tb-markdown>
}
@if (handOver().choice; as choice) {
<div class="k-choice-panel">
<div class="k-choice">
<span class="k-qi"><mat-icon class="tb-mat-18" aria-hidden="true">{{ choice.icon }}</mat-icon></span>
<span class="k-qt">{{ choice.question }}</span>
<span class="ob-seg k-seg" role="group" [attr.aria-label]="choice.question">
@for (option of choice.options; track option.id) {
<button type="button" [attr.aria-pressed]="choiceValue() === option.id" (click)="pick(option.id)">
@if (option.icon) {
<mat-icon class="tb-mat-18" aria-hidden="true">{{ option.icon }}</mat-icon>
}
{{ option.label }}
</button>
}
</span>
</div>
@if (choiceText()) {
<div class="k-choice-body"><tb-markdown usePlainMarkdown [data]="choiceText()"></tb-markdown></div>
}
</div>
}
@if (handOver().steps.length) {
<ol class="k-steps">
@for (step of handOver().steps; track $index; let i = $index) {
<li [class.done]="done(i)">
<label>
<input type="checkbox" [checked]="done(i)" (change)="tick(i)">
<span class="k-step-t">{{ step.title }}</span>
@if (step.detail) {
<span class="k-step-d">{{ step.detail }}</span>
}
</label>
@if (step.values.length || step.markdown) {
<div class="k-step-x">
@for (value of step.values; track $index; let v = $index) {
<div class="k-value" [class.secret]="value.secret">
<mat-icon class="tb-mat-18 k-value-ic" aria-hidden="true">{{ value.icon }}</mat-icon>
<span class="k-value-l">{{ value.label }}</span>
<code class="k-value-v">{{ value.secret && !shown().has(i + '-' + v) ? masked(value.value) : value.value }}</code>
@if (value.secret) {
<button mat-icon-button type="button" class="k-value-b" (click)="reveal(i + '-' + v)"
[matTooltip]="(shown().has(i + '-' + v) ? 'ai-assistant.hand-over.hide' : 'ai-assistant.hand-over.show') | translate"
[attr.aria-label]="(shown().has(i + '-' + v) ? 'ai-assistant.hand-over.hide' : 'ai-assistant.hand-over.show') | translate">
<mat-icon class="tb-mat-18">{{ shown().has(i + '-' + v) ? 'visibility_off' : 'visibility' }}</mat-icon>
</button>
}
<button mat-icon-button type="button" class="k-value-b" (click)="copy(i + '-' + v, value.value)"
[matTooltip]="(copied() === i + '-' + v ? 'ai-assistant.hand-over.copied' : 'action.copy') | translate"
[attr.aria-label]="'action.copy' | translate">
<mat-icon class="tb-mat-18">{{ copied() === i + '-' + v ? 'check' : 'content_copy' }}</mat-icon>
</button>
</div>
}
@if (step.markdown) {
<tb-markdown usePlainMarkdown [data]="step.markdown"></tb-markdown>
}
</div>
}
</li>
}
</ol>
}
@if (quiet() || stoppedQuiet()) {
<div class="k-quiet">
<div class="k-wait warn" role="status">
<mat-icon class="tb-mat-18" aria-hidden="true">schedule</mat-icon>
<span>{{ 'ai-assistant.hand-over.nothing-heard' | translate: {minutes: quietMinutes()} }}</span>
@if (waiting()) {
<span class="clock">{{ clock() }}</span>
}
</div>
<div class="k-chips">
<button type="button" class="ob-chip" (click)="say('ai-assistant.hand-over.keep-waiting-prompt')">
<mat-icon aria-hidden="true">check</mat-icon>{{ 'ai-assistant.hand-over.keep-waiting' | translate }}
</button>
<button type="button" class="ob-chip" (click)="say('ai-assistant.hand-over.what-wrong-prompt')">
<mat-icon aria-hidden="true">help_outline</mat-icon>{{ 'ai-assistant.hand-over.what-wrong' | translate }}
</button>
</div>
</div>
} @else if (waiting()) {
<div class="k-wait" role="status">
<tb-ai-spin kind="think" aria-hidden="true"></tb-ai-spin>
<span class="k-wait-t">{{ waitLabel() }}</span>
<span class="clock">{{ clock() }}</span>
</div>
}
</div>
}
</section>

125
ui-ngx/src/app/modules/home/components/ai/ai-hand-over.component.ts

@ -0,0 +1,125 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Component, computed, DestroyRef, effect, ElementRef, EventEmitter, inject, input, Output, signal } from '@angular/core';
import { Clipboard } from '@angular/cdk/clipboard';
import { TranslateService } from '@ngx-translate/core';
import { AiConnectionCheck, AiHandOver } from '@home/components/ai/ai-action.models';
import { announceCopied, decorateCodeBlocks } from '@home/components/ai/ai-code-block';
export interface AiHandOverWait {
running: boolean;
startedAt: number;
progress?: string;
check?: AiConnectionCheck | null;
}
const MIN_SILENCE_MS = 120000;
const COPIED_MS = 1500;
@Component({
selector: 'tb-ai-hand-over',
templateUrl: './ai-hand-over.component.html',
standalone: false
})
export class AiHandOverComponent {
handOver = input.required<AiHandOver>();
wait = input<AiHandOverWait | null>(null);
time = input<number>(0);
@Output() prompt = new EventEmitter<string>();
private host = inject(ElementRef<HTMLElement>);
private translate = inject(TranslateService);
private clipboard = inject(Clipboard);
readonly picked = signal<string | null>(null);
readonly ticked = signal<ReadonlySet<number>>(new Set());
readonly shown = signal<ReadonlySet<string>>(new Set());
readonly copied = signal<string | null>(null);
readonly now = signal(Date.now());
readonly open = signal(false);
readonly choiceValue = computed(() => this.picked() ?? this.handOver().choice?.value ?? null);
readonly choiceText = computed(() => this.handOver().choice?.options.find(option => option.id === this.choiceValue())?.text ?? '');
readonly arrived = computed(() => this.wait()?.check?.dataArriving === true);
readonly folded = computed(() => this.arrived() && !this.open());
readonly waiting = computed(() => !!this.wait()?.running);
readonly elapsed = computed(() => Math.max(0, this.now() - (this.wait()?.startedAt ?? this.now())));
readonly clock = computed(() => {
const seconds = Math.floor(this.elapsed() / 1000);
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
});
readonly silenceMs = computed(() => Math.max(MIN_SILENCE_MS, 2 * 1000 * (this.handOver().waitFor === 'gateway' ? 0 : this.handOver().intervalSeconds ?? 0)));
readonly quiet = computed(() => this.waiting() && this.elapsed() >= this.silenceMs());
readonly quietMinutes = computed(() => Math.max(2, Math.floor(this.elapsed() / 60000)));
readonly stoppedQuiet = computed(() => {
const wait = this.wait();
return !!wait && !wait.running && !!wait.check && !wait.check.dataArriving;
});
constructor() {
const timer = setInterval(() => {
if (this.waiting()) {
this.now.set(Date.now());
}
}, 1000);
inject(DestroyRef).onDestroy(() => clearInterval(timer));
effect(() => {
this.choiceText();
this.handOver();
this.folded();
setTimeout(() => decorateCodeBlocks(this.host.nativeElement, this.translate, text => this.clipboard.copy(text)));
});
}
waitLabel(): string {
return this.translate.instant('ai-assistant.hand-over.wait-' + (this.handOver().waitFor ?? 'message'));
}
pick(id: string): void {
this.picked.set(id);
}
tick(index: number): void {
const next = new Set(this.ticked());
if (next.has(index)) {
next.delete(index);
} else {
next.add(index);
}
this.ticked.set(next);
}
done(index: number): boolean {
return this.ticked().has(index) !== (this.handOver().steps[index]?.done === true);
}
reveal(key: string): void {
const next = new Set(this.shown());
if (next.has(key)) {
next.delete(key);
} else {
next.add(key);
}
this.shown.set(next);
}
masked(value: string): string {
return value.length > 8 ? value.slice(0, 4) + '••••••••' + value.slice(-4) : '••••••••';
}
copy(key: string, value: string): void {
if (this.clipboard.copy(value)) {
this.copied.set(key);
announceCopied(this.translate.instant('ai-assistant.copied'));
setTimeout(() => this.copied.set(null), COPIED_MS);
}
}
say(key: string): void {
this.prompt.emit(this.translate.instant(key));
}
}

47
ui-ngx/src/app/modules/home/components/ai/ai-limit-out.component.html

@ -0,0 +1,47 @@
<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
@let current = view();
<section class="k-credits-out" role="alert" [attr.aria-label]="current.title">
<div class="k-credits-out-head">
<span class="k-credits-out-mark" aria-hidden="true"><mat-icon fontSet="material-icons-round">{{ current.icon }}</mat-icon></span>
<div class="k-credits-out-text">
<b>{{ current.title }}</b>
<span>{{ current.text }}</span>
</div>
<button mat-icon-button type="button" class="k-credits-out-close" [matTooltip]="'action.close' | translate"
[attr.aria-label]="'action.close' | translate" (click)="dismissed.emit()">
<mat-icon>close</mat-icon>
</button>
</div>
@if (current.action !== 'none' || current.usage) {
<div class="k-credits-out-actions">
@switch (current.action) {
@case ('request') {
@if (state() === 'sent') {
<span class="k-credits-out-sent" role="status"><mat-icon fontSet="material-icons-round">check_circle</mat-icon>{{ 'ai-assistant.limit-out.sent' | translate }}</span>
} @else {
<button mat-flat-button color="primary" type="button" [disabled]="state() === 'sending'" (click)="request()">
{{ current.requestLabel | translate }}
</button>
@if (state() === 'failed') {
<span class="k-credits-out-failed" role="status">{{ 'ai-assistant.limit-out.failed' | translate }}</span>
}
}
}
@case ('license') {
<a mat-flat-button color="primary" routerLink="/license">{{ 'ai-assistant.limit-out.manage-license' | translate }}</a>
}
@case ('pricing') {
<a mat-flat-button color="primary" [href]="pricingUrl" target="_blank" rel="noopener">{{ 'subscription.upgrade-plan' | translate }}</a>
}
}
@if (current.usage) {
<a mat-button routerLink="/usage" class="k-credits-out-usage">{{ 'ai-assistant.limit-out.view-usage' | translate }}</a>
}
</div>
}
</section>

179
ui-ngx/src/app/modules/home/components/ai/ai-limit-out.component.ts

@ -0,0 +1,179 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { ChangeDetectionStrategy, Component, computed, effect, inject, input, output, signal } from '@angular/core';
import { Store } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { AppState } from '@core/core.state';
import { getCurrentAuthState, getCurrentAuthUser } from '@core/auth/auth.selectors';
import { NotificationService } from '@core/http/notification.service';
import { Authority } from '@shared/models/authority.enum';
import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models';
import { AddonType, SubscriptionEntry, subscriptionEntryToEntityType } from '@shared/models/subscription.models';
import { AiPlatformLimit } from '@shared/models/ai-chat.models';
type RequestState = 'idle' | 'sending' | 'sent' | 'failed';
type LimitAction = 'request' | 'license' | 'pricing' | 'none';
interface LimitView {
icon: string;
title: string;
text: string;
action: LimitAction;
usage: boolean;
requestLabel?: string;
storageKey: string;
send?: () => Observable<void>;
}
const PRICING_URL = 'https://thingsboard.io/pricing/';
const WL_REQUESTED_STORAGE_KEY = 'wlRequested';
const PE_PACK_REQUESTED_STORAGE_KEY = 'pePackRequested';
const FEATURE_KEYS: Record<string, string> = {
[SubscriptionEntry.WHITE_LABELING]: 'white-labeling',
INTEGRATIONS: 'integrations',
SCHEDULER: 'scheduler',
REPORTING: 'reporting'
};
@Component({
selector: 'tb-ai-limit-out',
templateUrl: './ai-limit-out.component.html',
styleUrls: ['./ai-credits-out.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class AiLimitOutComponent {
platformLimit = input.required<AiPlatformLimit>();
dismissed = output<void>();
private notificationService = inject(NotificationService);
private translate = inject(TranslateService);
private readonly store = inject(Store<AppState>);
private readonly user = getCurrentAuthUser(this.store);
private readonly authState = getCurrentAuthState(this.store);
readonly pricingUrl = PRICING_URL;
readonly state = signal<RequestState>('idle');
readonly view = computed(() => this.viewOf(this.platformLimit()));
constructor() {
effect(() => this.state.set(this.wasRequested(this.view().storageKey) ? 'sent' : 'idle'));
}
request(): void {
const send = this.view().send;
if (!send || this.state() === 'sending' || this.state() === 'sent') {
return;
}
this.state.set('sending');
send().subscribe({
next: () => {
this.rememberRequested(this.view().storageKey);
this.state.set('sent');
},
error: () => this.state.set('failed')
});
}
private viewOf(limit: AiPlatformLimit): LimitView {
const tenantAdmin = this.user?.authority === Authority.TENANT_ADMIN;
const sysAdmin = this.user?.authority === Authority.SYS_ADMIN;
const customer = this.user?.authority === Authority.CUSTOMER_USER;
const oldLicense = !(this.authState?.licenseVersion > 1);
const config = {ignoreLoading: true, ignoreErrors: true};
if (limit.errorCode === 41 && limit.entityType) {
const entityType = limit.entityType;
return {
icon: 'data_usage',
title: this.say('entity-title', {entities: this.entities(entityType)}),
text: customer
? this.say('tenant-text-plain', {entities: this.entities(entityType).toLowerCase()})
: this.say('tenant-text', {limit: limit.limit, entities: this.entities(entityType).toLowerCase()}),
action: 'request',
usage: tenantAdmin,
requestLabel: 'ai-assistant.limit-out.request',
storageKey: `tb-entity-limit-request:${this.user?.tenantId}:${entityType}:${limit.limit}`,
send: () => this.notificationService.sendEntitiesLimitIncreaseRequest(entityType, false, config)
};
}
const entry = limit.subscriptionEntry as SubscriptionEntry;
const licensedType = subscriptionEntryToEntityType.get(entry);
if (limit.subscriptionErrorCode === 'LIMIT_REACHED' && licensedType) {
return {
icon: 'data_usage',
title: this.say('entity-title', {entities: this.entities(licensedType)}),
text: oldLicense
? this.say('license-text-old', {entities: this.entities(licensedType).toLowerCase()})
: this.say('license-text', {entities: this.entities(licensedType).toLowerCase()}),
action: oldLicense ? 'pricing' : (sysAdmin ? 'license' : 'request'),
usage: false,
requestLabel: 'ai-assistant.limit-out.request',
storageKey: `tb-entity-limit-request:${this.user?.tenantId}:${licensedType}:license`,
send: () => this.notificationService.sendEntitiesLimitIncreaseRequest(licensedType, true, config)
};
}
const featureKey = FEATURE_KEYS[limit.subscriptionEntry ?? ''];
if (limit.subscriptionErrorCode === 'FEATURE_DISABLED' && featureKey) {
const whiteLabeling = entry === SubscriptionEntry.WHITE_LABELING;
const grant = !!this.authState?.communityGrantLicense;
const addon = whiteLabeling && !grant ? AddonType.WHITE_LABELING : AddonType.PROFESSIONAL_UPGRADE;
return {
icon: whiteLabeling ? 'palette' : 'lock',
title: grant
? this.translate.instant(`platform-feature.${featureKey}.not-in-ce-grant`)
: (whiteLabeling ? this.translate.instant('platform-feature.white-labeling.not-in-plan')
: this.say('feature-title', {feature: this.say(`feature.${featureKey}`)})),
text: this.say(addon === AddonType.WHITE_LABELING ? 'white-labeling-text' : 'pack-text'),
action: sysAdmin ? 'license' : (oldLicense && !grant ? 'pricing' : 'request'),
usage: false,
requestLabel: 'subscription.request-access',
storageKey: addon === AddonType.WHITE_LABELING ? WL_REQUESTED_STORAGE_KEY : PE_PACK_REQUESTED_STORAGE_KEY,
send: () => this.notificationService.sendAddonAccessRequest(addon, config)
};
}
return {
icon: 'lock',
title: this.say('license-required'),
text: limit.message ?? '',
action: sysAdmin ? 'license' : 'none',
usage: false,
storageKey: ''
};
}
private entities(entityType: EntityType): string {
const translations = entityTypeTranslations.get(entityType);
return translations ? this.translate.instant(translations.typePlural) as string : entityType;
}
private say(key: string, params?: object): string {
return this.translate.instant('ai-assistant.limit-out.' + key, params);
}
private wasRequested(key: string): boolean {
if (!key) {
return false;
}
try {
const stored = localStorage.getItem(key);
return stored === 'sent' || stored === 'true';
} catch {
return false;
}
}
private rememberRequested(key: string): void {
if (!key) {
return;
}
try {
localStorage.setItem(key, key === WL_REQUESTED_STORAGE_KEY || key === PE_PACK_REQUESTED_STORAGE_KEY ? JSON.stringify(true) : 'sent');
} catch {
return;
}
}
}

16
ui-ngx/src/app/modules/home/components/ai/ai-prompt-input.component.scss

@ -689,15 +689,17 @@ $chevron: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox=
align-items: center;
justify-content: center;
box-sizing: border-box;
min-width: 22px;
height: 22px;
padding: 0 6px;
min-width: 20px;
height: 20px;
padding: 0 5px;
border: 1px solid var(--tb-line);
border-bottom-width: 2px;
border-radius: 6px;
background: var(--tb-surface);
color: var(--tb-ink-54);
font: 500 12px/1 var(--tb-font);
border-radius: 5px;
background: none;
color: var(--k-faint);
font: 400 11px/1 var(--tb-font);
letter-spacing: .2px;
white-space: nowrap;
pointer-events: none;
transform: translateY(-50%);
}

7
ui-ngx/src/app/modules/home/components/ai/ai-record-card.component.ts

@ -43,7 +43,7 @@ export function aiWidgetThumb(): string {
template: `
@let rec = view();
<div #card class="tb-rec card" [attr.data-pal]="kind().palette"
[class.with-pic]="picture()" [class.primary]="!!primaryAction()" [class.tight]="tight()" [class.with-details]="hasFoot()">
[class.with-pic]="picture()" [class.primary]="!!primaryAction()" [class.open-icon]="primaryAction() === 'open'" [class.tight]="tight()" [class.with-details]="hasFoot()">
<div class="tb-rec-row">
@if (picture()) {
<span class="tb-rec-pic" [class.sq]="rec.square" [class.wide]="rec.wide" aria-hidden="true">
@ -100,8 +100,9 @@ export function aiWidgetThumb(): string {
</button>
}
@case ('open') {
<a mat-flat-button class="tb-open-btn" [routerLink]="rec.url">
<mat-icon aria-hidden="true">{{ kind().icon }}</mat-icon>{{ openLabel() }}
<a mat-flat-button class="tb-open-btn icon" [routerLink]="rec.url" [matTooltip]="openLabel()" matTooltipPosition="above"
[attr.aria-label]="openLabel() + ': ' + rec.name">
<mat-icon aria-hidden="true">arrow_forward</mat-icon>
</a>
}
@default {

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

@ -11,7 +11,7 @@ export interface AiReference {
id: string;
}
const SKIP = 'code, pre, a, table, .tb-chiplink, .k-ent';
const SKIP = 'code, pre, a, .tb-chiplink, .k-ent';
export function decorateReferences(root: HTMLElement, references: AiReference[] | undefined): void {
if (!references?.length) {
@ -78,31 +78,73 @@ function chip(reference: AiReference): HTMLElement {
const link = document.createElement('a');
link.className = 'tb-chiplink';
link.href = `${base}/${reference.id}`;
code.append(chipChevron());
link.append(code);
return link;
}
export function chipChevron(): HTMLElement {
const chevron = document.createElement('span');
chevron.className = 'mat-icon notranslate material-icons mat-ligature-font tb-chip-go';
chevron.setAttribute('aria-hidden', 'true');
chevron.textContent = 'chevron_right';
return chevron;
}
function escape(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
export function decorateLinks(root: HTMLElement): void {
export function decorateLinks(root: HTMLElement, newTab: string): void {
root.querySelectorAll<HTMLAnchorElement>('a[href]:not(.tb-chiplink)').forEach(link => {
if (link.closest('pre, code') || link.origin === location.origin || !/^https?:$/.test(link.protocol)) {
return;
}
link.target = '_blank';
link.rel = 'noopener noreferrer';
if (!link.querySelector('.k-ext')) {
const icon = document.createElement('span');
icon.className = 'mat-icon notranslate material-icons mat-ligature-font k-ext';
icon.setAttribute('aria-hidden', 'true');
icon.textContent = 'open_in_new';
link.append(icon);
if (link.querySelector('.k-ext')) {
return;
}
const last = lastText(link);
const tail = document.createElement('span');
tail.className = 'k-ext-tail';
if (last) {
const text = last.textContent ?? '';
const cut = text.trimEnd().lastIndexOf(' ') + 1;
tail.append(text.slice(cut));
last.textContent = text.slice(0, cut);
last.after(tail);
} else {
link.append(tail);
}
const icon = document.createElement('span');
icon.className = 'mat-icon notranslate material-icons mat-ligature-font k-ext';
icon.setAttribute('aria-hidden', 'true');
icon.textContent = 'north_east';
tail.append(icon);
const hidden = document.createElement('span');
hidden.className = 'tb-ai-sr-only';
hidden.textContent = ' ' + newTab;
link.append(hidden);
});
}
function lastText(root: Node): Text | null {
for (let node = root.lastChild; node; node = node.previousSibling) {
if (node.nodeType === Node.TEXT_NODE) {
if (node.textContent?.trim()) {
return node as Text;
}
} else {
const found = lastText(node);
if (found) {
return found;
}
}
}
return null;
}
const SEVERITY_SKIP = 'code, pre, a, table, .k-sev, .tb-chiplink';
export function decorateSeverities(root: HTMLElement, severities: string[] | undefined, label: (severity: string) => string): void {

2
ui-ngx/src/app/modules/home/components/ai/ai-started-from.component.ts

@ -57,7 +57,7 @@ const LIST_PAGES: Record<string, {entityType: string; url: string}> = {
<span>{{ 'ai-assistant.started-from' | translate }}</span>
@if (current.url) {
<a class="tb-chiplink" [routerLink]="current.url" [matTooltip]="'ai-assistant.open-page' | translate: {name: current.name}" matTooltipPosition="above">
<code class="k-ent" [attr.data-pal]="kind().palette"><mat-icon class="k-ent-ic" aria-hidden="true">{{ kind().icon }}</mat-icon>{{ current.name }}</code>
<code class="k-ent" [attr.data-pal]="kind().palette"><mat-icon class="k-ent-ic" aria-hidden="true">{{ kind().icon }}</mat-icon>{{ current.name }}<mat-icon class="tb-chip-go" aria-hidden="true">chevron_right</mat-icon></code>
</a>
} @else {
<code class="k-ent" [attr.data-pal]="kind().palette"><mat-icon class="k-ent-ic" aria-hidden="true">{{ kind().icon }}</mat-icon>{{ current.name }}</code>

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

@ -11,6 +11,7 @@ import { AiApprovalCardComponent } from '@home/components/ai/ai-approval-card.co
import { AiRenameDialogComponent } from '@home/components/ai/ai-rename-dialog.component';
import { AiCreditsComponent } from '@home/components/ai/ai-credits.component';
import { AiCreditsOutComponent } from '@home/components/ai/ai-credits-out.component';
import { AiLimitOutComponent } from '@home/components/ai/ai-limit-out.component';
import { AiCreditsPopupComponent } from '@home/components/ai/ai-credits-popup.component';
import { AiLoadingModalComponent } from '@home/components/ai/ai-loading-modal.component';
import { AiNoTelemetryModalComponent } from '@home/components/ai/ai-no-telemetry-modal.component';
@ -35,6 +36,7 @@ import { AiCardActionsComponent } from '@home/components/ai/ai-card-actions.comp
import { AiDisclosureComponent } from '@home/components/ai/ai-disclosure.component';
import { AiQuestionComponent } from '@home/components/ai/ai-question.component';
import { AiPlanComponent } from '@home/components/ai/ai-plan.component';
import { AiHandOverComponent } from '@home/components/ai/ai-hand-over.component';
import { AiArtifactPaneComponent } from '@home/components/ai/ai-artifact-pane.component';
import { AiFileBodyComponent } from '@home/components/ai/ai-file-body.component';
import { AiSparkComponent } from '@home/components/ai/ai-spark.component';
@ -51,6 +53,7 @@ import { AiCliGuideComponent } from '@home/components/ai/ai-cli-guide.component'
AiRenameDialogComponent,
AiCreditsComponent,
AiCreditsOutComponent,
AiLimitOutComponent,
AiCreditsPopupComponent,
AiLoadingModalComponent,
AiNoTelemetryModalComponent,
@ -73,6 +76,7 @@ import { AiCliGuideComponent } from '@home/components/ai/ai-cli-guide.component'
AiMarkComponent,
AiQuestionComponent,
AiPlanComponent,
AiHandOverComponent,
AiArtifactPaneComponent,
AiFileBodyComponent,
AiSevMarkComponent,
@ -103,11 +107,13 @@ import { AiCliGuideComponent } from '@home/components/ai/ai-cli-guide.component'
AiRenameDialogComponent,
AiCreditsComponent,
AiCreditsOutComponent,
AiLimitOutComponent,
AiLoadingModalComponent,
AiNoTelemetryModalComponent,
AiAttachmentsComponent,
AiQuestionComponent,
AiPlanComponent,
AiHandOverComponent,
AiArtifactPaneComponent,
AiFileBodyComponent,
AiRecordComponent,

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

@ -143,7 +143,7 @@
@if (solutionId()) {
<tb-solution-chat class="ai-canvas ai-solution" (loaded)="onSolutionLoaded($event)" (click)="onChatClick($event)"></tb-solution-chat>
} @else if (cli()) {
<tb-ai-cli-guide class="ai-canvas" [copiedUntil]="cliCopiedUntil()" (closed)="openGetStarted()" (click)="onChatClick($event)">
<tb-ai-cli-guide class="ai-canvas" (closed)="openGetStarted()" (click)="onChatClick($event)">
@if (!railOpen()) {
<button aiChatLead type="button" class="ai-ib ai-bar-chats" (click)="toggleRail()"
[matTooltip]="'ai-assistant.open-chats' | translate" matTooltipPosition="above" [attr.aria-label]="'ai-assistant.open-chats' | translate">

16
ui-ngx/src/app/modules/home/pages/ai-assistant/ai-assistant.component.scss

@ -256,10 +256,20 @@
.ai-find-key {
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
min-width: 20px;
height: 20px;
padding: 0 5px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.05);
font: 500 11px/18px var(--tb-font);
border: 1px solid var(--tb-line);
border-bottom-width: 2px;
border-radius: 5px;
background: none;
font: 400 11px/1 var(--tb-font);
letter-spacing: .2px;
white-space: nowrap;
color: var(--k-faint);
@media (max-width: 599px), (pointer: coarse) {

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

@ -34,7 +34,6 @@ import { AiChatComponent } from '@home/components/ai/ai-chat.component';
import { AiSolutionsService } from '@core/services/ai-solutions.service';
import { NEW_SOLUTION_ID, SolutionInfo } from '@shared/models/solution-creator.models';
import { SolutionChatComponent } from '@home/components/ai/solution/solution-chat.component';
import { CLI_COPIED_MS } from '@home/components/ai/ai-cli.models';
export interface AiRailRow {
id: string;
@ -92,8 +91,6 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
cli = signal(false);
cliCopiedUntil = signal(0);
aiChats = inject(AiChatsService);
private aiChat = inject(AiChatService);
@ -255,8 +252,8 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
if (params.get('focus') === 'composer') {
this.landOnComposer();
}
if (params.has('copied')) {
this.landOnCli(params.get('copied') === 'prompt');
if (params.get('chats') === 'closed') {
this.landFolded();
}
if (handOff) {
this.newChat();
@ -580,12 +577,9 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
this.getStarted.set(getStarted && !showCli && !nextSolution && !next);
}
private landOnCli(copied: boolean): void {
private landFolded(): void {
this.railOpen.set(false);
if (copied) {
this.cliCopiedUntil.set(Date.now() + CLI_COPIED_MS);
}
this.router.navigate([], {relativeTo: this.route, queryParams: {copied: null}, queryParamsHandling: 'merge', replaceUrl: true});
this.router.navigate([], {relativeTo: this.route, queryParams: {chats: null}, queryParamsHandling: 'merge', replaceUrl: true});
}
private landOnComposer(): void {

17
ui-ngx/src/app/modules/home/pages/home-page/components/ai-start-home.component.ts

@ -11,9 +11,6 @@ import { EntityCountCmd, TelemetrySubscriber } from '@shared/models/telemetry/te
import { AliasFilterType } from '@shared/models/alias.models';
import { EntityType } from '@shared/models/entity-type.models';
import { NEW_SOLUTION_ID } from '@shared/models/solution-creator.models';
import { Router } from '@angular/router';
import { ClipboardService } from 'ngx-clipboard';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'tb-ai-start-home',
@ -48,7 +45,7 @@ import { TranslateService } from '@ngx-translate/core';
<span class="tb-ai-start-t">{{ 'home.ai.start-solution' | translate }}</span>
<mat-icon class="tb-ai-start-go" aria-hidden="true">chevron_right</mat-icon>
</a>
<a class="tb-ai-start cli" href="/ai-assistant?cli=true" (click)="useCli($event)"
<a class="tb-ai-start cli" routerLink="/ai-assistant" [queryParams]="{cli: true, chats: 'closed'}"
[matTooltip]="'home.ai.start-cli-tip' | translate" matTooltipPosition="above">
<span class="tb-ai-start-ic" aria-hidden="true"><mat-icon fontSet="material-icons-round">terminal</mat-icon></span>
<span class="tb-ai-start-t">{{ 'home.ai.start-cli' | translate }}</span>
@ -68,9 +65,6 @@ export class AiStartHomeComponent {
private chats = inject(AiChatsService);
private solutions = inject(AiSolutionsService);
private router = inject(Router);
private clipboard = inject(ClipboardService);
private translate = inject(TranslateService);
private readonly devices = signal<number | null>(null);
@ -100,15 +94,6 @@ export class AiStartHomeComponent {
});
}
useCli(event: MouseEvent): void {
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
return;
}
event.preventDefault();
const copied = this.clipboard.copyFromContent(this.translate.instant('ai-assistant.cli.setup-prompt'));
this.router.navigate(['/ai-assistant'], {queryParams: {cli: true, copied: copied ? 'prompt' : null}});
}
private readShown(): boolean {
try {
return localStorage.getItem(this.shownKey) === '1';

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

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { EntityId } from '@shared/models/id/entity-id';
import { EntityType } from '@shared/models/entity-type.models';
export interface ChatConfiguration {
title: string;
@ -44,9 +45,9 @@ export interface ChatInfo extends ChatConfiguration {
updatedTime?: number;
}
export type ChatStatus = 'RUNNING' | 'NEEDS_YOU' | 'FAILED';
export type ChatStatus = 'RUNNING' | 'NEEDS_YOU' | 'NO_DATA' | 'FAILED';
export type ChatLevel = 'needs' | 'running' | 'error';
export type ChatLevel = 'needs' | 'nodata' | 'running' | 'error';
export interface BaseChatEvent {
event: string;
@ -250,8 +251,23 @@ export interface ThinkingChatEvent extends BaseChatEvent {
data: {headline?: string; tool?: string; arguments?: unknown};
}
export interface LimitReachedChatEvent extends BaseChatEvent {
event: 'limitReached';
data: AiPlatformLimit;
}
export interface AiPlatformLimit {
errorCode: number;
message?: string;
entityType?: EntityType;
limit?: number;
subscriptionErrorCode?: 'LIMIT_REACHED' | 'FEATURE_DISABLED';
subscriptionEntry?: string;
subscriptionValue?: number;
}
export type ChatEvent = AssistantChatEvent | AssistantDeltaChatEvent | ToolExecutionRequestedEvent | ToolExecutionResultEvent | ErrorEvent | ChatTitleGeneratedEvent
| TurnResumedEvent | TurnStoppedEvent | MessageQueuedEvent | ToolStartedEvent | ToolFinishedEvent | ThinkingChatEvent;
| TurnResumedEvent | TurnStoppedEvent | MessageQueuedEvent | ToolStartedEvent | ToolFinishedEvent | ThinkingChatEvent | LimitReachedChatEvent;
export enum AiAssistantViewType {
PAGE = 'PAGE',

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

@ -1898,6 +1898,62 @@
"run": "Deleting the asset profile",
"done": "Deleted the asset profile"
},
"save-credentials": {
"run": "Changing the device credentials",
"done": "Changed the device credentials"
},
"test-converter": {
"run": "Testing the converter",
"done": "Tested the converter"
},
"read-converter-library": {
"run": "Reading the converter library",
"done": "Read the converter library"
},
"create-device-profile": {
"run": "Creating the device profile",
"done": "Created the device profile"
},
"update-device-profile": {
"run": "Updating the device profile",
"done": "Updated the device profile"
},
"create-converter": {
"run": "Creating the converter",
"done": "Created the converter"
},
"update-converter": {
"run": "Updating the converter",
"done": "Updated the converter"
},
"create-integration": {
"run": "Creating the integration",
"done": "Created the integration"
},
"update-integration": {
"run": "Updating the integration",
"done": "Updated the integration"
},
"delete-device-profile": {
"run": "Deleting the device profile",
"done": "Deleted the device profile"
},
"delete-integration": {
"run": "Deleting the integration",
"done": "Deleted the integration"
},
"delete-converter": {
"run": "Deleting the converter",
"done": "Deleted the converter"
},
"check-connection": {
"run": "Checking the connection",
"done": "Checked the connection"
},
"wait-for-data": {
"run": "Waiting for data",
"done": "Waited for data"
},
"delete-secret": {
"run": "Deleting the secret",
"done": "Deleted the secret"
@ -2117,6 +2173,21 @@
"none-left": "No credits left",
"aria": "AI credits: {{used}} of {{max}} used this month"
},
"hand-over": {
"needs-you": "Needs you",
"fold": "Fold",
"show": "Show",
"hide": "Hide",
"copied": "Copied",
"wait-message": "listening for the first message",
"wait-uplink": "listening for the first uplink",
"wait-gateway": "listening for the gateway",
"nothing-heard": "nothing heard for {{minutes}} min",
"keep-waiting": "It is on, keep waiting",
"keep-waiting-prompt": "It is on. Keep waiting for the data.",
"what-wrong": "What could be wrong?",
"what-wrong-prompt": "Nothing arrived. What could be wrong?"
},
"credits-out": {
"title": "AI credits used up",
"tenant-text": "Your tenant has used all {{limit}} AI credits for this month. They reset on {{date}}, or your system administrator can raise the limit.",
@ -2127,6 +2198,28 @@
"failed": "Couldn't send the request. Try again.",
"view-usage": "View usage"
},
"limit-out": {
"entity-title": "{{entities}} limit reached",
"tenant-text": "Your tenant can have up to {{limit}} {{entities}}. Your system administrator can raise the limit.",
"tenant-text-plain": "Your tenant has reached its limit of {{entities}}. Your system administrator can raise the limit.",
"license-text": "Your license allows no more {{entities}}. Your system administrator can raise the limit in License management.",
"license-text-old": "You have reached the maximum {{entities}} allowed by your subscription plan. You can upgrade the plan to raise your limits.",
"feature-title": "{{feature}} not included in your plan",
"feature": {
"white-labeling": "White-labeling",
"integrations": "Integrations",
"scheduler": "Scheduler",
"reporting": "Reports"
},
"white-labeling-text": "With White-labeling, your brand replaces ThingsBoard's on the login page, in the mail you send and on every page your customers work in.",
"pack-text": "It comes with the Professional Pack. Request access and your system administrator gets your request.",
"license-required": "License required",
"request": "Request a higher limit",
"manage-license": "Manage license",
"sent": "Request sent to your system administrator.",
"failed": "Couldn't send the request. Try again.",
"view-usage": "View usage"
},
"get-started": {
"title": "Get started",
"heading": "What are you building, or what device do you have?",
@ -2160,77 +2253,6 @@
"create-solution": "Create a solution",
"create-solution-hint": "Devices, dashboards and alarms, set up as one",
"create-solution-start": "Start",
"code": {
"script": "Script",
"lines": "{ count, plural, =1 {1 line} other {# lines} }",
"wrap-lines": "Wrap lines",
"one-line-each": "One line each",
"wrap-long-lines": "Wrap long lines"
},
"task": {
"connect-device": {
"title": "Connect a device",
"hint": "A sensor, a gateway or a cloud integration",
"prompt": "Connect "
},
"build-dashboard": {
"title": "Build a dashboard",
"hint": "From the keys a device sends",
"prompt": "Build a dashboard for "
},
"set-up-alarm": {
"title": "Set up an alarm",
"hint": "A rule on a value, and who is told",
"prompt": "Alert me when "
}
},
"copy": "Copy",
"edit-message": "Edit: the words back in the composer",
"show-all": "Show all",
"rename-save": "Save (Enter)",
"rename-discard": "Discard (Esc)",
"review": {
"verb": {
"install": "Install",
"restart": "Restart",
"update": "Update",
"upgrade": "Upgrade",
"upgrade-agent": "Upgrade the agent",
"delete": "Delete",
"cancel": "Cancel the operation",
"sync": "Sync"
},
"head": {
"pending": "Needs your review",
"approved": "Approved",
"auto": "Auto-approved",
"denied": "Denied",
"expired": "No answer in time"
},
"current": "Current",
"new": "New",
"unchanged": "{{count}} unchanged",
"hide-unchanged": "Hide unchanged",
"not-set": "not set",
"delete": "Delete",
"create": "Create",
"update": "Update",
"denied-text": "Nothing was made.",
"expired-text": "Nothing was made. The run waits here.",
"ask-again": "Ask again",
"ask-again-message": "Ask me again for the same change.",
"field": {
"agent": "Agent",
"install": "Install",
"runs": "Runs",
"operation": "Operation",
"application": "Application",
"applications": "Applications",
"removeVolumes": "Delete its data",
"provisionType": "Provisioning",
"appProfiles": "Application profiles",
"default": "Default profile",
"variant": "Variant",
"cli": {
"title": "ThingsBoard CLI",
"kicker": "ThingsBoard CLI",
@ -2244,7 +2266,64 @@
},
"hero": {
"title": "Build on ThingsBoard with your coding agent",
"lead": "Describe your devices to Claude Code or Antigravity. Your agent builds the solution and deploys to ThingsBoard when you approve."
"lead": "Describe your devices in plain words. Claude Code or Antigravity builds the solution in minutes.",
"start": "Get started",
"docs": "CLI docs"
},
"term": {
"label": "Example sessions",
"picture": "A coding agent in a terminal: {{about}}.",
"thinking": "Thinking…",
"running": "Running…",
"done": "Done in {{seconds}}s",
"connected": "Connected to eu.thingsboard.cloud",
"detected": "Coding agent detected",
"office-sensor": {
"about": "asked for an office sensor with a CO2 alert, the agent writes the device, an alarm rule and a dashboard, asks before the deploy, then deploys and streams demo data",
"you": "Add my office sensor: temperature, humidity and CO2. Alert me when CO2 goes above 1000.",
"written": "office: device, profile, alarm rule and dashboard written",
"ready": "Done. The office sensor is ready:",
"device": "Device Office Sensor, its profile with temperature, humidity and co2",
"alarm": "Alarm rule CO2 High, above 1000 ppm",
"dashboard": "Dashboard Office: three charts and the alarm list",
"ask": "Deploy to ThingsBoard and stream live demo data for 5 minutes?",
"stream": "Deploy and stream live data",
"deploy-only": "Deploy only",
"not-now": "Not now",
"deployed": "office deployed · 4 entities",
"streaming": "streaming to Office Sensor"
},
"smart-retail": {
"about": "asked for a smart retail solution, the agent designs it, asks how to approve the build, shows the dashboards and builds after a yes",
"devices": "eu.thingsboard.cloud · 0 devices",
"connected": "Connected to ThingsBoard, nothing built yet.",
"you": "Create a smart retail solution: three stores with freezers, fridges and door sensors.",
"designed": "3 stores · 36 devices · 4 dashboards · 2 roles",
"approve": "The design is ready. How do you want to approve the build?",
"step": "Step by step",
"whole": "The whole build at once",
"first": "First, the dashboards:",
"overview": "Chain overview: the stores on a map, open alarms by store",
"store": "Store: freezers, fridges and doors, with their alarms",
"build": "Build the devices and dashboards?",
"yes": "Yes",
"not-yet": "Not yet",
"built": "smart-retail: 52 entities written · validated",
"next": "Built and validated. The freezer alarms come next."
},
"freezer-limits": {
"about": "asked for an alarm limit on each freezer, the agent updates the solution, lists what changed, asks before the push and deploys after a yes",
"you": "Each freezer needs its own alarm limit. Let me set the limit from the dashboard.",
"updated": "attribute, alarm rule and dashboard updated",
"done": "Done. Each freezer now has its own temperature threshold:",
"attribute": "New attribute temperatureThreshold, set to -15 °C on all freezers",
"alarm": "Freezer Too Warm alarm now reads each freezer’s own threshold",
"dashboard": "Dashboard: the freezer view has a Temperature Threshold card",
"ask": "Want me to push this to dev?",
"push": "Push to dev",
"not-now": "Not now",
"deployed": "smart-retail deployed → dev · 9 entities"
}
},
"how-to-set-up": "How to set up",
"way": {
@ -2256,27 +2335,23 @@
"windows": "Windows",
"setup-prompt-label": "Setup prompt",
"setup-prompt": "Set up ThingsBoard CLI in this folder:\n\n1. Install or upgrade it. On macOS or Linux, run: curl -LsSf https://thingsboard.io/cli/install.sh | sh\n On Windows, run: powershell -ExecutionPolicy ByPass -c \"irm https://thingsboard.io/cli/install.ps1 | iex\"\n2. Run \"tb init --agent-format <agent> --browser\". Use \"claude\" for Claude Code or \"antigravity\" for Antigravity. It opens a page where I enter my ThingsBoard URL and API key. Tell me to complete the page, then wait. Never ask me for the API key in the chat, and never print secrets.\n3. Check the connection with \"tb device list\".\n\nIf everything works, reply with one sentence: the setup is complete, and I must restart you to load the ThingsBoard skills. Then show the restart commands for you only. Claude Code: type /exit, then run claude --continue. Antigravity: close it, then run agy in this folder. If a step fails, tell me what failed and how to fix it.",
"show-more": "Show more",
"show-less": "Show less",
"note-terminal": "Installs the CLI, then walks you through the setup.",
"note-agent": "Paste into your agent, in a new folder. One restart at the end.",
"step-by-step": "Step-by-step setup",
"how": {
"title": "How it works",
"agent": {
"title": "The agent does the work",
"text": "Claude Code or Antigravity, using the ThingsBoard skills the CLI adds."
"title": "Agents do the work",
"text": "Claude Code or Antigravity, with the CLI’s ThingsBoard skills."
},
"files": {
"title": "The solution is files",
"text": "Devices, dashboards and alarms as JSON in a folder, each step committed to git."
"title": "Solutions live in git",
"text": "Devices, dashboards and alarms as JSON, every step a commit.",
"commit": "Alarm limits"
},
"deploy": {
"title": "The deploy waits for a yes",
"text": "The CLI checks the files against ThingsBoard, and the agent asks before deploying.",
"question": "Deploy to ThingsBoard?",
"yes": "Deploy",
"no": "Not now"
"title": "Nothing goes live unasked",
"text": "The CLI checks the files against ThingsBoard before any deploy.",
"question": "Push this to dev?",
"yes": "1. Push to dev",
"no": "2. Not now"
}
},
"steps": {
@ -2334,7 +2409,7 @@
},
"deploy": {
"title": "Deploy and open the dashboard",
"text": "Your agent asks before the deploy, unless your request already said to deploy. Pick “Deploy and stream live data” and open the dashboard link in the reply.",
"text": "Your agent asks before deploying, unless your request already says to. Pick “Deploy and stream live data” and open the dashboard link in the reply.",
"push-note": "A push replaces changes made in the ThingsBoard UI. Ask your agent to pull first.",
"stream": "Stream demo data again:"
},
@ -2343,21 +2418,101 @@
"text": "After the deploy, your agent offers to connect a real device. Say Yes and name the device: an ESP32 board, a Raspberry Pi, or your own code. Your agent prepares the sketch, script or settings, then waits for the first value. No device yet? Say Later."
},
"docs": {
"title": "Go further in the CLI docs",
"title": "Explore the docs",
"device": {
"title": "Connect a real device",
"title": "Connect a device",
"line": "HTTP, MQTT or CoAP, by firmware or script"
},
"troubleshooting": {
"title": "Troubleshooting",
"title": "Troubleshoot",
"line": "Connection, setup, push and demo data"
},
"all": {
"title": "All CLI docs",
"title": "Browse all docs",
"line": "Alarms, customers, CI and the commands"
}
}
},
"code": {
"script": "Script",
"lines": "{ count, plural, =1 {1 line} other {# lines} }",
"wrap-lines": "Wrap lines",
"one-line-each": "One line each",
"wrap-long-lines": "Wrap long lines"
},
"task": {
"connect-device": {
"title": "Connect a device",
"hint": "A sensor, a gateway or a cloud integration",
"prompt": "Connect "
},
"build-dashboard": {
"title": "Build a dashboard",
"hint": "From the keys a device sends",
"prompt": "Build a dashboard for "
},
"set-up-alarm": {
"title": "Set up an alarm",
"hint": "A rule on a value, and who is told",
"prompt": "Alert me when "
}
},
"copy": "Copy",
"edit-message": "Edit: the words back in the composer",
"show-all": "Show all",
"rename-save": "Save (Enter)",
"rename-discard": "Discard (Esc)",
"review": {
"verb": {
"install": "Install",
"restart": "Restart",
"update": "Update",
"upgrade": "Upgrade",
"upgrade-agent": "Upgrade the agent",
"delete": "Delete",
"cancel": "Cancel the operation",
"sync": "Sync"
},
"head": {
"pending": "Needs your review",
"approved": "Approved",
"auto": "Auto-approved",
"denied": "Denied",
"expired": "No answer in time"
},
"current": "Current",
"new": "New",
"unchanged": "{{count}} unchanged",
"hide-unchanged": "Hide unchanged",
"not-set": "not set",
"delete": "Delete",
"create": "Create",
"update": "Update",
"denied-text": "Nothing was made.",
"expired-text": "Nothing was made. The run waits here.",
"ask-again": "Ask again",
"ask-again-message": "Ask me again for the same change.",
"field": {
"agent": "Agent",
"install": "Install",
"runs": "Runs",
"operation": "Operation",
"application": "Application",
"applications": "Applications",
"removeVolumes": "Delete its data",
"provisionType": "Provisioning",
"transport": "Transport",
"script": "Script",
"endpoint": "Endpoint",
"converter": "Converter",
"integration": "Integration",
"clientId": "Client ID",
"certificate": "Certificate",
"securityMode": "Security mode",
"entity": "Entity",
"appProfiles": "Application profiles",
"default": "Default profile",
"variant": "Variant",
"edgeTemplateRoot": "Root of new edges",
"autoAssign": "Assigned to new edges",
"cloudEndpoint": "Cloud endpoint",
@ -2808,12 +2963,15 @@
"failed": "The feedback was not saved. Try again."
},
"copied": "Copied",
"opens-new-tab": "(opens in a new tab)",
"what-should-be-different": "What should be different?",
"deny-placeholder": "Or say what should be different…",
"status-needs": "Needs you",
"status-nodata": "No data",
"status-running": "Running",
"status-error": "Failed",
"status-tip-needs": "Waits for your answer or approval",
"status-tip-nodata": "Nothing arrived from the device yet",
"status-tip-running": "In progress",
"status-tip-error": "The run stopped",
"waiting-one": "Open {{ title }}, it needs you",
@ -9055,6 +9213,8 @@
"start-device-tip": "The AI Assistant's Get started: one device, from an example",
"start-solution": "Create a solution",
"start-solution-tip": "The AI Assistant's New solution: describe it, or start from an example",
"start-cli": "Use the CLI",
"start-cli-tip": "Opens the ThingsBoard CLI guide for your coding agent",
"offer-title": "Ask from Home",
"offer-text": "Ask a question, or have it connect a device, build a dashboard or add an alarm rule.",
"offer-action": "Ask",
@ -9137,8 +9297,6 @@
"embed-to-angular-template": "Embed to Angular HTML template",
"embed-to-angular-template-text": "Using the following code snippet, you may embed an image into the Angular HTML template that will be used for components.<br/>Such components include the Markdown widget, HTML section in the widget editor, custom actions, etc."
},
"start-cli": "Use the CLI",
"start-cli-tip": "Copies a prompt for your coding agent and opens the ThingsBoard CLI",
"image-input": {
"drop-images-or": "Drag and drop an images or",
"drag-and-drop": "Drag & Drop",

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

@ -108,7 +108,8 @@
--chat-line-lh: 20px;
--chat-chip: 14px;
--chat-chip-lh: 18px;
--chat-chip-pad: 2px;
--chat-chip-pad: 1px;
--chat-chip-mono: 14px;
--chat-meta: 12px;
--chat-meta-lh: 16px;
--chat-caption: 12px;
@ -203,9 +204,10 @@
--chat-text-lh: 20px;
--chat-head: 14px;
--chat-head-lh: 20px;
--chat-chip: 13px;
--chat-chip-lh: 16px;
--chat-chip-pad: 1px;
--chat-chip: 14px;
--chat-chip-lh: 18px;
--chat-chip-pad: 0px;
--chat-chip-mono: 13px;
--chat-code-lh: 18px;
--chat-title: 20px;
--chat-title-lh: 28px;
@ -256,9 +258,10 @@
--chat-text-lh: 20px;
--chat-head: 14px;
--chat-head-lh: 20px;
--chat-chip: 13px;
--chat-chip-lh: 16px;
--chat-chip-pad: 1px;
--chat-chip: 14px;
--chat-chip-lh: 18px;
--chat-chip-pad: 0px;
--chat-chip-mono: 13px;
--chat-code-lh: 18px;
--chat-title: 20px;
--chat-title-lh: 28px;
@ -380,6 +383,14 @@
background: var(--tb-caution);
}
&.nodata::before {
width: 8px;
height: 8px;
box-sizing: border-box;
border-radius: 50%;
border: 2px solid var(--tb-caution);
}
&.error::before {
width: 6px;
height: 6px;
@ -517,6 +528,25 @@
translate: -12px 30px;
}
@mixin tb-ai-kbd {
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
min-width: 20px;
height: 20px;
padding: 0 5px;
border: 1px solid var(--tb-line);
border-bottom-width: 2px;
border-radius: 5px;
background: var(--chat-key);
color: var(--tb-ink-76);
font: 500 11px/1 var(--tb-font);
letter-spacing: .2px;
white-space: nowrap;
flex: none;
}
.tb-popover.tb-ai-tip {
.tb-popover-inner {
border-radius: 8px;
@ -604,16 +634,12 @@
}
kbd {
min-width: 16px;
height: 17px;
box-sizing: border-box;
padding: 0 4px;
@include tb-ai-kbd;
min-width: 18px;
height: 18px;
border: 0;
border-radius: 4px;
background: rgba(255, 255, 255, 0.14);
color: var(--ai-on-action);
font: 500 10.5px/17px var(--tb-font);
text-align: center;
color: #fff;
}
&.tip-keys {
@ -937,6 +963,7 @@
}
.tb-rec.card {
position: relative;
display: block;
margin-top: 14px;
padding: 10px 12px 12px;
@ -1047,16 +1074,69 @@
a.tb-rec-title {
border-bottom: 0;
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
text-decoration-color: transparent;
transition: text-decoration-color .15s ease;
text-decoration: none;
&:hover, &:focus-visible {
border-bottom: 0;
color: var(--tb-ink);
text-decoration-color: var(--tb-ink-54);
text-decoration: none;
}
&::after {
content: '';
position: absolute;
inset: 0;
border-radius: 11px;
}
&:focus-visible {
outline: none;
}
&:focus-visible::after {
outline: 2px solid var(--tb-primary-300);
outline-offset: 2px;
}
}
&.with-details > .tb-rec-row {
position: relative;
}
&.with-details a.tb-rec-title {
&::after {
inset: -8px -10px;
border-radius: 9px;
}
&:focus-visible::after {
outline-offset: 0;
}
}
:is(.tb-open, .tb-open-btn, .tb-rec-act, .tb-state.hub) {
position: relative;
z-index: 1;
}
&:has(a.tb-rec-title:hover) .tb-open {
background: rgba(0, 0, 0, 0.06);
color: var(--tb-ink);
}
&:has(a.tb-rec-title:hover) .tb-open-btn {
background: var(--ai-action-hover);
}
.tb-rec-side .tb-open-btn.icon.mat-mdc-unelevated-button {
width: 36px;
min-width: 36px;
padding: 0;
justify-content: center;
overflow: visible;
> .mat-icon.mat-icon {
margin: 0;
}
}
@ -1079,7 +1159,7 @@
margin: 0 0 0 12px;
}
&.tight.primary {
&.tight.primary:not(.open-icon) {
.tb-rec-row {
align-items: start;
}
@ -1524,19 +1604,6 @@ body.tb-ai-resizing {
text-decoration: none;
border-bottom: 0;
> code {
cursor: pointer;
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
text-decoration-color: color-mix(in srgb, currentColor 28%, transparent);
transition: text-decoration-color .12s ease;
}
&:hover > code, &:focus-visible > code {
text-decoration-color: currentColor;
}
&:focus-visible {
outline: 2px solid var(--ai-focus);
outline-offset: 1px;
@ -1548,9 +1615,10 @@ code.k-ent {
display: inline-block;
max-width: 100%;
box-sizing: border-box;
padding: var(--chat-chip-pad, 2px) 7px;
padding: var(--chat-chip-pad, 1px) 7px;
border-radius: 5px;
background: rgba(0, 0, 0, 0.05);
background: var(--tb-surface);
box-shadow: inset 0 0 0 1px var(--tb-line);
font: 400 var(--chat-chip, 14px)/var(--chat-chip-lh, 18px) var(--tb-font);
color: var(--tb-ink);
white-space: nowrap;
@ -2771,6 +2839,10 @@ a.tb-chiplink > code {
position: relative;
top: 0;
cursor: pointer;
transition: box-shadow .12s ease;
}
a.tb-chiplink > code:not(.k-ent) {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
@ -2778,6 +2850,32 @@ a.tb-chiplink > code {
transition: text-decoration-color .12s ease;
}
a.tb-chiplink > code.k-ent {
padding-right: 2px;
}
code.k-ent > .tb-chip-go {
display: inline-block;
font-size: 14px;
width: 11px;
height: 14px;
line-height: 14px;
margin-left: 2px;
overflow: hidden;
text-indent: -1.5px;
vertical-align: -2px;
color: var(--tb-ink-38);
transition: color .12s ease;
}
a.tb-chiplink:hover > code.k-ent, a.tb-chiplink:focus-visible > code.k-ent {
box-shadow: inset 0 0 0 1px var(--tb-ink-38);
}
a.tb-chiplink:hover .tb-chip-go, a.tb-chiplink:focus-visible .tb-chip-go {
color: var(--ai-link);
}
a.tb-chiplink:hover > code, a.tb-chiplink:focus-visible > code {
text-decoration-color: currentColor;
}
@ -3932,95 +4030,37 @@ cursor: pointer;
.k-docs {
display: grid;
gap: 8px;
gap: 10px;
}
.k-doc {
display: grid;
grid-template-columns: 40px minmax(0, 1fr);
gap: 14px;
align-items: start;
max-width: 600px;
padding: 14px 16px;
box-sizing: border-box;
border: 1px solid var(--k-stroke);
border-bottom-color: rgba(0, 0, 0, 0.12);
border-radius: 12px;
background: var(--tb-surface);
font-family: var(--tb-font);
font-size: 14px;
line-height: 20px;
letter-spacing: .25px;
color: var(--tb-ink);
.tb-rec.card.source {
max-width: 560px;
margin: 0;
&.ext .k-doc-tile {
background: rgba(0, 0, 0, 0.05);
color: var(--tb-ink-60);
.tb-rec-tile {
background: var(--ai-teal-50);
color: var(--ai-teal-500);
}
q {
display: block;
margin: 6px 0 0;
padding: 0;
border: 0;
font-size: 14px;
line-height: 20px;
color: var(--tb-ink-76);
quotes: '“' '”';
&.ext .tb-rec-tile {
background: rgba(0, 0, 0, 0.05);
color: var(--tb-ink-60);
}
}
.k-doc-tile {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 10px;
background: var(--ai-teal-50);
color: var(--ai-teal-500);
}
.k-doc-t {
min-width: 0;
}
.k-doc a.k-doc-title {
display: inline;
border: 0;
font-size: 15px;
line-height: 21px;
font-weight: 500;
color: var(--tb-ink);
text-decoration: underline;
text-decoration-color: rgba(0, 0, 0, 0.18);
text-underline-offset: 3px;
&:hover {
text-decoration-color: var(--ai-teal-300);
.tb-open {
pointer-events: none;
}
.k-ext {
width: 14px;
height: 14px;
margin-left: 4px;
font-size: 14px;
line-height: 14px;
vertical-align: -1px;
color: var(--tb-ink-54);
.tb-rec-det > q.tb-rec-note {
display: block;
font-size: 13.5px;
line-height: 19px;
quotes: '\201C' '\201D';
}
}
.k-doc-from {
display: block;
margin-top: 1px;
font-size: 12.5px;
line-height: 17px;
color: var(--k-grey);
}
.agent-docs {
margin-top: 10px;
margin-top: 12px;
}
.ai .agent .agent-body .tb-markdown-view [class*="tb-markdown-view-"] .k-hint.agent-hint {
@ -4051,17 +4091,12 @@ cursor: pointer;
color: var(--k-faint);
kbd {
display: inline-block;
@include tb-ai-kbd;
margin-left: 10px;
padding: 0 6px;
border: 1px solid var(--tb-line);
border-bottom-width: 2px;
border-radius: 4px;
background: var(--chat-key);
font-family: var(--tb-mono);
font-size: 11px;
line-height: 16px;
color: var(--tb-ink-54);
background: none;
color: inherit;
font-weight: 400;
vertical-align: 1px;
}
}
@ -4574,12 +4609,12 @@ cursor: pointer;
vertical-align: baseline;
code.k-tel-key.k-tel-key {
padding: var(--chat-chip-pad, 2px) 7px;
padding: var(--chat-chip-pad, 1px) 7px;
border: 0;
border-radius: 5px;
background: rgba(0, 0, 0, 0.06);
font-family: var(--tb-mono);
font-size: var(--chat-chip, 14px);
font-size: var(--chat-chip-mono, 14px);
line-height: var(--chat-chip-lh);
color: var(--tb-ink);
}
@ -4590,7 +4625,7 @@ cursor: pointer;
gap: 5px;
padding: 1px 4px;
border-radius: 5px;
font-size: var(--chat-chip, 14px);
font-size: var(--chat-chip-mono, 14px);
line-height: var(--chat-chip-lh);
font-weight: 600;
font-variant-numeric: tabular-nums;
@ -5861,19 +5896,8 @@ tb-ai-action-detail.k-detail {
}
kbd {
min-width: 24px;
height: 24px;
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 7px;
border: 1px solid var(--tb-line);
border-bottom-width: 2px;
border-radius: 6px;
background: var(--tb-surface);
color: var(--tb-ink-76);
font: 500 var(--chat-meta)/1 var(--tb-font);
@include tb-ai-kbd;
vertical-align: 0;
}
@media (max-width: 599px) {
@ -6209,7 +6233,7 @@ tb-ai-record-card {
display: none;
}
&.primary .tb-open-btn {
&.primary:not(.open-icon) .tb-open-btn {
flex: 1 1 auto;
width: auto;
}
@ -6242,6 +6266,140 @@ tb-ai-action-detail.k-detail .k-detail-recs:is(.k-detail-hub, .k-detail-list) {
}
}
@container k-col (max-width: 480px) {
.tb-rec.card {
padding: 8px 10px 10px;
.tb-rec-row {
align-items: start;
}
.tb-rec-tile {
width: 36px;
height: 36px;
border-radius: 9px;
.mat-icon {
font-size: 20px;
width: 20px;
height: 20px;
line-height: 20px;
}
}
.tb-rec-det {
margin: 8px -10px -10px;
padding: 8px 10px 10px;
}
.tb-rec-meta {
white-space: normal;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
&.primary:not(.open-icon) {
.tb-rec-side {
grid-column: 2 / -1;
grid-row: 2;
margin: 10px 0 0;
justify-self: stretch;
}
.tb-open-btn {
width: 100%;
justify-content: center;
}
}
&:is(:not(.primary), .open-icon) {
.tb-rec-row {
grid-template-columns: auto minmax(0, 1fr) auto;
}
.tb-rec-side {
display: contents;
}
:is(.tb-open, .tb-open-btn) {
grid-column: 3;
grid-row: 1;
}
.tb-open {
margin: -4px -4px 0 4px;
}
.tb-state {
grid-column: 2 / -1;
grid-row: 2;
justify-self: start;
margin-top: 6px;
}
}
&.open-icon .tb-open-btn {
margin-left: 8px;
}
}
.tb-list-body > .tb-rec.line {
padding: 3px 0;
min-height: 30px;
}
.tb-rec.line {
width: auto;
display: grid;
grid-template-columns: 24px minmax(0, 1fr) auto;
column-gap: 8px;
align-items: center;
.tb-rec-tile {
grid-row: 1;
align-self: center;
}
.tb-rec-name {
grid-column: 2;
grid-row: 1;
}
.tb-rec-meta {
grid-column: 2 / -1;
grid-row: 2;
min-width: 0;
}
> .tb-state {
grid-column: 3;
grid-row: 1;
}
}
.tb-rec.line:not(:is(.tb-list-body, .tb-rec-det, .tb-disc, .k-review, .k-hand, .k-detail-recs) .tb-rec) {
grid-template-columns: 20px minmax(0, 1fr) auto;
row-gap: 0;
align-items: start;
padding: 6px 10px 6px 8px;
.tb-rec-tile {
align-self: start;
width: 20px;
height: 20px;
background: none;
.mat-icon {
font-size: 18px;
width: 18px;
height: 18px;
line-height: 18px;
}
}
}
}
.tb-list-body {
> .tb-rec.line {
width: fit-content;
@ -6408,3 +6566,331 @@ tb-ai-action-detail.k-detail .tb-codeblock pre.tb-code {
0%, 100% { opacity: .7; }
50% { opacity: .25; }
}
.k-hand {
position: relative;
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: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 18px rgba(16, 24, 40, 0.06);
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;
min-height: 24px;
font-size: var(--chat-head);
line-height: var(--chat-head-lh);
font-weight: 500;
white-space: nowrap;
color: var(--tb-caution-text);
> .mat-icon {
font-size: var(--chat-icon);
width: var(--chat-icon);
height: var(--chat-icon);
line-height: var(--chat-icon);
}
.k-sub {
flex: 1;
min-width: 0;
white-space: normal;
font-weight: 400;
color: var(--tb-ink-76);
}
.k-hand-close {
flex: none;
margin: -6px -8px -6px 0;
color: var(--tb-ink-54);
}
}
> .k-body {
margin-top: 10px;
> * + * {
margin-top: 12px;
}
p {
margin: 0;
}
.tb-markdown-view {
p {
padding: 0;
}
p + p {
margin-top: 8px;
}
}
> .k-wait:last-child, > .k-quiet:last-child {
margin: 14px calc(-1 * var(--chat-card-pad)) 0;
padding: 12px var(--chat-card-pad) 0;
border-top: 1px solid var(--k-stroke);
}
}
&.folded {
padding-top: 8px;
padding-bottom: 8px;
box-shadow: none;
}
.k-hand-fold {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
padding: 0;
border: 0;
background: none;
font: inherit;
color: var(--tb-ink-76);
text-align: left;
cursor: pointer;
> .mat-icon:first-child {
color: var(--ai-teal-500, var(--tb-primary-500));
}
> span {
flex: 1;
min-width: 0;
}
.k-hand-fold-tg {
color: var(--tb-ink-54);
}
}
.k-steps {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 10px;
> li {
min-width: 0;
}
li label {
display: grid;
grid-template-columns: 16px minmax(0, 1fr);
column-gap: 12px;
row-gap: 1px;
align-items: start;
cursor: pointer;
}
input {
width: 16px;
height: 16px;
margin: 2px 0 0;
accent-color: var(--ai-deep);
}
.k-step-t {
font-weight: 500;
color: var(--tb-ink);
}
.k-step-d {
grid-column: 2;
font-size: var(--chat-meta);
line-height: var(--chat-meta-lh);
color: var(--tb-ink-76);
}
li.done .k-step-t {
font-weight: 400;
color: var(--tb-text-secondary);
text-decoration: line-through;
text-decoration-color: var(--tb-ink-38);
}
.k-step-x {
margin: 8px 0 2px 28px;
min-width: 0;
> * + * {
margin-top: 6px;
}
}
}
.k-value {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
padding: 2px 4px 2px 10px;
border: 1px solid var(--k-stroke);
border-radius: 8px;
background: color-mix(in srgb, var(--tb-ink) 3%, transparent);
.k-value-ic {
flex: none;
color: var(--tb-ink-54);
}
.k-value-l {
flex: none;
font-size: var(--chat-meta);
color: var(--tb-ink-76);
}
.k-value-v {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-family: var(--tb-mono);
font-size: 13px;
background: none;
color: var(--tb-ink);
}
.k-value-b.mat-mdc-icon-button {
--mdc-icon-button-state-layer-size: 32px;
--mat-icon-button-state-layer-size: 32px;
width: 32px;
height: 32px;
padding: 0;
flex: none;
color: var(--tb-ink-54);
display: inline-flex;
align-items: center;
justify-content: center;
}
}
.k-choice-panel {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 10px;
}
.k-choice {
display: grid;
grid-template-columns: 24px auto minmax(0, 1fr);
align-items: center;
gap: 10px;
.k-qi {
display: inline-flex;
color: var(--tb-ink-54);
}
.k-qt {
color: var(--tb-ink);
}
}
.k-seg {
display: inline-flex;
flex-wrap: wrap;
justify-self: start;
border: 1px solid var(--k-stroke);
border-radius: 8px;
overflow: hidden;
button {
display: inline-flex;
align-items: center;
gap: 6px;
height: 32px;
padding: 0 12px;
border: 0;
border-left: 1px solid var(--k-stroke);
background: var(--tb-surface);
font: 500 13px/20px var(--tb-font);
color: var(--tb-ink);
cursor: pointer;
&:first-child {
border-left: 0;
}
.mat-icon {
color: var(--tb-ink-54);
}
&[aria-pressed="true"] {
background: var(--ai-deep);
color: #fff;
.mat-icon {
color: inherit;
}
}
}
}
.k-choice-body {
padding-left: 34px;
color: var(--tb-ink-76);
}
.k-wait {
display: flex;
align-items: center;
gap: 8px;
font-family: var(--tb-mono);
font-size: 13.5px;
color: var(--tb-text-secondary);
tb-ai-spin {
--spin: 18px;
flex: none;
}
.clock {
margin-left: auto;
color: var(--tb-ink-54);
font-variant-numeric: tabular-nums;
}
&.warn {
color: var(--tb-caution-text);
}
}
.k-quiet {
display: grid;
gap: 8px;
}
}
@media (max-width: 599px) {
.k-hand {
> .k-head {
flex-wrap: wrap;
.k-sub {
flex-basis: 100%;
margin-left: 26px;
}
}
.k-choice {
grid-template-columns: 24px minmax(0, 1fr);
.k-seg {
grid-column: 2;
}
}
}
}

Loading…
Cancel
Save