@thevinci/web 1.3.0 → 1.3.1

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.
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modelPrefsAutoSave-BUSppnWi.js","assets/vendor-.bun-DgrCmzWD.js","assets/vendor--DaW60Aqe.css","assets/index-BW75F1_U.js","assets/index-B_msE9DC.css"])))=>i.map(i=>d[i]);
2
- import{c as G,j as i,R as h,_ as Nt,av as At,r as Rt}from"./vendor-.bun-DgrCmzWD.js";import"./index-BW75F1_U.js";import{eu as Lt,u as _t,dW as Ot,N as b,m as le,l as Ze,Z as S,bk as vt,ev as Bt,C as zt,a$ as Dt,a6 as Tt,a8 as $t,a9 as Wt,c as Ut,ah as Gt,ew as Vt,ab as he,I as pe,ex as Ft,R as bt,a as wt,ag as U,a3 as Ht,ax as qt,ae as Kt,ea as Jt,eb as Zt,ec as Qt,o as jt,e9 as kt,ef as Xt,ei as Yt,ee as en,ai as tn,ed as nn,ey as rn,bR as sn,eq as on,er as an,es as cn,et as ln,ej as dn,ek as un,el as fn,em as mn,en as pn,eo as hn,ep as yn}from"./modelPrefsAutoSave-BUSppnWi.js";const gn=t=>{const e=G.c(3),{mode:r,children:s}=t;let n;return e[0]!==s||e[1]!==r?(n=i.jsx(Lt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=n):n=e[2],n},xn=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=typeof window<"u"?window.__VINCI_HOME__:"";if(r&&e===r)return"~";if(r&&e.startsWith(`${r}/`))return`~/${e.slice(r.length+1)}`;const s=e.split("/").filter(Boolean);return s.length<=3?e:`.../${s.slice(-3).join("/")}`},T=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=e.replace(/\\/g,"/");return r==="/"?"/":r.replace(/\/+$/,"")},wn=t=>{const e=G.c(135),{mode:r}=t,{t:s}=_t(),n=b(Sn),d=b(bn),a=b(jn),u=le(In),f=Ze(_n),l=Ze(Dn),p=S(kn),D=S(Pn),j=vt(),g=Bt(n??""),y=zt(),w=Dt(Cn);let B;e[0]!==n?(B=o=>n?o.worktreeMetadata.get(n)?.path??"":"",e[0]=n,e[1]=B):B=e[1];const N=b(B);let M;e[2]!==n?(M=o=>n?o.worktreeMetadata.get(n)?.branch?.trim()??null:null,e[2]=n,e[3]=M):M=e[3];const c=b(M);let A;e[4]!==n?(A=o=>n?o.getAttachment(n):void 0,e[4]=n,e[5]=A):A=e[5];const I=Tt(A),ye=b(Mn),[_,L]=h.useState(!1),de=typeof window<"u"?window.__APP_MACOS_MAJOR__??0:0,Qe=Number.isFinite(de)&&de>0,ue=Qe?de>=26?"h-12":de<=15?"h-14":"":"";let z;e[6]!==n||e[7]!==j?(z=n?j.find(o=>o.id===n)??null:null,e[6]=n,e[7]=j,e[8]=z):z=e[8];const R=z,V=R?.worktreeMetadata??null;let ge,xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>{Vt()&&he("desktop_get_window_pinned").then(o=>{typeof o?.pinned=="boolean"&&L(o.pinned)})},xe=[],e[9]=ge,e[10]=xe):(ge=e[9],xe=e[10]),h.useEffect(ge,xe);let we;e[11]!==d||e[12]!==r||e[13]!==R?.title||e[14]!==s?(we=R?.title?.trim()||s(d||r==="draft"?"miniChat.header.newSession":"miniChat.header.session"),e[11]=d,e[12]=r,e[13]=R?.title,e[14]=s,e[15]=we):we=e[15];const Xe=we,Ye=R?.directory??null;let ve;e[16]!==Ye?(ve=T(Ye),e[16]=Ye,e[17]=ve):ve=e[17];const Se=ve,et=N||V?.path||I?.cwd||I?.worktreeRoot||"";let be;e[18]!==et?(be=T(et),e[18]=et,e[19]=be):be=e[19];const je=be;let Ie;e[20]!==u?(Ie=T(u),e[20]=u,e[21]=Ie):Ie=e[21];const k=je||Se||ye||Ie;let _e;e[22]!==k?(_e=xn(k),e[22]=k,e[23]=_e):_e=e[23];const Pt=_e;let De;e[24]!==Se||e[25]!==je?(De=o=>{const m=T(je||Se||"");if(!m)return null;for(const C of o.availableWorktreesByProject.values()){const v=C.find(O=>T(O.path)===m)?.branch?.trim();if(v)return v}return null},e[24]=Se,e[25]=je,e[26]=De):De=e[26];const tt=b(De);let ke,Pe;e[27]!==w||e[28]!==k||e[29]!==y.git?(ke=()=>{k&&w(k,y.git).catch(En)},Pe=[w,k,y.git],e[27]=w,e[28]=k,e[29]=y.git,e[30]=ke,e[31]=Pe):(ke=e[30],Pe=e[31]),h.useEffect(ke,Pe),V?.projectDirectory,I?.worktreeRoot;let nt;e:{const o=V?.projectDirectory??I?.worktreeRoot??null;let m;e[32]!==o?(m=T(o),e[32]=o,e[33]=m):m=e[33];const x=m||k;if(!x){nt=null;break e}let v;e[34]!==x||e[35]!==f?(v=f.map(Nn).filter(O=>O.normalizedPath&&(O.normalizedPath===x||x.startsWith(`${O.normalizedPath}/`))).sort(An)[0]??null,e[34]=x,e[35]=f,e[36]=v):v=e[36],nt=v}const Ct=nt;let Ce;e:{const o=Ct??l;if(!o){Ce=Pt||"Vinci";break e}let m;e[37]!==o.label?(m=o.label?.trim(),e[37]=o.label,e[38]=m):m=e[38];const C=m;if(C){Ce=C;break e}let x;e[39]!==o.path?(x=o.path.split(/[\\/]/).filter(Boolean).at(-1)??o.path,e[39]=o.path,e[40]=x):x=e[40],Ce=x}const rt=Ce,st=$t(k||null);let Me;e[41]!==tt||e[42]!==st||e[43]!==V?.branch||e[44]!==I?.branch||e[45]!==c?(Me=st||c||V?.branch?.trim()||I?.branch?.trim()||tt,e[41]=tt,e[42]=st,e[43]=V?.branch,e[44]=I?.branch,e[45]=c,e[46]=Me):Me=e[46];const ot=Me,Ee=ot&&ot!=="HEAD"?ot:null;R?.summary;const it=R?.summary;let Ne;e[47]!==it?(Ne=Wt(it),e[47]=it,e[48]=Ne):Ne=e[48];const at=Ne;let Ae;e[49]!==at?(Ae=at??{additions:0,deletions:0},e[49]=at,e[50]=Ae):Ae=e[50];const F=Ae,ct=F.additions>0||F.deletions>0;let Re;e[51]!==p?(Re=p(),e[51]=p,e[52]=Re):Re=e[52];const St=Re;let lt;e:{for(let o=g.length-1;o>=0;o=o-1,o){const m=g[o];if(m.role!=="assistant"||typeof m.providerID!="string"||typeof m.modelID!="string")continue;const x=D.find(v=>v.id===m.providerID)?.models.find(v=>v.id===m.modelID);if(x){lt=x;break e}}lt=void 0}const Mt=lt,Le=St?.limit?St:Mt,H=Le&&typeof Le.limit=="object"&&Le.limit!==null?Le.limit:null,$=H&&typeof H.context=="number"?H.context:0,fe=H&&typeof H.output=="number"?H.output:0;let Oe;e:{if(!n||g.length===0){Oe=null;break e}let o,m;for(let me=g.length-1;me>=0;me=me-1,me){const xt=g[me];if(xt.role!=="assistant")continue;const W=xt.tokens;if(!W)continue;if(W.input+W.output+W.reasoning+(W.cache?.read??0)+(W.cache?.write??0)>0){o=W,m=xt.id;break}}if(!o){Oe=null;break e}const C=o.input+o.output+o.reasoning+(o.cache?.read??0)+(o.cache?.write??0),x=$>0?$:2e5;let v;e[53]!==$||e[54]!==C?(v=$>0?Math.round(C/$*100):0,e[53]=$,e[54]=C,e[55]=v):v=e[55];const O=v;let Ke;e[56]!==o.output||e[57]!==fe?(Ke=fe>0?Math.round(o.output/fe*100):void 0,e[56]=o.output,e[57]=fe,e[58]=Ke):Ke=e[58];const ht=Ke,yt=$||0,gt=fe||void 0;let Je;e[59]!==m||e[60]!==ht||e[61]!==O||e[62]!==yt||e[63]!==gt||e[64]!==x||e[65]!==C?(Je={totalTokens:C,percentage:O,contextLimit:yt,outputLimit:gt,normalizedOutput:ht,thresholdLimit:x,lastMessageId:m},e[59]=m,e[60]=ht,e[61]=O,e[62]=yt,e[63]=gt,e[64]=x,e[65]=C,e[66]=Je):Je=e[66],Oe=Je}const P=Oe,[E,dt]=h.useState(null);let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be={WebkitAppRegion:"drag"},e[67]=Be):Be=e[67];const Et=Be;let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze={WebkitAppRegion:"no-drag"},e[68]=ze):ze=e[68];const ut=ze;let Te,$e;e[69]!==P||e[70]!==n?(Te=()=>{if(!n){dt(Rn);return}if(P&&P.totalTokens>0){dt(o=>o&&o.totalTokens===P.totalTokens&&o.percentage===P.percentage&&o.contextLimit===P.contextLimit&&(o.outputLimit??0)===(P.outputLimit??0)&&(o.normalizedOutput??0)===(P.normalizedOutput??0)&&o.thresholdLimit===P.thresholdLimit&&o.lastMessageId===P.lastMessageId?o:P);return}dt(Ln)},$e=[P,n],e[69]=P,e[70]=n,e[71]=Te,e[72]=$e):(Te=e[71],$e=e[72]),h.useEffect(Te,$e);const ft=E&&E.contextLimit>0?Math.min(999,E.totalTokens/E.contextLimit*100):0;let We;e[73]!==_?(We=()=>{const o=!_;L(o),he("desktop_set_window_pinned",{pinned:o}).catch(()=>{L(!o)})},e[73]=_,e[74]=We):We=e[74];const mt=We;let Ue;e[75]!==u||e[76]!==n||e[77]!==a||e[78]!==k||e[79]!==R?(Ue=()=>{const o=n?{sessionId:n,directory:R?.directory??u??""}:{mode:"draft",directory:k||u||"",projectId:a};he("desktop_focus_main_window",o).then(On)},e[75]=u,e[76]=n,e[77]=a,e[78]=k,e[79]=R,e[80]=Ue):Ue=e[80];const pt=Ue;let Ge;e[81]===Symbol.for("react.memo_cache_sentinel")?(Ge=Ut("flex items-center gap-3 border-b border-[var(--interactive-border)] bg-[var(--surface-background)] pr-3",Qe?"pl-[5.5rem]":"pl-3",ue||"min-h-14"),e[81]=Ge):Ge=e[81];let q;e[82]!==Xe?(q=i.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xe}),e[82]=Xe,e[83]=q):q=e[83];let K;e[84]!==rt?(K=i.jsx("span",{className:"truncate",children:rt}),e[84]=rt,e[85]=K):K=e[85];let J;e[86]!==Ee?(J=Ee?i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[i.jsx(pe,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),i.jsx("span",{className:"truncate",children:Ee})]}):null,e[86]=Ee,e[87]=J):J=e[87];let Z;e[88]!==F||e[89]!==ct?(Z=ct?i.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-0 text-[0.92em]",children:[i.jsxs("span",{className:"text-status-success/80",children:["+",F.additions]}),i.jsx("span",{className:"text-muted-foreground/60",children:"/"}),i.jsxs("span",{className:"text-status-error/65",children:["-",F.deletions]})]}):null,e[88]=F,e[89]=ct,e[90]=Z):Z=e[90];let Q;e[91]!==K||e[92]!==J||e[93]!==Z?(Q=i.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[K,J,Z]}),e[91]=K,e[92]=J,e[93]=Z,e[94]=Q):Q=e[94];let X;e[95]!==q||e[96]!==Q?(X=i.jsxs("div",{className:"flex min-w-0 flex-col items-start",children:[q,Q]}),e[95]=q,e[96]=Q,e[97]=X):X=e[97];let Y;e[98]!==s?(Y=s("sessions.switcher.openAria"),e[98]=s,e[99]=Y):Y=e[99];let Ve;e[100]===Symbol.for("react.memo_cache_sentinel")?(Ve=i.jsx(pe,{name:"history",className:"h-5 w-5"}),e[100]=Ve):Ve=e[100];let ee;e[101]!==Y?(ee=i.jsx(Ft,{children:i.jsx("button",{type:"button","aria-label":Y,style:ut,className:"inline-flex h-9 w-9 items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:Ve})}),e[101]=Y,e[102]=ee):ee=e[102];let Fe;e[103]===Symbol.for("react.memo_cache_sentinel")?(Fe=i.jsx("div",{className:"min-w-0 flex-1"}),e[103]=Fe):Fe=e[103];let te;e[104]!==ft||e[105]!==E?(te=E&&E.totalTokens>0?i.jsx(Gt,{totalTokens:E.totalTokens,percentage:ft,colorPercentage:E.percentage,contextLimit:E.contextLimit,outputLimit:E.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-5 w-5"}):null,e[104]=ft,e[105]=E,e[106]=te):te=e[106];let ne;e[107]!==_||e[108]!==s?(ne=s(_?"miniChat.actions.unpinAria":"miniChat.actions.pinAria"),e[107]=_,e[108]=s,e[109]=ne):ne=e[109];let re;e[110]!==_||e[111]!==s?(re=s(_?"miniChat.actions.unpin":"miniChat.actions.pin"),e[110]=_,e[111]=s,e[112]=re):re=e[112];let se;e[113]!==_?(se=_?i.jsx(pe,{name:"pushpin-2-fill",className:"h-4 w-4"}):i.jsx(pe,{name:"pushpin-2",className:"h-4 w-4"}),e[113]=_,e[114]=se):se=e[114];let oe;e[115]!==mt||e[116]!==ne||e[117]!==re||e[118]!==se?(oe=i.jsx(bt,{type:"button",variant:"ghost",size:"icon",onClick:mt,"aria-label":ne,title:re,style:ut,children:se}),e[115]=mt,e[116]=ne,e[117]=re,e[118]=se,e[119]=oe):oe=e[119];let ie;e[120]!==s?(ie=s("miniChat.actions.openMainAria"),e[120]=s,e[121]=ie):ie=e[121];let ae;e[122]!==s?(ae=s("miniChat.actions.openMain"),e[122]=s,e[123]=ae):ae=e[123];let He;e[124]===Symbol.for("react.memo_cache_sentinel")?(He=i.jsx(pe,{name:"external-link",className:"h-4 w-4"}),e[124]=He):He=e[124];let ce;e[125]!==pt||e[126]!==ie||e[127]!==ae?(ce=i.jsx(bt,{type:"button",variant:"ghost",size:"icon",onClick:pt,"aria-label":ie,title:ae,style:ut,children:He}),e[125]=pt,e[126]=ie,e[127]=ae,e[128]=ce):ce=e[128];let qe;return e[129]!==X||e[130]!==ee||e[131]!==te||e[132]!==oe||e[133]!==ce?(qe=i.jsxs("header",{className:Ge,style:Et,children:[X,ee,Fe,te,oe,ce]}),e[129]=X,e[130]=ee,e[131]=te,e[132]=oe,e[133]=ce,e[134]=qe):qe=e[134],qe},vn=t=>{const e=G.c(9),{mode:r,autoOpenDraft:s,unavailable:n}=t,d=s===void 0?!1:s,a=n===void 0?!1:n,{t:u}=_t();let f;e[0]!==r?(f=i.jsx(wn,{mode:r}),e[0]=r,e[1]=f):f=e[1];let l;e[2]!==d||e[3]!==u||e[4]!==a?(l=i.jsx("main",{className:"min-h-0 flex-1",children:a?i.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:i.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[i.jsx("div",{className:"font-medium text-foreground",children:u("miniChat.unavailable.title")}),i.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:u("miniChat.unavailable.description")})]})}):i.jsx(gn,{mode:"mini-chat",children:i.jsx(Ot,{autoOpenDraft:d})})}),e[2]=d,e[3]=u,e[4]=a,e[5]=l):l=e[5];let p;return e[6]!==f||e[7]!==l?(p=i.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[f,l]}),e[6]=f,e[7]=l,e[8]=p):p=e[8],p};function Sn(t){return t.currentSessionId}function bn(t){return!!t.newSessionDraft?.open}function jn(t){return t.newSessionDraft?.selectedProjectId??null}function In(t){return t.currentDirectory}function _n(t){return t.projects}function Dn(t){return t.getActiveProject()}function kn(t){return t.getCurrentModel}function Pn(t){return t.providers}function Cn(t){return t.ensureStatus}function Mn(t){return t.newSessionDraft?.open?T(t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride??""):""}function En(){}function Nn(t){return{...t,normalizedPath:T(t.path)}}function An(t,e){return e.path.length-t.path.length}function Rn(t){return t===null?t:null}function Ln(t){return t===null?t:null}function On(t){return t?.focused===!0?he("desktop_close_current_window"):null}const It=()=>{document.querySelector('textarea[data-chat-input="true"]')?.focus()},Bn=()=>{const t=wt(n=>n.shortcutOverrides),e=le(n=>n.currentDirectory),r=Ze(n=>n.getActiveProject()),s=b(n=>n.openNewSessionDraft);h.useEffect(()=>{const n=a=>Kt(a,t),d=a=>{if(U(a,n("focus_input"))){a.preventDefault(),It();return}if(Ht()&&U(a,n("new_mini_chat"))){a.preventDefault(),he("desktop_open_draft_mini_chat_window",{directory:e||r?.path||"",projectId:r?.id??null})?.catch(l=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",l)});return}if(U(a,n("new_chat"))){a.preventDefault(),s({selectedProjectId:r?.id??null,directoryOverride:e||r?.path||null,preserveDirectoryOverride:!!(e||r?.path)}),It();return}if(U(a,n("open_model_selector"))){a.preventDefault();const{isModelSelectorOpen:l,setModelSelectorOpen:p}=wt.getState();p(!l);return}if(U(a,n("cycle_thinking_variant"))){const l=S.getState();if(l.getCurrentModelVariants().length===0)return;a.preventDefault(),l.cycleCurrentVariant();const D=S.getState().currentVariant,j=b.getState().currentSessionId,g=S.getState().currentAgentName,y=S.getState().currentProviderId,w=S.getState().currentModelId;j&&g&&y&&w&&qt.getState().saveAgentModelVariantForSession(j,g,y,w,D);return}const u=U(a,n("cycle_favorite_model_forward")),f=U(a,n("cycle_favorite_model_backward"));if(u||f){const{favoriteModels:l,addRecentModel:p}=wt.getState();if(l.length===0)return;a.preventDefault();const{currentProviderId:D,currentModelId:j,setProvider:g,setModel:y}=S.getState(),w=l.findIndex(M=>M.providerID===D&&M.modelID===j),N=l[(w+(u?1:-1)+l.length)%l.length];g(N.providerID),y(N.modelID),p(N.providerID,N.modelID)}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[r?.id,r?.path,e,s,t])},zn="vinci:mini-chat-presence",Tn=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,e=t.get("mode")==="session"?"session":"draft",r=t.get("sessionId")?.trim()||null,s=t.get("directory")?.trim()||null,n=t.get("projectId")?.trim()||null;return{mode:e,sessionId:r,directory:s,projectId:n}},$n=({config:t})=>{const e=vt(),r=le(c=>c.currentDirectory),s=le(c=>c.setDirectory),n=Ze(c=>c.projects),d=b(c=>c.currentSessionId),a=b(c=>!!c.newSessionDraft?.open),u=b(c=>c.newSessionDraft?.open?c.newSessionDraft.bootstrapPendingDirectory??c.newSessionDraft.directoryOverride??"":""),f=b(c=>c.setCurrentSession),l=b(c=>c.openNewSessionDraft),p=S(c=>c.initializeApp),D=S(c=>c.isInitialized),j=S(c=>c.isConnected),g=S(c=>c.loadProviders),y=S(c=>c.loadAgents),w=S(c=>c.providers.length),B=S(c=>c.agents.length);h.useEffect(()=>{p()},[p]),h.useEffect(()=>{if(D)return;let c=!0,A=0;const I=window.setInterval(()=>{if(c){if(A+=1,A>10){window.clearInterval(I);return}S.getState().isInitialized||S.getState().initializeApp()}},1e3);return()=>{c=!1,window.clearInterval(I)}},[D]);const N=h.useRef(!1);h.useEffect(()=>{if(!N.current&&t.mode==="session"&&t.directory){if(r===t.directory){N.current=!0;return}s(t.directory,{showOverlay:!1}),N.current=!0}},[t.directory,t.mode,r,s]),h.useEffect(()=>{t.mode!=="draft"||!a||d||!u||r===u||s(u,{showOverlay:!1})},[t.mode,r,d,u,a,s]),h.useEffect(()=>{j&&(w===0&&g(),B===0&&y())},[B,j,y,g,w]);const M=h.useRef(!1);return h.useEffect(()=>{if(M.current||t.mode!=="session"||!t.sessionId)return;if(d===t.sessionId){M.current=!0;return}if(d){M.current=!0;return}const c=e.find(I=>I.id===t.sessionId);if(!c)return;const A=c.directory??t.directory;f(t.sessionId,A),M.current=!0},[t,d,e,f]),h.useEffect(()=>{t.mode!=="draft"||a||d||l({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,d,a,l]),h.useEffect(()=>{if(n.length===0)return;let c=!1;return(async()=>{const I=new Map,ye=[];await Promise.all(n.map(async _=>{const L=_.path.replace(/\\/g,"/").replace(/\/+$/,"");if(L)try{if(!(Dt.getState().directories.get(L)?.isGitRepo??await Nt(()=>import("./modelPrefsAutoSave-BUSppnWi.js").then(z=>z.fc),__vite__mapDeps([0,1,2,3,4])).then(z=>z.checkIsGitRepository(L))))return;const ue=await sn({id:_.id,path:L});if(c||ue.length===0)return;I.set(L,ue),ye.push(...ue)}catch{}})),!c&&b.setState({availableWorktrees:ye,availableWorktreesByProject:I})})(),()=>{c=!0}},[n]),null},Wn=()=>{const t=G.c(4),e=b(qn),r=le(Kn);let s,n;return t[0]!==r||t[1]!==e?(s=()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const d=new BroadcastChannel(zn),a=l=>{d.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:l})};a(!0);const u=window.setInterval(()=>a(!0),5e3),f=()=>a(!1);return window.addEventListener("beforeunload",f),()=>{window.clearInterval(u),window.removeEventListener("beforeunload",f),a(!1),d.close()}},n=[r,e],t[0]=r,t[1]=e,t[2]=s,t[3]=n):(s=t[2],n=t[3]),h.useEffect(s,n),null},Un=t=>{const e=G.c(6),r=vt(),s=b(Jn),[n,d]=h.useState(!1);let a,u;return e[0]!==t.mode||e[1]!==t.sessionId||e[2]!==s||e[3]!==r?(a=()=>{if(t.mode!=="session"||!t.sessionId||s===t.sessionId){d(!1);return}if(r.some(l=>l.id===t.sessionId)){d(!1);return}const f=window.setTimeout(()=>d(!0),5e3);return()=>window.clearTimeout(f)},u=[t.mode,t.sessionId,s,r],e[0]=t.mode,e[1]=t.sessionId,e[2]=s,e[3]=r,e[4]=a,e[5]=u):(a=e[4],u=e[5]),h.useEffect(a,u),n};function Gn(t){const e=G.c(15),{apis:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Tn(),e[0]=s):s=e[0];const n=s,d=le(Fn);let a,u;e[1]!==d?(a=()=>{jt.setDirectory(d||n.directory||void 0)},u=[n.directory,d],e[1]=d,e[2]=a,e[3]=u):(a=e[2],u=e[3]),h.useEffect(a,u);let f,l;e[4]!==r?(f=()=>(kt(r),Vn),l=[r],e[4]=r,e[5]=f,e[6]=l):(f=e[5],l=e[6]),h.useEffect(f,l),Jt(),Bn();let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p={enabled:!0},e[7]=p):p=e[7],Zt(p),Qt();let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=jt.getSdkClient(),e[8]=D):D=e[8];const j=d||n.directory||"";let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Xt,{delayDuration:300,skipDelayDuration:150,children:i.jsxs("div",{className:"h-full text-foreground bg-background",children:[i.jsx(Hn,{config:n}),i.jsx(Yt,{})]})}),e[9]=g):g=e[9];let y;e[10]!==r?(y=i.jsx(en,{apis:r,children:g}),e[10]=r,e[11]=y):y=e[11];let w;return e[12]!==y||e[13]!==j?(w=i.jsx(tn,{children:i.jsx(nn,{sdk:D,directory:j,children:y})}),e[12]=y,e[13]=j,e[14]=w):w=e[14],w}function Vn(){return kt(null)}function Fn(t){return t.currentDirectory}const Hn=t=>{const e=G.c(11),{config:r}=t,s=Un(r);let n;e[0]!==r?(n=i.jsx($n,{config:r}),e[0]=r,e[1]=n):n=e[1];let d,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Wn,{}),a=i.jsx(rn,{embeddedBackgroundWorkEnabled:!0}),e[2]=d,e[3]=a):(d=e[2],a=e[3]);const u=r.mode==="draft";let f;e[4]!==r.mode||e[5]!==s||e[6]!==u?(f=i.jsx(vn,{mode:r.mode,autoOpenDraft:u,unavailable:s}),e[4]=r.mode,e[5]=s,e[6]=u,e[7]=f):f=e[7];let l;return e[8]!==n||e[9]!==f?(l=i.jsxs(i.Fragment,{children:[n,d,a,f]}),e[8]=n,e[9]=f,e[10]=l):l=e[10],l};function qn(t){return t.currentSessionId}function Kn(t){return t.currentDirectory}function Jn(t){return t.currentSessionId}const Zn=()=>{dn(),un().then(()=>{Promise.all([fn(),mn()]).catch(t=>{console.error("[mini-chat-main] settings init failed:",t)}),pn(),hn(),yn()}).catch(t=>{console.error("[mini-chat-main] appearance init failed:",t)})};function nr(t){Zn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");At.createRoot(e).render(i.jsx(Rt.StrictMode,{children:i.jsx(on,{children:i.jsx(an,{children:i.jsx(cn,{children:i.jsx(ln,{children:i.jsx(Gn,{apis:t})})})})})}))}export{nr as renderElectronMiniChatApp};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modelPrefsAutoSave-DEc6o6vH.js","assets/vendor-.bun-DgrCmzWD.js","assets/vendor--DaW60Aqe.css","assets/index-BW75F1_U.js","assets/index-B_msE9DC.css"])))=>i.map(i=>d[i]);
2
+ import{c as G,j as i,R as h,_ as Nt,av as At,r as Rt}from"./vendor-.bun-DgrCmzWD.js";import"./index-BW75F1_U.js";import{eu as Lt,u as _t,dW as Ot,N as b,m as le,l as Ze,Z as S,bk as vt,ev as Bt,C as zt,a$ as Dt,a6 as Tt,a8 as $t,a9 as Wt,c as Ut,ah as Gt,ew as Vt,ab as he,I as pe,ex as Ft,R as bt,a as wt,ag as U,a3 as Ht,ax as qt,ae as Kt,ea as Jt,eb as Zt,ec as Qt,o as jt,e9 as kt,ef as Xt,ei as Yt,ee as en,ai as tn,ed as nn,ey as rn,bR as sn,eq as on,er as an,es as cn,et as ln,ej as dn,ek as un,el as fn,em as mn,en as pn,eo as hn,ep as yn}from"./modelPrefsAutoSave-DEc6o6vH.js";const gn=t=>{const e=G.c(3),{mode:r,children:s}=t;let n;return e[0]!==s||e[1]!==r?(n=i.jsx(Lt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=n):n=e[2],n},xn=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=typeof window<"u"?window.__VINCI_HOME__:"";if(r&&e===r)return"~";if(r&&e.startsWith(`${r}/`))return`~/${e.slice(r.length+1)}`;const s=e.split("/").filter(Boolean);return s.length<=3?e:`.../${s.slice(-3).join("/")}`},T=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=e.replace(/\\/g,"/");return r==="/"?"/":r.replace(/\/+$/,"")},wn=t=>{const e=G.c(135),{mode:r}=t,{t:s}=_t(),n=b(Sn),d=b(bn),a=b(jn),u=le(In),f=Ze(_n),l=Ze(Dn),p=S(kn),D=S(Pn),j=vt(),g=Bt(n??""),y=zt(),w=Dt(Cn);let B;e[0]!==n?(B=o=>n?o.worktreeMetadata.get(n)?.path??"":"",e[0]=n,e[1]=B):B=e[1];const N=b(B);let M;e[2]!==n?(M=o=>n?o.worktreeMetadata.get(n)?.branch?.trim()??null:null,e[2]=n,e[3]=M):M=e[3];const c=b(M);let A;e[4]!==n?(A=o=>n?o.getAttachment(n):void 0,e[4]=n,e[5]=A):A=e[5];const I=Tt(A),ye=b(Mn),[_,L]=h.useState(!1),de=typeof window<"u"?window.__APP_MACOS_MAJOR__??0:0,Qe=Number.isFinite(de)&&de>0,ue=Qe?de>=26?"h-12":de<=15?"h-14":"":"";let z;e[6]!==n||e[7]!==j?(z=n?j.find(o=>o.id===n)??null:null,e[6]=n,e[7]=j,e[8]=z):z=e[8];const R=z,V=R?.worktreeMetadata??null;let ge,xe;e[9]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>{Vt()&&he("desktop_get_window_pinned").then(o=>{typeof o?.pinned=="boolean"&&L(o.pinned)})},xe=[],e[9]=ge,e[10]=xe):(ge=e[9],xe=e[10]),h.useEffect(ge,xe);let we;e[11]!==d||e[12]!==r||e[13]!==R?.title||e[14]!==s?(we=R?.title?.trim()||s(d||r==="draft"?"miniChat.header.newSession":"miniChat.header.session"),e[11]=d,e[12]=r,e[13]=R?.title,e[14]=s,e[15]=we):we=e[15];const Xe=we,Ye=R?.directory??null;let ve;e[16]!==Ye?(ve=T(Ye),e[16]=Ye,e[17]=ve):ve=e[17];const Se=ve,et=N||V?.path||I?.cwd||I?.worktreeRoot||"";let be;e[18]!==et?(be=T(et),e[18]=et,e[19]=be):be=e[19];const je=be;let Ie;e[20]!==u?(Ie=T(u),e[20]=u,e[21]=Ie):Ie=e[21];const k=je||Se||ye||Ie;let _e;e[22]!==k?(_e=xn(k),e[22]=k,e[23]=_e):_e=e[23];const Pt=_e;let De;e[24]!==Se||e[25]!==je?(De=o=>{const m=T(je||Se||"");if(!m)return null;for(const C of o.availableWorktreesByProject.values()){const v=C.find(O=>T(O.path)===m)?.branch?.trim();if(v)return v}return null},e[24]=Se,e[25]=je,e[26]=De):De=e[26];const tt=b(De);let ke,Pe;e[27]!==w||e[28]!==k||e[29]!==y.git?(ke=()=>{k&&w(k,y.git).catch(En)},Pe=[w,k,y.git],e[27]=w,e[28]=k,e[29]=y.git,e[30]=ke,e[31]=Pe):(ke=e[30],Pe=e[31]),h.useEffect(ke,Pe),V?.projectDirectory,I?.worktreeRoot;let nt;e:{const o=V?.projectDirectory??I?.worktreeRoot??null;let m;e[32]!==o?(m=T(o),e[32]=o,e[33]=m):m=e[33];const x=m||k;if(!x){nt=null;break e}let v;e[34]!==x||e[35]!==f?(v=f.map(Nn).filter(O=>O.normalizedPath&&(O.normalizedPath===x||x.startsWith(`${O.normalizedPath}/`))).sort(An)[0]??null,e[34]=x,e[35]=f,e[36]=v):v=e[36],nt=v}const Ct=nt;let Ce;e:{const o=Ct??l;if(!o){Ce=Pt||"Vinci";break e}let m;e[37]!==o.label?(m=o.label?.trim(),e[37]=o.label,e[38]=m):m=e[38];const C=m;if(C){Ce=C;break e}let x;e[39]!==o.path?(x=o.path.split(/[\\/]/).filter(Boolean).at(-1)??o.path,e[39]=o.path,e[40]=x):x=e[40],Ce=x}const rt=Ce,st=$t(k||null);let Me;e[41]!==tt||e[42]!==st||e[43]!==V?.branch||e[44]!==I?.branch||e[45]!==c?(Me=st||c||V?.branch?.trim()||I?.branch?.trim()||tt,e[41]=tt,e[42]=st,e[43]=V?.branch,e[44]=I?.branch,e[45]=c,e[46]=Me):Me=e[46];const ot=Me,Ee=ot&&ot!=="HEAD"?ot:null;R?.summary;const it=R?.summary;let Ne;e[47]!==it?(Ne=Wt(it),e[47]=it,e[48]=Ne):Ne=e[48];const at=Ne;let Ae;e[49]!==at?(Ae=at??{additions:0,deletions:0},e[49]=at,e[50]=Ae):Ae=e[50];const F=Ae,ct=F.additions>0||F.deletions>0;let Re;e[51]!==p?(Re=p(),e[51]=p,e[52]=Re):Re=e[52];const St=Re;let lt;e:{for(let o=g.length-1;o>=0;o=o-1,o){const m=g[o];if(m.role!=="assistant"||typeof m.providerID!="string"||typeof m.modelID!="string")continue;const x=D.find(v=>v.id===m.providerID)?.models.find(v=>v.id===m.modelID);if(x){lt=x;break e}}lt=void 0}const Mt=lt,Le=St?.limit?St:Mt,H=Le&&typeof Le.limit=="object"&&Le.limit!==null?Le.limit:null,$=H&&typeof H.context=="number"?H.context:0,fe=H&&typeof H.output=="number"?H.output:0;let Oe;e:{if(!n||g.length===0){Oe=null;break e}let o,m;for(let me=g.length-1;me>=0;me=me-1,me){const xt=g[me];if(xt.role!=="assistant")continue;const W=xt.tokens;if(!W)continue;if(W.input+W.output+W.reasoning+(W.cache?.read??0)+(W.cache?.write??0)>0){o=W,m=xt.id;break}}if(!o){Oe=null;break e}const C=o.input+o.output+o.reasoning+(o.cache?.read??0)+(o.cache?.write??0),x=$>0?$:2e5;let v;e[53]!==$||e[54]!==C?(v=$>0?Math.round(C/$*100):0,e[53]=$,e[54]=C,e[55]=v):v=e[55];const O=v;let Ke;e[56]!==o.output||e[57]!==fe?(Ke=fe>0?Math.round(o.output/fe*100):void 0,e[56]=o.output,e[57]=fe,e[58]=Ke):Ke=e[58];const ht=Ke,yt=$||0,gt=fe||void 0;let Je;e[59]!==m||e[60]!==ht||e[61]!==O||e[62]!==yt||e[63]!==gt||e[64]!==x||e[65]!==C?(Je={totalTokens:C,percentage:O,contextLimit:yt,outputLimit:gt,normalizedOutput:ht,thresholdLimit:x,lastMessageId:m},e[59]=m,e[60]=ht,e[61]=O,e[62]=yt,e[63]=gt,e[64]=x,e[65]=C,e[66]=Je):Je=e[66],Oe=Je}const P=Oe,[E,dt]=h.useState(null);let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be={WebkitAppRegion:"drag"},e[67]=Be):Be=e[67];const Et=Be;let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze={WebkitAppRegion:"no-drag"},e[68]=ze):ze=e[68];const ut=ze;let Te,$e;e[69]!==P||e[70]!==n?(Te=()=>{if(!n){dt(Rn);return}if(P&&P.totalTokens>0){dt(o=>o&&o.totalTokens===P.totalTokens&&o.percentage===P.percentage&&o.contextLimit===P.contextLimit&&(o.outputLimit??0)===(P.outputLimit??0)&&(o.normalizedOutput??0)===(P.normalizedOutput??0)&&o.thresholdLimit===P.thresholdLimit&&o.lastMessageId===P.lastMessageId?o:P);return}dt(Ln)},$e=[P,n],e[69]=P,e[70]=n,e[71]=Te,e[72]=$e):(Te=e[71],$e=e[72]),h.useEffect(Te,$e);const ft=E&&E.contextLimit>0?Math.min(999,E.totalTokens/E.contextLimit*100):0;let We;e[73]!==_?(We=()=>{const o=!_;L(o),he("desktop_set_window_pinned",{pinned:o}).catch(()=>{L(!o)})},e[73]=_,e[74]=We):We=e[74];const mt=We;let Ue;e[75]!==u||e[76]!==n||e[77]!==a||e[78]!==k||e[79]!==R?(Ue=()=>{const o=n?{sessionId:n,directory:R?.directory??u??""}:{mode:"draft",directory:k||u||"",projectId:a};he("desktop_focus_main_window",o).then(On)},e[75]=u,e[76]=n,e[77]=a,e[78]=k,e[79]=R,e[80]=Ue):Ue=e[80];const pt=Ue;let Ge;e[81]===Symbol.for("react.memo_cache_sentinel")?(Ge=Ut("flex items-center gap-3 border-b border-[var(--interactive-border)] bg-[var(--surface-background)] pr-3",Qe?"pl-[5.5rem]":"pl-3",ue||"min-h-14"),e[81]=Ge):Ge=e[81];let q;e[82]!==Xe?(q=i.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xe}),e[82]=Xe,e[83]=q):q=e[83];let K;e[84]!==rt?(K=i.jsx("span",{className:"truncate",children:rt}),e[84]=rt,e[85]=K):K=e[85];let J;e[86]!==Ee?(J=Ee?i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[i.jsx(pe,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),i.jsx("span",{className:"truncate",children:Ee})]}):null,e[86]=Ee,e[87]=J):J=e[87];let Z;e[88]!==F||e[89]!==ct?(Z=ct?i.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-0 text-[0.92em]",children:[i.jsxs("span",{className:"text-status-success/80",children:["+",F.additions]}),i.jsx("span",{className:"text-muted-foreground/60",children:"/"}),i.jsxs("span",{className:"text-status-error/65",children:["-",F.deletions]})]}):null,e[88]=F,e[89]=ct,e[90]=Z):Z=e[90];let Q;e[91]!==K||e[92]!==J||e[93]!==Z?(Q=i.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[K,J,Z]}),e[91]=K,e[92]=J,e[93]=Z,e[94]=Q):Q=e[94];let X;e[95]!==q||e[96]!==Q?(X=i.jsxs("div",{className:"flex min-w-0 flex-col items-start",children:[q,Q]}),e[95]=q,e[96]=Q,e[97]=X):X=e[97];let Y;e[98]!==s?(Y=s("sessions.switcher.openAria"),e[98]=s,e[99]=Y):Y=e[99];let Ve;e[100]===Symbol.for("react.memo_cache_sentinel")?(Ve=i.jsx(pe,{name:"history",className:"h-5 w-5"}),e[100]=Ve):Ve=e[100];let ee;e[101]!==Y?(ee=i.jsx(Ft,{children:i.jsx("button",{type:"button","aria-label":Y,style:ut,className:"inline-flex h-9 w-9 items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:Ve})}),e[101]=Y,e[102]=ee):ee=e[102];let Fe;e[103]===Symbol.for("react.memo_cache_sentinel")?(Fe=i.jsx("div",{className:"min-w-0 flex-1"}),e[103]=Fe):Fe=e[103];let te;e[104]!==ft||e[105]!==E?(te=E&&E.totalTokens>0?i.jsx(Gt,{totalTokens:E.totalTokens,percentage:ft,colorPercentage:E.percentage,contextLimit:E.contextLimit,outputLimit:E.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-5 w-5"}):null,e[104]=ft,e[105]=E,e[106]=te):te=e[106];let ne;e[107]!==_||e[108]!==s?(ne=s(_?"miniChat.actions.unpinAria":"miniChat.actions.pinAria"),e[107]=_,e[108]=s,e[109]=ne):ne=e[109];let re;e[110]!==_||e[111]!==s?(re=s(_?"miniChat.actions.unpin":"miniChat.actions.pin"),e[110]=_,e[111]=s,e[112]=re):re=e[112];let se;e[113]!==_?(se=_?i.jsx(pe,{name:"pushpin-2-fill",className:"h-4 w-4"}):i.jsx(pe,{name:"pushpin-2",className:"h-4 w-4"}),e[113]=_,e[114]=se):se=e[114];let oe;e[115]!==mt||e[116]!==ne||e[117]!==re||e[118]!==se?(oe=i.jsx(bt,{type:"button",variant:"ghost",size:"icon",onClick:mt,"aria-label":ne,title:re,style:ut,children:se}),e[115]=mt,e[116]=ne,e[117]=re,e[118]=se,e[119]=oe):oe=e[119];let ie;e[120]!==s?(ie=s("miniChat.actions.openMainAria"),e[120]=s,e[121]=ie):ie=e[121];let ae;e[122]!==s?(ae=s("miniChat.actions.openMain"),e[122]=s,e[123]=ae):ae=e[123];let He;e[124]===Symbol.for("react.memo_cache_sentinel")?(He=i.jsx(pe,{name:"external-link",className:"h-4 w-4"}),e[124]=He):He=e[124];let ce;e[125]!==pt||e[126]!==ie||e[127]!==ae?(ce=i.jsx(bt,{type:"button",variant:"ghost",size:"icon",onClick:pt,"aria-label":ie,title:ae,style:ut,children:He}),e[125]=pt,e[126]=ie,e[127]=ae,e[128]=ce):ce=e[128];let qe;return e[129]!==X||e[130]!==ee||e[131]!==te||e[132]!==oe||e[133]!==ce?(qe=i.jsxs("header",{className:Ge,style:Et,children:[X,ee,Fe,te,oe,ce]}),e[129]=X,e[130]=ee,e[131]=te,e[132]=oe,e[133]=ce,e[134]=qe):qe=e[134],qe},vn=t=>{const e=G.c(9),{mode:r,autoOpenDraft:s,unavailable:n}=t,d=s===void 0?!1:s,a=n===void 0?!1:n,{t:u}=_t();let f;e[0]!==r?(f=i.jsx(wn,{mode:r}),e[0]=r,e[1]=f):f=e[1];let l;e[2]!==d||e[3]!==u||e[4]!==a?(l=i.jsx("main",{className:"min-h-0 flex-1",children:a?i.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:i.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[i.jsx("div",{className:"font-medium text-foreground",children:u("miniChat.unavailable.title")}),i.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:u("miniChat.unavailable.description")})]})}):i.jsx(gn,{mode:"mini-chat",children:i.jsx(Ot,{autoOpenDraft:d})})}),e[2]=d,e[3]=u,e[4]=a,e[5]=l):l=e[5];let p;return e[6]!==f||e[7]!==l?(p=i.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[f,l]}),e[6]=f,e[7]=l,e[8]=p):p=e[8],p};function Sn(t){return t.currentSessionId}function bn(t){return!!t.newSessionDraft?.open}function jn(t){return t.newSessionDraft?.selectedProjectId??null}function In(t){return t.currentDirectory}function _n(t){return t.projects}function Dn(t){return t.getActiveProject()}function kn(t){return t.getCurrentModel}function Pn(t){return t.providers}function Cn(t){return t.ensureStatus}function Mn(t){return t.newSessionDraft?.open?T(t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride??""):""}function En(){}function Nn(t){return{...t,normalizedPath:T(t.path)}}function An(t,e){return e.path.length-t.path.length}function Rn(t){return t===null?t:null}function Ln(t){return t===null?t:null}function On(t){return t?.focused===!0?he("desktop_close_current_window"):null}const It=()=>{document.querySelector('textarea[data-chat-input="true"]')?.focus()},Bn=()=>{const t=wt(n=>n.shortcutOverrides),e=le(n=>n.currentDirectory),r=Ze(n=>n.getActiveProject()),s=b(n=>n.openNewSessionDraft);h.useEffect(()=>{const n=a=>Kt(a,t),d=a=>{if(U(a,n("focus_input"))){a.preventDefault(),It();return}if(Ht()&&U(a,n("new_mini_chat"))){a.preventDefault(),he("desktop_open_draft_mini_chat_window",{directory:e||r?.path||"",projectId:r?.id??null})?.catch(l=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",l)});return}if(U(a,n("new_chat"))){a.preventDefault(),s({selectedProjectId:r?.id??null,directoryOverride:e||r?.path||null,preserveDirectoryOverride:!!(e||r?.path)}),It();return}if(U(a,n("open_model_selector"))){a.preventDefault();const{isModelSelectorOpen:l,setModelSelectorOpen:p}=wt.getState();p(!l);return}if(U(a,n("cycle_thinking_variant"))){const l=S.getState();if(l.getCurrentModelVariants().length===0)return;a.preventDefault(),l.cycleCurrentVariant();const D=S.getState().currentVariant,j=b.getState().currentSessionId,g=S.getState().currentAgentName,y=S.getState().currentProviderId,w=S.getState().currentModelId;j&&g&&y&&w&&qt.getState().saveAgentModelVariantForSession(j,g,y,w,D);return}const u=U(a,n("cycle_favorite_model_forward")),f=U(a,n("cycle_favorite_model_backward"));if(u||f){const{favoriteModels:l,addRecentModel:p}=wt.getState();if(l.length===0)return;a.preventDefault();const{currentProviderId:D,currentModelId:j,setProvider:g,setModel:y}=S.getState(),w=l.findIndex(M=>M.providerID===D&&M.modelID===j),N=l[(w+(u?1:-1)+l.length)%l.length];g(N.providerID),y(N.modelID),p(N.providerID,N.modelID)}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[r?.id,r?.path,e,s,t])},zn="vinci:mini-chat-presence",Tn=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,e=t.get("mode")==="session"?"session":"draft",r=t.get("sessionId")?.trim()||null,s=t.get("directory")?.trim()||null,n=t.get("projectId")?.trim()||null;return{mode:e,sessionId:r,directory:s,projectId:n}},$n=({config:t})=>{const e=vt(),r=le(c=>c.currentDirectory),s=le(c=>c.setDirectory),n=Ze(c=>c.projects),d=b(c=>c.currentSessionId),a=b(c=>!!c.newSessionDraft?.open),u=b(c=>c.newSessionDraft?.open?c.newSessionDraft.bootstrapPendingDirectory??c.newSessionDraft.directoryOverride??"":""),f=b(c=>c.setCurrentSession),l=b(c=>c.openNewSessionDraft),p=S(c=>c.initializeApp),D=S(c=>c.isInitialized),j=S(c=>c.isConnected),g=S(c=>c.loadProviders),y=S(c=>c.loadAgents),w=S(c=>c.providers.length),B=S(c=>c.agents.length);h.useEffect(()=>{p()},[p]),h.useEffect(()=>{if(D)return;let c=!0,A=0;const I=window.setInterval(()=>{if(c){if(A+=1,A>10){window.clearInterval(I);return}S.getState().isInitialized||S.getState().initializeApp()}},1e3);return()=>{c=!1,window.clearInterval(I)}},[D]);const N=h.useRef(!1);h.useEffect(()=>{if(!N.current&&t.mode==="session"&&t.directory){if(r===t.directory){N.current=!0;return}s(t.directory,{showOverlay:!1}),N.current=!0}},[t.directory,t.mode,r,s]),h.useEffect(()=>{t.mode!=="draft"||!a||d||!u||r===u||s(u,{showOverlay:!1})},[t.mode,r,d,u,a,s]),h.useEffect(()=>{j&&(w===0&&g(),B===0&&y())},[B,j,y,g,w]);const M=h.useRef(!1);return h.useEffect(()=>{if(M.current||t.mode!=="session"||!t.sessionId)return;if(d===t.sessionId){M.current=!0;return}if(d){M.current=!0;return}const c=e.find(I=>I.id===t.sessionId);if(!c)return;const A=c.directory??t.directory;f(t.sessionId,A),M.current=!0},[t,d,e,f]),h.useEffect(()=>{t.mode!=="draft"||a||d||l({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,d,a,l]),h.useEffect(()=>{if(n.length===0)return;let c=!1;return(async()=>{const I=new Map,ye=[];await Promise.all(n.map(async _=>{const L=_.path.replace(/\\/g,"/").replace(/\/+$/,"");if(L)try{if(!(Dt.getState().directories.get(L)?.isGitRepo??await Nt(()=>import("./modelPrefsAutoSave-DEc6o6vH.js").then(z=>z.fc),__vite__mapDeps([0,1,2,3,4])).then(z=>z.checkIsGitRepository(L))))return;const ue=await sn({id:_.id,path:L});if(c||ue.length===0)return;I.set(L,ue),ye.push(...ue)}catch{}})),!c&&b.setState({availableWorktrees:ye,availableWorktreesByProject:I})})(),()=>{c=!0}},[n]),null},Wn=()=>{const t=G.c(4),e=b(qn),r=le(Kn);let s,n;return t[0]!==r||t[1]!==e?(s=()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const d=new BroadcastChannel(zn),a=l=>{d.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:l})};a(!0);const u=window.setInterval(()=>a(!0),5e3),f=()=>a(!1);return window.addEventListener("beforeunload",f),()=>{window.clearInterval(u),window.removeEventListener("beforeunload",f),a(!1),d.close()}},n=[r,e],t[0]=r,t[1]=e,t[2]=s,t[3]=n):(s=t[2],n=t[3]),h.useEffect(s,n),null},Un=t=>{const e=G.c(6),r=vt(),s=b(Jn),[n,d]=h.useState(!1);let a,u;return e[0]!==t.mode||e[1]!==t.sessionId||e[2]!==s||e[3]!==r?(a=()=>{if(t.mode!=="session"||!t.sessionId||s===t.sessionId){d(!1);return}if(r.some(l=>l.id===t.sessionId)){d(!1);return}const f=window.setTimeout(()=>d(!0),5e3);return()=>window.clearTimeout(f)},u=[t.mode,t.sessionId,s,r],e[0]=t.mode,e[1]=t.sessionId,e[2]=s,e[3]=r,e[4]=a,e[5]=u):(a=e[4],u=e[5]),h.useEffect(a,u),n};function Gn(t){const e=G.c(15),{apis:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Tn(),e[0]=s):s=e[0];const n=s,d=le(Fn);let a,u;e[1]!==d?(a=()=>{jt.setDirectory(d||n.directory||void 0)},u=[n.directory,d],e[1]=d,e[2]=a,e[3]=u):(a=e[2],u=e[3]),h.useEffect(a,u);let f,l;e[4]!==r?(f=()=>(kt(r),Vn),l=[r],e[4]=r,e[5]=f,e[6]=l):(f=e[5],l=e[6]),h.useEffect(f,l),Jt(),Bn();let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p={enabled:!0},e[7]=p):p=e[7],Zt(p),Qt();let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=jt.getSdkClient(),e[8]=D):D=e[8];const j=d||n.directory||"";let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Xt,{delayDuration:300,skipDelayDuration:150,children:i.jsxs("div",{className:"h-full text-foreground bg-background",children:[i.jsx(Hn,{config:n}),i.jsx(Yt,{})]})}),e[9]=g):g=e[9];let y;e[10]!==r?(y=i.jsx(en,{apis:r,children:g}),e[10]=r,e[11]=y):y=e[11];let w;return e[12]!==y||e[13]!==j?(w=i.jsx(tn,{children:i.jsx(nn,{sdk:D,directory:j,children:y})}),e[12]=y,e[13]=j,e[14]=w):w=e[14],w}function Vn(){return kt(null)}function Fn(t){return t.currentDirectory}const Hn=t=>{const e=G.c(11),{config:r}=t,s=Un(r);let n;e[0]!==r?(n=i.jsx($n,{config:r}),e[0]=r,e[1]=n):n=e[1];let d,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Wn,{}),a=i.jsx(rn,{embeddedBackgroundWorkEnabled:!0}),e[2]=d,e[3]=a):(d=e[2],a=e[3]);const u=r.mode==="draft";let f;e[4]!==r.mode||e[5]!==s||e[6]!==u?(f=i.jsx(vn,{mode:r.mode,autoOpenDraft:u,unavailable:s}),e[4]=r.mode,e[5]=s,e[6]=u,e[7]=f):f=e[7];let l;return e[8]!==n||e[9]!==f?(l=i.jsxs(i.Fragment,{children:[n,d,a,f]}),e[8]=n,e[9]=f,e[10]=l):l=e[10],l};function qn(t){return t.currentSessionId}function Kn(t){return t.currentDirectory}function Jn(t){return t.currentSessionId}const Zn=()=>{dn(),un().then(()=>{Promise.all([fn(),mn()]).catch(t=>{console.error("[mini-chat-main] settings init failed:",t)}),pn(),hn(),yn()}).catch(t=>{console.error("[mini-chat-main] appearance init failed:",t)})};function nr(t){Zn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");At.createRoot(e).render(i.jsx(Rt.StrictMode,{children:i.jsx(on,{children:i.jsx(an,{children:i.jsx(cn,{children:i.jsx(ln,{children:i.jsx(Gn,{apis:t})})})})})}))}export{nr as renderElectronMiniChatApp};
package/dist/index.html CHANGED
@@ -532,7 +532,7 @@
532
532
  pointer-events: none;
533
533
  }
534
534
  </style>
535
- <script type="module" crossorigin src="/assets/main-DZyYGTEK.js"></script>
535
+ <script type="module" crossorigin src="/assets/main-7cePcdQe.js"></script>
536
536
  <link rel="modulepreload" crossorigin href="/assets/index-BW75F1_U.js">
537
537
  <link rel="modulepreload" crossorigin href="/assets/vendor-.bun-DgrCmzWD.js">
538
538
  <link rel="stylesheet" crossorigin href="/assets/index-B_msE9DC.css">
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
6
6
  <title>Vinci Mini Chat</title>
7
- <script type="module" crossorigin src="/assets/miniChat-BYeO3Yg4.js"></script>
7
+ <script type="module" crossorigin src="/assets/miniChat-DEMXzB4E.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/assets/index-BW75F1_U.js">
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-.bun-DgrCmzWD.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-B_msE9DC.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thevinci/web",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",
@@ -746,15 +746,25 @@ export const registerFsRoutes = (app, dependencies) => {
746
746
  const Busboy = (await import('busboy')).default;
747
747
  const busboy = Busboy({ headers: req.headers, limits: { files: 50 } });
748
748
 
749
- const targetDir = req.body?.path || '';
749
+ let targetDir = '';
750
750
  const uploadedFiles = [];
751
751
  const errors = [];
752
+ let responseSent = false;
753
+
754
+ const sendError = (status, error) => {
755
+ if (responseSent) return;
756
+ responseSent = true;
757
+ return res.status(status).json({ error: error || 'Upload failed' });
758
+ };
759
+
760
+ busboy.on('field', (fieldname, value) => {
761
+ if (fieldname === 'path' && typeof value === 'string') {
762
+ targetDir = value;
763
+ }
764
+ });
752
765
 
753
766
  busboy.on('file', (fieldname, file, info) => {
754
767
  const filename = info?.filename || fieldname;
755
- const encoding = info?.encoding || '7bit';
756
- const mimeType = info?.mimeType || 'application/octet-stream';
757
-
758
768
  const resolvedTarget = targetDir ? `${targetDir}/${filename}` : filename;
759
769
 
760
770
  const writePromise = (async () => {
@@ -785,10 +795,15 @@ export const registerFsRoutes = (app, dependencies) => {
785
795
 
786
796
  writePromise
787
797
  .then((result) => uploadedFiles.push(result))
788
- .catch((err) => errors.push({ filename, error: err.message }));
798
+ .catch((err) => {
799
+ console.error(`[upload] Failed to write ${filename}:`, err.message);
800
+ errors.push({ filename, error: err.message });
801
+ });
789
802
  });
790
803
 
791
804
  busboy.on('finish', () => {
805
+ if (responseSent) return;
806
+ responseSent = true;
792
807
  if (errors.length > 0 && uploadedFiles.length === 0) {
793
808
  return res.status(500).json({ error: errors[0].error || 'Upload failed', errors });
794
809
  }
@@ -796,8 +811,12 @@ export const registerFsRoutes = (app, dependencies) => {
796
811
  });
797
812
 
798
813
  busboy.on('error', (err) => {
799
- console.error('Busboy error:', err);
800
- return res.status(500).json({ error: 'Upload failed' });
814
+ console.error('[upload] Busboy error:', err);
815
+ return sendError(500, 'Upload failed');
816
+ });
817
+
818
+ req.on('aborted', () => {
819
+ console.error('[upload] Request aborted');
801
820
  });
802
821
 
803
822
  req.pipe(busboy);