diff --git a/extension/react-app/src/util/jetbrains.ts b/extension/react-app/src/util/jetbrains.ts index 1c22df20d..1be7809a8 100644 --- a/extension/react-app/src/util/jetbrains.ts +++ b/extension/react-app/src/util/jetbrains.ts @@ -28,6 +28,28 @@ export const handleKeyDownJetBrainsMac = (e, text: string, setText) => { e.target.selectionStart = prevNewLineIndex + 1; e.target.selectionEnd = prevNewLineIndex + 1; } + } else if (isCmdOrCtrlPressed) { + const startPos = e.target.selectionStart; + const endPos = e.target.selectionEnd; + let newStartPos = startPos; + let newEndPos = endPos; + const isShiftPressed = e.shiftKey; + + if (e.key === "ArrowLeft") { + const prevNewLineIndex = text.lastIndexOf("\n", startPos - 1); + + newStartPos = prevNewLineIndex === -1 ? 0 : prevNewLineIndex + 1; + newEndPos = isShiftPressed ? endPos : newStartPos; + } else if (e.key === "ArrowRight") { + const nextNewLineIndex = text.indexOf("\n", startPos); + + newEndPos = nextNewLineIndex === -1 ? text.length : nextNewLineIndex; + newStartPos = isShiftPressed ? newStartPos : newEndPos; + } + + e.target.selectionStart = newStartPos; + e.target.selectionEnd = newEndPos; + e.preventDefault(); } }; @@ -64,5 +86,28 @@ export const handleKeyDownJetBrains = (e, text: string, setText) => { e.target.selectionEnd = prevSpaceIndex + 1; }, 10); } + } else if (isCtrlPressed && e.key === "c") { + // If Ctrl+C is pressed, copy the selected text + e.preventDefault(); + e.stopPropagation(); + if (startPos !== endPos) { + const selectedText = text.slice(startPos, endPos); + navigator.clipboard.writeText(selectedText); + } + } else if (isCtrlPressed && e.key === "v") { + // If Ctrl+V is pressed, paste the copied text at the cursor position + e.preventDefault(); + e.stopPropagation(); + navigator.clipboard.readText().then((clipText) => { + const newValue = text.slice(0, startPos) + clipText + text.slice(endPos); + setText(newValue); + + // Set the cursor to the end of the pasted text + const newCursorPos = startPos + clipText.length; + setTimeout(() => { + e.target.selectionStart = newCursorPos; + e.target.selectionEnd = newCursorPos; + }, 10); + }); } }; diff --git a/intellij-extension/gradle.properties b/intellij-extension/gradle.properties index 5e0642774..bc5a94c35 100644 --- a/intellij-extension/gradle.properties +++ b/intellij-extension/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension pluginName = continue-intellij-extension pluginRepositoryUrl = https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion = 0.0.12 +pluginVersion = 0.0.13 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 223 diff --git a/intellij-extension/src/main/resources/webview/assets/index.js b/intellij-extension/src/main/resources/webview/assets/index.js index c440abdd8..28fdc9258 100644 --- a/intellij-extension/src/main/resources/webview/assets/index.js +++ b/intellij-extension/src/main/resources/webview/assets/index.js @@ -453,8 +453,10 @@ Hint: It might not be working because maybe you're not up to date with the Meili opacity: 0.7; `} } -`;function ece(e){const t=Lt(i=>i.config.vscMediaUrl),[n,r]=C.useState(localStorage.getItem("continueButtonColor"));return C.useEffect(()=>{const i=a=>{a.key==="continueButtonColor"&&r(a.newValue)};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),x.jsx(Jue,{showStop:e.showStop,color:n,hidden:e.hidden,style:{fontSize:"10px"},className:"m-auto press-start-2p",onClick:e.disabled?void 0:e.onClick,isDisabled:e.disabled,children:e.showStop?x.jsxs(x.Fragment,{children:[x.jsx(SY,{width:"18px",height:"18px"}),"STOP"]}):x.jsxs(x.Fragment,{children:[t?x.jsx("img",{src:`${t}/play_button.png`,height:"18px"}):x.jsx(AL,{width:"18px",height:"18px"}),"CONTINUE"]})})}const tce={history:{timeline:[],current_index:3},user_input_queue:[],active:!1,slash_commands:[],adding_highlighted_code:!1,selected_context_items:[],config:{system_message:"",temperature:.5}},b7=Op({name:"serverState",initialState:tce,reducers:{setServerState:(e,t)=>{e.selected_context_items=[],e.user_input_queue=[],e.slash_commands=[],Object.assign(e,t.payload)},temporarilyPushToUserInputQueue:(e,t)=>{e.user_input_queue=[...e.user_input_queue,t.payload]},temporarilyCreateNewUserInput:(e,t)=>{e.history.timeline=[...e.history.timeline,{step:{description:t.payload,name:"User Input",hide:!1},depth:0,active:!1,context_used:e.selected_context_items}]},temporarilyClearSession:(e,t)=>{e.history.timeline=[],e.selected_context_items=[],e.session_info={title:t.payload?"Loading session...":"New Session",session_id:"",date_created:""}}}}),{setServerState:nce,temporarilyPushToUserInputQueue:rce,temporarilyClearSession:P0,temporarilyCreateNewUserInput:ice}=b7.actions,ace=b7.reducer,E7=Op({name:"misc",initialState:{highlightedCode:"",takenAction:!1,serverStatusMessage:"Continue Server Starting"},reducers:{setHighlightedCode:(e,t)=>{e.highlightedCode=t.payload},setTakenActionTrue:(e,t)=>{e.takenAction=!0},setServerStatusMessage:(e,t)=>{e.serverStatusMessage=t.payload}}}),{setHighlightedCode:oce,setTakenActionTrue:qd,setServerStatusMessage:sce}=E7.actions,lce=E7.reducer,uce=(e,t,n)=>{if(Dg(e)&&e.key==="Backspace"){e.preventDefault();const i=e.target.selectionStart,a=e.target.selectionEnd;if(i!==a){const o=t.slice(0,i)+t.slice(a);n(o),e.target.selectionStart=i,e.target.selectionEnd=i}else{const o=t.lastIndexOf(` -`,i-1),s=t.slice(0,o+1)+t.slice(i);n(s),e.target.selectionStart=o+1,e.target.selectionEnd=o+1}}},cce=(e,t,n)=>{const r=e.target.selectionStart,i=e.target.selectionEnd;if(Dg(e)&&e.key==="Backspace")if(e.preventDefault(),r!==i){const o=t.slice(0,r)+t.slice(i);n(o),e.target.selectionStart=r,e.target.selectionEnd=r}else{const o=t.slice(0,r).trimEnd().lastIndexOf(" "),s=t.slice(0,o+1)+t.slice(r);n(s),console.log(o),setTimeout(()=>{e.target.selectionStart=o+1,e.target.selectionEnd=o+1},10)}},dce="continue_context_items",pce=qm` +`;function ece(e){const t=Lt(i=>i.config.vscMediaUrl),[n,r]=C.useState(localStorage.getItem("continueButtonColor"));return C.useEffect(()=>{const i=a=>{a.key==="continueButtonColor"&&r(a.newValue)};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),x.jsx(Jue,{showStop:e.showStop,color:n,hidden:e.hidden,style:{fontSize:"10px"},className:"m-auto press-start-2p",onClick:e.disabled?void 0:e.onClick,isDisabled:e.disabled,children:e.showStop?x.jsxs(x.Fragment,{children:[x.jsx(SY,{width:"18px",height:"18px"}),"STOP"]}):x.jsxs(x.Fragment,{children:[t?x.jsx("img",{src:`${t}/play_button.png`,height:"18px"}):x.jsx(AL,{width:"18px",height:"18px"}),"CONTINUE"]})})}const tce={history:{timeline:[],current_index:3},user_input_queue:[],active:!1,slash_commands:[],adding_highlighted_code:!1,selected_context_items:[],config:{system_message:"",temperature:.5}},b7=Op({name:"serverState",initialState:tce,reducers:{setServerState:(e,t)=>{e.selected_context_items=[],e.user_input_queue=[],e.slash_commands=[],Object.assign(e,t.payload)},temporarilyPushToUserInputQueue:(e,t)=>{e.user_input_queue=[...e.user_input_queue,t.payload]},temporarilyCreateNewUserInput:(e,t)=>{e.history.timeline=[...e.history.timeline,{step:{description:t.payload,name:"User Input",hide:!1},depth:0,active:!1,context_used:e.selected_context_items}]},temporarilyClearSession:(e,t)=>{e.history.timeline=[],e.selected_context_items=[],e.session_info={title:t.payload?"Loading session...":"New Session",session_id:"",date_created:""}}}}),{setServerState:nce,temporarilyPushToUserInputQueue:rce,temporarilyClearSession:P0,temporarilyCreateNewUserInput:ice}=b7.actions,ace=b7.reducer,E7=Op({name:"misc",initialState:{highlightedCode:"",takenAction:!1,serverStatusMessage:"Continue Server Starting"},reducers:{setHighlightedCode:(e,t)=>{e.highlightedCode=t.payload},setTakenActionTrue:(e,t)=>{e.takenAction=!0},setServerStatusMessage:(e,t)=>{e.serverStatusMessage=t.payload}}}),{setHighlightedCode:oce,setTakenActionTrue:qd,setServerStatusMessage:sce}=E7.actions,lce=E7.reducer,uce=(e,t,n)=>{const r=Dg(e);if(r&&e.key==="Backspace"){e.preventDefault();const i=e.target.selectionStart,a=e.target.selectionEnd;if(i!==a){const o=t.slice(0,i)+t.slice(a);n(o),e.target.selectionStart=i,e.target.selectionEnd=i}else{const o=t.lastIndexOf(` +`,i-1),s=t.slice(0,o+1)+t.slice(i);n(s),e.target.selectionStart=o+1,e.target.selectionEnd=o+1}}else if(r){const i=e.target.selectionStart,a=e.target.selectionEnd;let o=i,s=a;const u=e.shiftKey;if(e.key==="ArrowLeft"){const c=t.lastIndexOf(` +`,i-1);o=c===-1?0:c+1,s=u?a:o}else if(e.key==="ArrowRight"){const c=t.indexOf(` +`,i);s=c===-1?t.length:c,o=u?o:s}e.target.selectionStart=o,e.target.selectionEnd=s,e.preventDefault()}},cce=(e,t,n)=>{const r=e.target.selectionStart,i=e.target.selectionEnd,a=Dg(e);if(a&&e.key==="Backspace")if(e.preventDefault(),r!==i){const o=t.slice(0,r)+t.slice(i);n(o),e.target.selectionStart=r,e.target.selectionEnd=r}else{const o=t.slice(0,r).trimEnd().lastIndexOf(" "),s=t.slice(0,o+1)+t.slice(r);n(s),console.log(o),setTimeout(()=>{e.target.selectionStart=o+1,e.target.selectionEnd=o+1},10)}else if(a&&e.key==="c"){if(e.preventDefault(),e.stopPropagation(),r!==i){const o=t.slice(r,i);navigator.clipboard.writeText(o)}}else a&&e.key==="v"&&(e.preventDefault(),e.stopPropagation(),navigator.clipboard.readText().then(o=>{const s=t.slice(0,r)+o+t.slice(i);n(s);const u=r+o.length;setTimeout(()=>{e.target.selectionStart=u,e.target.selectionEnd=u},10)}))},dce="continue_context_items",pce=qm` 0% { background-position: 0px 0; } @@ -756,7 +758,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho top: 0; z-index: 100; background-color: ${Pt}; -`;function lD(e){var ue,ce;const t=C.useContext(Oa),n=V7(),r=jo(),i=Wo(),a=Lt(Z=>Z.serverState.history),o=Lt(Z=>{var V;return(V=Z.serverState.config.models)==null?void 0:V.default}),s=Lt(Z=>Z.misc.serverStatusMessage),u=Lt(Z=>Z.serverState.user_input_queue),c=Lt(Z=>{var V;return(V=Z.serverState.session_info)==null?void 0:V.title}),[p,f]=C.useState(!1),[m,g]=C.useState([]),[E,b]=C.useState(!0),[T,y]=C.useState(!0),_=C.useRef(null),A=C.useRef(null),w=C.useRef(null),D=Lt(Z=>Z.uiState.bottomMessage),k=Lt(Z=>Z.misc.takenAction);C.useEffect(()=>{w.current&&r(bue(w.current.getBoundingClientRect().top{var V;const Z=()=>{var F,re;const N=((F=A.current)==null?void 0:F.scrollTop)||0,ye=((re=A.current)==null?void 0:re.scrollHeight)||0,ae=window.innerHeight||0;N+ae+-25>=ye?B(!1):B(!0)};return(V=A.current)==null||V.addEventListener("scroll",Z),()=>{window.removeEventListener("scroll",Z)}},[A.current]),C.useLayoutEffect(()=>{var Z,V;R||(V=A.current)==null||V.scrollTo({top:(Z=A.current)==null?void 0:Z.scrollHeight,behavior:"instant"})},[(ue=A.current)==null?void 0:ue.scrollHeight,a.timeline]),C.useEffect(()=>{const Z=V=>{var he;V.key==="Backspace"&&Dg(V)&&!V.shiftKey&&typeof(a==null?void 0:a.current_index)<"u"&&((he=a.timeline[a.current_index])!=null&&he.active)?t==null||t.deleteAtIndex(a.current_index):V.key==="Escape"&&r(Bl(void 0))};return window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z)}},[t,a]),C.useEffect(()=>{t==null||t.onStateUpdate(Z=>{var he;const V=Z.active&&Z.history.current_index{const ye=[...N];for(let ae=ye.length;ae{if(t&&E){b(!1);for(const Z of u)t.sendMainInput(Z)}},[t,u,E]);const K=Z=>{var V,he;if(r(qd(null)),_.current){let N=_.current.inputValue;if(N.trim()==="")return;if(N.startsWith("#")&&(N.length===7||N.length===4)){localStorage.setItem("continueButtonColor",N),_.current.setInputValue("");return}if(Z&&Dg(Z)&&(N=`/codebase ${N}`),_.current.setInputValue(""),!t){r(rce(N));return}if((o==null?void 0:o.class_name)==="OpenAIFreeTrial"&&(o==null?void 0:o.api_key)===""&&(!N.startsWith("/")||N.startsWith("/edit"))){const ae=localStorage.getItem("ftc");if(ae){const F=parseInt(ae);if(localStorage.setItem("ftc",(F+1).toString()),F>=250){r(Nc(!0)),r(Ty(x.jsx(ppe,{})));return}}else localStorage.setItem("ftc","1")}if(f(!0),a&&a.current_index>=0&&a.current_index{F.preventDefault(),n==null||n.capture("user_interest_form",{name:F.target.elements[0].value,email:F.target.elements[1].value}),r(Ty(x.jsx("div",{className:"text-center p-4",children:"Thanks! We'll be in touch soon."})))},style:{display:"flex",flexDirection:"column",gap:"10px"},children:[x.jsx("input",{style:{padding:"10px",borderRadius:"5px"},type:"text",name:"name",placeholder:"Name",required:!0}),x.jsx("input",{style:{padding:"10px",borderRadius:"5px"},type:"email",name:"email",placeholder:"Email",required:!0}),x.jsx("button",{style:{padding:"10px",borderRadius:"5px",cursor:"pointer"},type:"submit",children:"Submit"})]})]}))),r(mue(!1)),r(Nc(!0)))}else localStorage.setItem("mainTextEntryCounter","1")}},P=(Z,V)=>{t&&t.sendStepUserInput(Z,V)},J=C.useCallback(Z=>{const V=[];let he=-1;for(let N=Z;N>=0;N--)if((a==null?void 0:a.timeline.length)>N&&a.timeline[N].step.name==="User Input"&&a.timeline[N].step.hide===!1){V.push(N),he=N;break}if(V.length===0)return[];for(let N=he+1;N<(a==null?void 0:a.timeline.length)&&!((a==null?void 0:a.timeline.length)>N&&a.timeline[N].step.name==="User Input"&&a.timeline[N].step.hide===!1);N++)V.push(N);return V},[a.timeline]),$=C.useCallback(Z=>{const V=J(Z),he=V[0];g(N=>{const ye=[...N];return ye[Z]=!ye[Z],!V.some((F,re)=>re>0&&ye[F])?ye[he]=!1:!V.some((re,Se)=>Se>0&&!ye[re])&&(ye[he]=!0),ye})},[J]);C.useEffect(()=>{c&&pe(c)},[c]);const[oe,pe]=C.useState(c||"New Session");return x.jsxs(Epe,{ref:A,onKeyDown:Z=>{Z.key==="Enter"&&Z.ctrlKey&&K()},children:[x.jsxs(Tpe,{children:[x.jsx(ype,{onClick:Z=>{Z.target.setSelectionRange(0,Z.target.value.length)},value:oe,onChange:Z=>pe(Z.target.value),onBlur:Z=>{Z.target.value===c||typeof c>"u"&&Z.target.value==="New Session"||t==null||t.setCurrentSessionTitle(Z.target.value)},onKeyDown:Z=>{Z.key==="Enter"?(Z.preventDefault(),Z.target.blur()):Z.key==="Escape"&&(pe(c||"New Session"),Z.target.blur())}}),x.jsxs("div",{className:"flex gap-2",children:[a.timeline.filter(Z=>!Z.step.hide).length>0&&x.jsx(ni,{onClick:()=>{a.timeline.filter(Z=>!Z.step.hide).length>0&&(r(P0(!1)),t==null||t.loadSession(void 0))},text:"New Session (⌥⌘N)",children:x.jsx(wL,{width:"1.4em",height:"1.4em"})}),x.jsx(ni,{onClick:()=>{i("/history")},text:"History",children:x.jsx(JK,{width:"1.4em",height:"1.4em"})})]})]}),(k||T)&&typeof t>"u"&&x.jsxs(x.Fragment,{children:[x.jsx(Xde,{}),x.jsx("p",{style:{textAlign:"center",margin:"0px",fontSize:"14px"},children:s}),x.jsxs("div",{className:"flex mx-8 my-2",children:[x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},children:x.jsx("u",{children:x.jsx("a",{style:{color:"inherit"},href:"https://continue.dev/docs/troubleshooting",target:"_blank",children:"Troubleshooting help"})})}),x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},onClick:()=>{Ms("toggleDevTools",{})},children:x.jsx("u",{children:"View logs"})}),x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},children:x.jsx("u",{children:x.jsx("a",{style:{color:"inherit"},href:"https://continue.dev/docs/walkthroughs/manually-run-continue#recommended-use-the-continuedev-pypi-package",target:"_blank",children:"Manually start server"})})})]})]}),x.jsx("br",{}),x.jsx(bpe,{onClick:Z=>{t==null||t.sendMainInput(Z)}}),x.jsx(vpe,{children:a==null?void 0:a.timeline.map((Z,V)=>{var he,N,ye;return Z.step.hide?null:x.jsx(C.Fragment,{children:Z.step.name==="User Input"?Z.step.hide||x.jsx(pO,{isMainInput:!1,value:Z.step.description,active:J(V).some(ae=>a.timeline[ae].active)||a.timeline[V].active,onEnter:(ae,F)=>{F&&(t==null||t.editStepAtIndex(F,V)),ae==null||ae.stopPropagation(),ae==null||ae.preventDefault()},groupIndices:J(V),onToggle:ae=>{g(F=>{const re=[...F];return J(V).forEach(Se=>{re[Se]=ae}),re})},onToggleAll:ae=>{g(F=>F.map(re=>ae))},isToggleOpen:typeof m[V]>"u"?!0:m[V],index:V,onDelete:()=>{J(V).forEach(ae=>{t==null||t.deleteAtIndex(ae)})}}):x.jsx(Jde,{historyNode:Z,iconElement:Z.step.class_name==="DefaultModelEditCodeStep"?x.jsx(GK,{width:"16px",height:"16px"}):(he=Z.observation)!=null&&he.error?x.jsx(SL,{width:"16px",height:"16px",color:"red"}):x.jsx(TL,{width:"16px",height:"16px"}),open:typeof m[V]>"u"?!((N=Z.observation)!=null&&N.error):m[V],onToggle:()=>$(V),children:(ye=Z.observation)!=null&&ye.error?x.jsx(t1e,{onClose:()=>$(V),historyNode:Z,onDelete:()=>t==null?void 0:t.deleteAtIndex(V)}):x.jsx(lse,{index:V,isLast:V===a.timeline.length-1,isFirst:V===0,open:typeof m[V]>"u"?!0:m[V],onUserInput:ae=>{P(ae,V)},inFuture:V>(a==null?void 0:a.current_index),historyNode:Z,onReverse:()=>{t==null||t.reverseToIndex(V)},onRetry:()=>{t==null||t.retryAtIndex(V),f(!0)},onDelete:()=>{t==null||t.deleteAtIndex(V)},noUserInputParent:J(V).length===0},V)})},V)})}),x.jsx("div",{children:(ce=u==null?void 0:u.map)==null?void 0:ce.call(u,(Z,V)=>x.jsx(_pe,{children:Z},V))}),x.jsx("div",{ref:w}),x.jsx(pO,{isMainInput:!0,ref:_,onEnter:(Z,V)=>{K(Z),Z==null||Z.stopPropagation(),Z==null||Z.preventDefault()},onInputValueChange:()=>{},onToggleAddContext:()=>{t==null||t.toggleAddingHighlightedCode()}})]})}const Spe=Be.div` +`;function lD(e){var ue,ce;const t=C.useContext(Oa),n=V7(),r=jo(),i=Wo(),a=Lt(Z=>Z.serverState.history),o=Lt(Z=>{var V;return(V=Z.serverState.config.models)==null?void 0:V.default}),s=Lt(Z=>Z.misc.serverStatusMessage),u=Lt(Z=>Z.serverState.user_input_queue),c=Lt(Z=>{var V;return(V=Z.serverState.session_info)==null?void 0:V.title}),[p,f]=C.useState(!1),[m,g]=C.useState([]),[E,b]=C.useState(!0),[T,y]=C.useState(!0),_=C.useRef(null),A=C.useRef(null),w=C.useRef(null),D=Lt(Z=>Z.uiState.bottomMessage),k=Lt(Z=>Z.misc.takenAction);C.useEffect(()=>{w.current&&r(bue(w.current.getBoundingClientRect().top{var V;const Z=()=>{var F,re;const N=((F=A.current)==null?void 0:F.scrollTop)||0,ye=((re=A.current)==null?void 0:re.scrollHeight)||0,ae=window.innerHeight||0;N+ae+-25>=ye?B(!1):B(!0)};return(V=A.current)==null||V.addEventListener("scroll",Z),()=>{window.removeEventListener("scroll",Z)}},[A.current]),C.useLayoutEffect(()=>{var Z,V;R||(V=A.current)==null||V.scrollTo({top:(Z=A.current)==null?void 0:Z.scrollHeight,behavior:"instant"})},[(ue=A.current)==null?void 0:ue.scrollHeight,a.timeline]),C.useEffect(()=>{const Z=V=>{var he;V.key==="Backspace"&&Dg(V)&&!V.shiftKey&&typeof(a==null?void 0:a.current_index)<"u"&&((he=a.timeline[a.current_index])!=null&&he.active)?t==null||t.deleteAtIndex(a.current_index):V.key==="Escape"&&r(Bl(void 0))};return window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z)}},[t,a]),C.useEffect(()=>{t==null||t.onStateUpdate(Z=>{var he;const V=Z.active&&Z.history.current_index{const ye=[...N];for(let ae=ye.length;ae{if(t&&E){b(!1);for(const Z of u)t.sendMainInput(Z)}},[t,u,E]);const K=Z=>{var V,he;if(r(qd(null)),_.current){let N=_.current.inputValue;if(N.trim()==="")return;if(N.startsWith("#")&&(N.length===7||N.length===4)){localStorage.setItem("continueButtonColor",N),_.current.setInputValue("");return}if(Z&&Dg(Z)&&(N=`/edit ${N}`),_.current.setInputValue(""),!t){r(rce(N));return}if((o==null?void 0:o.class_name)==="OpenAIFreeTrial"&&(o==null?void 0:o.api_key)===""&&(!N.startsWith("/")||N.startsWith("/edit"))){const ae=localStorage.getItem("ftc");if(ae){const F=parseInt(ae);if(localStorage.setItem("ftc",(F+1).toString()),F>=250){r(Nc(!0)),r(Ty(x.jsx(ppe,{})));return}}else localStorage.setItem("ftc","1")}if(f(!0),a&&a.current_index>=0&&a.current_index{F.preventDefault(),n==null||n.capture("user_interest_form",{name:F.target.elements[0].value,email:F.target.elements[1].value}),r(Ty(x.jsx("div",{className:"text-center p-4",children:"Thanks! We'll be in touch soon."})))},style:{display:"flex",flexDirection:"column",gap:"10px"},children:[x.jsx("input",{style:{padding:"10px",borderRadius:"5px"},type:"text",name:"name",placeholder:"Name",required:!0}),x.jsx("input",{style:{padding:"10px",borderRadius:"5px"},type:"email",name:"email",placeholder:"Email",required:!0}),x.jsx("button",{style:{padding:"10px",borderRadius:"5px",cursor:"pointer"},type:"submit",children:"Submit"})]})]}))),r(mue(!1)),r(Nc(!0)))}else localStorage.setItem("mainTextEntryCounter","1")}},P=(Z,V)=>{t&&t.sendStepUserInput(Z,V)},J=C.useCallback(Z=>{const V=[];let he=-1;for(let N=Z;N>=0;N--)if((a==null?void 0:a.timeline.length)>N&&a.timeline[N].step.name==="User Input"&&a.timeline[N].step.hide===!1){V.push(N),he=N;break}if(V.length===0)return[];for(let N=he+1;N<(a==null?void 0:a.timeline.length)&&!((a==null?void 0:a.timeline.length)>N&&a.timeline[N].step.name==="User Input"&&a.timeline[N].step.hide===!1);N++)V.push(N);return V},[a.timeline]),$=C.useCallback(Z=>{const V=J(Z),he=V[0];g(N=>{const ye=[...N];return ye[Z]=!ye[Z],!V.some((F,re)=>re>0&&ye[F])?ye[he]=!1:!V.some((re,Se)=>Se>0&&!ye[re])&&(ye[he]=!0),ye})},[J]);C.useEffect(()=>{c&&pe(c)},[c]);const[oe,pe]=C.useState(c||"New Session");return x.jsxs(Epe,{ref:A,onKeyDown:Z=>{Z.key==="Enter"&&Z.ctrlKey&&K()},children:[x.jsxs(Tpe,{children:[x.jsx(ype,{onClick:Z=>{Z.target.setSelectionRange(0,Z.target.value.length)},value:oe,onChange:Z=>pe(Z.target.value),onBlur:Z=>{Z.target.value===c||typeof c>"u"&&Z.target.value==="New Session"||t==null||t.setCurrentSessionTitle(Z.target.value)},onKeyDown:Z=>{Z.key==="Enter"?(Z.preventDefault(),Z.target.blur()):Z.key==="Escape"&&(pe(c||"New Session"),Z.target.blur())}}),x.jsxs("div",{className:"flex gap-2",children:[a.timeline.filter(Z=>!Z.step.hide).length>0&&x.jsx(ni,{onClick:()=>{a.timeline.filter(Z=>!Z.step.hide).length>0&&(r(P0(!1)),t==null||t.loadSession(void 0))},text:"New Session (⌥⌘N)",children:x.jsx(wL,{width:"1.4em",height:"1.4em"})}),x.jsx(ni,{onClick:()=>{i("/history")},text:"History",children:x.jsx(JK,{width:"1.4em",height:"1.4em"})})]})]}),(k||T)&&typeof t>"u"&&x.jsxs(x.Fragment,{children:[x.jsx(Xde,{}),x.jsx("p",{style:{textAlign:"center",margin:"0px",fontSize:"14px"},children:s}),x.jsxs("div",{className:"flex mx-8 my-2",children:[x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},children:x.jsx("u",{children:x.jsx("a",{style:{color:"inherit"},href:"https://continue.dev/docs/troubleshooting",target:"_blank",children:"Troubleshooting help"})})}),x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},onClick:()=>{Ms("toggleDevTools",{})},children:x.jsx("u",{children:"View logs"})}),x.jsx("p",{style:{margin:"auto",textAlign:"center",marginTop:"4px",fontSize:"12px",cursor:"pointer",opacity:.7},children:x.jsx("u",{children:x.jsx("a",{style:{color:"inherit"},href:"https://continue.dev/docs/walkthroughs/manually-run-continue#recommended-use-the-continuedev-pypi-package",target:"_blank",children:"Manually start server"})})})]})]}),x.jsx("br",{}),x.jsx(bpe,{onClick:Z=>{t==null||t.sendMainInput(Z)}}),x.jsx(vpe,{children:a==null?void 0:a.timeline.map((Z,V)=>{var he,N,ye;return Z.step.hide?null:x.jsx(C.Fragment,{children:Z.step.name==="User Input"?Z.step.hide||x.jsx(pO,{isMainInput:!1,value:Z.step.description,active:J(V).some(ae=>a.timeline[ae].active)||a.timeline[V].active,onEnter:(ae,F)=>{F&&(t==null||t.editStepAtIndex(F,V)),ae==null||ae.stopPropagation(),ae==null||ae.preventDefault()},groupIndices:J(V),onToggle:ae=>{g(F=>{const re=[...F];return J(V).forEach(Se=>{re[Se]=ae}),re})},onToggleAll:ae=>{g(F=>F.map(re=>ae))},isToggleOpen:typeof m[V]>"u"?!0:m[V],index:V,onDelete:()=>{J(V).forEach(ae=>{t==null||t.deleteAtIndex(ae)})}}):x.jsx(Jde,{historyNode:Z,iconElement:Z.step.class_name==="DefaultModelEditCodeStep"?x.jsx(GK,{width:"16px",height:"16px"}):(he=Z.observation)!=null&&he.error?x.jsx(SL,{width:"16px",height:"16px",color:"red"}):x.jsx(TL,{width:"16px",height:"16px"}),open:typeof m[V]>"u"?!((N=Z.observation)!=null&&N.error):m[V],onToggle:()=>$(V),children:(ye=Z.observation)!=null&&ye.error?x.jsx(t1e,{onClose:()=>$(V),historyNode:Z,onDelete:()=>t==null?void 0:t.deleteAtIndex(V)}):x.jsx(lse,{index:V,isLast:V===a.timeline.length-1,isFirst:V===0,open:typeof m[V]>"u"?!0:m[V],onUserInput:ae=>{P(ae,V)},inFuture:V>(a==null?void 0:a.current_index),historyNode:Z,onReverse:()=>{t==null||t.reverseToIndex(V)},onRetry:()=>{t==null||t.retryAtIndex(V),f(!0)},onDelete:()=>{t==null||t.deleteAtIndex(V)},noUserInputParent:J(V).length===0},V)})},V)})}),x.jsx("div",{children:(ce=u==null?void 0:u.map)==null?void 0:ce.call(u,(Z,V)=>x.jsx(_pe,{children:Z},V))}),x.jsx("div",{ref:w}),x.jsx(pO,{isMainInput:!0,ref:_,onEnter:(Z,V)=>{K(Z),Z==null||Z.stopPropagation(),Z==null||Z.preventDefault()},onInputValueChange:()=>{},onToggleAddContext:()=>{t==null||t.toggleAddingHighlightedCode()}})]})}const Spe=Be.div` display: flex; flex-direction: row; align-items: center;