| 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` |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 14 | @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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 29 | .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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 38 | justify-content: center; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 39 | align-items: center; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 40 | width: 32px; |
| 41 | height: 32px; |
| 42 | border-radius: 4px; |
| 43 | transition: all 0.2s ease; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 44 | position: relative; |
| 45 | } |
| 46 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 47 | /* LLM indicator (lightbulb) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 48 | .llm-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 49 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 50 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | .llm-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 54 | background-color: #fef3c7; /* Light yellow */ |
| 55 | color: #f59e0b; /* Yellow/amber when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 56 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 59 | /* Tool indicator (wrench) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 60 | .tool-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 61 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 62 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | .tool-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 66 | background-color: #dbeafe; /* Light blue */ |
| 67 | color: #3b82f6; /* Blue when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 68 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 71 | svg { |
| 72 | width: 20px; |
| 73 | height: 20px; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 74 | } |
| 75 | `; |
| 76 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 77 | render() { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 78 | 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 88 | 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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 96 | ${unsafeHTML(lightbulbSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 97 | </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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 106 | ${unsafeHTML(wrenchSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 107 | </div> |
| 108 | </div> |
| 109 | `; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | declare global { |
| 114 | interface HTMLElementTagNameMap { |
| 115 | "sketch-call-status": SketchCallStatus; |
| 116 | } |
| 117 | } |