| 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 | |
| Pokey Rule | ef58e06 | 2025-05-07 13:32:58 +0100 | [diff] [blame] | 5 | @customElement("sketch-tool-card-patch") |
| 6 | export 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) => { |
| Autoformatter | 47fbca6 | 2025-05-07 12:38:12 +0000 | [diff] [blame^] | 30 | return html`Patch operation: <b>${patch.operation}</b> |
| Pokey Rule | ef58e06 | 2025-05-07 13:32:58 +0100 | [diff] [blame] | 31 | <pre>${patch.newText}</pre>`; |
| Autoformatter | 47fbca6 | 2025-05-07 12:38:12 +0000 | [diff] [blame^] | 32 | })} |
| Pokey Rule | ef58e06 | 2025-05-07 13:32:58 +0100 | [diff] [blame] | 33 | </div> |
| 34 | <div slot="result"> |
| 35 | <pre>${this.toolCall?.result_message?.tool_result}</pre> |
| 36 | </div> |
| 37 | </sketch-tool-card>`; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | declare global { |
| 42 | interface HTMLElementTagNameMap { |
| 43 | "sketch-tool-card-patch": SketchToolCardPatch; |
| 44 | } |
| 45 | } |