vzcode 2.9.0 → 2.10.0
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.
|
@@ -375,7 +375,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStat
|
|
|
375
375
|
`+n),r.b(" </div>"),r.b(`
|
|
376
376
|
`+n),r.b("</div>"),r.fl()},partials:{},subs:{}});mi["tag-file-added"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-changed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-deleted"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),r.fl()},partials:{},subs:{}});mi["tag-file-renamed"]=new ii.Template({code:function(t,e,n){var r=this;return r.b(n=n||""),r.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),r.fl()},partials:{},subs:{}});class Q_e{constructor({compiledTemplates:e={},rawTemplates:n={}}){const r=Object.entries(n).reduce((i,[o,s])=>{const a=ii.compile(s,{asString:!1});return Object.assign(Object.assign({},i),{[o]:a})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},mi),e),r)}static compile(e){return ii.compile(e,{asString:!1})}render(e,n,r,i,o){const s=this.templateKey(e,n);try{return this.preCompiledTemplates[s].render(r,i,o)}catch{throw new Error(`Could not find template to render '${s}'`)}}template(e,n){return this.preCompiledTemplates[this.templateKey(e,n)]}templateKey(e,n){return`${e}-${n}`}}const F_e=Object.assign(Object.assign(Object.assign({},fW),dW),{outputFormat:i_e.LINE_BY_LINE,drawFileList:!0});function B_e(t,e={}){const n=Object.assign(Object.assign({},F_e),e),r=typeof t=="string"?h_e(t,n):t,i=new Q_e(n),{colorScheme:o}=n,s={colorScheme:o},a=n.drawFileList?new E_e(i,s).render(r):"",l=n.outputFormat==="side-by-side"?new $_e(i,n).render(r):new A_e(i,n).render(r);return a+l}const U_e=({diffData:t})=>{const{content:e,openTab:n,setIsAIChatOpen:r}=N.useContext(Lr),i=N.useRef(null),o=Object.values(t).filter(c=>c.length>0);let s=0,a=0;for(const c of o){const f=n_e(c);s+=f.additions,a+=f.deletions}const l=r_e(t),u=B_e(l,{drawFileList:!1,matching:"words",diffStyle:"word",outputFormat:"line-by-line"});return N.useEffect(()=>{if(!i.current)return;const c=h=>{const p=h.target;if(p.classList.contains("d2h-file-name")){h.preventDefault(),h.stopPropagation(),console.log("File name clicked");const g=p.textContent?.trim();if(console.log("Clicked file name:",g),g){const y=e?.files;if(y){const O=Object.entries(y).find(([b,S])=>S.name===g)?.[0];console.log("Mapped file ID:",O),O&&(n({fileId:O,isTransient:!1}),r(!1))}}}},d=i.current.querySelectorAll(".d2h-file-name");return d.forEach(h=>{h.addEventListener("click",c),h.style.cursor="pointer",h.style.textDecoration="underline",h.style.color="#58a6ff"}),()=>{d.forEach(h=>{h.removeEventListener("click",c)})}},[u,e,n,r]),o.length===0?null:q.jsxs("div",{className:"diff-view",children:[q.jsx("div",{className:"diff-summary",children:q.jsxs("div",{className:"diff-stats",children:[q.jsxs("span",{className:"files-changed",children:[o.length," file",o.length!==1?"s":""," changed"]}),s>0&&q.jsxs("span",{className:"additions",children:["+",s]}),a>0&&q.jsxs("span",{className:"deletions",children:["-",a]})]})}),q.jsx("div",{className:"diff-files",ref:i,dangerouslySetInnerHTML:{__html:u}})]})},q_e=({id:t,role:e,content:n,timestamp:r,isStreaming:i,diffData:o,chatId:s})=>{const{additionalWidgets:a,handleSendMessage:l}=N.useContext(Lr),u=N.useMemo(()=>phe(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[r]),c=N.useMemo(()=>`ai-chat-message ${e}${i?" streaming":""}`,[e,i]);return q.jsxs("div",{className:c,children:[q.jsxs("div",{className:"ai-chat-message-content",children:[q.jsx(Nz,{remarkPlugins:[sW],children:n}),o&&Object.keys(o).length>0&&q.jsx(U_e,{diffData:o}),a&&s&&a({messageId:t,chatId:s,handleSendMessage:l})]}),q.jsx("div",{className:"ai-chat-message-time",children:u})]})},V_e=N.memo(q_e),z_e=()=>q.jsx("div",{className:"ai-chat-message assistant",children:q.jsx("div",{className:"ai-chat-message-content",children:q.jsxs("div",{className:"ai-chat-typing",children:[q.jsx("span",{}),q.jsx("span",{}),q.jsx("span",{})]})})}),W_e=N.memo(z_e),Z_e=({content:t,isVisible:e})=>{const n=N.useRef(null),[r,i]=N.useState(!1),[o,s]=N.useState(!0),a=N.useRef(),l=N.useCallback(()=>{const f=n.current;if(!f)return!0;const d=10,{scrollTop:h,scrollHeight:p,clientHeight:g}=f;return p-h-g<d},[]),u=N.useCallback(()=>{if(!o)return;const f=n.current;f&&f.scrollTo({top:f.scrollHeight,behavior:"smooth"})},[o]),c=N.useCallback(()=>{if(!n.current)return;const d=l();a.current&&clearTimeout(a.current),!d&&!r&&(i(!0),s(!1)),d&&r&&(a.current=setTimeout(()=>{i(!1),s(!0)},300))},[r,l]);return N.useEffect(()=>(o&&!r&&e&&t&&(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{u()},50)),()=>{a.current&&clearTimeout(a.current)}),[t,o,r,e,u]),N.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),N.useEffect(()=>{e&&(i(!1),s(!0))},[e]),!e||!t?null:q.jsxs("div",{className:"thinking-scratchpad",children:[q.jsxs("div",{className:"thinking-scratchpad-header",children:[q.jsx("span",{className:"thinking-scratchpad-icon",children:"🧠"}),q.jsx("span",{className:"thinking-scratchpad-title",children:"AI is thinking..."})]}),q.jsx("div",{className:"thinking-scratchpad-content",ref:n,onScroll:c,children:q.jsx(Nz,{remarkPlugins:[sW],children:t})})]})},X_e=N.memo(Z_e),H_e=({messages:t,isLoading:e,chatId:n,aiScratchpad:r})=>{const i=N.useRef(null),o=N.useRef(null),[s,a]=N.useState(!1),[l,u]=N.useState(!0),c=N.useRef(),f=N.useCallback(()=>{const k=o.current;if(!k)return!0;const x=50,{scrollTop:_,scrollHeight:I,clientHeight:M}=k;return I-_-M<x},[]),d=N.useCallback(()=>{l&&i.current?.scrollIntoView({behavior:"smooth",block:"end"})},[l]),h=N.useCallback(()=>{if(!o.current)return;const x=f();c.current&&clearTimeout(c.current),!x&&!s&&(a(!0),u(!1)),x&&s&&(c.current=setTimeout(()=>{a(!1),u(!0)},500))},[s,f]);N.useEffect(()=>(l&&!s&&(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d()},100)),()=>{c.current&&clearTimeout(c.current)}),[t,l,s,d]);const[p,g]=N.useState(e);N.useEffect(()=>{p&&!e&&(i.current?.scrollIntoView({behavior:"smooth",block:"end"}),a(!1),u(!0)),g(e)},[e,p]),N.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const y=t[t.length-1],O=y?.role==="assistant"&&y.content!=="",b=e&&!O,S=!!(r&&r.trim());return q.jsxs("div",{className:"ai-chat-messages",ref:o,onScroll:h,children:[t.map((k,x)=>q.jsx(V_e,{id:k.id,role:k.role,content:k.content,timestamp:k.timestamp,diffData:k.diffData,chatId:n},k.id)),S&&q.jsx(X_e,{content:r||"",isVisible:S}),b&&q.jsx(W_e,{}),q.jsx("div",{ref:i})]})},Y_e=N.memo(H_e),G_e=t=>{const[e,n]=N.useState(!1),[r,i]=N.useState(null),[,o]=N.useState("");N.useEffect(()=>{const l=window.SpeechRecognition||window.webkitSpeechRecognition;if(l){const u=new l;return u.continuous=!0,u.interimResults=!0,u.onresult=c=>{let f="",d="";for(let p=0;p<c.results.length;p++){const g=c.results[p];g.isFinal?f+=g[0].transcript:d+=g[0].transcript}o(f);const h=f+d;t(h)},u.onerror=c=>{console.error("Speech recognition error",c.error),n(!1)},u.onend=()=>{n(!1),o("")},i(u),()=>{u.abort()}}},[t]);const s=N.useCallback(()=>{if(!r){console.error("Speech recognition not supported in this browser");return}e?(r.stop(),n(!1)):(o(""),r.start(),n(!0))},[e,r]),a=N.useCallback(()=>{r&&e&&(r.stop(),n(!1),o(""))},[e,r]);return{isSpeaking:e,toggleSpeechRecognition:s,stopSpeaking:a}},K_e=({aiChatMessage:t,setAIChatMessage:e,onSendMessage:n,isLoading:r,focused:i,aiChatMode:o,setAIChatMode:s,navigateMessageHistoryUp:a,navigateMessageHistoryDown:l,resetMessageHistoryNavigation:u})=>{const c=N.useRef(null),{isSpeaking:f,toggleSpeechRecognition:d,stopSpeaking:h}=G_e(e);N.useEffect(()=>{i&&c.current&&c.current.focus()},[i]);const p=N.useCallback(O=>{if(O.key==="Enter"&&!O.shiftKey)O.preventDefault(),n();else if(O.key==="Enter"&&O.shiftKey)O.stopPropagation();else if(O.key==="ArrowUp"){const b=O.target,{selectionStart:S,value:k}=b;k.substring(0,S).split(`
|
|
377
377
|
`).length===1&&S===0&&(O.preventDefault(),a())}else if(O.key==="ArrowDown"){const b=O.target,{selectionStart:S,value:k}=b,_=k.substring(S).split(`
|
|
378
|
-
`);_.length===1&&_[0]===""&&(O.preventDefault(),l())}},[n,a,l]),g=N.useCallback(()=>{f&&h(),n()},[n,f,h]),y=N.useCallback(O=>{e(O.target.value),u()},[e,u]);return q.jsxs("div",{className:"ai-chat-input-container",children:[W1e,q.jsxs(Ir.Group,{className:"ai-chat-input-group",children:[q.jsx(Ir.Control,{as:"textarea",rows:5,value:t,onChange:y,onKeyDown:p,ref:c,placeholder:o==="edit"?"Ask me to make code changes...":"Ask me anything about your code...",spellCheck:"false",disabled:r,"aria-label":"Chat message input"}),q.jsxs("div",{className:"ai-chat-input-footer",children:[q.jsx("span",{className:"ai-chat-hint",children:t?"Press Enter to send":""}),q.jsxs("div",{style:{display:"flex",gap:"8px"},children:[q.jsx(Il,{variant:f?"danger":"outline-secondary",size:"sm",onClick:d,disabled:r,"aria-label":f?"Stop voice typing":"Start voice typing",title:f?"Stop voice typing":"Start voice typing",style:{borderColor:f?void 0:"#dee2e6",borderRadius:"0.375rem",borderWidth:"1px",borderStyle:"solid"},children:f?q.jsx(MOe,{}):q.jsx(AOe,{})}),q.jsx(Il,{variant:t.trim()?"primary":"outline-secondary",onClick:g,disabled:!t.trim()||r,className:"ai-chat-send-button","aria-label":"Send message",title:"Send message (Enter)",children:"Send"})]})]})]})]})},J_e=N.memo(K_e),eQ=!1,ePe=!1,tPe=()=>{const{aiChatFocused:t,content:e,aiChatMode:n,aiChatMessage:r,isLoading:i,currentChatId:o,selectedChatId:s,setSelectedChatId:a,aiErrorMessage:l,setAIChatMode:u,clearStoredAIPrompt:c,getStoredAIPrompt:f,setAIChatMessage:d,handleSendMessage:h,setAIErrorMessage:p,navigateMessageHistoryUp:g,navigateMessageHistoryDown:y,resetMessageHistoryNavigation:O}=N.useContext(Lr),b=s,S=b?e?.chats?.[b]:null,k=S?.messages||[],x=S?.aiStatus,_=S?.aiScratchpad,I=N.useMemo(()=>k.map((L,A)=>({...L,id:L.id||`msg-${A}`})),[k]),M=!s||k.length===0,P=e?.chats||{},R=Object.values(P).filter(L=>L.messages.length>0).length>0,T=N.useCallback(()=>(s||a(o),h()),[s,a,o,h]);return N.useEffect(()=>{if(f){const L=f();L&&(d(L.prompt),u(L.modelName==="ask"?"ask":"edit"),c(),setTimeout(()=>{h(L.prompt)},100))}},[f,c,d,u,h]),q.jsxs("div",{className:"ai-chat-container",children:[q.jsx("div",{className:"ai-chat-content",children:q.jsxs("div",{className:"ai-chat-messages-container",children:[M?q.jsxs("div",{className:"ai-chat-empty",children:[q.jsx("div",{className:"ai-chat-empty-icon",children:"✨"}),q.jsx("h3",{className:"ai-chat-empty-title",children:"Edit with AI"}),q.jsx("div",{className:"ai-chat-empty-text",children:"How can I help you?"}),R&&ePe,eQ,eQ]}):q.jsx(Y_e,{messages:I,aiStatus:x,isLoading:i,chatId:s||o,aiScratchpad:_}),l&&q.jsx("div",{className:"ai-chat-error",children:q.jsxs("div",{className:"ai-chat-error-content",children:[q.jsx("span",{className:"ai-chat-error-icon",children:"⚠️"}),q.jsx("span",{className:"ai-chat-error-message",children:l}),q.jsx("button",{className:"ai-chat-error-dismiss",onClick:()=>p(null),"aria-label":"Dismiss error",children:"×"})]})})]})}),q.jsx("div",{className:"ai-chat-input-fixed",children:q.jsx(J_e,{aiChatMessage:r,setAIChatMessage:d,onSendMessage:T,isLoading:i,focused:t,aiChatMode:n,setAIChatMode:u,navigateMessageHistoryUp:g,navigateMessageHistoryDown:y,resetMessageHistoryNavigation:O})})]})};function nPe(t){const e=t.split(".");switch(e[e.length-1]){case"jsx":case"tsx":return q.jsx(_Oe,{});case"js":return q.jsx(kOe,{});case"ts":return q.jsx(xOe,{});case"json":return q.jsx(TOe,{});case"md":return q.jsx(ROe,{});case"html":return q.jsx(COe,{});case"css":return q.jsx(EOe,{});case"svelte":return q.jsx(POe,{});default:return q.jsx(KV,{})}}const pR=({name:t})=>q.jsx("i",{className:"file-icon",children:N.useMemo(()=>nPe(t),[t])}),hW=({show:t,onClose:e,onConfirm:n,isDirectory:r,name:i})=>{const o=N.useCallback(s=>{s.key==="Enter"&&n()},[n]);return N.useEffect(()=>(t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}),[t,o]),q.jsxs($r,{show:t,onHide:e,centered:!0,children:[q.jsx($r.Header,{closeButton:!0,onClick:e,children:q.jsxs($r.Title,{children:["Delete"," ",i==="all files"?"All Files":r?"Directory":"File"]})}),q.jsx($r.Body,{children:q.jsx("p",{children:i==="all files"?"This will delete all files in the project.":q.jsxs(q.Fragment,{children:["This will delete the"," ",r?"directory":"file"," ",q.jsx("strong",{children:i}),"."]})})}),q.jsxs($r.Footer,{children:[q.jsx(Il,{variant:"secondary",type:"button",onClick:e,children:"Cancel"}),q.jsx(Il,{variant:"primary",onClick:n,children:"Delete"})]})]})},pW=({id:t,name:e,children:n,handleClick:r,handleDoubleClick:i,handleRenameClick:o,handleDeleteClick:s,isDirectory:a=!1,isActive:l=!1,renameFileTooltipText:u=a?"Rename Directory":"Rename File",deleteFileTooltipText:c=a?"Delete Directory":"Delete File"})=>{const{hoveredItemId:f,setHoveredItemId:d}=N.useContext(Lr),h=f===t,p=N.useCallback(H=>{d(H?t:null)},[t,d]),[g,y]=N.useState(!1),[O,b]=N.useState(""),[S,k]=N.useState(!1),x=N.useRef(null),_=N.useCallback(H=>{H.key==="Escape"?y(!1):H.key==="Enter"&&x.current.blur()},[]),I=N.useCallback(()=>{y(!1),x.current.value.trim()===""?k(!0):o(x.current.value)},[o]),M=N.useCallback(H=>{H.stopPropagation(),y(!g),b(e)},[e,g]);N.useEffect(()=>{g&&x.current.focus()},[g]);const P=N.useCallback(H=>{H.stopPropagation(),k(!0)},[]),E=N.useCallback(()=>{k(!1)},[]),R=N.useCallback(H=>{H?.stopPropagation(),k(!1),s()},[s]),T=N.useCallback(()=>{p(!0)},[]),L=N.useCallback(()=>{p(!1)},[]),A=N.useCallback(()=>{b(x.current.value)},[]);return q.jsxs("div",{className:`file-or-directory user-select-none ${l?"active-file":""}`,onClick:g?null:r,onDoubleClick:g||!i?null:i,onMouseEnter:T,onMouseLeave:L,children:[q.jsx("div",{className:"name",children:g?q.jsxs(q.Fragment,{children:[q.jsx(pR,{name:O}),q.jsx("input",{className:"rename-input",ref:x,type:"text","aria-label":"Field name",value:O,onKeyDown:_,onBlur:I,onChange:A})]}):n}),h&&!g?q.jsxs("div",{className:"utils",style:{position:"relative"},children:[q.jsx(ho,{placement:"top",overlay:q.jsx(po,{id:"rename-file-tooltip",children:u}),children:q.jsx("i",{onClick:M,className:"icon-button icon-button-dark",children:q.jsx(hOe,{})})}),q.jsx(ho,{placement:"top",overlay:q.jsx(po,{id:"delete-file-tooltip",children:c}),children:q.jsx("i",{onClick:P,className:"icon-button icon-button-dark",children:q.jsx(gOe,{})})})]}):null,S&&q.jsx(hW,{show:S,onClose:E,onConfirm:R,isDirectory:a,name:e})]})},rPe=({name:t,path:e,children:n,handleFileClick:r,handleFileDoubleClick:i})=>{const{renameDirectory:o,deleteDirectory:s,isDirectoryOpen:a,toggleDirectory:l}=N.useContext(Lr),u=N.useCallback(()=>{l(e)},[l,e]),c=N.useCallback(()=>{s(e)},[s,e]),f=N.useCallback(h=>{o(e,t,h)},[o,e,t]),d=N.useMemo(()=>a(e),[a,e]);return q.jsxs(q.Fragment,{children:[q.jsxs(pW,{id:e,name:t,handleClick:u,handleDeleteClick:c,handleRenameClick:f,isDirectory:!0,children:[q.jsx("div",{className:"arrow-wrapper",style:{transform:`rotate(${d?90:0}deg)`},children:q.jsx(JV,{})}),q.jsx("div",{className:"name",children:t})]}),n&&d?q.jsx("div",{className:"indentation",children:n.map(h=>{const{fileId:p}=h,{path:g}=h;return q.jsx(mW,{entity:h,handleFileClick:r,handleFileDoubleClick:i},p||g)})}):null]})},iPe=({presence:t})=>q.jsx("div",{className:"presence-indicators",children:t.map((e,n)=>{const i=`rgb(${Q8(e.username)})`;return q.jsx("div",{className:"presence-indicator",style:{backgroundColor:i},children:e.username[0]},n)})}),oPe=({name:t,fileId:e,handleFileClick:n,handleFileDoubleClick:r,isActive:i,presence:o})=>{const{renameFile:s,deleteFile:a}=N.useContext(Lr),l=N.useCallback(()=>{n(e)},[e,n]),u=N.useCallback(()=>{r(e)},[e,r]),c=N.useCallback(()=>{a(e)},[e,a]),f=N.useCallback(d=>{s(e,d)},[e,s]);return q.jsxs(pW,{id:e,name:t,handleClick:l,handleDoubleClick:u,handleDeleteClick:c,handleRenameClick:f,isActive:i,children:[q.jsx(iPe,{presence:o}),q.jsx(pR,{name:t}),t]})},mW=({entity:t,handleFileClick:e,handleFileDoubleClick:n})=>{const{activePane:r,sidebarPresenceIndicators:i}=N.useContext(Lr),{name:o,file:s,fileId:a}=t,{path:l,children:u}=t,c=i?.filter(f=>f.fileId===a)||[];return s?q.jsx(oPe,{fileId:a,name:o,handleFileClick:e,handleFileDoubleClick:n,isActive:a===r.activeFileId,presence:c}):q.jsx(rPe,{name:o,path:l,children:u,handleFileClick:e,handleFileDoubleClick:n})};function tQ(t,e,n,r){const i=t.state.doc.line(n).from+r;t.dispatch({selection:{anchor:i,head:i+e.length},scrollIntoView:!0,effects:kt.scrollIntoView(i,{y:"center"})})}function nQ(t,e){const n=t.scrollTop,r=n+t.clientHeight,i=e.offsetTop-t.offsetTop,o=i+e.clientHeight;return i>=n+100&&o<=r-100}const sPe=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{search:i,setSearch:o,activePaneId:s,setActiveFileId:a,setSearchResults:l,setSearchFileVisibility:u,setSearchLineVisibility:c,setSearchFocusedIndex:f,shareDBDoc:d,editorCache:h,openTab:p}=N.useContext(Lr),{pattern:g,results:y,focusedIndex:O,focusedChildIndex:b,focused:S}=i,k=N.useRef(null),x=Object.entries(y).filter(([E,R])=>R.visibility!=="closed");N.useEffect(()=>{if(t){r(g.trim().length>=1);const E=setTimeout(()=>{g.trim().length>=1&&k.current&&(l(d),r(!1))},2e3);return()=>clearTimeout(E)}else e(!0)},[g]);const _=N.useCallback((E,R)=>{u(d,E,R.visibility==="open"&&b===null?"flattened":"open")},[O,b]),I=N.useCallback(E=>{u(d,E,"closed")},[]),M=N.useCallback((E,R)=>{a(E),f(R,null)},[]),P=E=>{if(E.preventDefault(),x.length===0)return;const R=x[O][1].matches.length;switch(E.key){case"Tab":f(O,null);break;case"ArrowUp":if(O==0&&b==null)break;if(b===null||R==0){const H=x[O-1][1].matches.length;f(O-1,H>0?H-1:null)}else b===0?f(O,null):f(O,b-1);break;case"ArrowDown":if(O==x.length-1&&b==R-1)break;b===null&&R>0?f(O,0):b==R-1||R==0?f(O+1,null):f(O,b+1);break;case"ArrowLeft":b!==null?f(O,null):_(x[O][0],x[O][1]);break;case"ArrowRight":x[O][1].visibility!=="open"?_(x[O][0],x[O][1]):b===null&&R!==0&&f(O,0);break;case"Enter":case" ":const A=x[O][0];if(p({fileId:A,isTransient:!0}),a(A),b!==null){const H=x[O][1].matches[b].line,W=x[O][1].matches[b].index,Z=vm(A,s);h.has(Z)&&tQ(h.get(Z).editor,g,H,W)}break}const T=x[O][0],L=document.getElementById("sidebar-view-container");if(L)if(b===null){const A=document.getElementById(T);nQ(L,A)||A.scrollIntoView({block:"center"})}else{const A=x[O][1].matches[b].line,H=document.getElementById(T+"-"+A);nQ(L,H)||H.scrollIntoView({block:"center"})}};return N.useEffect(()=>{k.current&&k.current.focus()},[S]),q.jsxs("div",{children:[q.jsx(Ir.Group,{className:"sidebar-search-form mb-3",controlId:"searchName",children:q.jsx(Ir.Control,{type:"text",value:g,onChange:E=>o(E.target.value),ref:k,spellCheck:"false"})}),Object.keys(y).length>=1&&g.trim().length>=1?q.jsx("div",{onKeyDown:P,tabIndex:0,className:"search-results",children:x.map(([E,R],T)=>{const L=R.matches;return q.jsxs("div",{className:"search-result",children:[q.jsxs("div",{onClick:()=>M(E,T),id:E,className:`search-file-heading
|
|
378
|
+
`);_.length===1&&_[0]===""&&(O.preventDefault(),l())}},[n,a,l]),g=N.useCallback(()=>{f&&h(),n()},[n,f,h]),y=N.useCallback(O=>{e(O.target.value),u()},[e,u]);return q.jsxs("div",{className:"ai-chat-input-container",children:[W1e,q.jsxs(Ir.Group,{className:"ai-chat-input-group",children:[q.jsx(Ir.Control,{as:"textarea",rows:5,value:t,onChange:y,onKeyDown:p,ref:c,placeholder:o==="edit"?"Ask me to make code changes...":"Ask me anything about your code...",spellCheck:"false",disabled:r,"aria-label":"Chat message input"}),q.jsxs("div",{className:"ai-chat-input-footer",children:[q.jsx("span",{className:"ai-chat-hint",children:t?"Press Enter to send":""}),q.jsxs("div",{style:{display:"flex",gap:"8px"},children:[q.jsx(Il,{variant:f?"danger":"outline-secondary",size:"sm",onClick:d,disabled:r,"aria-label":f?"Stop voice typing":"Start voice typing",title:f?"Stop voice typing":"Start voice typing",style:{borderColor:f?void 0:"#dee2e6",borderRadius:"0.375rem",borderWidth:"1px",borderStyle:"solid"},children:f?q.jsx(MOe,{}):q.jsx(AOe,{})}),q.jsx(Il,{variant:t.trim()?"primary":"outline-secondary",onClick:g,disabled:!t.trim()||r,className:"ai-chat-send-button","aria-label":"Send message",title:"Send message (Enter)",children:"Send"})]})]})]})]})},J_e=N.memo(K_e),eQ=!1,ePe=!1,tPe=()=>{const{aiChatFocused:t,content:e,aiChatMode:n,aiChatMessage:r,isLoading:i,currentChatId:o,selectedChatId:s,setSelectedChatId:a,aiErrorMessage:l,setAIChatMode:u,clearStoredAIPrompt:c,getStoredAIPrompt:f,setAIChatMessage:d,handleSendMessage:h,setAIErrorMessage:p,navigateMessageHistoryUp:g,navigateMessageHistoryDown:y,resetMessageHistoryNavigation:O}=N.useContext(Lr),b=s,S=b?e?.chats?.[b]:null,k=S?.messages||[];S?.aiStatus;const x=S?.aiScratchpad,_=N.useMemo(()=>k.map((T,L)=>({...T,id:T.id||`msg-${L}`})),[k]),I=!s||k.length===0,M=e?.chats||{},E=Object.values(M).filter(T=>T.messages.length>0).length>0,R=N.useCallback(()=>(s||a(o),h()),[s,a,o,h]);return N.useEffect(()=>{if(f){const T=f();T&&(d(T.prompt),u(T.modelName==="ask"?"ask":"edit"))}},[f,d,u]),q.jsxs("div",{className:"ai-chat-container",children:[q.jsx("div",{className:"ai-chat-content",children:q.jsxs("div",{className:"ai-chat-messages-container",children:[I?q.jsxs("div",{className:"ai-chat-empty",children:[q.jsx("div",{className:"ai-chat-empty-icon",children:"✨"}),q.jsx("h3",{className:"ai-chat-empty-title",children:"Edit with AI"}),q.jsx("div",{className:"ai-chat-empty-text",children:"How can I help you?"}),E&&ePe,eQ,eQ]}):q.jsx(Y_e,{messages:_,isLoading:i,chatId:s||o,aiScratchpad:x}),l&&q.jsx("div",{className:"ai-chat-error",children:q.jsxs("div",{className:"ai-chat-error-content",children:[q.jsx("span",{className:"ai-chat-error-icon",children:"⚠️"}),q.jsx("span",{className:"ai-chat-error-message",children:l}),q.jsx("button",{className:"ai-chat-error-dismiss",onClick:()=>p(null),"aria-label":"Dismiss error",children:"×"})]})})]})}),q.jsx("div",{className:"ai-chat-input-fixed",children:q.jsx(J_e,{aiChatMessage:r,setAIChatMessage:d,onSendMessage:R,isLoading:i,focused:t,aiChatMode:n,setAIChatMode:u,navigateMessageHistoryUp:g,navigateMessageHistoryDown:y,resetMessageHistoryNavigation:O})})]})};function nPe(t){const e=t.split(".");switch(e[e.length-1]){case"jsx":case"tsx":return q.jsx(_Oe,{});case"js":return q.jsx(kOe,{});case"ts":return q.jsx(xOe,{});case"json":return q.jsx(TOe,{});case"md":return q.jsx(ROe,{});case"html":return q.jsx(COe,{});case"css":return q.jsx(EOe,{});case"svelte":return q.jsx(POe,{});default:return q.jsx(KV,{})}}const pR=({name:t})=>q.jsx("i",{className:"file-icon",children:N.useMemo(()=>nPe(t),[t])}),hW=({show:t,onClose:e,onConfirm:n,isDirectory:r,name:i})=>{const o=N.useCallback(s=>{s.key==="Enter"&&n()},[n]);return N.useEffect(()=>(t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}),[t,o]),q.jsxs($r,{show:t,onHide:e,centered:!0,children:[q.jsx($r.Header,{closeButton:!0,onClick:e,children:q.jsxs($r.Title,{children:["Delete"," ",i==="all files"?"All Files":r?"Directory":"File"]})}),q.jsx($r.Body,{children:q.jsx("p",{children:i==="all files"?"This will delete all files in the project.":q.jsxs(q.Fragment,{children:["This will delete the"," ",r?"directory":"file"," ",q.jsx("strong",{children:i}),"."]})})}),q.jsxs($r.Footer,{children:[q.jsx(Il,{variant:"secondary",type:"button",onClick:e,children:"Cancel"}),q.jsx(Il,{variant:"primary",onClick:n,children:"Delete"})]})]})},pW=({id:t,name:e,children:n,handleClick:r,handleDoubleClick:i,handleRenameClick:o,handleDeleteClick:s,isDirectory:a=!1,isActive:l=!1,renameFileTooltipText:u=a?"Rename Directory":"Rename File",deleteFileTooltipText:c=a?"Delete Directory":"Delete File"})=>{const{hoveredItemId:f,setHoveredItemId:d}=N.useContext(Lr),h=f===t,p=N.useCallback(H=>{d(H?t:null)},[t,d]),[g,y]=N.useState(!1),[O,b]=N.useState(""),[S,k]=N.useState(!1),x=N.useRef(null),_=N.useCallback(H=>{H.key==="Escape"?y(!1):H.key==="Enter"&&x.current.blur()},[]),I=N.useCallback(()=>{y(!1),x.current.value.trim()===""?k(!0):o(x.current.value)},[o]),M=N.useCallback(H=>{H.stopPropagation(),y(!g),b(e)},[e,g]);N.useEffect(()=>{g&&x.current.focus()},[g]);const P=N.useCallback(H=>{H.stopPropagation(),k(!0)},[]),E=N.useCallback(()=>{k(!1)},[]),R=N.useCallback(H=>{H?.stopPropagation(),k(!1),s()},[s]),T=N.useCallback(()=>{p(!0)},[]),L=N.useCallback(()=>{p(!1)},[]),A=N.useCallback(()=>{b(x.current.value)},[]);return q.jsxs("div",{className:`file-or-directory user-select-none ${l?"active-file":""}`,onClick:g?null:r,onDoubleClick:g||!i?null:i,onMouseEnter:T,onMouseLeave:L,children:[q.jsx("div",{className:"name",children:g?q.jsxs(q.Fragment,{children:[q.jsx(pR,{name:O}),q.jsx("input",{className:"rename-input",ref:x,type:"text","aria-label":"Field name",value:O,onKeyDown:_,onBlur:I,onChange:A})]}):n}),h&&!g?q.jsxs("div",{className:"utils",style:{position:"relative"},children:[q.jsx(ho,{placement:"top",overlay:q.jsx(po,{id:"rename-file-tooltip",children:u}),children:q.jsx("i",{onClick:M,className:"icon-button icon-button-dark",children:q.jsx(hOe,{})})}),q.jsx(ho,{placement:"top",overlay:q.jsx(po,{id:"delete-file-tooltip",children:c}),children:q.jsx("i",{onClick:P,className:"icon-button icon-button-dark",children:q.jsx(gOe,{})})})]}):null,S&&q.jsx(hW,{show:S,onClose:E,onConfirm:R,isDirectory:a,name:e})]})},rPe=({name:t,path:e,children:n,handleFileClick:r,handleFileDoubleClick:i})=>{const{renameDirectory:o,deleteDirectory:s,isDirectoryOpen:a,toggleDirectory:l}=N.useContext(Lr),u=N.useCallback(()=>{l(e)},[l,e]),c=N.useCallback(()=>{s(e)},[s,e]),f=N.useCallback(h=>{o(e,t,h)},[o,e,t]),d=N.useMemo(()=>a(e),[a,e]);return q.jsxs(q.Fragment,{children:[q.jsxs(pW,{id:e,name:t,handleClick:u,handleDeleteClick:c,handleRenameClick:f,isDirectory:!0,children:[q.jsx("div",{className:"arrow-wrapper",style:{transform:`rotate(${d?90:0}deg)`},children:q.jsx(JV,{})}),q.jsx("div",{className:"name",children:t})]}),n&&d?q.jsx("div",{className:"indentation",children:n.map(h=>{const{fileId:p}=h,{path:g}=h;return q.jsx(mW,{entity:h,handleFileClick:r,handleFileDoubleClick:i},p||g)})}):null]})},iPe=({presence:t})=>q.jsx("div",{className:"presence-indicators",children:t.map((e,n)=>{const i=`rgb(${Q8(e.username)})`;return q.jsx("div",{className:"presence-indicator",style:{backgroundColor:i},children:e.username[0]},n)})}),oPe=({name:t,fileId:e,handleFileClick:n,handleFileDoubleClick:r,isActive:i,presence:o})=>{const{renameFile:s,deleteFile:a}=N.useContext(Lr),l=N.useCallback(()=>{n(e)},[e,n]),u=N.useCallback(()=>{r(e)},[e,r]),c=N.useCallback(()=>{a(e)},[e,a]),f=N.useCallback(d=>{s(e,d)},[e,s]);return q.jsxs(pW,{id:e,name:t,handleClick:l,handleDoubleClick:u,handleDeleteClick:c,handleRenameClick:f,isActive:i,children:[q.jsx(iPe,{presence:o}),q.jsx(pR,{name:t}),t]})},mW=({entity:t,handleFileClick:e,handleFileDoubleClick:n})=>{const{activePane:r,sidebarPresenceIndicators:i}=N.useContext(Lr),{name:o,file:s,fileId:a}=t,{path:l,children:u}=t,c=i?.filter(f=>f.fileId===a)||[];return s?q.jsx(oPe,{fileId:a,name:o,handleFileClick:e,handleFileDoubleClick:n,isActive:a===r.activeFileId,presence:c}):q.jsx(rPe,{name:o,path:l,children:u,handleFileClick:e,handleFileDoubleClick:n})};function tQ(t,e,n,r){const i=t.state.doc.line(n).from+r;t.dispatch({selection:{anchor:i,head:i+e.length},scrollIntoView:!0,effects:kt.scrollIntoView(i,{y:"center"})})}function nQ(t,e){const n=t.scrollTop,r=n+t.clientHeight,i=e.offsetTop-t.offsetTop,o=i+e.clientHeight;return i>=n+100&&o<=r-100}const sPe=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{search:i,setSearch:o,activePaneId:s,setActiveFileId:a,setSearchResults:l,setSearchFileVisibility:u,setSearchLineVisibility:c,setSearchFocusedIndex:f,shareDBDoc:d,editorCache:h,openTab:p}=N.useContext(Lr),{pattern:g,results:y,focusedIndex:O,focusedChildIndex:b,focused:S}=i,k=N.useRef(null),x=Object.entries(y).filter(([E,R])=>R.visibility!=="closed");N.useEffect(()=>{if(t){r(g.trim().length>=1);const E=setTimeout(()=>{g.trim().length>=1&&k.current&&(l(d),r(!1))},2e3);return()=>clearTimeout(E)}else e(!0)},[g]);const _=N.useCallback((E,R)=>{u(d,E,R.visibility==="open"&&b===null?"flattened":"open")},[O,b]),I=N.useCallback(E=>{u(d,E,"closed")},[]),M=N.useCallback((E,R)=>{a(E),f(R,null)},[]),P=E=>{if(E.preventDefault(),x.length===0)return;const R=x[O][1].matches.length;switch(E.key){case"Tab":f(O,null);break;case"ArrowUp":if(O==0&&b==null)break;if(b===null||R==0){const H=x[O-1][1].matches.length;f(O-1,H>0?H-1:null)}else b===0?f(O,null):f(O,b-1);break;case"ArrowDown":if(O==x.length-1&&b==R-1)break;b===null&&R>0?f(O,0):b==R-1||R==0?f(O+1,null):f(O,b+1);break;case"ArrowLeft":b!==null?f(O,null):_(x[O][0],x[O][1]);break;case"ArrowRight":x[O][1].visibility!=="open"?_(x[O][0],x[O][1]):b===null&&R!==0&&f(O,0);break;case"Enter":case" ":const A=x[O][0];if(p({fileId:A,isTransient:!0}),a(A),b!==null){const H=x[O][1].matches[b].line,W=x[O][1].matches[b].index,Z=vm(A,s);h.has(Z)&&tQ(h.get(Z).editor,g,H,W)}break}const T=x[O][0],L=document.getElementById("sidebar-view-container");if(L)if(b===null){const A=document.getElementById(T);nQ(L,A)||A.scrollIntoView({block:"center"})}else{const A=x[O][1].matches[b].line,H=document.getElementById(T+"-"+A);nQ(L,H)||H.scrollIntoView({block:"center"})}};return N.useEffect(()=>{k.current&&k.current.focus()},[S]),q.jsxs("div",{children:[q.jsx(Ir.Group,{className:"sidebar-search-form mb-3",controlId:"searchName",children:q.jsx(Ir.Control,{type:"text",value:g,onChange:E=>o(E.target.value),ref:k,spellCheck:"false"})}),Object.keys(y).length>=1&&g.trim().length>=1?q.jsx("div",{onKeyDown:P,tabIndex:0,className:"search-results",children:x.map(([E,R],T)=>{const L=R.matches;return q.jsxs("div",{className:"search-result",children:[q.jsxs("div",{onClick:()=>M(E,T),id:E,className:`search-file-heading
|
|
379
379
|
${O==T&&b==null?"active":""}`,children:[q.jsxs("div",{className:"search-file-title",children:[q.jsx("div",{className:"arrow-wrapper",onClick:()=>_(E,R),style:{transform:`rotate(${R.visibility==="open"?90:0}deg)`},children:q.jsx(JV,{})}),q.jsxs("div",{className:"search-file-name",children:[q.jsx(pR,{name:R.name}),q.jsx("h5",{children:R.name})]})]}),q.jsx("div",{className:"search-file-info",children:T==O&&b==null?q.jsx("span",{className:"search-file-close",onClick:A=>{A.stopPropagation(),I(E),f(Math.max(0,T-1),null)},children:q.jsx(VO,{})}):q.jsx("h6",{className:"search-file-count",children:L.length})})]}),q.jsx("div",{className:"search-file-lines",children:(R.visibility==="open"||R.visibility==="flattened"&&T==O&&b!==null)&&R.matches.map((A,H)=>{const W=A.text.substring(0,A.index),Z=A.text.substring(A.index,A.index+g.length),G=A.text.substring(A.index+g.length),K=R.name+"-"+A.line;return q.jsxs("div",{tabIndex:T==O?0:-1,id:E+"-"+A.line,className:`search-line
|
|
380
380
|
${O==T&&b==H?"active":""}`,children:[q.jsxs("p",{onClick:()=>{f(T,H),p({fileId:E,isTransient:!0}),a(E);const U=vm(E,s);h.has(U)&&tQ(h.get(U).editor,g,A.line,A.index)},children:[W,q.jsx("span",{className:"search-pattern",children:Z}),G]},R.name+" - "+A.line+" - "+A.index),O==T&&b===H&&q.jsx("span",{className:"search-file-close",onClick:U=>{U.stopPropagation(),c(d,E,A.line),H==0&&f(T,null)},children:q.jsx(VO,{})})]},K)})})]},R.name)})}):q.jsx("div",{className:"search-state",children:q.jsx("h6",{children:n?"Searching...":"No Results"})})]})},Ys=!1,aPe=()=>{const[t,e]=N.useState(!1),[n,r]=N.useState(!1),{createFile:i}=N.useContext(Lr),o=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),e(!0)},[]),s=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),t||e(!0)},[t]),a=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),e(!1)},[]),l=p=>["text/","application/json","application/javascript","application/typescript","application/xml","application/x-httpd-php"].some(O=>p.type.startsWith(O))||p.name.match(/\.(txt|js|jsx|ts|tsx|md|css|scss|html|xml|json|php|py|rb|java|c|cpp|h|hpp)$/i)!==null,u=p=>["image/"].some(O=>p.type.startsWith(O))||p.name.match(/\.(png|jpg|jpeg|gif|bmp|svg|webp)$/i)!==null,c=p=>new Promise((g,y)=>{if(!l(p)){y(new Error(`File ${p.name} is not a text file`));return}const O=new FileReader;O.onload=b=>{b.target?.result?g(b.target.result):y(new Error(`Failed to read file ${p.name}`))},O.onerror=()=>{y(new Error(`Error reading file ${p.name}`))},O.readAsText(p)}),f=p=>new Promise((g,y)=>{if(!u(p)){y(new Error(`File ${p.name} is not an image file`));return}if(p.type==="image/svg+xml"||p.name.toLowerCase().endsWith(".svg")){const b=new FileReader;b.onload=S=>{S.target?.result?g(S.target.result):y(new Error(`Failed to read SVG file ${p.name}`))},b.onerror=()=>y(new Error(`Error reading SVG file ${p.name}`)),b.readAsText(p);return}const O=new FileReader;O.onload=b=>{if(b.target?.result){const S=b.target.result.split(",")[1];g(S)}else y(new Error(`Failed to read image file ${p.name}`))},O.onerror=()=>{y(new Error(`Error reading image file ${p.name}`))},O.readAsDataURL(p)}),d=async(p,g)=>{try{if(Ys&&console.log(`[useDragAndDrop] Processing entry: ${p.name} at path: ${g}`),p.isFile)Ys&&console.log(`[useDragAndDrop] Processing file: ${p.name}`),p.file(async y=>{try{if(u(y)){const O=await f(y);Ys&&console.log(`[useDragAndDrop] Creating image file: ${g}${y.name}`),i(`${g}${y.name}`,O)}else{const O=await c(y);Ys&&console.log(`[useDragAndDrop] Creating text file: ${g}${y.name}`),i(`${g}${y.name}`,O)}}catch(O){console.error(`Error processing file ${y.name}:`,O)}});else if(p.isDirectory)return Ys&&console.log(`[useDragAndDrop] Processing directory: ${p.name}`),new Promise(y=>{const O=p.createReader(),b=()=>{O.readEntries(async S=>{if(S.length===0){Ys&&console.log(`[useDragAndDrop] Finished reading directory: ${p.name}`),y();return}const k=`${g}${p.name}/`;Ys&&console.log(`[useDragAndDrop] Reading ${S.length} entries in directory: ${k}`),await Promise.all(S.map(x=>d(x,k))),b()})};b()})}catch(y){console.error(`Error processing entry ${p.name}:`,y)}},h=N.useCallback(async p=>{p.preventDefault(),p.stopPropagation(),e(!1),r(!0);try{const g=p.dataTransfer.items;Ys&&console.log(`[useDragAndDrop] Processing ${g.length} dropped items`);const y=[];for(const O of Array.from(g)){const b=O.webkitGetAsEntry?.()||O.getAsEntry?.()||O.createEntry?.();if(b)Ys&&console.log(`[useDragAndDrop] Got entry for: ${b.name}`),y.push(b);else if(O.kind==="file"){const S=O.getAsFile();if(S){Ys&&console.log(`[useDragAndDrop] Processing dropped file: ${S.name}`);try{if(u(S)){const k=await f(S);i(S.name,k)}else{const k=await c(S);i(S.name,k)}}catch(k){console.error(`Error processing file ${S.name}:`,k)}}}}Ys&&console.log(`[useDragAndDrop] Processing ${y.length} entries`),await Promise.all(y.map(O=>d(O,"")))}catch(g){console.error("Error processing dropped items:",g)}finally{r(!1)}},[i]);return{isDragOver:t,isProcessing:n,handleDragEnter:o,handleDragOver:s,handleDragLeave:a,handleDrop:h}};function lPe(t,e){const n={},d=[{regex:/^\s*###\s*`([^`]+)`\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Backtick-Heading Format",key:"backtick-heading"},{regex:/^\s*###\s*File:\s*\*\*(.+?)\*\*\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"File Bold Format",key:"file-bold"},{regex:/^\s*###\s*\d+\.\s*`([^`]+)`(?:[^\n]*\n)*?\s*```(?:\w+)?\n([\s\S]*?)```/gm,format:"Numbered Backtick Format",key:"numbered-backtick"},{regex:/^### \*\*([^\n`]+?)\*\*\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Heading Bold Format",key:"heading-bold"},{regex:/^\s*###\s*(?!`|File:|\d+\.)\s*([^\n`]+?)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Standard Heading Format",key:"standard-heading"},{regex:/^\s*(?!###|\*\*|`)([^\n#*`]+?):\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Colon Format",key:"colon"},{regex:/^\s*(?!###)\*\*([^\n*`]+?)\*\*(?:[^\n]*)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Bold Format",key:"bold"},{regex:/^\s*# ([^\n`]+?)\s*\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Hash Format",key:"hash"},{regex:/^\s*\d+\.\s*\*\*([^\n`]+?)\*\*[\s\S]*?\n```(?:\w+)?\n([\s\S]*?)```/gm,format:"Numbered Bold Format",key:"numbered-bold"}];let h=d;{const g=d.find(y=>y.key===e);if(!g)throw new Error(`Unsupported format: ${e}`);h=[g]}let p="Unknown Format";for(const{regex:g,format:y}of h){g.lastIndex=0;const O={};let b;for(;(b=g.exec(t))!==null;){let S=b[1].trim();y==="Bold Format"&&(S=S.replace(/\s*\([^)]*\).*$/,"").trim());const k=b[2].trim();O[S]=k}if(Object.keys(O).length>0){Object.assign(n,O),p=y;break}}return{files:n,format:p}}const uPe=t=>t.endsWith(".html")?"html":t.endsWith(".js")?"javascript":t.endsWith(".css")?"css":"",cPe=t=>Object.entries(t).map(([e,n])=>[`**${e}**
|
|
381
381
|
`,"```"+uPe(e),n,"```\n"].join(`
|
package/dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-CsDf6ybm.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-Bjj9VRMn.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
|
@@ -126,6 +126,8 @@ export const AIChat = () => {
|
|
|
126
126
|
]);
|
|
127
127
|
|
|
128
128
|
// Check for stored AI prompt on component mount (post-fork restoration)
|
|
129
|
+
// This logic is now handled by the AutoSendAIMessage component in VizHub
|
|
130
|
+
// to ensure proper timing and coordination with editor opening
|
|
129
131
|
useEffect(() => {
|
|
130
132
|
DEBUG &&
|
|
131
133
|
console.log('AIChat: Checking for stored AI prompt');
|
|
@@ -137,41 +139,29 @@ export const AIChat = () => {
|
|
|
137
139
|
storedPrompt,
|
|
138
140
|
);
|
|
139
141
|
if (storedPrompt) {
|
|
140
|
-
//
|
|
142
|
+
// Only restore the prompt and mode, but don't auto-send
|
|
143
|
+
// The AutoSendAIMessage component will handle the sending
|
|
141
144
|
DEBUG &&
|
|
142
|
-
console.log(
|
|
145
|
+
console.log(
|
|
146
|
+
'AIChat: Restoring prompt and mode only',
|
|
147
|
+
);
|
|
143
148
|
setAIChatMessage(storedPrompt.prompt);
|
|
144
149
|
setAIChatMode(
|
|
145
150
|
storedPrompt.modelName === 'ask' ? 'ask' : 'edit',
|
|
146
151
|
);
|
|
147
152
|
|
|
148
|
-
//
|
|
153
|
+
// Don't clear the stored prompt here - let AutoSendAIMessage handle it
|
|
154
|
+
// Don't auto-submit here - let AutoSendAIMessage handle the timing
|
|
149
155
|
DEBUG &&
|
|
150
|
-
console.log(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// Auto-submit the restored prompt after a short delay
|
|
154
|
-
DEBUG &&
|
|
155
|
-
console.log('AIChat: Scheduling auto-submit');
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
DEBUG &&
|
|
158
|
-
console.log(
|
|
159
|
-
'AIChat: Auto-submitting restored prompt',
|
|
160
|
-
);
|
|
161
|
-
handleSendMessage(storedPrompt.prompt);
|
|
162
|
-
}, 100);
|
|
156
|
+
console.log(
|
|
157
|
+
'AIChat: Prompt restored, waiting for AutoSendAIMessage to handle sending',
|
|
158
|
+
);
|
|
163
159
|
} else {
|
|
164
160
|
DEBUG &&
|
|
165
161
|
console.log('AIChat: No stored prompt found');
|
|
166
162
|
}
|
|
167
163
|
}
|
|
168
|
-
}, [
|
|
169
|
-
getStoredAIPrompt,
|
|
170
|
-
clearStoredAIPrompt,
|
|
171
|
-
setAIChatMessage,
|
|
172
|
-
setAIChatMode,
|
|
173
|
-
handleSendMessage,
|
|
174
|
-
]);
|
|
164
|
+
}, [getStoredAIPrompt, setAIChatMessage, setAIChatMode]);
|
|
175
165
|
|
|
176
166
|
return (
|
|
177
167
|
<div className="ai-chat-container">
|
|
@@ -307,7 +297,6 @@ export const AIChat = () => {
|
|
|
307
297
|
) : (
|
|
308
298
|
<MessageList
|
|
309
299
|
messages={messages}
|
|
310
|
-
aiStatus={aiStatus}
|
|
311
300
|
isLoading={isLoading}
|
|
312
301
|
chatId={selectedChatId || currentChatId}
|
|
313
302
|
aiScratchpad={aiScratchpad}
|