commandmate 0.11.0 → 0.11.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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +265 -265
- package/.next/app-path-routes-manifest.json +26 -26
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +15 -15
- package/.next/react-loadable-manifest.json +4 -4
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page.js +1 -1
- package/.next/server/app/chat/page.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page.js +1 -1
- package/.next/server/app/login/page.js.nft.json +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page.js +2 -2
- package/.next/server/app/more/page.js.nft.json +1 -1
- package/.next/server/app/more/page_client-reference-manifest.js +1 -1
- package/.next/server/app/offline/page.js +1 -1
- package/.next/server/app/offline/page.js.nft.json +1 -1
- package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page.js +1 -1
- package/.next/server/app/repositories/page.js.nft.json +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page.js +1 -1
- package/.next/server/app/review/page.js.nft.json +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page.js +1 -1
- package/.next/server/app/sessions/page.js.nft.json +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +3 -3
- package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +26 -26
- package/.next/server/chunks/3644.js +13 -0
- package/.next/server/chunks/5959.js +1 -1
- package/.next/server/chunks/646.js +2 -14
- package/.next/server/chunks/9355.js +13 -1
- package/.next/server/chunks/{9992.js → 9968.js} +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/4560-64b1461fd996127a.js +1 -0
- package/.next/static/chunks/{7347-7ee39e14be89e508.js → 6488-d6e53d8da584e644.js} +1 -1
- package/.next/static/chunks/{8566-b8bbcfd837cc338b.js → 8566-9da32e46c9d3fd54.js} +1 -1
- package/.next/static/chunks/8676.c1ef7e2aac5f05a0.js +1 -0
- package/.next/static/chunks/{8965-872d8de254196cec.js → 8965-5ff40db68775eb01.js} +1 -1
- package/.next/static/chunks/app/chat/{page-5d20240f98c07cee.js → page-6f714339e12c3a16.js} +1 -1
- package/.next/static/chunks/app/layout-86574192bd3c0e6b.js +1 -0
- package/.next/static/chunks/app/more/{page-af1d2af13ea901d2.js → page-a496425bba427b48.js} +1 -1
- package/.next/static/chunks/app/{page-3bbe737ec910d1fb.js → page-15bfd76bcf65842d.js} +1 -1
- package/.next/static/chunks/app/repositories/{page-ace9134ac165a6de.js → page-d214522ab8792ce7.js} +1 -1
- package/.next/static/chunks/app/review/{page-331b80f4f58582bc.js → page-1dadf0b5d7129598.js} +1 -1
- package/.next/static/chunks/app/sessions/{page-d694149a7e8649b6.js → page-96f007d986c5f327.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/files/[...path]/{page-9ff4d065483cdfe9.js → page-6a45f3744da50d95.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-3b07e3be354aae57.js +1 -0
- package/.next/static/chunks/{webpack-4fbc38b2e3abb013.js → webpack-25d4697671930f37.js} +1 -1
- package/.next/trace +10 -10
- package/package.json +1 -1
- package/.next/server/chunks/1104.js +0 -13
- package/.next/static/chunks/4560-2bf9cb6504cc4425.js +0 -1
- package/.next/static/chunks/8676.cc638529497c5a1e.js +0 -1
- package/.next/static/chunks/app/layout-fe5857360dfba2b9.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-1c311aaa0950db1e.js +0 -1
- /package/.next/static/{8yp8SRJ9h3Uj75SpHLYpl → WzRCDS2PLtMvg0Sjwlf0S}/_buildManifest.js +0 -0
- /package/.next/static/{8yp8SRJ9h3Uj75SpHLYpl → WzRCDS2PLtMvg0Sjwlf0S}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[838],{1226:()=>{},38038:(e,t,s)=>{Promise.resolve().then(s.bind(s,60675))},53482:(e,t,s)=>{"use strict";s.d(t,{i:()=>c});var a=s(95155),n=s(12115),r=s(60322),i=s(9900);function o(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function l(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function c(e){let{text:t,className:s="",label:c="Copy"}=e,[d,u]=(0,n.useState)(!1),m=(0,n.useRef)(null);(0,n.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let p=(0,n.useCallback)(async()=>{try{await (0,r.l)(t),u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>u(!1),i.s7)}catch(e){}},[t]);return(0,a.jsxs)("button",{type:"button",onClick:p,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted ".concat(s),"aria-label":d?"Copied":c,title:d?"Copied!":c,children:[d?(0,a.jsx)(l,{}):(0,a.jsx)(o,{}),(0,a.jsx)("span",{children:d?"Copied":c})]})}},60322:(e,t,s)=>{"use strict";s.d(t,{l:()=>n});let a=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function n(e){var t;if(!e||0===e.trim().length)return;let s=e.replace(a,"");if(null==(t=navigator.clipboard)?void 0:t.writeText)try{await navigator.clipboard.writeText(s);return}catch(e){}let n=document.createElement("textarea");n.value=s,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")}finally{document.body.removeChild(n)}}},60675:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>I});var a=s(95155),n=s(4560),r=s(12115),i=s(18955),o=s(71360),l=s(744),c=s(36402);let d=(0,r.memo)(function(e){let{onSend:t,disabled:s=!1,placeholder:n}=e,o=(0,i.c)("home"),[c,d]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),[p,h]=(0,r.useState)(!1),x=(0,r.useRef)(null),f=(0,r.useRef)(null),g=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=x.current;e&&(c?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,120),"px")):e.style.height="24px")},[c]);let b=(0,r.useCallback)(async()=>{if(!p&&c.trim()&&!u&&!s)try{m(!0),await t(c.trim()),d("")}catch(e){}finally{m(!1)}},[p,c,u,s,t]),v=(0,r.useCallback)(async e=>{e.preventDefault(),await b()},[b]),y=(0,r.useCallback)(()=>{h(!0),g.current=!1,f.current&&clearTimeout(f.current)},[]),w=(0,r.useCallback)(()=>{h(!1),g.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{g.current=!1},300)},[]),j=(0,r.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if(g.current&&"Enter"===e.key){g.current=!1;return}"Enter"!==e.key||p||e.shiftKey||(e.preventDefault(),b())}},[p,b]);return(0,a.jsxs)("form",{onSubmit:v,className:"flex shrink-0 items-center gap-2 rounded-lg border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 focus-within:border-accent-500 focus-within:ring-1 focus-within:ring-accent-500","data-testid":"assistant-message-input",children:[(0,a.jsx)("textarea",{ref:x,value:c,onChange:e=>d(e.target.value),onKeyDown:j,onCompositionStart:y,onCompositionEnd:w,placeholder:null!=n?n:o("assistant.input.defaultPlaceholder"),disabled:u||s,rows:1,className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin text-sm",style:{minHeight:"24px",maxHeight:"120px",paddingTop:"4px",paddingBottom:"4px",lineHeight:"18px"},"data-testid":"assistant-message-textarea"}),(0,a.jsx)(l.$n,{type:"submit",variant:"ghost",disabled:!c.trim()||u||s,className:"flex-shrink-0 rounded-full p-1.5 text-accent-600 hover:bg-accent-50 dark:text-accent-400 dark:hover:bg-accent-900/30 disabled:text-muted-foreground disabled:hover:bg-transparent","aria-label":o("assistant.input.send"),"data-testid":"assistant-send-button",children:u?(0,a.jsx)(l.y$,{size:"sm"}):(0,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})});var u=s(28857),m=s(22133),p=s(10934),h=s(5225);s(1226);var x=s(53482),f=s(3005);function g(e){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function b(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function v(e){let{message:t}=e;return(0,a.jsx)("div",{className:"text-center text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground",children:(0,a.jsx)("span",{className:"rounded-full border border-border bg-surface-2 px-3 py-1",children:t.content})})}function y(e){let{message:t,canEdit:s,onEdit:n}=e,o=(0,i.c)("home"),[l,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)(t.content),[m,p]=(0,r.useState)(!1),[h,f]=(0,r.useState)(null),v=t.deliveryStatus?"pending"===t.deliveryStatus?o("assistant.message.sending"):"failed"===t.deliveryStatus?o("assistant.message.failed"):o("assistant.message.sent"):null,y=(0,r.useCallback)(()=>{u(t.content),f(null),c(!0)},[t.content]),w=(0,r.useCallback)(()=>{c(!1),f(null)},[]),j=(0,r.useCallback)(async()=>{if(!n||m)return;let e=d.trim();if(!e||e===t.content.trim())return void c(!1);p(!0),f(null);try{await n(t,e),c(!1)}catch(e){f(e instanceof Error?e.message:o("assistant.errors.resubmitMessage"))}finally{p(!1)}},[d,t,n,m,o]);return(0,a.jsxs)("div",{className:"group ml-auto max-w-[88%] rounded-2xl border border-accent-500/40 bg-accent-500/10 px-4 py-3 text-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:[(0,a.jsx)("span",{children:o("assistant.message.you")}),(0,a.jsx)("span",{children:g(t.timestamp)})]}),l?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("textarea",{className:"w-full resize-y rounded border border-input bg-surface p-2 text-sm text-foreground focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring",value:d,onChange:e=>u(e.target.value),rows:Math.max(3,Math.min(12,d.split("\n").length+1)),disabled:m,"data-testid":"assistant-edit-textarea"}),h&&(0,a.jsx)("p",{className:"text-[11px] text-danger-foreground",children:h}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:w,disabled:m,className:"rounded border border-border bg-surface px-3 py-1 text-[11px] text-foreground transition-colors hover:bg-muted disabled:opacity-50",children:o("assistant.message.cancel")}),(0,a.jsx)("button",{type:"button",onClick:j,disabled:m||!d.trim(),className:"rounded bg-accent-600 px-3 py-1 text-[11px] font-medium text-white transition-colors hover:bg-accent-700 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-edit-save",children:m?o("assistant.message.resending"):o("assistant.message.saveAndResend")})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm leading-6",children:t.content}),(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,a.jsx)("span",{className:"text-[11px] font-medium ".concat("failed"===t.deliveryStatus?"text-danger-foreground":"text-muted-foreground"),children:null!=v?v:""}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 opacity-60 transition-opacity group-hover:opacity-100",children:[(0,a.jsx)(x.i,{text:t.content}),s&&n&&(0,a.jsxs)("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted","aria-label":o("assistant.message.editMessage"),"data-testid":"assistant-edit-button",title:o("assistant.message.editAndResend"),children:[(0,a.jsx)(b,{}),(0,a.jsx)("span",{children:o("assistant.message.edit")})]})]})]})]})]})}function w(e){let{message:t,assistantLabel:s}=e;return(0,a.jsxs)("div",{className:"group mr-auto max-w-[88%] rounded-2xl border border-border bg-surface px-4 py-3 text-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:[(0,a.jsx)("span",{children:s}),(0,a.jsx)("span",{children:g(t.timestamp)})]}),(0,a.jsx)("div",{className:"assistant-md text-sm leading-6",children:(0,a.jsx)(u.oz,{remarkPlugins:[m.A],rehypePlugins:[p.A,h.A],children:t.content})}),(0,a.jsx)("div",{className:"mt-2 flex justify-end opacity-60 transition-opacity group-hover:opacity-100",children:(0,a.jsx)(x.i,{text:t.content})})]})}function j(e){let{messages:t,assistantLabel:s,sessionActive:n,waitingForResponse:o=!1,canEdit:l=!1,onEditMessage:c}=e,d=(0,i.c)("home"),u=(0,r.useRef)(null),m=(0,r.useRef)(!0),p=(0,r.useMemo)(()=>{var e;let s=t[t.length-1];return s?"".concat(t.length,":").concat(s.id,":").concat(null!=(e=s.deliveryStatus)?e:"",":").concat(s.content.length,":").concat(o?"waiting":"idle"):"empty:".concat(o?"waiting":"idle")},[t,o]);(0,r.useEffect)(()=>{u.current&&m.current&&(u.current.scrollTop=u.current.scrollHeight)},[p]);let h=(0,r.useMemo)(()=>{let e=t[t.length-1];return n&&e&&"user"===e.role&&"failed"!==e.deliveryStatus?d("assistant.working"):d("assistant.emptyState")},[t,n,d]);return(0,a.jsx)("div",{ref:u,className:"h-full min-h-0 overflow-y-scroll rounded-xl border border-border bg-surface-2 p-3",style:{scrollbarGutter:"stable"},onScroll:e=>{let t=e.currentTarget;m.current=t.scrollHeight-t.scrollTop-t.clientHeight<48},"data-testid":"assistant-message-list",children:0!==t.length||o?(0,a.jsxs)("div",{className:"space-y-3",children:[t.map(e=>"system"===e.role&&"session_boundary"===e.messageType?(0,a.jsx)(v,{message:e},e.id):"user"===e.role?(0,a.jsx)(y,{message:e,canEdit:l,onEdit:c},e.id):(0,a.jsx)(w,{message:e,assistantLabel:s},e.id)),o&&(0,a.jsxs)("div",{className:"mr-auto flex max-w-[88%] items-center gap-3 rounded-2xl border border-border bg-surface px-4 py-3 shadow-sm","data-testid":"assistant-waiting-indicator","aria-live":"polite",children:[(0,a.jsx)(f.y,{size:"sm",variant:"accent"}),(0,a.jsx)("span",{className:"text-sm text-foreground",children:d("assistant.thinking",{label:s})})]})]}):(0,a.jsx)("div",{className:"flex h-full min-h-[160px] items-center justify-center text-sm text-muted-foreground",children:h})})}function k(e){return e?{...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),lastStartedAt:e.lastStartedAt?new Date(e.lastStartedAt):void 0,lastStoppedAt:e.lastStoppedAt?new Date(e.lastStoppedAt):void 0,contextSentAt:e.contextSentAt?new Date(e.contextSentAt):void 0}:null}function N(e){return{...e,timestamp:new Date(e.timestamp)}}let C={async getConversation(e,t){let s=await fetch("/api/assistant/conversation?repositoryId=".concat(encodeURIComponent(e),"&cliToolId=").concat(encodeURIComponent(t)));if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to get conversation (".concat(s.status,")"));return k((await s.json()).conversation)},async getMessages(e){let t=await fetch("/api/assistant/messages?conversationId=".concat(encodeURIComponent(e)));if(!t.ok)throw Error((await t.json().catch(()=>({}))).error||"Failed to get messages (".concat(t.status,")"));return(await t.json()).messages.map(N)},async clearMessages(e,t){var s;let a=new URLSearchParams({conversationId:e});(null==t?void 0:t.fromMessageId)&&a.set("fromMessageId",t.fromMessageId);let n=await fetch("/api/assistant/messages?".concat(a.toString()),{method:"DELETE"});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"Failed to clear messages (".concat(n.status,")"));return{archivedCount:null!=(s=(await n.json()).archivedCount)?s:0}},async startSession(e,t){let s=await fetch("/api/assistant/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e,repositoryId:t})});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to start session (".concat(s.status,")"));let a=await s.json();return{...a,conversation:k(a.conversation)}},async sendCommand(e,t,s){let a=await fetch("/api/assistant/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e,conversationId:t,command:s})});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||"Failed to send command (".concat(a.status,")"))},async getCurrentOutput(e,t){let s=await fetch("/api/assistant/current-output?cliToolId=".concat(encodeURIComponent(e),"&conversationId=").concat(encodeURIComponent(t)));if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to get output (".concat(s.status,")"));return s.json()},async stopSession(e,t){let s=await fetch("/api/assistant/session?cliToolId=".concat(encodeURIComponent(e),"&conversationId=").concat(encodeURIComponent(t)),{method:"DELETE"});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to stop session (".concat(s.status,")"));return s.json()},async getInstalledTools(){var e;let t=await fetch("/api/assistant/tools");return t.ok&&null!=(e=(await t.json()).tools)?e:[]}},S="commandmate-assistant-cli-tool",E=["claude","codex","antigravity"];function M(e){return E.includes(e)}function A(){var e;let t=(0,i.c)("home"),s=(0,c.SC)(),[n,u]=(0,r.useState)([]),[m,p]=(0,r.useState)([]),[h,x]=(0,r.useState)(""),[f,g]=(0,r.useState)("claude"),[b,v]=(0,r.useState)(null),[y,w]=(0,r.useState)([]),[k,N]=(0,r.useState)(null),[E,A]=(0,r.useState)(!1),[I,T]=(0,r.useState)(!1),[R,L]=(0,r.useState)(!1),[H,D]=(0,r.useState)(!1),[P,_]=(0,r.useState)(null),z="".concat(h,":").concat(f),F=!H||""!==h&&P!==z,U=(0,r.useRef)(null),O=(null==b?void 0:b.status)==="ready"||(null==b?void 0:b.status)==="running",B=(null==b?void 0:b.status)==="running",W=(null==b?void 0:b.status)==="ready",$=n.find(e=>e.id===h),V=(0,r.useMemo)(()=>m.filter(e=>M(e.id)),[m]),G=V.find(e=>e.id===f),J=null!=(e=null==G?void 0:G.name)?e:f,K=(0,r.useCallback)(async e=>{w(await C.getMessages(e))},[]),Z=(0,r.useCallback)(async()=>{if(!h){v(null),w([]);return}let e=await C.getConversation(h,f);v(e),e?await K(e.id):w([])},[K,h,f]);(0,r.useEffect)(()=>{{let e=localStorage.getItem(S);e&&M(e)&&g(e)}},[]),(0,r.useEffect)(()=>{async function e(){let e=await C.getInstalledTools();p(e);let t=e.filter(e=>M(e.id)),s=t.find(e=>e.installed);s&&g(e=>{let a=t.find(t=>t.id===e);return(null==a?void 0:a.installed)?e:s.id})}(async function(){try{var e;let t=await fetch("/api/worktrees");if(!t.ok)return;let s=(null!=(e=(await t.json()).repositories)?e:[]).map(e=>({id:e.id,path:e.path,name:e.name,displayName:e.displayName}));u(s),s.length>0&&x(e=>e||s[0].id)}catch(e){}finally{D(!0)}})(),e()},[]),(0,r.useEffect)(()=>{if(!h)return;let e=!1;return(async()=>{try{let t=await C.getConversation(h,f);if(e)return;if(v(t),t){let s=await C.getMessages(t.id);e||w(s)}else w([])}catch(s){e||N(s instanceof Error?s.message:t("assistant.errors.loadConversation"))}finally{e||_("".concat(h,":").concat(f))}})(),()=>{e=!0}},[h,f,t]),(0,r.useEffect)(()=>{if(U.current&&(clearInterval(U.current),U.current=null),!b)return;let e=async()=>{try{await Z()}catch(e){}};return e(),U.current=setInterval(e,2e3),()=>{U.current&&(clearInterval(U.current),U.current=null)}},[null==b?void 0:b.id,Z,b]);let q=(0,r.useCallback)(e=>{M(e)&&(g(e),localStorage.setItem(S,e))},[]),Q=(0,r.useCallback)(async()=>{if(h&&!E){A(!0),N(null);try{let e=await C.startSession(f,h);v(e.conversation),await K(e.conversation.id)}catch(e){N(e instanceof Error?e.message:t("assistant.errors.startSession"))}finally{A(!1)}}},[K,h,f,E,t]),X=(0,r.useCallback)(async()=>{if(b&&!I){T(!0),N(null);try{await C.stopSession(f,b.id),await Z()}catch(e){N(e instanceof Error?e.message:t("assistant.errors.stopSession"))}finally{T(!1)}}},[b,Z,f,I,t]),Y=(0,r.useCallback)(async()=>{if(b&&!R&&!B&&await s({description:t("assistant.clearHistoryConfirm"),variant:"danger"})){L(!0),N(null);try{await C.clearMessages(b.id),await Z()}catch(e){N(e instanceof Error?e.message:t("assistant.errors.clearHistory"))}finally{L(!1)}}},[R,b,B,Z,s,t]),ee=(0,r.useCallback)(async e=>{if(b&&W){N(null);try{await C.sendCommand(f,b.id,e),v(e=>e?{...e,status:"running"}:e),await Promise.all([K(b.id),Z()])}catch(e){throw N(e instanceof Error?e.message:t("assistant.errors.sendMessage")),e}}},[W,b,Z,K,f,t]),et=(0,r.useCallback)(async(e,s)=>{if(!b||!W)throw Error(t("assistant.errors.notReadyToResend"));N(null),await C.clearMessages(b.id,{fromMessageId:e.id}),await C.sendCommand(f,b.id,s),v(e=>e?{...e,status:"running"}:e),await Promise.all([K(b.id),Z()])},[W,b,Z,K,f,t]),es=(0,r.useCallback)(async e=>{if(O){if(!await s({description:t("assistant.changeRepoConfirm")}))return;try{await C.stopSession(f,b.id)}catch(e){N(e instanceof Error?e.message:t("assistant.errors.stopSession"));return}}x(e),N(null)},[b,O,f,s,t]);return(0,a.jsx)(l.Zp,{variant:"elevated",padding:"none",className:"overflow-hidden rounded-xl shadow-lg","data-testid":"assistant-chat-panel",children:(0,a.jsxs)("div",{className:"flex h-[78vh] min-h-[34rem] max-h-[48rem] flex-col gap-4 overflow-hidden bg-gradient-to-br from-transparent to-accent-500/5 p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_auto]",children:[(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t("assistant.repositoryLabel")}),(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t("assistant.cliLabel")}),(0,a.jsx)("span",{className:"hidden md:block"})]}),(0,a.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_auto] md:items-center",children:[(0,a.jsxs)("select",{value:h,onChange:e=>void es(e.target.value),disabled:0===n.length,className:"w-full rounded-lg border border-input bg-surface px-3 py-2 text-sm text-foreground shadow-sm transition-colors focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-repo-select",children:[0===n.length&&(0,a.jsx)("option",{value:"",children:t("assistant.noRepositories")}),n.map(e=>(0,a.jsx)("option",{value:e.id,children:e.displayName||e.name},e.id))]}),(0,a.jsx)("select",{value:f,onChange:e=>q(e.target.value),disabled:O,className:"w-full rounded-lg border border-input bg-surface px-3 py-2 text-sm text-foreground shadow-sm transition-colors focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-tool-select",children:V.map(e=>(0,a.jsx)("option",{value:e.id,disabled:!e.installed,children:e.installed?e.name:t("assistant.toolNotInstalled",{name:e.name})},e.id))}),(0,a.jsx)("div",{children:O?(0,a.jsx)(l.$n,{variant:"danger",onClick:X,disabled:I,className:"w-full md:w-auto","data-testid":"assistant-stop-button",children:I?t("assistant.stopping"):t("assistant.stop")}):(0,a.jsx)(l.$n,{variant:"primary",onClick:Q,disabled:!h||E,className:"w-full md:w-auto","data-testid":"assistant-start-button",children:E?t("assistant.starting"):t("assistant.start")})})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:$?t("assistant.startDirectory",{repository:$.displayName||$.name,path:$.path}):t("assistant.startDirectoryHint")})]}),k&&(0,a.jsx)("div",{className:"rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger-foreground",children:k}),(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground",children:t("assistant.history")}),(0,a.jsxs)(l.$n,{type:"button",variant:"ghost",size:"sm",onClick:Y,disabled:!b||R||B||0===y.length,className:"gap-1","data-testid":"assistant-clear-button",children:[(0,a.jsx)(o.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),R?t("assistant.clearing"):t("assistant.clearHistory")]})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:F&&0===y.length?(0,a.jsx)("div",{className:"h-full min-h-0 overflow-hidden rounded-xl border border-border bg-surface-2 p-3","data-testid":"assistant-chat-loading",role:"status","aria-label":t("assistant.loadingConversation"),children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(l.EA,{className:"ml-auto h-10 w-3/5 rounded-2xl"}),(0,a.jsx)(l.EA,{className:"mr-auto h-16 w-4/5 rounded-2xl"}),(0,a.jsx)(l.EA,{className:"ml-auto h-10 w-2/5 rounded-2xl"})]})}):(0,a.jsx)(j,{messages:y,assistantLabel:J,sessionActive:O,waitingForResponse:B,canEdit:W,onEditMessage:et})}),(0,a.jsx)("div",{className:"shrink-0",children:(0,a.jsx)(d,{onSend:ee,disabled:!W,placeholder:W?t("assistant.inputPlaceholder"):O?t("assistant.inputPlaceholderWaiting"):t("assistant.inputPlaceholderNoSession")})})]})]})})}function I(){return(0,a.jsx)(n.GV,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Assistant Chat"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Converse with a local CLI assistant (Claude or Codex) scoped to a selected repository."})]}),(0,a.jsx)(A,{})]})})}},71360:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(71847).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])}},e=>{e.O(0,[6481,6809,4909,2770,3165,4974,8566,2069,934,6402,744,7347,4560,8441,1255,7358],()=>e(e.s=38038)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[838],{1226:()=>{},38038:(e,t,s)=>{Promise.resolve().then(s.bind(s,60675))},53482:(e,t,s)=>{"use strict";s.d(t,{i:()=>c});var a=s(95155),n=s(12115),r=s(60322),i=s(9900);function o(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function l(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function c(e){let{text:t,className:s="",label:c="Copy"}=e,[d,u]=(0,n.useState)(!1),m=(0,n.useRef)(null);(0,n.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let p=(0,n.useCallback)(async()=>{try{await (0,r.l)(t),u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>u(!1),i.s7)}catch(e){}},[t]);return(0,a.jsxs)("button",{type:"button",onClick:p,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted ".concat(s),"aria-label":d?"Copied":c,title:d?"Copied!":c,children:[d?(0,a.jsx)(l,{}):(0,a.jsx)(o,{}),(0,a.jsx)("span",{children:d?"Copied":c})]})}},60322:(e,t,s)=>{"use strict";s.d(t,{l:()=>n});let a=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;async function n(e){var t;if(!e||0===e.trim().length)return;let s=e.replace(a,"");if(null==(t=navigator.clipboard)?void 0:t.writeText)try{await navigator.clipboard.writeText(s);return}catch(e){}let n=document.createElement("textarea");n.value=s,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")}finally{document.body.removeChild(n)}}},60675:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>I});var a=s(95155),n=s(4560),r=s(12115),i=s(18955),o=s(71360),l=s(744),c=s(36402);let d=(0,r.memo)(function(e){let{onSend:t,disabled:s=!1,placeholder:n}=e,o=(0,i.c)("home"),[c,d]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),[p,h]=(0,r.useState)(!1),x=(0,r.useRef)(null),f=(0,r.useRef)(null),g=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=x.current;e&&(c?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,120),"px")):e.style.height="24px")},[c]);let b=(0,r.useCallback)(async()=>{if(!p&&c.trim()&&!u&&!s)try{m(!0),await t(c.trim()),d("")}catch(e){}finally{m(!1)}},[p,c,u,s,t]),v=(0,r.useCallback)(async e=>{e.preventDefault(),await b()},[b]),y=(0,r.useCallback)(()=>{h(!0),g.current=!1,f.current&&clearTimeout(f.current)},[]),w=(0,r.useCallback)(()=>{h(!1),g.current=!0,f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{g.current=!1},300)},[]),j=(0,r.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if(g.current&&"Enter"===e.key){g.current=!1;return}"Enter"!==e.key||p||e.shiftKey||(e.preventDefault(),b())}},[p,b]);return(0,a.jsxs)("form",{onSubmit:v,className:"flex shrink-0 items-center gap-2 rounded-lg border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 focus-within:border-accent-500 focus-within:ring-1 focus-within:ring-accent-500","data-testid":"assistant-message-input",children:[(0,a.jsx)("textarea",{ref:x,value:c,onChange:e=>d(e.target.value),onKeyDown:j,onCompositionStart:y,onCompositionEnd:w,placeholder:null!=n?n:o("assistant.input.defaultPlaceholder"),disabled:u||s,rows:1,className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin text-sm",style:{minHeight:"24px",maxHeight:"120px",paddingTop:"4px",paddingBottom:"4px",lineHeight:"18px"},"data-testid":"assistant-message-textarea"}),(0,a.jsx)(l.$n,{type:"submit",variant:"ghost",disabled:!c.trim()||u||s,className:"flex-shrink-0 rounded-full p-1.5 text-accent-600 hover:bg-accent-50 dark:text-accent-400 dark:hover:bg-accent-900/30 disabled:text-muted-foreground disabled:hover:bg-transparent","aria-label":o("assistant.input.send"),"data-testid":"assistant-send-button",children:u?(0,a.jsx)(l.y$,{size:"sm"}):(0,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})});var u=s(51238),m=s(22133),p=s(10934),h=s(5225);s(1226);var x=s(53482),f=s(3005);function g(e){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function b(){return(0,a.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function v(e){let{message:t}=e;return(0,a.jsx)("div",{className:"text-center text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground",children:(0,a.jsx)("span",{className:"rounded-full border border-border bg-surface-2 px-3 py-1",children:t.content})})}function y(e){let{message:t,canEdit:s,onEdit:n}=e,o=(0,i.c)("home"),[l,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)(t.content),[m,p]=(0,r.useState)(!1),[h,f]=(0,r.useState)(null),v=t.deliveryStatus?"pending"===t.deliveryStatus?o("assistant.message.sending"):"failed"===t.deliveryStatus?o("assistant.message.failed"):o("assistant.message.sent"):null,y=(0,r.useCallback)(()=>{u(t.content),f(null),c(!0)},[t.content]),w=(0,r.useCallback)(()=>{c(!1),f(null)},[]),j=(0,r.useCallback)(async()=>{if(!n||m)return;let e=d.trim();if(!e||e===t.content.trim())return void c(!1);p(!0),f(null);try{await n(t,e),c(!1)}catch(e){f(e instanceof Error?e.message:o("assistant.errors.resubmitMessage"))}finally{p(!1)}},[d,t,n,m,o]);return(0,a.jsxs)("div",{className:"group ml-auto max-w-[88%] rounded-2xl border border-accent-500/40 bg-accent-500/10 px-4 py-3 text-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:[(0,a.jsx)("span",{children:o("assistant.message.you")}),(0,a.jsx)("span",{children:g(t.timestamp)})]}),l?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("textarea",{className:"w-full resize-y rounded border border-input bg-surface p-2 text-sm text-foreground focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring",value:d,onChange:e=>u(e.target.value),rows:Math.max(3,Math.min(12,d.split("\n").length+1)),disabled:m,"data-testid":"assistant-edit-textarea"}),h&&(0,a.jsx)("p",{className:"text-[11px] text-danger-foreground",children:h}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:w,disabled:m,className:"rounded border border-border bg-surface px-3 py-1 text-[11px] text-foreground transition-colors hover:bg-muted disabled:opacity-50",children:o("assistant.message.cancel")}),(0,a.jsx)("button",{type:"button",onClick:j,disabled:m||!d.trim(),className:"rounded bg-accent-600 px-3 py-1 text-[11px] font-medium text-white transition-colors hover:bg-accent-700 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-edit-save",children:m?o("assistant.message.resending"):o("assistant.message.saveAndResend")})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm leading-6",children:t.content}),(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,a.jsx)("span",{className:"text-[11px] font-medium ".concat("failed"===t.deliveryStatus?"text-danger-foreground":"text-muted-foreground"),children:null!=v?v:""}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 opacity-60 transition-opacity group-hover:opacity-100",children:[(0,a.jsx)(x.i,{text:t.content}),s&&n&&(0,a.jsxs)("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground transition-colors hover:bg-muted","aria-label":o("assistant.message.editMessage"),"data-testid":"assistant-edit-button",title:o("assistant.message.editAndResend"),children:[(0,a.jsx)(b,{}),(0,a.jsx)("span",{children:o("assistant.message.edit")})]})]})]})]})]})}function w(e){let{message:t,assistantLabel:s}=e;return(0,a.jsxs)("div",{className:"group mr-auto max-w-[88%] rounded-2xl border border-border bg-surface px-4 py-3 text-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:[(0,a.jsx)("span",{children:s}),(0,a.jsx)("span",{children:g(t.timestamp)})]}),(0,a.jsx)("div",{className:"assistant-md text-sm leading-6",children:(0,a.jsx)(u.oz,{remarkPlugins:[m.A],rehypePlugins:[p.A,h.A],children:t.content})}),(0,a.jsx)("div",{className:"mt-2 flex justify-end opacity-60 transition-opacity group-hover:opacity-100",children:(0,a.jsx)(x.i,{text:t.content})})]})}function j(e){let{messages:t,assistantLabel:s,sessionActive:n,waitingForResponse:o=!1,canEdit:l=!1,onEditMessage:c}=e,d=(0,i.c)("home"),u=(0,r.useRef)(null),m=(0,r.useRef)(!0),p=(0,r.useMemo)(()=>{var e;let s=t[t.length-1];return s?"".concat(t.length,":").concat(s.id,":").concat(null!=(e=s.deliveryStatus)?e:"",":").concat(s.content.length,":").concat(o?"waiting":"idle"):"empty:".concat(o?"waiting":"idle")},[t,o]);(0,r.useEffect)(()=>{u.current&&m.current&&(u.current.scrollTop=u.current.scrollHeight)},[p]);let h=(0,r.useMemo)(()=>{let e=t[t.length-1];return n&&e&&"user"===e.role&&"failed"!==e.deliveryStatus?d("assistant.working"):d("assistant.emptyState")},[t,n,d]);return(0,a.jsx)("div",{ref:u,className:"h-full min-h-0 overflow-y-scroll rounded-xl border border-border bg-surface-2 p-3",style:{scrollbarGutter:"stable"},onScroll:e=>{let t=e.currentTarget;m.current=t.scrollHeight-t.scrollTop-t.clientHeight<48},"data-testid":"assistant-message-list",children:0!==t.length||o?(0,a.jsxs)("div",{className:"space-y-3",children:[t.map(e=>"system"===e.role&&"session_boundary"===e.messageType?(0,a.jsx)(v,{message:e},e.id):"user"===e.role?(0,a.jsx)(y,{message:e,canEdit:l,onEdit:c},e.id):(0,a.jsx)(w,{message:e,assistantLabel:s},e.id)),o&&(0,a.jsxs)("div",{className:"mr-auto flex max-w-[88%] items-center gap-3 rounded-2xl border border-border bg-surface px-4 py-3 shadow-sm","data-testid":"assistant-waiting-indicator","aria-live":"polite",children:[(0,a.jsx)(f.y,{size:"sm",variant:"accent"}),(0,a.jsx)("span",{className:"text-sm text-foreground",children:d("assistant.thinking",{label:s})})]})]}):(0,a.jsx)("div",{className:"flex h-full min-h-[160px] items-center justify-center text-sm text-muted-foreground",children:h})})}function k(e){return e?{...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),lastStartedAt:e.lastStartedAt?new Date(e.lastStartedAt):void 0,lastStoppedAt:e.lastStoppedAt?new Date(e.lastStoppedAt):void 0,contextSentAt:e.contextSentAt?new Date(e.contextSentAt):void 0}:null}function N(e){return{...e,timestamp:new Date(e.timestamp)}}let C={async getConversation(e,t){let s=await fetch("/api/assistant/conversation?repositoryId=".concat(encodeURIComponent(e),"&cliToolId=").concat(encodeURIComponent(t)));if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to get conversation (".concat(s.status,")"));return k((await s.json()).conversation)},async getMessages(e){let t=await fetch("/api/assistant/messages?conversationId=".concat(encodeURIComponent(e)));if(!t.ok)throw Error((await t.json().catch(()=>({}))).error||"Failed to get messages (".concat(t.status,")"));return(await t.json()).messages.map(N)},async clearMessages(e,t){var s;let a=new URLSearchParams({conversationId:e});(null==t?void 0:t.fromMessageId)&&a.set("fromMessageId",t.fromMessageId);let n=await fetch("/api/assistant/messages?".concat(a.toString()),{method:"DELETE"});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"Failed to clear messages (".concat(n.status,")"));return{archivedCount:null!=(s=(await n.json()).archivedCount)?s:0}},async startSession(e,t){let s=await fetch("/api/assistant/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e,repositoryId:t})});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to start session (".concat(s.status,")"));let a=await s.json();return{...a,conversation:k(a.conversation)}},async sendCommand(e,t,s){let a=await fetch("/api/assistant/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e,conversationId:t,command:s})});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||"Failed to send command (".concat(a.status,")"))},async getCurrentOutput(e,t){let s=await fetch("/api/assistant/current-output?cliToolId=".concat(encodeURIComponent(e),"&conversationId=").concat(encodeURIComponent(t)));if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to get output (".concat(s.status,")"));return s.json()},async stopSession(e,t){let s=await fetch("/api/assistant/session?cliToolId=".concat(encodeURIComponent(e),"&conversationId=").concat(encodeURIComponent(t)),{method:"DELETE"});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to stop session (".concat(s.status,")"));return s.json()},async getInstalledTools(){var e;let t=await fetch("/api/assistant/tools");return t.ok&&null!=(e=(await t.json()).tools)?e:[]}},S="commandmate-assistant-cli-tool",E=["claude","codex","antigravity"];function M(e){return E.includes(e)}function A(){var e;let t=(0,i.c)("home"),s=(0,c.SC)(),[n,u]=(0,r.useState)([]),[m,p]=(0,r.useState)([]),[h,x]=(0,r.useState)(""),[f,g]=(0,r.useState)("claude"),[b,v]=(0,r.useState)(null),[y,w]=(0,r.useState)([]),[k,N]=(0,r.useState)(null),[E,A]=(0,r.useState)(!1),[I,T]=(0,r.useState)(!1),[R,L]=(0,r.useState)(!1),[H,D]=(0,r.useState)(!1),[P,_]=(0,r.useState)(null),z="".concat(h,":").concat(f),F=!H||""!==h&&P!==z,U=(0,r.useRef)(null),O=(null==b?void 0:b.status)==="ready"||(null==b?void 0:b.status)==="running",B=(null==b?void 0:b.status)==="running",W=(null==b?void 0:b.status)==="ready",$=n.find(e=>e.id===h),V=(0,r.useMemo)(()=>m.filter(e=>M(e.id)),[m]),G=V.find(e=>e.id===f),J=null!=(e=null==G?void 0:G.name)?e:f,K=(0,r.useCallback)(async e=>{w(await C.getMessages(e))},[]),Z=(0,r.useCallback)(async()=>{if(!h){v(null),w([]);return}let e=await C.getConversation(h,f);v(e),e?await K(e.id):w([])},[K,h,f]);(0,r.useEffect)(()=>{{let e=localStorage.getItem(S);e&&M(e)&&g(e)}},[]),(0,r.useEffect)(()=>{async function e(){let e=await C.getInstalledTools();p(e);let t=e.filter(e=>M(e.id)),s=t.find(e=>e.installed);s&&g(e=>{let a=t.find(t=>t.id===e);return(null==a?void 0:a.installed)?e:s.id})}(async function(){try{var e;let t=await fetch("/api/worktrees");if(!t.ok)return;let s=(null!=(e=(await t.json()).repositories)?e:[]).map(e=>({id:e.id,path:e.path,name:e.name,displayName:e.displayName}));u(s),s.length>0&&x(e=>e||s[0].id)}catch(e){}finally{D(!0)}})(),e()},[]),(0,r.useEffect)(()=>{if(!h)return;let e=!1;return(async()=>{try{let t=await C.getConversation(h,f);if(e)return;if(v(t),t){let s=await C.getMessages(t.id);e||w(s)}else w([])}catch(s){e||N(s instanceof Error?s.message:t("assistant.errors.loadConversation"))}finally{e||_("".concat(h,":").concat(f))}})(),()=>{e=!0}},[h,f,t]),(0,r.useEffect)(()=>{if(U.current&&(clearInterval(U.current),U.current=null),!b)return;let e=async()=>{try{await Z()}catch(e){}};return e(),U.current=setInterval(e,2e3),()=>{U.current&&(clearInterval(U.current),U.current=null)}},[null==b?void 0:b.id,Z,b]);let q=(0,r.useCallback)(e=>{M(e)&&(g(e),localStorage.setItem(S,e))},[]),Q=(0,r.useCallback)(async()=>{if(h&&!E){A(!0),N(null);try{let e=await C.startSession(f,h);v(e.conversation),await K(e.conversation.id)}catch(e){N(e instanceof Error?e.message:t("assistant.errors.startSession"))}finally{A(!1)}}},[K,h,f,E,t]),X=(0,r.useCallback)(async()=>{if(b&&!I){T(!0),N(null);try{await C.stopSession(f,b.id),await Z()}catch(e){N(e instanceof Error?e.message:t("assistant.errors.stopSession"))}finally{T(!1)}}},[b,Z,f,I,t]),Y=(0,r.useCallback)(async()=>{if(b&&!R&&!B&&await s({description:t("assistant.clearHistoryConfirm"),variant:"danger"})){L(!0),N(null);try{await C.clearMessages(b.id),await Z()}catch(e){N(e instanceof Error?e.message:t("assistant.errors.clearHistory"))}finally{L(!1)}}},[R,b,B,Z,s,t]),ee=(0,r.useCallback)(async e=>{if(b&&W){N(null);try{await C.sendCommand(f,b.id,e),v(e=>e?{...e,status:"running"}:e),await Promise.all([K(b.id),Z()])}catch(e){throw N(e instanceof Error?e.message:t("assistant.errors.sendMessage")),e}}},[W,b,Z,K,f,t]),et=(0,r.useCallback)(async(e,s)=>{if(!b||!W)throw Error(t("assistant.errors.notReadyToResend"));N(null),await C.clearMessages(b.id,{fromMessageId:e.id}),await C.sendCommand(f,b.id,s),v(e=>e?{...e,status:"running"}:e),await Promise.all([K(b.id),Z()])},[W,b,Z,K,f,t]),es=(0,r.useCallback)(async e=>{if(O){if(!await s({description:t("assistant.changeRepoConfirm")}))return;try{await C.stopSession(f,b.id)}catch(e){N(e instanceof Error?e.message:t("assistant.errors.stopSession"));return}}x(e),N(null)},[b,O,f,s,t]);return(0,a.jsx)(l.Zp,{variant:"elevated",padding:"none",className:"overflow-hidden rounded-xl shadow-lg","data-testid":"assistant-chat-panel",children:(0,a.jsxs)("div",{className:"flex h-[78vh] min-h-[34rem] max-h-[48rem] flex-col gap-4 overflow-hidden bg-gradient-to-br from-transparent to-accent-500/5 p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_auto]",children:[(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t("assistant.repositoryLabel")}),(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t("assistant.cliLabel")}),(0,a.jsx)("span",{className:"hidden md:block"})]}),(0,a.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_auto] md:items-center",children:[(0,a.jsxs)("select",{value:h,onChange:e=>void es(e.target.value),disabled:0===n.length,className:"w-full rounded-lg border border-input bg-surface px-3 py-2 text-sm text-foreground shadow-sm transition-colors focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-repo-select",children:[0===n.length&&(0,a.jsx)("option",{value:"",children:t("assistant.noRepositories")}),n.map(e=>(0,a.jsx)("option",{value:e.id,children:e.displayName||e.name},e.id))]}),(0,a.jsx)("select",{value:f,onChange:e=>q(e.target.value),disabled:O,className:"w-full rounded-lg border border-input bg-surface px-3 py-2 text-sm text-foreground shadow-sm transition-colors focus:border-accent-500 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground","data-testid":"assistant-tool-select",children:V.map(e=>(0,a.jsx)("option",{value:e.id,disabled:!e.installed,children:e.installed?e.name:t("assistant.toolNotInstalled",{name:e.name})},e.id))}),(0,a.jsx)("div",{children:O?(0,a.jsx)(l.$n,{variant:"danger",onClick:X,disabled:I,className:"w-full md:w-auto","data-testid":"assistant-stop-button",children:I?t("assistant.stopping"):t("assistant.stop")}):(0,a.jsx)(l.$n,{variant:"primary",onClick:Q,disabled:!h||E,className:"w-full md:w-auto","data-testid":"assistant-start-button",children:E?t("assistant.starting"):t("assistant.start")})})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:$?t("assistant.startDirectory",{repository:$.displayName||$.name,path:$.path}):t("assistant.startDirectoryHint")})]}),k&&(0,a.jsx)("div",{className:"rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger-foreground",children:k}),(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground",children:t("assistant.history")}),(0,a.jsxs)(l.$n,{type:"button",variant:"ghost",size:"sm",onClick:Y,disabled:!b||R||B||0===y.length,className:"gap-1","data-testid":"assistant-clear-button",children:[(0,a.jsx)(o.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),R?t("assistant.clearing"):t("assistant.clearHistory")]})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:F&&0===y.length?(0,a.jsx)("div",{className:"h-full min-h-0 overflow-hidden rounded-xl border border-border bg-surface-2 p-3","data-testid":"assistant-chat-loading",role:"status","aria-label":t("assistant.loadingConversation"),children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(l.EA,{className:"ml-auto h-10 w-3/5 rounded-2xl"}),(0,a.jsx)(l.EA,{className:"mr-auto h-16 w-4/5 rounded-2xl"}),(0,a.jsx)(l.EA,{className:"ml-auto h-10 w-2/5 rounded-2xl"})]})}):(0,a.jsx)(j,{messages:y,assistantLabel:J,sessionActive:O,waitingForResponse:B,canEdit:W,onEditMessage:et})}),(0,a.jsx)("div",{className:"shrink-0",children:(0,a.jsx)(d,{onSend:ee,disabled:!W,placeholder:W?t("assistant.inputPlaceholder"):O?t("assistant.inputPlaceholderWaiting"):t("assistant.inputPlaceholderNoSession")})})]})]})})}function I(){return(0,a.jsx)(n.GV,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Assistant Chat"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Converse with a local CLI assistant (Claude or Codex) scoped to a selected repository."})]}),(0,a.jsx)(A,{})]})})}},71360:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(71847).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])}},e=>{e.O(0,[6481,6809,4909,2770,3165,4974,8566,2069,934,6402,744,6488,4560,8441,1255,7358],()=>e(e.s=38038)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{3809:(e,t,r)=>{"use strict";r.d(t,{default:()=>s});var a=r(36809),n=r(95155);function s(e){let{locale:t,...r}=e;if(!t)throw Error(void 0);return(0,n.jsx)(a.Dk,{locale:t,...r})}},5379:(e,t,r)=>{"use strict";r.d(t,{D:()=>c,N:()=>d});var a=r(12115),n=(e,t,r,a,n,s,l,o)=>{let i=document.documentElement,c=["light","dark"];function d(t){var r;(Array.isArray(e)?e:[e]).forEach(e=>{let r="class"===e,a=r&&s?n.map(e=>s[e]||e):n;r?(i.classList.remove(...a),i.classList.add(s&&s[t]?s[t]:t)):i.setAttribute(e,t)}),r=t,o&&c.includes(r)&&(i.style.colorScheme=r)}if(a)d(a);else try{let e=localStorage.getItem(t)||r,a=l&&"system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e;d(a)}catch(e){}},s=["light","dark"],l="(prefers-color-scheme: dark)",o=a.createContext(void 0),i={setTheme:e=>{},themes:[]},c=()=>{var e;return null!=(e=a.useContext(o))?e:i},d=e=>a.useContext(o)?a.createElement(a.Fragment,null,e.children):a.createElement(m,{...e}),u=["light","dark"],m=e=>{let{forcedTheme:t,disableTransitionOnChange:r=!1,enableSystem:n=!0,enableColorScheme:i=!0,storageKey:c="theme",themes:d=u,defaultTheme:m=n?"system":"light",attribute:y="data-theme",value:g,children:b,nonce:k,scriptProps:x}=e,[w,A]=a.useState(()=>v(c,m)),[E,j]=a.useState(()=>"system"===w?p():w),S=g?Object.values(g):d,N=a.useCallback(e=>{let t=e;if(!t)return;"system"===e&&n&&(t=p());let a=g?g[t]:t,l=r?f(k):null,o=document.documentElement,c=e=>{"class"===e?(o.classList.remove(...S),a&&o.classList.add(a)):e.startsWith("data-")&&(a?o.setAttribute(e,a):o.removeAttribute(e))};if(Array.isArray(y)?y.forEach(c):c(y),i){let e=s.includes(m)?m:null,r=s.includes(t)?t:e;o.style.colorScheme=r}null==l||l()},[k]),C=a.useCallback(e=>{let t="function"==typeof e?e(w):e;A(t);try{localStorage.setItem(c,t)}catch(e){}},[w]),M=a.useCallback(e=>{j(p(e)),"system"===w&&n&&!t&&N("system")},[w,t]);a.useEffect(()=>{let e=window.matchMedia(l);return e.addListener(M),M(e),()=>e.removeListener(M)},[M]),a.useEffect(()=>{let e=e=>{e.key===c&&(e.newValue?A(e.newValue):C(m))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[C]),a.useEffect(()=>{N(null!=t?t:w)},[t,w]);let _=a.useMemo(()=>({theme:w,setTheme:C,forcedTheme:t,resolvedTheme:"system"===w?E:w,themes:n?[...d,"system"]:d,systemTheme:n?E:void 0}),[w,C,t,E,n,d]);return a.createElement(o.Provider,{value:_},a.createElement(h,{forcedTheme:t,storageKey:c,attribute:y,enableSystem:n,enableColorScheme:i,defaultTheme:m,value:g,themes:d,nonce:k,scriptProps:x}),b)},h=a.memo(e=>{let{forcedTheme:t,storageKey:r,attribute:s,enableSystem:l,enableColorScheme:o,defaultTheme:i,value:c,themes:d,nonce:u,scriptProps:m}=e,h=JSON.stringify([s,r,i,t,d,c,l,o]).slice(1,-1);return a.createElement("script",{...m,suppressHydrationWarning:!0,nonce:"",dangerouslySetInnerHTML:{__html:"(".concat(n.toString(),")(").concat(h,")")}})}),v=(e,t)=>{let r;try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t},f=e=>{let t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},p=e=>(e||(e=window.matchMedia(l)),e.matches?"dark":"light")},7183:e=>{e.exports={style:{fontFamily:"'GeistMono', ui-monospace, SFMono-Regular, Roboto Mono, Menlo, Monaco, Liberation Mono, DejaVu Sans Mono, Courier New, monospace"},className:"__className_46451f",variable:"__variable_46451f"}},13673:()=>{},18955:(e,t,r)=>{"use strict";r.d(t,{c:()=>s});var a=r(36809);function n(e,t){return(...e)=>{try{return t(...e)}catch{throw Error(void 0)}}}let s=n(0,a.c3);n(0,a.kc)},20063:(e,t,r)=>{"use strict";var a=r(47260);r.o(a,"useParams")&&r.d(t,{useParams:function(){return a.useParams}}),r.o(a,"usePathname")&&r.d(t,{usePathname:function(){return a.usePathname}}),r.o(a,"useRouter")&&r.d(t,{useRouter:function(){return a.useRouter}})},22311:e=>{e.exports={style:{fontFamily:"'GeistSans', 'GeistSans Fallback'"},className:"__className_8adcd2",variable:"__variable_8adcd2"}},22464:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,22311,23)),Promise.resolve().then(r.t.bind(r,7183,23)),Promise.resolve().then(r.t.bind(r,13673,23)),Promise.resolve().then(r.bind(r,25772))},23327:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},25772:(e,t,r)=>{"use strict";r.d(t,{AppProviders:()=>x});var a=r(95155),n=r(3809),s=r(5379),l=r(32916),o=r(65380),i=r(22592),c=r(92614),d=r(70628),u=r(66966),m=r(89275),h=r(63365),v=r(36402),f=r(94442),p=r(12115),y=r(18955),g=r(89559),b=r(59854);function k(){let e=(0,y.c)("pwa"),[t,r]=(0,p.useState)(null),n=(0,p.useRef)(!1);return((0,p.useEffect)(()=>{if("undefined"==typeof navigator||!("serviceWorker"in navigator))return;let e=!1,t=t=>{e||r(t)};navigator.serviceWorker.register("/sw.js").then(e=>{e.waiting&&navigator.serviceWorker.controller&&t(e.waiting),e.addEventListener("updatefound",()=>{let r=e.installing;r&&r.addEventListener("statechange",()=>{"installed"===r.state&&navigator.serviceWorker.controller&&t(r)})})}).catch(()=>{});let a=()=>{n.current||(n.current=!0,window.location.reload())};return navigator.serviceWorker.addEventListener("controllerchange",a),()=>{e=!0,navigator.serviceWorker.removeEventListener("controllerchange",a)}},[]),t)?(0,a.jsx)("div",{role:"status","aria-live":"polite",className:"fixed inset-x-0 bottom-0 flex justify-center px-4 pb-safe",style:{zIndex:b.M.TOAST},children:(0,a.jsxs)("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-surface px-4 py-3 shadow-lg",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:e("update.available")}),(0,a.jsxs)("button",{type:"button",onClick:()=>{t.postMessage({type:"SKIP_WAITING"})},className:"inline-flex items-center gap-1.5 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-accent-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background dark:bg-accent-500 dark:hover:bg-accent-600",children:[(0,a.jsx)(g.A,{className:"h-4 w-4"}),e("update.reload")]})]})}):null}function x(e){let{children:t,locale:r,messages:p,timeZone:y,authEnabled:g=!1}=e;return(0,a.jsx)(n.default,{locale:r,messages:p,timeZone:y,children:(0,a.jsx)(f.tE,{children:(0,a.jsx)(s.N,{attribute:"class",defaultTheme:"system",enableSystem:!0,children:(0,a.jsx)(o.O,{authEnabled:g,children:(0,a.jsx)(i.W5,{children:(0,a.jsx)(l.GB,{children:(0,a.jsx)(h.tS,{children:(0,a.jsx)(u.g7,{children:(0,a.jsx)(c.E,{children:(0,a.jsx)(d.S,{children:(0,a.jsxs)(v.aF,{children:[(0,a.jsx)(m.Bo,{children:t}),(0,a.jsx)(k,{})]})})})})})})})})})})})}},42529:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},52056:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},65229:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},71847:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(12115);let n=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim()};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:n=24,strokeWidth:o=2,absoluteStrokeWidth:i,className:c="",children:d,iconNode:u,...m}=e;return(0,a.createElement)("svg",{ref:t,...l,width:n,height:n,stroke:r,strokeWidth:i?24*Number(o)/Number(n):o,className:s("lucide",c),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(m)&&{"aria-hidden":"true"},...m},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),i=(e,t)=>{let r=(0,a.forwardRef)((r,l)=>{let{className:i,...c}=r;return(0,a.createElement)(o,{ref:l,iconNode:t,className:s("lucide-".concat(n(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),i),...c})});return r.displayName=n(e),r}},78874:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},83101:(e,t,r)=>{"use strict";r.d(t,{F:()=>l});var a=r(2821);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,s=a.$,l=(e,t)=>r=>{var a;if((null==t?void 0:t.variants)==null)return s(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:l,defaultVariants:o}=t,i=Object.keys(l).map(e=>{let t=null==r?void 0:r[e],a=null==o?void 0:o[e];if(null===t)return null;let s=n(t)||n(a);return l[e][s]}),c=r&&Object.entries(r).reduce((e,t)=>{let[r,a]=t;return void 0===a||(e[r]=a),e},{});return s(e,i,null==t||null==(a=t.compoundVariants)?void 0:a.reduce((e,t)=>{let{class:r,className:a,...n}=t;return Object.entries(n).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...o,...c}[t]):({...o,...c})[t]===r})?[...e,r,a]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}},89559:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(71847).A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])}},e=>{e.O(0,[5373,2978,6809,4909,6402,6488,8441,1255,7358],()=>e(e.s=22464)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3310],{80867:(e,t,a)=>{Promise.resolve().then(a.bind(a,95775))},95775:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>k});var s=a(95155),r=a(52619),n=a.n(r),i=a(18955),l=a(4560),o=a(744),d=a(12115);function c(e){var t;let{appId:a,pollInterval:r=3e4,showResponseTime:n=!1,compact:l=!1}=e,o=(0,i.c)("externalApps"),[c,m]=(0,d.useState)(null),[p,x]=(0,d.useState)(!0),u=(0,d.useCallback)(async()=>{try{let e=await fetch("/api/external-apps/".concat(a,"/health"));if(e.ok){let t=await e.json();m(t)}else m({id:a,healthy:!1,lastChecked:Date.now(),error:"Failed to check health"})}catch(e){m({id:a,healthy:!1,lastChecked:Date.now(),error:"Network error"})}finally{x(!1)}},[a]);if((0,d.useEffect)(()=>{u();let e=setInterval(u,r);return()=>clearInterval(e)},[u,r]),p)return(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-muted-foreground animate-pulse"}),!l&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:o("status.checking")})]});let h=null!=(t=null==c?void 0:c.healthy)&&t,f=h?"bg-success":"bg-muted-foreground",g=o(h?"status.running":"status.stopped");return l?(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(f),title:g}):(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(f)}),(0,s.jsx)("span",{className:"text-xs ".concat(h?"text-success-foreground":"text-muted-foreground"),children:g}),n&&(null==c?void 0:c.responseTime)!==void 0&&(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",c.responseTime,"ms)"]})]})}function m(e){var t;let{app:a,onEdit:r,onDelete:n}=e,l=(0,i.c)("externalApps"),m=(0,i.c)("common"),[p,x]=(0,d.useState)(!1),[u,h]=(0,d.useState)(!1),f=async()=>{h(!0);try{await n(a.id)}finally{h(!1),x(!1)}},g="/proxy/".concat(a.pathPrefix,"/");return(0,s.jsxs)(o.Zp,{padding:"md",className:"relative",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h4",{className:"text-base font-semibold text-foreground truncate",children:a.displayName}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 font-mono truncate",children:a.name})]}),(0,s.jsx)(o.Ex,{variant:{sveltekit:"warning",streamlit:"error",nextjs:"info",other:"gray"}[a.appType]||"gray",children:{sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"}[t=a.appType]||t})]}),(0,s.jsxs)("div",{className:"space-y-2 mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.status")}),(0,s.jsx)(c,{appId:a.id,pollInterval:3e4})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.port")}),(0,s.jsxs)("span",{className:"text-sm font-mono text-foreground",children:[":",a.targetPort]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.path")}),(0,s.jsxs)("span",{className:"text-sm font-mono text-foreground truncate max-w-[150px]",children:["/proxy/",a.pathPrefix,"/"]})]}),a.websocketEnabled&&(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.websocket")}),(0,s.jsx)(o.Ex,{variant:"info",children:l("card.enabled")})]}),!a.enabled&&(0,s.jsx)("div",{className:"mt-2 py-1 px-2 bg-warning-subtle border border-warning-border rounded text-xs text-warning-foreground",children:l("card.disabledNotice")})]}),p?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:l("card.deleteConfirm",{name:a.displayName})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"danger",size:"sm",onClick:f,disabled:u,loading:u,children:l("card.delete")}),(0,s.jsx)(o.$n,{variant:"ghost",size:"sm",onClick:()=>x(!1),disabled:u,children:m("cancel")})]})]}):(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:()=>window.open(g,"_blank"),disabled:!a.enabled,children:l("card.open")}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",onClick:()=>r(a),children:l("card.settings")}),(0,s.jsx)(o.$n,{variant:"ghost",size:"sm",onClick:()=>x(!0),className:"text-danger-foreground hover:bg-danger-subtle",children:l("card.delete")})]})]})}var p=a(87531);let x={MIN:1024,MAX:65535},u=/^[a-zA-Z0-9-]+$/,h={sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"},f=["sveltekit","streamlit","nextjs","other"].map(e=>({value:e,label:h[e]}));function g(e){let{isOpen:t,onClose:a,editApp:r,onSave:n}=e,l=(0,i.c)("externalApps"),c=(0,i.c)("common"),m=!!r,[h,g]=(0,d.useState)(""),[b,j]=(0,d.useState)(""),[N,v]=(0,d.useState)(""),[y,k]=(0,d.useState)(""),[w,C]=(0,d.useState)(""),[P,S]=(0,d.useState)(!1),[E,T]=(0,d.useState)(""),[A,O]=(0,d.useState)(!0),[M,I]=(0,d.useState)({}),[F,$]=(0,d.useState)(!1),[z,D]=(0,d.useState)(null);(0,d.useEffect)(()=>{t&&(r?(g(r.displayName),j(r.name),v(r.pathPrefix),k(r.targetPort),C(r.appType),S(r.websocketEnabled),T(r.description||""),O(r.enabled)):(g(""),j(""),v(""),k(""),C(""),S(!1),T(""),O(!0)),I({}),D(null))},[t,r]);let W=async e=>{e.preventDefault(),D(null);let t=function(e,t){var a,s,r,n;let i={};return((null==(a=e.displayName)?void 0:a.trim())||(i.displayName="Display name is required"),!t&&((null==(s=e.name)?void 0:s.trim())?u.test(e.name)||(i.name="Only alphanumeric characters and hyphens are allowed"):i.name="Identifier name is required",(null==(r=e.pathPrefix)?void 0:r.trim())?u.test(e.pathPrefix)||(i.pathPrefix="Only alphanumeric characters and hyphens are allowed"):i.pathPrefix="Path prefix is required"),e.targetPort)?"number"!=typeof e.targetPort||Number.isInteger(n=e.targetPort)&&n>=x.MIN&&n<=x.MAX||(i.targetPort="Port must be between ".concat(x.MIN," and ").concat(x.MAX)):i.targetPort="Port number is required",t||e.appType||(i.appType="App type is required"),i}({displayName:h,name:b,pathPrefix:N,targetPort:y,appType:w},m);if(Object.keys(t).length>0)return void I(t);I({}),$(!0);try{if(m&&r){let e=await fetch("/api/external-apps/".concat(r.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:h,description:E||void 0,targetPort:y||void 0,websocketEnabled:P,enabled:A})});if(!e.ok){let t=await e.json();throw Error(t.error||l("form.updateFailed"))}}else{let e=await fetch("/api/external-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:h,name:b,pathPrefix:N,targetPort:y,appType:w,websocketEnabled:P,description:E||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||l("form.createFailed"))}}n(),a()}catch(e){D(e instanceof Error?e.message:l("form.genericError"))}finally{$(!1)}};return(0,s.jsx)(o.Jh,{isOpen:t,onClose:a,title:m?l("form.editTitle"):l("form.addTitle"),size:"md",children:(0,s.jsxs)("form",{onSubmit:W,className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-md bg-warning-subtle p-3 mb-4 border border-warning-border",children:(0,s.jsx)("p",{className:"text-sm text-warning-foreground",children:l("form.securityWarning")})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"displayName",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.displayName")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"displayName",type:"text",value:h,onChange:e=>g(e.target.value),className:M.displayName?"border-danger":"",placeholder:l("form.displayNamePlaceholder"),disabled:F}),M.displayName&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.displayName})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.identifierName")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"name",type:"text",value:b,onChange:e=>j(e.target.value),className:"font-mono ".concat(M.name?"border-danger":""),placeholder:l("form.identifierNamePlaceholder"),disabled:F}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.identifierNameHelp")}),M.name&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.name})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"pathPrefix",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.pathPrefix")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground mr-1",children:"/proxy/"}),(0,s.jsx)(o.pd,{id:"pathPrefix",type:"text",value:N,onChange:e=>v(e.target.value),className:"w-auto flex-1 font-mono ".concat(M.pathPrefix?"border-danger":""),placeholder:l("form.pathPrefixPlaceholder"),disabled:F}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground ml-1",children:"/"})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.pathPrefixHelp")}),M.pathPrefix&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.pathPrefix})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"targetPort",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.portNumber")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"targetPort",type:"number",value:y,onChange:e=>k(e.target.value?parseInt(e.target.value,10):""),className:"font-mono ".concat(M.targetPort?"border-danger":""),placeholder:l("form.portNumberPlaceholder"),min:x.MIN,max:x.MAX,disabled:F}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.portNumberHelp",{min:x.MIN,max:x.MAX})}),M.targetPort&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.targetPort})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"appType",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.appType")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsxs)("select",{id:"appType",value:w,onChange:e=>C(e.target.value),className:(0,p.cn)((0,o.j1)(),M.appType&&"border-danger"),disabled:F,children:[(0,s.jsx)("option",{value:"",children:l("form.appTypePlaceholder")}),f.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}),M.appType&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.appType})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"description",className:"block text-sm font-medium text-foreground mb-1",children:l("form.description")}),(0,s.jsx)(o.k_,{id:"description",value:E,onChange:e=>T(e.target.value),placeholder:l("form.descriptionPlaceholder"),rows:2,disabled:F})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(o.dO,{id:"websocketEnabled",checked:P,onCheckedChange:S,disabled:F}),(0,s.jsx)("label",{htmlFor:"websocketEnabled",className:"text-sm text-foreground",children:l("form.websocketLabel")})]}),m&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(o.dO,{id:"enabled",checked:A,onCheckedChange:O,disabled:F}),(0,s.jsx)("label",{htmlFor:"enabled",className:"text-sm text-foreground",children:l("form.enabledLabel")})]}),z&&(0,s.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:z}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[(0,s.jsx)(o.$n,{type:"button",variant:"ghost",onClick:a,disabled:F,children:c("cancel")}),(0,s.jsx)(o.$n,{type:"submit",variant:"primary",loading:F,children:m?l("form.save"):l("form.add")})]})]})})}function b(){let e=(0,i.c)("externalApps"),t=(0,i.c)("common"),[a,r]=(0,d.useState)([]),[n,l]=(0,d.useState)(!0),[c,p]=(0,d.useState)(null),[x,u]=(0,d.useState)(!1),[h,f]=(0,d.useState)(null),b=(0,d.useCallback)(async()=>{try{p(null);let e=await fetch("/api/external-apps");if(!e.ok)throw Error("Failed to fetch external apps");let t=await e.json();r(t.apps||[])}catch(e){p(e instanceof Error?e.message:"An error occurred")}finally{l(!1)}},[]);(0,d.useEffect)(()=>{b();let e=setInterval(b,6e4);return()=>clearInterval(e)},[b]);let j=(0,d.useCallback)(e=>{f(e),u(!0)},[]),N=(0,d.useCallback)(()=>{f(null),u(!0)},[]),v=(0,d.useCallback)(async e=>{try{let t=await fetch("/api/external-apps/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete app")}b()}catch(e){console.error("Failed to delete app:",e)}},[b]),y=(0,d.useCallback)(()=>{b()},[b]),k=(0,d.useCallback)(()=>{u(!1),f(null)},[]);return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:N,children:e("manager.addApp")})}),n?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,s.jsx)(o.y$,{size:"xl",variant:"accent"}),(0,s.jsx)("span",{className:"ml-3 text-muted-foreground",children:e("manager.loading")})]})}):c?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)("p",{className:"text-danger-foreground mb-4",children:e("manager.loadError")}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",onClick:b,children:t("retry")})]})}):0===a.length?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)("p",{className:"text-muted-foreground mb-4",children:e("manager.empty")}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:e("manager.emptyHelp")}),(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:N,children:e("manager.addFirst")})]})}):(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(e=>(0,s.jsx)(m,{app:e,onEdit:j,onDelete:v},e.id))}),(0,s.jsx)(g,{isOpen:x,onClose:k,editApp:h,onSave:y})]})}let j=(0,a(71847).A)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);var N=a(94442);function v(){return"undefined"!=typeof navigator&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function y(){let e=(0,i.c)("notifications"),{showToast:t,toasts:a,removeToast:r}=(0,N.dj)(),[n,l]=(0,d.useState)(!0),[c,m]=(0,d.useState)(!1),[p,x]=(0,d.useState)(!0),[u,h]=(0,d.useState)(!1),[f,g]=(0,d.useState)(null),[b,y]=(0,d.useState)(null),[k,w]=(0,d.useState)(!1),[C,P]=(0,d.useState)(null),[S,E]=(0,d.useState)({prompt:!0,completion:!0}),T=null!==C;(0,d.useEffect)(()=>{let e=!1;return(async()=>{let t=function(){var e,t;let a=v(),s="undefined"!=typeof navigator&&(!!/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!(null!=(e=(t=window).matchMedia)&&e.call(t,"(display-mode: standalone)").matches||!0===navigator.standalone);return{supported:a&&!s,iosNeedsInstall:s}}();e||(x(v()),h(t.iosNeedsInstall),"undefined"!=typeof Notification&&"denied"===Notification.permission&&w(!0));try{let t=await fetch("/api/push/vapid"),a=await t.json();e||(g(a.configured),y(a.publicKey))}catch(t){e||g(!1)}if(v())try{let t=await navigator.serviceWorker.getRegistration(),a=t?await t.pushManager.getSubscription():null;if(a&&!e){P(a.endpoint);let t=await fetch("/api/push/subscriptions?endpoint=".concat(encodeURIComponent(a.endpoint))),s=await t.json();s.subscribed&&s.subscription&&!e&&E(s.subscription.preferences)}}catch(e){}e||l(!1)})(),()=>{e=!0}},[]);let A=(0,d.useCallback)(async()=>{if(b){m(!0);try{var a;let s=await Notification.requestPermission();if("granted"!==s){w("denied"===s),t(e("toast.error"),"error");return}if(!await navigator.serviceWorker.getRegistration())return void t(e("toast.error"),"error");let r=await navigator.serviceWorker.ready,n=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let t="=".repeat((4-e.length%4)%4),a=atob((e+t).replace(/-/g,"+").replace(/_/g,"/")),s=new Uint8Array(new ArrayBuffer(a.length));for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);return s}(b)}),i=await fetch("/api/push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription:n.toJSON(),deviceLabel:navigator.userAgent.slice(0,120)})});if(!i.ok)throw Error("subscribe request failed");let l=await i.json();P(n.endpoint),(null==(a=l.subscription)?void 0:a.preferences)&&E(l.subscription.preferences),w(!1),t(e("toast.enabled"),"success")}catch(a){t(e("toast.error"),"error")}finally{m(!1)}}},[b,t,e]),O=(0,d.useCallback)(async()=>{m(!0);try{var a;let s=await navigator.serviceWorker.getRegistration(),r=s?await s.pushManager.getSubscription():null,n=null!=(a=null==r?void 0:r.endpoint)?a:C;r&&await r.unsubscribe(),n&&await fetch("/api/push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:n})}),P(null),t(e("toast.disabled"),"info")}catch(a){t(e("toast.error"),"error")}finally{m(!1)}},[C,t,e]),M=(0,d.useCallback)(async(a,s)=>{if(!C)return;let r={...S,[a]:s};E(r);try{if(!(await fetch("/api/push/subscriptions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:C,preferences:r})})).ok)throw Error("update failed");t(e("toast.updated"),"success")}catch(a){E(S),t(e("toast.error"),"error")}},[C,S,t,e]);return(0,s.jsxs)(o.Zp,{children:[n?(0,s.jsx)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:(0,s.jsx)(o.y$,{size:"sm"})}):p?u?(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"notifications-ios-guidance",children:e("ios.guidance")}):!1===f?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("notConfigured")}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("description")}),k&&(0,s.jsx)("p",{className:"text-sm text-danger-foreground","data-testid":"notifications-permission-denied",children:e("permission.denied")}),T?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground",children:e("enabledOnThisDevice")}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e("types.heading")}),(0,s.jsxs)("label",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e("types.promptWaiting")}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e("types.promptWaitingDesc")})]}),(0,s.jsx)(o.dO,{checked:S.prompt,onCheckedChange:e=>M("prompt",e),disabled:c,"aria-label":e("types.promptWaiting"),"data-testid":"notifications-toggle-prompt"})]}),(0,s.jsxs)("label",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e("types.completion")}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e("types.completionDesc")})]}),(0,s.jsx)(o.dO,{checked:S.completion,onCheckedChange:e=>M("completion",e),disabled:c,"aria-label":e("types.completion"),"data-testid":"notifications-toggle-completion"})]})]}),(0,s.jsx)(o.$n,{variant:"secondary",onClick:O,disabled:c,"data-testid":"notifications-unsubscribe",children:e("unsubscribe")})]}):(0,s.jsxs)(o.$n,{variant:"primary",onClick:A,disabled:c||k||!b,"data-testid":"notifications-enable",children:[(0,s.jsx)(j,{className:"h-4 w-4"}),c?e("enabling"):e("enable")]})]}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("unsupported")}),(0,s.jsx)(N.N9,{toasts:a,onClose:r})]})}function k(){let e=(0,i.c)("notifications");return(0,s.jsx)(l.GV,{children:(0,s.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"More"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Settings, external apps, and more."})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"Quick Links"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:(0,s.jsx)(n(),{href:"/repositories",className:"block","data-testid":"more-link-repositories",children:(0,s.jsxs)(o.Zp,{hover:!0,className:"transition-colors hover:border-accent-300 dark:hover:border-accent-700",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Repositories"}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"Manage repositories and worktrees"})]})})})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:e("title")}),(0,s.jsx)(y,{})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"External Apps"}),(0,s.jsx)(b,{})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"About"}),(0,s.jsx)(o.Zp,{children:(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:"CommandMate - A local control plane for agent CLIs."})})]})]})})}}},e=>{e.O(0,[6809,4909,2770,3165,4974,6402,744,7347,4560,8441,1255,7358],()=>e(e.s=80867)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3310],{80867:(e,t,a)=>{Promise.resolve().then(a.bind(a,95775))},95775:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>k});var s=a(95155),r=a(52619),n=a.n(r),i=a(18955),l=a(4560),o=a(744),d=a(12115);function c(e){var t;let{appId:a,pollInterval:r=3e4,showResponseTime:n=!1,compact:l=!1}=e,o=(0,i.c)("externalApps"),[c,m]=(0,d.useState)(null),[p,x]=(0,d.useState)(!0),u=(0,d.useCallback)(async()=>{try{let e=await fetch("/api/external-apps/".concat(a,"/health"));if(e.ok){let t=await e.json();m(t)}else m({id:a,healthy:!1,lastChecked:Date.now(),error:"Failed to check health"})}catch(e){m({id:a,healthy:!1,lastChecked:Date.now(),error:"Network error"})}finally{x(!1)}},[a]);if((0,d.useEffect)(()=>{u();let e=setInterval(u,r);return()=>clearInterval(e)},[u,r]),p)return(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-muted-foreground animate-pulse"}),!l&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:o("status.checking")})]});let h=null!=(t=null==c?void 0:c.healthy)&&t,f=h?"bg-success":"bg-muted-foreground",g=o(h?"status.running":"status.stopped");return l?(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(f),title:g}):(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(f)}),(0,s.jsx)("span",{className:"text-xs ".concat(h?"text-success-foreground":"text-muted-foreground"),children:g}),n&&(null==c?void 0:c.responseTime)!==void 0&&(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",c.responseTime,"ms)"]})]})}function m(e){var t;let{app:a,onEdit:r,onDelete:n}=e,l=(0,i.c)("externalApps"),m=(0,i.c)("common"),[p,x]=(0,d.useState)(!1),[u,h]=(0,d.useState)(!1),f=async()=>{h(!0);try{await n(a.id)}finally{h(!1),x(!1)}},g="/proxy/".concat(a.pathPrefix,"/");return(0,s.jsxs)(o.Zp,{padding:"md",className:"relative",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h4",{className:"text-base font-semibold text-foreground truncate",children:a.displayName}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 font-mono truncate",children:a.name})]}),(0,s.jsx)(o.Ex,{variant:{sveltekit:"warning",streamlit:"error",nextjs:"info",other:"gray"}[a.appType]||"gray",children:{sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"}[t=a.appType]||t})]}),(0,s.jsxs)("div",{className:"space-y-2 mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.status")}),(0,s.jsx)(c,{appId:a.id,pollInterval:3e4})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.port")}),(0,s.jsxs)("span",{className:"text-sm font-mono text-foreground",children:[":",a.targetPort]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.path")}),(0,s.jsxs)("span",{className:"text-sm font-mono text-foreground truncate max-w-[150px]",children:["/proxy/",a.pathPrefix,"/"]})]}),a.websocketEnabled&&(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:l("card.websocket")}),(0,s.jsx)(o.Ex,{variant:"info",children:l("card.enabled")})]}),!a.enabled&&(0,s.jsx)("div",{className:"mt-2 py-1 px-2 bg-warning-subtle border border-warning-border rounded text-xs text-warning-foreground",children:l("card.disabledNotice")})]}),p?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:l("card.deleteConfirm",{name:a.displayName})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"danger",size:"sm",onClick:f,disabled:u,loading:u,children:l("card.delete")}),(0,s.jsx)(o.$n,{variant:"ghost",size:"sm",onClick:()=>x(!1),disabled:u,children:m("cancel")})]})]}):(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:()=>window.open(g,"_blank"),disabled:!a.enabled,children:l("card.open")}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",onClick:()=>r(a),children:l("card.settings")}),(0,s.jsx)(o.$n,{variant:"ghost",size:"sm",onClick:()=>x(!0),className:"text-danger-foreground hover:bg-danger-subtle",children:l("card.delete")})]})]})}var p=a(87531);let x={MIN:1024,MAX:65535},u=/^[a-zA-Z0-9-]+$/,h={sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"},f=["sveltekit","streamlit","nextjs","other"].map(e=>({value:e,label:h[e]}));function g(e){let{isOpen:t,onClose:a,editApp:r,onSave:n}=e,l=(0,i.c)("externalApps"),c=(0,i.c)("common"),m=!!r,[h,g]=(0,d.useState)(""),[b,j]=(0,d.useState)(""),[N,v]=(0,d.useState)(""),[y,k]=(0,d.useState)(""),[w,C]=(0,d.useState)(""),[P,S]=(0,d.useState)(!1),[E,T]=(0,d.useState)(""),[A,O]=(0,d.useState)(!0),[M,I]=(0,d.useState)({}),[F,$]=(0,d.useState)(!1),[z,D]=(0,d.useState)(null);(0,d.useEffect)(()=>{t&&(r?(g(r.displayName),j(r.name),v(r.pathPrefix),k(r.targetPort),C(r.appType),S(r.websocketEnabled),T(r.description||""),O(r.enabled)):(g(""),j(""),v(""),k(""),C(""),S(!1),T(""),O(!0)),I({}),D(null))},[t,r]);let W=async e=>{e.preventDefault(),D(null);let t=function(e,t){var a,s,r,n;let i={};return((null==(a=e.displayName)?void 0:a.trim())||(i.displayName="Display name is required"),!t&&((null==(s=e.name)?void 0:s.trim())?u.test(e.name)||(i.name="Only alphanumeric characters and hyphens are allowed"):i.name="Identifier name is required",(null==(r=e.pathPrefix)?void 0:r.trim())?u.test(e.pathPrefix)||(i.pathPrefix="Only alphanumeric characters and hyphens are allowed"):i.pathPrefix="Path prefix is required"),e.targetPort)?"number"!=typeof e.targetPort||Number.isInteger(n=e.targetPort)&&n>=x.MIN&&n<=x.MAX||(i.targetPort="Port must be between ".concat(x.MIN," and ").concat(x.MAX)):i.targetPort="Port number is required",t||e.appType||(i.appType="App type is required"),i}({displayName:h,name:b,pathPrefix:N,targetPort:y,appType:w},m);if(Object.keys(t).length>0)return void I(t);I({}),$(!0);try{if(m&&r){let e=await fetch("/api/external-apps/".concat(r.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:h,description:E||void 0,targetPort:y||void 0,websocketEnabled:P,enabled:A})});if(!e.ok){let t=await e.json();throw Error(t.error||l("form.updateFailed"))}}else{let e=await fetch("/api/external-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:h,name:b,pathPrefix:N,targetPort:y,appType:w,websocketEnabled:P,description:E||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||l("form.createFailed"))}}n(),a()}catch(e){D(e instanceof Error?e.message:l("form.genericError"))}finally{$(!1)}};return(0,s.jsx)(o.Jh,{isOpen:t,onClose:a,title:m?l("form.editTitle"):l("form.addTitle"),size:"md",children:(0,s.jsxs)("form",{onSubmit:W,className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-md bg-warning-subtle p-3 mb-4 border border-warning-border",children:(0,s.jsx)("p",{className:"text-sm text-warning-foreground",children:l("form.securityWarning")})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"displayName",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.displayName")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"displayName",type:"text",value:h,onChange:e=>g(e.target.value),className:M.displayName?"border-danger":"",placeholder:l("form.displayNamePlaceholder"),disabled:F}),M.displayName&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.displayName})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.identifierName")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"name",type:"text",value:b,onChange:e=>j(e.target.value),className:"font-mono ".concat(M.name?"border-danger":""),placeholder:l("form.identifierNamePlaceholder"),disabled:F}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.identifierNameHelp")}),M.name&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.name})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"pathPrefix",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.pathPrefix")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground mr-1",children:"/proxy/"}),(0,s.jsx)(o.pd,{id:"pathPrefix",type:"text",value:N,onChange:e=>v(e.target.value),className:"w-auto flex-1 font-mono ".concat(M.pathPrefix?"border-danger":""),placeholder:l("form.pathPrefixPlaceholder"),disabled:F}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground ml-1",children:"/"})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.pathPrefixHelp")}),M.pathPrefix&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.pathPrefix})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"targetPort",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.portNumber")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsx)(o.pd,{id:"targetPort",type:"number",value:y,onChange:e=>k(e.target.value?parseInt(e.target.value,10):""),className:"font-mono ".concat(M.targetPort?"border-danger":""),placeholder:l("form.portNumberPlaceholder"),min:x.MIN,max:x.MAX,disabled:F}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l("form.portNumberHelp",{min:x.MIN,max:x.MAX})}),M.targetPort&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.targetPort})]}),!m&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"appType",className:"block text-sm font-medium text-foreground mb-1",children:[l("form.appType")," ",(0,s.jsx)("span",{className:"text-danger",children:"*"})]}),(0,s.jsxs)("select",{id:"appType",value:w,onChange:e=>C(e.target.value),className:(0,p.cn)((0,o.j1)(),M.appType&&"border-danger"),disabled:F,children:[(0,s.jsx)("option",{value:"",children:l("form.appTypePlaceholder")}),f.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}),M.appType&&(0,s.jsx)("p",{className:"mt-1 text-xs text-danger",children:M.appType})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"description",className:"block text-sm font-medium text-foreground mb-1",children:l("form.description")}),(0,s.jsx)(o.k_,{id:"description",value:E,onChange:e=>T(e.target.value),placeholder:l("form.descriptionPlaceholder"),rows:2,disabled:F})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(o.dO,{id:"websocketEnabled",checked:P,onCheckedChange:S,disabled:F}),(0,s.jsx)("label",{htmlFor:"websocketEnabled",className:"text-sm text-foreground",children:l("form.websocketLabel")})]}),m&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(o.dO,{id:"enabled",checked:A,onCheckedChange:O,disabled:F}),(0,s.jsx)("label",{htmlFor:"enabled",className:"text-sm text-foreground",children:l("form.enabledLabel")})]}),z&&(0,s.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:z}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[(0,s.jsx)(o.$n,{type:"button",variant:"ghost",onClick:a,disabled:F,children:c("cancel")}),(0,s.jsx)(o.$n,{type:"submit",variant:"primary",loading:F,children:m?l("form.save"):l("form.add")})]})]})})}function b(){let e=(0,i.c)("externalApps"),t=(0,i.c)("common"),[a,r]=(0,d.useState)([]),[n,l]=(0,d.useState)(!0),[c,p]=(0,d.useState)(null),[x,u]=(0,d.useState)(!1),[h,f]=(0,d.useState)(null),b=(0,d.useCallback)(async()=>{try{p(null);let e=await fetch("/api/external-apps");if(!e.ok)throw Error("Failed to fetch external apps");let t=await e.json();r(t.apps||[])}catch(e){p(e instanceof Error?e.message:"An error occurred")}finally{l(!1)}},[]);(0,d.useEffect)(()=>{b();let e=setInterval(b,6e4);return()=>clearInterval(e)},[b]);let j=(0,d.useCallback)(e=>{f(e),u(!0)},[]),N=(0,d.useCallback)(()=>{f(null),u(!0)},[]),v=(0,d.useCallback)(async e=>{try{let t=await fetch("/api/external-apps/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete app")}b()}catch(e){console.error("Failed to delete app:",e)}},[b]),y=(0,d.useCallback)(()=>{b()},[b]),k=(0,d.useCallback)(()=>{u(!1),f(null)},[]);return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-end",children:(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:N,children:e("manager.addApp")})}),n?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,s.jsx)(o.y$,{size:"xl",variant:"accent"}),(0,s.jsx)("span",{className:"ml-3 text-muted-foreground",children:e("manager.loading")})]})}):c?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)("p",{className:"text-danger-foreground mb-4",children:e("manager.loadError")}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",onClick:b,children:t("retry")})]})}):0===a.length?(0,s.jsx)(o.Zp,{padding:"lg",children:(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)("p",{className:"text-muted-foreground mb-4",children:e("manager.empty")}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:e("manager.emptyHelp")}),(0,s.jsx)(o.$n,{variant:"primary",size:"sm",onClick:N,children:e("manager.addFirst")})]})}):(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(e=>(0,s.jsx)(m,{app:e,onEdit:j,onDelete:v},e.id))}),(0,s.jsx)(g,{isOpen:x,onClose:k,editApp:h,onSave:y})]})}let j=(0,a(71847).A)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);var N=a(94442);function v(){return"undefined"!=typeof navigator&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function y(){let e=(0,i.c)("notifications"),{showToast:t}=(0,N.dj)(),[a,r]=(0,d.useState)(!0),[n,l]=(0,d.useState)(!1),[c,m]=(0,d.useState)(!0),[p,x]=(0,d.useState)(!1),[u,h]=(0,d.useState)(null),[f,g]=(0,d.useState)(null),[b,y]=(0,d.useState)(!1),[k,w]=(0,d.useState)(null),[C,P]=(0,d.useState)({prompt:!0,completion:!0}),S=null!==k;(0,d.useEffect)(()=>{let e=!1;return(async()=>{let t=function(){var e,t;let a=v(),s="undefined"!=typeof navigator&&(!!/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!(null!=(e=(t=window).matchMedia)&&e.call(t,"(display-mode: standalone)").matches||!0===navigator.standalone);return{supported:a&&!s,iosNeedsInstall:s}}();e||(m(v()),x(t.iosNeedsInstall),"undefined"!=typeof Notification&&"denied"===Notification.permission&&y(!0));try{let t=await fetch("/api/push/vapid"),a=await t.json();e||(h(a.configured),g(a.publicKey))}catch(t){e||h(!1)}if(v())try{let t=await navigator.serviceWorker.getRegistration(),a=t?await t.pushManager.getSubscription():null;if(a&&!e){w(a.endpoint);let t=await fetch("/api/push/subscriptions?endpoint=".concat(encodeURIComponent(a.endpoint))),s=await t.json();s.subscribed&&s.subscription&&!e&&P(s.subscription.preferences)}}catch(e){}e||r(!1)})(),()=>{e=!0}},[]);let E=(0,d.useCallback)(async()=>{if(f){l(!0);try{var a;let s=await Notification.requestPermission();if("granted"!==s){y("denied"===s),t(e("toast.error"),"error");return}if(!await navigator.serviceWorker.getRegistration())return void t(e("toast.error"),"error");let r=await navigator.serviceWorker.ready,n=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let t="=".repeat((4-e.length%4)%4),a=atob((e+t).replace(/-/g,"+").replace(/_/g,"/")),s=new Uint8Array(new ArrayBuffer(a.length));for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);return s}(f)}),i=await fetch("/api/push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription:n.toJSON(),deviceLabel:navigator.userAgent.slice(0,120)})});if(!i.ok)throw Error("subscribe request failed");let l=await i.json();w(n.endpoint),(null==(a=l.subscription)?void 0:a.preferences)&&P(l.subscription.preferences),y(!1),t(e("toast.enabled"),"success")}catch(a){t(e("toast.error"),"error")}finally{l(!1)}}},[f,t,e]),T=(0,d.useCallback)(async()=>{l(!0);try{var a;let s=await navigator.serviceWorker.getRegistration(),r=s?await s.pushManager.getSubscription():null,n=null!=(a=null==r?void 0:r.endpoint)?a:k;r&&await r.unsubscribe(),n&&await fetch("/api/push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:n})}),w(null),t(e("toast.disabled"),"info")}catch(a){t(e("toast.error"),"error")}finally{l(!1)}},[k,t,e]),A=(0,d.useCallback)(async(a,s)=>{if(!k)return;let r={...C,[a]:s};P(r);try{if(!(await fetch("/api/push/subscriptions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:k,preferences:r})})).ok)throw Error("update failed");t(e("toast.updated"),"success")}catch(a){P(C),t(e("toast.error"),"error")}},[k,C,t,e]);return(0,s.jsx)(o.Zp,{children:a?(0,s.jsx)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:(0,s.jsx)(o.y$,{size:"sm"})}):c?p?(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"notifications-ios-guidance",children:e("ios.guidance")}):!1===u?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("notConfigured")}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("description")}),b&&(0,s.jsx)("p",{className:"text-sm text-danger-foreground","data-testid":"notifications-permission-denied",children:e("permission.denied")}),S?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground",children:e("enabledOnThisDevice")}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e("types.heading")}),(0,s.jsxs)("label",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e("types.promptWaiting")}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e("types.promptWaitingDesc")})]}),(0,s.jsx)(o.dO,{checked:C.prompt,onCheckedChange:e=>A("prompt",e),disabled:n,"aria-label":e("types.promptWaiting"),"data-testid":"notifications-toggle-prompt"})]}),(0,s.jsxs)("label",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e("types.completion")}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e("types.completionDesc")})]}),(0,s.jsx)(o.dO,{checked:C.completion,onCheckedChange:e=>A("completion",e),disabled:n,"aria-label":e("types.completion"),"data-testid":"notifications-toggle-completion"})]})]}),(0,s.jsx)(o.$n,{variant:"secondary",onClick:T,disabled:n,"data-testid":"notifications-unsubscribe",children:e("unsubscribe")})]}):(0,s.jsxs)(o.$n,{variant:"primary",onClick:E,disabled:n||b||!f,"data-testid":"notifications-enable",children:[(0,s.jsx)(j,{className:"h-4 w-4"}),n?e("enabling"):e("enable")]})]}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:e("unsupported")})})}function k(){let e=(0,i.c)("notifications");return(0,s.jsx)(l.GV,{children:(0,s.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"More"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Settings, external apps, and more."})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"Quick Links"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:(0,s.jsx)(n(),{href:"/repositories",className:"block","data-testid":"more-link-repositories",children:(0,s.jsxs)(o.Zp,{hover:!0,className:"transition-colors hover:border-accent-300 dark:hover:border-accent-700",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Repositories"}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"Manage repositories and worktrees"})]})})})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:e("title")}),(0,s.jsx)(y,{})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"External Apps"}),(0,s.jsx)(b,{})]}),(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"About"}),(0,s.jsx)(o.Zp,{children:(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:"CommandMate - A local control plane for agent CLIs."})})]})]})})}}},e=>{e.O(0,[6809,4909,2770,3165,4974,6402,744,6488,4560,8441,1255,7358],()=>e(e.s=80867)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{6473:(e,t,s)=>{"use strict";s.d(t,{Lc:()=>n,qz:()=>a});let a="animate-in fade-in-0 slide-in-from-bottom-2 fill-mode-backwards duration-300";function n(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:40,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;if(Number.isFinite(e)&&!(e<=0)&&!(e>=s))return"".concat(e*t,"ms")}},53292:(e,t,s)=>{"use strict";s.d(t,{Ll:()=>a,bu:()=>n});let a=2e3,n=4e3},54799:(e,t,s)=>{Promise.resolve().then(s.bind(s,75590))},75590:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>O});var a=s(95155),n=s(4560),o=s(66966),i=s(12115),r=s(18955);function d(e){let{worktrees:t}=e,s=(0,r.c)("home"),{runningCount:n,waitingCount:o}=(0,i.useMemo)(()=>{let e=0,s=0;for(let a of t)a.isSessionRunning&&(e++,a.isWaitingForResponse&&s++);return{runningCount:e,waitingCount:s}},[t]);return(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:s("title")}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":"home-subline",children:[(0,a.jsx)("span",{className:"tabular-nums","data-testid":"subline-running",children:n})," ",s("running"),(0,a.jsx)("span",{"aria-hidden":"true",children:" \xb7 "}),(0,a.jsx)("span",{className:"tabular-nums","data-testid":"subline-waiting",children:o})," ",s("waiting")]})]})}var l=s(52619),c=s.n(l),m=s(65229),u=s(61362),h=s(99051),x=s(744),g=s(2317);function f(e){return"boolean"==typeof e}let p=[{key:"registerRepository",href:"/repositories"},{key:"sendFirstMessage",href:"/sessions"}];function j(e){let{worktrees:t,repositories:s,isLoading:n=!1,error:o=null}=e,d=(0,r.c)("home"),{value:l,setValue:j}=(0,g.V)({key:"commandmate:onboarding-dismissed",defaultValue:!1,validate:f}),[b,y]=(0,i.useState)(!1);(0,i.useEffect)(()=>y(!0),[]);let v=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{hasRepository:(null!=t?t:[]).length>0,hasSentMessage:(null!=e?e:[]).some(e=>!!e.lastUserMessageAt)}}(t,s),N=v.hasRepository&&v.hasSentMessage,w=b&&!n&&null===o;return((0,i.useEffect)(()=>{w&&N&&!l&&j(!0)},[w,N,l,j]),!w||N||l)?null:(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsxs)(x.Zp,{variant:"elevated","data-testid":"onboarding-checklist",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d("onboarding.title")}),(0,a.jsx)(x.$n,{variant:"ghost",size:"sm","aria-label":d("onboarding.dismiss"),"data-testid":"onboarding-dismiss",onClick:()=>j(!0),children:(0,a.jsx)(m.A,{size:16,"aria-hidden":"true"})})]}),(0,a.jsx)("ol",{className:"mt-3 space-y-3",children:p.map(e=>{let{key:t,href:s}=e,n="registerRepository"===t?v.hasRepository:v.hasSentMessage;return(0,a.jsxs)("li",{className:"flex items-center gap-3","data-testid":"onboarding-step-".concat(t),"data-complete":n,children:[n?(0,a.jsx)(u.A,{size:20,className:"shrink-0 text-success-foreground","aria-hidden":"true"}):(0,a.jsx)(h.A,{size:20,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 text-sm ".concat(n?"text-muted-foreground line-through":"text-foreground"),children:d("onboarding.steps.".concat(t))}),!n&&(0,a.jsx)(c(),{href:s,"data-testid":"onboarding-action-".concat(t),className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:bg-accent-500 dark:hover:bg-accent-600",children:d("onboarding.actions.".concat(t))})]},t)})})]})})}var b=s(87531);function y(e){let{worktrees:t,isLoading:s=!1}=e,n=(0,r.c)("home"),{runningCount:o,waitingCount:d}=(0,i.useMemo)(()=>{let e=0,s=0;for(let a of t)a.isSessionRunning&&(e++,a.isWaitingForResponse&&s++);return{runningCount:e,waitingCount:s}},[t]);return s?(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3","data-testid":"home-session-summary-loading",role:"status","aria-label":n("sessionSummary.loading"),children:[0,1].map(e=>(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsx)("div",{className:"flex h-4 items-center",children:(0,a.jsx)(x.EA,{className:"h-3 w-16"})}),(0,a.jsx)("div",{className:"flex h-9 items-center",children:(0,a.jsx)(x.EA,{className:"h-7 w-10"})})]},e))}):(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3","data-testid":"home-session-summary",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(x.md,{status:o>0?"running":"idle",size:"sm",label:n("sessionSummary.running")}),n("sessionSummary.running")]}),(0,a.jsx)("div",{className:(0,b.cn)("text-3xl font-bold tabular-nums",o>0?"text-foreground":"text-muted-foreground"),"data-testid":"running-count",children:o})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(x.md,{status:d>0?"waiting":"idle",size:"sm",label:n("sessionSummary.waiting")}),n("sessionSummary.waiting")]}),(0,a.jsx)("div",{className:(0,b.cn)("text-3xl font-bold tabular-nums",d>0?"text-foreground":"text-muted-foreground"),"data-testid":"waiting-count",children:d})]})]})}var v=s(7636),N=s(83012);function w(e){var t;return null!=(t=e.lastUserMessageAt)?t:e.updatedAt}function k(e){let{worktrees:t,limit:s=5,isLoading:n=!1}=e,o=(0,r.c)("home"),d=(0,i.useMemo)(()=>[...t].sort((e,t)=>(0,v.nO)(w(e),w(t))).slice(0,s),[t,s]);return n?(0,a.jsx)("ul",{className:"space-y-1","data-testid":"recent-sessions-loading",role:"status","aria-label":o("recentSessions.loading"),children:Array.from({length:s},(e,t)=>(0,a.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5",children:[(0,a.jsx)(x.EA,{className:"h-2 w-2 shrink-0 rounded-full"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,a.jsx)(x.EA,{className:"h-4 w-2/5"}),(0,a.jsx)(x.EA,{className:"h-3 w-3/5"})]}),(0,a.jsx)(x.EA,{className:"h-3 w-8 shrink-0"})]},t))}):0===d.length?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"recent-sessions-empty",children:o("recentSessions.empty")}),(0,a.jsx)(c(),{href:"/repositories","data-testid":"recent-sessions-cta",className:"inline-block text-sm font-medium text-accent-600 transition-colors hover:text-accent-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 dark:hover:text-accent-300",children:o("recentSessions.cta")})]}):(0,a.jsx)("ul",{className:"space-y-1","data-testid":"recent-sessions",children:d.map(e=>{var t;let s=w(e),n=s?(0,N.Fx)(String(s)):"";return(0,a.jsx)("li",{children:(0,a.jsxs)(c(),{href:"/worktrees/".concat(e.id),"data-testid":"recent-session-".concat(e.id),className:"flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,a.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full ".concat(e.isWaitingForResponse?"bg-warning":e.isSessionRunning?"bg-success":"bg-muted-foreground"),"aria-hidden":"true"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block truncate text-sm font-medium text-foreground",children:null!=(t=e.repositoryDisplayName)?t:e.repositoryName}),(0,a.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.name})]}),n&&(0,a.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:n})]})},e.id)})})}function C(e){let{worktrees:t,isLoading:s=!1}=e,n=(0,r.c)("home");return(0,a.jsxs)(x.Zp,{variant:"elevated",className:"h-full","data-testid":"session-overview-tile",children:[(0,a.jsx)("h2",{className:"mb-3 text-lg font-semibold text-foreground",children:n("sessionOverview.title")}),(0,a.jsx)(y,{worktrees:t,isLoading:s}),(0,a.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:n("sessionOverview.recentSessions")}),(0,a.jsx)(c(),{href:"/sessions",className:"text-xs text-accent-600 hover:underline dark:text-accent-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","data-testid":"session-overview-view-all",children:n("sessionOverview.viewAll")})]}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(k,{worktrees:t,isLoading:s})})]})}var S=s(85872),A=s(53292);let E="commandmate-home-todo-repo";function R(e){var t;return(null==(t=e.repositoryDisplayName)?void 0:t.trim())||e.repositoryName||""}function F(){let e=(0,r.c)("home"),[t,s]=(0,i.useState)([]),[n,o]=(0,i.useState)(""),[d,l]=(0,i.useState)([]),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[p,j]=(0,i.useState)(null),b=(0,i.useRef)(!1),y=(0,i.useMemo)(()=>d.filter(e=>!e.done).length,[d]);(0,i.useEffect)(()=>{!async function(){try{var e;let t=await fetch("/api/worktrees");if(!t.ok)return;let a=(null!=(e=(await t.json()).repositories)?e:[]).map(e=>({id:e.id,path:e.path,name:e.name,displayName:e.displayName}));if(s(a),a.length>0){let e=localStorage.getItem(E),t=e&&a.some(t=>t.id===e)?e:a[0].id;o(t)}}catch(e){}finally{b.current=!0}}()},[]);let v=(0,i.useCallback)(async()=>{h(!0),j(null);try{let e=await S.$C.listAll();l(e)}catch(t){j(t instanceof Error?t.message:e("todo.errors.load")),l([])}finally{h(!1)}},[e]);(0,i.useEffect)(()=>{v()},[v]),(0,i.useEffect)(()=>{n&&localStorage.setItem(E,n)},[n]);let N=(0,i.useCallback)(async()=>{let t=c.trim();if(t&&n&&!g){f(!0),j(null);try{await S.$C.create(n,t),m(""),await v()}catch(t){j(t instanceof Error?t.message:e("todo.errors.add"))}finally{f(!1)}}},[c,n,g,v,e]),w=(0,i.useCallback)(async t=>{l(e=>e.map(e=>e.id===t.id?{...e,done:!e.done}:e)),j(null);try{await S.$C.update(t.repositoryId,t.id,{done:!t.done})}catch(t){j(t instanceof Error?t.message:e("todo.errors.update")),v()}},[v,e]),k=(0,i.useCallback)(async t=>{j(null);try{await S.$C.remove(t.repositoryId,t.id),l(e=>e.filter(e=>e.id!==t.id))}catch(t){j(t instanceof Error?t.message:e("todo.errors.delete"))}},[e]),C=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),N())},[N]),F=t.length>0;return(0,a.jsxs)(x.Zp,{className:"h-full","data-testid":"home-todo-widget",children:[(0,a.jsx)("h2",{className:"mb-3 text-lg font-semibold text-foreground",children:e("todo.title")}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3","data-testid":"todo-selector-row",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm text-muted-foreground min-w-0",children:[(0,a.jsx)("span",{className:"shrink-0",children:e("todo.repository")}),(0,a.jsx)("select",{value:n,onChange:e=>o(e.target.value),disabled:!F,"data-testid":"todo-repo-select",className:"min-w-0 flex-1 truncate rounded-md border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-sm text-surface-foreground disabled:opacity-50 sm:flex-initial sm:max-w-[16rem]",children:t.map(e=>{var t;return(0,a.jsx)("option",{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),F&&(0,a.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground","data-testid":"todo-remaining",children:e("todo.open",{count:y})})]}),F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(x.pd,{type:"text",value:c,onChange:e=>m(e.target.value),onKeyDown:C,maxLength:A.Ll,placeholder:e("todo.inputPlaceholder"),"data-testid":"todo-input",className:"w-auto flex-1 min-w-0"}),(0,a.jsx)(x.$n,{type:"button",variant:"primary",size:"sm",onClick:N,disabled:g||0===c.trim().length,"data-testid":"todo-add-button",className:"shrink-0",children:e("todo.add")})]}),p&&(0,a.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:p}),u&&0===d.length?(0,a.jsx)("ul",{className:"space-y-1","data-testid":"todo-loading",role:"status","aria-label":e("todo.loading"),children:[0,1,2].map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1",children:[(0,a.jsx)(x.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,a.jsx)(x.EA,{className:"h-4 ".concat(1===e?"w-2/3":"w-5/6")})]},e))}):0===d.length?(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:e("todo.empty")}):(0,a.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:d.map(t=>(0,a.jsxs)("li",{className:"flex flex-col gap-1 rounded-md px-1 py-1 hover:bg-muted group sm:flex-row sm:items-center sm:gap-2","data-testid":"todo-item",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("label",{className:"shrink-0 inline-flex min-h-[44px] min-w-[44px] cursor-pointer items-center justify-center sm:min-h-0 sm:min-w-0",children:(0,a.jsx)(x.Sc,{checked:t.done,onCheckedChange:()=>w(t),"data-testid":"todo-checkbox","aria-label":t.done?e("todo.markAsNotDone"):e("todo.markAsDone")})}),(0,a.jsx)("span",{className:"min-w-0 flex-1 break-words text-sm ".concat(t.done?"line-through text-muted-foreground":"text-foreground"),children:t.content})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2",children:[R(t)&&(0,a.jsx)("span",{className:"shrink-0 max-w-[8rem] truncate rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground","data-testid":"todo-repo-badge",title:R(t),children:R(t)}),(0,a.jsx)("button",{type:"button",onClick:()=>k(t),"aria-label":e("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,a.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id))})]}):(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e("todo.noRepositories")})]})}var M=s(37586),I=s(66685),T=s(24533),U=s(37772),z=s(6473);let L=[{key:"chat",href:"/chat",icon:(0,a.jsx)(M.A,{size:20,"aria-hidden":"true"})},{key:"sessions",href:"/sessions",icon:(0,a.jsx)(I.A,{size:20,"aria-hidden":"true"})},{key:"repositories",href:"/repositories",icon:(0,a.jsx)(T.A,{size:20,"aria-hidden":"true"})},{key:"review",href:"/review",icon:(0,a.jsx)(u.A,{size:20,"aria-hidden":"true"})},{key:"more",href:"/more",icon:(0,a.jsx)(U.A,{size:20,"aria-hidden":"true"})}];function D(){let e=(0,r.c)("common");return(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-5","data-testid":"home-quick-actions",children:L.map((t,s)=>{let n=e("nav.".concat(t.key));return(0,a.jsx)(c(),{href:t.href,"aria-label":n,className:"group block rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","data-testid":"quick-action-".concat(t.key),children:(0,a.jsxs)(x.Zp,{interactive:!0,padding:"sm",style:{animationDelay:(0,z.Lc)(s)},className:"flex h-full flex-col items-center justify-center gap-1.5 py-3 text-center hover:border-accent-300 dark:hover:border-accent-700 ".concat(z.qz),children:[(0,a.jsx)("span",{className:"text-muted-foreground group-hover:text-accent-600 dark:group-hover:text-accent-400 transition-colors",children:t.icon}),(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:n})]})},t.href)})})}function O(){let{worktrees:e,repositories:t,isLoading:s,error:i}=(0,o.Fn)(),r=s&&0===e.length;return(0,a.jsx)(n.GV,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsx)(d,{worktrees:e}),(0,a.jsx)(j,{worktrees:e,repositories:t,isLoading:r,error:i}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12","data-testid":"home-bento-grid",children:[(0,a.jsx)("div",{className:"md:col-span-8",children:(0,a.jsx)(C,{worktrees:e,isLoading:r})}),(0,a.jsx)("div",{className:"md:col-span-4",children:(0,a.jsx)(F,{})}),(0,a.jsx)("div",{className:"md:col-span-12",children:(0,a.jsx)(D,{})})]})]})})}},83012:(e,t,s)=>{"use strict";s.d(t,{Fx:()=>i,bg:()=>r,fw:()=>o});var a=s(53298),n=s(73683);function o(e,t){let s=new Date(e);return isNaN(s.getTime())?"":(0,a.m)(s,{addSuffix:!0,...t?{locale:t}:{}})}function i(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let s=Math.round((Date.now()-t.getTime())/1e3);if(s<45)return"now";let a=Math.round(s/60);if(a<60)return"".concat(a,"m ago");let n=Math.round(a/60);if(n<24)return"".concat(n,"h ago");let o=Math.round(n/24);return o<7?"".concat(o,"d ago"):o<30?"".concat(Math.round(o/7),"w ago"):o<365?"".concat(Math.round(o/30),"mo ago"):"".concat(Math.round(o/365),"y ago")}function r(e,t){return!(e instanceof Date)||isNaN(e.getTime())?"":(0,n.GP)(e,"PPp",t?{locale:t}:void 0)}},85872:(e,t,s)=>{"use strict";async function a(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}s.d(t,{$C:()=>n,Ar:()=>i,KG:()=>o});let n={async list(e){var t;let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"));return s.ok?null!=(t=(await s.json()).todos)?t:[]:a(s,"Failed to load todos")},async listAll(){var e;let t=await fetch("/api/todos");return t.ok?null!=(e=(await t.json()).todos)?e:[]:a(t,"Failed to load todos")},async create(e,t){let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});return s.ok?(await s.json()).todo:a(s,"Failed to create todo")},async update(e,t,s){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return n.ok?(await n.json()).todo:a(n,"Failed to update todo")},async remove(e,t){let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});s.ok||await a(s,"Failed to delete todo")}},o=["todo","doing","done"],i={async list(e){var t;let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"));return s.ok?null!=(t=(await s.json()).todos)?t:[]:a(s,"Failed to load todos")},async create(e,t,s){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(void 0!==s?{content:t,detail:s}:{content:t})});return n.ok?(await n.json()).todo:a(n,"Failed to create todo")},async update(e,t,s){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return n.ok?(await n.json()).todo:a(n,"Failed to update todo")},async remove(e,t){let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});s.ok||await a(s,"Failed to delete todo")},async reorder(e,t){let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({todoIds:t})});s.ok||await a(s,"Failed to reorder todos")}}}},e=>{e.O(0,[6809,4909,2770,3165,4974,9948,6402,744,7347,4560,8441,1255,7358],()=>e(e.s=54799)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{6473:(e,t,s)=>{"use strict";s.d(t,{Lc:()=>n,qz:()=>a});let a="animate-in fade-in-0 slide-in-from-bottom-2 fill-mode-backwards duration-300";function n(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:40,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;if(Number.isFinite(e)&&!(e<=0)&&!(e>=s))return"".concat(e*t,"ms")}},53292:(e,t,s)=>{"use strict";s.d(t,{Ll:()=>a,bu:()=>n});let a=2e3,n=4e3},54799:(e,t,s)=>{Promise.resolve().then(s.bind(s,75590))},75590:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>O});var a=s(95155),n=s(4560),o=s(66966),i=s(12115),r=s(18955);function d(e){let{worktrees:t}=e,s=(0,r.c)("home"),{runningCount:n,waitingCount:o}=(0,i.useMemo)(()=>{let e=0,s=0;for(let a of t)a.isSessionRunning&&(e++,a.isWaitingForResponse&&s++);return{runningCount:e,waitingCount:s}},[t]);return(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:s("title")}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":"home-subline",children:[(0,a.jsx)("span",{className:"tabular-nums","data-testid":"subline-running",children:n})," ",s("running"),(0,a.jsx)("span",{"aria-hidden":"true",children:" \xb7 "}),(0,a.jsx)("span",{className:"tabular-nums","data-testid":"subline-waiting",children:o})," ",s("waiting")]})]})}var l=s(52619),c=s.n(l),m=s(65229),u=s(61362),h=s(99051),x=s(744),g=s(2317);function f(e){return"boolean"==typeof e}let p=[{key:"registerRepository",href:"/repositories"},{key:"sendFirstMessage",href:"/sessions"}];function j(e){let{worktrees:t,repositories:s,isLoading:n=!1,error:o=null}=e,d=(0,r.c)("home"),{value:l,setValue:j}=(0,g.V)({key:"commandmate:onboarding-dismissed",defaultValue:!1,validate:f}),[b,y]=(0,i.useState)(!1);(0,i.useEffect)(()=>y(!0),[]);let v=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{hasRepository:(null!=t?t:[]).length>0,hasSentMessage:(null!=e?e:[]).some(e=>!!e.lastUserMessageAt)}}(t,s),N=v.hasRepository&&v.hasSentMessage,w=b&&!n&&null===o;return((0,i.useEffect)(()=>{w&&N&&!l&&j(!0)},[w,N,l,j]),!w||N||l)?null:(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsxs)(x.Zp,{variant:"elevated","data-testid":"onboarding-checklist",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d("onboarding.title")}),(0,a.jsx)(x.$n,{variant:"ghost",size:"sm","aria-label":d("onboarding.dismiss"),"data-testid":"onboarding-dismiss",onClick:()=>j(!0),children:(0,a.jsx)(m.A,{size:16,"aria-hidden":"true"})})]}),(0,a.jsx)("ol",{className:"mt-3 space-y-3",children:p.map(e=>{let{key:t,href:s}=e,n="registerRepository"===t?v.hasRepository:v.hasSentMessage;return(0,a.jsxs)("li",{className:"flex items-center gap-3","data-testid":"onboarding-step-".concat(t),"data-complete":n,children:[n?(0,a.jsx)(u.A,{size:20,className:"shrink-0 text-success-foreground","aria-hidden":"true"}):(0,a.jsx)(h.A,{size:20,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 text-sm ".concat(n?"text-muted-foreground line-through":"text-foreground"),children:d("onboarding.steps.".concat(t))}),!n&&(0,a.jsx)(c(),{href:s,"data-testid":"onboarding-action-".concat(t),className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:bg-accent-500 dark:hover:bg-accent-600",children:d("onboarding.actions.".concat(t))})]},t)})})]})})}var b=s(87531);function y(e){let{worktrees:t,isLoading:s=!1}=e,n=(0,r.c)("home"),{runningCount:o,waitingCount:d}=(0,i.useMemo)(()=>{let e=0,s=0;for(let a of t)a.isSessionRunning&&(e++,a.isWaitingForResponse&&s++);return{runningCount:e,waitingCount:s}},[t]);return s?(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3","data-testid":"home-session-summary-loading",role:"status","aria-label":n("sessionSummary.loading"),children:[0,1].map(e=>(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsx)("div",{className:"flex h-4 items-center",children:(0,a.jsx)(x.EA,{className:"h-3 w-16"})}),(0,a.jsx)("div",{className:"flex h-9 items-center",children:(0,a.jsx)(x.EA,{className:"h-7 w-10"})})]},e))}):(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3","data-testid":"home-session-summary",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(x.md,{status:o>0?"running":"idle",size:"sm",label:n("sessionSummary.running")}),n("sessionSummary.running")]}),(0,a.jsx)("div",{className:(0,b.cn)("text-3xl font-bold tabular-nums",o>0?"text-foreground":"text-muted-foreground"),"data-testid":"running-count",children:o})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(x.md,{status:d>0?"waiting":"idle",size:"sm",label:n("sessionSummary.waiting")}),n("sessionSummary.waiting")]}),(0,a.jsx)("div",{className:(0,b.cn)("text-3xl font-bold tabular-nums",d>0?"text-foreground":"text-muted-foreground"),"data-testid":"waiting-count",children:d})]})]})}var v=s(7636),N=s(83012);function w(e){var t;return null!=(t=e.lastUserMessageAt)?t:e.updatedAt}function k(e){let{worktrees:t,limit:s=5,isLoading:n=!1}=e,o=(0,r.c)("home"),d=(0,i.useMemo)(()=>[...t].sort((e,t)=>(0,v.nO)(w(e),w(t))).slice(0,s),[t,s]);return n?(0,a.jsx)("ul",{className:"space-y-1","data-testid":"recent-sessions-loading",role:"status","aria-label":o("recentSessions.loading"),children:Array.from({length:s},(e,t)=>(0,a.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5",children:[(0,a.jsx)(x.EA,{className:"h-2 w-2 shrink-0 rounded-full"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,a.jsx)(x.EA,{className:"h-4 w-2/5"}),(0,a.jsx)(x.EA,{className:"h-3 w-3/5"})]}),(0,a.jsx)(x.EA,{className:"h-3 w-8 shrink-0"})]},t))}):0===d.length?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"recent-sessions-empty",children:o("recentSessions.empty")}),(0,a.jsx)(c(),{href:"/repositories","data-testid":"recent-sessions-cta",className:"inline-block text-sm font-medium text-accent-600 transition-colors hover:text-accent-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 dark:hover:text-accent-300",children:o("recentSessions.cta")})]}):(0,a.jsx)("ul",{className:"space-y-1","data-testid":"recent-sessions",children:d.map(e=>{var t;let s=w(e),n=s?(0,N.Fx)(String(s)):"";return(0,a.jsx)("li",{children:(0,a.jsxs)(c(),{href:"/worktrees/".concat(e.id),"data-testid":"recent-session-".concat(e.id),className:"flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,a.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full ".concat(e.isWaitingForResponse?"bg-warning":e.isSessionRunning?"bg-success":"bg-muted-foreground"),"aria-hidden":"true"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block truncate text-sm font-medium text-foreground",children:null!=(t=e.repositoryDisplayName)?t:e.repositoryName}),(0,a.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.name})]}),n&&(0,a.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:n})]})},e.id)})})}function C(e){let{worktrees:t,isLoading:s=!1}=e,n=(0,r.c)("home");return(0,a.jsxs)(x.Zp,{variant:"elevated",className:"h-full","data-testid":"session-overview-tile",children:[(0,a.jsx)("h2",{className:"mb-3 text-lg font-semibold text-foreground",children:n("sessionOverview.title")}),(0,a.jsx)(y,{worktrees:t,isLoading:s}),(0,a.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:n("sessionOverview.recentSessions")}),(0,a.jsx)(c(),{href:"/sessions",className:"text-xs text-accent-600 hover:underline dark:text-accent-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","data-testid":"session-overview-view-all",children:n("sessionOverview.viewAll")})]}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(k,{worktrees:t,isLoading:s})})]})}var S=s(85872),A=s(53292);let E="commandmate-home-todo-repo";function R(e){var t;return(null==(t=e.repositoryDisplayName)?void 0:t.trim())||e.repositoryName||""}function F(){let e=(0,r.c)("home"),[t,s]=(0,i.useState)([]),[n,o]=(0,i.useState)(""),[d,l]=(0,i.useState)([]),[c,m]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[p,j]=(0,i.useState)(null),b=(0,i.useRef)(!1),y=(0,i.useMemo)(()=>d.filter(e=>!e.done).length,[d]);(0,i.useEffect)(()=>{!async function(){try{var e;let t=await fetch("/api/worktrees");if(!t.ok)return;let a=(null!=(e=(await t.json()).repositories)?e:[]).map(e=>({id:e.id,path:e.path,name:e.name,displayName:e.displayName}));if(s(a),a.length>0){let e=localStorage.getItem(E),t=e&&a.some(t=>t.id===e)?e:a[0].id;o(t)}}catch(e){}finally{b.current=!0}}()},[]);let v=(0,i.useCallback)(async()=>{h(!0),j(null);try{let e=await S.$C.listAll();l(e)}catch(t){j(t instanceof Error?t.message:e("todo.errors.load")),l([])}finally{h(!1)}},[e]);(0,i.useEffect)(()=>{v()},[v]),(0,i.useEffect)(()=>{n&&localStorage.setItem(E,n)},[n]);let N=(0,i.useCallback)(async()=>{let t=c.trim();if(t&&n&&!g){f(!0),j(null);try{await S.$C.create(n,t),m(""),await v()}catch(t){j(t instanceof Error?t.message:e("todo.errors.add"))}finally{f(!1)}}},[c,n,g,v,e]),w=(0,i.useCallback)(async t=>{l(e=>e.map(e=>e.id===t.id?{...e,done:!e.done}:e)),j(null);try{await S.$C.update(t.repositoryId,t.id,{done:!t.done})}catch(t){j(t instanceof Error?t.message:e("todo.errors.update")),v()}},[v,e]),k=(0,i.useCallback)(async t=>{j(null);try{await S.$C.remove(t.repositoryId,t.id),l(e=>e.filter(e=>e.id!==t.id))}catch(t){j(t instanceof Error?t.message:e("todo.errors.delete"))}},[e]),C=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),N())},[N]),F=t.length>0;return(0,a.jsxs)(x.Zp,{className:"h-full","data-testid":"home-todo-widget",children:[(0,a.jsx)("h2",{className:"mb-3 text-lg font-semibold text-foreground",children:e("todo.title")}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3","data-testid":"todo-selector-row",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm text-muted-foreground min-w-0",children:[(0,a.jsx)("span",{className:"shrink-0",children:e("todo.repository")}),(0,a.jsx)("select",{value:n,onChange:e=>o(e.target.value),disabled:!F,"data-testid":"todo-repo-select",className:"min-w-0 flex-1 truncate rounded-md border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-sm text-surface-foreground disabled:opacity-50 sm:flex-initial sm:max-w-[16rem]",children:t.map(e=>{var t;return(0,a.jsx)("option",{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),F&&(0,a.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground","data-testid":"todo-remaining",children:e("todo.open",{count:y})})]}),F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(x.pd,{type:"text",value:c,onChange:e=>m(e.target.value),onKeyDown:C,maxLength:A.Ll,placeholder:e("todo.inputPlaceholder"),"data-testid":"todo-input",className:"w-auto flex-1 min-w-0"}),(0,a.jsx)(x.$n,{type:"button",variant:"primary",size:"sm",onClick:N,disabled:g||0===c.trim().length,"data-testid":"todo-add-button",className:"shrink-0",children:e("todo.add")})]}),p&&(0,a.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:p}),u&&0===d.length?(0,a.jsx)("ul",{className:"space-y-1","data-testid":"todo-loading",role:"status","aria-label":e("todo.loading"),children:[0,1,2].map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1",children:[(0,a.jsx)(x.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,a.jsx)(x.EA,{className:"h-4 ".concat(1===e?"w-2/3":"w-5/6")})]},e))}):0===d.length?(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:e("todo.empty")}):(0,a.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:d.map(t=>(0,a.jsxs)("li",{className:"flex flex-col gap-1 rounded-md px-1 py-1 hover:bg-muted group sm:flex-row sm:items-center sm:gap-2","data-testid":"todo-item",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("label",{className:"shrink-0 inline-flex min-h-[44px] min-w-[44px] cursor-pointer items-center justify-center sm:min-h-0 sm:min-w-0",children:(0,a.jsx)(x.Sc,{checked:t.done,onCheckedChange:()=>w(t),"data-testid":"todo-checkbox","aria-label":t.done?e("todo.markAsNotDone"):e("todo.markAsDone")})}),(0,a.jsx)("span",{className:"min-w-0 flex-1 break-words text-sm ".concat(t.done?"line-through text-muted-foreground":"text-foreground"),children:t.content})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2",children:[R(t)&&(0,a.jsx)("span",{className:"shrink-0 max-w-[8rem] truncate rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground","data-testid":"todo-repo-badge",title:R(t),children:R(t)}),(0,a.jsx)("button",{type:"button",onClick:()=>k(t),"aria-label":e("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,a.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id))})]}):(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e("todo.noRepositories")})]})}var M=s(37586),I=s(66685),T=s(24533),U=s(37772),z=s(6473);let L=[{key:"chat",href:"/chat",icon:(0,a.jsx)(M.A,{size:20,"aria-hidden":"true"})},{key:"sessions",href:"/sessions",icon:(0,a.jsx)(I.A,{size:20,"aria-hidden":"true"})},{key:"repositories",href:"/repositories",icon:(0,a.jsx)(T.A,{size:20,"aria-hidden":"true"})},{key:"review",href:"/review",icon:(0,a.jsx)(u.A,{size:20,"aria-hidden":"true"})},{key:"more",href:"/more",icon:(0,a.jsx)(U.A,{size:20,"aria-hidden":"true"})}];function D(){let e=(0,r.c)("common");return(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-5","data-testid":"home-quick-actions",children:L.map((t,s)=>{let n=e("nav.".concat(t.key));return(0,a.jsx)(c(),{href:t.href,"aria-label":n,className:"group block rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","data-testid":"quick-action-".concat(t.key),children:(0,a.jsxs)(x.Zp,{interactive:!0,padding:"sm",style:{animationDelay:(0,z.Lc)(s)},className:"flex h-full flex-col items-center justify-center gap-1.5 py-3 text-center hover:border-accent-300 dark:hover:border-accent-700 ".concat(z.qz),children:[(0,a.jsx)("span",{className:"text-muted-foreground group-hover:text-accent-600 dark:group-hover:text-accent-400 transition-colors",children:t.icon}),(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:n})]})},t.href)})})}function O(){let{worktrees:e,repositories:t,isLoading:s,error:i}=(0,o.Fn)(),r=s&&0===e.length;return(0,a.jsx)(n.GV,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsx)(d,{worktrees:e}),(0,a.jsx)(j,{worktrees:e,repositories:t,isLoading:r,error:i}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12","data-testid":"home-bento-grid",children:[(0,a.jsx)("div",{className:"md:col-span-8",children:(0,a.jsx)(C,{worktrees:e,isLoading:r})}),(0,a.jsx)("div",{className:"md:col-span-4",children:(0,a.jsx)(F,{})}),(0,a.jsx)("div",{className:"md:col-span-12",children:(0,a.jsx)(D,{})})]})]})})}},83012:(e,t,s)=>{"use strict";s.d(t,{Fx:()=>i,bg:()=>r,fw:()=>o});var a=s(53298),n=s(73683);function o(e,t){let s=new Date(e);return isNaN(s.getTime())?"":(0,a.m)(s,{addSuffix:!0,...t?{locale:t}:{}})}function i(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let s=Math.round((Date.now()-t.getTime())/1e3);if(s<45)return"now";let a=Math.round(s/60);if(a<60)return"".concat(a,"m ago");let n=Math.round(a/60);if(n<24)return"".concat(n,"h ago");let o=Math.round(n/24);return o<7?"".concat(o,"d ago"):o<30?"".concat(Math.round(o/7),"w ago"):o<365?"".concat(Math.round(o/30),"mo ago"):"".concat(Math.round(o/365),"y ago")}function r(e,t){return!(e instanceof Date)||isNaN(e.getTime())?"":(0,n.GP)(e,"PPp",t?{locale:t}:void 0)}},85872:(e,t,s)=>{"use strict";async function a(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}s.d(t,{$C:()=>n,Ar:()=>i,KG:()=>o});let n={async list(e){var t;let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"));return s.ok?null!=(t=(await s.json()).todos)?t:[]:a(s,"Failed to load todos")},async listAll(){var e;let t=await fetch("/api/todos");return t.ok?null!=(e=(await t.json()).todos)?e:[]:a(t,"Failed to load todos")},async create(e,t){let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});return s.ok?(await s.json()).todo:a(s,"Failed to create todo")},async update(e,t,s){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return n.ok?(await n.json()).todo:a(n,"Failed to update todo")},async remove(e,t){let s=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});s.ok||await a(s,"Failed to delete todo")}},o=["todo","doing","done"],i={async list(e){var t;let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"));return s.ok?null!=(t=(await s.json()).todos)?t:[]:a(s,"Failed to load todos")},async create(e,t,s){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(void 0!==s?{content:t,detail:s}:{content:t})});return n.ok?(await n.json()).todo:a(n,"Failed to create todo")},async update(e,t,s){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return n.ok?(await n.json()).todo:a(n,"Failed to update todo")},async remove(e,t){let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});s.ok||await a(s,"Failed to delete todo")},async reorder(e,t){let s=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({todoIds:t})});s.ok||await a(s,"Failed to reorder todos")}}}},e=>{e.O(0,[6809,4909,2770,3165,4974,9948,6402,744,6488,4560,8441,1255,7358],()=>e(e.s=54799)),_N_E=e.O()}]);
|
package/.next/static/chunks/app/repositories/{page-ace9134ac165a6de.js → page-d214522ab8792ce7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3135],{540:(e,t,s)=>{Promise.resolve().then(s.bind(s,22743))},9219:(e,t,s)=>{"use strict";s.d(t,{k:()=>i});var r=s(95155),a=s(12115),l=s(744),n=s(87531);function i(e){let{onRefresh:t,enabled:s=!0,className:i,children:o}=e,{containerRef:c,pullDistance:d,isRefreshing:u,isPulling:m}=function(e){let{onRefresh:t,enabled:s=!0,threshold:r=64,maxPull:l=96,resistance:n=.5}=e,i=(0,a.useRef)(null),[o,c]=(0,a.useState)(0),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(!1),x=(0,a.useRef)(null),h=(0,a.useRef)(0),g=(0,a.useRef)(!1);g.current=d;let f=(0,a.useCallback)(()=>{x.current=null,h.current=0,c(0),p(!1)},[]),b=(0,a.useCallback)(e=>{if(!s||g.current)return;let t=i.current;t&&!(t.scrollTop>0)&&(x.current=e.touches[0].clientY,h.current=0)},[s]),v=(0,a.useCallback)(e=>{if(null===x.current)return;let t=i.current;if(!t)return;if(t.scrollTop>0)return void f();let s=e.touches[0].clientY-x.current;if(s<=0){0!==h.current&&(h.current=0,c(0),p(!1));return}e.cancelable&&e.preventDefault();let r=Math.min(s*n,l);h.current=r,c(r),p(!0)},[n,l,f]),y=(0,a.useCallback)(async()=>{u(!0),p(!1),c(r);try{await Promise.resolve(t())}finally{u(!1),c(0)}},[t,r]),j=(0,a.useCallback)(()=>{if(null===x.current)return;let e=h.current>=r&&!g.current;x.current=null,h.current=0,e?y():(c(0),p(!1))},[r,y]);return(0,a.useEffect)(()=>{let e=i.current;if(e)return e.addEventListener("touchstart",b,{passive:!0}),e.addEventListener("touchmove",v,{passive:!1}),e.addEventListener("touchend",j,{passive:!0}),e.addEventListener("touchcancel",j,{passive:!0}),()=>{e.removeEventListener("touchstart",b),e.removeEventListener("touchmove",v),e.removeEventListener("touchend",j),e.removeEventListener("touchcancel",j)}},[b,v,j]),{containerRef:i,pullDistance:o,isRefreshing:d,isPulling:m}}({onRefresh:t,enabled:s,threshold:64}),p=u||d>0,x=u?1:Math.min(d/64,1);return(0,r.jsxs)("div",{ref:c,className:(0,n.cn)("relative overflow-auto",i),style:{overscrollBehaviorY:"contain"},"data-testid":"pull-to-refresh",children:[(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex justify-center",style:{transform:"translateY(".concat(p?Math.max(d-24,8):-32,"px)"),opacity:x,transition:m?"none":"transform 0.2s ease-out, opacity 0.2s ease-out"},"data-testid":"pull-to-refresh-indicator",role:"status","aria-hidden":!u,children:(0,r.jsx)(l.y$,{size:"sm",variant:"accent"})}),(0,r.jsx)("div",{style:{transform:p?"translateY(".concat(d,"px)"):void 0,transition:m?"none":"transform 0.2s ease-out"},children:o})]})}},18514:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(71847).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},22743:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var r=s(95155),a=s(12115),l=s(4560),n=s(9219),i=s(38218),o=s(18955),c=s(744),d=s(80344);class u{static getInstance(){return u.instance||(u.instance=new u),u.instance}normalize(e){let t=e.match(/^ssh:\/\/git@([^:\/]+)(:\d+)?\/(.+?)(\.git)?$/);if(t)return"https://".concat(t[1],"/").concat(t[3]).toLowerCase().replace(/\/$/,"");let s=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return s?"https://".concat(s[1],"/").concat(s[2]).toLowerCase().replace(/\/$/,""):e.replace(/\.git\/?$/,"").replace(/\/$/,"").toLowerCase()}isSameRepository(e,t){return this.normalize(e)===this.normalize(t)}extractRepoName(e){let t=e.match(/^ssh:\/\/git@[^\/]+\/(.+?)(\.git)?$/);if(t){let e=t[1].split("/");return e[e.length-1]}let s=e.match(/:(.+?)(\.git)?$/);if(s&&e.startsWith("git@")){let e=s[1].split("/");return e[e.length-1]}let r=e.match(/\/([^\/]+?)(\.git)?$/);return r?r[1]:""}getUrlType(e){return e.startsWith("https://")?"https":e.startsWith("git@")||e.startsWith("ssh://")?"ssh":null}validate(e){if(!e||"string"!=typeof e||""===e.trim())return{valid:!1,error:"EMPTY_URL"};let t=e.trim();return t.startsWith("https://")?/^https:\/\/[^\/]+\/[^\/]+\/[^\/]+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("git@")?/^git@[^:]+:.+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("ssh://")?/^ssh:\/\/git@[^\/]+(:\d+)?\/[^\/]+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:{valid:!1,error:"INVALID_URL_FORMAT"}}constructor(){}}function m(e){let{onRepositoryAdded:t}=e,s=(0,o.c)("common"),[l,n]=(0,a.useState)(!1),[i,m]=(0,a.useState)("local"),[p,x]=(0,a.useState)(""),[h,g]=(0,a.useState)(""),[f,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),[S,C]=(0,a.useState)(null),[E,R]=(0,a.useState)(null),L=u.getInstance(),$=(0,a.useCallback)(async e=>{try{let a=await d.Rx.getCloneStatus(e);if("completed"===a.status)R(s("repositories.cloneSuccess")),N(!1),k(null),g(""),n(!1),t&&t();else if("failed"===a.status){var r;C((null==(r=a.error)?void 0:r.message)||s("repositories.cloneFailed")),N(!1),k(null)}else("running"===a.status||"pending"===a.status)&&setTimeout(()=>$(e),2e3)}catch(e){C((0,d.hS)(e)),N(!1),k(null)}},[t,s]);(0,a.useEffect)(()=>{w&&j&&$(w)},[w,j]);let A=async e=>{if(e.preventDefault(),!p.trim())return void C(s("repositories.pathRequired"));C(null),R(null),b(!0);try{let e=await d.Rx.scan(p);R(e.message),x(""),n(!1),t&&t()}catch(e){C((0,d.hS)(e))}finally{b(!1)}},D=async e=>{if(e.preventDefault(),!h.trim())return void C(s("repositories.urlRequired"));let t=L.validate(h.trim());if(!t.valid)return void("EMPTY_URL"===t.error?C(s("repositories.urlRequired")):C(s("repositories.urlInvalid")));C(null),R(null),N(!0);try{let e=await d.Rx.clone(h.trim());k(e.jobId)}catch(e){C((0,d.hS)(e)),N(!1)}},_=async()=>{C(null),R(null),y(!0);try{let e=await d.Rx.sync();R(e.message),t&&t()}catch(e){C((0,d.hS)(e))}finally{y(!1)}},z=()=>{n(!1),x(""),g(""),C(null),m("local")};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[!l&&(0,r.jsxs)(c.$n,{variant:"primary",size:"sm",onClick:()=>n(!0),children:["+ ",s("repositories.add")]}),(0,r.jsx)(c.$n,{variant:"secondary",size:"sm",onClick:_,disabled:v,children:v?s("repositories.syncing"):s("repositories.syncAll")})]}),l&&(0,r.jsx)(c.Zp,{padding:"lg",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{children:(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2 text-foreground",children:s("repositories.addNewTitle")})}),(0,r.jsxs)(c.tU,{value:i,onValueChange:e=>m(e),children:[(0,r.jsxs)(c.j7,{className:"w-full",children:[(0,r.jsx)(c.Xi,{value:"local",children:s("repositories.localPathTab")}),(0,r.jsx)(c.Xi,{value:"url",children:s("repositories.cloneUrlTab")})]}),(0,r.jsx)(c.av,{value:"local",children:(0,r.jsxs)("form",{onSubmit:A,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:s("repositories.localPathDescription")}),(0,r.jsx)("label",{htmlFor:"repositoryPath",className:"block text-sm font-medium text-foreground mb-2",children:s("repositories.localPathLabel")}),(0,r.jsx)(c.pd,{id:"repositoryPath",type:"text",value:p,onChange:e=>x(e.target.value),placeholder:"/absolute/path/to/repository",className:"font-mono",disabled:f}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("repositories.localPathExample")})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{type:"submit",variant:"primary",disabled:f||!p.trim(),children:f?s("repositories.scanning"):s("repositories.scan")}),(0,r.jsx)(c.$n,{type:"button",variant:"ghost",onClick:z,disabled:f,children:s("cancel")})]})]})}),(0,r.jsx)(c.av,{value:"url",children:(0,r.jsxs)("form",{onSubmit:D,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:s("repositories.cloneUrlDescription")}),(0,r.jsx)("label",{htmlFor:"cloneUrl",className:"block text-sm font-medium text-foreground mb-2",children:s("repositories.cloneUrlLabel")}),(0,r.jsx)(c.pd,{id:"cloneUrl",type:"text",value:h,onChange:e=>g(e.target.value),placeholder:"https://github.com/user/repo.git",className:"font-mono",disabled:j}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("repositories.cloneUrlHelp")})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{type:"submit",variant:"primary",disabled:j||!h.trim(),children:j?s("repositories.cloning"):s("repositories.clone")}),(0,r.jsx)(c.$n,{type:"button",variant:"ghost",onClick:z,disabled:j,children:s("cancel")})]})]})})]})]})}),E&&(0,r.jsx)("div",{className:"p-4 bg-success-subtle border border-success-border rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-success-foreground",children:E})}),S&&(0,r.jsx)("div",{className:"p-4 bg-danger-subtle border border-danger-border rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-danger-foreground",children:S})})]})}var p=s(18514),x=s(87531);let h={id:null,value:"",error:null,saving:!1};function g(){return(0,r.jsx)("thead",{className:"bg-muted border-b border-border",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Name"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Display name"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Visibility"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Path"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Worktrees"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Status"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Actions"})]})})}function f(e){let{repo:t,pending:s,onToggle:a}=e,l=t.visible;return(0,r.jsxs)("button",{type:"button",role:"switch","aria-checked":l,"aria-label":l?"Hide ".concat(t.name," from sidebar"):"Show ".concat(t.name," in sidebar"),"data-testid":"visibility-toggle-".concat(t.id),onClick:()=>a(t),disabled:s,className:(0,x.cn)("inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-muted hover:text-foreground","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-60 disabled:cursor-not-allowed"),children:[(0,r.jsx)(c.md,{status:l?"ready":"idle",size:"sm",label:l?"Visible":"Hidden","aria-hidden":"true"}),l?"Visible":"Hidden"]})}let b=(0,a.memo)(function(e){let{refreshKey:t,onChanged:s}=e,l=(0,o.c)("common"),[n,i]=(0,a.useState)([]),[u,m]=(0,a.useState)(!0),[x,b]=(0,a.useState)(null),[v,y]=(0,a.useState)(h),[j,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(new Set),S=(0,a.useCallback)(async()=>{m(!0),b(null);try{let e=await d.Rx.list();i(e.repositories)}catch(e){b((0,d.hS)(e))}finally{m(!1)}},[]);(0,a.useEffect)(()=>{S()},[S,t]);let C=(0,a.useCallback)(e=>{var t;y({id:e.id,value:null!=(t=e.displayName)?t:"",error:null,saving:!1}),N(null)},[]),E=(0,a.useCallback)(()=>{y(h)},[]),R=(0,a.useCallback)(e=>{y(t=>{if(null===t.id)return t;let s=e.length>100?"Display name must be ".concat(100," characters or less"):null;return{...t,value:e,error:s}})},[]),L=(0,a.useCallback)(async e=>{let t=v.value.trim();if(t.length>100)return void y(e=>({...e,error:"Display name must be ".concat(100," characters or less")}));y(e=>({...e,saving:!0,error:null}));try{let r=0===t.length?null:t,a=await d.Rx.updateDisplayName(e.id,r);i(t=>t.map(t=>t.id===e.id?{...t,...a.repository}:t)),y(h),N({type:"success",message:"Display name updated"}),s&&s()}catch(t){let e=(0,d.hS)(t);y(t=>({...t,saving:!1,error:e})),N({type:"error",message:e})}},[v.value,s]),$=(0,a.useCallback)((e,t)=>{"Enter"===e.key?(e.preventDefault(),L(t)):"Escape"===e.key&&(e.preventDefault(),E())},[E,L]),A=(0,a.useCallback)(async e=>{if(w.has(e.id))return;let t=!e.visible;k(t=>{let s=new Set(t);return s.add(e.id),s}),i(s=>s.map(s=>s.id===e.id?{...s,visible:t}:s)),N(null);try{let r=await d.Rx.updateVisibility(e.id,t);i(t=>t.map(t=>t.id===e.id?{...t,...r.repository}:t)),s&&s()}catch(t){i(t=>t.map(t=>t.id===e.id?{...e}:t)),N({type:"error",message:(0,d.hS)(t)})}finally{k(t=>{let s=new Set(t);return s.delete(e.id),s})}},[s,w]);return u&&0===n.length?(0,r.jsx)(c.Zp,{padding:"none",children:(0,r.jsx)("div",{className:"overflow-x-auto","data-testid":"repository-list-loading",role:"status","aria-label":l("repositories.loading"),children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)(g,{}),(0,r.jsx)("tbody",{children:[0,1,2].map(e=>(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-24"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-20"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-16"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-48"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-10"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-14"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-20"})})]},e))})]})})}):x?(0,r.jsx)(c.Zp,{padding:"lg",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm text-danger-foreground",children:["Failed to load repositories: ",x]}),(0,r.jsx)(c.$n,{variant:"secondary",size:"sm",onClick:()=>void S(),children:"Retry"})]})}):(0,r.jsxs)("div",{className:"space-y-3",children:[j&&(0,r.jsx)("div",{role:"status",className:"p-3 rounded-lg text-sm ".concat("success"===j.type?"bg-success-subtle border border-success-border text-success-foreground":"bg-danger-subtle border border-danger-border text-danger-foreground"),children:j.message}),(0,r.jsx)(c.Zp,{padding:"none",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)(g,{}),(0,r.jsxs)("tbody",{children:[0===n.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:7,className:"px-4 py-6 text-center text-muted-foreground",children:l("repositories.empty")})}),n.map(e=>{let t=v.id===e.id;return(0,r.jsxs)("tr",{className:"border-b border-border","data-testid":"repository-row-".concat(e.id),children:[(0,r.jsx)("td",{className:"px-4 py-3 align-top text-foreground",children:e.name}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:t?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(c.pd,{"aria-label":"Edit display name for ".concat(e.name),type:"text",value:v.value,disabled:v.saving,maxLength:101,onChange:e=>R(e.target.value),onKeyDown:t=>$(t,e)}),v.error&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground",children:v.error})]}):e.displayName?(0,r.jsx)("span",{className:"text-foreground",children:e.displayName}):(0,r.jsx)("span",{className:"text-muted-foreground","aria-hidden":"true",children:"—"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(f,{repo:e,pending:w.has(e.id),onToggle:A})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)("span",{className:"block max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:e.path,children:e.path})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top text-foreground",children:e.worktreeCount}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,r.jsx)(c.md,{status:e.enabled?"ready":"idle",size:"sm",label:e.enabled?"Enabled":"Disabled","aria-hidden":"true"}),e.enabled?"Enabled":"Disabled"]})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:t?(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{variant:"primary",size:"sm",onClick:()=>void L(e),disabled:v.saving||null!==v.error,children:v.saving?"Saving...":"Save"}),(0,r.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:E,disabled:v.saving,children:"Cancel"})]}):(0,r.jsx)(c.$n,{variant:"ghost",size:"sm",className:"px-2",onClick:()=>C(e),"aria-label":"Edit display name for ".concat(e.name),children:(0,r.jsx)(p.A,{className:"h-4 w-4","aria-hidden":"true"})})})]},e.id)})]})]})})})]})});function v(){let e=(0,i.a)(),[t,s]=(0,a.useState)(0),o=(0,a.useCallback)(()=>{s(e=>e+1)},[]),c=(0,a.useCallback)(async()=>{s(e=>e+1),await new Promise(e=>setTimeout(e,500))},[]);return(0,r.jsx)(l.GV,{children:(0,r.jsxs)(n.k,{onRefresh:c,enabled:e,className:"container-custom py-8 h-full",children:[(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Repositories"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Manage repositories and worktrees."})]}),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(m,{onRepositoryAdded:o}),(0,r.jsx)(b,{refreshKey:t,onChanged:o})]})]})})}}},e=>{e.O(0,[6809,4909,2770,3165,4974,6402,744,7347,4560,8441,1255,7358],()=>e(e.s=540)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3135],{540:(e,t,s)=>{Promise.resolve().then(s.bind(s,22743))},9219:(e,t,s)=>{"use strict";s.d(t,{k:()=>i});var r=s(95155),a=s(12115),l=s(744),n=s(87531);function i(e){let{onRefresh:t,enabled:s=!0,className:i,children:o}=e,{containerRef:c,pullDistance:d,isRefreshing:u,isPulling:m}=function(e){let{onRefresh:t,enabled:s=!0,threshold:r=64,maxPull:l=96,resistance:n=.5}=e,i=(0,a.useRef)(null),[o,c]=(0,a.useState)(0),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(!1),x=(0,a.useRef)(null),h=(0,a.useRef)(0),g=(0,a.useRef)(!1);g.current=d;let f=(0,a.useCallback)(()=>{x.current=null,h.current=0,c(0),p(!1)},[]),b=(0,a.useCallback)(e=>{if(!s||g.current)return;let t=i.current;t&&!(t.scrollTop>0)&&(x.current=e.touches[0].clientY,h.current=0)},[s]),v=(0,a.useCallback)(e=>{if(null===x.current)return;let t=i.current;if(!t)return;if(t.scrollTop>0)return void f();let s=e.touches[0].clientY-x.current;if(s<=0){0!==h.current&&(h.current=0,c(0),p(!1));return}e.cancelable&&e.preventDefault();let r=Math.min(s*n,l);h.current=r,c(r),p(!0)},[n,l,f]),y=(0,a.useCallback)(async()=>{u(!0),p(!1),c(r);try{await Promise.resolve(t())}finally{u(!1),c(0)}},[t,r]),j=(0,a.useCallback)(()=>{if(null===x.current)return;let e=h.current>=r&&!g.current;x.current=null,h.current=0,e?y():(c(0),p(!1))},[r,y]);return(0,a.useEffect)(()=>{let e=i.current;if(e)return e.addEventListener("touchstart",b,{passive:!0}),e.addEventListener("touchmove",v,{passive:!1}),e.addEventListener("touchend",j,{passive:!0}),e.addEventListener("touchcancel",j,{passive:!0}),()=>{e.removeEventListener("touchstart",b),e.removeEventListener("touchmove",v),e.removeEventListener("touchend",j),e.removeEventListener("touchcancel",j)}},[b,v,j]),{containerRef:i,pullDistance:o,isRefreshing:d,isPulling:m}}({onRefresh:t,enabled:s,threshold:64}),p=u||d>0,x=u?1:Math.min(d/64,1);return(0,r.jsxs)("div",{ref:c,className:(0,n.cn)("relative overflow-auto",i),style:{overscrollBehaviorY:"contain"},"data-testid":"pull-to-refresh",children:[(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex justify-center",style:{transform:"translateY(".concat(p?Math.max(d-24,8):-32,"px)"),opacity:x,transition:m?"none":"transform 0.2s ease-out, opacity 0.2s ease-out"},"data-testid":"pull-to-refresh-indicator",role:"status","aria-hidden":!u,children:(0,r.jsx)(l.y$,{size:"sm",variant:"accent"})}),(0,r.jsx)("div",{style:{transform:p?"translateY(".concat(d,"px)"):void 0,transition:m?"none":"transform 0.2s ease-out"},children:o})]})}},18514:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(71847).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},22743:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var r=s(95155),a=s(12115),l=s(4560),n=s(9219),i=s(38218),o=s(18955),c=s(744),d=s(80344);class u{static getInstance(){return u.instance||(u.instance=new u),u.instance}normalize(e){let t=e.match(/^ssh:\/\/git@([^:\/]+)(:\d+)?\/(.+?)(\.git)?$/);if(t)return"https://".concat(t[1],"/").concat(t[3]).toLowerCase().replace(/\/$/,"");let s=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return s?"https://".concat(s[1],"/").concat(s[2]).toLowerCase().replace(/\/$/,""):e.replace(/\.git\/?$/,"").replace(/\/$/,"").toLowerCase()}isSameRepository(e,t){return this.normalize(e)===this.normalize(t)}extractRepoName(e){let t=e.match(/^ssh:\/\/git@[^\/]+\/(.+?)(\.git)?$/);if(t){let e=t[1].split("/");return e[e.length-1]}let s=e.match(/:(.+?)(\.git)?$/);if(s&&e.startsWith("git@")){let e=s[1].split("/");return e[e.length-1]}let r=e.match(/\/([^\/]+?)(\.git)?$/);return r?r[1]:""}getUrlType(e){return e.startsWith("https://")?"https":e.startsWith("git@")||e.startsWith("ssh://")?"ssh":null}validate(e){if(!e||"string"!=typeof e||""===e.trim())return{valid:!1,error:"EMPTY_URL"};let t=e.trim();return t.startsWith("https://")?/^https:\/\/[^\/]+\/[^\/]+\/[^\/]+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("git@")?/^git@[^:]+:.+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("ssh://")?/^ssh:\/\/git@[^\/]+(:\d+)?\/[^\/]+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:{valid:!1,error:"INVALID_URL_FORMAT"}}constructor(){}}function m(e){let{onRepositoryAdded:t}=e,s=(0,o.c)("common"),[l,n]=(0,a.useState)(!1),[i,m]=(0,a.useState)("local"),[p,x]=(0,a.useState)(""),[h,g]=(0,a.useState)(""),[f,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),[S,C]=(0,a.useState)(null),[E,R]=(0,a.useState)(null),L=u.getInstance(),$=(0,a.useCallback)(async e=>{try{let a=await d.Rx.getCloneStatus(e);if("completed"===a.status)R(s("repositories.cloneSuccess")),N(!1),k(null),g(""),n(!1),t&&t();else if("failed"===a.status){var r;C((null==(r=a.error)?void 0:r.message)||s("repositories.cloneFailed")),N(!1),k(null)}else("running"===a.status||"pending"===a.status)&&setTimeout(()=>$(e),2e3)}catch(e){C((0,d.hS)(e)),N(!1),k(null)}},[t,s]);(0,a.useEffect)(()=>{w&&j&&$(w)},[w,j]);let A=async e=>{if(e.preventDefault(),!p.trim())return void C(s("repositories.pathRequired"));C(null),R(null),b(!0);try{let e=await d.Rx.scan(p);R(e.message),x(""),n(!1),t&&t()}catch(e){C((0,d.hS)(e))}finally{b(!1)}},D=async e=>{if(e.preventDefault(),!h.trim())return void C(s("repositories.urlRequired"));let t=L.validate(h.trim());if(!t.valid)return void("EMPTY_URL"===t.error?C(s("repositories.urlRequired")):C(s("repositories.urlInvalid")));C(null),R(null),N(!0);try{let e=await d.Rx.clone(h.trim());k(e.jobId)}catch(e){C((0,d.hS)(e)),N(!1)}},_=async()=>{C(null),R(null),y(!0);try{let e=await d.Rx.sync();R(e.message),t&&t()}catch(e){C((0,d.hS)(e))}finally{y(!1)}},z=()=>{n(!1),x(""),g(""),C(null),m("local")};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[!l&&(0,r.jsxs)(c.$n,{variant:"primary",size:"sm",onClick:()=>n(!0),children:["+ ",s("repositories.add")]}),(0,r.jsx)(c.$n,{variant:"secondary",size:"sm",onClick:_,disabled:v,children:v?s("repositories.syncing"):s("repositories.syncAll")})]}),l&&(0,r.jsx)(c.Zp,{padding:"lg",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{children:(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2 text-foreground",children:s("repositories.addNewTitle")})}),(0,r.jsxs)(c.tU,{value:i,onValueChange:e=>m(e),children:[(0,r.jsxs)(c.j7,{className:"w-full",children:[(0,r.jsx)(c.Xi,{value:"local",children:s("repositories.localPathTab")}),(0,r.jsx)(c.Xi,{value:"url",children:s("repositories.cloneUrlTab")})]}),(0,r.jsx)(c.av,{value:"local",children:(0,r.jsxs)("form",{onSubmit:A,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:s("repositories.localPathDescription")}),(0,r.jsx)("label",{htmlFor:"repositoryPath",className:"block text-sm font-medium text-foreground mb-2",children:s("repositories.localPathLabel")}),(0,r.jsx)(c.pd,{id:"repositoryPath",type:"text",value:p,onChange:e=>x(e.target.value),placeholder:"/absolute/path/to/repository",className:"font-mono",disabled:f}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("repositories.localPathExample")})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{type:"submit",variant:"primary",disabled:f||!p.trim(),children:f?s("repositories.scanning"):s("repositories.scan")}),(0,r.jsx)(c.$n,{type:"button",variant:"ghost",onClick:z,disabled:f,children:s("cancel")})]})]})}),(0,r.jsx)(c.av,{value:"url",children:(0,r.jsxs)("form",{onSubmit:D,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:s("repositories.cloneUrlDescription")}),(0,r.jsx)("label",{htmlFor:"cloneUrl",className:"block text-sm font-medium text-foreground mb-2",children:s("repositories.cloneUrlLabel")}),(0,r.jsx)(c.pd,{id:"cloneUrl",type:"text",value:h,onChange:e=>g(e.target.value),placeholder:"https://github.com/user/repo.git",className:"font-mono",disabled:j}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:s("repositories.cloneUrlHelp")})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{type:"submit",variant:"primary",disabled:j||!h.trim(),children:j?s("repositories.cloning"):s("repositories.clone")}),(0,r.jsx)(c.$n,{type:"button",variant:"ghost",onClick:z,disabled:j,children:s("cancel")})]})]})})]})]})}),E&&(0,r.jsx)("div",{className:"p-4 bg-success-subtle border border-success-border rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-success-foreground",children:E})}),S&&(0,r.jsx)("div",{className:"p-4 bg-danger-subtle border border-danger-border rounded-lg",children:(0,r.jsx)("p",{className:"text-sm text-danger-foreground",children:S})})]})}var p=s(18514),x=s(87531);let h={id:null,value:"",error:null,saving:!1};function g(){return(0,r.jsx)("thead",{className:"bg-muted border-b border-border",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Name"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Display name"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Visibility"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Path"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Worktrees"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Status"}),(0,r.jsx)("th",{className:"px-4 py-2 text-left font-medium text-foreground",children:"Actions"})]})})}function f(e){let{repo:t,pending:s,onToggle:a}=e,l=t.visible;return(0,r.jsxs)("button",{type:"button",role:"switch","aria-checked":l,"aria-label":l?"Hide ".concat(t.name," from sidebar"):"Show ".concat(t.name," in sidebar"),"data-testid":"visibility-toggle-".concat(t.id),onClick:()=>a(t),disabled:s,className:(0,x.cn)("inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-muted hover:text-foreground","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-60 disabled:cursor-not-allowed"),children:[(0,r.jsx)(c.md,{status:l?"ready":"idle",size:"sm",label:l?"Visible":"Hidden","aria-hidden":"true"}),l?"Visible":"Hidden"]})}let b=(0,a.memo)(function(e){let{refreshKey:t,onChanged:s}=e,l=(0,o.c)("common"),[n,i]=(0,a.useState)([]),[u,m]=(0,a.useState)(!0),[x,b]=(0,a.useState)(null),[v,y]=(0,a.useState)(h),[j,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(new Set),S=(0,a.useCallback)(async()=>{m(!0),b(null);try{let e=await d.Rx.list();i(e.repositories)}catch(e){b((0,d.hS)(e))}finally{m(!1)}},[]);(0,a.useEffect)(()=>{S()},[S,t]);let C=(0,a.useCallback)(e=>{var t;y({id:e.id,value:null!=(t=e.displayName)?t:"",error:null,saving:!1}),N(null)},[]),E=(0,a.useCallback)(()=>{y(h)},[]),R=(0,a.useCallback)(e=>{y(t=>{if(null===t.id)return t;let s=e.length>100?"Display name must be ".concat(100," characters or less"):null;return{...t,value:e,error:s}})},[]),L=(0,a.useCallback)(async e=>{let t=v.value.trim();if(t.length>100)return void y(e=>({...e,error:"Display name must be ".concat(100," characters or less")}));y(e=>({...e,saving:!0,error:null}));try{let r=0===t.length?null:t,a=await d.Rx.updateDisplayName(e.id,r);i(t=>t.map(t=>t.id===e.id?{...t,...a.repository}:t)),y(h),N({type:"success",message:"Display name updated"}),s&&s()}catch(t){let e=(0,d.hS)(t);y(t=>({...t,saving:!1,error:e})),N({type:"error",message:e})}},[v.value,s]),$=(0,a.useCallback)((e,t)=>{"Enter"===e.key?(e.preventDefault(),L(t)):"Escape"===e.key&&(e.preventDefault(),E())},[E,L]),A=(0,a.useCallback)(async e=>{if(w.has(e.id))return;let t=!e.visible;k(t=>{let s=new Set(t);return s.add(e.id),s}),i(s=>s.map(s=>s.id===e.id?{...s,visible:t}:s)),N(null);try{let r=await d.Rx.updateVisibility(e.id,t);i(t=>t.map(t=>t.id===e.id?{...t,...r.repository}:t)),s&&s()}catch(t){i(t=>t.map(t=>t.id===e.id?{...e}:t)),N({type:"error",message:(0,d.hS)(t)})}finally{k(t=>{let s=new Set(t);return s.delete(e.id),s})}},[s,w]);return u&&0===n.length?(0,r.jsx)(c.Zp,{padding:"none",children:(0,r.jsx)("div",{className:"overflow-x-auto","data-testid":"repository-list-loading",role:"status","aria-label":l("repositories.loading"),children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)(g,{}),(0,r.jsx)("tbody",{children:[0,1,2].map(e=>(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-24"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-20"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-16"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-48"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-10"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-14"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(c.EA,{className:"h-4 w-20"})})]},e))})]})})}):x?(0,r.jsx)(c.Zp,{padding:"lg",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm text-danger-foreground",children:["Failed to load repositories: ",x]}),(0,r.jsx)(c.$n,{variant:"secondary",size:"sm",onClick:()=>void S(),children:"Retry"})]})}):(0,r.jsxs)("div",{className:"space-y-3",children:[j&&(0,r.jsx)("div",{role:"status",className:"p-3 rounded-lg text-sm ".concat("success"===j.type?"bg-success-subtle border border-success-border text-success-foreground":"bg-danger-subtle border border-danger-border text-danger-foreground"),children:j.message}),(0,r.jsx)(c.Zp,{padding:"none",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)(g,{}),(0,r.jsxs)("tbody",{children:[0===n.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:7,className:"px-4 py-6 text-center text-muted-foreground",children:l("repositories.empty")})}),n.map(e=>{let t=v.id===e.id;return(0,r.jsxs)("tr",{className:"border-b border-border","data-testid":"repository-row-".concat(e.id),children:[(0,r.jsx)("td",{className:"px-4 py-3 align-top text-foreground",children:e.name}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:t?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(c.pd,{"aria-label":"Edit display name for ".concat(e.name),type:"text",value:v.value,disabled:v.saving,maxLength:101,onChange:e=>R(e.target.value),onKeyDown:t=>$(t,e)}),v.error&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground",children:v.error})]}):e.displayName?(0,r.jsx)("span",{className:"text-foreground",children:e.displayName}):(0,r.jsx)("span",{className:"text-muted-foreground","aria-hidden":"true",children:"—"})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)(f,{repo:e,pending:w.has(e.id),onToggle:A})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsx)("span",{className:"block max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:e.path,children:e.path})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top text-foreground",children:e.worktreeCount}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground",children:[(0,r.jsx)(c.md,{status:e.enabled?"ready":"idle",size:"sm",label:e.enabled?"Enabled":"Disabled","aria-hidden":"true"}),e.enabled?"Enabled":"Disabled"]})}),(0,r.jsx)("td",{className:"px-4 py-3 align-top",children:t?(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.$n,{variant:"primary",size:"sm",onClick:()=>void L(e),disabled:v.saving||null!==v.error,children:v.saving?"Saving...":"Save"}),(0,r.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:E,disabled:v.saving,children:"Cancel"})]}):(0,r.jsx)(c.$n,{variant:"ghost",size:"sm",className:"px-2",onClick:()=>C(e),"aria-label":"Edit display name for ".concat(e.name),children:(0,r.jsx)(p.A,{className:"h-4 w-4","aria-hidden":"true"})})})]},e.id)})]})]})})})]})});function v(){let e=(0,i.a)(),[t,s]=(0,a.useState)(0),o=(0,a.useCallback)(()=>{s(e=>e+1)},[]),c=(0,a.useCallback)(async()=>{s(e=>e+1),await new Promise(e=>setTimeout(e,500))},[]);return(0,r.jsx)(l.GV,{children:(0,r.jsxs)(n.k,{onRefresh:c,enabled:e,className:"container-custom py-8 h-full",children:[(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Repositories"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Manage repositories and worktrees."})]}),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(m,{onRepositoryAdded:o}),(0,r.jsx)(b,{refreshKey:t,onChanged:o})]})]})})}}},e=>{e.O(0,[6809,4909,2770,3165,4974,6402,744,6488,4560,8441,1255,7358],()=>e(e.s=540)),_N_E=e.O()}]);
|