Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Merge main into branch, resolve history view conflicts

Abi Rajab352157c05db
diff --cc frontend/src/components/history/HistoryDisplay.tsx
index f0869b51,5abd839f..cd7122cd
--- a/frontend/src/components/history/HistoryDisplay.tsx
+++ b/frontend/src/components/history/HistoryDisplay.tsx
@@@ -42,70 -158,82 +158,92 @@@ export default function HistoryDisplay(
>
{/* Version number badge */}
<span
- className={`shrink-0 text-xs font-medium ${
+ className={`shrink-0 flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-semibold ${
isActive
- ? "text-gray-900 dark:text-white"
- : "text-gray-400 dark:text-gray-500"
+ ? "bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300"
+ : "bg-gray-100 dark:bg-zinc-800 text-gray-400 dark:text-gray-500"
}`}
>
- v{versionNumber}
+ {versionNumber}
</span>
+ {/* Thumbnail */}
+ <MediaThumbnail
+ item={item}
+ onPlayClick={() => handleVideoPlayClick(item.hash)}
+ />
+
{/* Summary */}
<div className="flex-1 min-w-0">
- <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"
+ <div className="flex items-center gap-1.5">
+ <span
+ className={`text-[10px] uppercase tracking-wider font-medium px-1.5 py-0.5 rounded ${
+ item.type === "Create"
+ ? "bg-emerald-50 dark:bg-emerald-900/30 text-emerald-600 dark:text-emerald-400"
+ : item.type === "Edit"
+ ? "bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400"
+ : "bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400"
}`}
>
- {item.summary}
- </p>
+ {item.type}
+ </span>
+ {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">
++ <code className="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">
+ &lt;{item.selectedElementTag}&gt;
+ </code>
+ )}
+ {item.parentVersion !== null && (
+ <span className="text-[10px] text-gray-400 dark:text-gray-500">
+ from v{item.parentVersion}
+ </span>
+ )}
</div>
- {item.parentVersion !== null && (
- <p className="text-xs text-gray-400 dark:text-gray-500">
- from v{item.parentVersion}
- </p>
- )}
+ <p
+ className={`text-sm mt-0.5 line-clamp-2 ${
+ isActive
+ ? "font-medium text-gray-900 dark:text-white"
+ : "text-gray-600 dark:text-gray-400"
+ }`}
+ >
+ {item.summary}
+ </p>
</div>
- {/* Type label + expand */}
- <span className="shrink-0 text-[10px] uppercase tracking-wider text-gray-400 dark:text-gray-500">
- {item.type}
- </span>
- <button
- onClick={(e) => {
- e.stopPropagation();
- setExpandedHash(isExpanded ? null : item.hash);
- }}
- className="shrink-0 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 p-0.5"
- >
- {isExpanded ? (
- <BsChevronDown className="w-3 h-3" />
- ) : (
- <BsChevronRight className="w-3 h-3" />
- )}
- </button>
+ {/* Expand button */}
+ {(hasMedia || item.summary.length > 30) && (
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ setExpandedHash(isExpanded ? null : item.hash);
+ }}
+ className="shrink-0 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 p-1 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-700 transition-colors"
+ >
+ {isExpanded ? (
+ <BsChevronDown className="w-3 h-3" />
+ ) : (
+ <BsChevronRight className="w-3 h-3" />
+ )}
+ </button>
+ )}
</div>
{/* Expanded details */}
{isExpanded && (
- <div className="px-3 pb-2.5 pl-12">
- <p className="text-xs text-gray-500 dark:text-gray-400 break-words">
- {item.summary}
- </p>
+ <div className="px-3 pb-3 pl-12">
+ {item.summary.length > 30 && (
+ <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">&lt;{item.selectedElementTag}&gt;</code>
+ </p>
+ )}
+ <ExpandedMedia
+ item={item}
+ autoPlayVideo={autoPlayHash === item.hash}
+ />
</div>
)}
</div>
diff --cc frontend/src/components/history/utils.test.ts
index 68ffc07e,d88d69b1..2f7229bc
--- a/frontend/src/components/history/utils.test.ts
+++ b/frontend/src/components/history/utils.test.ts
@@@ -71,22 -71,25 +71,28 @@@ describe("History Utils", () =>
...basicLinearHistory["0"],
type: "Create",
summary: "Create",
+ selectedElementTag: null,
parentVersion: null,
+ images: [""],
+ videos: [],
},
{
...basicLinearHistory["1"],
type: "Edit",
summary: "use better icons",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
{
...basicLinearHistory["2"],
type: "Edit",
summary: "make text red",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
]);
@@@ -96,22 -99,25 +102,28 @@@
...basicLinearHistoryWithCode["0"],
type: "Imported from code",
summary: "Imported from code",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
{
...basicLinearHistoryWithCode["1"],
type: "Edit",
summary: "use better icons",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
{
...basicLinearHistoryWithCode["2"],
type: "Edit",
summary: "make text red",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
]);
@@@ -121,29 -127,33 +133,37 @@@
...basicBranchingHistory["0"],
type: "Create",
summary: "Create",
+ selectedElementTag: null,
parentVersion: null,
+ images: [""],
+ videos: [],
},
{
...basicBranchingHistory["1"],
type: "Edit",
summary: "use better icons",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
{
...basicBranchingHistory["2"],
type: "Edit",
summary: "make text red",
+ selectedElementTag: null,
parentVersion: null,
+ images: [],
+ videos: [],
},
{
...basicBranchingHistory["3"],
type: "Edit",
summary: "make text green",
+ selectedElementTag: null,
parentVersion: 2,
+ images: [],
+ videos: [],
},
]);
});
diff --cc frontend/src/components/history/utils.ts
index 4fd15c1d,ab065aab..67c22171
--- a/frontend/src/components/history/utils.ts
+++ b/frontend/src/components/history/utils.ts
@@@ -31,12 -31,17 +31,22 @@@ const setParentVersion = (commit: Commi
: null;
};
+function extractTagName(html: string): string {
+ const match = html.match(/^<(\w+)/);
+ return match ? match[1].toLowerCase() : "element";
+}
+
+ function getCommitMedia(commit: Commit): { images: string[]; videos: string[] } {
+ if (commit.type === "code_create") {
+ return { images: [], videos: [] };
+ }
+ return {
+ images: commit.inputs.images || [],
+ videos: commit.inputs.videos || [],
+ };
+ }
+
-export function summarizeHistoryItem(commit: Commit) {
+export function summarizeHistoryItem(commit: Commit): string {
const commitType = commit.type;
switch (commitType) {
case "ai_create":
@@@ -52,15 -57,16 +62,24 @@@
}
}
+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 = [];
+ export type RenderedHistoryItem = Omit<Commit, "type"> & {
+ type: string;
+ summary: string;
++ selectedElementTag: string | null;
+ parentVersion: number | null;
+ images: string[];
+ videos: string[];
+ };
+
+ export const renderHistory = (history: Commit[]): RenderedHistoryItem[] => {
+ const renderedHistory: RenderedHistoryItem[] = [];
for (let i = 0; i < history.length; i++) {
const commit = history[i];
@@@ -68,8 -75,9 +88,10 @@@
...commit,
type: displayHistoryItemType(commit.type),
summary: summarizeHistoryItem(commit),
+ selectedElementTag: getSelectedElementTag(commit),
parentVersion: setParentVersion(commit, history),
+ images: media.images,
+ videos: media.videos,
});
}