groove-dev 0.27.84 → 0.27.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/process.js +23 -0
- package/node_modules/@groove-dev/gui/dist/assets/{index-DoEeiBhY.js → index-BbDDgazC.js} +2 -2
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/src/components/chat/chat-messages.jsx +9 -7
- package/node_modules/@groove-dev/gui/src/components/chat/chat-view.jsx +1 -0
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/process.js +23 -0
- package/packages/gui/dist/assets/{index-DoEeiBhY.js → index-BbDDgazC.js} +2 -2
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +1 -1
- package/packages/gui/src/components/chat/chat-messages.jsx +9 -7
- package/packages/gui/src/components/chat/chat-view.jsx +1 -0
- package/spash-page.png +0 -0
- package/ui.png +0 -0
- package/welcome.png +0 -0
|
@@ -739,6 +739,22 @@ For normal file edits within your scope, proceed without review.
|
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
if (this.daemon.trajectoryCapture) {
|
|
743
|
+
try {
|
|
744
|
+
if (status === 'completed') {
|
|
745
|
+
this.daemon.trajectoryCapture.onAgentComplete(agent.id, {
|
|
746
|
+
status: 'SUCCESS', exit_code: code || 0, signal,
|
|
747
|
+
});
|
|
748
|
+
} else {
|
|
749
|
+
this.daemon.trajectoryCapture.onAgentCrash(agent.id,
|
|
750
|
+
signal ? 'Killed by signal ' + signal : 'Exit status ' + status
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
const count = (this.daemon.state.get('training_sessions_captured') || 0) + 1;
|
|
754
|
+
this.daemon.state.set('training_sessions_captured', count);
|
|
755
|
+
} catch (e) { /* fail silent */ }
|
|
756
|
+
}
|
|
757
|
+
|
|
742
758
|
this.daemon.broadcast({ type: 'agent:exit', agentId: agent.id, code: code || 0, signal, status });
|
|
743
759
|
if (this.daemon.integrations) this.daemon.integrations.refreshMcpJson();
|
|
744
760
|
if (status === 'completed' && this.daemon.journalist) {
|
|
@@ -1888,6 +1904,13 @@ For normal file edits within your scope, proceed without review.
|
|
|
1888
1904
|
if (loop) {
|
|
1889
1905
|
await loop.stop();
|
|
1890
1906
|
this.handles.delete(agentId);
|
|
1907
|
+
if (this.daemon.trajectoryCapture) {
|
|
1908
|
+
try {
|
|
1909
|
+
this.daemon.trajectoryCapture.onAgentComplete(agentId, { status: 'STOPPED' });
|
|
1910
|
+
const count = (this.daemon.state.get('training_sessions_captured') || 0) + 1;
|
|
1911
|
+
this.daemon.state.set('training_sessions_captured', count);
|
|
1912
|
+
} catch (e) { /* fail silent */ }
|
|
1913
|
+
}
|
|
1891
1914
|
this.daemon.registry.update(agentId, { status: 'stopped', pid: null });
|
|
1892
1915
|
return;
|
|
1893
1916
|
}
|
|
@@ -8606,8 +8606,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${a.do
|
|
|
8606
8606
|
`),s=[];let o=0;for(;o<a.length;){const c=a[o];if(c.startsWith("```")){const p=c.slice(3).trim(),x=[];for(o++;o<a.length&&!a[o].startsWith("```");)x.push(a[o]),o++;o++,s.push({type:"code",language:p,code:x.join(`
|
|
8607
8607
|
`)});continue}const l=c.match(/^(#{1,6})\s+(.+)/);if(l){s.push({type:"heading",level:l[1].length,text:l[2]}),o++;continue}if(/^(-{3,}|_{3,}|\*{3,})$/.test(c.trim())){s.push({type:"hr"}),o++;continue}if(c.startsWith("> ")){const p=[c.slice(2)];for(o++;o<a.length&&a[o].startsWith("> ");)p.push(a[o].slice(2)),o++;s.push({type:"blockquote",text:p.join(`
|
|
8608
8608
|
`)});continue}if(/^[-*+]\s/.test(c)){const p=[c.replace(/^[-*+]\s/,"")];for(o++;o<a.length&&/^[-*+]\s/.test(a[o]);)p.push(a[o].replace(/^[-*+]\s/,"")),o++;s.push({type:"ul",items:p});continue}if(/^\d+\.\s/.test(c)){const p=[c.replace(/^\d+\.\s/,"")];for(o++;o<a.length&&/^\d+\.\s/.test(a[o]);)p.push(a[o].replace(/^\d+\.\s/,"")),o++;s.push({type:"ol",items:p});continue}if(c.includes("|")&&o+1<a.length&&/^\|?\s*[-:]+/.test(a[o+1])){const p=c.split("|").map(m=>m.trim()).filter(Boolean);o+=2;const x=[];for(;o<a.length&&a[o].includes("|");)x.push(a[o].split("|").map(m=>m.trim()).filter(Boolean)),o++;s.push({type:"table",headers:p,rows:x});continue}if(c.trim()===""){o++;continue}const d=[c];for(o++;o<a.length&&a[o].trim()!==""&&!a[o].startsWith("```")&&!a[o].startsWith("#")&&!/^[-*+]\s/.test(a[o])&&!/^\d+\.\s/.test(a[o])&&!a[o].startsWith("> ")&&!/^(-{3,}|_{3,}|\*{3,})$/.test(a[o].trim());)d.push(a[o]),o++;s.push({type:"paragraph",text:d.join(`
|
|
8609
|
-
`)})}return s}function z1({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|~~[^~]+~~|\[([^\]]+)\]\(([^)]+)\))/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("`")&&s.endsWith("`")&&!s.startsWith("``"))return e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o);if(s.startsWith("**")&&s.endsWith("**"))return e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o);if(s.startsWith("*")&&s.endsWith("*")&&!s.startsWith("**"))return e.jsx("em",{className:"italic",children:s.slice(1,-1)},o);if(s.startsWith("~~")&&s.endsWith("~~"))return e.jsx("del",{className:"line-through text-text-3",children:s.slice(2,-2)},o);const c=s.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return c?e.jsx("a",{href:c[2],target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:c[1]},o):e.jsx("span",{children:s},o)})})}function Oze({text:t}){const a=kze(t);return e.jsx("div",{className:"space-y-2",children:a.map((s,o)=>{switch(s.type){case"code":return e.jsx(gze,{language:s.language,code:s.code},o);case"heading":{const c=["text-lg font-bold","text-base font-bold","text-sm font-semibold","text-sm font-semibold","text-xs font-semibold","text-xs font-semibold"];return e.jsx("div",{className:G(c[s.level-1]||c[0],"text-text-0 font-sans mt-3 mb-1"),children:e.jsx(z1,{text:s.text})},o)}case"hr":return e.jsx("hr",{className:"border-border-subtle my-3"},o);case"blockquote":return e.jsx("div",{className:"border-l-2 border-accent/40 pl-3 py-1 text-sm text-text-2 italic font-sans",children:e.jsx(z1,{text:s.text})},o);case"ul":return e.jsx("ul",{className:"list-disc list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"ol":return e.jsx("ol",{className:"list-decimal list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"table":return e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsxs("table",{className:"text-xs font-sans border-collapse w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border",children:s.headers.map((c,l)=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-text-0",children:c},l))})}),e.jsx("tbody",{children:s.rows.map((c,l)=>e.jsx("tr",{className:"border-b border-border-subtle",children:c.map((d,p)=>e.jsx("td",{className:"px-3 py-1.5 text-text-0",children:e.jsx(z1,{text:d})},p))},l))})]})},o);case"paragraph":return e.jsx("p",{className:"text-sm text-text-0 font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.jsx(z1,{text:s.text})},o);default:return null}})})}function vze({msg:t}){return e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-br-md bg-accent/10 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.text})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function bze({msg:t,model:a}){const s=yze(t.text);return e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx(mze,{name:a||"assistant",role:"assistant",size:"sm",className:"mt-1 flex-shrink-0"}),e.jsxs("div",{className:"max-w-[85%]",children:[a&&e.jsx("div",{className:"text-2xs text-text-3 font-sans mb-1 font-medium",children:a}),e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-bl-md bg-surface-4 border border-border-subtle",children:e.jsx("div",{className:"text-sm text-text-0 font-sans leading-relaxed",children:e.jsx(Oze,{text:s})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})]})}function wze({msg:t}){return e.jsx("div",{className:"max-w-[85%]",children:e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsx("div",{className:"w-80 h-80 image-loading-shimmer flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-3/80 flex items-center justify-center",children:e.jsx(hn,{size:18,className:"text-accent animate-pulse"})}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Generating image..."})]})}),t.prompt&&e.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:e.jsxs("p",{className:"text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']})})]})})}function jze({msg:t,onReply:a}){const[s,o]=k.useState(!1),[c,l]=k.useState(!1),d=k.useCallback(()=>{if(!t.imageUrl)return;const p=document.createElement("a");p.href=t.imageUrl,p.download=`groove-${t.model||"image"}-${Date.now()}.png`,document.body.appendChild(p),p.click(),document.body.removeChild(p)},[t.imageUrl,t.model]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[85%]",children:[t.model&&e.jsxs("div",{className:"text-2xs text-text-3 font-mono mb-1.5 font-medium flex items-center gap-1.5",children:[e.jsx(hn,{size:10})," ",t.model]}),e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsxs("div",{className:"relative group",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-full max-h-[480px] object-contain cursor-pointer",onClick:()=>o(!0)}),c&&e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1.5",children:[e.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Download",children:e.jsx(oa,{size:14})}),e.jsx("button",{onClick:()=>o(!0),className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Fullscreen",children:e.jsx(wd,{size:14})}),e.jsx(AG,{text:t.prompt||"",className:"h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle text-text-2 hover:text-accent"})]})]}),e.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center gap-2",children:[e.jsxs("p",{className:"flex-1 text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']}),a&&e.jsxs("button",{onClick:()=>a(t),className:"text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer flex items-center gap-1 flex-shrink-0",children:[e.jsx(Zt,{size:10})," Iterate"]})]})]}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[200] bg-surface-0/95 backdrop-blur-md flex items-center justify-center",onClick:()=>o(!1),children:[e.jsx("button",{onClick:()=>o(!1),className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-surface-3 border border-border flex items-center justify-center text-text-2 hover:text-text-0 transition-colors cursor-pointer z-10",children:e.jsx(Ge,{size:18})}),e.jsx("div",{className:"absolute bottom-4 right-4 flex gap-2 z-10",children:e.jsxs("button",{onClick:p=>{p.stopPropagation(),d()},className:"h-9 px-4 rounded-lg bg-surface-3 border border-border flex items-center gap-2 text-xs font-sans text-text-1 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",children:[e.jsx(oa,{size:14})," Download"]})}),e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:p=>p.stopPropagation()}),t.prompt&&e.jsx("div",{className:"absolute bottom-4 left-4 max-w-md px-4 py-2 rounded-lg bg-surface-3/90 backdrop-blur-sm border border-border-subtle z-10",children:e.jsxs("p",{className:"text-xs text-text-2 font-sans italic",children:['"',t.prompt,'"']})})]})]})}function Mze({msg:t}){return e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-surface-4/50",children:[e.jsx(Do,{size:10,className:"text-text-4"}),e.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.text})]})})}function Nze(){return e.jsx("div",{className:"flex flex-col items-center justify-center h-full text-center py-16",children:e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Send a message to start"})})}function Sze(){const[t,a]=k.useState(0),[s,o]=k.useState(!0);return k.useEffect(()=>{const c=setInterval(()=>{o(!1),setTimeout(()=>{a(l=>(l+1)%PD.length),o(!0)},250)},2800);return()=>clearInterval(c)},[]),e.jsxs("div",{className:"flex items-center gap-2.5 ml-8 py-1",children:[e.jsx("div",{className:"relative w-3.5 h-3.5 flex-shrink-0",children:e.jsx("span",{className:"absolute inset-0 rounded-full border border-transparent border-t-accent animate-spin",style:{animationDuration:"0.9s"}})}),e.jsx("span",{className:"text-2xs font-sans text-text-3 transition-opacity duration-[250ms]",style:{opacity:s?1:0},children:PD[t]})]})}function _ze({messages:t,isStreaming:a,model:s,mode:o,onImageReply:c}){const l=k.useRef(null),d=k.useRef(!0);return k.useEffect(()=>{const p=l.current;if(!p)return;function x(){d.current=p.scrollHeight-p.scrollTop-p.clientHeight<50}return p.addEventListener("scroll",x),()=>p.removeEventListener("scroll",x)},[]),k.useEffect(()=>{d.current&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t==null?void 0:t.length,a]),!t||t.length===0?e.jsx("div",{ref:l,className:"flex-1 overflow-y-auto",children:e.jsx(Nze,{})}):e.jsxs("div",{ref:l,className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[t.map((p,x)=>p.type==="image-loading"?e.jsx(wze,{msg:p},x):p.type==="image"?e.jsx(jze,{msg:p,onReply:c},x):p.from==="user"?e.jsx(vze,{msg:p},x):p.from==="system"?e.jsx(Mze,{msg:p},x):e.jsx(bze,{msg:p,model:s},x)),a&&(o==="agent"?e.jsx(PG,{className:"py-1"}):e.jsx(Sze,{}))]})}function AD({onSend:t,onStop:a,sending:s,streaming:o,disabled:c,isImageModel:l,currentModel:d,replyContext:p,onClearReply:x,role:m}){const[O,f]=k.useState(""),y=k.useRef(null),b=k.useRef(null),w=k.useCallback(()=>{const q=y.current;q&&(q.style.height="auto",q.style.height=Math.min(q.scrollHeight,200)+"px")},[]);k.useEffect(()=>{w()},[O,w]),k.useEffect(()=>{!c&&y.current&&y.current.focus()},[c]);function M(){const q=O.trim();!q||s||c||(t(q),f(""),y.current&&(y.current.style.height="auto"))}function N(q){q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),M())}function j(q){const Q=Array.from(q.target.files||[]);if(Q.length===0)return;const S=Q.map(z=>z.name).join(", ");f(z=>z+(z?`
|
|
8610
|
-
`:"")+`[Attached: ${S}]`),q.target.value=""}const _=o||s,$=O.trim()&&!s&&!c,L=c?"Select a model to start chatting...":l?"Describe the image you want to generate...":m?`Ask your ${m}...`:"Send a message...";return e.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 bg-surface-1",children:[p&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-2 rounded-lg bg-accent/5 border border-accent/15",children:[e.jsx(hn,{size:12,className:"text-accent flex-shrink-0"}),e.jsxs("span",{className:"flex-1 text-2xs text-text-2 font-sans truncate",children:['Iterating: "',p.prompt,'"']}),e.jsx("button",{onClick:x,className:"text-text-4 hover:text-text-1 cursor-pointer flex-shrink-0",children:e.jsx(Cd,{size:10})})]}),d&&e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:G("flex items-center gap-1 h-6 px-2 rounded-md text-2xs font-mono border",l?"bg-purple/8 border-purple/20 text-purple":"bg-surface-3 border-border-subtle text-text-3"),children:[l&&e.jsx(hn,{size:9}),e.jsx("span",{className:"max-w-[80px] truncate",children:PA(d)})]})}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("input",{ref:b,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:j,className:"hidden"}),e.jsx("button",{onClick:()=>{var q;return(q=b.current)==null?void 0:q.click()},disabled:c,className:"w-10 h-10 flex items-center justify-center rounded-xl text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed flex-shrink-0",title:"Attach file",children:e.jsx(K1,{size:16})}),e.jsx("textarea",{ref:y,value:O,onChange:q=>f(q.target.value),onKeyDown:N,placeholder:L,disabled:c,rows:1,className:G("flex-1 resize-y rounded-xl px-4 py-2.5 text-sm","bg-surface-0 border text-text-0 font-sans","placeholder:text-text-4","focus:outline-none focus:ring-1","min-h-[40px]","border-border focus:ring-accent/40","disabled:opacity-50 disabled:cursor-not-allowed")}),_?e.jsx("button",{onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-xl bg-danger/80 text-white hover:bg-danger transition-all cursor-pointer shadow-lg shadow-danger/20 flex-shrink-0",title:"Stop generation",children:e.jsx(Cd,{size:14,fill:"currentColor"})}):e.jsx("button",{onClick:M,disabled:!$,className:G("w-10 h-10 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",$?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:s?e.jsx(Le,{size:16,className:"animate-spin"}):e.jsx(fn,{size:16})})]})]})}function Cze({onNewChat:t}){return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-1 font-sans",children:"Groove Chat"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Every provider, every model, full project context."}),e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 h-9 px-5 rounded-lg bg-accent/15 text-accent text-sm font-semibold font-sans hover:bg-accent/25 transition-colors cursor-pointer border border-accent/20",children:[e.jsx(ct,{size:14}),"New Chat"]})]})})}function $ze(){const t=P(T=>T.conversations),a=P(T=>T.activeConversationId),s=P(T=>T.conversationMessages),o=P(T=>T.sendingMessage),c=P(T=>T.streamingConversationId),l=P(T=>T.createConversation);P(T=>T.setActiveConversation);const d=P(T=>T.sendChatMessage),p=P(T=>T.sendImageMessage),x=P(T=>T.stopAgent),m=P(T=>T.stopChatStreaming),O=P(T=>T.setConversationMode),f=P(T=>T.setConversationModel),y=P(T=>T.conversationRoles),b=P(T=>T.setConversationRole),[w,M]=k.useState(!1),[N,j]=k.useState(null),_=a&&(y==null?void 0:y[a])||null,$=t.find(T=>T.id===a)||null,L=a?s[a]||[]:[],q=c===a&&o,Q=$?iL($.model):!1,S=k.useCallback(async(T,A)=>{const X=T||"claude-code",B=A||"claude-sonnet-4-6";try{await l(X,B,"api")}catch{}},[l]),z=k.useCallback(T=>{a&&O(a,T)},[a,O]),E=k.useCallback(T=>{a&&b(a,T)},[a,b]),R=k.useCallback(T=>{if(a)if(Q){const A=N?`${T} (iterating on: "${N.prompt}")`:T;p(a,A,{model:$.model}),j(null)}else d(a,T)},[a,$,Q,N,d,p]),J=k.useCallback(()=>{$&&($.mode==="agent"&&$.agentId?x($.agentId):m(a))},[$,a,x,m]),ae=k.useCallback(async T=>{a?await f(a,T.provider,T.model):await S(T.provider,T.model)},[a,f,S]),ce=k.useCallback(T=>{j(T)},[]),V=$?{provider:$.provider,model:$.model}:null;return e.jsxs("div",{className:"flex h-full bg-surface-0",children:[e.jsx("div",{className:G("flex-shrink-0 border-r border-accent/12 bg-surface-1 transition-all duration-200 overflow-hidden",w?"w-0":"w-64"),children:e.jsx(pze,{onNewChat:()=>S()})}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx(xze,{conversation:$,model:V,onModelChange:ae,onModeChange:z,role:_,onRoleChange:E}),e.jsx(_ze,{messages:L,isStreaming:q,model:$.model,mode:$.mode||"api",onImageReply:ce}),e.jsx(AD,{onSend:R,onStop:J,sending:o,streaming:q,disabled:!1,isImageModel:Q,currentModel:$.model,replyContext:N,onClearReply:()=>j(null),role:_})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cze,{onNewChat:()=>S()}),e.jsx(AD,{onSend:T=>{S().then(()=>{setTimeout(()=>{const A=P.getState().activeConversationId;A&&d(A,T)},500)})},onStop:()=>{},sending:!1,streaming:!1,disabled:!1,isImageModel:!1,currentModel:null})]})})]})}function Lze(){return e.jsx($ze,{})}const Qze=[{id:"desktop",icon:Bo,label:"Desktop",width:"100%"},{id:"tablet",icon:U0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:Z0,label:"Mobile (375px)",width:"375px"}];function zze({onRefresh:t}){const a=P(O=>O.previewState),s=P(O=>O.setPreviewDevice),o=P(O=>O.toggleScreenshotMode),c=P(O=>O.closePreview),[l,d]=k.useState(!1),p=k.useRef(null);k.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);function x(){l?(p.current&&clearTimeout(p.current),d(!1),c()):(d(!0),p.current=setTimeout(()=>d(!1),2e3))}const m=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return e.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[e.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:e.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:m||"No URL"})}),e.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:e.jsx(Zt,{size:14})}),e.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:Qze.map(O=>e.jsx("button",{onClick:()=>s(O.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===O.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:O.label,children:e.jsx(O.icon,{size:13})},O.id))}),e.jsx("button",{onClick:o,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:e.jsx(D1,{size:14})}),e.jsx("button",{onClick:x,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",l?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:l?e.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):e.jsx(Ge,{size:14})})]})}function Tze({iframeRef:t}){const a=P(Q=>Q.toggleScreenshotMode),s=P(Q=>Q.iteratePreview),o=k.useRef(null),[c,l]=k.useState(!1),[d,p]=k.useState(null),[x,m]=k.useState(null),[O,f]=k.useState(null),[y,b]=k.useState(""),[w,M]=k.useState(null),N=k.useCallback(Q=>{if(O)return;const S=o.current.getBoundingClientRect();p({x:Q.clientX-S.left,y:Q.clientY-S.top}),m(null),l(!0)},[O]),j=k.useCallback(Q=>{if(!c||O)return;const S=o.current.getBoundingClientRect();m({x:Q.clientX-S.left,y:Q.clientY-S.top})},[c,O]),_=k.useCallback(()=>{if(!c||!d||!x){l(!1);return}l(!1);const Q={x:Math.min(d.x,x.x),y:Math.min(d.y,x.y),w:Math.abs(x.x-d.x),h:Math.abs(x.y-d.y)};if(Q.w<10||Q.h<10){p(null),m(null);return}f({base64:null,rect:Q,loading:!0});function S(E){f({base64:E,rect:Q,loading:!1}),M(Q),setTimeout(()=>M(null),600)}function z(){const E=document.createElement("canvas"),R=window.devicePixelRatio||1;E.width=Q.w*R,E.height=Q.h*R;const J=E.getContext("2d");return J.scale(R,R),J.fillStyle="#1e2127",J.fillRect(0,0,Q.w,Q.h),J.strokeStyle="#3e4451",J.lineWidth=1,J.strokeRect(4,4,Q.w-8,Q.h-8),J.fillStyle="#6e7681",J.font="12px Inter, sans-serif",J.textAlign="center",J.textBaseline="middle",J.fillText(`${Math.round(Q.w)} × ${Math.round(Q.h)}`,Q.w/2,Q.h/2),E.toDataURL("image/png")}try{const E=t.current;if(!E){S(z());return}const R=document.createElement("canvas"),J=window.devicePixelRatio||1;R.width=Q.w*J,R.height=Q.h*J;const ae=R.getContext("2d");ae.scale(J,J);const ce=E.getBoundingClientRect(),V=o.current.getBoundingClientRect(),T=Q.x-(ce.left-V.left),A=Q.y-(ce.top-V.top);try{ae.drawImage(E,-T*J,-A*J,ce.width*J,ce.height*J,0,0,Q.w,Q.h);const X=ae.getImageData(0,0,1,1).data;if(X[0]===0&&X[1]===0&&X[2]===0&&X[3]===0)throw new Error("blank");S(R.toDataURL("image/png"))}catch{S(z())}}catch{p(null),m(null),f(null)}},[c,d,x,t]);k.useEffect(()=>{function Q(S){S.key==="Escape"&&a()}return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[a]);function $(){!O||O.loading||(s(y||"See screenshot",O.base64),a())}const L=d&&x?{left:Math.min(d.x,x.x),top:Math.min(d.y,x.y),width:Math.abs(x.x-d.x),height:Math.abs(x.y-d.y)}:null,q=k.useCallback(Q=>{if(!Q||!o.current)return{};const S=o.current.clientHeight,z=o.current.clientWidth,E=S-(Q.y+Q.h+8),R=200,J=E<R&&Q.y>R;return{left:Math.max(8,Math.min(Q.x,z-300)),top:J?Q.y-R-8:Q.y+Q.h+8}},[]);return e.jsxs("div",{ref:o,className:"absolute inset-0 z-30",style:{cursor:O?"default":"crosshair"},onMouseDown:N,onMouseMove:j,onMouseUp:_,children:[e.jsx("div",{className:"absolute inset-0 bg-info/10 pointer-events-none"}),L&&!O&&e.jsx("div",{className:"absolute border-2 border-dashed border-accent bg-accent/5 pointer-events-none",style:L}),w&&e.jsx("div",{className:"absolute pointer-events-none animate-capture-flash rounded",style:{left:w.x,top:w.y,width:w.w,height:w.h}}),O&&e.jsx("div",{className:"absolute border-2 border-accent rounded pointer-events-none",style:{left:O.rect.x,top:O.rect.y,width:O.rect.w,height:O.rect.h}}),O&&e.jsxs("div",{className:"absolute z-40 w-72 bg-surface-2 border border-border rounded-lg shadow-2xl animate-chat-fade-in",style:q(O.rect),children:[e.jsx("div",{className:"p-3 border-b border-border-subtle",children:O.loading?e.jsx("div",{className:"w-full h-24 rounded border border-border-subtle bg-surface-0 flex items-center justify-center",children:e.jsx(Le,{size:20,className:"text-accent animate-spin"})}):e.jsx("img",{src:O.base64,alt:"Screenshot",className:"w-full h-auto rounded border border-border-subtle max-h-32 object-contain bg-surface-0"})}),e.jsxs("div",{className:"p-3 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:Q=>b(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&$()},placeholder:"Describe what to change...",className:"flex-1 h-8 px-3 rounded-md bg-surface-1 border border-border-subtle text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:border-accent/40",autoFocus:!0}),e.jsx("button",{onClick:$,disabled:O.loading,className:"w-8 h-8 flex items-center justify-center rounded-md bg-accent/15 text-accent hover:bg-accent/25 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(fn,{size:14})}),e.jsx("button",{onClick:()=>a(),className:"w-8 h-8 flex items-center justify-center rounded-md text-text-3 hover:text-text-1 hover:bg-surface-4 transition-colors cursor-pointer",children:e.jsx(Ge,{size:14})})]})]}),!O&&!c&&e.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 px-3 py-1.5 rounded-full bg-surface-0/90 border border-border-subtle text-2xs text-text-2 font-sans pointer-events-none",children:"Click and drag to select a region · Esc to cancel"})]})}function Pze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*)/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3),l=c.indexOf(`
|
|
8609
|
+
`)})}return s}function z1({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|~~[^~]+~~|\[([^\]]+)\]\(([^)]+)\))/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("`")&&s.endsWith("`")&&!s.startsWith("``"))return e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o);if(s.startsWith("**")&&s.endsWith("**"))return e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o);if(s.startsWith("*")&&s.endsWith("*")&&!s.startsWith("**"))return e.jsx("em",{className:"italic",children:s.slice(1,-1)},o);if(s.startsWith("~~")&&s.endsWith("~~"))return e.jsx("del",{className:"line-through text-text-3",children:s.slice(2,-2)},o);const c=s.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return c?e.jsx("a",{href:c[2],target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:c[1]},o):e.jsx("span",{children:s},o)})})}function Oze({text:t}){const a=kze(t);return e.jsx("div",{className:"space-y-2",children:a.map((s,o)=>{switch(s.type){case"code":return e.jsx(gze,{language:s.language,code:s.code},o);case"heading":{const c=["text-lg font-bold","text-base font-bold","text-sm font-semibold","text-sm font-semibold","text-xs font-semibold","text-xs font-semibold"];return e.jsx("div",{className:G(c[s.level-1]||c[0],"text-text-0 font-sans mt-3 mb-1"),children:e.jsx(z1,{text:s.text})},o)}case"hr":return e.jsx("hr",{className:"border-border-subtle my-3"},o);case"blockquote":return e.jsx("div",{className:"border-l-2 border-accent/40 pl-3 py-1 text-sm text-text-2 italic font-sans",children:e.jsx(z1,{text:s.text})},o);case"ul":return e.jsx("ul",{className:"list-disc list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"ol":return e.jsx("ol",{className:"list-decimal list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"table":return e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsxs("table",{className:"text-xs font-sans border-collapse w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border",children:s.headers.map((c,l)=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-text-0",children:c},l))})}),e.jsx("tbody",{children:s.rows.map((c,l)=>e.jsx("tr",{className:"border-b border-border-subtle",children:c.map((d,p)=>e.jsx("td",{className:"px-3 py-1.5 text-text-0",children:e.jsx(z1,{text:d})},p))},l))})]})},o);case"paragraph":return e.jsx("p",{className:"text-sm text-text-0 font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.jsx(z1,{text:s.text})},o);default:return null}})})}function vze({msg:t}){return e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-br-md bg-accent/10 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.text})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function bze({msg:t,model:a,role:s}){const o=yze(t.text),c=a||"Assistant",l=s||"chat";return e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx(mze,{name:c,role:l,size:"sm",className:"mt-1 flex-shrink-0"}),e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"text-2xs text-text-3 font-sans mb-1 font-medium",children:c}),e.jsx("div",{className:"border-l-2 border-accent/40 pl-3.5 py-1",children:e.jsx("div",{className:"text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed",children:e.jsx(Oze,{text:o})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})]})}function wze({msg:t}){return e.jsx("div",{className:"max-w-[85%]",children:e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsx("div",{className:"w-80 h-80 image-loading-shimmer flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-3/80 flex items-center justify-center",children:e.jsx(hn,{size:18,className:"text-accent animate-pulse"})}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Generating image..."})]})}),t.prompt&&e.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:e.jsxs("p",{className:"text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']})})]})})}function jze({msg:t,onReply:a}){const[s,o]=k.useState(!1),[c,l]=k.useState(!1),d=k.useCallback(()=>{if(!t.imageUrl)return;const p=document.createElement("a");p.href=t.imageUrl,p.download=`groove-${t.model||"image"}-${Date.now()}.png`,document.body.appendChild(p),p.click(),document.body.removeChild(p)},[t.imageUrl,t.model]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[85%]",children:[t.model&&e.jsxs("div",{className:"text-2xs text-text-3 font-mono mb-1.5 font-medium flex items-center gap-1.5",children:[e.jsx(hn,{size:10})," ",t.model]}),e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsxs("div",{className:"relative group",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-full max-h-[480px] object-contain cursor-pointer",onClick:()=>o(!0)}),c&&e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1.5",children:[e.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Download",children:e.jsx(oa,{size:14})}),e.jsx("button",{onClick:()=>o(!0),className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Fullscreen",children:e.jsx(wd,{size:14})}),e.jsx(AG,{text:t.prompt||"",className:"h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle text-text-2 hover:text-accent"})]})]}),e.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center gap-2",children:[e.jsxs("p",{className:"flex-1 text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']}),a&&e.jsxs("button",{onClick:()=>a(t),className:"text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer flex items-center gap-1 flex-shrink-0",children:[e.jsx(Zt,{size:10})," Iterate"]})]})]}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[200] bg-surface-0/95 backdrop-blur-md flex items-center justify-center",onClick:()=>o(!1),children:[e.jsx("button",{onClick:()=>o(!1),className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-surface-3 border border-border flex items-center justify-center text-text-2 hover:text-text-0 transition-colors cursor-pointer z-10",children:e.jsx(Ge,{size:18})}),e.jsx("div",{className:"absolute bottom-4 right-4 flex gap-2 z-10",children:e.jsxs("button",{onClick:p=>{p.stopPropagation(),d()},className:"h-9 px-4 rounded-lg bg-surface-3 border border-border flex items-center gap-2 text-xs font-sans text-text-1 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",children:[e.jsx(oa,{size:14})," Download"]})}),e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:p=>p.stopPropagation()}),t.prompt&&e.jsx("div",{className:"absolute bottom-4 left-4 max-w-md px-4 py-2 rounded-lg bg-surface-3/90 backdrop-blur-sm border border-border-subtle z-10",children:e.jsxs("p",{className:"text-xs text-text-2 font-sans italic",children:['"',t.prompt,'"']})})]})]})}function Mze({msg:t}){return e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-surface-4/50",children:[e.jsx(Do,{size:10,className:"text-text-4"}),e.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.text})]})})}function Nze(){return e.jsx("div",{className:"flex flex-col items-center justify-center h-full text-center py-16",children:e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Send a message to start"})})}function Sze(){const[t,a]=k.useState(0),[s,o]=k.useState(!0);return k.useEffect(()=>{const c=setInterval(()=>{o(!1),setTimeout(()=>{a(l=>(l+1)%PD.length),o(!0)},250)},2800);return()=>clearInterval(c)},[]),e.jsxs("div",{className:"flex items-center gap-2.5 ml-8 py-1",children:[e.jsx("div",{className:"relative w-3.5 h-3.5 flex-shrink-0",children:e.jsx("span",{className:"absolute inset-0 rounded-full border border-transparent border-t-accent animate-spin",style:{animationDuration:"0.9s"}})}),e.jsx("span",{className:"text-2xs font-sans text-text-3 transition-opacity duration-[250ms]",style:{opacity:s?1:0},children:PD[t]})]})}function _ze({messages:t,isStreaming:a,model:s,mode:o,onImageReply:c,role:l}){const d=k.useRef(null),p=k.useRef(!0);return k.useEffect(()=>{const x=d.current;if(!x)return;function m(){p.current=x.scrollHeight-x.scrollTop-x.clientHeight<50}return x.addEventListener("scroll",m),()=>x.removeEventListener("scroll",m)},[]),k.useEffect(()=>{p.current&&d.current&&(d.current.scrollTop=d.current.scrollHeight)},[t==null?void 0:t.length,a]),!t||t.length===0?e.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.jsx(Nze,{})}):e.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[t.map((x,m)=>x.type==="image-loading"?e.jsx(wze,{msg:x},m):x.type==="image"?e.jsx(jze,{msg:x,onReply:c},m):x.from==="user"?e.jsx(vze,{msg:x},m):x.from==="system"?e.jsx(Mze,{msg:x},m):e.jsx(bze,{msg:x,model:s,role:l},m)),a&&(o==="agent"?e.jsx(PG,{className:"py-1"}):e.jsx(Sze,{}))]})}function AD({onSend:t,onStop:a,sending:s,streaming:o,disabled:c,isImageModel:l,currentModel:d,replyContext:p,onClearReply:x,role:m}){const[O,f]=k.useState(""),y=k.useRef(null),b=k.useRef(null),w=k.useCallback(()=>{const q=y.current;q&&(q.style.height="auto",q.style.height=Math.min(q.scrollHeight,200)+"px")},[]);k.useEffect(()=>{w()},[O,w]),k.useEffect(()=>{!c&&y.current&&y.current.focus()},[c]);function M(){const q=O.trim();!q||s||c||(t(q),f(""),y.current&&(y.current.style.height="auto"))}function N(q){q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),M())}function j(q){const Q=Array.from(q.target.files||[]);if(Q.length===0)return;const S=Q.map(z=>z.name).join(", ");f(z=>z+(z?`
|
|
8610
|
+
`:"")+`[Attached: ${S}]`),q.target.value=""}const _=o||s,$=O.trim()&&!s&&!c,L=c?"Select a model to start chatting...":l?"Describe the image you want to generate...":m?`Ask your ${m}...`:"Send a message...";return e.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 bg-surface-1",children:[p&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-2 rounded-lg bg-accent/5 border border-accent/15",children:[e.jsx(hn,{size:12,className:"text-accent flex-shrink-0"}),e.jsxs("span",{className:"flex-1 text-2xs text-text-2 font-sans truncate",children:['Iterating: "',p.prompt,'"']}),e.jsx("button",{onClick:x,className:"text-text-4 hover:text-text-1 cursor-pointer flex-shrink-0",children:e.jsx(Cd,{size:10})})]}),d&&e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:G("flex items-center gap-1 h-6 px-2 rounded-md text-2xs font-mono border",l?"bg-purple/8 border-purple/20 text-purple":"bg-surface-3 border-border-subtle text-text-3"),children:[l&&e.jsx(hn,{size:9}),e.jsx("span",{className:"max-w-[80px] truncate",children:PA(d)})]})}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("input",{ref:b,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:j,className:"hidden"}),e.jsx("button",{onClick:()=>{var q;return(q=b.current)==null?void 0:q.click()},disabled:c,className:"w-10 h-10 flex items-center justify-center rounded-xl text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed flex-shrink-0",title:"Attach file",children:e.jsx(K1,{size:16})}),e.jsx("textarea",{ref:y,value:O,onChange:q=>f(q.target.value),onKeyDown:N,placeholder:L,disabled:c,rows:1,className:G("flex-1 resize-y rounded-xl px-4 py-2.5 text-sm","bg-surface-0 border text-text-0 font-sans","placeholder:text-text-4","focus:outline-none focus:ring-1","min-h-[40px]","border-border focus:ring-accent/40","disabled:opacity-50 disabled:cursor-not-allowed")}),_?e.jsx("button",{onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-xl bg-danger/80 text-white hover:bg-danger transition-all cursor-pointer shadow-lg shadow-danger/20 flex-shrink-0",title:"Stop generation",children:e.jsx(Cd,{size:14,fill:"currentColor"})}):e.jsx("button",{onClick:M,disabled:!$,className:G("w-10 h-10 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",$?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:s?e.jsx(Le,{size:16,className:"animate-spin"}):e.jsx(fn,{size:16})})]})]})}function Cze({onNewChat:t}){return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-1 font-sans",children:"Groove Chat"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Every provider, every model, full project context."}),e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 h-9 px-5 rounded-lg bg-accent/15 text-accent text-sm font-semibold font-sans hover:bg-accent/25 transition-colors cursor-pointer border border-accent/20",children:[e.jsx(ct,{size:14}),"New Chat"]})]})})}function $ze(){const t=P(T=>T.conversations),a=P(T=>T.activeConversationId),s=P(T=>T.conversationMessages),o=P(T=>T.sendingMessage),c=P(T=>T.streamingConversationId),l=P(T=>T.createConversation);P(T=>T.setActiveConversation);const d=P(T=>T.sendChatMessage),p=P(T=>T.sendImageMessage),x=P(T=>T.stopAgent),m=P(T=>T.stopChatStreaming),O=P(T=>T.setConversationMode),f=P(T=>T.setConversationModel),y=P(T=>T.conversationRoles),b=P(T=>T.setConversationRole),[w,M]=k.useState(!1),[N,j]=k.useState(null),_=a&&(y==null?void 0:y[a])||null,$=t.find(T=>T.id===a)||null,L=a?s[a]||[]:[],q=c===a&&o,Q=$?iL($.model):!1,S=k.useCallback(async(T,A)=>{const X=T||"claude-code",B=A||"claude-sonnet-4-6";try{await l(X,B,"api")}catch{}},[l]),z=k.useCallback(T=>{a&&O(a,T)},[a,O]),E=k.useCallback(T=>{a&&b(a,T)},[a,b]),R=k.useCallback(T=>{if(a)if(Q){const A=N?`${T} (iterating on: "${N.prompt}")`:T;p(a,A,{model:$.model}),j(null)}else d(a,T)},[a,$,Q,N,d,p]),J=k.useCallback(()=>{$&&($.mode==="agent"&&$.agentId?x($.agentId):m(a))},[$,a,x,m]),ae=k.useCallback(async T=>{a?await f(a,T.provider,T.model):await S(T.provider,T.model)},[a,f,S]),ce=k.useCallback(T=>{j(T)},[]),V=$?{provider:$.provider,model:$.model}:null;return e.jsxs("div",{className:"flex h-full bg-surface-0",children:[e.jsx("div",{className:G("flex-shrink-0 border-r border-accent/12 bg-surface-1 transition-all duration-200 overflow-hidden",w?"w-0":"w-64"),children:e.jsx(pze,{onNewChat:()=>S()})}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx(xze,{conversation:$,model:V,onModelChange:ae,onModeChange:z,role:_,onRoleChange:E}),e.jsx(_ze,{messages:L,isStreaming:q,model:$.model,mode:$.mode||"api",onImageReply:ce,role:_}),e.jsx(AD,{onSend:R,onStop:J,sending:o,streaming:q,disabled:!1,isImageModel:Q,currentModel:$.model,replyContext:N,onClearReply:()=>j(null),role:_})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cze,{onNewChat:()=>S()}),e.jsx(AD,{onSend:T=>{S().then(()=>{setTimeout(()=>{const A=P.getState().activeConversationId;A&&d(A,T)},500)})},onStop:()=>{},sending:!1,streaming:!1,disabled:!1,isImageModel:!1,currentModel:null})]})})]})}function Lze(){return e.jsx($ze,{})}const Qze=[{id:"desktop",icon:Bo,label:"Desktop",width:"100%"},{id:"tablet",icon:U0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:Z0,label:"Mobile (375px)",width:"375px"}];function zze({onRefresh:t}){const a=P(O=>O.previewState),s=P(O=>O.setPreviewDevice),o=P(O=>O.toggleScreenshotMode),c=P(O=>O.closePreview),[l,d]=k.useState(!1),p=k.useRef(null);k.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);function x(){l?(p.current&&clearTimeout(p.current),d(!1),c()):(d(!0),p.current=setTimeout(()=>d(!1),2e3))}const m=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return e.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[e.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:e.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:m||"No URL"})}),e.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:e.jsx(Zt,{size:14})}),e.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:Qze.map(O=>e.jsx("button",{onClick:()=>s(O.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===O.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:O.label,children:e.jsx(O.icon,{size:13})},O.id))}),e.jsx("button",{onClick:o,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:e.jsx(D1,{size:14})}),e.jsx("button",{onClick:x,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",l?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:l?e.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):e.jsx(Ge,{size:14})})]})}function Tze({iframeRef:t}){const a=P(Q=>Q.toggleScreenshotMode),s=P(Q=>Q.iteratePreview),o=k.useRef(null),[c,l]=k.useState(!1),[d,p]=k.useState(null),[x,m]=k.useState(null),[O,f]=k.useState(null),[y,b]=k.useState(""),[w,M]=k.useState(null),N=k.useCallback(Q=>{if(O)return;const S=o.current.getBoundingClientRect();p({x:Q.clientX-S.left,y:Q.clientY-S.top}),m(null),l(!0)},[O]),j=k.useCallback(Q=>{if(!c||O)return;const S=o.current.getBoundingClientRect();m({x:Q.clientX-S.left,y:Q.clientY-S.top})},[c,O]),_=k.useCallback(()=>{if(!c||!d||!x){l(!1);return}l(!1);const Q={x:Math.min(d.x,x.x),y:Math.min(d.y,x.y),w:Math.abs(x.x-d.x),h:Math.abs(x.y-d.y)};if(Q.w<10||Q.h<10){p(null),m(null);return}f({base64:null,rect:Q,loading:!0});function S(E){f({base64:E,rect:Q,loading:!1}),M(Q),setTimeout(()=>M(null),600)}function z(){const E=document.createElement("canvas"),R=window.devicePixelRatio||1;E.width=Q.w*R,E.height=Q.h*R;const J=E.getContext("2d");return J.scale(R,R),J.fillStyle="#1e2127",J.fillRect(0,0,Q.w,Q.h),J.strokeStyle="#3e4451",J.lineWidth=1,J.strokeRect(4,4,Q.w-8,Q.h-8),J.fillStyle="#6e7681",J.font="12px Inter, sans-serif",J.textAlign="center",J.textBaseline="middle",J.fillText(`${Math.round(Q.w)} × ${Math.round(Q.h)}`,Q.w/2,Q.h/2),E.toDataURL("image/png")}try{const E=t.current;if(!E){S(z());return}const R=document.createElement("canvas"),J=window.devicePixelRatio||1;R.width=Q.w*J,R.height=Q.h*J;const ae=R.getContext("2d");ae.scale(J,J);const ce=E.getBoundingClientRect(),V=o.current.getBoundingClientRect(),T=Q.x-(ce.left-V.left),A=Q.y-(ce.top-V.top);try{ae.drawImage(E,-T*J,-A*J,ce.width*J,ce.height*J,0,0,Q.w,Q.h);const X=ae.getImageData(0,0,1,1).data;if(X[0]===0&&X[1]===0&&X[2]===0&&X[3]===0)throw new Error("blank");S(R.toDataURL("image/png"))}catch{S(z())}}catch{p(null),m(null),f(null)}},[c,d,x,t]);k.useEffect(()=>{function Q(S){S.key==="Escape"&&a()}return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[a]);function $(){!O||O.loading||(s(y||"See screenshot",O.base64),a())}const L=d&&x?{left:Math.min(d.x,x.x),top:Math.min(d.y,x.y),width:Math.abs(x.x-d.x),height:Math.abs(x.y-d.y)}:null,q=k.useCallback(Q=>{if(!Q||!o.current)return{};const S=o.current.clientHeight,z=o.current.clientWidth,E=S-(Q.y+Q.h+8),R=200,J=E<R&&Q.y>R;return{left:Math.max(8,Math.min(Q.x,z-300)),top:J?Q.y-R-8:Q.y+Q.h+8}},[]);return e.jsxs("div",{ref:o,className:"absolute inset-0 z-30",style:{cursor:O?"default":"crosshair"},onMouseDown:N,onMouseMove:j,onMouseUp:_,children:[e.jsx("div",{className:"absolute inset-0 bg-info/10 pointer-events-none"}),L&&!O&&e.jsx("div",{className:"absolute border-2 border-dashed border-accent bg-accent/5 pointer-events-none",style:L}),w&&e.jsx("div",{className:"absolute pointer-events-none animate-capture-flash rounded",style:{left:w.x,top:w.y,width:w.w,height:w.h}}),O&&e.jsx("div",{className:"absolute border-2 border-accent rounded pointer-events-none",style:{left:O.rect.x,top:O.rect.y,width:O.rect.w,height:O.rect.h}}),O&&e.jsxs("div",{className:"absolute z-40 w-72 bg-surface-2 border border-border rounded-lg shadow-2xl animate-chat-fade-in",style:q(O.rect),children:[e.jsx("div",{className:"p-3 border-b border-border-subtle",children:O.loading?e.jsx("div",{className:"w-full h-24 rounded border border-border-subtle bg-surface-0 flex items-center justify-center",children:e.jsx(Le,{size:20,className:"text-accent animate-spin"})}):e.jsx("img",{src:O.base64,alt:"Screenshot",className:"w-full h-auto rounded border border-border-subtle max-h-32 object-contain bg-surface-0"})}),e.jsxs("div",{className:"p-3 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:Q=>b(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&$()},placeholder:"Describe what to change...",className:"flex-1 h-8 px-3 rounded-md bg-surface-1 border border-border-subtle text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:border-accent/40",autoFocus:!0}),e.jsx("button",{onClick:$,disabled:O.loading,className:"w-8 h-8 flex items-center justify-center rounded-md bg-accent/15 text-accent hover:bg-accent/25 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(fn,{size:14})}),e.jsx("button",{onClick:()=>a(),className:"w-8 h-8 flex items-center justify-center rounded-md text-text-3 hover:text-text-1 hover:bg-surface-4 transition-colors cursor-pointer",children:e.jsx(Ge,{size:14})})]})]}),!O&&!c&&e.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 px-3 py-1.5 rounded-full bg-surface-0/90 border border-border-subtle text-2xs text-text-2 font-sans pointer-events-none",children:"Click and drag to select a region · Esc to cancel"})]})}function Pze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*)/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3),l=c.indexOf(`
|
|
8611
8611
|
`),d=l>=0?c.slice(l+1):c;return e.jsx("pre",{className:"my-2 px-3 py-2 rounded-lg bg-surface-0 border border-border-subtle overflow-x-auto",children:e.jsx("code",{className:"text-xs font-mono text-text-1 whitespace-pre",children:d})},o)}return s.startsWith("`")&&s.endsWith("`")?e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o):s.startsWith("**")&&s.endsWith("**")?e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o):s.startsWith("*")&&s.endsWith("*")?e.jsx("em",{className:"italic",children:s.slice(1,-1)},o):e.jsx("span",{children:s},o)})})}function Aze({msg:t}){return t.role==="user"?e.jsx("div",{className:"flex justify-end animate-chat-fade-in",children:e.jsxs("div",{className:"max-w-[85%]",children:[t.screenshot&&e.jsx("img",{src:t.screenshot,alt:"Screenshot",className:"mb-2 rounded-lg border border-border-subtle max-h-40 object-contain"}),e.jsx("div",{className:"px-4 py-3 rounded-2xl rounded-br-md bg-gradient-to-br from-accent/12 to-accent/6 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.content})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})}):e.jsxs("div",{className:"max-w-[85%] animate-chat-fade-in",children:[e.jsx("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle px-4 py-3",children:e.jsx("p",{className:"text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed",children:e.jsx(Pze,{text:t.content})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})}function Ize(){const t=P(y=>y.previewChat),a=P(y=>y.previewState),s=P(y=>y.iteratePreview),o=P(y=>y.previewIterating),[c,l]=k.useState(""),d=k.useRef(null),p=k.useRef(null),x=k.useRef(!0);k.useEffect(()=>{const y=d.current;if(!y)return;function b(){x.current=y.scrollHeight-y.scrollTop-y.clientHeight<50}return y.addEventListener("scroll",b),()=>y.removeEventListener("scroll",b)},[]),k.useEffect(()=>{x.current&&d.current&&(d.current.scrollTop=d.current.scrollHeight)},[t==null?void 0:t.length]);const m=k.useCallback(()=>{const y=p.current;y&&(y.style.height="auto",y.style.height=Math.min(y.scrollHeight,160)+"px")},[]);k.useEffect(()=>{m()},[c,m]);function O(){const y=c.trim();!y||o||(s(y),l(""),p.current&&(p.current.style.height="auto"))}function f(y){y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),O())}return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0",children:[e.jsx("div",{className:"flex-shrink-0 h-10 flex items-center px-4 border-b border-border bg-surface-3",children:e.jsx("span",{className:"text-xs font-semibold text-text-1 font-sans",children:"Iterate"})}),e.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent/5 border-b border-accent/10",children:e.jsxs("p",{className:"text-2xs text-accent font-sans",children:["Iterating on ",e.jsx("span",{className:"font-semibold",children:a.teamId||"project"})," — changes auto-refresh via hot reload"]})}),e.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[t.length===0&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"max-w-xs w-full px-5 py-5 bg-surface-1 border border-border-subtle rounded-xl text-center",children:[e.jsx(pn,{size:24,className:"mx-auto text-accent mb-3"}),e.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-3",children:"Preview is live!"}),e.jsxs("ul",{className:"text-left space-y-2 text-2xs text-text-2 font-sans",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx(fn,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Type a message to request changes — your feedback goes to the team planner who routes it to the right agent"})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx(D1,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Use the camera icon to screenshot a specific area and annotate it"})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx(Zt,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Changes auto-refresh via hot module reload"})]})]})]})}),t.map((y,b)=>e.jsx(Aze,{msg:y},b)),o&&e.jsx("div",{className:"max-w-[85%] animate-chat-fade-in",children:e.jsx("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{size:14,className:"text-accent animate-spin"}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Routing to planner..."})]})})})]}),e.jsx("div",{className:"flex-shrink-0 px-3 py-3 border-t border-border",children:e.jsxs("div",{className:"flex items-end gap-2 rounded-2xl bg-surface-1/80 border border-accent/8 px-3 py-2",children:[e.jsx("textarea",{ref:p,value:c,onChange:y=>l(y.target.value),onKeyDown:f,placeholder:"Describe changes...",rows:1,style:{minHeight:"36px"},className:"flex-1 resize-none bg-transparent text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none py-1.5"}),e.jsx("button",{onClick:O,disabled:!c.trim()||o,className:G("w-9 h-9 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",c.trim()&&!o?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:e.jsx(fn,{size:16})})]})})]})}function qze(){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-surface-0",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx(E0,{size:40,className:"mx-auto text-text-4"}),e.jsx("h2",{className:"text-lg font-semibold text-text-1 font-sans",children:"No preview active"}),e.jsx("p",{className:"text-sm text-text-3 font-sans max-w-xs",children:"Build a project with a planner team to see it here."})]})})}const Rze={desktop:"100%",tablet:"768px",mobile:"375px"};function Eze(){const t=P(x=>x.previewState),a=k.useRef(null),[s,o]=k.useState(0),c=k.useCallback(()=>{o(x=>x+1)},[]);if(!t.url)return e.jsx(qze,{});const l=t.teamId?`/api/preview/${t.teamId}/proxy/`:t.url,d=Rze[t.deviceSize]||"100%",p=t.deviceSize==="desktop";return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0 md:flex-row",children:[e.jsxs("div",{className:"flex flex-col flex-[3] min-w-0 min-h-0",children:[e.jsx(zze,{onRefresh:c}),e.jsxs("div",{className:"flex-1 relative overflow-hidden bg-surface-1",children:[t.screenshotMode&&e.jsx(Tze,{iframeRef:a}),e.jsx("div",{className:G("h-full transition-all duration-200",p?"w-full":"mx-auto"),style:p?void 0:{width:d,maxWidth:"100%"},children:e.jsx("iframe",{ref:a,src:l,title:"Preview",className:"w-full h-full border-0 bg-white",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},s)})]})]}),e.jsx("div",{className:"flex-[2] min-w-[280px] max-w-[480px] border-l border-border md:max-w-none md:flex-[2]",children:e.jsx(Ize,{})})]})}function Vze(){return e.jsx(Eze,{})}const zP=[];function IG(t){const a=(t||"").toLowerCase();return a.includes("reading")||a.includes("read ")?{icon:Yt,color:"text-info",label:"Reading"}:a.includes("editing")||a.includes("wrote")||a.includes("writing")||a.includes("edit ")?{icon:Vs,color:"text-warning",label:"Editing"}:a.includes("searching")||a.includes("search")||a.includes("grep")||a.includes("glob")?{icon:Ut,color:"text-purple",label:"Searching"}:a.includes("running")||a.includes("bash")||a.includes("command")||a.includes("exec")?{icon:Bs,color:"text-orange",label:"Running"}:a.includes("test")||a.includes("pass")?{icon:Mn,color:"text-success",label:"Testing"}:a.includes("error")||a.includes("fail")||a.includes("crash")?{icon:Ct,color:"text-danger",label:"Error"}:a.includes("rotat")?{icon:Gs,color:"text-accent",label:"Rotating"}:a.includes("spawn")||a.includes("start")?{icon:kt,color:"text-success",label:"Spawned"}:a.includes("tool")||a.includes("function")?{icon:F0,color:"text-text-2",label:"Tool"}:a.includes("complet")||a.includes("done")||a.includes("finish")?{icon:Mn,color:"text-success",label:"Done"}:{icon:fa,color:"text-text-3",label:"Activity"}}function P1({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((a,s)=>a.startsWith("**")&&a.endsWith("**")?e.jsx("strong",{className:"font-semibold text-text-0",children:a.slice(2,-2)},s):a.startsWith("`")&&a.endsWith("`")?e.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:a.slice(1,-1)},s):e.jsx("span",{children:a},s)):null}function Dze({text:t}){if(!t)return null;const a=[],s=t.split(`
|
|
8612
8612
|
`);let o=0;for(;o<s.length;){const c=s[o];if(c.trimStart().startsWith("```")){const d=[],p=c.trim().slice(3);for(o++;o<s.length&&!s[o].trimStart().startsWith("```");)d.push(s[o]),o++;o++,a.push({type:"code",content:d.join(`
|
|
8613
8613
|
`),lang:p});continue}if(/^#{1,3}\s/.test(c)||/^\*\*[^*]+:\*\*\s*$/.test(c.trim())){const d=c.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();a.push({type:"heading",content:d}),o++;continue}if(/^\s*[-*]\s/.test(c)){const d=[];for(;o<s.length&&/^\s*[-*]\s/.test(s[o]);)d.push(s[o].replace(/^\s*[-*]\s+/,"").trim()),o++;a.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(c)){const d=[];for(;o<s.length&&/^\s*\d+[\.)]\s/.test(s[o]);)d.push(s[o].replace(/^\s*\d+[\.)]\s+/,"").trim()),o++;a.push({type:"numbered",items:d});continue}if(!c.trim()){o++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(c.trim())){a.push({type:"note",content:c.trim()}),o++;continue}const l=[];for(;o<s.length&&s[o].trim()&&!/^#{1,3}\s/.test(s[o])&&!/^\s*[-*]\s/.test(s[o])&&!/^\s*\d+[\.)]\s/.test(s[o])&&!s[o].trimStart().startsWith("```");)l.push(s[o].trim()),o++;l.length>0&&a.push({type:"para",content:l.join(" ")})}return e.jsx("div",{className:"space-y-2",children:a.map((c,l)=>{switch(c.type){case"heading":return e.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[e.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),e.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:e.jsx(P1,{text:c.content})})]},l);case"list":return e.jsx("div",{className:"space-y-1 pl-2",children:c.items.map((d,p)=>e.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[e.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),e.jsx("span",{className:"min-w-0",children:e.jsx(P1,{text:d})})]},p))},l);case"numbered":return e.jsx("div",{className:"space-y-1 pl-2",children:c.items.map((d,p)=>e.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[e.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[p+1,"."]}),e.jsx("span",{className:"min-w-0",children:e.jsx(P1,{text:d})})]},p))},l);case"code":return e.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:c.content},l);case"note":return e.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[e.jsx(Ct,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:e.jsx(P1,{text:c.content})})]},l);case"para":default:return e.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:e.jsx(P1,{text:c.content})},l)}})})}function Xze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```)/g);return e.jsx("span",{children:a.map((s,o)=>{if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3).replace(/^\w+\n/,"");return e.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:c},o)}return e.jsx("span",{children:e.jsx(P1,{text:s})},o)})})}function Zze({msg:t}){const a=t.isQuery;return e.jsx("div",{className:"flex justify-end pl-8",children:e.jsxs("div",{className:"max-w-[90%]",children:[a&&e.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[e.jsx(na,{size:9,className:"text-info"}),e.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),e.jsx("div",{className:G("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:e.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:e.jsx(Xze,{text:t.text})})}),e.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function Uze({msg:t,agent:a}){var l,d;const[s,o]=k.useState(((l=t.text)==null?void 0:l.length)>600),c=((d=t.text)==null?void 0:d.length)>600;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(a==null?void 0:a.name)||"Agent"}),e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:a==null?void 0:a.role}),e.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:xt(t.timestamp)})]}),e.jsx("div",{className:"border-l border-accent pl-3.5 py-1",children:e.jsx(Dze,{text:s?t.text.slice(0,600)+"...":t.text})}),s&&e.jsxs("button",{onClick:()=>o(!1),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[e.jsx($t,{size:11}),"Show full response"]}),c&&!s&&e.jsxs("button",{onClick:()=>o(!0),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[e.jsx($t,{size:11,className:"rotate-180"}),"Collapse"]})]})}function Hze({msg:t}){return e.jsxs("div",{className:"flex items-center gap-3 py-2",children:[e.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),e.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),e.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function Gze({entries:t,isLive:a}){var d;const[s,o]=k.useState(0);if(k.useEffect(()=>{if(!a||t.length<=1)return;const p=setInterval(()=>o(x=>(x+1)%t.length),1500);return()=>clearInterval(p)},[t.length,a]),!a){const p=t[t.length-1],m=IG(p.text).icon;return e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 text-[10px] text-text-4 font-mono",children:[e.jsx(m,{size:10,className:"opacity-50"}),e.jsxs("span",{children:[t.length," tool call",t.length!==1?"s":""]})]})}const c=t[Math.min(s,t.length-1)],l=((d=c.text)==null?void 0:d.length)>60?c.text.slice(0,60)+"...":c.text;return e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 max-w-[280px] rounded-md bg-surface-3/50 border border-border-subtle/30",children:[e.jsx(Le,{size:11,className:"text-accent animate-spin flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate transition-opacity duration-300",children:l}),t.length>1&&e.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function Bze({agent:t}){const a=P(x=>x.activityLog[t.id])||zP,s=a[a.length-1],o=s?IG(s.text):null,c=(o==null?void 0:o.icon)||fa,l=s&&Date.now()-s.timestamp<1e4,d=l&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,p=Math.round((t.contextUsage||0)*100);return e.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),e.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),l?e.jsxs(e.Fragment,{children:[e.jsx(c,{size:10,className:G(o.color,"flex-shrink-0")}),e.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):e.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:Wze(t.tokensUsed)}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-14 h-0.5 rounded-sm bg-surface-4 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${p}%`,background:p>=75?"var(--color-danger)":p>=50?"var(--color-warning)":"var(--color-accent)"}})}),e.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[p,"%"]})]})]})]})}function Wze(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function Fze({agent:t}){const[a,s]=k.useState([]),o=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return k.useEffect(()=>{const c=o.map((l,d)=>setTimeout(()=>s(p=>[...p,d]),l.delay));return()=>c.forEach(clearTimeout)},[]),e.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsxs("div",{className:"relative w-9 h-9",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),e.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),e.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),e.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),e.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:o.map((c,l)=>{const d=a.includes(l),p=l===o.length-1;return e.jsxs("div",{className:G("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[e.jsx("span",{className:G("w-1 h-1 rounded-full flex-shrink-0",p&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),e.jsx("span",{className:G("text-[11px] font-mono",p&&d?"text-accent":"text-text-3"),children:c.text}),p&&d&&e.jsxs("span",{className:"flex gap-0.5 ml-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},l)})})]})}function Yze({agent:t}){const a=P(R=>R.chatHistory[t.id])||zP,s=P(R=>R.activityLog[t.id])||zP,o=P(R=>R.instructAgent),c=P(R=>R.queryAgent),l=P(R=>{var J;return(J=R.thinkingAgents)==null?void 0:J.has(t.id)}),d=P(R=>R.chatInputs[t.id]||""),p=R=>P.setState(J=>({chatInputs:{...J.chatInputs,[t.id]:R}})),x=d,m=p,[O,f]=k.useState("instruct"),[y,b]=k.useState(!1),[w,M]=k.useState(36),N=k.useRef(null),j=k.useRef(null),_=k.useRef(null),$=k.useRef(null),L=k.useCallback(R=>{R.preventDefault();const J=R.clientY,ae=w,ce=T=>M(Math.min(Math.max(36,ae-(T.clientY-J)),280)),V=()=>{window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",V)};window.addEventListener("mousemove",ce),window.addEventListener("mouseup",V)},[w]),q=k.useMemo(()=>{var A;const R=[],J=new Set;for(const X of a){const B=`${X.from}:${(A=X.text)==null?void 0:A.slice(0,100)}`;R.find(U=>{var pe;return U.kind==="chat"&&`${U.from}:${(pe=U.text)==null?void 0:pe.slice(0,100)}`===B&&Math.abs(U.ts-X.timestamp)<5e3})||(R.push({...X,kind:"chat",ts:X.timestamp}),J.add(X.text))}const ae=J,ce=s.slice(-30);for(const X of ce)(X.text||"").trim()&&!ae.has(X.text)&&R.push({...X,kind:"activity",ts:X.timestamp});R.sort((X,B)=>X.ts-B.ts);const V=[];let T=[];for(const X of R)X.kind==="activity"?T.push(X):(T.length>0&&(V.push({kind:"activity-group",entries:T}),T=[]),V.push(X));return T.length>0&&V.push({kind:"activity-group",entries:T}),V},[a,s]);k.useEffect(()=>{j.current&&requestAnimationFrame(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)})},[q.length]);async function Q(R){var V;const J=Array.from(R.target.files||[]);if(J.length===0)return;const ae=P.getState().addToast,ce=[];for(const T of J)try{const A=await new Promise((X,B)=>{const F=new FileReader;F.onload=()=>X(F.result.split(",")[1]),F.onerror=B,F.readAsDataURL(T)});await D.post(`/agents/${t.id}/upload`,{filename:T.name,content:A}),ce.push(T.name)}catch(A){ae("error",`Upload failed: ${T.name}`,A.message)}if(ce.length>0){const T=ce.join(", ");m(A=>(A?A+`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
8
|
<title>Groove GUI</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-BbDDgazC.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-C0HXlhrU.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-BQPfi37R.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-BBL3i_JW.js">
|
|
@@ -258,15 +258,17 @@ function UserMessage({ msg }) {
|
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
function AssistantMessage({ msg, model }) {
|
|
261
|
+
function AssistantMessage({ msg, model, role }) {
|
|
262
262
|
const cleanText = stripEmojis(msg.text);
|
|
263
|
+
const displayName = model || 'Assistant';
|
|
264
|
+
const avatarRole = role || 'chat';
|
|
263
265
|
return (
|
|
264
266
|
<div className="flex gap-2.5">
|
|
265
|
-
<Avatar name={
|
|
267
|
+
<Avatar name={displayName} role={avatarRole} size="sm" className="mt-1 flex-shrink-0" />
|
|
266
268
|
<div className="max-w-[85%]">
|
|
267
|
-
|
|
268
|
-
<div className="
|
|
269
|
-
<div className="text-sm text-text-
|
|
269
|
+
<div className="text-2xs text-text-3 font-sans mb-1 font-medium">{displayName}</div>
|
|
270
|
+
<div className="border-l-2 border-accent/40 pl-3.5 py-1">
|
|
271
|
+
<div className="text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed">
|
|
270
272
|
<RenderedMarkdown text={cleanText} />
|
|
271
273
|
</div>
|
|
272
274
|
</div>
|
|
@@ -454,7 +456,7 @@ function ApiTypingIndicator() {
|
|
|
454
456
|
);
|
|
455
457
|
}
|
|
456
458
|
|
|
457
|
-
export function ChatMessages({ messages, isStreaming, model, mode, onImageReply }) {
|
|
459
|
+
export function ChatMessages({ messages, isStreaming, model, mode, onImageReply, role }) {
|
|
458
460
|
const scrollRef = useRef(null);
|
|
459
461
|
const isAtBottomRef = useRef(true);
|
|
460
462
|
|
|
@@ -489,7 +491,7 @@ export function ChatMessages({ messages, isStreaming, model, mode, onImageReply
|
|
|
489
491
|
if (msg.type === 'image') return <ImageMessage key={i} msg={msg} onReply={onImageReply} />;
|
|
490
492
|
if (msg.from === 'user') return <UserMessage key={i} msg={msg} />;
|
|
491
493
|
if (msg.from === 'system') return <SystemMessage key={i} msg={msg} />;
|
|
492
|
-
return <AssistantMessage key={i} msg={msg} model={model} />;
|
|
494
|
+
return <AssistantMessage key={i} msg={msg} model={model} role={role} />;
|
|
493
495
|
})}
|
|
494
496
|
{isStreaming && (
|
|
495
497
|
mode === 'agent' ? (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groove-dev",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.86",
|
|
4
4
|
"description": "Open-source agent orchestration layer — the AI company OS. Local model agent engine (GGUF/Ollama/llama-server), HuggingFace model browser, MCP integrations (Slack, Gmail, Stripe, 15+), agent scheduling (cron), business roles (CMO, CFO, EA). GUI dashboard, multi-agent coordination, zero cold-start, infinite sessions. Works with Claude Code, Codex, Gemini CLI, Ollama, any local model.",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"author": "Groove Dev <hello@groovedev.ai> (https://groovedev.ai)",
|
|
@@ -739,6 +739,22 @@ For normal file edits within your scope, proceed without review.
|
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
if (this.daemon.trajectoryCapture) {
|
|
743
|
+
try {
|
|
744
|
+
if (status === 'completed') {
|
|
745
|
+
this.daemon.trajectoryCapture.onAgentComplete(agent.id, {
|
|
746
|
+
status: 'SUCCESS', exit_code: code || 0, signal,
|
|
747
|
+
});
|
|
748
|
+
} else {
|
|
749
|
+
this.daemon.trajectoryCapture.onAgentCrash(agent.id,
|
|
750
|
+
signal ? 'Killed by signal ' + signal : 'Exit status ' + status
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
const count = (this.daemon.state.get('training_sessions_captured') || 0) + 1;
|
|
754
|
+
this.daemon.state.set('training_sessions_captured', count);
|
|
755
|
+
} catch (e) { /* fail silent */ }
|
|
756
|
+
}
|
|
757
|
+
|
|
742
758
|
this.daemon.broadcast({ type: 'agent:exit', agentId: agent.id, code: code || 0, signal, status });
|
|
743
759
|
if (this.daemon.integrations) this.daemon.integrations.refreshMcpJson();
|
|
744
760
|
if (status === 'completed' && this.daemon.journalist) {
|
|
@@ -1888,6 +1904,13 @@ For normal file edits within your scope, proceed without review.
|
|
|
1888
1904
|
if (loop) {
|
|
1889
1905
|
await loop.stop();
|
|
1890
1906
|
this.handles.delete(agentId);
|
|
1907
|
+
if (this.daemon.trajectoryCapture) {
|
|
1908
|
+
try {
|
|
1909
|
+
this.daemon.trajectoryCapture.onAgentComplete(agentId, { status: 'STOPPED' });
|
|
1910
|
+
const count = (this.daemon.state.get('training_sessions_captured') || 0) + 1;
|
|
1911
|
+
this.daemon.state.set('training_sessions_captured', count);
|
|
1912
|
+
} catch (e) { /* fail silent */ }
|
|
1913
|
+
}
|
|
1891
1914
|
this.daemon.registry.update(agentId, { status: 'stopped', pid: null });
|
|
1892
1915
|
return;
|
|
1893
1916
|
}
|
|
@@ -8606,8 +8606,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${a.do
|
|
|
8606
8606
|
`),s=[];let o=0;for(;o<a.length;){const c=a[o];if(c.startsWith("```")){const p=c.slice(3).trim(),x=[];for(o++;o<a.length&&!a[o].startsWith("```");)x.push(a[o]),o++;o++,s.push({type:"code",language:p,code:x.join(`
|
|
8607
8607
|
`)});continue}const l=c.match(/^(#{1,6})\s+(.+)/);if(l){s.push({type:"heading",level:l[1].length,text:l[2]}),o++;continue}if(/^(-{3,}|_{3,}|\*{3,})$/.test(c.trim())){s.push({type:"hr"}),o++;continue}if(c.startsWith("> ")){const p=[c.slice(2)];for(o++;o<a.length&&a[o].startsWith("> ");)p.push(a[o].slice(2)),o++;s.push({type:"blockquote",text:p.join(`
|
|
8608
8608
|
`)});continue}if(/^[-*+]\s/.test(c)){const p=[c.replace(/^[-*+]\s/,"")];for(o++;o<a.length&&/^[-*+]\s/.test(a[o]);)p.push(a[o].replace(/^[-*+]\s/,"")),o++;s.push({type:"ul",items:p});continue}if(/^\d+\.\s/.test(c)){const p=[c.replace(/^\d+\.\s/,"")];for(o++;o<a.length&&/^\d+\.\s/.test(a[o]);)p.push(a[o].replace(/^\d+\.\s/,"")),o++;s.push({type:"ol",items:p});continue}if(c.includes("|")&&o+1<a.length&&/^\|?\s*[-:]+/.test(a[o+1])){const p=c.split("|").map(m=>m.trim()).filter(Boolean);o+=2;const x=[];for(;o<a.length&&a[o].includes("|");)x.push(a[o].split("|").map(m=>m.trim()).filter(Boolean)),o++;s.push({type:"table",headers:p,rows:x});continue}if(c.trim()===""){o++;continue}const d=[c];for(o++;o<a.length&&a[o].trim()!==""&&!a[o].startsWith("```")&&!a[o].startsWith("#")&&!/^[-*+]\s/.test(a[o])&&!/^\d+\.\s/.test(a[o])&&!a[o].startsWith("> ")&&!/^(-{3,}|_{3,}|\*{3,})$/.test(a[o].trim());)d.push(a[o]),o++;s.push({type:"paragraph",text:d.join(`
|
|
8609
|
-
`)})}return s}function z1({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|~~[^~]+~~|\[([^\]]+)\]\(([^)]+)\))/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("`")&&s.endsWith("`")&&!s.startsWith("``"))return e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o);if(s.startsWith("**")&&s.endsWith("**"))return e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o);if(s.startsWith("*")&&s.endsWith("*")&&!s.startsWith("**"))return e.jsx("em",{className:"italic",children:s.slice(1,-1)},o);if(s.startsWith("~~")&&s.endsWith("~~"))return e.jsx("del",{className:"line-through text-text-3",children:s.slice(2,-2)},o);const c=s.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return c?e.jsx("a",{href:c[2],target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:c[1]},o):e.jsx("span",{children:s},o)})})}function Oze({text:t}){const a=kze(t);return e.jsx("div",{className:"space-y-2",children:a.map((s,o)=>{switch(s.type){case"code":return e.jsx(gze,{language:s.language,code:s.code},o);case"heading":{const c=["text-lg font-bold","text-base font-bold","text-sm font-semibold","text-sm font-semibold","text-xs font-semibold","text-xs font-semibold"];return e.jsx("div",{className:G(c[s.level-1]||c[0],"text-text-0 font-sans mt-3 mb-1"),children:e.jsx(z1,{text:s.text})},o)}case"hr":return e.jsx("hr",{className:"border-border-subtle my-3"},o);case"blockquote":return e.jsx("div",{className:"border-l-2 border-accent/40 pl-3 py-1 text-sm text-text-2 italic font-sans",children:e.jsx(z1,{text:s.text})},o);case"ul":return e.jsx("ul",{className:"list-disc list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"ol":return e.jsx("ol",{className:"list-decimal list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"table":return e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsxs("table",{className:"text-xs font-sans border-collapse w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border",children:s.headers.map((c,l)=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-text-0",children:c},l))})}),e.jsx("tbody",{children:s.rows.map((c,l)=>e.jsx("tr",{className:"border-b border-border-subtle",children:c.map((d,p)=>e.jsx("td",{className:"px-3 py-1.5 text-text-0",children:e.jsx(z1,{text:d})},p))},l))})]})},o);case"paragraph":return e.jsx("p",{className:"text-sm text-text-0 font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.jsx(z1,{text:s.text})},o);default:return null}})})}function vze({msg:t}){return e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-br-md bg-accent/10 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.text})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function bze({msg:t,model:a}){const s=yze(t.text);return e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx(mze,{name:a||"assistant",role:"assistant",size:"sm",className:"mt-1 flex-shrink-0"}),e.jsxs("div",{className:"max-w-[85%]",children:[a&&e.jsx("div",{className:"text-2xs text-text-3 font-sans mb-1 font-medium",children:a}),e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-bl-md bg-surface-4 border border-border-subtle",children:e.jsx("div",{className:"text-sm text-text-0 font-sans leading-relaxed",children:e.jsx(Oze,{text:s})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})]})}function wze({msg:t}){return e.jsx("div",{className:"max-w-[85%]",children:e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsx("div",{className:"w-80 h-80 image-loading-shimmer flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-3/80 flex items-center justify-center",children:e.jsx(hn,{size:18,className:"text-accent animate-pulse"})}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Generating image..."})]})}),t.prompt&&e.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:e.jsxs("p",{className:"text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']})})]})})}function jze({msg:t,onReply:a}){const[s,o]=k.useState(!1),[c,l]=k.useState(!1),d=k.useCallback(()=>{if(!t.imageUrl)return;const p=document.createElement("a");p.href=t.imageUrl,p.download=`groove-${t.model||"image"}-${Date.now()}.png`,document.body.appendChild(p),p.click(),document.body.removeChild(p)},[t.imageUrl,t.model]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[85%]",children:[t.model&&e.jsxs("div",{className:"text-2xs text-text-3 font-mono mb-1.5 font-medium flex items-center gap-1.5",children:[e.jsx(hn,{size:10})," ",t.model]}),e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsxs("div",{className:"relative group",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-full max-h-[480px] object-contain cursor-pointer",onClick:()=>o(!0)}),c&&e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1.5",children:[e.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Download",children:e.jsx(oa,{size:14})}),e.jsx("button",{onClick:()=>o(!0),className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Fullscreen",children:e.jsx(wd,{size:14})}),e.jsx(AG,{text:t.prompt||"",className:"h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle text-text-2 hover:text-accent"})]})]}),e.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center gap-2",children:[e.jsxs("p",{className:"flex-1 text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']}),a&&e.jsxs("button",{onClick:()=>a(t),className:"text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer flex items-center gap-1 flex-shrink-0",children:[e.jsx(Zt,{size:10})," Iterate"]})]})]}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[200] bg-surface-0/95 backdrop-blur-md flex items-center justify-center",onClick:()=>o(!1),children:[e.jsx("button",{onClick:()=>o(!1),className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-surface-3 border border-border flex items-center justify-center text-text-2 hover:text-text-0 transition-colors cursor-pointer z-10",children:e.jsx(Ge,{size:18})}),e.jsx("div",{className:"absolute bottom-4 right-4 flex gap-2 z-10",children:e.jsxs("button",{onClick:p=>{p.stopPropagation(),d()},className:"h-9 px-4 rounded-lg bg-surface-3 border border-border flex items-center gap-2 text-xs font-sans text-text-1 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",children:[e.jsx(oa,{size:14})," Download"]})}),e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:p=>p.stopPropagation()}),t.prompt&&e.jsx("div",{className:"absolute bottom-4 left-4 max-w-md px-4 py-2 rounded-lg bg-surface-3/90 backdrop-blur-sm border border-border-subtle z-10",children:e.jsxs("p",{className:"text-xs text-text-2 font-sans italic",children:['"',t.prompt,'"']})})]})]})}function Mze({msg:t}){return e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-surface-4/50",children:[e.jsx(Do,{size:10,className:"text-text-4"}),e.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.text})]})})}function Nze(){return e.jsx("div",{className:"flex flex-col items-center justify-center h-full text-center py-16",children:e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Send a message to start"})})}function Sze(){const[t,a]=k.useState(0),[s,o]=k.useState(!0);return k.useEffect(()=>{const c=setInterval(()=>{o(!1),setTimeout(()=>{a(l=>(l+1)%PD.length),o(!0)},250)},2800);return()=>clearInterval(c)},[]),e.jsxs("div",{className:"flex items-center gap-2.5 ml-8 py-1",children:[e.jsx("div",{className:"relative w-3.5 h-3.5 flex-shrink-0",children:e.jsx("span",{className:"absolute inset-0 rounded-full border border-transparent border-t-accent animate-spin",style:{animationDuration:"0.9s"}})}),e.jsx("span",{className:"text-2xs font-sans text-text-3 transition-opacity duration-[250ms]",style:{opacity:s?1:0},children:PD[t]})]})}function _ze({messages:t,isStreaming:a,model:s,mode:o,onImageReply:c}){const l=k.useRef(null),d=k.useRef(!0);return k.useEffect(()=>{const p=l.current;if(!p)return;function x(){d.current=p.scrollHeight-p.scrollTop-p.clientHeight<50}return p.addEventListener("scroll",x),()=>p.removeEventListener("scroll",x)},[]),k.useEffect(()=>{d.current&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t==null?void 0:t.length,a]),!t||t.length===0?e.jsx("div",{ref:l,className:"flex-1 overflow-y-auto",children:e.jsx(Nze,{})}):e.jsxs("div",{ref:l,className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[t.map((p,x)=>p.type==="image-loading"?e.jsx(wze,{msg:p},x):p.type==="image"?e.jsx(jze,{msg:p,onReply:c},x):p.from==="user"?e.jsx(vze,{msg:p},x):p.from==="system"?e.jsx(Mze,{msg:p},x):e.jsx(bze,{msg:p,model:s},x)),a&&(o==="agent"?e.jsx(PG,{className:"py-1"}):e.jsx(Sze,{}))]})}function AD({onSend:t,onStop:a,sending:s,streaming:o,disabled:c,isImageModel:l,currentModel:d,replyContext:p,onClearReply:x,role:m}){const[O,f]=k.useState(""),y=k.useRef(null),b=k.useRef(null),w=k.useCallback(()=>{const q=y.current;q&&(q.style.height="auto",q.style.height=Math.min(q.scrollHeight,200)+"px")},[]);k.useEffect(()=>{w()},[O,w]),k.useEffect(()=>{!c&&y.current&&y.current.focus()},[c]);function M(){const q=O.trim();!q||s||c||(t(q),f(""),y.current&&(y.current.style.height="auto"))}function N(q){q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),M())}function j(q){const Q=Array.from(q.target.files||[]);if(Q.length===0)return;const S=Q.map(z=>z.name).join(", ");f(z=>z+(z?`
|
|
8610
|
-
`:"")+`[Attached: ${S}]`),q.target.value=""}const _=o||s,$=O.trim()&&!s&&!c,L=c?"Select a model to start chatting...":l?"Describe the image you want to generate...":m?`Ask your ${m}...`:"Send a message...";return e.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 bg-surface-1",children:[p&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-2 rounded-lg bg-accent/5 border border-accent/15",children:[e.jsx(hn,{size:12,className:"text-accent flex-shrink-0"}),e.jsxs("span",{className:"flex-1 text-2xs text-text-2 font-sans truncate",children:['Iterating: "',p.prompt,'"']}),e.jsx("button",{onClick:x,className:"text-text-4 hover:text-text-1 cursor-pointer flex-shrink-0",children:e.jsx(Cd,{size:10})})]}),d&&e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:G("flex items-center gap-1 h-6 px-2 rounded-md text-2xs font-mono border",l?"bg-purple/8 border-purple/20 text-purple":"bg-surface-3 border-border-subtle text-text-3"),children:[l&&e.jsx(hn,{size:9}),e.jsx("span",{className:"max-w-[80px] truncate",children:PA(d)})]})}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("input",{ref:b,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:j,className:"hidden"}),e.jsx("button",{onClick:()=>{var q;return(q=b.current)==null?void 0:q.click()},disabled:c,className:"w-10 h-10 flex items-center justify-center rounded-xl text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed flex-shrink-0",title:"Attach file",children:e.jsx(K1,{size:16})}),e.jsx("textarea",{ref:y,value:O,onChange:q=>f(q.target.value),onKeyDown:N,placeholder:L,disabled:c,rows:1,className:G("flex-1 resize-y rounded-xl px-4 py-2.5 text-sm","bg-surface-0 border text-text-0 font-sans","placeholder:text-text-4","focus:outline-none focus:ring-1","min-h-[40px]","border-border focus:ring-accent/40","disabled:opacity-50 disabled:cursor-not-allowed")}),_?e.jsx("button",{onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-xl bg-danger/80 text-white hover:bg-danger transition-all cursor-pointer shadow-lg shadow-danger/20 flex-shrink-0",title:"Stop generation",children:e.jsx(Cd,{size:14,fill:"currentColor"})}):e.jsx("button",{onClick:M,disabled:!$,className:G("w-10 h-10 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",$?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:s?e.jsx(Le,{size:16,className:"animate-spin"}):e.jsx(fn,{size:16})})]})]})}function Cze({onNewChat:t}){return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-1 font-sans",children:"Groove Chat"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Every provider, every model, full project context."}),e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 h-9 px-5 rounded-lg bg-accent/15 text-accent text-sm font-semibold font-sans hover:bg-accent/25 transition-colors cursor-pointer border border-accent/20",children:[e.jsx(ct,{size:14}),"New Chat"]})]})})}function $ze(){const t=P(T=>T.conversations),a=P(T=>T.activeConversationId),s=P(T=>T.conversationMessages),o=P(T=>T.sendingMessage),c=P(T=>T.streamingConversationId),l=P(T=>T.createConversation);P(T=>T.setActiveConversation);const d=P(T=>T.sendChatMessage),p=P(T=>T.sendImageMessage),x=P(T=>T.stopAgent),m=P(T=>T.stopChatStreaming),O=P(T=>T.setConversationMode),f=P(T=>T.setConversationModel),y=P(T=>T.conversationRoles),b=P(T=>T.setConversationRole),[w,M]=k.useState(!1),[N,j]=k.useState(null),_=a&&(y==null?void 0:y[a])||null,$=t.find(T=>T.id===a)||null,L=a?s[a]||[]:[],q=c===a&&o,Q=$?iL($.model):!1,S=k.useCallback(async(T,A)=>{const X=T||"claude-code",B=A||"claude-sonnet-4-6";try{await l(X,B,"api")}catch{}},[l]),z=k.useCallback(T=>{a&&O(a,T)},[a,O]),E=k.useCallback(T=>{a&&b(a,T)},[a,b]),R=k.useCallback(T=>{if(a)if(Q){const A=N?`${T} (iterating on: "${N.prompt}")`:T;p(a,A,{model:$.model}),j(null)}else d(a,T)},[a,$,Q,N,d,p]),J=k.useCallback(()=>{$&&($.mode==="agent"&&$.agentId?x($.agentId):m(a))},[$,a,x,m]),ae=k.useCallback(async T=>{a?await f(a,T.provider,T.model):await S(T.provider,T.model)},[a,f,S]),ce=k.useCallback(T=>{j(T)},[]),V=$?{provider:$.provider,model:$.model}:null;return e.jsxs("div",{className:"flex h-full bg-surface-0",children:[e.jsx("div",{className:G("flex-shrink-0 border-r border-accent/12 bg-surface-1 transition-all duration-200 overflow-hidden",w?"w-0":"w-64"),children:e.jsx(pze,{onNewChat:()=>S()})}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx(xze,{conversation:$,model:V,onModelChange:ae,onModeChange:z,role:_,onRoleChange:E}),e.jsx(_ze,{messages:L,isStreaming:q,model:$.model,mode:$.mode||"api",onImageReply:ce}),e.jsx(AD,{onSend:R,onStop:J,sending:o,streaming:q,disabled:!1,isImageModel:Q,currentModel:$.model,replyContext:N,onClearReply:()=>j(null),role:_})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cze,{onNewChat:()=>S()}),e.jsx(AD,{onSend:T=>{S().then(()=>{setTimeout(()=>{const A=P.getState().activeConversationId;A&&d(A,T)},500)})},onStop:()=>{},sending:!1,streaming:!1,disabled:!1,isImageModel:!1,currentModel:null})]})})]})}function Lze(){return e.jsx($ze,{})}const Qze=[{id:"desktop",icon:Bo,label:"Desktop",width:"100%"},{id:"tablet",icon:U0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:Z0,label:"Mobile (375px)",width:"375px"}];function zze({onRefresh:t}){const a=P(O=>O.previewState),s=P(O=>O.setPreviewDevice),o=P(O=>O.toggleScreenshotMode),c=P(O=>O.closePreview),[l,d]=k.useState(!1),p=k.useRef(null);k.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);function x(){l?(p.current&&clearTimeout(p.current),d(!1),c()):(d(!0),p.current=setTimeout(()=>d(!1),2e3))}const m=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return e.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[e.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:e.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:m||"No URL"})}),e.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:e.jsx(Zt,{size:14})}),e.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:Qze.map(O=>e.jsx("button",{onClick:()=>s(O.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===O.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:O.label,children:e.jsx(O.icon,{size:13})},O.id))}),e.jsx("button",{onClick:o,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:e.jsx(D1,{size:14})}),e.jsx("button",{onClick:x,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",l?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:l?e.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):e.jsx(Ge,{size:14})})]})}function Tze({iframeRef:t}){const a=P(Q=>Q.toggleScreenshotMode),s=P(Q=>Q.iteratePreview),o=k.useRef(null),[c,l]=k.useState(!1),[d,p]=k.useState(null),[x,m]=k.useState(null),[O,f]=k.useState(null),[y,b]=k.useState(""),[w,M]=k.useState(null),N=k.useCallback(Q=>{if(O)return;const S=o.current.getBoundingClientRect();p({x:Q.clientX-S.left,y:Q.clientY-S.top}),m(null),l(!0)},[O]),j=k.useCallback(Q=>{if(!c||O)return;const S=o.current.getBoundingClientRect();m({x:Q.clientX-S.left,y:Q.clientY-S.top})},[c,O]),_=k.useCallback(()=>{if(!c||!d||!x){l(!1);return}l(!1);const Q={x:Math.min(d.x,x.x),y:Math.min(d.y,x.y),w:Math.abs(x.x-d.x),h:Math.abs(x.y-d.y)};if(Q.w<10||Q.h<10){p(null),m(null);return}f({base64:null,rect:Q,loading:!0});function S(E){f({base64:E,rect:Q,loading:!1}),M(Q),setTimeout(()=>M(null),600)}function z(){const E=document.createElement("canvas"),R=window.devicePixelRatio||1;E.width=Q.w*R,E.height=Q.h*R;const J=E.getContext("2d");return J.scale(R,R),J.fillStyle="#1e2127",J.fillRect(0,0,Q.w,Q.h),J.strokeStyle="#3e4451",J.lineWidth=1,J.strokeRect(4,4,Q.w-8,Q.h-8),J.fillStyle="#6e7681",J.font="12px Inter, sans-serif",J.textAlign="center",J.textBaseline="middle",J.fillText(`${Math.round(Q.w)} × ${Math.round(Q.h)}`,Q.w/2,Q.h/2),E.toDataURL("image/png")}try{const E=t.current;if(!E){S(z());return}const R=document.createElement("canvas"),J=window.devicePixelRatio||1;R.width=Q.w*J,R.height=Q.h*J;const ae=R.getContext("2d");ae.scale(J,J);const ce=E.getBoundingClientRect(),V=o.current.getBoundingClientRect(),T=Q.x-(ce.left-V.left),A=Q.y-(ce.top-V.top);try{ae.drawImage(E,-T*J,-A*J,ce.width*J,ce.height*J,0,0,Q.w,Q.h);const X=ae.getImageData(0,0,1,1).data;if(X[0]===0&&X[1]===0&&X[2]===0&&X[3]===0)throw new Error("blank");S(R.toDataURL("image/png"))}catch{S(z())}}catch{p(null),m(null),f(null)}},[c,d,x,t]);k.useEffect(()=>{function Q(S){S.key==="Escape"&&a()}return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[a]);function $(){!O||O.loading||(s(y||"See screenshot",O.base64),a())}const L=d&&x?{left:Math.min(d.x,x.x),top:Math.min(d.y,x.y),width:Math.abs(x.x-d.x),height:Math.abs(x.y-d.y)}:null,q=k.useCallback(Q=>{if(!Q||!o.current)return{};const S=o.current.clientHeight,z=o.current.clientWidth,E=S-(Q.y+Q.h+8),R=200,J=E<R&&Q.y>R;return{left:Math.max(8,Math.min(Q.x,z-300)),top:J?Q.y-R-8:Q.y+Q.h+8}},[]);return e.jsxs("div",{ref:o,className:"absolute inset-0 z-30",style:{cursor:O?"default":"crosshair"},onMouseDown:N,onMouseMove:j,onMouseUp:_,children:[e.jsx("div",{className:"absolute inset-0 bg-info/10 pointer-events-none"}),L&&!O&&e.jsx("div",{className:"absolute border-2 border-dashed border-accent bg-accent/5 pointer-events-none",style:L}),w&&e.jsx("div",{className:"absolute pointer-events-none animate-capture-flash rounded",style:{left:w.x,top:w.y,width:w.w,height:w.h}}),O&&e.jsx("div",{className:"absolute border-2 border-accent rounded pointer-events-none",style:{left:O.rect.x,top:O.rect.y,width:O.rect.w,height:O.rect.h}}),O&&e.jsxs("div",{className:"absolute z-40 w-72 bg-surface-2 border border-border rounded-lg shadow-2xl animate-chat-fade-in",style:q(O.rect),children:[e.jsx("div",{className:"p-3 border-b border-border-subtle",children:O.loading?e.jsx("div",{className:"w-full h-24 rounded border border-border-subtle bg-surface-0 flex items-center justify-center",children:e.jsx(Le,{size:20,className:"text-accent animate-spin"})}):e.jsx("img",{src:O.base64,alt:"Screenshot",className:"w-full h-auto rounded border border-border-subtle max-h-32 object-contain bg-surface-0"})}),e.jsxs("div",{className:"p-3 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:Q=>b(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&$()},placeholder:"Describe what to change...",className:"flex-1 h-8 px-3 rounded-md bg-surface-1 border border-border-subtle text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:border-accent/40",autoFocus:!0}),e.jsx("button",{onClick:$,disabled:O.loading,className:"w-8 h-8 flex items-center justify-center rounded-md bg-accent/15 text-accent hover:bg-accent/25 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(fn,{size:14})}),e.jsx("button",{onClick:()=>a(),className:"w-8 h-8 flex items-center justify-center rounded-md text-text-3 hover:text-text-1 hover:bg-surface-4 transition-colors cursor-pointer",children:e.jsx(Ge,{size:14})})]})]}),!O&&!c&&e.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 px-3 py-1.5 rounded-full bg-surface-0/90 border border-border-subtle text-2xs text-text-2 font-sans pointer-events-none",children:"Click and drag to select a region · Esc to cancel"})]})}function Pze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*)/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3),l=c.indexOf(`
|
|
8609
|
+
`)})}return s}function z1({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|~~[^~]+~~|\[([^\]]+)\]\(([^)]+)\))/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("`")&&s.endsWith("`")&&!s.startsWith("``"))return e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o);if(s.startsWith("**")&&s.endsWith("**"))return e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o);if(s.startsWith("*")&&s.endsWith("*")&&!s.startsWith("**"))return e.jsx("em",{className:"italic",children:s.slice(1,-1)},o);if(s.startsWith("~~")&&s.endsWith("~~"))return e.jsx("del",{className:"line-through text-text-3",children:s.slice(2,-2)},o);const c=s.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return c?e.jsx("a",{href:c[2],target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:c[1]},o):e.jsx("span",{children:s},o)})})}function Oze({text:t}){const a=kze(t);return e.jsx("div",{className:"space-y-2",children:a.map((s,o)=>{switch(s.type){case"code":return e.jsx(gze,{language:s.language,code:s.code},o);case"heading":{const c=["text-lg font-bold","text-base font-bold","text-sm font-semibold","text-sm font-semibold","text-xs font-semibold","text-xs font-semibold"];return e.jsx("div",{className:G(c[s.level-1]||c[0],"text-text-0 font-sans mt-3 mb-1"),children:e.jsx(z1,{text:s.text})},o)}case"hr":return e.jsx("hr",{className:"border-border-subtle my-3"},o);case"blockquote":return e.jsx("div",{className:"border-l-2 border-accent/40 pl-3 py-1 text-sm text-text-2 italic font-sans",children:e.jsx(z1,{text:s.text})},o);case"ul":return e.jsx("ul",{className:"list-disc list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"ol":return e.jsx("ol",{className:"list-decimal list-inside space-y-0.5 text-sm text-text-0 font-sans",children:s.items.map((c,l)=>e.jsx("li",{children:e.jsx(z1,{text:c})},l))},o);case"table":return e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsxs("table",{className:"text-xs font-sans border-collapse w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border",children:s.headers.map((c,l)=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-text-0",children:c},l))})}),e.jsx("tbody",{children:s.rows.map((c,l)=>e.jsx("tr",{className:"border-b border-border-subtle",children:c.map((d,p)=>e.jsx("td",{className:"px-3 py-1.5 text-text-0",children:e.jsx(z1,{text:d})},p))},l))})]})},o);case"paragraph":return e.jsx("p",{className:"text-sm text-text-0 font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.jsx(z1,{text:s.text})},o);default:return null}})})}function vze({msg:t}){return e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-br-md bg-accent/10 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.text})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function bze({msg:t,model:a,role:s}){const o=yze(t.text),c=a||"Assistant",l=s||"chat";return e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx(mze,{name:c,role:l,size:"sm",className:"mt-1 flex-shrink-0"}),e.jsxs("div",{className:"max-w-[85%]",children:[e.jsx("div",{className:"text-2xs text-text-3 font-sans mb-1 font-medium",children:c}),e.jsx("div",{className:"border-l-2 border-accent/40 pl-3.5 py-1",children:e.jsx("div",{className:"text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed",children:e.jsx(Oze,{text:o})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})]})}function wze({msg:t}){return e.jsx("div",{className:"max-w-[85%]",children:e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsx("div",{className:"w-80 h-80 image-loading-shimmer flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-surface-3/80 flex items-center justify-center",children:e.jsx(hn,{size:18,className:"text-accent animate-pulse"})}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Generating image..."})]})}),t.prompt&&e.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:e.jsxs("p",{className:"text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']})})]})})}function jze({msg:t,onReply:a}){const[s,o]=k.useState(!1),[c,l]=k.useState(!1),d=k.useCallback(()=>{if(!t.imageUrl)return;const p=document.createElement("a");p.href=t.imageUrl,p.download=`groove-${t.model||"image"}-${Date.now()}.png`,document.body.appendChild(p),p.click(),document.body.removeChild(p)},[t.imageUrl,t.model]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[85%]",children:[t.model&&e.jsxs("div",{className:"text-2xs text-text-3 font-mono mb-1.5 font-medium flex items-center gap-1.5",children:[e.jsx(hn,{size:10})," ",t.model]}),e.jsxs("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle overflow-hidden",children:[e.jsxs("div",{className:"relative group",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-full max-h-[480px] object-contain cursor-pointer",onClick:()=>o(!0)}),c&&e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1.5",children:[e.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Download",children:e.jsx(oa,{size:14})}),e.jsx("button",{onClick:()=>o(!0),className:"w-8 h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle flex items-center justify-center text-text-2 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",title:"Fullscreen",children:e.jsx(wd,{size:14})}),e.jsx(AG,{text:t.prompt||"",className:"h-8 rounded-lg bg-surface-0/90 backdrop-blur-sm border border-border-subtle text-text-2 hover:text-accent"})]})]}),e.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center gap-2",children:[e.jsxs("p",{className:"flex-1 text-2xs text-text-3 font-sans italic truncate",children:['"',t.prompt,'"']}),a&&e.jsxs("button",{onClick:()=>a(t),className:"text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer flex items-center gap-1 flex-shrink-0",children:[e.jsx(Zt,{size:10})," Iterate"]})]})]}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[200] bg-surface-0/95 backdrop-blur-md flex items-center justify-center",onClick:()=>o(!1),children:[e.jsx("button",{onClick:()=>o(!1),className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-surface-3 border border-border flex items-center justify-center text-text-2 hover:text-text-0 transition-colors cursor-pointer z-10",children:e.jsx(Ge,{size:18})}),e.jsx("div",{className:"absolute bottom-4 right-4 flex gap-2 z-10",children:e.jsxs("button",{onClick:p=>{p.stopPropagation(),d()},className:"h-9 px-4 rounded-lg bg-surface-3 border border-border flex items-center gap-2 text-xs font-sans text-text-1 hover:text-accent hover:border-accent/30 transition-colors cursor-pointer",children:[e.jsx(oa,{size:14})," Download"]})}),e.jsx("img",{src:t.imageUrl,alt:t.prompt||"Generated image",className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:p=>p.stopPropagation()}),t.prompt&&e.jsx("div",{className:"absolute bottom-4 left-4 max-w-md px-4 py-2 rounded-lg bg-surface-3/90 backdrop-blur-sm border border-border-subtle z-10",children:e.jsxs("p",{className:"text-xs text-text-2 font-sans italic",children:['"',t.prompt,'"']})})]})]})}function Mze({msg:t}){return e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-surface-4/50",children:[e.jsx(Do,{size:10,className:"text-text-4"}),e.jsx("span",{className:"text-2xs text-text-3 font-sans",children:t.text})]})})}function Nze(){return e.jsx("div",{className:"flex flex-col items-center justify-center h-full text-center py-16",children:e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Send a message to start"})})}function Sze(){const[t,a]=k.useState(0),[s,o]=k.useState(!0);return k.useEffect(()=>{const c=setInterval(()=>{o(!1),setTimeout(()=>{a(l=>(l+1)%PD.length),o(!0)},250)},2800);return()=>clearInterval(c)},[]),e.jsxs("div",{className:"flex items-center gap-2.5 ml-8 py-1",children:[e.jsx("div",{className:"relative w-3.5 h-3.5 flex-shrink-0",children:e.jsx("span",{className:"absolute inset-0 rounded-full border border-transparent border-t-accent animate-spin",style:{animationDuration:"0.9s"}})}),e.jsx("span",{className:"text-2xs font-sans text-text-3 transition-opacity duration-[250ms]",style:{opacity:s?1:0},children:PD[t]})]})}function _ze({messages:t,isStreaming:a,model:s,mode:o,onImageReply:c,role:l}){const d=k.useRef(null),p=k.useRef(!0);return k.useEffect(()=>{const x=d.current;if(!x)return;function m(){p.current=x.scrollHeight-x.scrollTop-x.clientHeight<50}return x.addEventListener("scroll",m),()=>x.removeEventListener("scroll",m)},[]),k.useEffect(()=>{p.current&&d.current&&(d.current.scrollTop=d.current.scrollHeight)},[t==null?void 0:t.length,a]),!t||t.length===0?e.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.jsx(Nze,{})}):e.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[t.map((x,m)=>x.type==="image-loading"?e.jsx(wze,{msg:x},m):x.type==="image"?e.jsx(jze,{msg:x,onReply:c},m):x.from==="user"?e.jsx(vze,{msg:x},m):x.from==="system"?e.jsx(Mze,{msg:x},m):e.jsx(bze,{msg:x,model:s,role:l},m)),a&&(o==="agent"?e.jsx(PG,{className:"py-1"}):e.jsx(Sze,{}))]})}function AD({onSend:t,onStop:a,sending:s,streaming:o,disabled:c,isImageModel:l,currentModel:d,replyContext:p,onClearReply:x,role:m}){const[O,f]=k.useState(""),y=k.useRef(null),b=k.useRef(null),w=k.useCallback(()=>{const q=y.current;q&&(q.style.height="auto",q.style.height=Math.min(q.scrollHeight,200)+"px")},[]);k.useEffect(()=>{w()},[O,w]),k.useEffect(()=>{!c&&y.current&&y.current.focus()},[c]);function M(){const q=O.trim();!q||s||c||(t(q),f(""),y.current&&(y.current.style.height="auto"))}function N(q){q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),M())}function j(q){const Q=Array.from(q.target.files||[]);if(Q.length===0)return;const S=Q.map(z=>z.name).join(", ");f(z=>z+(z?`
|
|
8610
|
+
`:"")+`[Attached: ${S}]`),q.target.value=""}const _=o||s,$=O.trim()&&!s&&!c,L=c?"Select a model to start chatting...":l?"Describe the image you want to generate...":m?`Ask your ${m}...`:"Send a message...";return e.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 bg-surface-1",children:[p&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-2 rounded-lg bg-accent/5 border border-accent/15",children:[e.jsx(hn,{size:12,className:"text-accent flex-shrink-0"}),e.jsxs("span",{className:"flex-1 text-2xs text-text-2 font-sans truncate",children:['Iterating: "',p.prompt,'"']}),e.jsx("button",{onClick:x,className:"text-text-4 hover:text-text-1 cursor-pointer flex-shrink-0",children:e.jsx(Cd,{size:10})})]}),d&&e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:G("flex items-center gap-1 h-6 px-2 rounded-md text-2xs font-mono border",l?"bg-purple/8 border-purple/20 text-purple":"bg-surface-3 border-border-subtle text-text-3"),children:[l&&e.jsx(hn,{size:9}),e.jsx("span",{className:"max-w-[80px] truncate",children:PA(d)})]})}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("input",{ref:b,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:j,className:"hidden"}),e.jsx("button",{onClick:()=>{var q;return(q=b.current)==null?void 0:q.click()},disabled:c,className:"w-10 h-10 flex items-center justify-center rounded-xl text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed flex-shrink-0",title:"Attach file",children:e.jsx(K1,{size:16})}),e.jsx("textarea",{ref:y,value:O,onChange:q=>f(q.target.value),onKeyDown:N,placeholder:L,disabled:c,rows:1,className:G("flex-1 resize-y rounded-xl px-4 py-2.5 text-sm","bg-surface-0 border text-text-0 font-sans","placeholder:text-text-4","focus:outline-none focus:ring-1","min-h-[40px]","border-border focus:ring-accent/40","disabled:opacity-50 disabled:cursor-not-allowed")}),_?e.jsx("button",{onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-xl bg-danger/80 text-white hover:bg-danger transition-all cursor-pointer shadow-lg shadow-danger/20 flex-shrink-0",title:"Stop generation",children:e.jsx(Cd,{size:14,fill:"currentColor"})}):e.jsx("button",{onClick:M,disabled:!$,className:G("w-10 h-10 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",$?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:s?e.jsx(Le,{size:16,className:"animate-spin"}):e.jsx(fn,{size:16})})]})]})}function Cze({onNewChat:t}){return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-1 font-sans",children:"Groove Chat"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Every provider, every model, full project context."}),e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 h-9 px-5 rounded-lg bg-accent/15 text-accent text-sm font-semibold font-sans hover:bg-accent/25 transition-colors cursor-pointer border border-accent/20",children:[e.jsx(ct,{size:14}),"New Chat"]})]})})}function $ze(){const t=P(T=>T.conversations),a=P(T=>T.activeConversationId),s=P(T=>T.conversationMessages),o=P(T=>T.sendingMessage),c=P(T=>T.streamingConversationId),l=P(T=>T.createConversation);P(T=>T.setActiveConversation);const d=P(T=>T.sendChatMessage),p=P(T=>T.sendImageMessage),x=P(T=>T.stopAgent),m=P(T=>T.stopChatStreaming),O=P(T=>T.setConversationMode),f=P(T=>T.setConversationModel),y=P(T=>T.conversationRoles),b=P(T=>T.setConversationRole),[w,M]=k.useState(!1),[N,j]=k.useState(null),_=a&&(y==null?void 0:y[a])||null,$=t.find(T=>T.id===a)||null,L=a?s[a]||[]:[],q=c===a&&o,Q=$?iL($.model):!1,S=k.useCallback(async(T,A)=>{const X=T||"claude-code",B=A||"claude-sonnet-4-6";try{await l(X,B,"api")}catch{}},[l]),z=k.useCallback(T=>{a&&O(a,T)},[a,O]),E=k.useCallback(T=>{a&&b(a,T)},[a,b]),R=k.useCallback(T=>{if(a)if(Q){const A=N?`${T} (iterating on: "${N.prompt}")`:T;p(a,A,{model:$.model}),j(null)}else d(a,T)},[a,$,Q,N,d,p]),J=k.useCallback(()=>{$&&($.mode==="agent"&&$.agentId?x($.agentId):m(a))},[$,a,x,m]),ae=k.useCallback(async T=>{a?await f(a,T.provider,T.model):await S(T.provider,T.model)},[a,f,S]),ce=k.useCallback(T=>{j(T)},[]),V=$?{provider:$.provider,model:$.model}:null;return e.jsxs("div",{className:"flex h-full bg-surface-0",children:[e.jsx("div",{className:G("flex-shrink-0 border-r border-accent/12 bg-surface-1 transition-all duration-200 overflow-hidden",w?"w-0":"w-64"),children:e.jsx(pze,{onNewChat:()=>S()})}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx(xze,{conversation:$,model:V,onModelChange:ae,onModeChange:z,role:_,onRoleChange:E}),e.jsx(_ze,{messages:L,isStreaming:q,model:$.model,mode:$.mode||"api",onImageReply:ce,role:_}),e.jsx(AD,{onSend:R,onStop:J,sending:o,streaming:q,disabled:!1,isImageModel:Q,currentModel:$.model,replyContext:N,onClearReply:()=>j(null),role:_})]}):e.jsxs(e.Fragment,{children:[e.jsx(Cze,{onNewChat:()=>S()}),e.jsx(AD,{onSend:T=>{S().then(()=>{setTimeout(()=>{const A=P.getState().activeConversationId;A&&d(A,T)},500)})},onStop:()=>{},sending:!1,streaming:!1,disabled:!1,isImageModel:!1,currentModel:null})]})})]})}function Lze(){return e.jsx($ze,{})}const Qze=[{id:"desktop",icon:Bo,label:"Desktop",width:"100%"},{id:"tablet",icon:U0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:Z0,label:"Mobile (375px)",width:"375px"}];function zze({onRefresh:t}){const a=P(O=>O.previewState),s=P(O=>O.setPreviewDevice),o=P(O=>O.toggleScreenshotMode),c=P(O=>O.closePreview),[l,d]=k.useState(!1),p=k.useRef(null);k.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);function x(){l?(p.current&&clearTimeout(p.current),d(!1),c()):(d(!0),p.current=setTimeout(()=>d(!1),2e3))}const m=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return e.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[e.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:e.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:m||"No URL"})}),e.jsx("button",{onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:e.jsx(Zt,{size:14})}),e.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:Qze.map(O=>e.jsx("button",{onClick:()=>s(O.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===O.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:O.label,children:e.jsx(O.icon,{size:13})},O.id))}),e.jsx("button",{onClick:o,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:e.jsx(D1,{size:14})}),e.jsx("button",{onClick:x,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",l?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:l?e.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):e.jsx(Ge,{size:14})})]})}function Tze({iframeRef:t}){const a=P(Q=>Q.toggleScreenshotMode),s=P(Q=>Q.iteratePreview),o=k.useRef(null),[c,l]=k.useState(!1),[d,p]=k.useState(null),[x,m]=k.useState(null),[O,f]=k.useState(null),[y,b]=k.useState(""),[w,M]=k.useState(null),N=k.useCallback(Q=>{if(O)return;const S=o.current.getBoundingClientRect();p({x:Q.clientX-S.left,y:Q.clientY-S.top}),m(null),l(!0)},[O]),j=k.useCallback(Q=>{if(!c||O)return;const S=o.current.getBoundingClientRect();m({x:Q.clientX-S.left,y:Q.clientY-S.top})},[c,O]),_=k.useCallback(()=>{if(!c||!d||!x){l(!1);return}l(!1);const Q={x:Math.min(d.x,x.x),y:Math.min(d.y,x.y),w:Math.abs(x.x-d.x),h:Math.abs(x.y-d.y)};if(Q.w<10||Q.h<10){p(null),m(null);return}f({base64:null,rect:Q,loading:!0});function S(E){f({base64:E,rect:Q,loading:!1}),M(Q),setTimeout(()=>M(null),600)}function z(){const E=document.createElement("canvas"),R=window.devicePixelRatio||1;E.width=Q.w*R,E.height=Q.h*R;const J=E.getContext("2d");return J.scale(R,R),J.fillStyle="#1e2127",J.fillRect(0,0,Q.w,Q.h),J.strokeStyle="#3e4451",J.lineWidth=1,J.strokeRect(4,4,Q.w-8,Q.h-8),J.fillStyle="#6e7681",J.font="12px Inter, sans-serif",J.textAlign="center",J.textBaseline="middle",J.fillText(`${Math.round(Q.w)} × ${Math.round(Q.h)}`,Q.w/2,Q.h/2),E.toDataURL("image/png")}try{const E=t.current;if(!E){S(z());return}const R=document.createElement("canvas"),J=window.devicePixelRatio||1;R.width=Q.w*J,R.height=Q.h*J;const ae=R.getContext("2d");ae.scale(J,J);const ce=E.getBoundingClientRect(),V=o.current.getBoundingClientRect(),T=Q.x-(ce.left-V.left),A=Q.y-(ce.top-V.top);try{ae.drawImage(E,-T*J,-A*J,ce.width*J,ce.height*J,0,0,Q.w,Q.h);const X=ae.getImageData(0,0,1,1).data;if(X[0]===0&&X[1]===0&&X[2]===0&&X[3]===0)throw new Error("blank");S(R.toDataURL("image/png"))}catch{S(z())}}catch{p(null),m(null),f(null)}},[c,d,x,t]);k.useEffect(()=>{function Q(S){S.key==="Escape"&&a()}return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[a]);function $(){!O||O.loading||(s(y||"See screenshot",O.base64),a())}const L=d&&x?{left:Math.min(d.x,x.x),top:Math.min(d.y,x.y),width:Math.abs(x.x-d.x),height:Math.abs(x.y-d.y)}:null,q=k.useCallback(Q=>{if(!Q||!o.current)return{};const S=o.current.clientHeight,z=o.current.clientWidth,E=S-(Q.y+Q.h+8),R=200,J=E<R&&Q.y>R;return{left:Math.max(8,Math.min(Q.x,z-300)),top:J?Q.y-R-8:Q.y+Q.h+8}},[]);return e.jsxs("div",{ref:o,className:"absolute inset-0 z-30",style:{cursor:O?"default":"crosshair"},onMouseDown:N,onMouseMove:j,onMouseUp:_,children:[e.jsx("div",{className:"absolute inset-0 bg-info/10 pointer-events-none"}),L&&!O&&e.jsx("div",{className:"absolute border-2 border-dashed border-accent bg-accent/5 pointer-events-none",style:L}),w&&e.jsx("div",{className:"absolute pointer-events-none animate-capture-flash rounded",style:{left:w.x,top:w.y,width:w.w,height:w.h}}),O&&e.jsx("div",{className:"absolute border-2 border-accent rounded pointer-events-none",style:{left:O.rect.x,top:O.rect.y,width:O.rect.w,height:O.rect.h}}),O&&e.jsxs("div",{className:"absolute z-40 w-72 bg-surface-2 border border-border rounded-lg shadow-2xl animate-chat-fade-in",style:q(O.rect),children:[e.jsx("div",{className:"p-3 border-b border-border-subtle",children:O.loading?e.jsx("div",{className:"w-full h-24 rounded border border-border-subtle bg-surface-0 flex items-center justify-center",children:e.jsx(Le,{size:20,className:"text-accent animate-spin"})}):e.jsx("img",{src:O.base64,alt:"Screenshot",className:"w-full h-auto rounded border border-border-subtle max-h-32 object-contain bg-surface-0"})}),e.jsxs("div",{className:"p-3 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:Q=>b(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&$()},placeholder:"Describe what to change...",className:"flex-1 h-8 px-3 rounded-md bg-surface-1 border border-border-subtle text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:border-accent/40",autoFocus:!0}),e.jsx("button",{onClick:$,disabled:O.loading,className:"w-8 h-8 flex items-center justify-center rounded-md bg-accent/15 text-accent hover:bg-accent/25 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(fn,{size:14})}),e.jsx("button",{onClick:()=>a(),className:"w-8 h-8 flex items-center justify-center rounded-md text-text-3 hover:text-text-1 hover:bg-surface-4 transition-colors cursor-pointer",children:e.jsx(Ge,{size:14})})]})]}),!O&&!c&&e.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 px-3 py-1.5 rounded-full bg-surface-0/90 border border-border-subtle text-2xs text-text-2 font-sans pointer-events-none",children:"Click and drag to select a region · Esc to cancel"})]})}function Pze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```|`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*)/g);return e.jsx(e.Fragment,{children:a.map((s,o)=>{if(!s)return null;if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3),l=c.indexOf(`
|
|
8611
8611
|
`),d=l>=0?c.slice(l+1):c;return e.jsx("pre",{className:"my-2 px-3 py-2 rounded-lg bg-surface-0 border border-border-subtle overflow-x-auto",children:e.jsx("code",{className:"text-xs font-mono text-text-1 whitespace-pre",children:d})},o)}return s.startsWith("`")&&s.endsWith("`")?e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-surface-0 text-xs font-mono text-accent",children:s.slice(1,-1)},o):s.startsWith("**")&&s.endsWith("**")?e.jsx("strong",{className:"font-semibold text-text-0",children:s.slice(2,-2)},o):s.startsWith("*")&&s.endsWith("*")?e.jsx("em",{className:"italic",children:s.slice(1,-1)},o):e.jsx("span",{children:s},o)})})}function Aze({msg:t}){return t.role==="user"?e.jsx("div",{className:"flex justify-end animate-chat-fade-in",children:e.jsxs("div",{className:"max-w-[85%]",children:[t.screenshot&&e.jsx("img",{src:t.screenshot,alt:"Screenshot",className:"mb-2 rounded-lg border border-border-subtle max-h-40 object-contain"}),e.jsx("div",{className:"px-4 py-3 rounded-2xl rounded-br-md bg-gradient-to-br from-accent/12 to-accent/6 border border-accent/15",children:e.jsx("p",{className:"text-sm text-text-0 font-sans whitespace-pre-wrap break-words leading-relaxed",children:t.content})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})}):e.jsxs("div",{className:"max-w-[85%] animate-chat-fade-in",children:[e.jsx("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle px-4 py-3",children:e.jsx("p",{className:"text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed",children:e.jsx(Pze,{text:t.content})})}),e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-1",children:xt(t.timestamp)})]})}function Ize(){const t=P(y=>y.previewChat),a=P(y=>y.previewState),s=P(y=>y.iteratePreview),o=P(y=>y.previewIterating),[c,l]=k.useState(""),d=k.useRef(null),p=k.useRef(null),x=k.useRef(!0);k.useEffect(()=>{const y=d.current;if(!y)return;function b(){x.current=y.scrollHeight-y.scrollTop-y.clientHeight<50}return y.addEventListener("scroll",b),()=>y.removeEventListener("scroll",b)},[]),k.useEffect(()=>{x.current&&d.current&&(d.current.scrollTop=d.current.scrollHeight)},[t==null?void 0:t.length]);const m=k.useCallback(()=>{const y=p.current;y&&(y.style.height="auto",y.style.height=Math.min(y.scrollHeight,160)+"px")},[]);k.useEffect(()=>{m()},[c,m]);function O(){const y=c.trim();!y||o||(s(y),l(""),p.current&&(p.current.style.height="auto"))}function f(y){y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),O())}return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0",children:[e.jsx("div",{className:"flex-shrink-0 h-10 flex items-center px-4 border-b border-border bg-surface-3",children:e.jsx("span",{className:"text-xs font-semibold text-text-1 font-sans",children:"Iterate"})}),e.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent/5 border-b border-accent/10",children:e.jsxs("p",{className:"text-2xs text-accent font-sans",children:["Iterating on ",e.jsx("span",{className:"font-semibold",children:a.teamId||"project"})," — changes auto-refresh via hot reload"]})}),e.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[t.length===0&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"max-w-xs w-full px-5 py-5 bg-surface-1 border border-border-subtle rounded-xl text-center",children:[e.jsx(pn,{size:24,className:"mx-auto text-accent mb-3"}),e.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-3",children:"Preview is live!"}),e.jsxs("ul",{className:"text-left space-y-2 text-2xs text-text-2 font-sans",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx(fn,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Type a message to request changes — your feedback goes to the team planner who routes it to the right agent"})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx(D1,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Use the camera icon to screenshot a specific area and annotate it"})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx(Zt,{size:11,className:"text-text-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Changes auto-refresh via hot module reload"})]})]})]})}),t.map((y,b)=>e.jsx(Aze,{msg:y},b)),o&&e.jsx("div",{className:"max-w-[85%] animate-chat-fade-in",children:e.jsx("div",{className:"rounded-2xl rounded-tl-md bg-surface-1/80 border border-border-subtle px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{size:14,className:"text-accent animate-spin"}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Routing to planner..."})]})})})]}),e.jsx("div",{className:"flex-shrink-0 px-3 py-3 border-t border-border",children:e.jsxs("div",{className:"flex items-end gap-2 rounded-2xl bg-surface-1/80 border border-accent/8 px-3 py-2",children:[e.jsx("textarea",{ref:p,value:c,onChange:y=>l(y.target.value),onKeyDown:f,placeholder:"Describe changes...",rows:1,style:{minHeight:"36px"},className:"flex-1 resize-none bg-transparent text-sm text-text-0 font-sans placeholder:text-text-4 focus:outline-none py-1.5"}),e.jsx("button",{onClick:O,disabled:!c.trim()||o,className:G("w-9 h-9 flex items-center justify-center rounded-xl transition-all cursor-pointer flex-shrink-0","disabled:opacity-20 disabled:cursor-not-allowed",c.trim()&&!o?"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/25":"bg-surface-4 text-text-4"),children:e.jsx(fn,{size:16})})]})})]})}function qze(){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-surface-0",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx(E0,{size:40,className:"mx-auto text-text-4"}),e.jsx("h2",{className:"text-lg font-semibold text-text-1 font-sans",children:"No preview active"}),e.jsx("p",{className:"text-sm text-text-3 font-sans max-w-xs",children:"Build a project with a planner team to see it here."})]})})}const Rze={desktop:"100%",tablet:"768px",mobile:"375px"};function Eze(){const t=P(x=>x.previewState),a=k.useRef(null),[s,o]=k.useState(0),c=k.useCallback(()=>{o(x=>x+1)},[]);if(!t.url)return e.jsx(qze,{});const l=t.teamId?`/api/preview/${t.teamId}/proxy/`:t.url,d=Rze[t.deviceSize]||"100%",p=t.deviceSize==="desktop";return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0 md:flex-row",children:[e.jsxs("div",{className:"flex flex-col flex-[3] min-w-0 min-h-0",children:[e.jsx(zze,{onRefresh:c}),e.jsxs("div",{className:"flex-1 relative overflow-hidden bg-surface-1",children:[t.screenshotMode&&e.jsx(Tze,{iframeRef:a}),e.jsx("div",{className:G("h-full transition-all duration-200",p?"w-full":"mx-auto"),style:p?void 0:{width:d,maxWidth:"100%"},children:e.jsx("iframe",{ref:a,src:l,title:"Preview",className:"w-full h-full border-0 bg-white",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},s)})]})]}),e.jsx("div",{className:"flex-[2] min-w-[280px] max-w-[480px] border-l border-border md:max-w-none md:flex-[2]",children:e.jsx(Ize,{})})]})}function Vze(){return e.jsx(Eze,{})}const zP=[];function IG(t){const a=(t||"").toLowerCase();return a.includes("reading")||a.includes("read ")?{icon:Yt,color:"text-info",label:"Reading"}:a.includes("editing")||a.includes("wrote")||a.includes("writing")||a.includes("edit ")?{icon:Vs,color:"text-warning",label:"Editing"}:a.includes("searching")||a.includes("search")||a.includes("grep")||a.includes("glob")?{icon:Ut,color:"text-purple",label:"Searching"}:a.includes("running")||a.includes("bash")||a.includes("command")||a.includes("exec")?{icon:Bs,color:"text-orange",label:"Running"}:a.includes("test")||a.includes("pass")?{icon:Mn,color:"text-success",label:"Testing"}:a.includes("error")||a.includes("fail")||a.includes("crash")?{icon:Ct,color:"text-danger",label:"Error"}:a.includes("rotat")?{icon:Gs,color:"text-accent",label:"Rotating"}:a.includes("spawn")||a.includes("start")?{icon:kt,color:"text-success",label:"Spawned"}:a.includes("tool")||a.includes("function")?{icon:F0,color:"text-text-2",label:"Tool"}:a.includes("complet")||a.includes("done")||a.includes("finish")?{icon:Mn,color:"text-success",label:"Done"}:{icon:fa,color:"text-text-3",label:"Activity"}}function P1({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((a,s)=>a.startsWith("**")&&a.endsWith("**")?e.jsx("strong",{className:"font-semibold text-text-0",children:a.slice(2,-2)},s):a.startsWith("`")&&a.endsWith("`")?e.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:a.slice(1,-1)},s):e.jsx("span",{children:a},s)):null}function Dze({text:t}){if(!t)return null;const a=[],s=t.split(`
|
|
8612
8612
|
`);let o=0;for(;o<s.length;){const c=s[o];if(c.trimStart().startsWith("```")){const d=[],p=c.trim().slice(3);for(o++;o<s.length&&!s[o].trimStart().startsWith("```");)d.push(s[o]),o++;o++,a.push({type:"code",content:d.join(`
|
|
8613
8613
|
`),lang:p});continue}if(/^#{1,3}\s/.test(c)||/^\*\*[^*]+:\*\*\s*$/.test(c.trim())){const d=c.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();a.push({type:"heading",content:d}),o++;continue}if(/^\s*[-*]\s/.test(c)){const d=[];for(;o<s.length&&/^\s*[-*]\s/.test(s[o]);)d.push(s[o].replace(/^\s*[-*]\s+/,"").trim()),o++;a.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(c)){const d=[];for(;o<s.length&&/^\s*\d+[\.)]\s/.test(s[o]);)d.push(s[o].replace(/^\s*\d+[\.)]\s+/,"").trim()),o++;a.push({type:"numbered",items:d});continue}if(!c.trim()){o++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(c.trim())){a.push({type:"note",content:c.trim()}),o++;continue}const l=[];for(;o<s.length&&s[o].trim()&&!/^#{1,3}\s/.test(s[o])&&!/^\s*[-*]\s/.test(s[o])&&!/^\s*\d+[\.)]\s/.test(s[o])&&!s[o].trimStart().startsWith("```");)l.push(s[o].trim()),o++;l.length>0&&a.push({type:"para",content:l.join(" ")})}return e.jsx("div",{className:"space-y-2",children:a.map((c,l)=>{switch(c.type){case"heading":return e.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[e.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),e.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:e.jsx(P1,{text:c.content})})]},l);case"list":return e.jsx("div",{className:"space-y-1 pl-2",children:c.items.map((d,p)=>e.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[e.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),e.jsx("span",{className:"min-w-0",children:e.jsx(P1,{text:d})})]},p))},l);case"numbered":return e.jsx("div",{className:"space-y-1 pl-2",children:c.items.map((d,p)=>e.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[e.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[p+1,"."]}),e.jsx("span",{className:"min-w-0",children:e.jsx(P1,{text:d})})]},p))},l);case"code":return e.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:c.content},l);case"note":return e.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[e.jsx(Ct,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:e.jsx(P1,{text:c.content})})]},l);case"para":default:return e.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:e.jsx(P1,{text:c.content})},l)}})})}function Xze({text:t}){if(!t)return null;const a=t.split(/(```[\s\S]*?```)/g);return e.jsx("span",{children:a.map((s,o)=>{if(s.startsWith("```")&&s.endsWith("```")){const c=s.slice(3,-3).replace(/^\w+\n/,"");return e.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:c},o)}return e.jsx("span",{children:e.jsx(P1,{text:s})},o)})})}function Zze({msg:t}){const a=t.isQuery;return e.jsx("div",{className:"flex justify-end pl-8",children:e.jsxs("div",{className:"max-w-[90%]",children:[a&&e.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[e.jsx(na,{size:9,className:"text-info"}),e.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),e.jsx("div",{className:G("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:e.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:e.jsx(Xze,{text:t.text})})}),e.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:xt(t.timestamp)})]})})}function Uze({msg:t,agent:a}){var l,d;const[s,o]=k.useState(((l=t.text)==null?void 0:l.length)>600),c=((d=t.text)==null?void 0:d.length)>600;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(a==null?void 0:a.name)||"Agent"}),e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:a==null?void 0:a.role}),e.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:xt(t.timestamp)})]}),e.jsx("div",{className:"border-l border-accent pl-3.5 py-1",children:e.jsx(Dze,{text:s?t.text.slice(0,600)+"...":t.text})}),s&&e.jsxs("button",{onClick:()=>o(!1),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[e.jsx($t,{size:11}),"Show full response"]}),c&&!s&&e.jsxs("button",{onClick:()=>o(!0),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[e.jsx($t,{size:11,className:"rotate-180"}),"Collapse"]})]})}function Hze({msg:t}){return e.jsxs("div",{className:"flex items-center gap-3 py-2",children:[e.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),e.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),e.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function Gze({entries:t,isLive:a}){var d;const[s,o]=k.useState(0);if(k.useEffect(()=>{if(!a||t.length<=1)return;const p=setInterval(()=>o(x=>(x+1)%t.length),1500);return()=>clearInterval(p)},[t.length,a]),!a){const p=t[t.length-1],m=IG(p.text).icon;return e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 text-[10px] text-text-4 font-mono",children:[e.jsx(m,{size:10,className:"opacity-50"}),e.jsxs("span",{children:[t.length," tool call",t.length!==1?"s":""]})]})}const c=t[Math.min(s,t.length-1)],l=((d=c.text)==null?void 0:d.length)>60?c.text.slice(0,60)+"...":c.text;return e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-2 max-w-[280px] rounded-md bg-surface-3/50 border border-border-subtle/30",children:[e.jsx(Le,{size:11,className:"text-accent animate-spin flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate transition-opacity duration-300",children:l}),t.length>1&&e.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function Bze({agent:t}){const a=P(x=>x.activityLog[t.id])||zP,s=a[a.length-1],o=s?IG(s.text):null,c=(o==null?void 0:o.icon)||fa,l=s&&Date.now()-s.timestamp<1e4,d=l&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,p=Math.round((t.contextUsage||0)*100);return e.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),e.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),l?e.jsxs(e.Fragment,{children:[e.jsx(c,{size:10,className:G(o.color,"flex-shrink-0")}),e.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):e.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:Wze(t.tokensUsed)}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-14 h-0.5 rounded-sm bg-surface-4 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${p}%`,background:p>=75?"var(--color-danger)":p>=50?"var(--color-warning)":"var(--color-accent)"}})}),e.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[p,"%"]})]})]})]})}function Wze(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function Fze({agent:t}){const[a,s]=k.useState([]),o=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return k.useEffect(()=>{const c=o.map((l,d)=>setTimeout(()=>s(p=>[...p,d]),l.delay));return()=>c.forEach(clearTimeout)},[]),e.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsxs("div",{className:"relative w-9 h-9",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),e.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),e.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),e.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),e.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:o.map((c,l)=>{const d=a.includes(l),p=l===o.length-1;return e.jsxs("div",{className:G("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[e.jsx("span",{className:G("w-1 h-1 rounded-full flex-shrink-0",p&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),e.jsx("span",{className:G("text-[11px] font-mono",p&&d?"text-accent":"text-text-3"),children:c.text}),p&&d&&e.jsxs("span",{className:"flex gap-0.5 ml-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},l)})})]})}function Yze({agent:t}){const a=P(R=>R.chatHistory[t.id])||zP,s=P(R=>R.activityLog[t.id])||zP,o=P(R=>R.instructAgent),c=P(R=>R.queryAgent),l=P(R=>{var J;return(J=R.thinkingAgents)==null?void 0:J.has(t.id)}),d=P(R=>R.chatInputs[t.id]||""),p=R=>P.setState(J=>({chatInputs:{...J.chatInputs,[t.id]:R}})),x=d,m=p,[O,f]=k.useState("instruct"),[y,b]=k.useState(!1),[w,M]=k.useState(36),N=k.useRef(null),j=k.useRef(null),_=k.useRef(null),$=k.useRef(null),L=k.useCallback(R=>{R.preventDefault();const J=R.clientY,ae=w,ce=T=>M(Math.min(Math.max(36,ae-(T.clientY-J)),280)),V=()=>{window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",V)};window.addEventListener("mousemove",ce),window.addEventListener("mouseup",V)},[w]),q=k.useMemo(()=>{var A;const R=[],J=new Set;for(const X of a){const B=`${X.from}:${(A=X.text)==null?void 0:A.slice(0,100)}`;R.find(U=>{var pe;return U.kind==="chat"&&`${U.from}:${(pe=U.text)==null?void 0:pe.slice(0,100)}`===B&&Math.abs(U.ts-X.timestamp)<5e3})||(R.push({...X,kind:"chat",ts:X.timestamp}),J.add(X.text))}const ae=J,ce=s.slice(-30);for(const X of ce)(X.text||"").trim()&&!ae.has(X.text)&&R.push({...X,kind:"activity",ts:X.timestamp});R.sort((X,B)=>X.ts-B.ts);const V=[];let T=[];for(const X of R)X.kind==="activity"?T.push(X):(T.length>0&&(V.push({kind:"activity-group",entries:T}),T=[]),V.push(X));return T.length>0&&V.push({kind:"activity-group",entries:T}),V},[a,s]);k.useEffect(()=>{j.current&&requestAnimationFrame(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)})},[q.length]);async function Q(R){var V;const J=Array.from(R.target.files||[]);if(J.length===0)return;const ae=P.getState().addToast,ce=[];for(const T of J)try{const A=await new Promise((X,B)=>{const F=new FileReader;F.onload=()=>X(F.result.split(",")[1]),F.onerror=B,F.readAsDataURL(T)});await D.post(`/agents/${t.id}/upload`,{filename:T.name,content:A}),ce.push(T.name)}catch(A){ae("error",`Upload failed: ${T.name}`,A.message)}if(ce.length>0){const T=ce.join(", ");m(A=>(A?A+`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
8
|
<title>Groove GUI</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-BbDDgazC.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-C0HXlhrU.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-BQPfi37R.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-BBL3i_JW.js">
|
|
@@ -258,15 +258,17 @@ function UserMessage({ msg }) {
|
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
function AssistantMessage({ msg, model }) {
|
|
261
|
+
function AssistantMessage({ msg, model, role }) {
|
|
262
262
|
const cleanText = stripEmojis(msg.text);
|
|
263
|
+
const displayName = model || 'Assistant';
|
|
264
|
+
const avatarRole = role || 'chat';
|
|
263
265
|
return (
|
|
264
266
|
<div className="flex gap-2.5">
|
|
265
|
-
<Avatar name={
|
|
267
|
+
<Avatar name={displayName} role={avatarRole} size="sm" className="mt-1 flex-shrink-0" />
|
|
266
268
|
<div className="max-w-[85%]">
|
|
267
|
-
|
|
268
|
-
<div className="
|
|
269
|
-
<div className="text-sm text-text-
|
|
269
|
+
<div className="text-2xs text-text-3 font-sans mb-1 font-medium">{displayName}</div>
|
|
270
|
+
<div className="border-l-2 border-accent/40 pl-3.5 py-1">
|
|
271
|
+
<div className="text-sm text-text-1 font-sans whitespace-pre-wrap break-words leading-relaxed">
|
|
270
272
|
<RenderedMarkdown text={cleanText} />
|
|
271
273
|
</div>
|
|
272
274
|
</div>
|
|
@@ -454,7 +456,7 @@ function ApiTypingIndicator() {
|
|
|
454
456
|
);
|
|
455
457
|
}
|
|
456
458
|
|
|
457
|
-
export function ChatMessages({ messages, isStreaming, model, mode, onImageReply }) {
|
|
459
|
+
export function ChatMessages({ messages, isStreaming, model, mode, onImageReply, role }) {
|
|
458
460
|
const scrollRef = useRef(null);
|
|
459
461
|
const isAtBottomRef = useRef(true);
|
|
460
462
|
|
|
@@ -489,7 +491,7 @@ export function ChatMessages({ messages, isStreaming, model, mode, onImageReply
|
|
|
489
491
|
if (msg.type === 'image') return <ImageMessage key={i} msg={msg} onReply={onImageReply} />;
|
|
490
492
|
if (msg.from === 'user') return <UserMessage key={i} msg={msg} />;
|
|
491
493
|
if (msg.from === 'system') return <SystemMessage key={i} msg={msg} />;
|
|
492
|
-
return <AssistantMessage key={i} msg={msg} model={model} />;
|
|
494
|
+
return <AssistantMessage key={i} msg={msg} model={model} role={role} />;
|
|
493
495
|
})}
|
|
494
496
|
{isStreaming && (
|
|
495
497
|
mode === 'agent' ? (
|
package/spash-page.png
DELETED
|
Binary file
|
package/ui.png
DELETED
|
Binary file
|
package/welcome.png
DELETED
|
Binary file
|