| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 1 | import { css, html, LitElement } from "lit"; |
| 2 | import { customElement, property } from "lit/decorators.js"; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 3 | import { unsafeHTML } from "lit/directives/unsafe-html.js"; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 4 | |
| 5 | @customElement("sketch-call-status") |
| 6 | export class SketchCallStatus extends LitElement { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 7 | @property() |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 8 | llmCalls: number = 0; |
| 9 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 10 | @property() |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 11 | 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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 23 | justify-content: center; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 24 | align-items: center; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 25 | width: 32px; |
| 26 | height: 32px; |
| 27 | border-radius: 4px; |
| 28 | transition: all 0.2s ease; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 29 | position: relative; |
| 30 | } |
| 31 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 32 | /* LLM indicator (lightbulb) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 33 | .llm-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 34 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 35 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | .llm-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 39 | background-color: #fef3c7; /* Light yellow */ |
| 40 | color: #f59e0b; /* Yellow/amber when active */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 43 | /* Tool indicator (wrench) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 44 | .tool-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 45 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 46 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | .tool-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 50 | background-color: #dbeafe; /* Light blue */ |
| 51 | color: #3b82f6; /* Blue when active */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 54 | svg { |
| 55 | width: 20px; |
| 56 | height: 20px; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 57 | } |
| 58 | `; |
| 59 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 60 | render() { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 61 | 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 71 | 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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 79 | ${unsafeHTML(lightbulbSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 80 | </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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 89 | ${unsafeHTML(wrenchSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 90 | </div> |
| 91 | </div> |
| 92 | `; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | declare global { |
| 97 | interface HTMLElementTagNameMap { |
| 98 | "sketch-call-status": SketchCallStatus; |
| 99 | } |
| 100 | } |