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