history states
Browse filesFiles changed (3)
36 unmodified lines373839404142158 unmodified lines20120220320420520620728 unmodified lines23623723823924024124236 unmodified lines"editor");const [prompts, setPrompts] = useState<string[]>([]);const fetchMe = async () => {const res = await fetch("/api/@me");158 unmodified lines})}><Tabs /><divonClick={(e) => {if (isAiWorking) {28 unmodified lines</div><AskAIhtml={html}setHtml={setHtml}isAiWorking={isAiWorking}setisAiWorking={setisAiWorking}setView={setCurrentView}36 unmodified lines373839404142434445158 unmodified lines20420520620720820921028 unmodified lines23924024124224324424524624724824925025125225325425525636 unmodified lines"editor");const [prompts, setPrompts] = useState<string[]>([]);const [htmlHistory, setHtmlHistory] = useState<{ html: string; createdAt: Date; prompt: string }[]>([]);const fetchMe = async () => {const res = await fetch("/api/@me");158 unmodified lines})}><Tabs htmlHistory={htmlHistory} setHtml={setHtml} /><divonClick={(e) => {if (isAiWorking) {28 unmodified lines</div><AskAIhtml={html}setHtml={(newHtml: string) => {setHtml(newHtml);}}onSuccess={(finalHtml: string, p: string) => {const currentHistory = [...htmlHistory];currentHistory.unshift({html: finalHtml,createdAt: new Date(),prompt: p,});setHtmlHistory(currentHistory);}}isAiWorking={isAiWorking}setisAiWorking={setisAiWorking}setView={setCurrentView}
22 unmodified lines2324252627282 unmodified lines31323334353653 unmodified lines90919293949596976 unmodified lines10410510610710810943 unmodified lines15315415515615715815916016116216322 unmodified linessetisAiWorking,setView,onNewPrompt,}: {html: string;setHtml: (html: string) => void;2 unmodified linesonNewPrompt: (prompt: string) => void;setView: React.Dispatch<React.SetStateAction<"editor" | "preview">>;setisAiWorking: React.Dispatch<React.SetStateAction<boolean>>;}) {const [open, setOpen] = useState(false);const [prompt, setPrompt] = useState("");53 unmodified linesconst { done, value } = await reader.read();if (done) {toast.success("AI responded successfully");setPrompt("");setPreviousPrompt(prompt);setisAiWorking(false);setHasAsked(true);audio.play();6 unmodified linesif (finalDoc) {setHtml(finalDoc);}return;}43 unmodified lines>{defaultHTML !== html && (<pclassName="text-2xl text-white/50 hover:text-white/80 -translate-y-[calc(100%+8px)] absolute top-0 right-0 cursor-pointer"onClick={() => {copyToClipboard(html);toast.success("HTML copied to clipboard");audio.play();}}><IoCopy />22 unmodified lines232425262728292 unmodified lines3233343536373853 unmodified lines92939495969798996 unmodified lines10610710810911011111243 unmodified lines15615715815916016116216316416522 unmodified linessetisAiWorking,setView,onNewPrompt,onSuccess,}: {html: string;setHtml: (html: string) => void;2 unmodified linesonNewPrompt: (prompt: string) => void;setView: React.Dispatch<React.SetStateAction<"editor" | "preview">>;setisAiWorking: React.Dispatch<React.SetStateAction<boolean>>;onSuccess: (h: string, p: string) => void;}) {const [open, setOpen] = useState(false);const [prompt, setPrompt] = useState("");53 unmodified linesconst { done, value } = await reader.read();if (done) {toast.success("AI responded successfully");setPreviousPrompt(prompt);setPrompt("");setisAiWorking(false);setHasAsked(true);audio.play();6 unmodified linesif (finalDoc) {setHtml(finalDoc);}onSuccess(finalDoc ?? contentResponse, prompt);return;}43 unmodified lines>{defaultHTML !== html && (<pclassName="text-xl text-white/50 hover:text-white/80 -translate-y-[calc(100%+8px)] absolute top-0 right-0 cursor-pointer"onClick={() => {copyToClipboard(html);toast.success("HTML copied to clipboard");}}><IoCopy />
12345678910111213141516import Deepseek from "./../../assets/deepseek-color.svg";function Tabs({ children }: { children?: React.ReactNode }) {return (<div className="border-b border-gray-800 pl-4 lg:pl-7 pr-3 flex items-center justify-between"><divclassName="space-x-6"><button className="rounded-md text-sm cursor-pointer transition-all duration-100 font-medium relative py-2.5 text-white">index.html<span className="absolute bottom-0 left-0 h-0.5 w-full transition-all duration-100 bg-white" /></button></div><div className="flex items-center justify-end gap-3"><a123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import { useState } from "react";import classNames from "classnames";import { IoTimeOutline } from "react-icons/io5";import Deepseek from "./../../assets/deepseek-color.svg";function Tabs({htmlHistory,setHtml,children,}: {htmlHistory?: { html: string; createdAt: Date; prompt: string }[];setHtml: (html: string) => void;children?: React.ReactNode;}) {const [visible, setVisible] = useState(false);return (<div className="border-b border-gray-800 pl-4 lg:pl-7 pr-3 flex items-center justify-between"><div className="flex items-center justify-start gap-4 flex-1"><divclassName="space-x-6"><button className="rounded-md text-sm cursor-pointer transition-all duration-100 font-medium relative py-2.5 text-white">index.html<span className="absolute bottom-0 left-0 h-0.5 w-full transition-all duration-100 bg-white" /></button></div>{htmlHistory && htmlHistory?.length > 1 && (<divclassName="relative"onMouseEnter={() => setVisible(true)}onMouseLeave={() => setVisible(false)}><buttonclassName={classNames("text-gray-400 hover:text-gray-300 cursor-pointer text-sm nderline flex items-center justify-start gap-1",{"!text-gray-300": visible,})}><IoTimeOutline />{htmlHistory?.length} versions</button><divclassName={classNames("absolute bottom-0 left-0 min-w-sm w-full z-10 translate-y-full pt-2 transition-all duration-200",{"opacity-0 pointer-events-none": !visible,})}><div className="bg-gray-950 border border-gray-800 rounded-xl shadow-2xs p-4"><p className="text-xs font-bold text-white">Version History</p><p className="text-gray-400 text-xs mt-1">This is a list of the full history of what AI has done tothis.</p><ul className="mt-2 max-h-[250px] overflow-y-auto">{htmlHistory?.map((item, index) => (<likey={index}className="text-gray-300 text-xs py-2 border-b border-gray-800 last:border-0 flex items-center justify-between gap-2"><div className=""><span className="line-clamp-1">{item.prompt}</span><span className="text-gray-500 text-[10px]">{new Date(item.createdAt).toLocaleDateString("en-US",{month: "2-digit",day: "2-digit",year: "2-digit",}) +" " +new Date(item.createdAt).toLocaleTimeString("en-US",{hour: "2-digit",minute: "2-digit",second: "2-digit",hour12: false,})}</span></div><buttonclassName="bg-pink-500 text-white text-xs font-medium rounded-md px-2 py-1 transition-all duration-100 hover:bg-pink-600 cursor-pointer"onClick={() => {setHtml(item.html);}}>Select</button></li>))}</ul></div></div></div>)}</div><div className="flex items-center justify-end gap-3"><a
src/components/App.tsx+16-2
src/components/ask-ai/ask-ai.tsx+5-3
src/components/tabs/tabs.tsx+100-9