| 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; |
| 37 | align-items: center; |
| 38 | gap: 10px; |
| 39 | padding: 0 10px; |
| 40 | } |
| 41 | |
| 42 | .indicator { |
| 43 | display: flex; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 44 | justify-content: center; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 45 | align-items: center; |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 46 | width: 32px; |
| 47 | height: 32px; |
| 48 | border-radius: 4px; |
| 49 | transition: all 0.2s ease; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 50 | position: relative; |
| 51 | } |
| 52 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 53 | /* LLM indicator (lightbulb) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 54 | .llm-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 55 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 56 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | .llm-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 60 | background-color: #fef3c7; /* Light yellow */ |
| 61 | color: #f59e0b; /* Yellow/amber when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 62 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 65 | /* Tool indicator (wrench) */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 66 | .tool-indicator { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 67 | background-color: transparent; |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 68 | color: #9ca3af; /* Gray when inactive */ |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | .tool-indicator.active { |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 72 | background-color: #dbeafe; /* Light blue */ |
| 73 | color: #3b82f6; /* Blue when active */ |
| Josh Bleecher Snyder | e81233f | 2025-04-30 04:05:41 +0000 | [diff] [blame] | 74 | animation: gentle-pulse 1.5s infinite ease-in-out; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 77 | svg { |
| 78 | width: 20px; |
| 79 | height: 20px; |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 80 | } |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 81 | |
| 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 103 | `; |
| 104 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 105 | render() { |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 106 | 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 McCullough | d9d4581 | 2025-04-30 16:53:41 -0700 | [diff] [blame] | 116 | const agentState = `${this.agentState ? " (" + this.agentState + ")" : ""}`; |
| 117 | |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 118 | // Determine working state - working if not idle |
| 119 | const isWorking = !this.isIdle; |
| 120 | |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 121 | 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 McCullough | d9d4581 | 2025-04-30 16:53:41 -0700 | [diff] [blame] | 127 | : "No LLM calls in progress"}${agentState}" |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 128 | > |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 129 | ${unsafeHTML(lightbulbSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 130 | </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 McCullough | d9d4581 | 2025-04-30 16:53:41 -0700 | [diff] [blame] | 137 | : "No tool calls in progress"}${agentState}" |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 138 | > |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 139 | ${unsafeHTML(wrenchSVG)} |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 140 | </div> |
| Philip Zeyliger | 7231839 | 2025-05-14 02:56:07 +0000 | [diff] [blame] | 141 | <div |
| 142 | class="status-banner ${isWorking ? "status-working" : "status-idle"}" |
| 143 | > |
| 144 | ${isWorking ? "WORKING" : "IDLE"} |
| 145 | </div> |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 146 | </div> |
| 147 | `; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | declare global { |
| 152 | interface HTMLElementTagNameMap { |
| 153 | "sketch-call-status": SketchCallStatus; |
| 154 | } |
| 155 | } |