blob: 76ef0b85bf0f7074aade507e50c5bd9c29d3bec9 [file] [log] [blame]
Philip Zeyliger99a9a022025-04-27 15:15:25 +00001import { css, html, LitElement } from "lit";
2import { customElement, property } from "lit/decorators.js";
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -07003import { unsafeHTML } from "lit/directives/unsafe-html.js";
Philip Zeyliger99a9a022025-04-27 15:15:25 +00004
5@customElement("sketch-call-status")
6export class SketchCallStatus extends LitElement {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -07007 @property()
Philip Zeyliger99a9a022025-04-27 15:15:25 +00008 llmCalls: number = 0;
9
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070010 @property()
Philip Zeyliger99a9a022025-04-27 15:15:25 +000011 toolCalls: string[] = [];
12
Sean McCulloughd9d45812025-04-30 16:53:41 -070013 @property()
14 agentState: string | null = null;
15
Philip Zeyliger99a9a022025-04-27 15:15:25 +000016 static styles = css`
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000017 @keyframes gentle-pulse {
18 0% {
19 transform: scale(1);
20 opacity: 1;
21 }
22 50% {
23 transform: scale(1.15);
24 opacity: 0.8;
25 }
26 100% {
27 transform: scale(1);
28 opacity: 1;
29 }
30 }
31
Philip Zeyliger99a9a022025-04-27 15:15:25 +000032 .call-status-container {
33 display: flex;
34 align-items: center;
35 gap: 10px;
36 padding: 0 10px;
37 }
38
39 .indicator {
40 display: flex;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070041 justify-content: center;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000042 align-items: center;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070043 width: 32px;
44 height: 32px;
45 border-radius: 4px;
46 transition: all 0.2s ease;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000047 position: relative;
48 }
49
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070050 /* LLM indicator (lightbulb) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000051 .llm-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070052 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000053 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000054 }
55
56 .llm-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000057 background-color: #fef3c7; /* Light yellow */
58 color: #f59e0b; /* Yellow/amber when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000059 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000060 }
61
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070062 /* Tool indicator (wrench) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000063 .tool-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070064 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000065 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000066 }
67
68 .tool-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000069 background-color: #dbeafe; /* Light blue */
70 color: #3b82f6; /* Blue when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000071 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000072 }
73
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070074 svg {
75 width: 20px;
76 height: 20px;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000077 }
78 `;
79
Philip Zeyliger99a9a022025-04-27 15:15:25 +000080 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070081 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">
82 <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>
83 <path d="M9 18h6"></path>
84 <path d="M10 22h4"></path>
85 </svg>`;
86
87 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">
88 <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>
89 </svg>`;
90
Sean McCulloughd9d45812025-04-30 16:53:41 -070091 const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`;
92
Philip Zeyliger99a9a022025-04-27 15:15:25 +000093 return html`
94 <div class="call-status-container">
95 <div
96 class="indicator llm-indicator ${this.llmCalls > 0 ? "active" : ""}"
97 title="${this.llmCalls > 0
98 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
Sean McCulloughd9d45812025-04-30 16:53:41 -070099 : "No LLM calls in progress"}${agentState}"
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000100 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700101 ${unsafeHTML(lightbulbSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000102 </div>
103 <div
104 class="indicator tool-indicator ${this.toolCalls.length > 0
105 ? "active"
106 : ""}"
107 title="${this.toolCalls.length > 0
108 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
Sean McCulloughd9d45812025-04-30 16:53:41 -0700109 : "No tool calls in progress"}${agentState}"
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000110 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700111 ${unsafeHTML(wrenchSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000112 </div>
113 </div>
114 `;
115 }
116}
117
118declare global {
119 interface HTMLElementTagNameMap {
120 "sketch-call-status": SketchCallStatus;
121 }
122}