| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 1 | import { html } from "lit"; |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 2 | import { customElement, property } from "lit/decorators.js"; |
| 3 | import { ToolCall } from "../types"; |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 4 | import { SketchTailwindElement } from "./sketch-tailwind-element"; |
| 5 | import "./sketch-tool-card-base"; |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 6 | |
| 7 | @customElement("sketch-tool-card-browser-wait-for") |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 8 | export class SketchToolCardBrowserWaitFor extends SketchTailwindElement { |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 9 | @property() |
| 10 | toolCall: ToolCall; |
| 11 | |
| 12 | @property() |
| 13 | open: boolean; |
| 14 | |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 15 | render() { |
| 16 | // Parse the input to get selector |
| 17 | let selector = ""; |
| 18 | try { |
| 19 | if (this.toolCall?.input) { |
| 20 | const input = JSON.parse(this.toolCall.input); |
| 21 | selector = input.selector || ""; |
| 22 | } |
| 23 | } catch (e) { |
| 24 | console.error("Error parsing wait for input:", e); |
| 25 | } |
| 26 | |
| banksean | 1ee0bc6 | 2025-07-22 23:24:18 +0000 | [diff] [blame] | 27 | const summaryContent = html`<span |
| 28 | class="font-mono text-gray-700 dark:text-gray-300 break-all" |
| 29 | > |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 30 | ⏳ ${selector} |
| 31 | </span>`; |
| 32 | const inputContent = html`<div> |
| 33 | Wait for: |
| 34 | <span |
| banksean | 1ee0bc6 | 2025-07-22 23:24:18 +0000 | [diff] [blame] | 35 | class="font-mono bg-black/[0.05] dark:bg-white/[0.1] px-2 py-1 rounded inline-block break-all" |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 36 | >${selector}</span |
| 37 | > |
| 38 | </div>`; |
| 39 | const resultContent = this.toolCall?.result_message?.tool_result |
| 40 | ? html`<pre |
| banksean | 1ee0bc6 | 2025-07-22 23:24:18 +0000 | [diff] [blame] | 41 | class="bg-gray-200 dark:bg-gray-700 text-black dark:text-gray-100 p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border" |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 42 | > |
| 43 | ${this.toolCall.result_message.tool_result}</pre |
| 44 | >` |
| 45 | : ""; |
| 46 | |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 47 | return html` |
| banksean | 333aa67 | 2025-07-13 19:49:21 +0000 | [diff] [blame] | 48 | <sketch-tool-card-base |
| 49 | .open=${this.open} |
| 50 | .toolCall=${this.toolCall} |
| 51 | .summaryContent=${summaryContent} |
| 52 | .inputContent=${inputContent} |
| 53 | .resultContent=${resultContent} |
| 54 | > |
| 55 | </sketch-tool-card-base> |
| Josh Bleecher Snyder | 2d08119 | 2025-05-29 13:46:04 +0000 | [diff] [blame] | 56 | `; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | declare global { |
| 61 | interface HTMLElementTagNameMap { |
| 62 | "sketch-tool-card-browser-wait-for": SketchToolCardBrowserWaitFor; |
| 63 | } |
| 64 | } |