blob: 458709cc71e1637314c193bdfecbafcc9c41f3a1 [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
13 static styles = css`
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000014 @keyframes gentle-pulse {
15 0% {
16 transform: scale(1);
17 opacity: 1;
18 }
19 50% {
20 transform: scale(1.15);
21 opacity: 0.8;
22 }
23 100% {
24 transform: scale(1);
25 opacity: 1;
26 }
27 }
28
Philip Zeyliger99a9a022025-04-27 15:15:25 +000029 .call-status-container {
30 display: flex;
31 align-items: center;
32 gap: 10px;
33 padding: 0 10px;
34 }
35
36 .indicator {
37 display: flex;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070038 justify-content: center;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000039 align-items: center;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070040 width: 32px;
41 height: 32px;
42 border-radius: 4px;
43 transition: all 0.2s ease;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000044 position: relative;
45 }
46
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070047 /* LLM indicator (lightbulb) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000048 .llm-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070049 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000050 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000051 }
52
53 .llm-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000054 background-color: #fef3c7; /* Light yellow */
55 color: #f59e0b; /* Yellow/amber when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000056 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000057 }
58
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070059 /* Tool indicator (wrench) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000060 .tool-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070061 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000062 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000063 }
64
65 .tool-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000066 background-color: #dbeafe; /* Light blue */
67 color: #3b82f6; /* Blue when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000068 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000069 }
70
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070071 svg {
72 width: 20px;
73 height: 20px;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000074 }
75 `;
76
Philip Zeyliger99a9a022025-04-27 15:15:25 +000077 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070078 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">
79 <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>
80 <path d="M9 18h6"></path>
81 <path d="M10 22h4"></path>
82 </svg>`;
83
84 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">
85 <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>
86 </svg>`;
87
Philip Zeyliger99a9a022025-04-27 15:15:25 +000088 return html`
89 <div class="call-status-container">
90 <div
91 class="indicator llm-indicator ${this.llmCalls > 0 ? "active" : ""}"
92 title="${this.llmCalls > 0
93 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
94 : "No LLM calls in progress"}"
95 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070096 ${unsafeHTML(lightbulbSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +000097 </div>
98 <div
99 class="indicator tool-indicator ${this.toolCalls.length > 0
100 ? "active"
101 : ""}"
102 title="${this.toolCalls.length > 0
103 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
104 : "No tool calls in progress"}"
105 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700106 ${unsafeHTML(wrenchSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000107 </div>
108 </div>
109 `;
110 }
111}
112
113declare global {
114 interface HTMLElementTagNameMap {
115 "sketch-call-status": SketchCallStatus;
116 }
117}