blob: dbc5d57197a2e26ea845fda5a2d7c09d7c32a902 [file] [log] [blame]
banksean659b9832025-06-27 00:50:41 +00001import { html } from "lit";
Philip Zeyliger99a9a022025-04-27 15:15:25 +00002import { customElement, property } from "lit/decorators.js";
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -07003import { unsafeHTML } from "lit/directives/unsafe-html.js";
banksean659b9832025-06-27 00:50:41 +00004import { SketchTailwindElement } from "./sketch-tailwind-element.js";
Philip Zeyliger99a9a022025-04-27 15:15:25 +00005
6@customElement("sketch-call-status")
banksean659b9832025-06-27 00:50:41 +00007export class SketchCallStatus extends SketchTailwindElement {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -07008 @property()
Philip Zeyliger99a9a022025-04-27 15:15:25 +00009 llmCalls: number = 0;
10
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070011 @property()
Philip Zeyliger99a9a022025-04-27 15:15:25 +000012 toolCalls: string[] = [];
13
Sean McCulloughd9d45812025-04-30 16:53:41 -070014 @property()
15 agentState: string | null = null;
16
Philip Zeyliger72318392025-05-14 02:56:07 +000017 @property()
18 isIdle: boolean = false;
Autoformatter8c463622025-05-16 21:54:17 +000019
Philip Zeyliger5e357022025-05-16 04:50:34 +000020 @property()
21 isDisconnected: boolean = false;
Philip Zeyliger72318392025-05-14 02:56:07 +000022
Philip Zeyliger99a9a022025-04-27 15:15:25 +000023 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070024 const lightbulbSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
25 <path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"></path>
26 <path d="M9 18h6"></path>
27 <path d="M10 22h4"></path>
28 </svg>`;
29
30 const wrenchSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
31 <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path>
32 </svg>`;
33
Sean McCulloughd9d45812025-04-30 16:53:41 -070034 const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`;
35
Philip Zeyliger5e357022025-05-16 04:50:34 +000036 // Determine state - disconnected takes precedence, then working vs idle
37 let statusClass = "status-idle";
38 let statusText = "IDLE";
Autoformatter8c463622025-05-16 21:54:17 +000039
Philip Zeyliger5e357022025-05-16 04:50:34 +000040 if (this.isDisconnected) {
41 statusClass = "status-disconnected";
42 statusText = "DISCONNECTED";
43 } else if (!this.isIdle) {
44 statusClass = "status-working";
45 statusText = "WORKING";
46 }
Philip Zeyliger72318392025-05-14 02:56:07 +000047
Philip Zeyliger99a9a022025-04-27 15:15:25 +000048 return html`
banksean659b9832025-06-27 00:50:41 +000049 <style>
50 @keyframes gentle-pulse {
51 0% {
52 transform: scale(1);
53 opacity: 1;
54 }
55 50% {
56 transform: scale(1.15);
57 opacity: 0.8;
58 }
59 100% {
60 transform: scale(1);
61 opacity: 1;
62 }
63 }
64 .animate-gentle-pulse {
65 animation: gentle-pulse 1.5s infinite ease-in-out;
66 }
67 </style>
68 <div class="flex relative items-center px-2.5">
69 <div class="flex items-center gap-2.5 relative">
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000070 <div
banksean659b9832025-06-27 00:50:41 +000071 class="llm-indicator flex justify-center items-center w-8 h-8 rounded transition-all duration-200 relative ${this
72 .llmCalls > 0
banksean3eaa4332025-07-19 02:19:06 +000073 ? "bg-yellow-100 dark:bg-yellow-900 text-amber-500 dark:text-amber-400 animate-gentle-pulse active"
74 : "bg-transparent text-gray-400 dark:text-gray-500"}"
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000075 title="${this.llmCalls > 0
76 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
77 : "No LLM calls in progress"}${agentState}"
78 >
banksean659b9832025-06-27 00:50:41 +000079 <div class="w-5 h-5">${unsafeHTML(lightbulbSVG)}</div>
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000080 </div>
81 <div
banksean659b9832025-06-27 00:50:41 +000082 class="tool-indicator flex justify-center items-center w-8 h-8 rounded transition-all duration-200 relative ${this
83 .toolCalls.length > 0
banksean3eaa4332025-07-19 02:19:06 +000084 ? "bg-blue-100 dark:bg-blue-900 text-blue-500 dark:text-blue-400 animate-gentle-pulse active"
85 : "bg-transparent text-gray-400 dark:text-gray-500"}"
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000086 title="${this.toolCalls.length > 0
87 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
88 : "No tool calls in progress"}${agentState}"
89 >
banksean659b9832025-06-27 00:50:41 +000090 <div class="w-5 h-5">${unsafeHTML(wrenchSVG)}</div>
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000091 </div>
Philip Zeyliger99a9a022025-04-27 15:15:25 +000092 </div>
banksean659b9832025-06-27 00:50:41 +000093 <div
94 class="status-banner absolute py-0.5 px-1.5 rounded text-xs font-bold text-center tracking-wider w-26 left-1/2 transform -translate-x-1/2 top-3/5 z-10 opacity-90 ${statusClass} ${this
95 .isDisconnected
banksean3eaa4332025-07-19 02:19:06 +000096 ? "bg-red-50 dark:bg-red-900 text-red-600 dark:text-red-400"
banksean659b9832025-06-27 00:50:41 +000097 : !this.isIdle
banksean3eaa4332025-07-19 02:19:06 +000098 ? "bg-orange-50 dark:bg-orange-900 text-orange-600 dark:text-orange-400"
99 : "bg-green-50 dark:bg-green-900 text-green-700 dark:text-green-400"}"
Josh Bleecher Snyder7208bb42025-07-18 00:44:11 +0000100 title="${this.isDisconnected
101 ? "Connection lost or container shut down"
102 : !this.isIdle
103 ? "Agent is processing"
104 : "Agent is idle and ready for input"}"
banksean659b9832025-06-27 00:50:41 +0000105 >
106 ${statusText}
107 </div>
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000108 </div>
109 `;
110 }
111}
112
113declare global {
114 interface HTMLElementTagNameMap {
115 "sketch-call-status": SketchCallStatus;
116 }
117}