blob: be765d02d0250fd895a6651a6001f6169489b278 [file] [log] [blame]
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +00001import { css, html, LitElement } from "lit";
2import { customElement, property } from "lit/decorators.js";
3import { ToolCall } from "../types";
4
5@customElement("sketch-tool-card-browser-scroll-into-view")
6export class SketchToolCardBrowserScrollIntoView extends LitElement {
7 @property()
8 toolCall: ToolCall;
9
10 @property()
11 open: boolean;
12
13 static styles = css`
14 .summary-text {
15 font-family: monospace;
16 color: #444;
17 word-break: break-all;
18 }
Autoformatter71c73b52025-05-29 20:18:43 +000019
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000020 .selector-input {
21 font-family: monospace;
22 background: rgba(0, 0, 0, 0.05);
23 padding: 4px 8px;
24 border-radius: 4px;
25 display: inline-block;
26 word-break: break-all;
27 }
28 `;
29
30 render() {
31 // Parse the input to get selector
32 let selector = "";
33 try {
34 if (this.toolCall?.input) {
35 const input = JSON.parse(this.toolCall.input);
36 selector = input.selector || "";
37 }
38 } catch (e) {
39 console.error("Error parsing scroll into view input:", e);
40 }
41
42 return html`
43 <sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}>
Autoformatter71c73b52025-05-29 20:18:43 +000044 <span slot="summary" class="summary-text"> 🔄 ${selector} </span>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000045 <div slot="input">
Autoformatter71c73b52025-05-29 20:18:43 +000046 <div>
47 Scroll into view: <span class="selector-input">${selector}</span>
48 </div>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000049 </div>
50 <div slot="result">
51 ${this.toolCall?.result_message?.tool_result
52 ? html`<pre>${this.toolCall.result_message.tool_result}</pre>`
53 : ""}
54 </div>
55 </sketch-tool-card>
56 `;
57 }
58}
59
60declare global {
61 interface HTMLElementTagNameMap {
62 "sketch-tool-card-browser-scroll-into-view": SketchToolCardBrowserScrollIntoView;
63 }
64}