blob: 41a256bec26c7927a07a927a25b48433bc00bba1 [file] [log] [blame]
Pokey Ruleef58e062025-05-07 13:32:58 +01001import { LitElement, html } from "lit";
2import { customElement, property } from "lit/decorators.js";
3import { ToolCall } from "../types";
4
5@customElement("sketch-tool-card-codereview")
6export 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
33declare global {
34 interface HTMLElementTagNameMap {
35 "sketch-tool-card-codereview": SketchToolCardCodeReview;
36 }
37}