blob: f3985627be3af74ba1b014b49ead083adcbf6155 [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;
37 align-items: center;
38 gap: 10px;
39 padding: 0 10px;
40 }
41
42 .indicator {
43 display: flex;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070044 justify-content: center;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000045 align-items: center;
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070046 width: 32px;
47 height: 32px;
48 border-radius: 4px;
49 transition: all 0.2s ease;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000050 position: relative;
51 }
52
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070053 /* LLM indicator (lightbulb) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000054 .llm-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070055 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000056 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000057 }
58
59 .llm-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000060 background-color: #fef3c7; /* Light yellow */
61 color: #f59e0b; /* Yellow/amber when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000062 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000063 }
64
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070065 /* Tool indicator (wrench) */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000066 .tool-indicator {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070067 background-color: transparent;
Autoformatter570c3f82025-04-29 18:26:50 +000068 color: #9ca3af; /* Gray when inactive */
Philip Zeyliger99a9a022025-04-27 15:15:25 +000069 }
70
71 .tool-indicator.active {
Autoformatter570c3f82025-04-29 18:26:50 +000072 background-color: #dbeafe; /* Light blue */
73 color: #3b82f6; /* Blue when active */
Josh Bleecher Snydere81233f2025-04-30 04:05:41 +000074 animation: gentle-pulse 1.5s infinite ease-in-out;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000075 }
76
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070077 svg {
78 width: 20px;
79 height: 20px;
Philip Zeyliger99a9a022025-04-27 15:15:25 +000080 }
Philip Zeyliger72318392025-05-14 02:56:07 +000081
82 .status-banner {
83 margin-top: 4px;
84 padding: 2px 5px;
85 border-radius: 3px;
86 font-size: 10px;
87 font-weight: bold;
88 text-align: center;
89 letter-spacing: 0.5px;
90 width: 100%;
91 min-width: 64px; /* Ensure same width regardless of state */
92 }
93
94 .status-working {
95 background-color: #ffeecc;
96 color: #e65100;
97 }
98
99 .status-idle {
100 background-color: #e6f4ea;
101 color: #0d652d;
102 }
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000103 `;
104
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000105 render() {
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700106 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">
107 <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>
108 <path d="M9 18h6"></path>
109 <path d="M10 22h4"></path>
110 </svg>`;
111
112 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">
113 <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>
114 </svg>`;
115
Sean McCulloughd9d45812025-04-30 16:53:41 -0700116 const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`;
117
Philip Zeyliger72318392025-05-14 02:56:07 +0000118 // Determine working state - working if not idle
119 const isWorking = !this.isIdle;
120
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000121 return html`
122 <div class="call-status-container">
123 <div
124 class="indicator llm-indicator ${this.llmCalls > 0 ? "active" : ""}"
125 title="${this.llmCalls > 0
126 ? `${this.llmCalls} LLM ${this.llmCalls === 1 ? "call" : "calls"} in progress`
Sean McCulloughd9d45812025-04-30 16:53:41 -0700127 : "No LLM calls in progress"}${agentState}"
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000128 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700129 ${unsafeHTML(lightbulbSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000130 </div>
131 <div
132 class="indicator tool-indicator ${this.toolCalls.length > 0
133 ? "active"
134 : ""}"
135 title="${this.toolCalls.length > 0
136 ? `${this.toolCalls.length} tool ${this.toolCalls.length === 1 ? "call" : "calls"} in progress: ${this.toolCalls.join(", ")}`
Sean McCulloughd9d45812025-04-30 16:53:41 -0700137 : "No tool calls in progress"}${agentState}"
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000138 >
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -0700139 ${unsafeHTML(wrenchSVG)}
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000140 </div>
Philip Zeyliger72318392025-05-14 02:56:07 +0000141 <div
142 class="status-banner ${isWorking ? "status-working" : "status-idle"}"
143 >
144 ${isWorking ? "WORKING" : "IDLE"}
145 </div>
Philip Zeyliger99a9a022025-04-27 15:15:25 +0000146 </div>
147 `;
148 }
149}
150
151declare global {
152 interface HTMLElementTagNameMap {
153 "sketch-call-status": SketchCallStatus;
154 }
155}