blob: a390093832db67323fbe2b926950733962f340f9 [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 Zeyliger72318392025-05-14 02:56:07 +000016 @property()
17 isIdle: boolean = false;
18
Philip Zeyliger99a9a022025-04-27 15:15:25 +000019 static styles = css`
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000020 @keyframes gentle-pulse {
21 0% {
22 transform: scale(1);
23 opacity: 1;
24 }
25 50% {
26 transform: scale(1.15);
27 opacity: 0.8;
28 }
29 100% {
30 transform: scale(1);
31 opacity: 1;
32 }
33 }
34
Philip Zeyliger99a9a022025-04-27 15:15:25 +000035 .call-status-container {
36 display: flex;
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000037 position: relative;
38 align-items: center;
39 padding: 0 10px;
40 }
41
42 .indicators-container {
43 display: flex;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000044 align-items: center;
45 gap: 10px;
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000046 position: relative;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000047 }
48
49 .indicator {
50 display: flex;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070051 justify-content: center;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000052 align-items: center;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070053 width: 32px;
54 height: 32px;
55 border-radius: 4px;
56 transition: all 0.2s ease;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000057 position: relative;
58 }
59
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070060 /* LLM indicator (lightbulb) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000061 .llm-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070062 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000063 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000064 }
65
66 .llm-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000067 background-color: #fef3c7; /* Light yellow */
68 color: #f59e0b; /* Yellow/amber when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000069 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000070 }
71
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070072 /* Tool indicator (wrench) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000073 .tool-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070074 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000075 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000076 }
77
78 .tool-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000079 background-color: #dbeafe; /* Light blue */
80 color: #3b82f6; /* Blue when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000081 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000082 }
83
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070084 svg {
85 width: 20px;
86 height: 20px;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000087 }
Philip Zeyliger72318392025-05-14 02:56:07 +000088
89 .status-banner {
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000090 position: absolute;
Philip Zeyliger72318392025-05-14 02:56:07 +000091 padding: 2px 5px;
92 border-radius: 3px;
93 font-size: 10px;
94 font-weight: bold;
95 text-align: center;
96 letter-spacing: 0.5px;
Philip Zeyligerbd7b6252025-05-15 16:21:36 +000097 width: 64px; /* Fixed width for the banner */
98 left: 50%;
99 transform: translateX(-50%);
100 top: 60%; /* Position a little below center */
101 z-index: 10; /* Ensure it appears above the icons */
102 opacity: 0.6;
Philip Zeyliger72318392025-05-14 02:56:07 +0000103 }
104
105 .status-working {
106 background-color: #ffeecc;
107 color: #e65100;
108 }
109
110 .status-idle {
111 background-color: #e6f4ea;
112 color: #0d652d;
113 }
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000114 `;
115
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000116 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700117 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">
118 <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>
119 <path d="M9 18h6"></path>
120 <path d="M10 22h4"></path>
121 </svg>`;
122
123 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">
124 <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>
125 </svg>`;
126
Sean McCulloughd9d45812025-04-30 16:53:41 -0700127 const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`;
128
Philip Zeyliger72318392025-05-14 02:56:07 +0000129 // Determine working state - working if not idle
130 const isWorking = !this.isIdle;
131
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000132 return html`
133 <div class="call-status-container">
Philip Zeyligerbd7b6252025-05-15 16:21:36 +0000134 <div class="indicators-container">
135 <div
136 class="indicator llm-indicator ${this.llmCalls > 0 ? "active" : ""}"
137 title="${this.llmCalls > 0
138 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
139 : "No LLM calls in progress"}${agentState}"
140 >
141 ${unsafeHTML(lightbulbSVG)}
142 </div>
143 <div
144 class="indicator tool-indicator ${this.toolCalls.length > 0
145 ? "active"
146 : ""}"
147 title="${this.toolCalls.length > 0
148 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
149 : "No tool calls in progress"}${agentState}"
150 >
151 ${unsafeHTML(wrenchSVG)}
152 </div>
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000153 </div>
Philip Zeyliger72318392025-05-14 02:56:07 +0000154 <div
155 class="status-banner ${isWorking ? "status-working" : "status-idle"}"
156 >
157 ${isWorking ? "WORKING" : "IDLE"}
158 </div>
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000159 </div>
160 `;
161 }
162}
163
164declare global {
165 interface HTMLElementTagNameMap {
166 "sketch-call-status": SketchCallStatus;
167 }
168}