Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Clean up select-and-edit prompt display in chat bubble and history
Claudefbf93ff4b605
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex ea8cd7f4..1c681430 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -215,16 +215,6 @@ function App() {})),};- const latestHistoryMessage =- requestParams.history && requestParams.history.length > 0- ? requestParams.history[requestParams.history.length - 1]- : null;- const latestUpdateInput = latestHistoryMessage ?? {- text: requestParams.prompt.text,- images: requestParams.prompt.images,- videos: requestParams.prompt.videos ?? [],- };-const commitInputObject =requestParams.generationType === "create"? {@@ -237,11 +227,7 @@ function App() {...baseCommitObject,type: "ai_edit" as const,parentHash: head,- inputs: {- text: latestUpdateInput.text,- images: latestUpdateInput.images,- videos: latestUpdateInput.videos,- },+ inputs: requestParams.prompt,};// Create a new commit and set it as the head@@ -486,10 +472,12 @@ function App() {);let modifiedUpdateInstruction = updateInstruction;+ let selectedElementHtml: string | undefined;// Send in a reference to the selected element if it existsif (selectedElement) {const elementHtml = removeHighlight(selectedElement).outerHTML;+ selectedElementHtml = elementHtml;modifiedUpdateInstruction =updateInstruction +" referring to this element specifically: " +@@ -520,9 +508,10 @@ function App() {generationType: "update",inputMode,prompt: {- text: modifiedUpdateInstruction,+ text: updateInstruction,images: updateImages,videos: [],+ selectedElementHtml,},history: updatedHistory,optionCodes,diff --git a/frontend/src/components/history/utils.ts b/frontend/src/components/history/utils.tsindex 2c0f7482..d7081993 100644--- a/frontend/src/components/history/utils.ts+++ b/frontend/src/components/history/utils.ts@@ -31,13 +31,25 @@ const setParentVersion = (commit: Commit, history: Commit[]) => {: null;};+function extractTagName(html: string): string {+ const match = html.match(/^<(\w+)/);+ return match ? match[1].toLowerCase() : "element";+}+export function summarizeHistoryItem(commit: Commit) {const commitType = commit.type;switch (commitType) {case "ai_create":return "Create";- case "ai_edit":- return commit.inputs.text;+ 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 "code_create":return "Imported from code";default: {diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsxindex 72d669d5..52110822 100644--- a/frontend/src/components/sidebar/Sidebar.tsx+++ b/frontend/src/components/sidebar/Sidebar.tsx@@ -24,6 +24,11 @@ interface SidebarProps {const MAX_UPDATE_IMAGES = 5;+function extractTagName(html: string): string {+ const match = html.match(/^<(\w+)/);+ return match ? match[1].toLowerCase() : "element";+}+function summarizeLatestChange(commit: Commit | null): string | null {if (!commit) return null;if (commit.type === "code_create") return "Imported existing code.";@@ -44,6 +49,13 @@ function summarizeLatestChange(commit: Commit | null): string | null {return "Updated code.";}+function getSelectedElementTag(commit: Commit | null): string | null {+ if (!commit || commit.type === "code_create") return null;+ const html = commit.inputs.selectedElementHtml;+ if (!html) return null;+ return extractTagName(html);+}+function Sidebar({showSelectAndEditFeature,doUpdate,@@ -117,6 +129,7 @@ function Sidebar({const currentCommit = head ? commits[head] : null;const latestChangeSummary = summarizeLatestChange(currentCommit);+ const selectedElementTag = getSelectedElementTag(currentCommit);const latestChangeImages =currentCommit && currentCommit.type !== "code_create"? currentCommit.inputs.images@@ -263,6 +276,14 @@ function Sidebar({>{latestChangeSummary}</p>+ {selectedElementTag && (+ <div className="mt-1.5 flex items-center gap-1.5">+ <LuMousePointerClick className="w-3 h-3 text-violet-500 dark:text-violet-400" />+ <span className="text-[11px] text-violet-600 dark:text-violet-300">+ Selected: <code className="font-mono text-[10px] bg-violet-200/60 dark:bg-violet-800/50 px-1 py-0.5 rounded"><{selectedElementTag}></code>+ </span>+ </div>+ )}{(isPromptClamped || isPromptExpanded) && (<div className="flex justify-end mt-1.5"><buttondiff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 7f961e54..e43b69b8 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -44,6 +44,7 @@ export interface PromptContent {text: string;images: string[]; // Array of data URLsvideos?: string[]; // Array of data URLs+ selectedElementHtml?: string; // Raw HTML of selected element (for display only)}export interface PromptHistoryMessage {