blob: 362ed0e46c55e19e04d330637cf4c150a0663210 [file] [log] [blame]
Pokey Ruleef58e062025-05-07 13:32:58 +01001import { LitElement, css, html } from "lit";
2import { customElement, property } from "lit/decorators.js";
3import { ToolCall } from "../types";
4
Pokey Ruleef58e062025-05-07 13:32:58 +01005@customElement("sketch-tool-card-patch")
6export class SketchToolCardPatch extends LitElement {
7 @property() toolCall: ToolCall;
8 @property() open: boolean;
9
10 static styles = css`
11 .summary-text {
12 color: #555;
13 font-family: monospace;
14 overflow: hidden;
15 text-overflow: ellipsis;
16 white-space: nowrap;
17 border-radius: 3px;
18 }
19 `;
20
21 render() {
22 const patchInput = JSON.parse(this.toolCall?.input);
23 return html`<sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}>
24 <span slot="summary" class="summary-text">
25 ${patchInput?.path}: ${patchInput.patches.length}
26 edit${patchInput.patches.length > 1 ? "s" : ""}
27 </span>
28 <div slot="input">
29 ${patchInput.patches.map((patch) => {
Autoformatter47fbca62025-05-07 12:38:12 +000030 return html`Patch operation: <b>${patch.operation}</b>
Pokey Ruleef58e062025-05-07 13:32:58 +010031 <pre>${patch.newText}</pre>`;
Autoformatter47fbca62025-05-07 12:38:12 +000032 })}
Pokey Ruleef58e062025-05-07 13:32:58 +010033 </div>
34 <div slot="result">
35 <pre>${this.toolCall?.result_message?.tool_result}</pre>
36 </div>
37 </sketch-tool-card>`;
38 }
39}
40
41declare global {
42 interface HTMLElementTagNameMap {
43 "sketch-tool-card-patch": SketchToolCardPatch;
44 }
45}