cursor-local-remote 0.1.7 → 0.1.9
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/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +28 -21
- package/.next/app-path-routes-manifest.json +7 -6
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +20 -20
- package/.next/required-server-files.json +1 -2
- package/.next/routes-manifest.json +1 -1
- package/.next/server/app/_not-found/page.js +11 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +11 -1
- package/.next/server/app/_not-found.rsc +14 -15
- package/.next/server/app/api/chat/route.js +3 -9
- package/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route.js +6 -0
- package/.next/server/app/api/git/route.js.nft.json +1 -0
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/info/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models/route.js +3 -9
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/projects/route.js +15 -0
- package/.next/server/app/api/projects/route.js.nft.json +1 -0
- package/.next/server/app/api/projects/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/active/route.js +1 -1
- package/.next/server/app/api/sessions/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/history/route.js +1 -1
- package/.next/server/app/api/sessions/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/route.js +3 -9
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/watch/route.js +2 -2
- package/.next/server/app/api/sessions/watch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/route.js +3 -9
- package/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/upload/route.js +1 -0
- package/.next/server/app/api/upload/route.js.nft.json +1 -0
- package/.next/server/app/api/upload/route_client-reference-manifest.js +1 -0
- package/.next/server/app/index.html +11 -1
- package/.next/server/app/index.rsc +16 -17
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +13 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +7 -6
- package/.next/server/chunks/819.js +1 -0
- package/.next/server/instrumentation.js +1 -1
- package/.next/server/instrumentation.js.nft.json +1 -1
- package/.next/server/middleware-manifest.json +1 -1
- package/.next/server/pages/404.html +11 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/src/middleware.js +1 -1
- package/.next/static/cH5h87qDQAGoVaAIw15pq/_buildManifest.js +1 -0
- package/.next/static/chunks/app/api/chat/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/git/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/info/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/models/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/projects/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/sessions/active/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/sessions/history/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/sessions/watch/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/settings/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/api/upload/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/layout-c1b1bf5b5f175921.js +1 -0
- package/.next/static/chunks/app/manifest.webmanifest/route-4be467a4132150d7.js +1 -0
- package/.next/static/chunks/app/page-cd57aa6c99572600.js +1 -0
- package/.next/static/css/7a31a6ac831a221c.css +1 -0
- package/README.md +18 -25
- package/bin/dev.mjs +98 -0
- package/next.config.mjs +3 -3
- package/package.json +3 -4
- package/public/sw.js +2 -63
- package/.next/server/app/api/push/subscribe/route.js +0 -21
- package/.next/server/app/api/push/subscribe/route.js.nft.json +0 -1
- package/.next/server/app/api/push/subscribe/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/push/vapid-key/route.js +0 -21
- package/.next/server/app/api/push/vapid-key/route.js.nft.json +0 -1
- package/.next/server/app/api/push/vapid-key/route_client-reference-manifest.js +0 -1
- package/.next/server/chunks/369.js +0 -21
- package/.next/server/chunks/407.js +0 -1
- package/.next/server/chunks/519.js +0 -21
- package/.next/server/chunks/848.js +0 -1
- package/.next/static/FopTfwgkaVjrbw4A5Ol85/_buildManifest.js +0 -1
- package/.next/static/chunks/app/api/chat/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/info/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/models/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/push/subscribe/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/push/vapid-key/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/sessions/active/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/sessions/history/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/sessions/watch/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/api/settings/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/layout-168baea1ba298a10.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-0de2bc720406b0f8.js +0 -1
- package/.next/static/chunks/app/page-df671bcff0abba4f.js +0 -1
- package/.next/static/css/e600fbf434173a2f.css +0 -1
- /package/.next/static/{FopTfwgkaVjrbw4A5Ol85 → cH5h87qDQAGoVaAIw15pq}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[558],{2317:(e,n,o)=>{"use strict";o.d(n,{PwaInstall:()=>r});var s=o(5155),t=o(2115);function r(){return(0,t.useEffect)(()=>{o.e(561).then(o.bind(o,9561)).catch(()=>{})},[]),(0,s.jsx)("pwa-install",{"manifest-url":"/manifest.webmanifest",name:"Cursor Local Remote",description:"Control Cursor IDE from any device on your local network",icon:"/apple-touch-icon.png"})}},3673:()=>{},5293:(e,n,o)=>{Promise.resolve().then(o.t.bind(o,3673,23)),Promise.resolve().then(o.bind(o,2317))}},e=>{e.O(0,[978,441,255,358],()=>e(e.s=5293)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9,26,64,97,177,252,276,337,413,552,822,974],{4441:()=>{}},_=>{_.O(0,[441,255,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[593],{2673:(e,t,s)=>{Promise.resolve().then(s.bind(s,9050)),Promise.resolve().then(s.bind(s,5932))},5932:(e,t,s)=>{"use strict";s.d(t,{ErrorBoundary:()=>a});var r=s(5155),n=s(2115);class a extends n.Component{static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("Uncaught render error:",e,t.componentStack)}render(){return this.state.error?"inline"===this.props.fallback?(0,r.jsx)("div",{className:"h-full flex items-center justify-center px-6",children:(0,r.jsxs)("div",{className:"text-center max-w-sm",children:[(0,r.jsx)("p",{className:"text-[13px] font-medium text-text mb-2",children:"Something went wrong"}),(0,r.jsx)("p",{className:"text-[11px] text-text-muted mb-3 font-mono break-all",children:this.state.error.message}),(0,r.jsx)("button",{onClick:()=>this.setState({error:null}),className:"px-3 py-1 rounded-lg text-[12px] font-medium bg-bg-surface text-text border border-border hover:bg-bg-hover transition-colors",children:"Try again"})]})}):(0,r.jsx)("div",{className:"h-dvh flex items-center justify-center bg-[#0a0a0b] px-6",children:(0,r.jsxs)("div",{className:"text-center max-w-sm",children:[(0,r.jsx)("p",{className:"text-[14px] font-medium text-[#e8e8e8] mb-2",children:"Something went wrong"}),(0,r.jsx)("p",{className:"text-[12px] text-[#888] mb-4 font-mono break-all",children:this.state.error.message}),(0,r.jsx)("button",{onClick:()=>this.setState({error:null}),className:"px-4 py-1.5 rounded-lg text-[12px] font-medium bg-[#1c1c1c] text-[#e8e8e8] border border-[#2a2a2a] hover:bg-[#252525] transition-colors",children:"Try again"})]})}):this.props.children}constructor(...e){super(...e),this.state={error:null}}}},9050:(e,t,s)=>{"use strict";s.d(t,{ChatWorkspace:()=>eL});var r=s(5155),n=s(2115),a=s(154);function l(){let{trigger:e}=(0,a.Y)();return{tap:()=>e("light"),send:()=>e("success"),select:()=>e("selection"),warn:()=>e("warning"),error:()=>e("error")}}function o(e,t){let s=Error(t);return s.name="ApiError",s.status=e,s.body={error:t},s}let i=new Set([502,503,504]);async function c(e,t,s){let{timeoutMs:r=3e4,retries:n,...a}=t,l=new AbortController,d=setTimeout(()=>l.abort(),r);try{let r=await fetch(e,{...a,credentials:"same-origin",signal:l.signal});if(!r.ok){if(s>0&&i.has(r.status))return await new Promise(e=>setTimeout(e,500)),c(e,t,s-1);let n="HTTP ".concat(r.status);try{let e=await r.json();e.error&&(n=e.error)}catch(e){}throw o(r.status,n)}return r}catch(r){if(r instanceof Error&&"AbortError"===r.name){if(s>0)return await new Promise(e=>setTimeout(e,500)),c(e,t,s-1);throw o(0,"Request timed out")}throw r}finally{clearTimeout(d)}}function d(e){var t;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e,s,null!=(t=s.retries)?t:2)}function x(){var e;return"function"==typeof(null==(e=globalThis.crypto)?void 0:e.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}async function u(){try{let e=await d("/api/sessions/active");if(!e.ok)return[];return(await e.json()).sessions||[]}catch(e){return[]}}function h(){try{return"1"===localStorage.getItem("clr_sound_muted")}catch(e){return!1}}function m(e){if(e.current)return e.current;try{return e.current=new AudioContext,e.current}catch(e){return null}}function p(e,t,s,r,n){let a=e.createOscillator(),l=e.createGain();a.type="sine",a.frequency.value=t,l.gain.setValueAtTime(n,s),l.gain.exponentialRampToValueAtTime(.001,s+r),a.connect(l),l.connect(e.destination),a.start(s),a.stop(s+r)}function f(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return"now";if(t<60)return"".concat(t,"m ago");let s=Math.floor(t/60);if(s<24)return"".concat(s,"h ago");let r=Math.floor(s/24);return"".concat(r,"d ago")}var g=s(6504),b=s(4514),j=s(5225);s(1226);let v={h1:e=>{let{children:t}=e;return(0,r.jsx)("h1",{className:"text-[17px] font-semibold mt-5 mb-2 text-text",children:t})},h2:e=>{let{children:t}=e;return(0,r.jsx)("h2",{className:"text-[15px] font-semibold mt-4 mb-1.5 text-text",children:t})},h3:e=>{let{children:t}=e;return(0,r.jsx)("h3",{className:"text-[14px] font-semibold mt-3 mb-1 text-text",children:t})},h4:e=>{let{children:t}=e;return(0,r.jsx)("h4",{className:"text-[13px] font-semibold mt-2.5 mb-1 text-text",children:t})},h5:e=>{let{children:t}=e;return(0,r.jsx)("h5",{className:"text-[13px] font-medium mt-2 mb-0.5 text-text-secondary",children:t})},h6:e=>{let{children:t}=e;return(0,r.jsx)("h6",{className:"text-[12px] font-medium mt-2 mb-0.5 text-text-secondary",children:t})},p:e=>{let{children:t}=e;return(0,r.jsx)("p",{className:"my-1 text-[13px] leading-[1.6]",children:t})},a:e=>{let{href:t,children:s}=e;return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline underline-offset-2 decoration-text-muted/40 hover:decoration-accent transition-colors",children:s})},pre:e=>{let{children:t}=e;return(0,r.jsx)("pre",{className:"my-2 rounded-lg bg-[#0d0d0d] border border-border px-3.5 py-3 overflow-x-auto",children:t})},code:e=>{let{className:t,children:s}=e;return t?(0,r.jsx)("code",{className:"".concat(t," text-[12px] leading-[1.7] font-mono"),children:s}):(0,r.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-[#1c1c1c] text-[#d4d4d4] text-[12px] font-mono",children:s})},ul:e=>{let{children:t}=e;return(0,r.jsx)("ul",{className:"my-1.5 space-y-0.5 list-disc pl-5",children:t})},ol:e=>{let{children:t}=e;return(0,r.jsx)("ol",{className:"my-1.5 space-y-0.5 list-decimal pl-5",children:t})},li:e=>{let{children:t}=e;return(0,r.jsx)("li",{className:"text-[13px] leading-[1.6]",children:t})},hr:()=>(0,r.jsx)("hr",{className:"my-3 border-border"}),blockquote:e=>{let{children:t}=e;return(0,r.jsx)("blockquote",{className:"my-2 pl-3 border-l-2 border-border text-text-secondary italic",children:t})},table:e=>{let{children:t}=e;return(0,r.jsx)("div",{className:"my-2 overflow-x-auto",children:(0,r.jsx)("table",{className:"min-w-full text-[13px] border-collapse",children:t})})},th:e=>{let{children:t}=e;return(0,r.jsx)("th",{className:"px-3 py-1.5 text-left font-semibold border-b border-border text-text",children:t})},td:e=>{let{children:t}=e;return(0,r.jsx)("td",{className:"px-3 py-1.5 border-b border-border/50",children:t})},img:e=>{let{src:t,alt:s}=e;return(0,r.jsx)("img",{src:t,alt:null!=s?s:"",className:"my-2 max-w-full rounded",loading:"lazy"})}},y=(0,n.memo)(function(e){let{content:t}=e;return(0,r.jsx)("div",{className:"text-text",children:(0,r.jsx)(g.oz,{remarkPlugins:[b.A],rehypePlugins:[j.A],components:v,children:t})})}),N={size:14,className:""};function k(e){let{size:t=10,className:s=""}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function w(e){let{size:t=N.size,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function C(e){let{size:t=12,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function S(e){let{size:t=N.size,className:s=N.className}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function E(e){let{size:t=N.size,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function W(e){let{size:t=20,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,r.jsx)("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),(0,r.jsx)("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}function L(e){let{size:t=12,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function R(e){let{size:t=N.size,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-6.22-8.56"}),(0,r.jsx)("polyline",{points:"21 3 21 9 15 9"})]})}function T(e){let{size:t=12,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:s,children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("polyline",{points:"19 12 12 19 5 12"})]})}function z(e){let{size:t=18,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),(0,r.jsx)("polyline",{points:"5 12 12 5 19 12"})]})}function A(e){let{size:t=18,className:s=N.className}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:s,children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}function _(e){let{className:t="w-3 h-3"}=e;return(0,r.jsx)("span",{className:"inline-block rounded-full border-2 border-text-muted border-t-transparent animate-spin ".concat(t)})}function F(e){let{size:t=10,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,r.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function M(e){let{size:t=N.size,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function D(e){let{size:t=12,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function I(e){let{size:t=14,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function P(e){let{size:t=12,className:s=N.className}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]})}function O(e){let{copied:t,onClick:s}=e;return(0,r.jsx)("button",{onClick:s,className:"absolute top-2 right-0 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded text-text-muted hover:text-text-secondary","aria-label":t?"Copied":"Copy message",children:t?(0,r.jsx)(S,{}):(0,r.jsx)(E,{})})}let B=(0,n.memo)(function(e){let{message:t}=e,s="user"===t.role,[a,o]=(0,n.useState)(!1),i=l(),c=async()=>{try{await navigator.clipboard.writeText(t.content),i.tap(),o(!0),setTimeout(()=>o(!1),1500)}catch(e){}};return s?(0,r.jsxs)("div",{className:"py-3 group relative",children:[(0,r.jsx)("div",{className:"text-[13px] leading-[1.6] text-text whitespace-pre-wrap break-words bg-bg-surface rounded-lg px-3 py-2",children:t.content}),(0,r.jsx)(O,{copied:a,onClick:c})]}):(0,r.jsxs)("div",{className:"py-3 group relative",children:[(0,r.jsx)(y,{content:t.content}),(0,r.jsx)(O,{copied:a,onClick:c})]})}),U=new Set(["edit","write","shell","todo"]);function H(e){let{className:t}=e;return(0,r.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function V(e){let{type:t}=e,s="w-3.5 h-3.5 shrink-0";switch(t){case"read":return(0,r.jsxs)("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,r.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]});case"write":case"edit":return(0,r.jsxs)("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,r.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]});case"shell":return(0,r.jsxs)("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]});case"search":return(0,r.jsxs)("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]});case"todo":return(0,r.jsxs)("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,r.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]});default:return(0,r.jsx)(H,{className:s})}}function J(e){let t=e.split("/");return t.length<=3?e:".../"+t.slice(-2).join("/")}function Q(e){let{status:t}=e,s="w-3 h-3 shrink-0 mt-0.5";return t.includes("COMPLETED")?(0,r.jsx)("svg",{className:"".concat(s," text-text-secondary"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):t.includes("IN_PROGRESS")?(0,r.jsx)(_,{className:s}):(0,r.jsx)("svg",{className:"".concat(s," text-text-muted"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"})})}function q(e){let{diff:t,startLine:s}=e,n=t.split("\n"),a=void 0!==s,l=null!=s?s:1,o=null!=s?s:1,i=[];if(a)for(let e of n)e.startsWith("-")?(i.push(String(l)),l++):(e.startsWith("+")?i.push(String(o)):(i.push(String(o)),l++),o++);let c=a?String(Math.max(l,o)).length:0;return(0,r.jsx)("pre",{className:"bg-[#0d0d0d] rounded px-2 py-1.5 text-[11px] whitespace-pre-wrap break-all max-h-[300px] overflow-y-auto",children:n.map((e,t)=>(0,r.jsxs)("span",{className:e.startsWith("+")?"text-green-400/70":e.startsWith("-")?"text-red-400/70":"text-text-muted",children:[a&&(0,r.jsx)("span",{className:"text-text-muted/40 select-none inline-block mr-2",style:{width:"".concat(c,"ch"),textAlign:"right"},children:i[t]}),e,t<n.length-1?"\n":""]},t))})}function K(e){switch(e.type){case"read":return"Reading";case"write":return"Writing";case"edit":return"Editing";case"shell":return"Running";case"search":return"Searching";case"todo":return"Updating";default:return e.name}}function G(e){if("shell"===e.type&&e.command)return e.command;if("search"===e.type&&e.command){let t=e.path?" in ".concat(J(e.path)):"";return'"'.concat(e.command,'"').concat(t)}return"todo"===e.type?"todo list":e.path?J(e.path):e.name}function Y(e){let t={};for(let s of e){let e=s.name||s.type;t[e]=(t[e]||0)+1}return Object.entries(t).map(e=>{let[t,s]=e;return"".concat(s," ").concat(t)}).join(", ")}function $(e){let{toolCalls:t}=e,[s,a]=(0,n.useState)(!1),o=l(),i=t.every(e=>"completed"===e.status);return(0,r.jsxs)("div",{className:"py-1.5",children:[(0,r.jsxs)("button",{onClick:()=>{o.tap(),a(e=>!e)},"aria-expanded":s,"aria-label":"Tool call group: ".concat(Y(t)),className:"flex items-center gap-2 text-[12px] text-text-muted hover:text-text-secondary transition-colors w-full text-left",children:[(0,r.jsx)("span",{className:i?"text-text-muted":"text-text-secondary",children:i?(0,r.jsx)(H,{className:"w-3.5 h-3.5 shrink-0"}):(0,r.jsx)(_,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("span",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:(0,r.jsx)("span",{className:"font-mono text-text-muted truncate",children:Y(t)})}),(0,r.jsx)(k,{className:"shrink-0 transition-transform ".concat(s?"rotate-180":"")})]}),s&&(0,r.jsx)("div",{className:"ml-5 pl-3 border-l-2 border-border",children:t.map(e=>(0,r.jsx)(X,{toolCall:e},e.id))})]})}function X(e){let{toolCall:t,defaultExpanded:s}=e,[a,o]=(0,n.useState)(null!=s&&s),i=l(),c="running"===t.status;return(0,r.jsxs)("div",{className:"py-1.5",children:[(0,r.jsxs)("button",{onClick:()=>{i.tap(),o(e=>!e)},"aria-expanded":a,"aria-label":"".concat(K(t)," ").concat(G(t)),className:"flex items-center gap-2 text-[12px] text-text-muted hover:text-text-secondary transition-colors w-full text-left",children:[(0,r.jsx)("span",{className:c?"text-text-secondary":"text-text-muted",children:c?(0,r.jsx)(_,{className:"w-3.5 h-3.5"}):(0,r.jsx)(V,{type:t.type})}),(0,r.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"font-medium ".concat(c?"text-text-secondary":"text-text-muted"),children:K(t)}),(0,r.jsx)("span",{className:"font-mono truncate",children:G(t)})]}),t.result&&(0,r.jsx)("span",{className:"text-text-muted text-[11px] shrink-0",children:t.result}),(0,r.jsx)(k,{className:"shrink-0 transition-transform ".concat(a?"rotate-180":"")})]}),a&&(0,r.jsxs)("div",{className:"mt-1.5 ml-5 pl-3 border-l-2 border-border text-[11px] font-mono text-text-muted py-1.5 space-y-1 overflow-x-auto",children:[(0,r.jsx)("p",{className:"text-text-secondary",children:t.name}),t.path&&(0,r.jsx)("p",{className:"break-all",children:t.path}),"shell"===t.type&&t.command&&(0,r.jsxs)("pre",{className:"bg-[#0d0d0d] rounded px-2 py-1.5 text-[11px] text-[#c9d1d9] whitespace-pre-wrap break-all",children:["$ ",t.command]}),"search"===t.type&&t.command&&(0,r.jsxs)("p",{children:["pattern: ",(0,r.jsx)("span",{className:"text-text-secondary",children:t.command})]}),t.todos&&t.todos.length>0&&(0,r.jsx)("ul",{className:"space-y-0.5",children:t.todos.map(e=>(0,r.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,r.jsx)(Q,{status:e.status}),(0,r.jsx)("span",{className:e.status.includes("COMPLETED")?"text-text-muted line-through":"text-text-secondary",children:e.content})]},e.id))}),t.diff&&(0,r.jsx)(q,{diff:t.diff,startLine:t.diffStartLine}),!t.diff&&!t.todos&&t.result&&(0,r.jsx)("p",{className:"text-text-secondary",children:t.result}),c&&(0,r.jsx)("p",{className:"text-text-muted animate-pulse",children:"running..."})]})]})}function Z(e){let{toolCalls:t}=e,[s,a]=(0,n.useState)(!1),o=l(),i=function(e){let t=new Map;for(let s of e){if("write"!==s.type&&"edit"!==s.type||!s.path)continue;let e=t.get(s.path);e||(e={path:s.path,shortPath:J(s.path),writes:0,edits:0},t.set(s.path,e)),"write"===s.type?e.writes++:e.edits++}return Array.from(t.values()).sort((e,t)=>t.writes+t.edits-(e.writes+e.edits))}(t);if(0===i.length)return null;let c=i.reduce((e,t)=>e+t.edits,0),d=i.reduce((e,t)=>e+t.writes,0),x=[];return c>0&&x.push("".concat(c," edit").concat(c>1?"s":"")),d>0&&x.push("".concat(d," write").concat(d>1?"s":"")),(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsxs)("button",{onClick:()=>{o.tap(),a(e=>!e)},"aria-expanded":s,"aria-label":"Changes summary: ".concat(i.length," files"),className:"flex items-center gap-2 text-[12px] text-text-muted hover:text-text-secondary transition-colors w-full text-left",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),(0,r.jsxs)("span",{className:"font-medium text-text-secondary",children:[i.length," file",i.length>1?"s":""," changed"]}),(0,r.jsx)("span",{className:"text-text-muted text-[11px]",children:x.join(", ")}),(0,r.jsx)(k,{className:"shrink-0 transition-transform ml-auto ".concat(s?"rotate-180":"")})]}),s&&(0,r.jsx)("ul",{className:"mt-1.5 ml-5 pl-3 border-l-2 border-border space-y-0.5 py-1",children:i.map(e=>(0,r.jsxs)("li",{className:"flex items-center gap-2 text-[11px] font-mono",children:[(0,r.jsxs)("svg",{className:"w-3 h-3 shrink-0 text-text-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,r.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),(0,r.jsx)("span",{className:"text-text-secondary truncate flex-1",title:e.path,children:e.shortPath}),(0,r.jsx)("span",{className:"text-text-muted shrink-0",children:e.edits>0&&e.writes>0?"".concat(e.edits,"e ").concat(e.writes,"w"):e.edits>0?"".concat(e.edits," edit").concat(e.edits>1?"s":""):"".concat(e.writes," write").concat(e.writes>1?"s":"")})]},e.path))})]})}function ee(e){let{toolCall:t}=e,[s,a]=(0,n.useState)(!0),o=l(),i=t.todos;if(!i||0===i.length)return null;let c=i.filter(e=>e.status.includes("COMPLETED")).length,d=i.filter(e=>e.status.includes("IN_PROGRESS")).length;return(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsxs)("button",{onClick:()=>{o.tap(),a(e=>!e)},"aria-expanded":s,"aria-label":"Todo list: ".concat(c,"/").concat(i.length," done"),className:"flex items-center gap-2 text-[12px] text-text-muted hover:text-text-secondary transition-colors w-full text-left",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,r.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),(0,r.jsx)("span",{className:"font-medium text-text-secondary",children:"Todo"}),(0,r.jsxs)("span",{className:"text-text-muted text-[11px]",children:[c,"/",i.length," done",d>0?" \xb7 ".concat(d," active"):""]}),(0,r.jsx)(k,{className:"shrink-0 transition-transform ml-auto ".concat(s?"rotate-180":"")})]}),s&&(0,r.jsx)("ul",{className:"mt-1.5 ml-5 pl-3 border-l-2 border-border space-y-0.5 py-1",children:i.map(e=>(0,r.jsxs)("li",{className:"flex items-start gap-1.5 text-[11px] font-mono",children:[(0,r.jsx)(Q,{status:e.status}),(0,r.jsx)("span",{className:e.status.includes("COMPLETED")?"text-text-muted line-through":"text-text-secondary",children:e.content})]},e.id))})]})}function et(e){let{sessions:t,onSelect:s}=e,n=l();return 0===t.length?null:(0,r.jsxs)("div",{className:"mt-5 w-full max-w-xs",children:[(0,r.jsx)("p",{className:"text-text-muted text-[11px] font-medium mb-2 uppercase tracking-wider",children:"Recent sessions"}),(0,r.jsx)("div",{className:"space-y-1",children:t.map(e=>(0,r.jsxs)("button",{onClick:()=>{n.tap(),s(e.id,e.workspace)},className:"w-full text-left px-3 py-2 rounded-lg bg-bg-surface hover:bg-bg-hover border border-border/50 transition-colors group",children:[(0,r.jsx)("p",{className:"text-[12px] text-text-secondary group-hover:text-text truncate",children:e.title}),(0,r.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:f(e.updatedAt)})]},e.id))})]})}function es(e){let{msg:t,onForceSend:s,onEdit:a,onDelete:o}=e,[i,c]=(0,n.useState)(!1),[d,x]=(0,n.useState)(t.content),u=l(),h=()=>{let e=d.trim();e&&e!==t.content&&a(e),c(!1)},m=()=>{x(t.content),c(!1)};return(0,r.jsxs)("div",{className:"py-2.5 border border-dashed border-text-muted/25 rounded-lg px-3 bg-bg-surface/50",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"shrink-0 mt-0.5 text-text-muted/50",children:(0,r.jsx)(M,{})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:i?(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("textarea",{autoFocus:!0,"aria-label":"Edit queued message",value:d,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),h()),"Escape"===e.key&&m()},rows:2,className:"w-full resize-none bg-bg px-2 py-1.5 text-[13px] text-text rounded border border-border focus:outline-none focus:border-text-muted/40"}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{onClick:h,className:"px-2 py-0.5 text-[10px] font-medium rounded bg-bg-active text-text hover:bg-bg-hover transition-colors",children:"Save"}),(0,r.jsx)("button",{onClick:m,className:"px-2 py-0.5 text-[10px] font-medium rounded text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]})]}):(0,r.jsx)("p",{className:"text-[13px] text-text-secondary whitespace-pre-wrap break-words",children:t.content})})]}),!i&&(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-1.5 ml-5",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-muted/50 mr-1",children:"Queued"}),(0,r.jsx)("button",{onClick:()=>{u.send(),s()},className:"px-2 py-0.5 text-[10px] font-medium rounded bg-bg-active text-text-secondary hover:text-text transition-colors",title:"Stop current and send this now",children:"Send now"}),(0,r.jsx)("button",{onClick:()=>{u.tap(),x(t.content),c(!0)},className:"px-2 py-0.5 text-[10px] font-medium rounded text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:"Edit"}),(0,r.jsx)("button",{onClick:()=>{u.warn(),o()},className:"px-2 py-0.5 text-[10px] font-medium rounded text-text-muted hover:text-error/80 hover:bg-error/5 transition-colors",children:"Delete"})]})]})}function er(e){var t,s;let{messages:a,toolCalls:o,isStreaming:i,isLoadingHistory:c,isWatching:d,recentSessions:x=[],onSelectSession:u,onRetry:h,queuedMessages:m=[],onForceSend:p,onEditQueued:f,onDeleteQueued:g}=e,b=l(),j=(0,n.useRef)(null),v=(0,n.useRef)(null),[y,N]=(0,n.useState)(!0),k=(0,n.useRef)(!1),w=(0,n.useCallback)(()=>{var e;null==(e=v.current)||e.scrollIntoView({behavior:"smooth"}),N(!0)},[]),C=(0,n.useCallback)(()=>{if(k.current)return;let e=j.current;e&&N(e.scrollHeight-e.scrollTop-e.clientHeight<60)},[]),S=a[a.length-1],E=i&&(null==S?void 0:S.role)==="user",W=(0,n.useRef)(null),L=(0,n.useRef)(!1);(0,n.useEffect)(()=>{var e;if(y||E){if(W.current){L.current=!0;return}k.current=!0,null==(e=v.current)||e.scrollIntoView({behavior:"smooth"}),W.current=setTimeout(()=>{if(W.current=null,k.current=!1,L.current){var e;L.current=!1,null==(e=v.current)||e.scrollIntoView({behavior:"smooth"})}},200)}},[a,o,y,E]);let R=[...a.map(e=>({kind:"message",timestamp:e.timestamp,message:e})),...o.map(e=>({kind:"toolcall",timestamp:e.timestamp,toolCall:e}))].sort((e,t)=>e.timestamp-t.timestamp),z=[],A=[],M=()=>{0!==A.length&&(1===A.length?z.push({kind:"toolcall",timestamp:A[0].timestamp,toolCall:A[0]}):z.push({kind:"toolgroup",timestamp:A[0].timestamp,toolCalls:[...A]}),A=[])};for(let e of R)"toolcall"===e.kind&&e.toolCall&&(s=e.toolCall,!U.has(s.type))?A.push(e.toolCall):(M(),z.push(e));if(M(),c)return(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-[13px]",children:[(0,r.jsx)(_,{className:"w-3.5 h-3.5"}),"Loading session..."]})});if(0===z.length)return(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center px-6",children:(0,r.jsxs)("div",{className:"flex flex-col items-center max-w-sm",children:[(0,r.jsx)("p",{className:"text-text-secondary text-[13px] font-medium mb-1",children:"Cursor Remote"}),(0,r.jsx)("p",{className:"text-text-muted text-[12px] leading-relaxed",children:"Send a message to start an agent session."}),u&&(0,r.jsx)(et,{sessions:x,onSelect:u})]})});let D=o.some(e=>"running"===e.status),I=z[z.length-1],P=(null==I?void 0:I.kind)==="message"&&(null==(t=I.message)?void 0:t.role)==="user",O=i&&!D&&P,H=a[a.length-1],V=!i&&(null==H?void 0:H.role)==="user"&&h;return(0,r.jsxs)("div",{className:"flex-1 overflow-hidden relative",children:[(0,r.jsx)("div",{ref:j,onScroll:C,className:"h-full overflow-y-auto",children:(0,r.jsxs)("div",{className:"px-4 max-w-3xl mx-auto w-full",children:[(0,r.jsx)("div",{className:"divide-y divide-border/50",children:z.map((e,t)=>"message"===e.kind&&e.message?(0,r.jsx)(B,{message:e.message},e.message.id):"toolcall"===e.kind&&e.toolCall?"todo"===e.toolCall.type?(0,r.jsx)(ee,{toolCall:e.toolCall},e.toolCall.id):(0,r.jsx)(X,{toolCall:e.toolCall},e.toolCall.id):"toolgroup"===e.kind&&e.toolCalls?(0,r.jsx)($,{toolCalls:e.toolCalls},"group-".concat(t)):null)}),!i&&z.length>0&&o.length>0&&(0,r.jsx)(Z,{toolCalls:o}),O&&(0,r.jsxs)("div",{className:"py-3 flex items-center gap-2 text-text-muted text-[12px]",children:[(0,r.jsx)(_,{}),"Thinking..."]}),d&&!i&&z.length>0&&(0,r.jsxs)("div",{className:"py-3 flex items-center gap-2 text-text-muted text-[11px]",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-success animate-pulse"}),"Watching for updates..."]}),V&&(0,r.jsx)("div",{className:"py-1",children:(0,r.jsxs)("button",{onClick:()=>{b.tap(),null==h||h()},className:"flex items-center gap-1 text-[10px] text-text-muted/60 hover:text-text-muted transition-colors","aria-label":"Retry last message",children:[(0,r.jsx)(F,{}),"Retry last message"]})}),m.length>0&&(0,r.jsx)("div",{className:"space-y-2 py-2",children:m.map(e=>(0,r.jsx)(es,{msg:e,onForceSend:()=>null==p?void 0:p(e.id),onEdit:t=>null==f?void 0:f(e.id,t),onDelete:()=>null==g?void 0:g(e.id)},e.id))}),(0,r.jsx)("div",{ref:v,className:"h-4"})]})}),!y&&z.length>0&&(0,r.jsxs)("button",{onClick:w,"aria-label":"Scroll to bottom",className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-bg-elevated border border-border text-text-muted hover:text-text-secondary text-[11px] shadow-lg transition-colors",children:[(0,r.jsx)(T,{}),"Scroll to bottom"]})]})}let en=[{id:"agent",label:"Agent"},{id:"ask",label:"Ask"},{id:"plan",label:"Plan"}];function ea(e){var t;let{onSend:s,onStop:a,isStreaming:o,selectedModel:i,selectedMode:c,onModelChange:x,onModeChange:u}=e,[h,m]=(0,n.useState)(""),[p,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)([]),[j,v]=(0,n.useState)(!0),[y,N]=(0,n.useState)([]),[S,E]=(0,n.useState)(!1),[W,L]=(0,n.useState)(!1),R=(0,n.useRef)(null),T=l();(0,n.useEffect)(()=>{let e=!1;return d("/api/models").then(e=>e.json()).then(t=>{var s;!e&&(null==(s=t.models)?void 0:s.length)>0&&b(t.models)}).catch(e=>console.error("[models] Failed to fetch:",e)).finally(()=>{e||v(!1)}),()=>{e=!0}},[]);let F=(0,n.useCallback)(e=>{let t=e.filter(e=>e.type.startsWith("image/"));if(0===t.length)return;let s=t.map(e=>({file:e,preview:URL.createObjectURL(e)}));N(e=>[...e,...s])},[]),M=(0,n.useCallback)(e=>{N(t=>(URL.revokeObjectURL(t[e].preview),t.filter((t,s)=>s!==e)))},[]),D=(0,n.useCallback)(async e=>{let t=new FormData;for(let s of e)t.append("file",s.file);let s=await d("/api/upload",{method:"POST",body:t});return s.ok&&(await s.json()).paths||[]},[]),I=(0,n.useCallback)(async()=>{let e=h.trim();if(!e&&0===y.length)return;T.send();let t=e;if(y.length>0){E(!0);try{let e=await D(y);if(e.length>0){let s=e.map(e=>"[Attached image: ".concat(e,"]")).join("\n");t=t?t+"\n\n"+s:s}}catch(e){console.error("[upload] Failed to upload images")}finally{E(!1)}for(let e of y)URL.revokeObjectURL(e.preview);N([])}t&&s(t),m(""),R.current&&(R.current.style.height="auto")},[h,y,s,T,D]),P=(0,n.useCallback)(()=>{T.tap(),null==a||a()},[a,T]),O=(0,n.useCallback)(e=>{let t=Array.from(e.clipboardData.items).filter(e=>e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>null!==e);t.length>0&&(e.preventDefault(),F(t))},[F]),B=(0,n.useCallback)(e=>{e.preventDefault(),L(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.type.startsWith("image/"));t.length>0&&F(t)},[F]),U=(0,n.useCallback)(e=>{e.preventDefault(),L(!0)},[]),H=(0,n.useCallback)(()=>{L(!1)},[]),V=(null==(t=g.find(e=>e.id===i))?void 0:t.label)||i,J=g.find(e=>"auto"===e.id),Q=g.filter(e=>"auto"!==e.id);return(0,r.jsx)("div",{className:"shrink-0 bg-bg px-4 py-3 safe-bottom",children:(0,r.jsx)("div",{className:"max-w-3xl mx-auto",children:(0,r.jsxs)("div",{className:"relative bg-bg-surface border rounded-xl focus-within:border-text-muted/40 transition-colors ".concat(W?"border-accent/60 bg-accent/5":"border-border"),onDrop:B,onDragOver:U,onDragLeave:H,children:[(0,r.jsx)("textarea",{ref:R,value:h,onChange:e=>{m(e.target.value);let t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,160)+"px"},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),I())},onPaste:O,placeholder:o?"Type to queue a message...":"Ask Cursor anything...","aria-label":"Message input",rows:1,className:"w-full resize-none bg-transparent px-3.5 pt-2.5 pb-1 pr-10 text-[13px] text-text placeholder:text-text-muted focus:outline-none"}),y.length>0&&(0,r.jsx)("div",{className:"flex gap-2 px-3 pb-1.5 overflow-x-auto",children:y.map((e,t)=>(0,r.jsxs)("div",{className:"relative shrink-0 w-14 h-14 rounded-md overflow-hidden border border-border group",children:[(0,r.jsx)("img",{src:e.preview,alt:"",className:"w-full h-full object-cover"}),(0,r.jsx)("button",{onClick:()=>M(t),className:"absolute top-0 right-0 p-0.5 bg-black/70 rounded-bl text-white opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Remove image",children:(0,r.jsx)(w,{size:10})})]},e.preview))}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",role:"radiogroup","aria-label":"Agent mode",children:[en.map(e=>(0,r.jsx)("button",{role:"radio","aria-checked":c===e.id,onClick:()=>{T.select(),u(e.id)},className:"px-3 py-1.5 rounded text-[12px] font-medium transition-colors ".concat(c===e.id?"bg-bg-active text-text":"text-text-muted hover:text-text-secondary hover:bg-bg-hover"),children:e.label},e.id)),(0,r.jsx)("span",{className:"hidden sm:inline text-[10px] text-text-muted/50 ml-2 select-none",children:"Enter ↵ send \xb7 Shift+Enter newline"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>{T.tap(),f(!p)},"aria-haspopup":"listbox","aria-expanded":p,"aria-label":"Select model",className:"flex items-center gap-1 px-3 py-1.5 rounded text-[12px] text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:[j?(0,r.jsx)(_,{className:"w-2.5 h-2.5"}):(0,r.jsx)("span",{className:"truncate max-w-[80px] sm:max-w-[150px]",children:V}),(0,r.jsx)(k,{})]}),p&&g.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>f(!1)}),(0,r.jsxs)("div",{role:"listbox","aria-label":"Models",className:"absolute bottom-full right-0 mb-1 z-50 w-56 bg-bg-elevated border border-border rounded-lg shadow-xl py-1 max-h-80 overflow-y-auto",children:[J&&(0,r.jsx)(el,{model:J,selected:i===J.id,onSelect:()=>{x(J.id),f(!1)}},J.id),Q.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-px bg-border mx-2 my-1"}),Q.map(e=>(0,r.jsx)(el,{model:e,selected:i===e.id,onSelect:()=>{x(e.id),f(!1)}},e.id))]})]})]})]}),o&&(0,r.jsx)("button",{onClick:P,className:"p-2 rounded-md text-text-muted hover:text-text transition-colors","aria-label":"Stop streaming",children:(0,r.jsx)(A,{})}),(0,r.jsx)("button",{onClick:I,disabled:!h.trim()&&0===y.length||S,className:"p-2 rounded-md text-text-muted hover:text-text disabled:opacity-20 disabled:cursor-not-allowed transition-colors","aria-label":S?"Uploading...":o?"Queue message":"Send message",children:S?(0,r.jsx)(_,{className:"w-4 h-4"}):o?(0,r.jsx)(C,{size:18}):(0,r.jsx)(z,{})})]})]})]})})})}function el(e){let{model:t,selected:s,onSelect:n}=e,a=l();return(0,r.jsxs)("button",{role:"option","aria-selected":s,onClick:()=>{a.select(),n()},className:"w-full text-left px-3 py-1.5 text-[12px] flex items-center justify-between gap-2 transition-colors ".concat(s?"text-text bg-bg-active":"text-text-secondary hover:bg-bg-hover hover:text-text"),children:[(0,r.jsx)("span",{className:"truncate",children:t.label}),(0,r.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[t.isDefault&&(0,r.jsx)("span",{className:"text-[9px] px-1 py-px rounded bg-bg-hover text-text-secondary font-medium",children:"default"}),t.isCurrent&&(0,r.jsx)("span",{className:"text-[9px] px-1 py-px rounded bg-success/15 text-success font-medium",children:"current"})]})]})}function eo(e){let{diff:t}=e;if(!t)return(0,r.jsx)("p",{className:"text-text-muted text-[11px] px-3 py-2",children:"No diff available"});let s=t.split("\n");return(0,r.jsx)("div",{className:"overflow-x-auto text-[11px] font-mono leading-[1.6]",children:s.map((e,t)=>{let s="text-text-muted px-3";return e.startsWith("+")&&!e.startsWith("+++")?s="text-success bg-success/8 px-3":e.startsWith("-")&&!e.startsWith("---")?s="text-error bg-error/8 px-3":e.startsWith("@@")?s="text-info bg-info/8 px-3":(e.startsWith("diff ")||e.startsWith("index "))&&(s="text-text-muted/50 px-3"),(0,r.jsx)("div",{className:s,children:(0,r.jsx)("span",{className:"whitespace-pre",children:e})},t)})})}function ei(e,t,s){return d("/api/git",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,workspace:t,...s})})}function ec(e){var t;let{open:s,onClose:a,workspace:o}=e,[i,c]=(0,n.useState)(null),[x,u]=(0,n.useState)(!1),[h,m]=(0,n.useState)(""),[p,f]=(0,n.useState)(new Set),[g,b]=(0,n.useState)(!1),[j,v]=(0,n.useState)(!1),[y,N]=(0,n.useState)(!1),[C,E]=(0,n.useState)(!1),[W,L]=(0,n.useState)(!1),[T,z]=(0,n.useState)(!1),[A,F]=(0,n.useState)(!1),[M,D]=(0,n.useState)(!1),[I,P]=(0,n.useState)(null),[O,B]=(0,n.useState)(null),[U,H]=(0,n.useState)({}),[V,J]=(0,n.useState)(null),[Q,q]=(0,n.useState)(!1),[K,G]=(0,n.useState)(!1),[Y,$]=(0,n.useState)(!1),[X,Z]=(0,n.useState)(null),[ee,et]=(0,n.useState)(!1),[es,er]=(0,n.useState)(""),[en,ea]=(0,n.useState)(!1),el=l(),eo=o?"&workspace=".concat(encodeURIComponent(o)):"",ec=(0,n.useCallback)(()=>{u(!0),P(null),d("/api/git?detail=status".concat(eo)).then(e=>e.json()).then(e=>{var t;c(e),f(new Set((null!=(t=e.files)?t:[]).map(e=>e.file)))}).catch(()=>P("Failed to load git status")).finally(()=>u(!1))},[eo]),ex=(0,n.useCallback)(()=>{d("/api/git?detail=branches".concat(eo)).then(e=>e.json()).then(e=>Z(e)).catch(()=>{})},[eo]);(0,n.useEffect)(()=>{s&&(L(!1),z(!1),P(null),B(null),H({}),G(!1),$(!1),er(""),ec())},[s,ec]);let eu=(0,n.useCallback)(e=>{if(O===e)return void B(null);B(e),void 0===U[e]&&(J(e),d("/api/git?detail=diff&file=".concat(encodeURIComponent(e)).concat(eo)).then(e=>e.json()).then(t=>H(s=>({...s,[e]:t.diff||""}))).catch(()=>H(t=>({...t,[e]:"Failed to load diff"}))).finally(()=>J(null)))},[O,U,eo]),eh=(0,n.useCallback)((e,t)=>{t.stopPropagation(),el.select(),f(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),em=(0,n.useCallback)(()=>{var e;el.tap();let t=null!=(e=null==i?void 0:i.files)?e:[];p.size===t.length?f(new Set):f(new Set(t.map(e=>e.file)))},[i,p]),ep=(0,n.useCallback)(async()=>{if(!K)return void G(!0);G(!1),q(!0),P(null);try{let e=await ei("discard",o,{files:Array.from(p)});if(!e.ok){let t=await e.json();throw Error(t.error||"Discard failed")}H({}),B(null),el.warn(),ec()}catch(e){P(e instanceof Error?e.message:"Discard failed"),el.error()}finally{q(!1)}},[K,o,p,ec,el]),ef=(0,n.useCallback)(async()=>{if(h.trim()&&0!==p.size){b(!0),P(null);try{let e=await ei("commit",o,{message:h,files:Array.from(p)});if(!e.ok){let t=await e.json();throw Error(t.error||"Commit failed")}m(""),L(!0),setTimeout(()=>L(!1),2e3),H({}),B(null),el.send(),ec()}catch(e){P(e instanceof Error?e.message:"Commit failed"),el.error()}finally{b(!1)}}},[h,o,ec,p,el]),eg=(0,n.useCallback)(async()=>{v(!0),P(null);try{let e=await ei("push",o);if(!e.ok){let t=await e.json();throw Error(t.error||"Push failed")}z(!0),setTimeout(()=>z(!1),2e3),el.send(),ec()}catch(e){P(e instanceof Error?e.message:"Push failed"),el.error()}finally{v(!1)}},[o,ec,el]),eb=(0,n.useCallback)(async()=>{N(!0),P(null);try{let e=await ei("fetch",o);if(!e.ok){let t=await e.json();throw Error(t.error||"Fetch failed")}F(!0),setTimeout(()=>F(!1),2e3),el.tap(),ec()}catch(e){P(e instanceof Error?e.message:"Fetch failed"),el.error()}finally{N(!1)}},[o,ec,el]),ej=(0,n.useCallback)(async()=>{E(!0),P(null);try{let e=await ei("pull",o);if(!e.ok){let t=await e.json();throw Error(t.error||"Pull failed")}D(!0),setTimeout(()=>D(!1),2e3),H({}),B(null),el.tap(),ec()}catch(e){P(e instanceof Error?e.message:"Pull failed"),el.error()}finally{E(!1)}},[o,ec,el]),ev=(0,n.useCallback)(async e=>{et(!0),P(null);try{let t=await ei("checkout",o,{branch:e});if(!t.ok){let e=await t.json();throw Error(e.error||"Checkout failed")}$(!1),H({}),B(null),el.tap(),ec()}catch(e){P(e instanceof Error?e.message:"Checkout failed"),el.error()}finally{et(!1)}},[o,ec,el]),ey=(0,n.useCallback)(async()=>{let e=es.trim();if(e){ea(!0),P(null);try{let t=await ei("create_branch",o,{branch:e});if(!t.ok){let e=await t.json();throw Error(e.error||"Create branch failed")}er(""),$(!1),el.send(),ec()}catch(e){P(e instanceof Error?e.message:"Create branch failed"),el.error()}finally{ea(!1)}}},[es,o,ec,el]);if(!s)return null;let eN=null!=(t=null==i?void 0:i.files)?t:[],ek=eN.length>0,ew=p.size,eC=ek&&ew===eN.length;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/60","aria-hidden":"true",onClick:a}),(0,r.jsxs)("div",{className:"fixed inset-0 z-50 bg-bg-elevated flex flex-col sm:inset-auto sm:top-0 sm:right-0 sm:h-full sm:w-[380px] sm:border-l sm:border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between h-11 px-3 border-b border-border shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-secondary shrink-0",children:"Git"}),(null==i?void 0:i.branch)&&(0,r.jsxs)("button",{onClick:()=>{$(e=>!e),X||ex()},className:"flex items-center gap-1 text-[11px] text-text-muted font-mono hover:text-text-secondary transition-colors min-w-0",children:[(0,r.jsx)("span",{className:"truncate max-w-[120px]",children:i.branch}),(0,r.jsx)(k,{size:8})]}),i&&i.ahead>0&&(0,r.jsxs)("span",{className:"text-[10px] text-info shrink-0",children:["↑",i.ahead]}),i&&i.behind>0&&(0,r.jsxs)("span",{className:"text-[10px] text-warning shrink-0",children:["↓",i.behind]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,r.jsx)("button",{onClick:()=>{ec(),H({})},disabled:x,"aria-label":"Refresh",className:"p-1 rounded-md hover:bg-bg-hover text-text-muted hover:text-text-secondary transition-colors disabled:opacity-40",children:(0,r.jsx)(R,{size:14,className:x?"animate-spin":""})}),(0,r.jsx)("button",{onClick:a,"aria-label":"Close",className:"p-1 rounded-md hover:bg-bg-hover text-text-muted hover:text-text-secondary transition-colors",children:(0,r.jsx)(w,{size:14})})]})]}),Y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>$(!1)}),(0,r.jsxs)("div",{className:"relative z-50 mx-3 mt-2 bg-bg-elevated border border-border rounded-lg shadow-xl max-h-[280px] flex flex-col",children:[ee&&(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(_,{})}),!ee&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"p-2 border-b border-border flex gap-1.5",children:[(0,r.jsx)("input",{value:es,onChange:e=>er(e.target.value),placeholder:"New branch name...",className:"flex-1 min-w-0 rounded border border-border bg-bg-surface px-2 py-1 text-[11px] text-text placeholder:text-text-muted/50 focus:outline-none focus:border-text-muted/40",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ey())}}),(0,r.jsx)("button",{onClick:ey,disabled:!es.trim()||en,className:"shrink-0 px-2 py-1 rounded text-[10px] font-medium bg-bg-surface border border-border text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors disabled:opacity-40",children:en?(0,r.jsx)(_,{className:"w-2.5 h-2.5"}):"Create"})]}),(0,r.jsxs)("div",{className:"overflow-y-auto flex-1 py-1",children:[null==X?void 0:X.local.map(e=>(0,r.jsxs)("button",{onClick:()=>e!==X.current&&ev(e),className:"w-full text-left px-3 py-1.5 text-[11px] font-mono transition-colors ".concat(e===X.current?"text-text bg-bg-active":"text-text-secondary hover:bg-bg-hover hover:text-text"),children:[e,e===X.current&&(0,r.jsx)("span",{className:"text-text-muted ml-1",children:"(current)"})]},e)),X&&X.remoteOnly.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-px bg-border mx-2 my-1"}),(0,r.jsx)("div",{className:"px-3 py-1",children:(0,r.jsx)("span",{className:"text-[9px] font-medium uppercase tracking-wider text-text-muted",children:"Remote"})}),X.remoteOnly.map(e=>(0,r.jsx)("button",{onClick:()=>ev(e),className:"w-full text-left px-3 py-1.5 text-[11px] font-mono text-text-muted hover:bg-bg-hover hover:text-text-secondary transition-colors",children:e},e))]})]})]})]})]}),I&&(0,r.jsx)("div",{className:"mx-3 mt-2 px-2.5 py-2 rounded-md bg-error/10 text-error text-[11px] break-words",children:I}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:x&&!i?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(_,{})}):(null==i?void 0:i.branch)?ek?(0,r.jsxs)("div",{className:"py-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)("button",{onClick:em,className:"shrink-0 w-4 text-center","aria-label":"Toggle all",children:(0,r.jsx)("span",{className:"text-[11px] font-bold transition-colors ".concat(eC?"text-text-secondary":"text-text-muted/40"),children:eC?"✓":"–"})}),(0,r.jsxs)("span",{className:"text-[10px] font-medium uppercase tracking-wider text-text-muted flex-1",children:[ew,"/",eN.length," file",1!==eN.length?"s":""]}),ew>0&&(K?(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{onClick:ep,disabled:Q,className:"px-2 py-0.5 rounded text-[10px] font-medium bg-error/15 text-error hover:bg-error/25 transition-colors disabled:opacity-40",children:Q?(0,r.jsx)(_,{className:"w-2.5 h-2.5"}):"Discard ".concat(ew)}),(0,r.jsx)("button",{onClick:()=>G(!1),"aria-label":"Cancel",className:"p-0.5 rounded text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:(0,r.jsx)(w,{size:9})})]}):(0,r.jsx)("button",{onClick:ep,className:"px-2 py-0.5 rounded text-[10px] font-medium text-text-muted/50 hover:text-error hover:bg-error/10 transition-colors",children:"Discard"}))]}),eN.map(e=>(0,r.jsx)(ed,{file:e,checked:p.has(e.file),expanded:O===e.file,diff:U[e.file],loadingDiff:V===e.file,onToggleExpand:()=>eu(e.file),onToggleCheck:t=>eh(e.file,t)},e.file))]}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-text-muted text-[12px]",children:"Working tree clean"}),i.ahead>0&&(0,r.jsxs)("p",{className:"text-text-secondary text-[11px] mt-1",children:[i.ahead," commit",i.ahead>1?"s":""," ahead of remote"]})]}):(0,r.jsx)("p",{className:"text-text-muted text-[12px] text-center py-12",children:"Not a git repository"})}),(null==i?void 0:i.branch)&&(0,r.jsxs)("div",{className:"shrink-0 border-t border-border p-3 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:eb,disabled:y,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-medium bg-bg-surface border border-border text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[y?(0,r.jsx)(_,{className:"w-3 h-3"}):A?(0,r.jsx)(S,{size:11}):(0,r.jsxs)("svg",{width:11,height:11,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-6.22-8.56"}),(0,r.jsx)("polyline",{points:"21 3 21 9 15 9"})]}),A?"Fetched":"Fetch"]}),(0,r.jsxs)("button",{onClick:ej,disabled:C,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-medium bg-bg-surface border border-border text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[C?(0,r.jsx)(_,{className:"w-3 h-3"}):M?(0,r.jsx)(S,{size:11}):(0,r.jsxs)("svg",{width:11,height:11,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("polyline",{points:"19 12 12 19 5 12"})]}),M?"Pulled":"Pull"]}),(0,r.jsxs)("button",{onClick:eg,disabled:j,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-medium bg-bg-surface border border-border text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[j?(0,r.jsx)(_,{className:"w-3 h-3"}):T?(0,r.jsx)(S,{size:11}):(0,r.jsxs)("svg",{width:11,height:11,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),(0,r.jsx)("polyline",{points:"5 12 12 5 19 12"})]}),T?"Pushed":"Push"]})]}),ek&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("textarea",{value:h,onChange:e=>m(e.target.value),placeholder:"Commit message...",rows:2,className:"w-full resize-none rounded-md border border-border bg-bg-surface px-2.5 py-2 text-[12px] text-text placeholder:text-text-muted/50 focus:outline-none focus:border-text-muted/40",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ef())}}),(0,r.jsxs)("button",{onClick:ef,disabled:g||!h.trim()||0===ew,className:"w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-[12px] font-medium bg-bg-surface border border-border text-text-secondary hover:text-text hover:bg-bg-hover transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[g?(0,r.jsx)(_,{className:"w-3 h-3"}):W?(0,r.jsx)(S,{size:12}):null,W?"Committed":ew===eN.length?"Commit all":"Commit ".concat(ew," file").concat(1!==ew?"s":"")]}),(0,r.jsx)("p",{className:"text-[10px] text-text-muted/50 text-center",children:"⌘+Enter to commit"})]})]})]})]})}function ed(e){let{file:t,checked:s,expanded:n,diff:a,loadingDiff:l,onToggleExpand:o,onToggleCheck:i}=e;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 hover:bg-bg-hover transition-colors group cursor-pointer ".concat(n?"bg-bg-hover/50":""),children:[(0,r.jsx)("button",{onClick:i,className:"shrink-0 w-4 text-center","aria-label":s?"Deselect":"Select",children:(0,r.jsx)("span",{className:"text-[11px] font-bold transition-colors ".concat(s?"text-text-secondary":"text-text-muted/30"),children:s?"✓":"–"})}),(0,r.jsx)("span",{className:"shrink-0 w-4 text-center text-[10px] font-mono font-bold ".concat(function(e){switch(e){case"added":case"untracked":return"text-success";case"deleted":return"text-error";case"modified":return"text-warning";case"renamed":case"copied":return"text-info";default:return"text-text-muted"}}(t.status)),children:function(e){switch(e){case"added":return"A";case"untracked":return"U";case"deleted":return"D";case"modified":return"M";case"renamed":return"R";case"copied":return"C";default:return"?"}}(t.status)}),(0,r.jsx)("span",{className:"text-[11px] font-mono min-w-0 flex-1 text-text-secondary group-hover:text-text overflow-hidden text-ellipsis whitespace-nowrap",dir:"rtl",children:(0,r.jsx)("bdi",{children:t.file})}),(0,r.jsx)("svg",{width:10,height:10,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-text-muted/40 transition-transform ".concat(n?"rotate-180":""),children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),n&&(0,r.jsx)("div",{className:"border-t border-b border-border/50 bg-bg-surface/50 max-h-[300px] overflow-y-auto",children:l?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(_,{})}):(0,r.jsx)(eo,{diff:null!=a?a:""})})]})}function ex(e){let{initialSessionId:t,initialWorkspace:s,defaultModel:a,onLabelChange:o,onStreamingChange:i,onSessionIdChange:c,onSelectSession:f,onOpenSidebar:g,onOpenSettings:b,onOpenQr:j}=e,{messages:v,toolCalls:y,sessionId:N,isStreaming:k,isLoadingHistory:w,isWatching:C,model:E,selectedModel:L,selectedMode:R,error:T,sendMessage:z,loadSession:A,setSelectedModel:_,setSelectedMode:F,stopStreaming:M,retryLastMessage:O,queuedMessages:B,forceSendQueued:U,editQueued:H,deleteQueued:V}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"auto",[t,s]=(0,n.useState)(null),[r,a]=(0,n.useState)(!1),[l,o]=(0,n.useState)(!1),[i,c]=(0,n.useState)(null),[h,m]=(0,n.useState)(e),[p,f]=(0,n.useState)("agent"),[g,b]=(0,n.useState)(null),j=(0,n.useRef)(null),v=(0,n.useRef)(void 0),y=(0,n.useRef)(!1),N=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{j.current=t},[t]),(0,n.useEffect)(()=>{y.current=r},[r]);let k=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,s]=(0,n.useState)([]),[r,a]=(0,n.useState)([]),[l,o]=(0,n.useState)(!1),[i,c]=(0,n.useState)(!1),x=(0,n.useRef)(null),u=(0,n.useRef)(0),h=(0,n.useRef)(e.onStreamEnd),m=(0,n.useRef)(e.onStreamStart);(0,n.useEffect)(()=>{h.current=e.onStreamEnd},[e.onStreamEnd]),(0,n.useEffect)(()=>{m.current=e.onStreamStart},[e.onStreamStart]);let p=(0,n.useCallback)(()=>{x.current&&(x.current.close(),x.current=null),o(!1)},[]),f=(0,n.useCallback)(e=>{if(e.modifiedAt&&e.modifiedAt>u.current){var t,r;u.current=e.modifiedAt,(null==(t=e.messages)?void 0:t.length)>0&&s(e.messages),(null==(r=e.toolCalls)?void 0:r.length)>0&&a(e.toolCalls)}},[]),g=(0,n.useCallback)((e,t)=>{p();let r="/api/sessions/watch?id=".concat(encodeURIComponent(e));t&&(r+="&workspace=".concat(encodeURIComponent(t)));let n=new EventSource(r);x.current=n,n.addEventListener("connected",e=>{o(!0);try{var t,r,n;let l=JSON.parse(e.data);!0===l.isActive?(c(!0),null==(n=m.current)||n.call(m)):c(!1),l.modifiedAt&&(u.current=l.modifiedAt),(null==(t=l.messages)?void 0:t.length)>0&&s(l.messages),(null==(r=l.toolCalls)?void 0:r.length)>0&&a(l.toolCalls)}catch(e){console.error("[watch] Failed to parse connected event")}}),n.addEventListener("update",e=>{try{let s=JSON.parse(e.data);if(f(s),!1===s.isActive){var t;c(!1),null==(t=h.current)||t.call(h)}else!0===s.isActive&&c(!0)}catch(e){console.error("[watch] Failed to parse update event")}}),n.addEventListener("error",()=>{})},[p,f]),b=(0,n.useCallback)(async(e,t)=>{try{var r,n;let l="/api/sessions/history?id=".concat(encodeURIComponent(e));t&&(l+="&workspace=".concat(encodeURIComponent(t)));let o=await d(l);if(!o.ok)return;let i=await o.json();(null==(r=i.messages)?void 0:r.length)>0&&s(i.messages),(null==(n=i.toolCalls)?void 0:n.length)>0&&a(i.toolCalls),i.modifiedAt&&(u.current=i.modifiedAt)}catch(e){console.error("[watch] Failed to refresh from history")}},[]),j=(0,n.useCallback)(()=>{s([]),a([]),c(!1),u.current=0},[]);return(0,n.useEffect)(()=>()=>{p()},[p]),{messages:t,setMessages:s,toolCalls:r,setToolCalls:a,isWatching:l,isActive:i,setIsActive:c,startWatching:g,stopWatching:p,refreshFromHistory:b,resetState:j,lastModifiedRef:u}}({onStreamEnd:(0,n.useCallback)(()=>{a(!1);let e=w.dequeueNext();if(e){let t=e.model||e.mode?{model:e.model,mode:e.mode}:void 0;setTimeout(()=>{var s;null==(s=N.current)||s.call(N,e.content,t)},0)}},[]),onStreamStart:(0,n.useCallback)(()=>a(!0),[])}),w=function(e){let{selectedModel:t,selectedMode:s}=e,[r,a]=(0,n.useState)([]),l=(0,n.useRef)([]);(0,n.useEffect)(()=>{l.current=r},[r]);let o=(0,n.useCallback)(e=>{let r={id:x(),content:e,timestamp:Date.now(),model:t,mode:s};a(e=>[...e,r])},[t,s]),i=(0,n.useCallback)(()=>{let e=l.current;if(0===e.length)return null;let t=e[0];return a(e=>e.slice(1)),t},[]),c=(0,n.useCallback)(e=>{let t=l.current.find(t=>t.id===e);return t?(a(t=>t.filter(t=>t.id!==e)),t):null},[]),d=(0,n.useCallback)((e,t)=>{a(s=>s.map(s=>s.id===e?{...s,content:t}:s))},[]);return{queuedMessages:r,enqueue:o,dequeueNext:i,forceSendQueued:c,editQueued:d,deleteQueued:(0,n.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),clearQueue:(0,n.useCallback)(()=>{a([])},[])}}({selectedModel:h,selectedMode:p}),C=(0,n.useCallback)(()=>{k.stopWatching(),k.resetState(),s(null),v.current=void 0,c(null),b(null),a(!1),w.clearQueue()},[k,w]),S=(0,n.useCallback)(()=>{j.current&&d("/api/sessions/active",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:j.current})}).catch(e=>console.error("[chat] Failed to stop streaming:",e)),a(!1)},[]),E=(0,n.useCallback)(async(e,t)=>{k.stopWatching(),k.resetState(),o(!0),b(null),s(e),v.current=t;try{await k.refreshFromHistory(e,t),k.startWatching(e,t),(await u()).includes(e)&&a(!0)}catch(e){b(e instanceof Error?e.message:"Failed to load session")}finally{o(!1)}},[k]),W=(0,n.useCallback)(async(e,t)=>{var r,n,l;if(y.current)return void w.enqueue(e);k.stopWatching(),b(null),a(!0);let o={id:x(),role:"user",content:e,timestamp:Date.now()};k.setMessages(e=>[...e,o]);let i=null!=(r=null==t?void 0:t.model)?r:h,u=null!=(n=null==t?void 0:t.mode)?n:p;try{let t=await d("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:null!=(l=j.current)?l:void 0,model:"auto"!==i?i:void 0,mode:"agent"!==u?u:void 0,workspace:v.current})});if(!t.ok){let e=await t.json();throw Error(e.error||"HTTP ".concat(t.status))}let r=await t.json(),n=r.sessionId;j.current=n,s(n),r.model&&c(r.model),k.startWatching(n,v.current)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;b(e instanceof Error?e.message:"Unknown error"),a(!1)}},[h,p,k,w]);(0,n.useEffect)(()=>{N.current=W},[W]),(0,n.useEffect)(()=>{let e=async()=>{if("visible"!==document.visibilityState)return;let e=j.current;if(e)try{await k.refreshFromHistory(e,v.current);let t=await u();a(t.includes(e)),b(null),k.isWatching||k.startWatching(e,v.current)}catch(e){console.error("[chat] Failed to refresh on visibility change")}};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[k]);let L=(0,n.useCallback)(e=>{let t=w.forceSendQueued(e);if(!t)return;a(!1);let s=t.model||t.mode?{model:t.model,mode:t.mode}:void 0;setTimeout(()=>{var e;null==(e=N.current)||e.call(N,t.content,s)},0)},[w]),R=(0,n.useCallback)(()=>{if(y.current)return;let e=k.messages,t=[...e].reverse().find(e=>"user"===e.role);if(!t)return;let s=t.content,r=e.findIndex(e=>e.id===t.id);r>=0&&k.setMessages(e.slice(0,r)),k.setToolCalls(e=>e.filter(e=>e.timestamp<t.timestamp)),W(s).catch(e=>console.error("[chat] Retry failed:",e))},[k,W]);return{messages:k.messages,toolCalls:k.toolCalls,sessionId:t,isStreaming:r,isLoadingHistory:l,isWatching:k.isWatching,model:i,selectedModel:h,selectedMode:p,error:g,queuedMessages:w.queuedMessages,sendMessage:W,loadSession:E,setSessionId:s,setSelectedModel:m,setSelectedMode:f,clearChat:C,stopStreaming:S,retryLastMessage:R,forceSendQueued:L,editQueued:w.editQueued,deleteQueued:w.deleteQueued}}(a),J=l(),Q=function(){let e=(0,n.useRef)(null);return{playComplete:(0,n.useCallback)(()=>{if(h())return;let t=m(e);if(!t)return;let s=t.currentTime;p(t,880,s,.12,.15),p(t,1174.66,s+.1,.18,.12)},[]),playError:(0,n.useCallback)(()=>{if(h())return;let t=m(e);if(!t)return;let s=t.currentTime;p(t,330,s,.2,.15),p(t,220,s+.15,.25,.12)},[])}}(),[q,K]=(0,n.useState)(""),[G,Y]=(0,n.useState)([]),[$,X]=(0,n.useState)(0),[Z,ee]=(0,n.useState)(!1),[et,es]=(0,n.useState)(null),[en,el]=(0,n.useState)(!1),eo=(0,n.useRef)(0),ei=(0,n.useRef)(!1),ed=(0,n.useRef)(!1),ex=(0,n.useRef)(0);(0,n.useEffect)(()=>{t&&!ei.current&&(ei.current=!0,A(t,s))},[t,s,A]);let eu=(0,n.useCallback)(()=>{if(s)return void K(s);d("/api/info").then(e=>e.json()).then(e=>K(e.workspace||"")).catch(e=>console.error("[workspace] Failed to fetch:",e))},[s]);(0,n.useEffect)(()=>{eu(),d("/api/sessions").then(e=>e.json()).then(e=>{var t;(null==(t=e.sessions)?void 0:t.length)>0&&Y(e.sessions.slice(0,3))}).catch(e=>console.error("[sessions] Failed to fetch:",e))},[eu]),(0,n.useEffect)(()=>{let e=v.filter(e=>"assistant"===e.role).length;e>eo.current&&e>0&&J.tap(),eo.current=e},[v,J]),(0,n.useEffect)(()=>{if(k&&!ed.current&&(ex.current=Date.now()),ed.current&&!k){let e=Date.now()-ex.current>3e3;T?(e||document.hidden)&&Q.playError():(e||document.hidden)&&Q.playComplete()}ed.current=k,null==i||i(k)},[k,T]),(0,n.useEffect)(()=>{if(!k)return void X(0);let e=()=>X(Math.floor((Date.now()-ex.current)/1e3));e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[k]),(0,n.useEffect)(()=>{null==c||c(N)},[N]),(0,n.useEffect)(()=>{let e=v.find(e=>"user"===e.role);e&&(null==o||o(e.content.slice(0,50)))},[v]);let eh=(0,n.useCallback)(async()=>{let e=function(e,t){let s=[...e.map(e=>({ts:e.timestamp,kind:"msg",msg:e})),...t.map(e=>({ts:e.timestamp,kind:"tc",tc:e}))].sort((e,t)=>e.ts-t.ts),r=[];for(let e of s)if("msg"===e.kind&&e.msg){let t="user"===e.msg.role?"User":"Assistant";r.push("## ".concat(t,"\n\n").concat(e.msg.content))}else"tc"===e.kind&&e.tc&&r.push(function(e){let t="shell"===e.type?"Shell":"search"===e.type?"Search":"edit"===e.type?"Edit":"write"===e.type?"Write":"read"===e.type?"Read":e.name,s="shell"===e.type?e.command:e.path;return s?"> **".concat(t,"** `").concat(s,"`"):"> **".concat(t,"**")}(e.tc));return r.join("\n\n")}(v,y);try{await navigator.clipboard.writeText(e),J.tap(),ee(!0),setTimeout(()=>ee(!1),1500)}catch(n){let t=new Blob([e],{type:"text/markdown"}),s=URL.createObjectURL(t),r=document.createElement("a");r.href=s,r.download="session-".concat((null==N?void 0:N.slice(0,8))||"export",".md"),r.click(),URL.revokeObjectURL(s)}},[v,y,N,J]);(0,n.useEffect)(()=>{if(!q)return;let e="/api/git?workspace=".concat(encodeURIComponent(q)),t=()=>{d(e).then(e=>e.json()).then(e=>{var t;e.branch?es({branch:e.branch,changedFiles:null!=(t=e.changedFiles)?t:0}):es(null)}).catch(()=>{})};t();let s=setInterval(t,3e4);return()=>clearInterval(s)},[q]);let em=q.split("/").filter(Boolean).pop()||"~",ep=$>=60?"".concat(Math.floor($/60),"m ").concat($%60,"s"):"".concat($,"s");return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("header",{className:"shrink-0 flex items-center justify-between h-11 px-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>{J.tap(),null==g||g()},"aria-label":"Open session sidebar",className:"p-2 rounded-md hover:bg-bg-hover transition-colors text-text-muted hover:text-text-secondary",children:(0,r.jsx)(W,{})}),(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-secondary",children:em}),et&&(0,r.jsxs)("button",{onClick:()=>el(!0),className:"flex items-center gap-1 text-[10px] text-text-muted bg-bg-surface hover:bg-bg-hover rounded px-1.5 py-0.5 transition-colors",children:[(0,r.jsx)(P,{size:10}),(0,r.jsx)("span",{className:"truncate max-w-[80px]",children:et.branch}),et.changedFiles>0&&(0,r.jsxs)("span",{className:"text-warning",children:["+",et.changedFiles]})]}),k&&(0,r.jsxs)(r.Fragment,{children:[E&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-muted text-[11px]",children:"/"}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[120px]",children:E})]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted/60 tabular-nums",children:ep})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[N&&(0,r.jsx)("span",{className:"text-[10px] text-text-muted font-mono mr-1 hidden sm:inline opacity-60",children:N.slice(0,8)}),N&&v.length>0&&(0,r.jsx)("button",{onClick:eh,className:"p-2 rounded-md hover:bg-bg-hover transition-colors text-text-muted hover:text-text-secondary","aria-label":Z?"Copied to clipboard":"Export conversation",children:Z?(0,r.jsx)(S,{size:14}):(0,r.jsx)(I,{size:14})}),(0,r.jsx)("button",{onClick:()=>{J.tap(),null==b||b()},className:"p-2 rounded-md hover:bg-bg-hover transition-colors text-text-muted hover:text-text-secondary","aria-label":"Settings",children:(0,r.jsx)(D,{size:16})}),(0,r.jsx)("button",{onClick:()=>{J.tap(),null==j||j()},className:"p-2 rounded-md hover:bg-bg-hover transition-colors text-text-muted hover:text-text-secondary","aria-label":"Connect device",children:(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,r.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,r.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,r.jsx)("rect",{x:"14",y:"14",width:"3",height:"3"}),(0,r.jsx)("line",{x1:"21",y1:"14",x2:"21",y2:"14.01"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"21",y2:"21.01"})]})})]})]}),T&&(0,r.jsx)("div",{className:"shrink-0 px-4 py-2 border-b border-error/20 text-error text-[12px] bg-error/5",children:T}),(0,r.jsx)(er,{messages:v,toolCalls:y,isStreaming:k,isLoadingHistory:w,isWatching:C,recentSessions:G,onSelectSession:null!=f?f:A,onRetry:O,queuedMessages:B,onForceSend:U,onEditQueued:H,onDeleteQueued:V}),(0,r.jsx)(ea,{onSend:z,onStop:M,isStreaming:k,selectedModel:L,selectedMode:R,onModelChange:_,onModeChange:F}),(0,r.jsx)(ec,{open:en,onClose:()=>{el(!1),q&&d("/api/git?workspace=".concat(encodeURIComponent(q))).then(e=>e.json()).then(e=>{var t;e.branch?es({branch:e.branch,changedFiles:null!=(t=e.changedFiles)?t:0}):es(null)}).catch(()=>{})},workspace:q||void 0})]})}function eu(e){let{status:t}=e;return"streaming"===t?(0,r.jsx)("span",{className:"shrink-0 w-2 h-2 rounded-full border-[1.5px] border-success border-t-transparent animate-spin"}):(0,r.jsx)("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-text-muted/40"})}function eh(e){let{size:t=12,className:s=""}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("polyline",{points:"21 8 21 21 3 21 3 8"}),(0,r.jsx)("rect",{x:"1",y:"3",width:"22",height:"5"}),(0,r.jsx)("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]})}function em(e){let{size:t=12,className:s=""}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[(0,r.jsx)("polyline",{points:"21 8 21 21 3 21 3 8"}),(0,r.jsx)("rect",{x:"1",y:"3",width:"22",height:"5"}),(0,r.jsx)("polyline",{points:"12 15 12 10"}),(0,r.jsx)("polyline",{points:"9 12 12 9 15 12"})]})}let ep="clr-selected-project",ef="clr-starred-projects";function eg(e){let{size:t=12,filled:s=!1,className:n=""}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:s?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:(0,r.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}function eb(e){localStorage.setItem(ef,JSON.stringify(e)),d("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred_projects:JSON.stringify(e)})}).catch(()=>{})}function ej(e){let{session:t,children:s}=e,[a,l]=(0,n.useState)(!1),[o,i]=(0,n.useState)({x:0,y:0}),c=(0,n.useRef)(null);return(0,r.jsxs)("div",{ref:c,onMouseEnter:e=>{let t=e.currentTarget.getBoundingClientRect();i({x:t.left+t.width/2,y:t.top}),l(!0)},onMouseLeave:()=>l(!1),className:"relative",children:[s,a&&(0,r.jsx)("div",{className:"fixed z-[100] pointer-events-none",style:{left:o.x,top:o.y},children:(0,r.jsxs)("div",{className:"relative -translate-x-1/2 -translate-y-full -mt-1.5 max-w-[240px] px-2.5 py-1.5 rounded-md bg-bg-elevated border border-border shadow-lg",children:[(0,r.jsx)("p",{className:"text-[11px] text-text leading-snug break-words",children:t.title}),t.preview&&t.preview!==t.title&&(0,r.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5 leading-snug break-words line-clamp-3",children:t.preview}),(0,r.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 top-full w-0 h-0 border-x-[5px] border-x-transparent border-t-[5px] border-t-border"})]})})]})}function ev(e){var t;let{open:s,onClose:a,currentSessionId:o,onSelectSession:i,onNewSession:c,activeStatuses:x={}}=e,[u,h]=(0,n.useState)([]),[m,p]=(0,n.useState)(!1),[g,b]=(0,n.useState)(!1),[j,v]=(0,n.useState)(null),[y,N]=(0,n.useState)(null),[S,E]=(0,n.useState)([]),[W,T]=(0,n.useState)(null),[z,A]=(0,n.useState)(!1),[F,M]=(0,n.useState)([]),D=l();(0,n.useEffect)(()=>{let e=localStorage.getItem(ep),t=function(){try{return JSON.parse(localStorage.getItem(ef)||"[]")}catch(e){return[]}}();T(e),M(t),d("/api/settings").then(e=>e.json()).then(e=>{var s;let r=null==(s=e.settings)?void 0:s.starred_projects;if(r)try{let e=JSON.parse(r);(e.length>0||0===t.length)&&(M(e),localStorage.setItem(ef,r))}catch(e){}else t.length>0&&eb(t)}).catch(()=>{})},[]);let I=(0,n.useCallback)((e,t)=>{e.stopPropagation(),M(e=>{let s=e.includes(t)?e.filter(e=>e!==t):[...e,t];return eb(s),s})},[]),P=(0,n.useCallback)(()=>{d("/api/projects").then(e=>e.json()).then(e=>{E(e.projects||[]),!W&&e.currentWorkspace&&(T(e.currentWorkspace),localStorage.setItem(ep,e.currentWorkspace))}).catch(()=>{})},[W]),O=(0,n.useCallback)(()=>{N(null);let e=new URLSearchParams;"__all__"===W?e.set("all","true"):W&&e.set("workspace",W),g&&e.set("archived","true");let t=e.toString();return d("/api/sessions"+(t?"?"+t:"")).then(e=>e.json()).then(e=>h(e.sessions||[])).catch(()=>N("Failed to load sessions"))},[W,g]);(0,n.useEffect)(()=>{if(!s)return;let e=!1;return p(!0),v(null),P(),O().finally(()=>{e||p(!1)}),()=>{e=!0}},[s,O,P]);let B=(0,n.useCallback)(e=>{T(e),localStorage.setItem(ep,e),A(!1)},[]),U=(e,t)=>{e.stopPropagation(),j===t?(D.error(),d("/api/sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t})}).then(()=>O()).catch(()=>N("Failed to delete session")).finally(()=>v(null))):(D.warn(),v(t))},H=e=>{e.stopPropagation(),v(null)},V="__all__"===W?"All projects":(null==(t=S.find(e=>e.path===W))?void 0:t.name)||(null==W?void 0:W.split("/").pop())||"Current project";return(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/60","aria-hidden":"true",onClick:a}),(0,r.jsxs)("div",{role:"dialog","aria-label":"Session history","aria-hidden":!s,className:"fixed inset-0 z-50 bg-bg-elevated transform transition-transform duration-150 flex flex-col sm:inset-auto sm:top-0 sm:left-0 sm:h-full sm:w-[280px] sm:border-r sm:border-border ".concat(s?"translate-x-0":"-translate-x-full"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between h-11 px-3 border-b border-border shrink-0",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-secondary",children:"Sessions"}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,r.jsx)("button",{onClick:()=>{D.tap(),p(!0),O().finally(()=>p(!1))},disabled:m,"aria-label":"Refresh sessions",className:"p-1 rounded-md hover:bg-bg-hover text-text-muted hover:text-text-secondary transition-colors disabled:opacity-40",children:(0,r.jsx)(R,{size:14,className:m?"animate-spin":""})}),(0,r.jsx)("button",{onClick:a,"aria-label":"Close sidebar",className:"p-1 rounded-md hover:bg-bg-hover text-text-muted hover:text-text-secondary transition-colors",children:(0,r.jsx)(w,{size:14})})]})]}),(0,r.jsxs)("div",{className:"px-2 pt-2 pb-1 space-y-1 shrink-0",children:[(0,r.jsxs)("button",{onClick:()=>{c(W&&"__all__"!==W?W:void 0),a()},className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-[12px] text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:[(0,r.jsx)(C,{}),"New session"]}),F.length>0&&(0,r.jsx)("div",{className:"space-y-px",children:F.map(e=>{let t=S.find(t=>t.path===e),s=(null==t?void 0:t.name)||e.split("/").pop()||e,n=W===e;return(0,r.jsxs)("button",{onClick:()=>B(e),className:"w-full flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-[12px] transition-colors ".concat(n?"bg-bg-active text-text":"text-text-muted hover:text-text-secondary hover:bg-bg-hover"),children:[(0,r.jsx)(eg,{size:10,filled:!0,className:"shrink-0 text-text-secondary"}),(0,r.jsx)("span",{className:"truncate",children:s})]},e)})}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>{D.tap(),A(e=>!e)},className:"w-full flex items-center justify-between gap-2 px-2.5 py-1.5 rounded-md text-[12px] text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:[(0,r.jsx)("span",{className:"truncate",children:V}),(0,r.jsx)(k,{})]}),z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-bg-elevated border border-border rounded-lg shadow-xl py-1 max-h-60 overflow-y-auto",children:[(0,r.jsx)("button",{onClick:()=>B("__all__"),className:"w-full text-left px-3 py-1.5 text-[12px] transition-colors ".concat("__all__"===W?"text-text bg-bg-active":"text-text-secondary hover:bg-bg-hover hover:text-text"),children:"All projects"}),(0,r.jsx)("div",{className:"h-px bg-border mx-2 my-1"}),S.map(e=>(0,r.jsxs)("button",{onClick:()=>B(e.path),className:"w-full text-left px-3 py-1.5 text-[12px] transition-colors flex items-center gap-2 ".concat(W===e.path?"text-text bg-bg-active":"text-text-secondary hover:bg-bg-hover hover:text-text"),children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block truncate",children:e.name}),(0,r.jsx)("span",{className:"block text-[10px] text-text-muted font-mono truncate",children:e.path})]}),(0,r.jsx)("span",{onClick:t=>I(t,e.path),className:"shrink-0 p-0.5 rounded hover:bg-bg-active transition-colors ".concat(F.includes(e.path)?"text-text-secondary":"text-text-muted/30 hover:text-text-muted"),role:"button","aria-label":F.includes(e.path)?"Unstar project":"Star project",children:(0,r.jsx)(eg,{size:12,filled:F.includes(e.path)})})]},e.key))]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{onClick:()=>{D.tap(),b(e=>!e)},"aria-pressed":g,className:"flex-1 flex items-center gap-2 px-2.5 py-1.5 rounded-md text-[12px] transition-colors ".concat(g?"text-text bg-bg-active":"text-text-muted hover:text-text-secondary hover:bg-bg-hover"),children:[(0,r.jsx)(eh,{}),g?"Archived":"Archive"]}),!g&&u.length>0&&(0,r.jsx)("button",{onClick:()=>{D.warn(),d("/api/sessions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"archive_all",workspace:"__all__"===W?void 0:W||void 0})}).then(()=>O()).catch(()=>N("Failed to archive sessions"))},title:"Archive all visible sessions",className:"px-2 py-1.5 rounded-md text-[10px] text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors whitespace-nowrap",children:"Archive all"})]})]}),(0,r.jsxs)("div",{className:"overflow-y-auto flex-1 px-2 pb-2",children:[y&&(0,r.jsx)("div",{className:"mx-1 mb-2 px-2.5 py-2 rounded-md bg-error/10 text-error text-[11px]",children:y}),m?(0,r.jsx)("div",{className:"flex items-center gap-2 justify-center py-8 text-text-muted text-[12px]",children:(0,r.jsx)(_,{})}):0!==u.length||y?u.map(e=>{let t=x[e.id];return(0,r.jsx)(ej,{session:e,children:(0,r.jsxs)("div",{className:"relative mb-px",children:[(0,r.jsxs)("button",{onClick:()=>{D.select(),i(e.id,e.workspace),a()},"aria-current":e.id===o?"true":void 0,className:"group w-full text-left px-2.5 py-2 rounded-md transition-colors ".concat(e.id===o?"bg-bg-active text-text":"hover:bg-bg-hover text-text-secondary"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 pr-12",children:[t&&(0,r.jsx)(eu,{status:t}),(0,r.jsx)("p",{className:"text-[12px] truncate",children:e.title})]}),(0,r.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:f(e.updatedAt)})]}),"__all__"===W&&(0,r.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5 font-mono truncate",children:e.workspace.split("/").pop()})]}),j===e.id?(0,r.jsxs)("div",{className:"absolute top-1 right-1 flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:t=>U(t,e.id),className:"px-2 py-1 rounded text-[10px] font-medium bg-error/15 text-error hover:bg-error/25 transition-colors",children:"Delete"}),(0,r.jsx)("button",{onClick:H,"aria-label":"Cancel delete",className:"p-1 rounded text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:(0,r.jsx)(w,{size:10})})]}):(0,r.jsxs)("div",{className:"absolute top-1 right-1 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all",children:[(0,r.jsx)("button",{onClick:t=>{var s;return s=e.id,void(t.stopPropagation(),D.tap(),d("/api/sessions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:g?"unarchive":"archive",sessionId:s})}).then(()=>O()).catch(()=>N("Failed to update session")))},"aria-label":g?"Unarchive session":"Archive session",className:"p-1.5 rounded hover:bg-bg-surface text-text-muted hover:text-text-secondary transition-colors",children:g?(0,r.jsx)(em,{}):(0,r.jsx)(eh,{})}),(0,r.jsx)("button",{onClick:t=>U(t,e.id),"aria-label":"Delete session",className:"p-1.5 rounded hover:bg-bg-surface text-text-muted hover:text-error transition-colors",children:(0,r.jsx)(L,{})})]})]})},e.id)}):(0,r.jsx)("p",{className:"text-text-muted text-[12px] text-center py-8",children:g?"No archived sessions":"No sessions"})]})]})]})}let ey={trust:!0,sound:!0,default_model:"auto"},eN={trust:{label:"Workspace trust",description:"Allow the agent to execute code and edit files without asking"},sound:{label:"Sound effects",description:"Play sounds on completion and errors"}},ek=Object.keys(eN);function ew(e){var t;let{open:s,onClose:a,onDefaultModelChange:o}=e,[i,c]=(0,n.useState)(ey),[x,u]=(0,n.useState)(!0),[h,m]=(0,n.useState)([]),[p,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)(!1),j=l();(0,n.useEffect)(()=>{if(!s)return;let e=!1;return u(!0),Promise.all([d("/api/settings").then(e=>e.json()),d("/api/models").then(e=>e.json())]).then(t=>{var s;let[r,n]=t;!e&&(c({...ey,...r.settings}),(null==(s=n.models)?void 0:s.length)>0&&m(n.models))}).catch(()=>{}).finally(()=>{e||u(!1)}),()=>{e=!0}},[s]);let v=(0,n.useCallback)(e=>{j.tap(),c(t=>{let s={...t,[e]:!t[e]};return d("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:s[e]})}).catch(()=>{c(t)}),s})},[j]),y=(0,n.useCallback)(e=>{j.select(),c(t=>{let s={...t,default_model:e};return d("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({default_model:e})}).catch(()=>{c(t)}),s}),null==o||o(e),f(!1)},[o,j]),N=(0,n.useCallback)(async()=>{j.warn();try{if("serviceWorker"in navigator){let e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(e=>e.unregister()))}if("undefined"!=typeof caches){let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}b(!0),setTimeout(()=>b(!1),2e3)}catch(e){}},[j]),C=(null==(t=h.find(e=>e.id===i.default_model))?void 0:t.label)||i.default_model;return(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/60","aria-hidden":"true",onClick:a}),(0,r.jsxs)("div",{role:"dialog","aria-label":"Settings","aria-hidden":!s,className:"fixed inset-0 z-50 bg-bg-elevated transform transition-transform duration-150 flex flex-col sm:inset-auto sm:top-0 sm:right-0 sm:h-full sm:w-[300px] sm:border-l sm:border-border ".concat(s?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between h-11 px-3 border-b border-border shrink-0",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-secondary",children:"Settings"}),(0,r.jsx)("button",{onClick:a,"aria-label":"Close settings",className:"p-1 rounded-md hover:bg-bg-hover text-text-muted hover:text-text-secondary transition-colors",children:(0,r.jsx)(w,{size:14})})]}),(0,r.jsx)("div",{className:"overflow-y-auto flex-1 p-3 space-y-1",children:x?(0,r.jsx)("div",{className:"flex justify-center py-8",children:(0,r.jsx)("span",{className:"inline-block w-3 h-3 rounded-full border-2 border-text-muted border-t-transparent animate-spin"})}):(0,r.jsxs)(r.Fragment,{children:[ek.map(e=>(0,r.jsxs)("button",{onClick:()=>v(e),className:"w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-md hover:bg-bg-hover transition-colors text-left",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-[12px] text-text",children:eN[e].label}),(0,r.jsx)("p",{className:"text-[11px] text-text-muted mt-0.5 leading-tight",children:eN[e].description})]}),(0,r.jsx)("div",{className:"shrink-0 w-8 h-[18px] rounded-full transition-colors relative ".concat(i[e]?"bg-success":"bg-bg-active"),children:(0,r.jsx)("div",{className:"absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white transition-transform ".concat(i[e]?"translate-x-[16px]":"translate-x-[2px]")})})]},e)),(0,r.jsxs)("div",{className:"pt-3 mt-2 border-t border-border",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("p",{className:"text-[12px] text-text",children:"Default model"}),(0,r.jsx)("p",{className:"text-[11px] text-text-muted mt-0.5 leading-tight",children:"Model used for new sessions"})]}),(0,r.jsxs)("div",{className:"relative px-3",children:[(0,r.jsxs)("button",{onClick:()=>f(e=>!e),className:"w-full flex items-center justify-between gap-2 px-3 py-2 rounded-md bg-bg-surface border border-border text-[12px] text-text hover:bg-bg-hover transition-colors",children:[(0,r.jsx)("span",{className:"truncate",children:C}),(0,r.jsx)(k,{})]}),p&&h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>f(!1)}),(0,r.jsx)("div",{className:"absolute left-3 right-3 top-full mt-1 z-50 bg-bg-elevated border border-border rounded-lg shadow-xl py-1 max-h-60 overflow-y-auto",children:h.map(e=>(0,r.jsx)("button",{onClick:()=>y(e.id),className:"w-full text-left px-3 py-1.5 text-[12px] transition-colors ".concat(i.default_model===e.id?"text-text bg-bg-active":"text-text-secondary hover:bg-bg-hover hover:text-text"),children:e.label},e.id))})]})]})]}),(0,r.jsxs)("div",{className:"pt-3 mt-2 border-t border-border",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("p",{className:"text-[12px] text-text",children:"Cache"}),(0,r.jsx)("p",{className:"text-[11px] text-text-muted mt-0.5 leading-tight",children:"Clear cached data if the app feels stale"})]}),(0,r.jsx)("div",{className:"px-3",children:(0,r.jsx)("button",{onClick:N,className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 rounded-md bg-bg-surface border border-border text-[12px] text-text-muted hover:text-text-secondary hover:bg-bg-hover transition-colors",children:g?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S,{size:12}),"Cache cleared"]}):"Clear cache"})})]})]})})]})]})}var eC=s(2834);function eS(e){let{open:t,onClose:s}=e,[a,o]=(0,n.useState)(null),[i,c]=(0,n.useState)(null),x=l();return((0,n.useEffect)(()=>{if(!t)return;let e=!1;return d("/api/info").then(e=>e.json()).then(t=>{e||o(t)}).catch(()=>{e||c("Could not load network info")}),()=>{e=!0,o(null),c(null)}},[t]),t)?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:s,children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Connect device via QR code",className:"bg-bg-elevated border border-border rounded-xl p-6 max-w-xs w-full mx-4 text-center",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("p",{className:"text-[13px] font-medium text-text mb-1",children:"Connect device"}),(0,r.jsx)("p",{className:"text-[12px] text-text-muted mb-5",children:"Scan from any device on your network"}),a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"bg-white rounded-lg p-3 inline-block mb-3",children:(0,r.jsx)(eC.h,{value:a.authUrl,size:180})}),(0,r.jsx)("p",{className:"font-mono text-[12px] text-text-secondary",children:a.url})]}):i?(0,r.jsx)("div",{className:"py-10 text-error text-[12px]",children:i}):(0,r.jsx)("div",{className:"py-10 text-text-muted text-[12px]",children:(0,r.jsx)(_,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("button",{onClick:()=>{x.tap(),s()},className:"mt-4 w-full py-1.5 rounded-lg text-[12px] text-text-muted hover:text-text-secondary transition-colors",children:"Close"})]})}):null}var eE=s(5932);function eW(e,t){return{id:x(),sessionId:null,label:e?"Loading...":"New chat",isStreaming:!1,initialSessionId:e,initialWorkspace:t}}function eL(){var e,t;let[s,a]=(0,n.useState)(()=>[eW()]),[o,i]=(0,n.useState)(()=>s[0].id),[c,x]=(0,n.useState)(!1),[h,m]=(0,n.useState)(!1),[p,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)("auto"),j=l(),v=(0,n.useRef)(!1),y=(0,n.useRef)(!1);(0,n.useEffect)(()=>{y.current||(y.current=!0,d("/api/settings").then(e=>e.json()).then(e=>{var t;(null==(t=e.settings)?void 0:t.default_model)&&b(e.settings.default_model)}).catch(()=>{}))},[]),(0,n.useEffect)(()=>{v.current||(v.current=!0,u().then(e=>{0!==e.length&&a(t=>{let s=[...t],r=null;for(let t=0;t<e.length;t++){let n=e[t];if(s.some(e=>e.initialSessionId===n||e.sessionId===n))continue;let a=eW(n);0!==t||1!==s.length||s[0].sessionId||s[0].isStreaming?(s.push(a),r||(r=a.id)):(s[0]=a,r=a.id)}if(r){let e=r;setTimeout(()=>i(e),0)}return s})}))},[]);let N=(0,n.useMemo)(()=>{let e={};for(let t of s)t.sessionId&&(e[t.sessionId]=t.isStreaming?"streaming":"idle");return e},[s]),k=(0,n.useCallback)(e=>{j.tap();let t=s.find(e=>e.id===o);if(t&&!t.sessionId&&!t.isStreaming){if(e&&t.initialWorkspace!==e){let t=eW(void 0,e);a(e=>e.map(e=>e.id===o?t:e)),i(t.id)}return}let r=eW(void 0,e);a(e=>[...e,r]),i(r.id)},[j,s,o]),w=(0,n.useCallback)((e,t)=>{let r=s.find(t=>t.sessionId===e);if(r)return void i(r.id);let n=eW(e,t),l=s.find(e=>e.id===o);!l||l.sessionId||l.isStreaming?a(e=>[...e,n]):a(e=>e.map(e=>e.id===o?n:e)),i(n.id)},[s,o]),C=(0,n.useCallback)((e,t)=>{a(s=>{let r=s.find(t=>t.id===e);return r&&r.label!==t?s.map(s=>s.id===e?{...s,label:t}:s):s})},[]),S=(0,n.useCallback)((e,t)=>{a(s=>{let r=s.find(t=>t.id===e);return r&&r.isStreaming!==t?s.map(s=>s.id===e?{...s,isStreaming:t}:s):s})},[]),E=(0,n.useCallback)((e,t)=>{a(s=>{let r=s.find(t=>t.id===e);return r&&r.sessionId!==t?s.map(s=>s.id===e?{...s,sessionId:t}:s):s})},[]),W=null!=(t=null==(e=s.find(e=>e.id===o))?void 0:e.sessionId)?t:null;return(0,r.jsxs)("div",{className:"h-dvh",children:[s.map(e=>(0,r.jsx)("div",{className:e.id===o?"h-full":"hidden",children:(0,r.jsx)(eE.ErrorBoundary,{fallback:"inline",children:(0,r.jsx)(ex,{initialSessionId:e.initialSessionId,initialWorkspace:e.initialWorkspace,defaultModel:g,onLabelChange:t=>C(e.id,t),onStreamingChange:t=>S(e.id,t),onSessionIdChange:t=>E(e.id,t),onSelectSession:w,onOpenSidebar:()=>x(!0),onOpenSettings:()=>m(!0),onOpenQr:()=>f(!0)})})},e.id)),(0,r.jsx)(ev,{open:c,onClose:()=>x(!1),currentSessionId:W,onSelectSession:w,onNewSession:k,activeStatuses:N}),(0,r.jsx)(ew,{open:h,onClose:()=>m(!1),onDefaultModelChange:b}),(0,r.jsx)(eS,{open:p,onClose:()=>f(!1)})]})}}},e=>{e.O(0,[481,391,441,255,358],()=>e(e.s=2673)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-duration:initial}}}@layer theme{:host,:root{--font-sans:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;--font-mono:"SF Mono","Fira Code","Fira Mono",Menlo,Consolas,monospace;--color-red-400:oklch(70.4% .191 22.216);--color-green-400:oklch(79.2% .209 151.711);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-3xl:48rem;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wider:.05em;--leading-tight:1.25;--leading-snug:1.375;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg:#000;--color-bg-elevated:#0a0a0a;--color-bg-surface:#111;--color-bg-hover:#1a1a1a;--color-bg-active:#222;--color-border:#1e1e1e;--color-text:#e8e8e8;--color-text-secondary:#999;--color-text-muted:#555;--color-accent:#e8e8e8;--color-success:#3dd68c;--color-warning:#f5a623;--color-error:#ef4444}}@layer base{*,::backdrop,:after,:before{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}:host,html{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,optgroup,select,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-1{top:calc(var(--spacing) * 1)}.top-2{top:calc(var(--spacing) * 2)}.top-\[2px\]{top:2px}.top-full{top:100%}.right-0{right:calc(var(--spacing) * 0)}.right-1{right:calc(var(--spacing) * 1)}.right-3{right:calc(var(--spacing) * 3)}.bottom-3{bottom:calc(var(--spacing) * 3)}.bottom-full{bottom:100%}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.left-3{left:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.mx-1{margin-inline:calc(var(--spacing) * 1)}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing) * 1)}.my-1\.5{margin-block:calc(var(--spacing) * 1.5)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.-mt-1\.5{margin-top:calc(var(--spacing) * -1.5)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.mb-px{margin-bottom:1px}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-5{margin-left:calc(var(--spacing) * 5)}.ml-auto{margin-left:auto}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.h-0{height:calc(var(--spacing) * 0)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-11{height:calc(var(--spacing) * 11)}.h-14{height:calc(var(--spacing) * 14)}.h-\[14px\]{height:14px}.h-\[18px\]{height:18px}.h-dvh{height:100dvh}.h-full{height:100%}.h-px{height:1px}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-80{max-height:calc(var(--spacing) * 80)}.max-h-\[280px\]{max-height:280px}.max-h-\[300px\]{max-height:300px}.w-0{width:calc(var(--spacing) * 0)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-8{width:calc(var(--spacing) * 8)}.w-14{width:calc(var(--spacing) * 14)}.w-56{width:calc(var(--spacing) * 56)}.w-\[14px\]{width:14px}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[80px\]{max-width:80px}.max-w-\[120px\]{max-width:120px}.max-w-\[240px\]{max-width:240px}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-full{min-width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1)}.-translate-x-1\/2,.-translate-x-full{translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%}.translate-x-0{--tw-translate-x:calc(var(--spacing) * 0)}.translate-x-0,.translate-x-\[2px\]{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[2px\]{--tw-translate-x:2px}.translate-x-\[16px\]{--tw-translate-x:16px}.translate-x-\[16px\],.translate-x-full{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-full{--tw-translate-x:100%}.-translate-y-full{--tw-translate-y:-100%;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-px>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(1px * var(--tw-space-y-reverse));margin-block-end:calc(1px * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border\/50>:not(:last-child)){border-color:#1e1e1e80}@supports (color:color-mix(in lab,red,red)){:where(.divide-border\/50>:not(:last-child)){border-color:color-mix(in oklab,var(--color-border) 50%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap}.overflow-hidden,.truncate{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-none{overscroll-behavior:none}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e+38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\[1\.5px\]{border-style:var(--tw-border-style);border-width:1.5px}.border-x-\[5px\]{border-inline-style:var(--tw-border-style);border-inline-width:5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#2a2a2a\]{border-color:#2a2a2a}.border-accent\/60{border-color:#e8e8e899}@supports (color:color-mix(in lab,red,red)){.border-accent\/60{border-color:color-mix(in oklab,var(--color-accent) 60%,transparent)}}.border-border{border-color:var(--color-border)}.border-border\/50{border-color:#1e1e1e80}@supports (color:color-mix(in lab,red,red)){.border-border\/50{border-color:color-mix(in oklab,var(--color-border) 50%,transparent)}}.border-error\/20{border-color:#ef444433}@supports (color:color-mix(in lab,red,red)){.border-error\/20{border-color:color-mix(in oklab,var(--color-error) 20%,transparent)}}.border-success{border-color:var(--color-success)}.border-text-muted{border-color:var(--color-text-muted)}.border-text-muted\/25{border-color:#55555540}@supports (color:color-mix(in lab,red,red)){.border-text-muted\/25{border-color:color-mix(in oklab,var(--color-text-muted) 25%,transparent)}}.border-x-transparent{border-inline-color:#0000}.border-t-border{border-top-color:var(--color-border)}.border-t-transparent{border-top-color:#0000}.bg-\[\#0a0a0b\]{background-color:#0a0a0b}.bg-\[\#0d0d0d\]{background-color:#0d0d0d}.bg-\[\#1c1c1c\]{background-color:#1c1c1c}.bg-accent\/5{background-color:#e8e8e80d}@supports (color:color-mix(in lab,red,red)){.bg-accent\/5{background-color:color-mix(in oklab,var(--color-accent) 5%,transparent)}}.bg-bg{background-color:var(--color-bg)}.bg-bg-active{background-color:var(--color-bg-active)}.bg-bg-elevated{background-color:var(--color-bg-elevated)}.bg-bg-hover{background-color:var(--color-bg-hover)}.bg-bg-hover\/50{background-color:#1a1a1a80}@supports (color:color-mix(in lab,red,red)){.bg-bg-hover\/50{background-color:color-mix(in oklab,var(--color-bg-hover) 50%,transparent)}}.bg-bg-surface{background-color:var(--color-bg-surface)}.bg-bg-surface\/50{background-color:#11111180}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface\/50{background-color:color-mix(in oklab,var(--color-bg-surface) 50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black) 70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black) 80%,transparent)}}.bg-border{background-color:var(--color-border)}.bg-error\/5{background-color:#ef44440d}@supports (color:color-mix(in lab,red,red)){.bg-error\/5{background-color:color-mix(in oklab,var(--color-error) 5%,transparent)}}.bg-error\/8{background-color:#ef444414}@supports (color:color-mix(in lab,red,red)){.bg-error\/8{background-color:color-mix(in oklab,var(--color-error) 8%,transparent)}}.bg-error\/10{background-color:#ef44441a}@supports (color:color-mix(in lab,red,red)){.bg-error\/10{background-color:color-mix(in oklab,var(--color-error) 10%,transparent)}}.bg-error\/15{background-color:#ef444426}@supports (color:color-mix(in lab,red,red)){.bg-error\/15{background-color:color-mix(in oklab,var(--color-error) 15%,transparent)}}.bg-success{background-color:var(--color-success)}.bg-success\/8{background-color:#3dd68c14}@supports (color:color-mix(in lab,red,red)){.bg-success\/8{background-color:color-mix(in oklab,var(--color-success) 8%,transparent)}}.bg-success\/15{background-color:#3dd68c26}@supports (color:color-mix(in lab,red,red)){.bg-success\/15{background-color:color-mix(in oklab,var(--color-success) 15%,transparent)}}.bg-text-muted\/40{background-color:#5556}@supports (color:color-mix(in lab,red,red)){.bg-text-muted\/40{background-color:color-mix(in oklab,var(--color-text-muted) 40%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-12{padding-block:calc(var(--spacing) * 12)}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-2\.5{padding-top:calc(var(--spacing) * 2.5)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pr-12{padding-right:calc(var(--spacing) * 12)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-1\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.text-\[15px\]{font-size:15px}.text-\[17px\]{font-size:17px}.leading-\[1\.6\]{--tw-leading:1.6;line-height:1.6}.leading-\[1\.7\]{--tw-leading:1.7;line-height:1.7}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#888\]{color:#888}.text-\[\#c9d1d9\]{color:#c9d1d9}.text-\[\#d4d4d4\]{color:#d4d4d4}.text-\[\#e8e8e8\]{color:#e8e8e8}.text-accent{color:var(--color-accent)}.text-error{color:var(--color-error)}.text-green-400\/70{color:#05df72b3}@supports (color:color-mix(in lab,red,red)){.text-green-400\/70{color:color-mix(in oklab,var(--color-green-400) 70%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400) 70%,transparent)}}.text-success{color:var(--color-success)}.text-text{color:var(--color-text)}.text-text-muted{color:var(--color-text-muted)}.text-text-muted\/30{color:#5555554d}@supports (color:color-mix(in lab,red,red)){.text-text-muted\/30{color:color-mix(in oklab,var(--color-text-muted) 30%,transparent)}}.text-text-muted\/40{color:#5556}@supports (color:color-mix(in lab,red,red)){.text-text-muted\/40{color:color-mix(in oklab,var(--color-text-muted) 40%,transparent)}}.text-text-muted\/50{color:#55555580}@supports (color:color-mix(in lab,red,red)){.text-text-muted\/50{color:color-mix(in oklab,var(--color-text-muted) 50%,transparent)}}.text-text-muted\/60{color:#5559}@supports (color:color-mix(in lab,red,red)){.text-text-muted\/60{color:color-mix(in oklab,var(--color-text-muted) 60%,transparent)}}.text-text-secondary{color:var(--color-text-secondary)}.text-warning{color:var(--color-warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.decoration-text-muted\/40{text-decoration-color:#5556}@supports (color:color-mix(in lab,red,red)){.decoration-text-muted\/40{-webkit-text-decoration-color:color-mix(in oklab,var(--color-text-muted) 40%,transparent);text-decoration-color:color-mix(in oklab,var(--color-text-muted) 40%,transparent)}}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-60{opacity:.6}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a)}.shadow-lg,.shadow-xl{box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.group-hover\:text-text:is(:where(.group):hover *){color:var(--color-text)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\:text-text-muted::placeholder{color:var(--color-text-muted)}.placeholder\:text-text-muted\/50::placeholder{color:#55555580}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-text-muted\/50::placeholder{color:color-mix(in oklab,var(--color-text-muted) 50%,transparent)}}.focus-within\:border-text-muted\/40:focus-within{border-color:#5556}@supports (color:color-mix(in lab,red,red)){.focus-within\:border-text-muted\/40:focus-within{border-color:color-mix(in oklab,var(--color-text-muted) 40%,transparent)}}@media (hover:hover){.hover\:bg-\[\#252525\]:hover{background-color:#252525}.hover\:bg-bg-active:hover{background-color:var(--color-bg-active)}.hover\:bg-bg-hover:hover{background-color:var(--color-bg-hover)}.hover\:bg-bg-surface:hover{background-color:var(--color-bg-surface)}.hover\:bg-error\/5:hover{background-color:#ef44440d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-error\/5:hover{background-color:color-mix(in oklab,var(--color-error) 5%,transparent)}}.hover\:bg-error\/10:hover{background-color:#ef44441a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-error\/10:hover{background-color:color-mix(in oklab,var(--color-error) 10%,transparent)}}.hover\:bg-error\/25:hover{background-color:#ef444440}@supports (color:color-mix(in lab,red,red)){.hover\:bg-error\/25:hover{background-color:color-mix(in oklab,var(--color-error) 25%,transparent)}}.hover\:text-error:hover{color:var(--color-error)}.hover\:text-error\/80:hover{color:#ef4444cc}@supports (color:color-mix(in lab,red,red)){.hover\:text-error\/80:hover{color:color-mix(in oklab,var(--color-error) 80%,transparent)}}.hover\:text-text:hover{color:var(--color-text)}.hover\:text-text-muted:hover{color:var(--color-text-muted)}.hover\:text-text-secondary:hover{color:var(--color-text-secondary)}.hover\:decoration-accent:hover{-webkit-text-decoration-color:var(--color-accent);text-decoration-color:var(--color-accent)}}.focus\:border-text-muted\/40:focus{border-color:#5556}@supports (color:color-mix(in lab,red,red)){.focus\:border-text-muted\/40:focus{border-color:color-mix(in oklab,var(--color-text-muted) 40%,transparent)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-20:disabled{opacity:.2}.disabled\:opacity-40:disabled{opacity:.4}@media (min-width:40rem){.sm\:inset-auto{inset:auto}.sm\:top-0{top:calc(var(--spacing) * 0)}.sm\:right-0{right:calc(var(--spacing) * 0)}.sm\:left-0{left:calc(var(--spacing) * 0)}.sm\:inline{display:inline}.sm\:h-full{height:100%}.sm\:w-\[280px\]{width:280px}.sm\:w-\[300px\]{width:300px}.sm\:w-\[380px\]{width:380px}.sm\:max-w-\[150px\]{max-width:150px}.sm\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.sm\:border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.sm\:border-border{border-color:var(--color-border)}}}html{color-scheme:dark}body{background:var(--color-bg);color:var(--color-text);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:2px}.safe-bottom{padding-bottom:max(12px,env(safe-area-inset-bottom))}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(1turn)}}@keyframes pulse{50%{opacity:.5}}
|
package/README.md
CHANGED
|
@@ -33,22 +33,13 @@ A QR code pops up in your terminal — scan it from your phone and you're connec
|
|
|
33
33
|
|
|
34
34
|
## Features
|
|
35
35
|
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
- **
|
|
42
|
-
- **
|
|
43
|
-
- **Stop / retry / copy** — cancel a running response, retry, or copy any message
|
|
44
|
-
- **Install as app** — PWA support, add to home screen on iOS/Android for a native feel
|
|
45
|
-
- **Push notifications** — get notified when the agent finishes while the tab is in the background
|
|
46
|
-
- **Settings** — toggle workspace trust, notifications, and sound from the UI
|
|
47
|
-
- **Haptic feedback** — tactile feedback on mobile devices
|
|
48
|
-
- **Sound effects** — audio cues on completion and errors
|
|
49
|
-
- **Multi-tab sessions** — work with multiple chat sessions side by side
|
|
50
|
-
- **Share via QR** — in-app QR code to quickly connect another device
|
|
51
|
-
- **Auto-port** — if the default port is busy, the CLI finds the next available one
|
|
36
|
+
- **QR connect** — scan to connect your phone instantly and continue with phone coding session
|
|
37
|
+
- **Full agent control** — send prompts, pick models, switch modes, stop/retry from any device
|
|
38
|
+
- **Live streaming** — watch responses, tool calls, and file edits in real time
|
|
39
|
+
- **Multi-project** — switch between all your Cursor projects, star favorites, browse sessions across workspaces
|
|
40
|
+
- **Git panel** — view diffs, commit, push, pull, switch branches — all from the UI
|
|
41
|
+
- **Session management** — browse, resume, archive, and export past sessions
|
|
42
|
+
- **PWA ready** — install as an app on your phone's home screen
|
|
52
43
|
|
|
53
44
|
## Usage
|
|
54
45
|
|
|
@@ -97,20 +88,22 @@ All endpoints require a valid token (cookie or `Bearer` header).
|
|
|
97
88
|
|
|
98
89
|
| Endpoint | Method | Description |
|
|
99
90
|
| --- | --- | --- |
|
|
100
|
-
| `/api/chat` | `POST` | Send a prompt.
|
|
91
|
+
| `/api/chat` | `POST` | Send a prompt. Body: `{ prompt, sessionId?, model?, mode?, workspace? }` |
|
|
101
92
|
| `/api/models` | `GET` | List available models from `agent models` (cached 5 min) |
|
|
102
|
-
| `/api/sessions` | `GET` | Session list
|
|
93
|
+
| `/api/sessions` | `GET` | Session list. `?workspace=<path>` to filter, `?archived=true` to include archived |
|
|
94
|
+
| `/api/sessions` | `PATCH` | Archive/unarchive sessions. Body: `{ action, sessionId? }` |
|
|
103
95
|
| `/api/sessions` | `DELETE` | Delete a stored session. Body: `{ sessionId }` |
|
|
104
96
|
| `/api/sessions/active` | `GET` | List currently running agent session IDs |
|
|
105
97
|
| `/api/sessions/active` | `DELETE` | Kill a running agent process. Body: `{ sessionId }` |
|
|
106
|
-
| `/api/sessions/history` | `GET` | Full transcript for a session. `?id=<sessionId>` |
|
|
107
|
-
| `/api/sessions/watch` | `GET` | SSE stream for live session updates. `?id=<sessionId>` |
|
|
108
|
-
| `/api/
|
|
109
|
-
| `/api/
|
|
98
|
+
| `/api/sessions/history` | `GET` | Full transcript for a session. `?id=<sessionId>&workspace=<path>` |
|
|
99
|
+
| `/api/sessions/watch` | `GET` | SSE stream for live session updates. `?id=<sessionId>&workspace=<path>` |
|
|
100
|
+
| `/api/projects` | `GET` | List all discovered Cursor projects |
|
|
101
|
+
| `/api/git` | `GET` | Git status, diffs, and branches. `?workspace=<path>&detail=status\|diff\|branches` |
|
|
102
|
+
| `/api/git` | `POST` | Git actions. Body: `{ action, workspace?, message?, files?, branch? }` |
|
|
103
|
+
| `/api/upload` | `POST` | Upload images (multipart/form-data) |
|
|
104
|
+
| `/api/settings` | `GET` | Get current settings |
|
|
105
|
+
| `/api/settings` | `PATCH` | Update settings. Body: `{ key, value }` |
|
|
110
106
|
| `/api/info` | `GET` | Network info, auth URL, and workspace path |
|
|
111
|
-
| `/api/push/vapid-key` | `GET` | VAPID public key for push notification subscription |
|
|
112
|
-
| `/api/push/subscribe` | `POST` | Register a push subscription. Body: standard `PushSubscription` JSON |
|
|
113
|
-
| `/api/push/subscribe` | `DELETE` | Remove a push subscription. Body: `{ endpoint }` |
|
|
114
107
|
|
|
115
108
|
### Environment variables
|
|
116
109
|
|
package/bin/dev.mjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createServer } from "net";
|
|
4
|
+
import { spawn } from "child_process";
|
|
5
|
+
import { resolve, dirname } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { networkInterfaces } from "os";
|
|
8
|
+
import { randomInt } from "crypto";
|
|
9
|
+
import qrcode from "qrcode-terminal";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const projectRoot = resolve(__dirname, "..");
|
|
13
|
+
|
|
14
|
+
const startPort = parseInt(process.env.PORT || "3100", 10);
|
|
15
|
+
const MAX_ATTEMPTS = 20;
|
|
16
|
+
|
|
17
|
+
const WORDS = [
|
|
18
|
+
"alpha","amber","apple","atlas","azure","birch","blaze","bloom","brave","brook",
|
|
19
|
+
"cedar","charm","chess","climb","cloud","coral","crane","crisp","crown","dance",
|
|
20
|
+
"delta","dream","drift","eagle","ember","fable","flame","flint","frost","gleam",
|
|
21
|
+
"globe","grace","grove","haven","hazel","honey","ivory","jewel","karma","latch",
|
|
22
|
+
"lemon","light","lotus","maple","marsh","melon","mirth","noble","north","oasis",
|
|
23
|
+
"ocean","olive","orbit","pearl","petal","pilot","plume","prism","quail","quest",
|
|
24
|
+
"raven","ridge","rover","royal","ruby","sage","shore","silk","slate","solar",
|
|
25
|
+
"spark","spire","stone","storm","swift","thorn","tiger","torch","trail","trend",
|
|
26
|
+
"trick","trout","tulip","ultra","umbra","unity","upper","urban","vault","verse",
|
|
27
|
+
"vigor","vinyl","viola","viper","vivid","wagon","watch","wheat","whirl","width",
|
|
28
|
+
"wired","yacht","zebra","zephyr",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
function generateToken() {
|
|
32
|
+
return `${WORDS[randomInt(WORDS.length)]}-${WORDS[randomInt(WORDS.length)]}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isPortAvailable(port) {
|
|
36
|
+
return new Promise((res) => {
|
|
37
|
+
const srv = createServer();
|
|
38
|
+
srv.once("error", () => res(false));
|
|
39
|
+
srv.listen(port, "0.0.0.0", () => srv.close(() => res(true)));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function findPort(start) {
|
|
44
|
+
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
45
|
+
const p = start + i;
|
|
46
|
+
if (p > 65535) break;
|
|
47
|
+
if (await isPortAvailable(p)) return p;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const port = await findPort(startPort);
|
|
53
|
+
if (!port) {
|
|
54
|
+
console.error(`No available port found starting from ${startPort}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
if (port !== startPort) {
|
|
58
|
+
console.log(`Port ${startPort} in use, using ${port}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const authToken = process.env.AUTH_TOKEN || generateToken();
|
|
62
|
+
|
|
63
|
+
const isStart = process.argv.includes("--start");
|
|
64
|
+
const nextBin = resolve(projectRoot, "node_modules", ".bin", "next");
|
|
65
|
+
const args = isStart
|
|
66
|
+
? ["start", "--hostname", "0.0.0.0", "--port", String(port)]
|
|
67
|
+
: ["dev", "--hostname", "0.0.0.0", "--port", String(port)];
|
|
68
|
+
|
|
69
|
+
const lanIp = Object.values(networkInterfaces())
|
|
70
|
+
.flat()
|
|
71
|
+
.find((a) => a?.family === "IPv4" && !a.internal)?.address;
|
|
72
|
+
|
|
73
|
+
const localUrl = `http://localhost:${port}`;
|
|
74
|
+
const networkUrl = lanIp ? `http://${lanIp}:${port}` : null;
|
|
75
|
+
const authUrl = `${networkUrl || localUrl}?token=${authToken}`;
|
|
76
|
+
|
|
77
|
+
console.log(`\n \x1b[2mLocal:\x1b[0m ${localUrl}?token=${authToken}`);
|
|
78
|
+
if (networkUrl) {
|
|
79
|
+
console.log(` \x1b[2mNetwork:\x1b[0m ${authUrl}`);
|
|
80
|
+
}
|
|
81
|
+
console.log(` \x1b[2mToken:\x1b[0m ${authToken}\n`);
|
|
82
|
+
|
|
83
|
+
if (networkUrl) {
|
|
84
|
+
console.log(" \x1b[2mScan to connect from your phone:\x1b[0m\n");
|
|
85
|
+
qrcode.generate(authUrl, { small: true }, (code) => {
|
|
86
|
+
console.log(code.split("\n").map((l) => " " + l).join("\n") + "\n");
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const child = spawn(nextBin, args, {
|
|
91
|
+
cwd: projectRoot,
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
env: { ...process.env, PORT: String(port), AUTH_TOKEN: authToken },
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
child.on("close", (code) => process.exit(code ?? 0));
|
|
97
|
+
process.on("SIGINT", () => child.kill("SIGTERM"));
|
|
98
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
package/next.config.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const isDev = process.env.NODE_ENV === "development";
|
|
2
2
|
|
|
3
3
|
const csp = isDev
|
|
4
|
-
? "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' ws
|
|
5
|
-
: "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'
|
|
4
|
+
? "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' ws:"
|
|
5
|
+
: "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'";
|
|
6
6
|
|
|
7
7
|
/** @type {import('next').NextConfig} */
|
|
8
8
|
const nextConfig = {
|
|
9
|
-
serverExternalPackages: ["sql.js"
|
|
9
|
+
serverExternalPackages: ["sql.js"],
|
|
10
10
|
async headers() {
|
|
11
11
|
return [
|
|
12
12
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-local-remote",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Control Cursor IDE from any device on your local network",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"next.config.mjs"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "
|
|
35
|
+
"dev": "node bin/dev.mjs",
|
|
36
36
|
"build": "next build",
|
|
37
|
-
"start": "
|
|
37
|
+
"start": "node bin/dev.mjs --start",
|
|
38
38
|
"lint": "eslint .",
|
|
39
39
|
"lint:fix": "eslint . --fix",
|
|
40
40
|
"format": "prettier --write .",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"remark-gfm": "^4.0.1",
|
|
55
55
|
"sql.js": "^1.14.1",
|
|
56
56
|
"web-haptics": "^0.0.6",
|
|
57
|
-
"web-push": "^3.6.7",
|
|
58
57
|
"zod": "^4.3.6"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
package/public/sw.js
CHANGED
|
@@ -1,68 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const SHELL_URLS = ["/"];
|
|
3
|
-
|
|
4
|
-
self.addEventListener("install", (event) => {
|
|
5
|
-
event.waitUntil(
|
|
6
|
-
caches.open(CACHE_NAME).then((cache) => cache.addAll(SHELL_URLS)),
|
|
7
|
-
);
|
|
8
|
-
self.skipWaiting();
|
|
9
|
-
});
|
|
1
|
+
self.addEventListener("install", () => self.skipWaiting());
|
|
10
2
|
|
|
11
3
|
self.addEventListener("activate", (event) => {
|
|
12
4
|
event.waitUntil(
|
|
13
|
-
caches.keys().then((keys) =>
|
|
14
|
-
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))),
|
|
15
|
-
),
|
|
16
|
-
);
|
|
17
|
-
self.clients.claim();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
self.addEventListener("push", (event) => {
|
|
21
|
-
const data = event.data?.json() ?? {};
|
|
22
|
-
const title = data.title || "Agent finished";
|
|
23
|
-
const options = {
|
|
24
|
-
body: data.body || "Response complete",
|
|
25
|
-
icon: "/icon-192.png",
|
|
26
|
-
};
|
|
27
|
-
event.waitUntil(self.registration.showNotification(title, options));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
self.addEventListener("message", (event) => {
|
|
31
|
-
if (event.data?.type === "SHOW_NOTIFICATION") {
|
|
32
|
-
const { title, options } = event.data;
|
|
33
|
-
event.waitUntil(self.registration.showNotification(title, options));
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
self.addEventListener("notificationclick", (event) => {
|
|
38
|
-
event.notification.close();
|
|
39
|
-
event.waitUntil(
|
|
40
|
-
clients.matchAll({ type: "window", includeUncontrolled: true }).then((windowClients) => {
|
|
41
|
-
if (windowClients.length > 0) {
|
|
42
|
-
return windowClients[0].focus();
|
|
43
|
-
}
|
|
44
|
-
return clients.openWindow("/");
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
self.addEventListener("fetch", (event) => {
|
|
50
|
-
if (event.request.method !== "GET") return;
|
|
51
|
-
|
|
52
|
-
const url = new URL(event.request.url);
|
|
53
|
-
|
|
54
|
-
// Never cache API calls or SSE streams
|
|
55
|
-
if (url.pathname.startsWith("/api/")) return;
|
|
56
|
-
|
|
57
|
-
event.respondWith(
|
|
58
|
-
fetch(event.request)
|
|
59
|
-
.then((response) => {
|
|
60
|
-
if (response.ok && url.origin === self.location.origin) {
|
|
61
|
-
const clone = response.clone();
|
|
62
|
-
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
|
|
63
|
-
}
|
|
64
|
-
return response;
|
|
65
|
-
})
|
|
66
|
-
.catch(() => caches.match(event.request)),
|
|
5
|
+
caches.keys().then((keys) => Promise.all(keys.map((k) => caches.delete(k)))).then(() => self.registration.unregister()),
|
|
67
6
|
);
|
|
68
7
|
});
|