@sunpix/claude-code-web
Version:
A web-based interface for interacting with Claude Code CLI
2 lines (1 loc) • 9.85 kB
JavaScript
import{e,c as a,o as t,n as l,f as s,g as o,h as r,r as n,i,j as c,a as u,k as d,b as m,w as v,d as p,F as f,l as y,t as h,m as x,p as g,v as w,q as b,s as k,x as j,y as C}from"./sqhd64MX.js";import{C as _}from"./BjcZ56it.js";import{c as P}from"./BonREZMq.js";import{_ as N}from"./Cp9jViau.js";import"./2z2a5tpS.js";import"./BCo6x5W8.js";import"./B_x75UOw.js";import"./KAbOdxKQ.js";const S=e({__name:"Skeleton",props:{class:{}},setup(e){const o=e;return(e,r)=>(t(),a("div",{"data-slot":"skeleton",class:l(s(P)("animate-pulse rounded-md bg-primary/10",o.class))},null,2))}}),z={class:"flex flex-col items-center justify-center min-h-[400px] p-8"},B={class:"w-full max-w-2xl space-y-6"},D={class:"space-y-4"},V={class:"flex justify-center"},$={key:0,class:"flex justify-center"},F={key:1,class:"text-center py-8 text-muted-foreground"},M={key:2,class:"max-h-[400px] overflow-y-auto space-y-2 rounded-lg border p-2"},U=["onClick"],q={class:"flex items-center justify-between"},A={class:"flex flex-col space-y-1"},E={class:"font-medium"},L={class:"text-sm text-muted-foreground"},R={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},T={class:"bg-background border rounded-lg p-6 w-full max-w-md mx-4"},H={class:"space-y-4"},K={key:0,class:"text-sm text-destructive"},O={class:"flex justify-end space-x-2 mt-6"},I={key:0,class:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},W={key:1,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},Z={class:"bg-background border rounded-lg p-6 w-full max-w-md mx-4"},G={class:"space-y-4"},J=["placeholder"],Q={key:0,class:"text-sm text-destructive"},X={class:"flex justify-between items-center mt-6"},Y={class:"flex space-x-2"},ee={key:0,class:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},ae=e({__name:"ProjectSelector",setup(e){const k=o(),j=r(),C=n(!1),_=n(new Set),P=n(!1),ae=n(!1),te=n(""),le=n(""),se=n(""),oe=n(!1),re=n(!1),ne=n(null),ie=n(""),ce=n(""),ue=i(()=>j.projects);async function de(){if(te.value.trim()){ae.value=!0,se.value="";try{await $fetch("/api/projects",{method:"POST",body:{projectPath:te.value.trim(),displayName:le.value.trim()||void 0}}),await j.loadProjects(),me()}catch(e){se.value=e.data?.message||e.message||"Failed to create project"}finally{ae.value=!1}}else se.value="Project path is required"}function me(){P.value=!1,te.value="",le.value="",se.value="",ae.value=!1}async function ve(){if(ie.value.trim()){re.value=!0,ce.value="";try{await j.renameProject(ne.value.name,ie.value.trim()),pe()}catch(e){ce.value=e.data?.message||e.message||"Failed to rename project"}finally{re.value=!1}}else ce.value="Display name is required"}function pe(){oe.value=!1,ne.value=null,ie.value="",ce.value="",re.value=!1}async function fe(){ne.value&&confirm(`Are you sure you want to delete the project "${ne.value.displayName||ne.value.name}"? This action cannot be undone.`)&&(await async function(e){if(confirm(`Are you sure you want to delete the project "${e.displayName||e.name}"? This will delete all sessions from Claude Code (it will not delete the working directory itself).`)){_.value.add(e.name);try{await $fetch("/api/projects",{method:"DELETE",query:{projectName:e.name}}),await j.loadProjects()}catch(a){alert(`Failed to delete project: ${a.data?.message||a.message||"Unknown error"}`)}finally{_.value.delete(e.name)}}}(ne.value),pe())}return c(async()=>{0===j.projects.length&&(C.value=!0,await j.loadProjects(),C.value=!1)}),(e,o)=>(t(),a("div",z,[u("div",B,[o[7]||(o[7]=u("div",{class:"text-center space-y-2"},[u("h1",{class:"text-3xl font-bold"},"Welcome to Claude Code Web"),u("p",{class:"text-muted-foreground"},"Select a project to start chatting")],-1)),u("div",D,[u("div",V,[m(s(N),{onClick:o[0]||(o[0]=e=>P.value=!0),class:"bg-primary text-primary-foreground hover:bg-primary/90"},{default:v(()=>o[4]||(o[4]=[u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"mr-2"},[u("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),u("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1),p(" Create New Project ")])),_:1,__:[4]})]),C.value?(t(),a("div",$,[m(s(S),{class:"h-20 w-full"})])):0===ue.value.length?(t(),a("div",F," No projects found. Create your first project above. ")):(t(),a("div",M,[(t(!0),a(f,null,y(ue.value,e=>(t(),a("div",{key:e.name,class:"flex items-center p-4 rounded-md bg-card hover:bg-accent hover:text-accent-foreground transition-colors group"},[u("div",{onClick:a=>async function(e){C.value=!0;try{const a=ue.value.find(a=>a.name===e);a&&j.selectProject(a),await k.push(`/chat/${encodeURIComponent(e)}`)}catch(a){}finally{C.value=!1}}(e.name),class:l(["flex-1 cursor-pointer",{"opacity-50":C.value||_.value.has(e.name)}])},[u("div",q,[u("div",A,[u("span",E,h(e.displayName||e.name),1),u("span",L,h(e.path),1)]),o[5]||(o[5]=u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"opacity-0 group-hover:opacity-100 transition-opacity"},[u("polyline",{points:"9 18 15 12 9 6"})],-1))])],10,U),m(s(N),{onClick:x(a=>function(e){ne.value=e,ie.value=e.displayName||e.name,oe.value=!0,ce.value=""}(e),["stop"]),variant:"ghost",size:"sm",class:"ml-2 text-muted-foreground hover:text-foreground hover:bg-accent",disabled:C.value||_.value.has(e.name)},{default:v(()=>o[6]||(o[6]=[u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[u("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),u("path",{d:"m15 5 4 4"})],-1)])),_:2,__:[6]},1032,["onClick","disabled"])]))),128))]))]),o[8]||(o[8]=u("div",{class:"text-center"},[u("p",{class:"text-sm text-muted-foreground"}," Or continue from the sidebar to resume an existing session ")],-1))]),P.value?(t(),a("div",R,[u("div",T,[o[13]||(o[13]=u("h2",{class:"text-lg font-semibold mb-4"},"Create New Project",-1)),u("div",H,[u("div",null,[o[9]||(o[9]=u("label",{class:"text-sm font-medium"},"Project Directory Path",-1)),g(u("input",{"onUpdate:modelValue":o[1]||(o[1]=e=>te.value=e),type:"text",placeholder:"/path/to/your/project",class:"w-full mt-1 px-3 py-2 border rounded-md bg-background text-foreground",onKeyup:b(de,["enter"])},null,544),[[w,te.value]])]),u("div",null,[o[10]||(o[10]=u("label",{class:"text-sm font-medium"},"Display Name (optional)",-1)),g(u("input",{"onUpdate:modelValue":o[2]||(o[2]=e=>le.value=e),type:"text",placeholder:"My Project",class:"w-full mt-1 px-3 py-2 border rounded-md bg-background text-foreground",onKeyup:b(de,["enter"])},null,544),[[w,le.value]])]),se.value?(t(),a("div",K,h(se.value),1)):d("",!0)]),u("div",O,[m(s(N),{onClick:me,variant:"outline",disabled:ae.value},{default:v(()=>o[11]||(o[11]=[p(" Cancel ")])),_:1,__:[11]},8,["disabled"]),m(s(N),{onClick:de,disabled:ae.value||!te.value.trim()},{default:v(()=>[ae.value?(t(),a("svg",I,o[12]||(o[12]=[u("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),u("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)]))):d("",!0),p(" "+h(ae.value?"Creating...":"Create Project"),1)]),_:1},8,["disabled"])])])])):d("",!0),oe.value?(t(),a("div",W,[u("div",Z,[o[18]||(o[18]=u("h2",{class:"text-lg font-semibold mb-4"},"Edit Project",-1)),u("div",G,[u("div",null,[o[14]||(o[14]=u("label",{class:"text-sm font-medium"},"Display Name",-1)),g(u("input",{"onUpdate:modelValue":o[3]||(o[3]=e=>ie.value=e),type:"text",placeholder:ne.value?.displayName||ne.value?.name,class:"w-full mt-1 px-3 py-2 border rounded-md bg-background text-foreground",onKeyup:b(ve,["enter"])},null,40,J),[[w,ie.value]])]),ce.value?(t(),a("div",Q,h(ce.value),1)):d("",!0)]),u("div",X,[m(s(N),{onClick:fe,variant:"destructive",disabled:re.value||_.value.has(ne.value?.name||"")},{default:v(()=>o[15]||(o[15]=[u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"mr-2"},[u("polyline",{points:"3 6 5 6 21 6"}),u("path",{d:"m19 6-1.5 14a2 2 0 0 1-2 2H8.5a2 2 0 0 1-2-2L5 6"}),u("path",{d:"m10 11 0 6"}),u("path",{d:"m14 11 0 6"}),u("path",{d:"M5 6l1-2a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1l1 2"})],-1),p(" Delete Project ")])),_:1,__:[15]},8,["disabled"]),u("div",Y,[m(s(N),{onClick:pe,variant:"outline",disabled:re.value},{default:v(()=>o[16]||(o[16]=[p(" Cancel ")])),_:1,__:[16]},8,["disabled"]),m(s(N),{onClick:ve,disabled:re.value||!ie.value.trim()},{default:v(()=>[re.value?(t(),a("svg",ee,o[17]||(o[17]=[u("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),u("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)]))):d("",!0),p(" "+h(re.value?"Renaming...":"Rename"),1)]),_:1},8,["disabled"])])])])])):d("",!0)]))}}),te=Object.assign(ae,{__name:"ProjectSelector"}),le={class:"h-full w-full"},se=e({__name:"index",props:{selectedSession:{},onSessionSelected:{type:Function}},setup(e){const l=e,s=k(),o=j(),r=n(),c=n(l.selectedSession),u=i(()=>!!s.params.projectId||!!o.projectName);function d(){}return(e,l)=>(t(),a("div",le,[u.value?(t(),C(_,{key:1,ref_key:"chatViewRef",ref:r,"selected-session":c.value,onSessionLoaded:d},null,8,["selected-session"])):(t(),C(te,{key:0}))]))}});export{se as default};