orbital-command 0.3.0 → 1.0.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/README.md +67 -42
- package/bin/commands/config.js +19 -0
- package/bin/commands/events.js +40 -0
- package/bin/commands/launch.js +126 -0
- package/bin/commands/manifest.js +283 -0
- package/bin/commands/registry.js +104 -0
- package/bin/commands/update.js +24 -0
- package/bin/lib/helpers.js +229 -0
- package/bin/orbital.js +90 -873
- package/dist/assets/Landing-CfQdHR0N.js +11 -0
- package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
- package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
- package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
- package/dist/assets/Settings-DLcZwbCT.js +12 -0
- package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
- package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
- package/dist/assets/{arrow-down-CPy85_J6.js → arrow-down-DVPp6_qp.js} +1 -1
- package/dist/assets/bot-NFaJBDn_.js +6 -0
- package/dist/assets/{charts-DbDg0Psc.js → charts-LGLb8hyU.js} +1 -1
- package/dist/assets/{circle-x-Cwz6ZQDV.js → circle-x-IsFCkBZu.js} +1 -1
- package/dist/assets/{file-text-C46Xr65c.js → file-text-J1cebZXF.js} +1 -1
- package/dist/assets/{globe-Cn2yNZUD.js → globe-WzeyHsUc.js} +1 -1
- package/dist/assets/index-BdJ57EhC.css +1 -0
- package/dist/assets/index-o4ScMAuR.js +349 -0
- package/dist/assets/{key-OPaNTWJ5.js → key-CKR8JJSj.js} +1 -1
- package/dist/assets/{minus-GMsbpKym.js → minus-CHBsJyjp.js} +1 -1
- package/dist/assets/radio-xqZaR-Uk.js +6 -0
- package/dist/assets/rocket-D_xvvNG6.js +6 -0
- package/dist/assets/{shield-DwAFkDYI.js → shield-TdB1yv_a.js} +1 -1
- package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
- package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
- package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
- package/dist/assets/zap-C9wqYMpl.js +6 -0
- package/dist/index.html +3 -3
- package/dist/server/server/__tests__/data-routes.test.js +2 -0
- package/dist/server/server/__tests__/scope-routes.test.js +1 -0
- package/dist/server/server/config-migrator.js +0 -3
- package/dist/server/server/config.js +35 -6
- package/dist/server/server/database.js +0 -22
- package/dist/server/server/index.js +28 -816
- package/dist/server/server/init.js +32 -399
- package/dist/server/server/launch.js +1 -1
- package/dist/server/server/parsers/event-parser.js +4 -1
- package/dist/server/server/project-context.js +19 -9
- package/dist/server/server/project-manager.js +6 -6
- package/dist/server/server/routes/aggregate-routes.js +871 -0
- package/dist/server/server/routes/config-routes.js +41 -88
- package/dist/server/server/routes/data-routes.js +5 -15
- package/dist/server/server/routes/dispatch-routes.js +24 -8
- package/dist/server/server/routes/manifest-routes.js +1 -1
- package/dist/server/server/routes/scope-routes.js +10 -7
- package/dist/server/server/schema.js +1 -0
- package/dist/server/server/services/batch-orchestrator.js +17 -3
- package/dist/server/server/services/config-service.js +10 -1
- package/dist/server/server/services/scope-service.js +7 -7
- package/dist/server/server/services/sprint-orchestrator.js +24 -11
- package/dist/server/server/services/sprint-service.js +2 -2
- package/dist/server/server/uninstall.js +195 -0
- package/dist/server/server/update.js +212 -0
- package/dist/server/server/utils/dispatch-utils.js +8 -6
- package/dist/server/server/utils/flag-builder.js +54 -0
- package/dist/server/server/utils/json-fields.js +14 -0
- package/dist/server/server/utils/json-fields.test.js +73 -0
- package/dist/server/server/utils/route-helpers.js +37 -0
- package/dist/server/server/utils/route-helpers.test.js +115 -0
- package/dist/server/server/watchers/event-watcher.js +28 -13
- package/dist/server/server/wizard/config-editor.js +4 -4
- package/dist/server/server/wizard/doctor.js +2 -2
- package/dist/server/server/wizard/index.js +224 -39
- package/dist/server/server/wizard/phases/welcome.js +1 -4
- package/dist/server/server/wizard/ui.js +6 -7
- package/dist/server/shared/api-types.js +80 -1
- package/dist/server/shared/workflow-engine.js +1 -1
- package/package.json +20 -20
- package/schemas/orbital.config.schema.json +1 -19
- package/scripts/postinstall.js +6 -42
- package/scripts/release.sh +53 -0
- package/server/__tests__/data-routes.test.ts +2 -0
- package/server/__tests__/scope-routes.test.ts +1 -0
- package/server/config-migrator.ts +0 -3
- package/server/config.ts +39 -11
- package/server/database.ts +0 -26
- package/server/global-config.ts +4 -0
- package/server/index.ts +31 -896
- package/server/init.ts +32 -443
- package/server/launch.ts +1 -1
- package/server/parsers/event-parser.ts +4 -1
- package/server/project-context.ts +26 -10
- package/server/project-manager.ts +5 -6
- package/server/routes/aggregate-routes.ts +968 -0
- package/server/routes/config-routes.ts +41 -81
- package/server/routes/data-routes.ts +7 -16
- package/server/routes/dispatch-routes.ts +29 -8
- package/server/routes/manifest-routes.ts +1 -1
- package/server/routes/scope-routes.ts +12 -7
- package/server/schema.ts +1 -0
- package/server/services/batch-orchestrator.ts +18 -2
- package/server/services/config-service.ts +10 -1
- package/server/services/scope-service.ts +6 -6
- package/server/services/sprint-orchestrator.ts +24 -9
- package/server/services/sprint-service.ts +2 -2
- package/server/uninstall.ts +214 -0
- package/server/update.ts +263 -0
- package/server/utils/dispatch-utils.ts +8 -6
- package/server/utils/flag-builder.ts +56 -0
- package/server/utils/json-fields.test.ts +83 -0
- package/server/utils/json-fields.ts +14 -0
- package/server/utils/route-helpers.test.ts +144 -0
- package/server/utils/route-helpers.ts +38 -0
- package/server/watchers/event-watcher.ts +24 -12
- package/server/wizard/config-editor.ts +4 -4
- package/server/wizard/doctor.ts +2 -2
- package/server/wizard/index.ts +291 -40
- package/server/wizard/phases/welcome.ts +1 -5
- package/server/wizard/ui.ts +6 -7
- package/shared/api-types.ts +106 -0
- package/shared/workflow-engine.ts +1 -1
- package/templates/agents/QUICK-REFERENCE.md +1 -0
- package/templates/agents/README.md +1 -0
- package/templates/agents/SKILL-TRIGGERS.md +11 -0
- package/templates/agents/green-team/deep-dive.md +361 -0
- package/templates/hooks/end-session.sh +1 -0
- package/templates/hooks/init-session.sh +1 -0
- package/templates/hooks/scope-commit-logger.sh +2 -2
- package/templates/hooks/scope-create-gate.sh +2 -4
- package/templates/hooks/scope-gate.sh +4 -6
- package/templates/hooks/scope-helpers.sh +10 -1
- package/templates/hooks/scope-lifecycle-gate.sh +14 -5
- package/templates/hooks/scope-prepare.sh +1 -1
- package/templates/hooks/scope-transition.sh +14 -6
- package/templates/hooks/time-tracker.sh +2 -5
- package/templates/orbital.config.json +1 -4
- package/templates/presets/development.json +4 -4
- package/templates/presets/gitflow.json +7 -0
- package/templates/prompts/README.md +23 -0
- package/templates/prompts/deep-dive-audit.md +94 -0
- package/templates/quick/rules.md +56 -5
- package/templates/skills/git-commit/SKILL.md +21 -6
- package/templates/skills/git-dev/SKILL.md +8 -4
- package/templates/skills/git-main/SKILL.md +8 -4
- package/templates/skills/git-production/SKILL.md +6 -3
- package/templates/skills/git-staging/SKILL.md +6 -3
- package/templates/skills/scope-fix-review/SKILL.md +8 -4
- package/templates/skills/scope-implement/SKILL.md +13 -5
- package/templates/skills/scope-post-review/SKILL.md +16 -4
- package/templates/skills/scope-pre-review/SKILL.md +6 -2
- package/dist/assets/PrimitivesConfig-CrmQXYh4.js +0 -32
- package/dist/assets/QualityGates-BbasOsF3.js +0 -21
- package/dist/assets/SessionTimeline-CGeJsVvy.js +0 -1
- package/dist/assets/Settings-oiM496mc.js +0 -12
- package/dist/assets/SourceControl-B1fP2nJL.js +0 -41
- package/dist/assets/WorkflowVisualizer-CWLYf-f0.js +0 -74
- package/dist/assets/formatDistanceToNow-BMqsSP44.js +0 -1
- package/dist/assets/index-Aj4sV8Al.css +0 -1
- package/dist/assets/index-Bc9dK3MW.js +0 -354
- package/dist/assets/useWorkflowEditor-BJkTX_NR.js +0 -16
- package/dist/assets/zap-DfbUoOty.js +0 -11
- package/dist/server/server/services/telemetry-service.js +0 -143
- package/server/services/telemetry-service.ts +0 -195
- /package/{shared/default-workflow.json → templates/presets/default.json} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{j as e}from"./ui-BmsSg9jU.js";import{a as i}from"./vendor-Bqt8AJn2.js";import{c as D,e as G,V as Pe,s as W,j as Me,o as k,O as S,G as B,Y as z,Z as Q,_ as T,$ as J,B as f,a0 as _,q as ge,R as I,M as A,N as R,I as xe,g as je,a as w,J as He,a1 as Ee,a2 as Te,h as V,a3 as _e,a4 as $e,a5 as Ie,a6 as Ge,a7 as pe,a8 as ee,i as Oe,C as te,b as ae,X as Ue,U as Fe,T as Ne,a9 as be,F as Le,w as he}from"./index-o4ScMAuR.js";import{u as qe,f as O}from"./useSocketListener-0L5yiN5i.js";import{R as Ve,A as We,a as ze}from"./charts-LGLb8hyU.js";import{A as ye}from"./arrow-down-DVPp6_qp.js";import{G as we}from"./globe-WzeyHsUc.js";import{K as Qe}from"./key-CKR8JJSj.js";import{R as se}from"./rocket-D_xvvNG6.js";import{C as me}from"./circle-x-IsFCkBZu.js";/**
|
|
2
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Je=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ke=D("activity",Je);/**
|
|
7
|
+
* @license lucide-react v0.577.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Xe=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ke=D("arrow-up-down",Xe);/**
|
|
12
|
+
* @license lucide-react v0.577.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Ze=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ve=D("arrow-up",Ze);/**
|
|
17
|
+
* @license lucide-react v0.577.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Ye=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],re=D("git-pull-request",Ye);/**
|
|
22
|
+
* @license lucide-react v0.577.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const es=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],K=D("github",es);/**
|
|
27
|
+
* @license lucide-react v0.577.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ss=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ts=D("lock",ss);/**
|
|
32
|
+
* @license lucide-react v0.577.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const as=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],rs=D("log-out",as),L=50;function ns(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),[l,x]=i.useState([]),[u,d]=i.useState(null),[m,g]=i.useState(!0),[b,p]=i.useState([]),[v,P]=i.useState(null),[M,H]=i.useState([]),[C,y]=i.useState(!0),[$,X]=i.useState(!0),Z=i.useRef(0),E=i.useCallback(async j=>{if(s)try{const[N,F,ce,ie,oe,le,de]=await Promise.all([fetch(t("/git/overview"),{signal:j}),fetch(t(`/git/commits?limit=${L}&offset=0`),{signal:j}),fetch(t("/git/branches"),{signal:j}),fetch(t("/git/worktrees"),{signal:j}),fetch(t("/git/drift"),{signal:j}),fetch(t("/git/health"),{signal:j}),fetch(t("/git/activity?days=30"),{signal:j})]);if(N.ok&&r(await N.json()),F.ok){const Y=await F.json();c(Y),Z.current=Y.length,X(Y.length>=L)}ce.ok&&n(await ce.json()),ie.ok&&x(await ie.json()),oe.ok&&p(await oe.json()),le.ok&&P(await le.json()),de.ok&&H(await de.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||y(!1)}},[t,s]),U=i.useCallback(async j=>{if(s){g(!0);try{const N=await fetch(t("/github/status"),{signal:j});N.ok&&d(await N.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||g(!1)}}},[t,s]),ne=i.useCallback(()=>{E(),U()},[E,U]),De=i.useCallback(async()=>{try{const j=await fetch(t(`/git/commits?limit=${L}&offset=${Z.current}`));if(j.ok){const N=await j.json();c(F=>[...F,...N]),Z.current+=N.length,X(N.length>=L)}}catch{}},[t]);return i.useEffect(()=>{if(!s){y(!1),g(!1);return}const j=new AbortController;return E(j.signal),U(j.signal),()=>j.abort()},[s,E,U]),Pe(ne),i.useEffect(()=>{function j(){E()}return W.on("git:status:changed",j),()=>{W.off("git:status:changed",j)}},[E]),{overview:a,commits:o,branches:h,worktrees:l,github:u,githubChecking:m,drift:b,health:v,activity:M,loading:C,refetch:ne,loadMoreCommits:De,hasMoreCommits:$,buildUrl:t}}function cs(s){const[t,a]=i.useState([]),[r,o]=i.useState([]),[c,h]=i.useState([]),[n,l]=i.useState([]),[x,u]=i.useState(new Map),[d,m]=i.useState(!0),g=i.useCallback(async()=>{if(s)try{const[p,v,P,M,H]=await Promise.all([fetch("/api/orbital/aggregate/git/overview"),fetch("/api/orbital/aggregate/git/commits?limit=50"),fetch("/api/orbital/aggregate/github/prs"),fetch("/api/orbital/aggregate/git/health"),fetch("/api/orbital/aggregate/git/activity?days=30")]);if(p.ok&&a(await p.json()),v.ok&&o(await v.json()),P.ok&&h(await P.json()),M.ok&&l(await M.json()),H.ok){const C=await H.json(),y=new Map;for(const $ of C)y.set($.projectId,$.series);u(y)}}catch{}finally{m(!1)}},[s]),b=i.useCallback(()=>{g()},[g]);return i.useEffect(()=>{s&&(m(!0),g())},[s,g]),i.useEffect(()=>{if(!s)return;function p(){g()}return W.on("git:status:changed",p),()=>{W.off("git:status:changed",p)}},[s,g]),{projectOverviews:t,commits:r,prs:c,branchHealth:n,activitySeries:x,loading:d,refetch:b}}function is(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),l=i.useCallback(async()=>{if(!s)return;const[u,d,m]=await Promise.all([fetch(t("/pipeline/drift")),fetch(t("/deployments/frequency")),fetch(t("/deployments"))]);u.ok&&r(await u.json()),d.ok&&c(await d.json()),m.ok&&n(await m.json())},[t,s]),{loading:x}=Me(l);return qe("deploy:updated",()=>{l()},[l]),{drift:a,frequency:o,deployments:h,loading:x,refetch:l}}function Ce({data:s,color:t="210 80% 55%",height:a=28}){if(s.length===0)return null;const r=`hsl(${t})`;return e.jsx("div",{style:{width:"100%",height:a},children:e.jsx(Ve,{width:"100%",height:"100%",children:e.jsxs(We,{data:s,margin:{top:0,right:0,bottom:0,left:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`sparkFill-${t.replace(/\s/g,"")}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:.25}),e.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:.02})]})}),e.jsx(ze,{type:"monotone",dataKey:"count",stroke:r,strokeWidth:1.5,fill:`url(#sparkFill-${t.replace(/\s/g,"")})`,isAnimationActive:!1})]})})})}function os({overview:s,github:t,githubChecking:a,activity:r}){var o;return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex flex-wrap items-center gap-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),e.jsx("code",{className:"font-mono text-sm",children:s.currentBranch}),s.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(T,{className:"h-2.5 w-2.5 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsx(f,{variant:"outline",className:"text-xs",children:s.branchingMode}),s.mainHead&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"HEAD"}),e.jsx("code",{className:"font-mono text-xs",children:s.mainHead.sha.slice(0,7)}),e.jsx("span",{className:"max-w-[200px] truncate",children:s.mainHead.message})]}),s.aheadBehind&&(s.aheadBehind.ahead>0||s.aheadBehind.behind>0)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(ke,{className:"h-3 w-3 text-muted-foreground"}),s.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[s.aheadBehind.ahead,"↑"]}),s.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[s.aheadBehind.behind,"↓"]})]}),s.branchingMode==="worktree"&&s.worktreeCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(_,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.worktreeCount," worktree",s.worktreeCount!==1?"s":""]})]}),s.branchingMode==="trunk"&&s.featureBranchCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.featureBranchCount," feature branch",s.featureBranchCount!==1?"es":""]})]}),r&&r.length>0&&e.jsx("div",{className:"w-20",children:e.jsx(Ce,{data:r,height:22})}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"}),a?e.jsxs(f,{variant:"outline",className:"text-xs text-muted-foreground gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking…"]}):t!=null&&t.connected?e.jsxs(z,{children:[e.jsx(Q,{children:e.jsxs(f,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(T,{className:"h-1.5 w-1.5 fill-bid-green text-bid-green"}),((o=t.repo)==null?void 0:o.fullName)??"Connected"]})}),e.jsx(J,{children:t.authUser?`Signed in as ${t.authUser}`:"Connected to GitHub"})]}):e.jsx(f,{variant:"outline",className:"text-xs text-muted-foreground",children:"Not connected"})]})]})})}function Se({projectId:s,className:t}){const{hasMultipleProjects:a,getProjectColor:r,getProjectName:o}=ge();if(!a||!s)return null;const c=r(s),h=o(s);return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0 text-[10px] ${t??""}`,style:{borderColor:`hsl(${c} / 0.4)`,color:`hsl(${c})`,borderWidth:"1px",borderStyle:"solid"},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${c})`}}),h]})}const ue=new Map,ls=6e4;function Be({commitSha:s,pr:t}){const a=G(),[r,o]=i.useState(null),[c,h]=i.useState(!1),n=i.useRef(!1),l=s??(t==null?void 0:t.branch);if(!l)return null;const x=async()=>{if(n.current||c)return;const m=ue.get(l);if(m&&Date.now()-m.ts<ls){o(m.data),n.current=!0;return}h(!0);try{const g=await fetch(a(`/github/checks/${l}`));if(g.ok){const b=await g.json();ue.set(l,{data:b,ts:Date.now()}),o(b)}}catch{}h(!1),n.current=!0};let u="text-muted-foreground/30",d="CI";if(r&&r.length>0){const m=r.some(p=>p.conclusion==="failure"),g=r.some(p=>p.status==="in_progress"||p.status==="queued"),b=r.every(p=>p.conclusion==="success"||p.conclusion==="neutral");m?(u="text-ask-red",d=`${r.filter(p=>p.conclusion==="failure").length} failing`):g?(u="text-warning-amber",d="Running"):b&&(u="text-bid-green",d="Passed")}return e.jsxs(z,{children:[e.jsx(Q,{className:"shrink-0",onMouseEnter:x,children:c?e.jsx(I,{className:"h-3 w-3 animate-spin text-muted-foreground/50"}):e.jsx(T,{className:`h-2.5 w-2.5 fill-current ${u}`})}),e.jsx(J,{side:"top",className:"max-w-xs",children:r===null?e.jsx("span",{className:"text-xs",children:"Hover to load CI status"}):r.length===0?e.jsx("span",{className:"text-xs",children:"No CI checks"}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:d}),r.slice(0,5).map((m,g)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(T,{className:`h-1.5 w-1.5 fill-current ${m.conclusion==="success"?"text-bid-green":m.conclusion==="failure"?"text-ask-red":"text-warning-amber"}`}),e.jsx("span",{className:"truncate",children:m.name})]},g)),r.length>5&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",r.length-5," more"]})]})})]})}function ds({commit:s}){return e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(Be,{commitSha:s.sha}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-primary",children:s.shortSha}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:s.message}),e.jsx(Se,{projectId:s.project_id}),s.branch&&e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:s.branch}),s.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",s.scopeId]}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:s.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(s.date),{addSuffix:!0})})]})}function Ae({commits:s,branches:t,hasMore:a,onLoadMore:r}){const[o,c]=i.useState("all"),h=i.useMemo(()=>{const x=new Set(["main","master","dev","develop","staging","production"]);for(const u of t)!u.isRemote&&!u.name.startsWith("feat/")&&!u.name.startsWith("fix/")&&x.add(u.name);return x},[t]),n=i.useMemo(()=>o==="all"?s:o==="main"?s.filter(x=>!x.branch||h.has(x.branch)):s.filter(x=>x.branch&&!h.has(x.branch)),[s,o,h]),l=[{key:"all",label:"All"},{key:"main",label:"Main"},{key:"feature",label:"Feature"}];return e.jsxs(k,{className:"lg:col-span-2",children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4 text-primary"}),"Commits"," ",e.jsx(f,{variant:"secondary",children:n.length})]}),e.jsx("div",{className:"flex gap-1",children:l.map(x=>e.jsx("button",{onClick:()=>c(x.key),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${o===x.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:x.label},x.key))})]})}),e.jsx(S,{children:n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(xe,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No commits found."})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"max-h-[600px]",children:e.jsx("div",{className:"space-y-0.5",children:n.map(x=>e.jsx(ds,{commit:x},x.sha))})}),a&&e.jsx("button",{onClick:r,className:"mt-3 w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:"Load more commits"})]})})]})}function xs({branches:s}){const t=[...s].filter(a=>!a.isRemote).sort((a,r)=>a.isCurrent?-1:r.isCurrent?1:a.isStale!==r.isStale?a.isStale?1:-1:new Date(r.headDate).getTime()-new Date(a.headDate).getTime());return t.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(B,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No branches found."})]}):e.jsx("div",{className:"space-y-0.5",children:t.map(a=>e.jsxs("div",{className:w("flex items-center gap-2 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",a.isStale&&"opacity-50"),children:[e.jsx(B,{className:w("h-3.5 w-3.5 shrink-0",a.isCurrent?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:w("min-w-0 flex-1 truncate font-mono text-xs",a.isCurrent&&"text-foreground font-medium"),children:a.name}),a.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",a.scopeId]}),a.aheadBehind&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-xs",children:[a.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),a.aheadBehind.ahead]}),a.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),a.aheadBehind.behind]})]}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:a.headSha}),a.headDate&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(a.headDate),{addSuffix:!0})})]},a.name))})}function hs({worktrees:s}){return s.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(_,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active worktrees."})]}):e.jsx("div",{className:"space-y-1",children:s.map(t=>e.jsxs("div",{className:"rounded border border-border/50 px-3 py-2 transition-colors hover:bg-surface-light",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.branch}),t.dirty&&e.jsx(T,{className:"h-2 w-2 shrink-0 fill-warning-amber text-warning-amber"}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:t.head})]}),t.scopeId&&e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs(f,{variant:"secondary",className:"text-xs",children:["#",t.scopeId]}),t.scopeTitle&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.scopeTitle}),t.scopeStatus&&e.jsx(f,{variant:"outline",className:w("shrink-0 text-xs capitalize"),children:t.scopeStatus})]}),t.aheadBehind&&(t.aheadBehind.ahead>0||t.aheadBehind.behind>0)&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs",children:[t.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),t.aheadBehind.ahead," ahead"]}),t.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),t.aheadBehind.behind," behind"]})]})]},t.path))})}function ms(s){return s===0?"text-bid-green":s<=5?"text-accent-blue":s<=20?"text-warning-amber":"text-ask-red"}function us({branches:s,worktrees:t,drift:a,branchingMode:r}){const o=r==="worktree",[c,h]=i.useState("branches");return e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),o?c==="branches"?"Branches":"Worktrees":"Branches",e.jsx(f,{variant:"secondary",children:c==="branches"?s.filter(n=>!n.isRemote).length:t.length})]}),o&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>h("branches"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="branches"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(B,{className:"inline h-3 w-3 mr-1"}),"Branches"]}),e.jsxs("button",{onClick:()=>h("worktrees"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="worktrees"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(_,{className:"inline h-3 w-3 mr-1"}),"Worktrees"]})]})]})}),e.jsxs(S,{children:[e.jsx(je,{className:"max-h-[400px]",children:c==="branches"?e.jsx(xs,{branches:s}):e.jsx(hs,{worktrees:t})}),a.length>0&&e.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Branch Drift"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("code",{className:"font-mono text-muted-foreground",children:n.from}),e.jsx(He,{className:"h-3 w-3 text-muted-foreground/50"}),e.jsx("code",{className:"font-mono text-muted-foreground",children:n.to}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",ms(n.count)),children:n.count===0?"in sync":`${n.count} commit${n.count!==1?"s":""}`})]},`${n.from}-${n.to}`))})]})]})]})}function fs({error:s,onConnected:t}){const a=G(),[r,o]=i.useState(!1),[c,h]=i.useState("oauth"),[n,l]=i.useState("idle"),[x,u]=i.useState(""),[d,m]=i.useState(""),g=i.useRef(),b=i.useRef(),p=s==null?void 0:s.includes("not installed"),v=i.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0)},[]);i.useEffect(()=>()=>{v(),clearTimeout(b.current)},[v]);const P=async()=>{l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"oauth"})})).json();y.success?(l("polling"),g.current=setInterval(async()=>{try{(await(await fetch(a("/github/auth-status"))).json()).authenticated&&(v(),clearTimeout(b.current),l("success"),setTimeout(()=>{o(!1),t()},1e3))}catch{}},2e3),b.current=setTimeout(()=>{g.current&&(v(),l("error"),m("Authentication timed out. Please try again."))},12e4)):(l("error"),m(y.error??"Failed to start OAuth flow"))}catch{l("error"),m("Failed to connect to server")}},M=async()=>{if(x.trim()){l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"pat",token:x.trim()})})).json();y.success?(l("success"),u(""),setTimeout(()=>{o(!1),t()},1e3)):(l("error"),m(y.error??"Authentication failed"))}catch{l("error"),m("Failed to connect to server")}}},H=C=>{o(C),C||(v(),l("idle"),m(""),u(""))};return e.jsxs(Ee,{open:r,onOpenChange:H,children:[e.jsx(Te,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Connect GitHub"]})}),e.jsxs(_e,{className:"sm:max-w-md",children:[e.jsxs($e,{children:[e.jsxs(Ie,{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5"}),"Connect to GitHub"]}),e.jsx(Ge,{children:p?"The GitHub CLI (gh) is required. Install it first, then authenticate.":"Authenticate with GitHub to see PRs, CI status, and repo info."})]}),p?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"rounded border border-border bg-surface-light p-3",children:[e.jsx("p",{className:"text-sm mb-2",children:"Install the GitHub CLI:"}),e.jsx("code",{className:"text-xs font-mono bg-background px-2 py-1 rounded",children:"brew install gh"}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Or visit"," ",e.jsxs("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-primary hover:underline",children:["cli.github.com ",e.jsx(pe,{className:"h-2.5 w-2.5"})]})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-1 rounded-md bg-surface-light p-1",children:[e.jsxs("button",{onClick:()=>h("oauth"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="oauth"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(we,{className:"h-4 w-4"}),"Browser OAuth"]}),e.jsxs("button",{onClick:()=>h("pat"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="pat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Qe,{className:"h-4 w-4"}),"Access Token"]})]}),c==="oauth"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens your browser to authenticate with GitHub. This is the recommended method."}),e.jsxs(V,{onClick:P,disabled:n==="connecting"||n==="polling"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="polling"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="polling"?"Waiting for browser...":n==="success"?"Connected!":"Connect with GitHub"]})]}),c==="pat"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a GitHub Personal Access Token. Needs ",e.jsx("code",{className:"text-xs",children:"repo"})," and ",e.jsx("code",{className:"text-xs",children:"read:org"})," scopes."]}),e.jsx("input",{type:"password",placeholder:"ghp_xxxxxxxxxxxxxxxxxxxx",value:x,onChange:C=>u(C.target.value),disabled:n==="connecting"||n==="success",className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50"}),e.jsxs(V,{onClick:M,disabled:!x.trim()||n==="connecting"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="success"?"Connected!":"Authenticate"]})]}),n==="error"&&d&&e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ask-red/10 px-3 py-2 text-xs text-ask-red",children:[e.jsx(Oe,{className:"h-4 w-4 shrink-0"}),d]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:"GitHub authentication is global — connecting here applies to all projects."})]})]})]})}function gs({github:s,githubChecking:t,onConnectionChange:a}){var l;const r=G(),[o,c]=i.useState(!0),h=i.useCallback(async()=>{try{await fetch(r("/github/disconnect"),{method:"POST"}),a==null||a()}catch{}},[r,a]),n=((l=s==null?void 0:s.repo)==null?void 0:l.visibility)==="public"?we:ts;return e.jsxs(k,{className:"mt-6",children:[e.jsx(A,{className:"cursor-pointer select-none",onClick:()=>c(!o),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[o?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(K,{className:"h-4 w-4 text-primary"}),"GitHub",(s==null?void 0:s.connected)&&s.repo&&e.jsxs(f,{variant:"secondary",className:"ml-1 text-xs gap-1",children:[e.jsx(n,{className:"h-2.5 w-2.5"}),s.repo.fullName]}),s!=null&&s.openPRs?e.jsxs(f,{variant:"outline",className:"text-xs",children:[s.openPRs," open PR",s.openPRs!==1?"s":""]}):null]})}),o&&e.jsx(S,{children:t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking GitHub connection…"]}):!s||!s.connected?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to GitHub to see repository info, pull requests, and CI status."}),e.jsx(fs,{error:(s==null?void 0:s.error)??null,onConnected:()=>a==null?void 0:a()})]}):e.jsxs("div",{className:"space-y-4",children:[s.repo&&e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repository"}),e.jsx("a",{href:s.repo.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.repo.fullName}),e.jsx("span",{className:"text-muted-foreground",children:"Default branch"}),e.jsx("code",{className:"font-mono",children:s.repo.defaultBranch}),e.jsx("span",{className:"text-muted-foreground",children:"Visibility"}),e.jsxs("span",{className:"flex items-center gap-1 capitalize",children:[e.jsx(n,{className:"h-3 w-3"}),s.repo.visibility]}),s.authUser&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Signed in as"}),e.jsx("span",{children:s.authUser})]})]}),e.jsx("div",{className:"border-t border-border pt-3",children:e.jsxs(V,{variant:"ghost",size:"sm",onClick:x=>{x.stopPropagation(),h()},className:"gap-2 text-xs text-muted-foreground hover:text-ask-red",children:[e.jsx(rs,{className:"h-3 w-3"}),"Disconnect"]})})]})})]})}function js({decision:s}){return s==="APPROVED"?e.jsx(ee,{className:"h-3.5 w-3.5 text-bid-green"}):s==="CHANGES_REQUESTED"?e.jsx(Ue,{className:"h-3.5 w-3.5 text-ask-red"}):e.jsx(Fe,{className:"h-3.5 w-3.5 text-warning-amber"})}function Re(s){const[t,a]=i.useState(!0),[r,o]=i.useState("all"),[c,h]=i.useState([]),n=i.useCallback(async()=>{if(!(s.isAggregate||!s.buildUrl))try{const d=await fetch(s.buildUrl("/github/prs"));d.ok&&h(await d.json())}catch{}},[s.isAggregate,s.buildUrl]);i.useEffect(()=>{s.isAggregate||n()},[s.isAggregate,n]);const l=s.isAggregate?s.prs:c,x=l.filter(d=>r==="all"?!0:r==="pending"?!d.reviewDecision||d.reviewDecision==="REVIEW_REQUIRED":r==="approved"?d.reviewDecision==="APPROVED":r==="changes"?d.reviewDecision==="CHANGES_REQUESTED":!0);if(l.length===0)return null;const u=[{key:"all",label:"All"},{key:"pending",label:"Pending"},{key:"approved",label:"Approved"},{key:"changes",label:"Changes"}];return e.jsxs(k,{className:"mb-6",children:[e.jsx(A,{className:"cursor-pointer select-none pb-2",onClick:()=>a(!t),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[t?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(re,{className:"h-4 w-4 text-primary"}),"Pull Requests",e.jsx(f,{variant:"secondary",children:l.length})]})}),t&&e.jsxs(S,{children:[e.jsx("div",{className:"mb-3 flex gap-1",children:u.map(d=>e.jsx("button",{onClick:m=>{m.stopPropagation(),o(d.key)},className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===d.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.key))}),e.jsx("div",{className:"space-y-0.5",children:x.map(d=>e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light group",children:[e.jsx(js,{decision:d.reviewDecision}),e.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["#",d.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:d.title}),e.jsx(Se,{projectId:d.project_id}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.branch}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.baseBranch}),d.scopeIds.map(m=>e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",m]},m)),e.jsx(Be,{pr:d}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:d.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(d.lastActivityAt??d.createdAt),{addSuffix:!0})}),e.jsx(pe,{className:"h-3 w-3 shrink-0 text-muted-foreground/40 opacity-0 group-hover:opacity-100 transition-opacity"})]},`${d.project_id??""}-${d.number}`))}),x.length===0&&e.jsx("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No PRs match this filter."})]})]})}function ps({overviews:s,activitySeries:t}){return s.length===0?null:e.jsx("div",{className:"mb-6 grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>e.jsx(Ns,{project:a,activity:t.get(a.projectId)??[]},a.projectId))})}function Ns({project:s,activity:t}){const{projectName:a,projectColor:r,status:o,overview:c,error:h}=s;return e.jsx(k,{className:"overflow-hidden",children:e.jsxs(S,{className:"py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${r})`}}),e.jsx("span",{className:"font-medium text-sm",style:{color:`hsl(${r})`},children:a}),o==="error"&&e.jsx(f,{variant:"destructive",className:"text-xs ml-auto",children:"Error"})]}),o==="error"?e.jsx("p",{className:"text-xs text-muted-foreground",children:h}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"font-mono text-xs",children:c.currentBranch}),c.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(T,{className:"h-2 w-2 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.aheadBehind&&(c.aheadBehind.ahead>0||c.aheadBehind.behind>0)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),c.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[c.aheadBehind.ahead,"↑"]}),c.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[c.aheadBehind.behind,"↓"]})]}),c.featureBranchCount>0&&e.jsxs("span",{children:[c.featureBranchCount," branch",c.featureBranchCount!==1?"es":""]}),e.jsx(f,{variant:"outline",className:"text-[10px] py-0",children:c.branchingMode})]}),c.mainHead&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:c.mainHead.message}),e.jsx("span",{className:"shrink-0 text-muted-foreground/60",children:O(new Date(c.mainHead.date),{addSuffix:!0})})]}),t.length>0&&e.jsx(Ce,{data:t,color:r})]}):null]})})}function bs(s){return s==="clean"?"text-bid-green":s==="low"?"text-accent-blue":s==="moderate"?"text-warning-amber":"text-ask-red"}function ys({health:s}){return s.length===0?e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No branch data available."})})]}):e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("div",{className:"space-y-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-2 transition-colors hover:bg-surface-light",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${t.projectColor})`}}),e.jsx("span",{className:"text-sm font-medium min-w-[100px]",style:{color:`hsl(${t.projectColor})`},children:t.projectName}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.branchCount," branch",t.branchCount!==1?"es":""]}),t.staleBranchCount>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-warning-amber",children:[e.jsx(Ne,{className:"h-3 w-3"}),t.staleBranchCount," stale"]}),t.featureBranchCount>0&&e.jsxs(f,{variant:"secondary",className:"text-xs",children:[t.featureBranchCount," feature"]}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",bs(t.maxDriftSeverity)),children:t.maxDriftSeverity==="clean"?"in sync":`${t.maxDriftSeverity} drift`})]},t.projectId))})})]})}function ws(s){return s==="A"?"text-bid-green":s==="B"?"text-accent-blue":s==="C"?"text-warning-amber":"text-ask-red"}function ks(s){return s==="A"?"bg-bid-green/10":s==="B"?"bg-accent-blue/10":s==="C"?"bg-warning-amber/10":"bg-ask-red/10"}function vs({health:s}){return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex items-center gap-6 py-3",children:[e.jsx("div",{className:w("flex items-center justify-center h-12 w-12 rounded-lg text-2xl font-bold shrink-0",ks(s.grade),ws(s.grade)),children:s.grade}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1",children:[e.jsx(q,{icon:e.jsx(Ke,{className:"h-3.5 w-3.5"}),label:"Commits/week",value:String(s.commitsPerWeek),warn:s.commitsPerWeek<5}),e.jsx(q,{icon:e.jsx(re,{className:"h-3.5 w-3.5"}),label:"Avg PR age",value:s.avgPrAgeDays>0?`${s.avgPrAgeDays}d`:"--",warn:s.avgPrAgeDays>3}),e.jsx(q,{icon:e.jsx(B,{className:"h-3.5 w-3.5"}),label:"Stale branches",value:String(s.staleBranchCount),warn:s.staleBranchCount>0}),e.jsx(q,{icon:e.jsx(Ne,{className:"h-3.5 w-3.5"}),label:"Drift",value:s.driftSeverity,warn:s.driftSeverity!=="clean"})]})]})})}function q({icon:s,label:t,value:a,warn:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:r?"text-warning-amber":"text-muted-foreground",children:s}),e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("span",{className:w("font-medium",r?"text-warning-amber":"text-foreground"),children:a})]})}const Cs={deploying:{icon:I,color:"text-accent-blue",label:"Deploying",animate:"animate-spin"},healthy:{icon:Le,color:"text-bid-green",label:"Healthy"},failed:{icon:me,color:"text-ask-red",label:"Failed"},"rolled-back":{icon:me,color:"text-warning-amber",label:"Rolled Back"}},fe=20;function Ss(s){const t=new Map;for(const a of s){const r=a.started_at?be(new Date(a.started_at),"yyyy-MM-dd"):"Unknown",o=t.get(r);o?o.push(a):t.set(r,[a])}return t}function Bs(s){if(!s.started_at||!s.completed_at)return null;const t=new Date(s.completed_at).getTime()-new Date(s.started_at).getTime();return t<1e3?"<1s":t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`}function As({deployments:s}){const[t,a]=i.useState(!1),r=t?s:s.slice(0,fe),o=Ss(r);return e.jsxs(k,{children:[e.jsx(A,{children:e.jsxs(R,{className:"text-base",children:["Deployment History",e.jsx(f,{variant:"secondary",className:"ml-2",children:s.length})]})}),e.jsx(S,{children:s.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(se,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deployments recorded yet."})]}):e.jsxs("div",{className:"space-y-4",children:[[...o.entries()].map(([c,h])=>e.jsxs("div",{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-card pb-1 pt-0.5",children:e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:c==="Unknown"?"Unknown date":be(new Date(c),"EEEE, MMM d")})}),e.jsx("div",{className:"space-y-0.5",children:h.map(n=>{const l=Cs[n.status],x=l.icon,u=Bs(n);return e.jsxs("div",{className:"flex items-center gap-4 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(x,{className:w("h-4 w-4 shrink-0",l.color,l.animate)}),e.jsx(f,{variant:"outline",className:"capitalize shrink-0",children:n.environment}),e.jsx("span",{className:"text-xs font-normal shrink-0",children:l.label}),n.commit_sha&&e.jsx("code",{className:"font-mono text-xs text-muted-foreground shrink-0",children:n.commit_sha.slice(0,7)}),n.branch&&e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.branch}),u&&e.jsx("span",{className:"font-mono text-xs text-muted-foreground/60 shrink-0",children:u}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/60 shrink-0",children:n.started_at?O(new Date(n.started_at),{addSuffix:!0}):"—"})]},n.id)})})]},c)),!t&&s.length>fe&&e.jsxs("button",{onClick:()=>a(!0),className:"w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:["Show all ",s.length," deployments"]})]})})]})}function Us(){const{activeProjectId:s,hasMultipleProjects:t}=ge(),a=t&&s===null,r=ns(!a),o=cs(a),{deployments:c}=is(!a),[h,n]=i.useState(!0);return(a?o.loading:r.loading)?e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"})})]}):e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a?e.jsx(Ds,{aggregate:o}):e.jsx(Rs,{sourceControl:r,deployments:c,deployExpanded:h,setDeployExpanded:n})})]})}function Rs({sourceControl:s,deployments:t,deployExpanded:a,setDeployExpanded:r}){const{overview:o,commits:c,branches:h,worktrees:n,github:l,githubChecking:x,drift:u,loadMoreCommits:d,hasMoreCommits:m,health:g,activity:b,refetch:p}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(_,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),o&&e.jsx(f,{variant:"secondary",children:o.currentBranch})]}),o&&e.jsx(os,{overview:o,github:l,githubChecking:x,activity:b}),g&&e.jsx(vs,{health:g}),(l==null?void 0:l.connected)&&e.jsx(Re,{buildUrl:s.buildUrl}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:c,branches:h,hasMore:m,onLoadMore:d}),e.jsx(us,{branches:h,worktrees:n,drift:u,branchingMode:(o==null?void 0:o.branchingMode)??"trunk"})]}),e.jsx(gs,{github:l,githubChecking:x,onConnectionChange:p}),t.length>0&&e.jsx("div",{className:"mt-6",children:a?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(!1),className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx(se,{className:"h-4 w-4"}),"Deploy History"]}),e.jsx(As,{deployments:t})]}):e.jsx(k,{className:"cursor-pointer select-none",onClick:()=>r(!0),children:e.jsx(A,{children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(se,{className:"h-4 w-4 text-primary"}),"Deploy History",e.jsx(f,{variant:"secondary",children:t.length})]})})})})]})}function Ds({aggregate:s}){const{projectOverviews:t,commits:a,prs:r,branchHealth:o,activitySeries:c}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(_,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),e.jsx(f,{variant:"secondary",children:"All Projects"})]}),e.jsx(ps,{overviews:t,activitySeries:c}),r.length>0&&e.jsx(Re,{prs:r,isAggregate:!0}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:a,branches:[],hasMore:!1,onLoadMore:()=>{}}),e.jsx(ys,{health:o})]})]})}export{Us as SourceControl};
|