blob: 23144e14ddbb372f13bc3cc5135ad8d3882c1f3b [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`
14 .call-status-container {
15 display: flex;
16 align-items: center;
17 gap: 10px;
18 padding: 0 10px;
19 }
20
21 .indicator {
22 display: flex;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070023 justify-content: center;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000024 align-items: center;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070025 width: 32px;
26 height: 32px;
27 border-radius: 4px;
28 transition: all 0.2s ease;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000029 position: relative;
30 }
31
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070032 /* LLM indicator (lightbulb) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000033 .llm-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070034 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000035 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000036 }
37
38 .llm-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000039 background-color: #fef3c7; /* Light yellow */
40 color: #f59e0b; /* Yellow/amber when active */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000041 }
42
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070043 /* Tool indicator (wrench) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000044 .tool-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070045 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000046 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000047 }
48
49 .tool-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000050 background-color: #dbeafe; /* Light blue */
51 color: #3b82f6; /* Blue when active */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000052 }
53
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070054 svg {
55 width: 20px;
56 height: 20px;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000057 }
58 `;
59
Philip Zeyliger99a9a022025-04-27 15:15:25 +000060 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070061 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">
62 <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>
63 <path d="M9 18h6"></path>
64 <path d="M10 22h4"></path>
65 </svg>`;
66
67 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">
68 <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>
69 </svg>`;
70
Philip Zeyliger99a9a022025-04-27 15:15:25 +000071 return html`
72 <div class="call-status-container">
73 <div
74 class="indicator llm-indicator ${this.llmCalls > 0 ? "active" : ""}"
75 title="${this.llmCalls > 0
76 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
77 : "No LLM calls in progress"}"
78 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070079 ${unsafeHTML(lightbulbSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +000080 </div>
81 <div
82 class="indicator tool-indicator ${this.toolCalls.length > 0
83 ? "active"
84 : ""}"
85 title="${this.toolCalls.length > 0
86 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
87 : "No tool calls in progress"}"
88 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070089 ${unsafeHTML(wrenchSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +000090 </div>
91 </div>
92 `;
93 }
94}
95
96declare global {
97 interface HTMLElementTagNameMap {
98 "sketch-call-status": SketchCallStatus;
99 }
100}