Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Improve element tag display in versions view with styled pill badge
Abi Rajaae87d0039131
diff --git a/frontend/src/components/history/HistoryDisplay.tsx b/frontend/src/components/history/HistoryDisplay.tsxindex 1f83cc2a..f0869b51 100644--- a/frontend/src/components/history/HistoryDisplay.tsx+++ b/frontend/src/components/history/HistoryDisplay.tsx@@ -53,15 +53,22 @@ export default function HistoryDisplay() {{/* Summary */}<div className="flex-1 min-w-0">- <p- className={`text-sm truncate ${- isActive- ? "font-medium text-gray-900 dark:text-white"- : "text-gray-600 dark:text-gray-400"- }`}- >- {item.summary}- </p>+ <div className="flex items-center gap-1.5 min-w-0">+ <p+ className={`text-sm truncate ${+ isActive+ ? "font-medium text-gray-900 dark:text-white"+ : "text-gray-600 dark:text-gray-400"+ }`}+ >+ {item.summary}+ </p>+ {item.selectedElementTag && (+ <code className="shrink-0 text-[10px] font-mono text-violet-600 dark:text-violet-400 bg-violet-100 dark:bg-violet-900/30 px-1.5 py-0.5 rounded-md">+ <{item.selectedElementTag}>+ </code>+ )}+ </div>{item.parentVersion !== null && (<p className="text-xs text-gray-400 dark:text-gray-500">from v{item.parentVersion}@@ -94,6 +101,11 @@ export default function HistoryDisplay() {<p className="text-xs text-gray-500 dark:text-gray-400 break-words">{item.summary}</p>+ {item.selectedElementTag && (+ <p className="text-xs text-violet-500 dark:text-violet-400 mt-1">+ Target: <code className="font-mono text-[10px] bg-violet-100 dark:bg-violet-900/30 px-1 py-0.5 rounded"><{item.selectedElementTag}></code>+ </p>+ )}</div>)}</div>diff --git a/frontend/src/components/history/utils.test.ts b/frontend/src/components/history/utils.test.tsindex 33041be0..68ffc07e 100644--- a/frontend/src/components/history/utils.test.ts+++ b/frontend/src/components/history/utils.test.ts@@ -71,18 +71,21 @@ describe("History Utils", () => {...basicLinearHistory["0"],type: "Create",summary: "Create",+ selectedElementTag: null,parentVersion: null,},{...basicLinearHistory["1"],type: "Edit",summary: "use better icons",+ selectedElementTag: null,parentVersion: null,},{...basicLinearHistory["2"],type: "Edit",summary: "make text red",+ selectedElementTag: null,parentVersion: null,},]);@@ -93,18 +96,21 @@ describe("History Utils", () => {...basicLinearHistoryWithCode["0"],type: "Imported from code",summary: "Imported from code",+ selectedElementTag: null,parentVersion: null,},{...basicLinearHistoryWithCode["1"],type: "Edit",summary: "use better icons",+ selectedElementTag: null,parentVersion: null,},{...basicLinearHistoryWithCode["2"],type: "Edit",summary: "make text red",+ selectedElementTag: null,parentVersion: null,},]);@@ -115,24 +121,28 @@ describe("History Utils", () => {...basicBranchingHistory["0"],type: "Create",summary: "Create",+ selectedElementTag: null,parentVersion: null,},{...basicBranchingHistory["1"],type: "Edit",summary: "use better icons",+ selectedElementTag: null,parentVersion: null,},{...basicBranchingHistory["2"],type: "Edit",summary: "make text red",+ selectedElementTag: null,parentVersion: null,},{...basicBranchingHistory["3"],type: "Edit",summary: "make text green",+ selectedElementTag: null,parentVersion: 2,},]);diff --git a/frontend/src/components/history/utils.ts b/frontend/src/components/history/utils.tsindex d7081993..4fd15c1d 100644--- a/frontend/src/components/history/utils.ts+++ b/frontend/src/components/history/utils.ts@@ -36,20 +36,13 @@ function extractTagName(html: string): string {return match ? match[1].toLowerCase() : "element";}-export function summarizeHistoryItem(commit: Commit) {+export function summarizeHistoryItem(commit: Commit): string {const commitType = commit.type;switch (commitType) {case "ai_create":return "Create";- case "ai_edit": {- const text = commit.inputs.text;- const elementHtml = commit.inputs.selectedElementHtml;- if (elementHtml) {- const tag = extractTagName(elementHtml);- return text ? `${text} [<${tag}>]` : `Edit <${tag}>`;- }- return text;- }+ case "ai_edit":+ return commit.inputs.text || "Edit";case "code_create":return "Imported from code";default: {@@ -59,6 +52,13 @@ export function summarizeHistoryItem(commit: Commit) {}}+export function getSelectedElementTag(commit: Commit): string | null {+ if (commit.type === "code_create") return null;+ const html = commit.inputs.selectedElementHtml;+ if (!html) return null;+ return extractTagName(html);+}+export const renderHistory = (history: Commit[]) => {const renderedHistory = [];@@ -68,6 +68,7 @@ export const renderHistory = (history: Commit[]) => {...commit,type: displayHistoryItemType(commit.type),summary: summarizeHistoryItem(commit),+ selectedElementTag: getSelectedElementTag(commit),parentVersion: setParentVersion(commit, history),});}