blob: 21993424238abd0d451e93e11e36e3a18eb27a13 [file] [log] [blame]
Philip Zeyliger16fa8b42025-05-02 04:28:16 +00001import { State, AgentMessage } from "../types";
Sean McCulloughb29f8912025-04-20 15:39:11 -07002import { LitElement, css, html } from "lit";
Philip Zeyligere66db3e2025-04-27 15:40:39 +00003import { customElement, property, state } from "lit/decorators.js";
Josh Bleecher Snydera0801ad2025-04-25 19:34:53 +00004import { formatNumber } from "../utils";
Sean McCullough86b56862025-04-18 13:04:03 -07005
6@customElement("sketch-container-status")
7export class SketchContainerStatus extends LitElement {
8 // Header bar: Container status details
9
10 @property()
11 state: State;
12
Philip Zeyligere66db3e2025-04-27 15:40:39 +000013 @state()
14 showDetails: boolean = false;
15
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000016 @state()
17 lastCommit: { hash: string; pushedBranch?: string } | null = null;
18
19 @state()
20 lastCommitCopied: boolean = false;
21
Sean McCullough86b56862025-04-18 13:04:03 -070022 // See https://lit.dev/docs/components/styles/ for how lit-element handles CSS.
23 // Note that these styles only apply to the scope of this web component's
24 // shadow DOM node, so they won't leak out or collide with CSS declared in
25 // other components or the containing web page (...unless you want it to do that).
26 static styles = css`
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000027 /* Last commit display styling */
28 .last-commit {
29 display: flex;
30 flex-direction: column;
31 padding: 3px 8px;
32 cursor: pointer;
33 position: relative;
34 margin: 4px 0;
35 transition: color 0.2s ease;
36 }
37
38 .last-commit:hover {
39 color: #0366d6;
40 }
41
Philip Zeyliger9bca61e2025-05-22 12:40:06 -070042 /* Pulse animation for new commits */
43 @keyframes pulse {
44 0% {
45 transform: scale(1);
46 opacity: 1;
47 }
48 50% {
49 transform: scale(1.05);
50 opacity: 0.8;
51 }
52 100% {
53 transform: scale(1);
54 opacity: 1;
55 }
56 }
57
58 .pulse {
59 animation: pulse 1.5s ease-in-out;
60 background-color: rgba(38, 132, 255, 0.1);
61 border-radius: 3px;
62 }
63
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000064 .last-commit-title {
65 color: #666;
66 font-family: system-ui, sans-serif;
67 font-size: 11px;
68 font-weight: 500;
69 line-height: 1.2;
70 }
71
72 .last-commit-hash {
73 font-family: monospace;
74 font-size: 12px;
75 white-space: nowrap;
76 overflow: hidden;
77 text-overflow: ellipsis;
78 }
79
80 /* Styles for the last commit in main grid */
81 .last-commit-column {
82 justify-content: flex-start;
83 }
84
85 .info-label {
86 color: #666;
87 font-family: system-ui, sans-serif;
88 font-size: 11px;
89 font-weight: 500;
90 }
91
92 .last-commit-main {
93 cursor: pointer;
94 position: relative;
95 padding-top: 0;
96 }
97
98 .last-commit-main:hover {
99 color: #0366d6;
100 }
101
102 .main-grid-commit {
103 font-family: monospace;
104 font-size: 12px;
105 white-space: nowrap;
106 overflow: hidden;
107 text-overflow: ellipsis;
108 }
109
110 .commit-hash-indicator {
111 color: #666;
112 }
113
114 .commit-branch-indicator {
115 color: #28a745;
116 }
117
118 .no-commit-indicator {
119 color: #999;
120 font-style: italic;
121 font-size: 12px;
122 }
123
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700124 .copied-indicator {
125 position: absolute;
126 top: 0;
127 left: 0;
128 background: rgba(0, 0, 0, 0.7);
129 color: white;
130 padding: 2px 6px;
131 border-radius: 3px;
132 font-size: 11px;
133 pointer-events: none;
134 z-index: 10;
135 }
136
137 .copy-icon {
138 margin-left: 4px;
139 opacity: 0.7;
140 }
141
142 .copy-icon svg {
143 vertical-align: middle;
144 }
145
146 .last-commit-main:hover .copy-icon {
147 opacity: 1;
148 }
149
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000150 .info-container {
151 display: flex;
152 align-items: center;
153 position: relative;
Sean McCullough86b56862025-04-18 13:04:03 -0700154 }
155
156 .info-grid {
157 display: flex;
158 flex-wrap: wrap;
159 gap: 8px;
160 background: #f9f9f9;
161 border-radius: 4px;
162 padding: 4px 10px;
163 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
164 flex: 1;
165 }
166
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000167 .info-expanded {
168 position: absolute;
169 top: 100%;
170 right: 0;
171 z-index: 10;
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000172 min-width: 400px;
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000173 background: white;
174 border-radius: 8px;
175 padding: 10px 15px;
176 box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
177 margin-top: 5px;
178 display: none;
179 }
180
181 .info-expanded.active {
182 display: block;
183 }
184
Sean McCullough86b56862025-04-18 13:04:03 -0700185 .info-item {
186 display: flex;
187 align-items: center;
188 white-space: nowrap;
189 margin-right: 10px;
190 font-size: 13px;
191 }
192
193 .info-label {
194 font-size: 11px;
195 color: #555;
196 margin-right: 3px;
197 font-weight: 500;
198 }
199
200 .info-value {
201 font-size: 11px;
202 font-weight: 600;
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000203 word-break: break-all;
Sean McCullough86b56862025-04-18 13:04:03 -0700204 }
205
Philip Zeyligerd1402952025-04-23 03:54:37 +0000206 [title] {
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000207 cursor: default;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000208 }
209
Sean McCullough86b56862025-04-18 13:04:03 -0700210 .info-item a {
211 --tw-text-opacity: 1;
212 color: rgb(37 99 235 / var(--tw-text-opacity, 1));
213 text-decoration: inherit;
214 }
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000215
216 .info-toggle {
217 margin-left: 8px;
218 width: 24px;
219 height: 24px;
220 border-radius: 50%;
221 display: flex;
222 align-items: center;
223 justify-content: center;
224 background: #f0f0f0;
225 border: 1px solid #ddd;
226 cursor: pointer;
227 font-weight: bold;
228 font-style: italic;
229 color: #555;
230 transition: all 0.2s ease;
231 }
232
233 .info-toggle:hover {
234 background: #e0e0e0;
235 }
236
237 .info-toggle.active {
238 background: #4a90e2;
239 color: white;
240 border-color: #3a80d2;
241 }
242
243 .main-info-grid {
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000244 display: grid;
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700245 grid-template-columns: 1fr 1fr;
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000246 gap: 10px;
247 width: 100%;
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000248 }
249
250 .info-column {
251 display: flex;
252 flex-direction: column;
253 gap: 2px;
254 }
255
256 .detailed-info-grid {
257 display: grid;
258 grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
259 gap: 8px;
260 margin-top: 10px;
261 }
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000262
263 .ssh-section {
264 margin-top: 10px;
265 padding-top: 10px;
266 border-top: 1px solid #eee;
267 }
268
269 .ssh-command {
270 display: flex;
271 align-items: center;
272 margin-bottom: 8px;
273 gap: 10px;
274 }
275
276 .ssh-command-text {
277 font-family: monospace;
278 font-size: 12px;
279 background: #f5f5f5;
280 padding: 4px 8px;
281 border-radius: 4px;
282 border: 1px solid #e0e0e0;
283 flex-grow: 1;
284 }
285
286 .copy-button {
287 background: #f0f0f0;
288 border: 1px solid #ddd;
289 border-radius: 4px;
290 padding: 3px 6px;
291 font-size: 11px;
292 cursor: pointer;
293 transition: all 0.2s;
294 }
295
296 .copy-button:hover {
297 background: #e0e0e0;
298 }
299
300 .ssh-warning {
301 background: #fff3e0;
302 border-left: 3px solid #ff9800;
303 padding: 8px 12px;
304 margin-top: 8px;
305 font-size: 12px;
306 color: #e65100;
307 }
308
309 .vscode-link {
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000310 color: white;
311 text-decoration: none;
312 background-color: #0066b8;
313 padding: 4px 8px;
314 border-radius: 4px;
315 display: flex;
316 align-items: center;
317 gap: 6px;
318 font-size: 12px;
319 transition: all 0.2s ease;
320 }
321
322 .vscode-link:hover {
323 background-color: #005091;
324 }
325
326 .vscode-icon {
327 width: 16px;
328 height: 16px;
329 }
330
331 .github-link {
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000332 color: #2962ff;
333 text-decoration: none;
334 }
335
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000336 .github-link:hover {
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000337 text-decoration: underline;
338 }
Sean McCullough86b56862025-04-18 13:04:03 -0700339 `;
340
341 constructor() {
342 super();
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000343 this._toggleInfoDetails = this._toggleInfoDetails.bind(this);
344
345 // Close the info panel when clicking outside of it
346 document.addEventListener("click", (event) => {
347 if (this.showDetails && !this.contains(event.target as Node)) {
348 this.showDetails = false;
349 this.requestUpdate();
350 }
351 });
352 }
353
354 /**
355 * Toggle the display of detailed information
356 */
357 private _toggleInfoDetails(event: Event) {
358 event.stopPropagation();
359 this.showDetails = !this.showDetails;
360 this.requestUpdate();
Sean McCullough86b56862025-04-18 13:04:03 -0700361 }
362
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000363 /**
364 * Update the last commit information based on messages
365 */
366 public updateLastCommitInfo(newMessages: AgentMessage[]): void {
367 if (!newMessages || newMessages.length === 0) return;
368
369 // Process messages in chronological order (latest last)
370 for (const message of newMessages) {
371 if (
372 message.type === "commit" &&
373 message.commits &&
374 message.commits.length > 0
375 ) {
376 // Get the first commit from the list
377 const commit = message.commits[0];
378 if (commit) {
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700379 // Check if the commit hash has changed
380 const hasChanged =
381 !this.lastCommit || this.lastCommit.hash !== commit.hash;
382
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000383 this.lastCommit = {
384 hash: commit.hash,
385 pushedBranch: commit.pushed_branch,
386 };
387 this.lastCommitCopied = false;
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700388
389 // Add pulse animation if the commit changed
390 if (hasChanged) {
391 // Find the last commit element
392 setTimeout(() => {
393 const lastCommitEl =
394 this.shadowRoot?.querySelector(".last-commit-main");
395 if (lastCommitEl) {
396 // Add the pulse class
397 lastCommitEl.classList.add("pulse");
398
399 // Remove the pulse class after animation completes
400 setTimeout(() => {
401 lastCommitEl.classList.remove("pulse");
402 }, 1500);
403 }
404 }, 0);
405 }
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000406 }
407 }
408 }
409 }
410
411 /**
412 * Copy commit info to clipboard when clicked
413 */
414 private copyCommitInfo(event: MouseEvent): void {
415 event.preventDefault();
416 event.stopPropagation();
417
418 if (!this.lastCommit) return;
419
420 const textToCopy =
421 this.lastCommit.pushedBranch || this.lastCommit.hash.substring(0, 8);
422
423 navigator.clipboard
424 .writeText(textToCopy)
425 .then(() => {
426 this.lastCommitCopied = true;
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700427 // Reset the copied state after 1.5 seconds
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000428 setTimeout(() => {
429 this.lastCommitCopied = false;
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700430 }, 1500);
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000431 })
432 .catch((err) => {
433 console.error("Failed to copy commit info:", err);
434 });
435 }
436
Philip Zeyligerd1402952025-04-23 03:54:37 +0000437 formatHostname() {
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000438 // Only display outside hostname
Philip Zeyliger18532b22025-04-23 21:11:46 +0000439 const outsideHostname = this.state?.outside_hostname;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000440
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000441 if (!outsideHostname) {
Philip Zeyligerd1402952025-04-23 03:54:37 +0000442 return this.state?.hostname;
443 }
444
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000445 return outsideHostname;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000446 }
447
448 formatWorkingDir() {
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000449 // Only display outside working directory
Philip Zeyliger18532b22025-04-23 21:11:46 +0000450 const outsideWorkingDir = this.state?.outside_working_dir;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000451
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000452 if (!outsideWorkingDir) {
Philip Zeyligerd1402952025-04-23 03:54:37 +0000453 return this.state?.working_dir;
454 }
455
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000456 return outsideWorkingDir;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000457 }
458
459 getHostnameTooltip() {
Philip Zeyliger18532b22025-04-23 21:11:46 +0000460 const outsideHostname = this.state?.outside_hostname;
461 const insideHostname = this.state?.inside_hostname;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000462
463 if (
Philip Zeyliger18532b22025-04-23 21:11:46 +0000464 !outsideHostname ||
465 !insideHostname ||
466 outsideHostname === insideHostname
Philip Zeyligerd1402952025-04-23 03:54:37 +0000467 ) {
468 return "";
469 }
470
Philip Zeyliger18532b22025-04-23 21:11:46 +0000471 return `Outside: ${outsideHostname}, Inside: ${insideHostname}`;
472 }
473
474 getWorkingDirTooltip() {
475 const outsideWorkingDir = this.state?.outside_working_dir;
476 const insideWorkingDir = this.state?.inside_working_dir;
477
478 if (
479 !outsideWorkingDir ||
480 !insideWorkingDir ||
481 outsideWorkingDir === insideWorkingDir
482 ) {
483 return "";
484 }
485
486 return `Outside: ${outsideWorkingDir}, Inside: ${insideWorkingDir}`;
Philip Zeyligerd1402952025-04-23 03:54:37 +0000487 }
488
Sean McCullough86b56862025-04-18 13:04:03 -0700489 // See https://lit.dev/docs/components/lifecycle/
490 connectedCallback() {
491 super.connectedCallback();
492 // register event listeners
493 }
494
495 // See https://lit.dev/docs/components/lifecycle/
496 disconnectedCallback() {
497 super.disconnectedCallback();
498 // unregister event listeners
499 }
500
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000501 copyToClipboard(text: string) {
502 navigator.clipboard
503 .writeText(text)
504 .then(() => {
505 // Could add a temporary success indicator here
506 })
507 .catch((err) => {
508 console.error("Could not copy text: ", err);
509 });
510 }
511
512 getSSHHostname() {
513 return `sketch-${this.state?.session_id}`;
514 }
515
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000516 // Format GitHub repository URL to org/repo format
517 formatGitHubRepo(url) {
518 if (!url) return null;
519
520 // Common GitHub URL patterns
521 const patterns = [
522 // HTTPS URLs
523 /https:\/\/github\.com\/([^/]+)\/([^/\s.]+)(?:\.git)?/,
524 // SSH URLs
525 /git@github\.com:([^/]+)\/([^/\s.]+)(?:\.git)?/,
526 // Git protocol
527 /git:\/\/github\.com\/([^/]+)\/([^/\s.]+)(?:\.git)?/,
528 ];
529
530 for (const pattern of patterns) {
531 const match = url.match(pattern);
532 if (match) {
533 return {
534 formatted: `${match[1]}/${match[2]}`,
535 url: `https://github.com/${match[1]}/${match[2]}`,
536 };
537 }
538 }
539
540 return null;
541 }
542
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000543 renderSSHSection() {
544 // Only show SSH section if we're in a Docker container and have session ID
545 if (!this.state?.session_id) {
546 return html``;
547 }
548
549 const sshHost = this.getSSHHostname();
550 const sshCommand = `ssh ${sshHost}`;
551 const vscodeCommand = `code --remote ssh-remote+root@${sshHost} /app -n`;
552 const vscodeURL = `vscode://vscode-remote/ssh-remote+root@${sshHost}/app?windowId=_blank`;
553
554 if (!this.state?.ssh_available) {
555 return html`
556 <div class="ssh-section">
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000557 <h3>Connect to Container</h3>
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000558 <div class="ssh-warning">
559 SSH connections are not available:
560 ${this.state?.ssh_error || "SSH configuration is missing"}
561 </div>
562 </div>
563 `;
564 }
565
566 return html`
567 <div class="ssh-section">
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000568 <h3>Connect to Container</h3>
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000569 <div class="ssh-command">
570 <div class="ssh-command-text">${sshCommand}</div>
571 <button
572 class="copy-button"
573 @click=${() => this.copyToClipboard(sshCommand)}
574 >
575 Copy
576 </button>
577 </div>
578 <div class="ssh-command">
579 <div class="ssh-command-text">${vscodeCommand}</div>
580 <button
581 class="copy-button"
582 @click=${() => this.copyToClipboard(vscodeCommand)}
583 >
584 Copy
585 </button>
586 </div>
587 <div class="ssh-command">
Philip Zeyligerbce3a132025-04-30 22:03:39 +0000588 <a href="${vscodeURL}" class="vscode-link" title="${vscodeURL}">
589 <svg
590 class="vscode-icon"
591 xmlns="http://www.w3.org/2000/svg"
592 viewBox="0 0 24 24"
593 fill="none"
594 stroke="white"
595 stroke-width="2"
596 stroke-linecap="round"
597 stroke-linejoin="round"
598 >
599 <path
600 d="M16.5 9.4 7.55 4.24a.35.35 0 0 0-.41.01l-1.23.93a.35.35 0 0 0-.14.29v13.04c0 .12.07.23.17.29l1.24.93c.13.1.31.09.43-.01L16.5 14.6l-6.39 4.82c-.16.12-.38.12-.55.01l-1.33-1.01a.35.35 0 0 1-.14-.28V5.88c0-.12.07-.23.18-.29l1.23-.93c.14-.1.32-.1.46 0l6.54 4.92-6.54 4.92c-.14.1-.32.1-.46 0l-1.23-.93a.35.35 0 0 1-.18-.29V5.88c0-.12.07-.23.17-.29l1.33-1.01c.16-.12.39-.11.55.01l6.39 4.81z"
601 />
602 </svg>
603 <span>Open in VSCode</span>
604 </a>
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000605 </div>
606 </div>
607 `;
608 }
609
Sean McCullough86b56862025-04-18 13:04:03 -0700610 render() {
611 return html`
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000612 <div class="info-container">
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700613 <!-- Main visible info in two columns - github/hostname/dir and last commit -->
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000614 <div class="main-info-grid">
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700615 <!-- First column: GitHub repo (or hostname) and working dir -->
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000616 <div class="info-column">
617 <div class="info-item">
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700618 ${(() => {
619 const github = this.formatGitHubRepo(this.state?.git_origin);
620 if (github) {
621 return html`
622 <a
623 href="${github.url}"
624 target="_blank"
625 rel="noopener noreferrer"
626 class="github-link"
627 title="${this.state?.git_origin}"
628 >
629 ${github.formatted}
630 </a>
631 `;
632 } else {
633 return html`
634 <span
635 id="hostname"
636 class="info-value"
637 title="${this.getHostnameTooltip()}"
638 >
639 ${this.formatHostname()}
640 </span>
641 `;
642 }
643 })()}
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000644 </div>
645 <div class="info-item">
646 <span
647 id="workingDir"
648 class="info-value"
649 title="${this.getWorkingDirTooltip()}"
650 >
651 ${this.formatWorkingDir()}
652 </span>
653 </div>
654 </div>
655
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700656 <!-- Second column: Last Commit -->
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000657 <div class="info-column last-commit-column">
658 <div class="info-item">
659 <span class="info-label">Last Commit</span>
660 </div>
661 <div
662 class="info-item last-commit-main"
663 @click=${(e: MouseEvent) => this.copyCommitInfo(e)}
664 title="Click to copy"
665 >
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000666 ${this.lastCommit
667 ? this.lastCommit.pushedBranch
668 ? html`<span class="commit-branch-indicator main-grid-commit"
669 >${this.lastCommit.pushedBranch}</span
670 >`
671 : html`<span class="commit-hash-indicator main-grid-commit"
672 >${this.lastCommit.hash.substring(0, 8)}</span
673 >`
674 : html`<span class="no-commit-indicator">N/A</span>`}
Philip Zeyliger9bca61e2025-05-22 12:40:06 -0700675 <span class="copy-icon">
676 ${this.lastCommitCopied
677 ? html`<svg
678 xmlns="http://www.w3.org/2000/svg"
679 width="16"
680 height="16"
681 viewBox="0 0 24 24"
682 fill="none"
683 stroke="currentColor"
684 stroke-width="2"
685 stroke-linecap="round"
686 stroke-linejoin="round"
687 >
688 <path d="M20 6L9 17l-5-5"></path>
689 </svg>`
690 : html`<svg
691 xmlns="http://www.w3.org/2000/svg"
692 width="16"
693 height="16"
694 viewBox="0 0 24 24"
695 fill="none"
696 stroke="currentColor"
697 stroke-width="2"
698 stroke-linecap="round"
699 stroke-linejoin="round"
700 >
701 <rect
702 x="9"
703 y="9"
704 width="13"
705 height="13"
706 rx="2"
707 ry="2"
708 ></rect>
709 <path
710 d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
711 ></path>
712 </svg>`}
713 </span>
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000714 </div>
715 </div>
Sean McCullough86b56862025-04-18 13:04:03 -0700716 </div>
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000717
718 <!-- Info toggle button -->
719 <button
720 class="info-toggle ${this.showDetails ? "active" : ""}"
721 @click=${this._toggleInfoDetails}
722 title="Show/hide details"
723 >
724 i
725 </button>
726
727 <!-- Expanded info panel -->
728 <div class="info-expanded ${this.showDetails ? "active" : ""}">
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000729 <!-- Last Commit section moved to main grid -->
730
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000731 <div class="detailed-info-grid">
732 <div class="info-item">
733 <span class="info-label">Commit:</span>
734 <span id="initialCommit" class="info-value"
735 >${this.state?.initial_commit?.substring(0, 8)}</span
736 >
737 </div>
738 <div class="info-item">
739 <span class="info-label">Msgs:</span>
740 <span id="messageCount" class="info-value"
741 >${this.state?.message_count}</span
742 >
743 </div>
744 <div class="info-item">
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000745 <span class="info-label">Session ID:</span>
746 <span id="sessionId" class="info-value"
747 >${this.state?.session_id || "N/A"}</span
748 >
749 </div>
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700750 <div class="info-item">
751 <span class="info-label">Hostname:</span>
752 <span
753 id="hostnameDetail"
754 class="info-value"
755 title="${this.getHostnameTooltip()}"
756 >
757 ${this.formatHostname()}
758 </span>
759 </div>
Philip Zeyliger72318392025-05-14 02:56:07 +0000760 ${this.state?.agent_state
761 ? html`
762 <div class="info-item">
763 <span class="info-label">Agent State:</span>
764 <span id="agentState" class="info-value"
765 >${this.state?.agent_state}</span
766 >
767 </div>
768 `
769 : ""}
Philip Zeyliger16fa8b42025-05-02 04:28:16 +0000770 <div class="info-item">
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000771 <span class="info-label">Input tokens:</span>
772 <span id="inputTokens" class="info-value"
773 >${formatNumber(
774 (this.state?.total_usage?.input_tokens || 0) +
775 (this.state?.total_usage?.cache_read_input_tokens || 0) +
776 (this.state?.total_usage?.cache_creation_input_tokens || 0),
777 )}</span
778 >
779 </div>
780 <div class="info-item">
781 <span class="info-label">Output tokens:</span>
782 <span id="outputTokens" class="info-value"
783 >${formatNumber(this.state?.total_usage?.output_tokens)}</span
784 >
785 </div>
Josh Bleecher Snyder44f847a2025-06-05 14:33:50 -0700786 ${(this.state?.total_usage?.total_cost_usd || 0) > 0
787 ? html`
788 <div class="info-item">
789 <span class="info-label">Total cost:</span>
790 <span id="totalCost" class="info-value cost"
791 >$${(this.state?.total_usage?.total_cost_usd).toFixed(
792 2,
793 )}</span
794 >
795 </div>
796 `
797 : ""}
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000798 <div
799 class="info-item"
800 style="grid-column: 1 / -1; margin-top: 5px; border-top: 1px solid #eee; padding-top: 5px;"
801 >
802 <a href="logs">Logs</a> (<a href="download">Download</a>)
803 </div>
804 </div>
Philip Zeyligerc72fff52025-04-29 20:17:54 +0000805
806 <!-- SSH Connection Information -->
807 ${this.renderSSHSection()}
Sean McCullough86b56862025-04-18 13:04:03 -0700808 </div>
809 </div>
810 `;
811 }
812}
813
814declare global {
815 interface HTMLElementTagNameMap {
816 "sketch-container-status": SketchContainerStatus;
817 }
818}