Spaces:
Running
Running
| import{r as t,j as e}from"./react-DKy9e2uO.js";import{c as k}from"./diff-DcU-ljqw.js";import{q as $,v as T,L as A}from"./index-Ck8YGBbR.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./@google-D80DdW2m.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const P=`function Greeter(props) { | |
| return <h1>Hello, {props.name}!</h1>; | |
| }`,B=`function Greeter({ name, enthusiasmLevel = 1 }) { | |
| const punctuation = '!'.repeat(enthusiasmLevel); | |
| return <h1>Hello, {name}{punctuation}</h1>; | |
| }`,O=()=>{const[a,v]=t.useState(P),[o,N]=t.useState(B),[x,u]=t.useState(!1),[p,l]=t.useState(""),[n,h]=t.useState(""),[c,f]=t.useState(""),[b,L]=t.useState("feature/new-logic"),[g,R]=t.useState("main"),[i,y]=t.useState("feat"),[d,G]=t.useState(""),[m,w]=t.useState(`1. | |
| 2. | |
| 3.`),S=t.useCallback(async()=>{if(!a.trim()&&!o.trim()){l("Please provide code to generate a summary.");return}u(!0),l("");try{const s=k("component.tsx",a,o),r=await $(s);h(r.title),f(`${r.summary} | |
| **Key Changes:** | |
| ${r.changes.map(C=>`- ${C}`).join(` | |
| `)}`)}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred.";l(`Failed to generate summary: ${r}`)}finally{u(!1)}},[a,o]),j=t.useMemo(()=>` | |
| # ${i}: ${n} | |
| ${d?` | |
| **Closes:** ${d} | |
| `:""} | |
| **Branch:** \`${b}\` -> \`${g}\` | |
| ## Description | |
| ${c} | |
| ## Testing Steps | |
| ${m} | |
| `.trim(),[n,c,b,g,i,d,m]);return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(T,{}),e.jsx("span",{className:"ml-3",children:"AI Pull Request Assistant"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Generate a PR summary from code changes and populate a full template."})]}),e.jsxs("div",{className:"flex-grow grid grid-cols-1 lg:grid-cols-2 gap-6 min-h-0",children:[e.jsxs("div",{className:"flex flex-col gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"before-code",className:"text-sm font-medium text-text-secondary mb-2",children:"Before"}),e.jsx("textarea",{id:"before-code",value:a,onChange:s=>v(s.target.value),className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"after-code",className:"text-sm font-medium text-text-secondary mb-2",children:"After"}),e.jsx("textarea",{id:"after-code",value:o,onChange:s=>N(s.target.value),className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsx("button",{onClick:S,disabled:x,className:"btn-primary w-full flex items-center justify-center px-6 py-3",children:x?e.jsx(A,{}):"Generate Title & Description"}),p&&e.jsx("p",{className:"text-red-500 text-xs text-center",children:p})]}),e.jsxs("div",{className:"flex flex-col gap-4 min-h-0",children:[e.jsxs("form",{className:"flex flex-col gap-2 overflow-y-auto pr-2 bg-surface border border-border p-4 rounded-lg h-1/2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-1/4",children:[e.jsx("label",{className:"block text-xs",children:"Type"}),e.jsxs("select",{value:i,onChange:s=>y(s.target.value),className:"w-full mt-1 p-1 rounded bg-background border border-border text-sm",children:[e.jsx("option",{children:"feat"}),e.jsx("option",{children:"fix"}),e.jsx("option",{children:"chore"}),e.jsx("option",{children:"docs"}),e.jsx("option",{children:"refactor"})]})]}),e.jsxs("div",{className:"w-3/4",children:[e.jsx("label",{className:"block text-xs",children:"Title"}),e.jsx("input",{type:"text",value:n,onChange:s=>h(s.target.value),className:"w-full mt-1 p-1 rounded bg-background border border-border text-sm"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs",children:"Description"}),e.jsx("textarea",{value:c,onChange:s=>f(s.target.value),className:"w-full mt-1 p-1 rounded bg-background border border-border resize-y h-24 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs",children:"Testing Steps"}),e.jsx("textarea",{value:m,onChange:s=>w(s.target.value),className:"w-full mt-1 p-1 rounded bg-background border border-border resize-y h-16 text-sm"})]})]}),e.jsxs("div",{className:"flex flex-col h-1/2",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"Markdown Preview"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(j),className:"px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:"Copy Markdown"})]}),e.jsx("div",{className:"relative flex-grow",children:e.jsx("pre",{className:"w-full h-full bg-background border border-border p-4 rounded-md text-sm overflow-auto whitespace-pre-wrap",children:j})})]})]})]})]})};export{O as AiPullRequestAssistant}; | |
| //# sourceMappingURL=AiPullRequestAssistant-auR4G7bZ.js.map | |