| Pokey Rule | ef58e06 | 2025-05-07 13:32:58 +0100 | [diff] [blame^] | 1 | import { LitElement, html } from "lit"; |
| 2 | import { customElement, property } from "lit/decorators.js"; |
| 3 | import { ToolCall } from "../types"; |
| 4 | |
| 5 | @customElement("sketch-tool-card-codereview") |
| 6 | export class SketchToolCardCodeReview extends LitElement { |
| 7 | @property() toolCall: ToolCall; |
| 8 | @property() open: boolean; |
| 9 | |
| 10 | // Determine the status icon based on the content of the result message |
| 11 | getStatusIcon(resultText: string): string { |
| 12 | if (!resultText) return ""; |
| 13 | if (resultText === "OK") return "✔️"; |
| 14 | if (resultText.includes("# Errors")) return "⚠️"; |
| 15 | if (resultText.includes("# Info")) return "ℹ️"; |
| 16 | if (resultText.includes("uncommitted changes in repo")) return "🧹"; |
| 17 | if (resultText.includes("no new commits have been added")) return "🐣"; |
| 18 | if (resultText.includes("git repo is not clean")) return "🧼"; |
| 19 | return "❓"; |
| 20 | } |
| 21 | |
| 22 | render() { |
| 23 | const resultText = this.toolCall?.result_message?.tool_result || ""; |
| 24 | const statusIcon = this.getStatusIcon(resultText); |
| 25 | |
| 26 | return html`<sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}> |
| 27 | <span slot="summary" class="summary-text">${statusIcon}</span> |
| 28 | <div slot="result"><pre>${resultText}</pre></div> |
| 29 | </sketch-tool-card>`; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | declare global { |
| 34 | interface HTMLElementTagNameMap { |
| 35 | "sketch-tool-card-codereview": SketchToolCardCodeReview; |
| 36 | } |
| 37 | } |