| 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 | |
| Sean McCullough | d9d4581 | 2025-04-30 16:53:41 -0700 | [diff] [blame] | 13 | @property() |
| 14 | agentState: string | null = null; |
| 15 | |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 16 | @property() |
| 17 | isIdle: boolean = false; |
| 18 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 19 | static styles = css` |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 20 | @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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 35 | .call-status-container { |
| 36 | display: flex; |
| Philip Zeyliger | bd7b625 | 2025-05-15 16:21:36 +0000 | [diff] [blame] | 37 | position: relative; |
| 38 | align-items: center; |
| 39 | padding: 0 10px; |
| 40 | } |
| 41 | |
| 42 | .indicators-container { |
| 43 | display: flex; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 44 | align-items: center; |
| 45 | gap: 10px; |
| Philip Zeyliger | bd7b625 | 2025-05-15 16:21:36 +0000 | [diff] [blame] | 46 | position: relative; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | .indicator { |
| 50 | display: flex; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 51 | justify-content: center; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 52 | align-items: center; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 53 | width: 32px; |
| 54 | height: 32px; |
| 55 | border-radius: 4px; |
| 56 | transition: all 0.2s ease; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 57 | position: relative; |
| 58 | } |
| 59 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 60 | /* LLM indicator (lightbulb) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 61 | .llm-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 62 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 63 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | .llm-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 67 | background-color: #fef3c7; /* Light yellow */ |
| 68 | color: #f59e0b; /* Yellow/amber when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 69 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 72 | /* Tool indicator (wrench) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 73 | .tool-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 74 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 75 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | .tool-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 79 | background-color: #dbeafe; /* Light blue */ |
| 80 | color: #3b82f6; /* Blue when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 81 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 84 | svg { |
| 85 | width: 20px; |
| 86 | height: 20px; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 87 | } |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 88 | |
| 89 | .status-banner { |
| Philip Zeyliger | bd7b625 | 2025-05-15 16:21:36 +0000 | [diff] [blame] | 90 | position: absolute; |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 91 | 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 Zeyliger | bd7b625 | 2025-05-15 16:21:36 +0000 | [diff] [blame] | 97 | 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 Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 103 | } |
| 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 114 | `; |
| 115 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 116 | render() { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 117 | 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 McCullough | d9d4581 | 2025-04-30 16:53:41 -0700 | [diff] [blame] | 127 | const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`; |
| 128 | |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 129 | // Determine working state - working if not idle |
| 130 | const isWorking = !this.isIdle; |
| 131 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 132 | return html` |
| 133 | <div class="call-status-container"> |
| Philip Zeyliger | bd7b625 | 2025-05-15 16:21:36 +0000 | [diff] [blame] | 134 | <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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 153 | </div> |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 154 | <div |
| 155 | class="status-banner ${isWorking ? "status-working" : "status-idle"}" |
| 156 | > |
| 157 | ${isWorking ? "WORKING" : "IDLE"} |
| 158 | </div> |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 159 | </div> |
| 160 | `; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | declare global { |
| 165 | interface HTMLElementTagNameMap { |
| 166 | "sketch-call-status": SketchCallStatus; |
| 167 | } |
| 168 | } |