@overlordai/server 1.0.124 → 1.0.126
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/dist/adapters/adapter.interface.d.ts +2 -2
- package/dist/adapters/adapter.interface.d.ts.map +1 -1
- package/dist/adapters/help-text.js +1 -1
- package/dist/adapters/help-text.js.map +1 -1
- package/dist/adapters/lark/lark-card.builder.d.ts.map +1 -1
- package/dist/adapters/lark/lark-card.builder.js +11 -1
- package/dist/adapters/lark/lark-card.builder.js.map +1 -1
- package/dist/adapters/lark/lark.adapter.d.ts +1 -1
- package/dist/adapters/lark/lark.adapter.d.ts.map +1 -1
- package/dist/adapters/lark/lark.adapter.js +4 -3
- package/dist/adapters/lark/lark.adapter.js.map +1 -1
- package/dist/adapters/lark/lark.controller.js +1 -1
- package/dist/adapters/lark/lark.controller.js.map +1 -1
- package/dist/adapters/slack/slack-block.builder.d.ts.map +1 -1
- package/dist/adapters/slack/slack-block.builder.js +11 -1
- package/dist/adapters/slack/slack-block.builder.js.map +1 -1
- package/dist/adapters/slack/slack.adapter.d.ts +1 -1
- package/dist/adapters/slack/slack.adapter.d.ts.map +1 -1
- package/dist/adapters/slack/slack.adapter.js +2 -2
- package/dist/adapters/slack/slack.adapter.js.map +1 -1
- package/dist/adapters/slack/slack.controller.js +2 -2
- package/dist/adapters/slack/slack.controller.js.map +1 -1
- package/dist/common/string-utils.d.ts +3 -1
- package/dist/common/string-utils.d.ts.map +1 -1
- package/dist/common/string-utils.js +16 -3
- package/dist/common/string-utils.js.map +1 -1
- package/dist/common/task-agent.d.ts +3 -0
- package/dist/common/task-agent.d.ts.map +1 -0
- package/dist/common/task-agent.js +21 -0
- package/dist/common/task-agent.js.map +1 -0
- package/dist/common/task-time-cost.d.ts +3 -0
- package/dist/common/task-time-cost.d.ts.map +1 -0
- package/dist/common/task-time-cost.js +28 -0
- package/dist/common/task-time-cost.js.map +1 -0
- package/dist/dispatcher/dispatcher.service.js +1 -1
- package/dist/dispatcher/dispatcher.service.js.map +1 -1
- package/dist/dispatcher/scheduler.service.d.ts.map +1 -1
- package/dist/dispatcher/scheduler.service.js +22 -1
- package/dist/dispatcher/scheduler.service.js.map +1 -1
- package/dist/dispatcher/state-machine.d.ts +1 -1
- package/dist/dispatcher/state-machine.js +2 -2
- package/dist/dispatcher/state-machine.js.map +1 -1
- package/dist/dispatcher/task-creation.service.d.ts.map +1 -1
- package/dist/dispatcher/task-creation.service.js +4 -2
- package/dist/dispatcher/task-creation.service.js.map +1 -1
- package/dist/dispatcher/task-lifecycle.service.js +4 -4
- package/dist/dispatcher/task-lifecycle.service.js.map +1 -1
- package/dist/dispatcher/worker-connection.manager.d.ts +1 -1
- package/dist/dispatcher/worker-connection.manager.d.ts.map +1 -1
- package/dist/dispatcher/worker-connection.manager.js +11 -3
- package/dist/dispatcher/worker-connection.manager.js.map +1 -1
- package/dist/dispatcher/worker-selector.d.ts.map +1 -1
- package/dist/dispatcher/worker-selector.js +16 -2
- package/dist/dispatcher/worker-selector.js.map +1 -1
- package/dist/notifier/notification-consumer.d.ts +7 -2
- package/dist/notifier/notification-consumer.d.ts.map +1 -1
- package/dist/notifier/notification-consumer.js +35 -13
- package/dist/notifier/notification-consumer.js.map +1 -1
- package/dist/web/dashboard.controller.d.ts +1 -0
- package/dist/web/dashboard.controller.d.ts.map +1 -1
- package/dist/web/dashboard.service.d.ts +4 -1
- package/dist/web/dashboard.service.d.ts.map +1 -1
- package/dist/web/dashboard.service.js +17 -9
- package/dist/web/dashboard.service.js.map +1 -1
- package/dist/web/project.controller.d.ts +1 -1
- package/dist/web/project.controller.d.ts.map +1 -1
- package/dist/web/project.controller.js +12 -5
- package/dist/web/project.controller.js.map +1 -1
- package/dist/web/pty.gateway.d.ts.map +1 -1
- package/dist/web/pty.gateway.js +7 -2
- package/dist/web/pty.gateway.js.map +1 -1
- package/dist/web/task.controller.d.ts +1 -1
- package/dist/web/task.controller.d.ts.map +1 -1
- package/dist/web/task.controller.js +3 -13
- package/dist/web/task.controller.js.map +1 -1
- package/dist/web/worker-channel.gateway.d.ts +1 -0
- package/dist/web/worker-channel.gateway.d.ts.map +1 -1
- package/dist/web/worker-channel.gateway.js +14 -2
- package/dist/web/worker-channel.gateway.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/{AccessTokensPage-Cr097v40.js → AccessTokensPage-Ck9KudgP.js} +1 -1
- package/public/assets/AdminPage-BKWbP0n2.js +1 -0
- package/public/assets/{AgentCliPage-0DYkyCFU.js → AgentCliPage-Bex4ulEr.js} +1 -1
- package/public/assets/ApiReferencePage-CTkJqTdJ.js +1 -0
- package/public/assets/{ArchitecturePage-QnOTiWty.js → ArchitecturePage-8SxZccYN.js} +1 -1
- package/public/assets/AuditLogPage-BLzj5y_X.js +1 -0
- package/public/assets/{BindPlatformPage-ot7gVchX.js → BindPlatformPage-D45esrNl.js} +1 -1
- package/public/assets/{BotIntegrationPage-BtyfG2XP.js → BotIntegrationPage-BhDYugrQ.js} +1 -1
- package/public/assets/{BotManage-BZAdr9Ef.js → BotManage-CbUW-s4b.js} +1 -1
- package/public/assets/{BotSetupPage-DHPQWTKC.js → BotSetupPage-DnwaG9Z7.js} +1 -1
- package/public/assets/{ChangelogPage-AEZ8l4_F.js → ChangelogPage-ROnloca6.js} +1 -1
- package/public/assets/CliReferencePage-C-Lw0uAV.js +14 -0
- package/public/assets/{DeploymentPage-DoLblVvb.js → DeploymentPage-Cm8hl7PF.js} +1 -1
- package/public/assets/{DevWorkflowPage-DejRDBZS.js → DevWorkflowPage-DTjFXI4G.js} +1 -1
- package/public/assets/{DeveloperManage-Cp8HZ0D6.js → DeveloperManage-4o7ML8ff.js} +1 -1
- package/public/assets/{DeveloperSetupPage-BR9jE9u9.js → DeveloperSetupPage-BQhIuXLe.js} +1 -1
- package/public/assets/{DocsIndexPage-DFjTwAEC.js → DocsIndexPage-CoUUKiVh.js} +1 -1
- package/public/assets/DocsLayout-Br7yGyG5.js +1 -0
- package/public/assets/{DocsPrimitives-BXzC3C_T.js → DocsPrimitives-DuiNLMTd.js} +1 -1
- package/public/assets/{EditProjectPage-BAdWNM1Q.js → EditProjectPage-C_vbQdR2.js} +1 -1
- package/public/assets/{EmptyState-CSnE65GT.js → EmptyState-aKMHLBhj.js} +1 -1
- package/public/assets/{EnvVariablesPage-CG4TuCIN.js → EnvVariablesPage-gbqhCWCv.js} +1 -1
- package/public/assets/HomePage-Sfw7oH7M.js +1 -0
- package/public/assets/{InfoRow-CUxNs9ne.js → InfoRow-BQI_KKyp.js} +1 -1
- package/public/assets/{InstallationPage-C679ErXI.js → InstallationPage-Ce0qD1m-.js} +1 -1
- package/public/assets/{LandingPage-E8pwfBvz.js → LandingPage-1SiyCrIO.js} +1 -1
- package/public/assets/{LocalDevelopmentPage-D6ILnSoo.js → LocalDevelopmentPage-tuixvO86.js} +1 -1
- package/public/assets/{LoginPage-D_DPwVwn.js → LoginPage-D7C2GvH2.js} +1 -1
- package/public/assets/{MetricBar-8GF9L_i9.js → MetricBar-DaWuVJHZ.js} +1 -1
- package/public/assets/{NotFoundPage-Cw8H-got.js → NotFoundPage-B2K-657t.js} +1 -1
- package/public/assets/{OnboardingGuide-CYh6h81Z.js → OnboardingGuide-Cj_QW_kH.js} +1 -1
- package/public/assets/{PermissionsPage-BJ5ucT9C.js → PermissionsPage-D4ZeOpEb.js} +1 -1
- package/public/assets/{PipelineConfigPage-CmFPv119.js → PipelineConfigPage-DaCDhd-P.js} +1 -1
- package/public/assets/{PipelineEditorPage-6adMKyts.js → PipelineEditorPage-rM_yORd4.js} +2 -2
- package/public/assets/ProfilePage-DshUwwog.js +1 -0
- package/public/assets/ProjectDetailPage-BMKog_vR.js +7 -0
- package/public/assets/{ProjectListPage-DrLdH4Ei.js → ProjectListPage-C5U_Q6m_.js} +2 -2
- package/public/assets/{PtyTerminal-gy77drbY.js → PtyTerminal-DJ4ToCWx.js} +2 -2
- package/public/assets/{QuickAuth-xZnzkGvb.js → QuickAuth-BPSm4iQz.js} +1 -1
- package/public/assets/{RemoveMemberConfirmDialog-B5OQbjQg.js → RemoveMemberConfirmDialog-GYx2AH26.js} +2 -2
- package/public/assets/{Select-Do5DXb3j.js → Select-CvM411zU.js} +1 -1
- package/public/assets/{SettingsPage-Bw9JmWan.js → SettingsPage-_cXRQuuA.js} +1 -1
- package/public/assets/{Skeleton-CW5d7fJ4.js → Skeleton-qXDikSxR.js} +1 -1
- package/public/assets/{SkillPage-C-ShsZGo.js → SkillPage-C3wTzd5o.js} +1 -1
- package/public/assets/TaskDetailPage-BQY6iia7.js +26 -0
- package/public/assets/TaskListPage-D6iQoHz7.js +1 -0
- package/public/assets/{TaskStatusBadge--oACnBUb.js → TaskStatusBadge-CJTrG6-l.js} +1 -1
- package/public/assets/TerminalHomePage-BFyQcEXU.js +11 -0
- package/public/assets/{TokenManage-D0UL7DBv.js → TokenManage-C5GQ1LB8.js} +1 -1
- package/public/assets/{Tooltip-BQSpwoKv.js → Tooltip-DYbD-tQw.js} +1 -1
- package/public/assets/{TotpSetupPage-D9iUn0_Y.js → TotpSetupPage-C09YtAXD.js} +1 -1
- package/public/assets/WorkerDetailPage-DhtIXNEC.js +1 -0
- package/public/assets/{WorkerListPage-B47Wc0zs.js → WorkerListPage-B_K4x-PV.js} +2 -2
- package/public/assets/{WorkerOperationsPage-XuqS7u-Y.js → WorkerOperationsPage-BZN-hLvH.js} +1 -1
- package/public/assets/{WorkerSetupGuidePage-D_fyqLD7.js → WorkerSetupGuidePage-DNy2wbA9.js} +1 -1
- package/public/assets/{WorkerSetupPage-C-xmBIhD.js → WorkerSetupPage-VBsAuhUc.js} +1 -1
- package/public/assets/{arrow-left-BmBtPvqR.js → arrow-left-B5R31ze1.js} +1 -1
- package/public/assets/{arrow-right-DQ5XDN6Z.js → arrow-right-C10sjQNz.js} +1 -1
- package/public/assets/{bot-DUC6k0o_.js → bot-J2o7uWlo.js} +1 -1
- package/public/assets/chevron-left-B5ojlwvf.js +6 -0
- package/public/assets/{chevron-right-D5yuBhvf.js → chevron-right-Yoiq-SRa.js} +1 -1
- package/public/assets/{copy-DsibVBOY.js → copy-BpM8iA-r.js} +1 -1
- package/public/assets/date-RFA7-ZGs.js +1 -0
- package/public/assets/{download-BLkgWRTq.js → download-DMI0uxkZ.js} +1 -1
- package/public/assets/{external-link-oEMmDqkw.js → external-link-BgyHxzCy.js} +1 -1
- package/public/assets/{git-fork-nMDIqkn8.js → git-fork-BSMVuD3x.js} +1 -1
- package/public/assets/index-DMWyyiI3.css +1 -0
- package/public/assets/{index-Cxiuct-Z.js → index-XDDf1Oy_.js} +42 -42
- package/public/assets/{key-CFQniqbQ.js → key-y6VWhViZ.js} +1 -1
- package/public/assets/{loader-circle-gHkPMihD.js → loader-circle-CMxLiCu8.js} +1 -1
- package/public/assets/{pencil-B01ssnBx.js → pencil-CUs1Ii2-.js} +1 -1
- package/public/assets/{plus-26O7XffR.js → plus-R7zuZ-Lg.js} +1 -1
- package/public/assets/{rotate-ccw-EIYq8PBk.js → rotate-ccw-B1uEgqoV.js} +1 -1
- package/public/assets/{scroll-text-BHCR_iaD.js → scroll-text-CL3s7j9w.js} +1 -1
- package/public/assets/{settings-beF7O3lb.js → settings-IoIv8DUf.js} +1 -1
- package/public/assets/status-colors-JE6CIHvW.js +1 -0
- package/public/assets/task-constants-DkWAZdpz.js +1 -0
- package/public/assets/{trash-2-BJmwr4y8.js → trash-2-BYatp6Y5.js} +1 -1
- package/public/assets/{useFetch-DiJtqzkU.js → useFetch-D6-vLVQP.js} +1 -1
- package/public/assets/{users-C17f7r3H.js → users-C3jRdgS-.js} +1 -1
- package/public/assets/{wifi-CJ7w56-5.js → wifi-B8ZV0Cuq.js} +1 -1
- package/public/assets/{workflow-DNH-yZBI.js → workflow-GXjmJAuH.js} +1 -1
- package/public/index.html +2 -2
- package/public/sw.js +1 -1
- package/public/assets/AdminPage-VIOLrGFx.js +0 -1
- package/public/assets/ApiReferencePage-B9a_wvSq.js +0 -1
- package/public/assets/AuditLogPage-B2V_M9t2.js +0 -6
- package/public/assets/CliReferencePage-Yr_43MGe.js +0 -14
- package/public/assets/DocsLayout-DC5Tkwza.js +0 -1
- package/public/assets/HomePage-BqlvkHSs.js +0 -1
- package/public/assets/ProfilePage-Ce-x-H8n.js +0 -1
- package/public/assets/ProjectDetailPage-DXZrEF_O.js +0 -7
- package/public/assets/TaskDetailPage-BakBoast.js +0 -26
- package/public/assets/TaskListPage--IQPCrtx.js +0 -1
- package/public/assets/TerminalHomePage-DCoze8O0.js +0 -11
- package/public/assets/WorkerDetailPage-D3Jzaen0.js +0 -1
- package/public/assets/date-BdNtiQTP.js +0 -1
- package/public/assets/index-zA1n63-W.css +0 -1
- package/public/assets/status-colors-BH60BXIE.js +0 -1
- package/public/assets/task-constants-CJk15ylu.js +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{c as Q,a as Y,r,h as g,j as e,M as ot,z as A,H as xt,t as J,v as ke,A as dt,f as mt,B as pt,q as ut,s as ht,k as Ke,p as D,l as We,m as ft,L as vt,X as ve,E as Xe,n as bt,x as gt,G as jt}from"./index-XDDf1Oy_.js";import{u as Nt,T as yt}from"./task-constants-DkWAZdpz.js";import{C as kt,H as He,P as Ve}from"./PtyTerminal-DJ4ToCWx.js";import{a as wt,b as _t,f as re}from"./date-RFA7-ZGs.js";import{S as Ct}from"./Select-CvM411zU.js";import{a as St}from"./status-colors-JE6CIHvW.js";import{T as Et}from"./Tooltip-DYbD-tQw.js";import{A as Tt}from"./arrow-left-B5R31ze1.js";import{R as be}from"./rotate-ccw-B1uEgqoV.js";import{G as Lt}from"./git-fork-BSMVuD3x.js";import{E as Dt}from"./external-link-BgyHxzCy.js";import{L as ge}from"./loader-circle-CMxLiCu8.js";/**
|
|
2
|
+
* @license lucide-react v0.469.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=Q("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
7
|
+
* @license lucide-react v0.469.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 It=Q("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
|
|
12
|
+
* @license lucide-react v0.469.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 $t=Q("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
17
|
+
* @license lucide-react v0.469.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 Rt=Q("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
22
|
+
* @license lucide-react v0.469.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 Pt=Q("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);function Qe({isOpen:l,onClose:c,taskId:a,stageName:n,timeoutSeconds:t,onSubmitted:m}){const{t:p}=Y(),[b,u]=r.useState(t),[_,C]=r.useState(!1);r.useEffect(()=>{if(!l)return;u(t);const o=setInterval(()=>{u(j=>j<=1?(clearInterval(o),0):j-1)},1e3);return()=>clearInterval(o)},[l,t]),r.useEffect(()=>{b===0&&l&&c()},[b,l,c]);const $=r.useCallback(async o=>{C(!0);try{await g.post(`web/tasks/${a}/confirm-stage`,{json:{stageName:n,approved:o}}),m==null||m(),c()}catch{}finally{C(!1)}},[a,n,c,m]);return l?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backdropFilter:"blur(2px)"},children:[e.jsx("div",{className:"fixed inset-0 bg-[var(--modal-backdrop)]"}),e.jsxs("div",{className:"relative z-10 w-full max-w-[480px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsxs("h3",{className:"text-sm text-[var(--text-primary)]",children:["// stage: ",n]})]}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-[var(--text-muted)]",children:[e.jsx(kt,{className:"h-3.5 w-3.5"}),wt(b)]})]}),e.jsx("div",{className:"space-y-4 px-5 py-5",children:e.jsx("p",{className:"whitespace-pre-wrap text-xs text-[var(--text-primary)]",children:p("tasks.confirm_stage_message",{name:n})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] px-5 py-4",children:[e.jsx("button",{type:"button",className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",disabled:_,onClick:()=>$(!1),children:p("tasks.reject")}),e.jsx("button",{type:"button",className:"rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",disabled:_,onClick:()=>$(!0),children:p(_?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})]})]}):null}function At(l,c){const a=new Date(l).getTime()-Date.now();if(a<=0)return c("tasks.tunnel_expired");const n=Math.floor(a/36e5),t=Math.floor(a%36e5/6e4);return n>0?c("tasks.tunnel_expires_hm",{h:n,m:t}):c("tasks.tunnel_expires_m",{m:t})}function Ye(l){switch(l){case"CONNECTED":return"var(--accent)";case"STARTING":return"var(--warning)";case"EXPIRED":return"var(--text-muted)";default:return"var(--text-muted)"}}function Ze(l,c){switch(l){case"IDLE":case"CLOSED":return c("tasks.tunnel_idle");case"STARTING":return c("tasks.tunnel_starting");case"CONNECTED":return c("tasks.tunnel_connected");case"EXPIRED":return c("tasks.tunnel_expired");case"CLOSING":return c("tasks.tunnel_closing");default:return String(l).toLowerCase()}}function Ft({taskId:l,taskFinished:c,compact:a}){const{t:n}=Y(),[t,m]=r.useState(A.IDLE),[p,b]=r.useState(null),[u,_]=r.useState(null),[C,$]=r.useState(""),[o,j]=r.useState(!1),[le,F]=r.useState(!1),M=r.useRef(null),R=r.useCallback(async()=>{try{const f=await g.get(`web/workspace-tunnel/${l}/status`).json();m(f.status),b(f.tunnelUrl??null),_(f.expiresAt??null),(f.status==="EXPIRED"||f.status==="IDLE"||f.status==="CLOSED")&&S()}catch{}},[l]);function ce(){S(),M.current=setInterval(R,5e3)}function S(){M.current&&(clearInterval(M.current),M.current=null)}r.useEffect(()=>{c&&(t===A.STARTING||t===A.CONNECTED)&&(m(A.IDLE),b(null),S())},[c,t]),r.useEffect(()=>{if(t!=="CONNECTED"||!u)return;const f=()=>{const E=At(u,n);$(E),E===n("tasks.tunnel_expired")&&(m(A.EXPIRED),b(null),S())};f();const I=setInterval(f,3e4);return()=>clearInterval(I)},[t,u]),r.useEffect(()=>()=>S(),[]),r.useEffect(()=>{c||R()},[R,c]);async function K(){j(!0);try{await g.post(`web/workspace-tunnel/${l}/start`),m(A.STARTING),ce()}catch(f){let I=n("tasks.tunnel_start_failed");try{if(f instanceof xt){const E=await f.response.json();E!=null&&E.error&&(I=E.error,/code.*not found|ENOENT.*code|spawn code/i.test(I)&&(I+=". "+n("tasks.tunnel_install_code_hint")))}}catch{}J.error(I)}finally{j(!1)}}async function W(){j(!0);try{await g.post(`web/workspace-tunnel/${l}/stop`),m(A.IDLE),b(null),S()}catch{}finally{j(!1)}}async function ie(){p&&(await navigator.clipboard.writeText(p),F(!0),setTimeout(()=>F(!1),2e3))}return a?e.jsxs("div",{className:"flex items-center gap-2 font-mono lowercase text-xs",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"ide_tunnel:"}),e.jsx("span",{style:{color:Ye(t)},children:Ze(t,n)}),(t==="IDLE"||t==="CLOSED"||t==="EXPIRED")&&e.jsx("button",{onClick:K,disabled:o,className:"rounded-[4px] px-2 py-1 text-[var(--info)] disabled:opacity-50",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:n(o?"tasks.tunnel_starting":"tasks.tunnel_start")}),t==="CONNECTED"&&p&&e.jsx("a",{href:p.replace(/^https?:/,"cursor:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] px-2 py-1 text-[var(--info)]",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:n("tasks.tunnel_open_in_cursor")})]}):e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:n("tasks.tunnel_header")}),e.jsxs("span",{className:"text-xs",style:{color:Ye(t)},children:["● ",Ze(t,n)]})]}),t==="CONNECTED"&&u&&e.jsxs("p",{className:"mb-2 text-xs text-[var(--text-muted)]",children:["// ",C]}),t==="CONNECTED"&&p&&e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2",children:[e.jsx("code",{className:"flex-1 truncate text-xs text-[var(--text-primary)]",children:p}),e.jsxs("button",{onClick:ie,className:"shrink-0 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors","aria-label":n("tasks.tunnel_copy_url"),children:["[",n("common.copy"),"]"]})]}),le&&e.jsx("p",{className:"mb-2 text-xs text-[var(--accent)]",children:n("tasks.tunnel_copied")}),t==="STARTING"&&e.jsx("p",{className:"mb-3 text-xs text-[var(--text-muted)]",children:n("tasks.tunnel_waiting")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(t==="IDLE"||t==="CLOSED")&&e.jsx("button",{onClick:K,disabled:o,className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors disabled:opacity-50",children:n(o?"tasks.tunnel_starting_button":"tasks.tunnel_start_button")}),t==="STARTING"&&e.jsx("button",{onClick:W,disabled:o,className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",children:n(o?"tasks.tunnel_stopping":"tasks.tunnel_cancel")}),t==="CONNECTED"&&p&&e.jsxs(e.Fragment,{children:[e.jsx("a",{href:p.replace(/^https?:/,"cursor:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors",children:n("tasks.tunnel_open_cursor")}),e.jsx("a",{href:p.replace(/^https?:/,"vscode:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:n("tasks.tunnel_open_vscode")}),e.jsx("button",{onClick:W,disabled:o,className:"rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors disabled:opacity-50",children:n(o?"tasks.tunnel_stopping":"tasks.tunnel_stop")})]}),t==="EXPIRED"&&e.jsx("button",{onClick:K,disabled:o,className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors disabled:opacity-50",children:n(o?"tasks.tunnel_starting_button":"tasks.tunnel_restart")})]})]})}function Mt({isOpen:l,onClose:c,onConfirm:a,taskId:n,isLoading:t}){const{t:m}=Y();return e.jsx(ke,{isOpen:l,onClose:c,onConfirm:a,title:m("tasks.cancel_task_title"),message:m("tasks.cancel_task_message",{id:String(n)}),confirmLabel:m("tasks.cancel_task_confirm_label"),confirmVariant:"danger",isLoading:t})}function Ot({isOpen:l,onClose:c,onConfirm:a,taskId:n,mrUrl:t,isLoading:m,reuseWorkspace:p,onReuseWorkspaceChange:b}){const{t:u}=Y(),_=t?u("tasks.retry_message_with_mr",{id:String(n),url:t}):u("tasks.retry_message_without_mr",{id:String(n)});return e.jsx(ke,{isOpen:l,onClose:c,onConfirm:a,title:u("tasks.retry_title"),message:_,confirmLabel:u("tasks.retry_confirm_label"),confirmVariant:"accent",isLoading:m,children:e.jsxs("label",{className:"flex items-center gap-2 mt-3 text-[var(--text-muted)] text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:C=>b(C.target.checked),className:"w-3.5 h-3.5 cursor-pointer accent-[var(--accent)]"}),u("tasks.reuse_workspace_label")]})})}const je=["implement","test","verify","review","simplify","submit"];function ye(l){if(typeof l=="string")try{return ye(JSON.parse(l))}catch{return null}if(!l||typeof l!="object")return null;const c=l.stages;if(!Array.isArray(c)||c.length===0)return null;const a=c.map(n=>n&&typeof n=="object"?n.name:null).filter(n=>typeof n=="string"&&n.length>0);return a.length===c.length?a:null}function qt(l){if(!l.configSnapshot)return je;try{const c=JSON.parse(l.configSnapshot);return ye(c.pipeline)??ye(c)??je}catch{return je}}function Ut(l){switch(l){case"stage_change":return"text-[var(--accent)]";case"info":return"text-[var(--text-secondary)]";case"warning":return"text-[var(--warning)]";case"error":return"text-[var(--destructive)]";case"system":return"text-[var(--info)]";default:return"text-[var(--text-muted)]"}}function Ne({status:l}){const c=St(l);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-[4px] px-2 py-0.5 text-xs",style:{color:c},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-[3px]",style:{backgroundColor:c}}),l.toLowerCase()]})}function Gt(l){const c=qt(l),a=l.currentStage?c.indexOf(l.currentStage):-1;return c.map((n,t)=>{let m="pending";return l.status===D.COMPLETED?m="completed":l.status===D.FAILED&&t<=a?m=t===a?"failed":"completed":a>=0&&(t<a?m="completed":t===a&&(m="running")),{name:n,status:m}})}function ne(l,c){if(!l||!c)return null;const a=l.repoUrl.replace(/\.git$/,"").replace(/\/+$/,"");return l.gitPlatform===jt.GITLAB?`${a}/-/tree/${c}`:`${a}/tree/${c}`}function ts(){var ze,Be;const{id:l}=dt(),c=mt(),{t:a}=Y(),n=Nt(s=>s.cancelTask),[t,m]=r.useState(null),[p,b]=r.useState(null),[u,_]=r.useState([]),[C,$]=r.useState(!0),[o,j]=r.useState(null),[le,F]=r.useState(!1),[M,R]=r.useState(!1),[ce,S]=r.useState(!1),[K,W]=r.useState(!1),[ie,f]=r.useState(!1),[I,E]=r.useState(!1),[we,_e]=r.useState(""),[Ce,oe]=r.useState(!1),[Se,et]=pt(),[k,xe]=r.useState("terminal"),[Ee,Te]=r.useState([]),[Z,Le]=r.useState(0),[X,O]=r.useState(0),[H,De]=r.useState(""),[ee,tt]=r.useState(""),[st,de]=r.useState(!1),[at,Ie]=r.useState(!1),[q,me]=r.useState(null),[T,$e]=r.useState("disconnected"),[V,Re]=r.useState("auto"),U=r.useRef(null),Pe=r.useRef(null),x=Number(l),v=t?yt.includes(t.status):!1;ut(t?ht(t,100):null);const L=r.useCallback(async()=>{try{const s=await g.get(`web/tasks/${x}`).json();m(s)}catch{}},[x]),te=r.useCallback(async()=>{try{const s=await g.get(`web/tasks/${x}/logs`).json();_(s.lines)}catch{}},[x]),G=r.useCallback(async()=>{try{const s=await g.get(`web/tasks/${x}/pending-confirm`).json();j(s.confirm)}catch{j(null)}},[x]),Ae=r.useCallback(async()=>{de(!0);try{const s=new URLSearchParams;s.set("limit","50"),s.set("offset",String(X*50)),H&&s.set("type",H),ee&&s.set("search",ee);const i=await g.get(`web/tasks/${x}/events?${s}`).json();Te(i.events),Le(i.total)}catch{}finally{de(!1)}},[x,X,H,ee]);r.useEffect(()=>{k==="logs"&&Ae()},[k,Ae]),r.useEffect(()=>{k==="pipeline"&&!v&&g.get(`web/workspaces/${x}`).json().then(me).catch(()=>me(null))},[k,x,v]);const z=Ke(s=>s.lastEvent),Fe=Ke(s=>s.eventSeq);r.useEffect(()=>{$(!0),m(null),b(null),_([]),j(null),me(null),Te([]),Le(0),O(0),de(!1),Promise.all([L(),te(),G()]).finally(()=>$(!1))},[L,te,G]),r.useEffect(()=>{t!=null&&t.projectKey&&g.get(`web/projects/${t.projectKey}`).json().then(b).catch(()=>b(null))},[t==null?void 0:t.projectKey]),r.useEffect(()=>{!z||Fe===0||(z.event==="task_status_changed"&&z.taskId===x||z.event==="task_created"&&z.taskId===x)&&(L(),G())},[Fe,z,x,L,G]),r.useEffect(()=>{if(v)return;const i=setInterval(()=>{document.visibilityState!=="hidden"&&Promise.all([L(),te(),G()])},15e3);return()=>clearInterval(i)},[v,L,te,G]);const Me=r.useCallback(()=>j(null),[]),se=r.useCallback(()=>{j(null),L()},[L]),rt=(t==null?void 0:t.status)===D.FAILED||(t==null?void 0:t.status)===D.CANCELLED,pe=(t==null?void 0:t.status)===D.COMPLETED||(t==null?void 0:t.status)===D.FAILED||(t==null?void 0:t.status)===D.CANCELLED;r.useEffect(()=>{Se.get("action")==="fork"&&t&&!C&&(pe&&Oe(),et(s=>(s.delete("action"),s),{replace:!0}))},[t,C,Se,pe]);async function nt(){W(!0);try{await n(x),F(!1),await L()}finally{W(!1)}}async function lt(){f(!0);try{await g.post(`web/tasks/${x}/retry`,{json:{reuseWorkspace:Ce}}),R(!1),oe(!1),await L()}finally{f(!1)}}function Oe(){_e(""),S(!0)}async function ct(){E(!0);try{const s=await g.post(`web/tasks/${x}/fork`,{json:{description:we||void 0}}).json();S(!1),J.success(a("tasks.fork_success")),c(`/tasks/${s.task.id}`)}catch{J.error(a("tasks.fork_error"))}finally{E(!1)}}const N=r.useMemo(()=>t?Gt(t):[],[t==null?void 0:t.configSnapshot,t==null?void 0:t.currentStage,t==null?void 0:t.status]),ue=N.findIndex(s=>s.status==="running");if(C)return e.jsx("div",{className:"flex h-full items-center justify-center font-mono",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:a("tasks.loading_task")})});if(!t)return e.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("tasks.task_not_found")}),e.jsxs("button",{onClick:()=>c("/tasks"),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:["< ",a("tasks.back_to_tasks")]})]});const w=t.status===D.QUEUED&&t.queuePosition!=null&&t.queueTotal!=null?{position:t.queuePosition,total:t.queueTotal}:null,y=_t(t.startedAt,t.completedAt),qe=w?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"queue"}),e.jsxs("span",{className:"text-[var(--info)]",children:["#",w.position," / ",w.total]})]}):null,Ue=e.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 py-3 shrink-0 md:hidden",children:[e.jsx("button",{onClick:()=>c("/tasks"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(Tt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"line-clamp-2 text-sm font-medium text-[var(--text-primary)]",title:ft(t),children:["#",t.id," ",We(t,100)]})]}),he=e.jsxs("div",{className:"hidden md:flex items-center gap-4 border-b border-[var(--border)] bg-[var(--bg-primary)] px-5 shrink-0",style:{height:44},children:[e.jsx(Ne,{status:t.status}),y&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["// time cost: ",y]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsx("span",{className:"text-xs text-[var(--info)]",children:a("tasks.queue_position",{position:String(w.position),total:String(w.total)})})]}),e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs(vt,{to:`/projects/${t.projectKey}`,className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors",children:["project: ",e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),t.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["branch: ",ne(p,t.branch)?e.jsx("a",{href:ne(p,t.branch),target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-primary)] hover:text-[var(--info)] hover:underline transition-colors",children:t.branch}):e.jsx("span",{className:"text-[var(--text-primary)]",children:t.branch})]})]}),t.mrUrl&&/^https?:\/\//.test(t.mrUrl)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs("a",{href:t.mrUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--info)] hover:underline",children:["MR: ",((ze=t.mrUrl.match(/!?\d+$/))==null?void 0:ze[0])??"view"]})]})]}),Ge=e.jsxs("div",{className:"flex items-center gap-3 border-t border-[var(--border)] bg-[var(--bg-primary)] px-4 md:px-5 shrink-0",style:{height:48},children:[!v&&e.jsxs("button",{onClick:()=>F(!0),className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--destructive)]/10 px-3 h-8 text-[11px] font-medium text-[var(--destructive)]",children:[e.jsx(ve,{className:"h-3 w-3"}),a("tasks.cancel_task")]}),rt&&e.jsxs("button",{onClick:()=>R(!0),className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-3 h-8 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-input)] transition-colors cursor-pointer",children:[e.jsx(be,{className:"h-3 w-3"}),a("tasks.retry_task")]}),pe&&e.jsxs("button",{onClick:Oe,className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-3 h-8 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-input)] transition-colors cursor-pointer",children:[e.jsx(Lt,{className:"h-3 w-3"}),a("tasks.fork_task")]}),t.workerId&&!v&&e.jsxs("button",{onClick:()=>{xe("pipeline"),setTimeout(()=>{var s,i;(i=(s=Pe.current)==null?void 0:s.scrollIntoView)==null||i.call(s,{behavior:"smooth",block:"center"})},50)},className:"hidden lg:flex items-center justify-center gap-1.5 rounded-[4px] px-3 h-8 text-[11px] font-medium text-[var(--info)]",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:[e.jsx(Dt,{className:"h-3 w-3"}),a("tasks.cursor_tunnel")]})]}),it=e.jsxs("div",{className:"hidden w-[280px] shrink-0 flex-col gap-6 overflow-y-auto border-l border-[var(--border)] bg-[var(--bg-primary)] p-4 lg:flex",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pipeline_stages")}),N.map(s=>{const i=s.status==="completed",d=s.status==="running",h=s.status==="failed";return e.jsxs("div",{className:`flex items-center gap-2 rounded-[4px] px-2 py-1.5 ${d?"bg-[#1a1a1a]":""}`,children:[i&&e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),d&&e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),h&&e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 text-[var(--destructive)]"}),s.status==="pending"&&e.jsx(Je,{className:"h-3.5 w-3.5 shrink-0 text-[#525252]"}),e.jsx("span",{className:"text-xs",style:{color:i?"var(--accent)":d?"#e5e5e5":h?"var(--destructive)":"#525252",fontWeight:d?500:400},children:d?`> ${s.name}`:s.name})]},s.name)})]}),y&&e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2 text-[11px] text-[var(--text-secondary)]",children:["// time cost: ",y]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.activity_log")}),u.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:u.slice(0,8).map((s,i)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-muted)]",children:s},i))}):e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_activity")})]})]}),fe=e.jsxs(e.Fragment,{children:[e.jsx(Mt,{isOpen:le,onClose:()=>F(!1),onConfirm:nt,taskId:x,isLoading:K}),e.jsx(Ot,{isOpen:M,onClose:()=>{R(!1),oe(!1)},onConfirm:lt,taskId:x,mrUrl:t.mrUrl??void 0,isLoading:ie,reuseWorkspace:Ce,onReuseWorkspaceChange:oe}),e.jsx(ke,{isOpen:ce,onClose:()=>S(!1),onConfirm:ct,title:a("tasks.fork_task"),message:a("tasks.fork_task_desc"),confirmLabel:a("tasks.fork_task"),confirmVariant:"accent",isLoading:I,children:e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["fork of #",x]}),e.jsx("textarea",{value:we,onChange:s=>_e(s.target.value),placeholder:a("tasks.fork_description_placeholder"),rows:4,className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)] resize-none"})]})})]});return at&&k==="terminal"?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-[var(--bg-primary)] font-mono lowercase h-screen",style:{height:"100dvh",paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:[he,e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-5 shrink-0",style:{height:36,backgroundColor:"#111111"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pty_terminal")}),e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] ${T==="connected"?"text-[var(--accent)]":T==="connecting"?"text-[var(--warning)]":"text-[var(--text-muted)]"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${T==="connected"?"bg-[var(--accent)]":T==="connecting"?"bg-[var(--warning)]":"bg-[#525252]"}`}),a(`tasks.${T}`)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v&&V==="auto"&&e.jsxs("button",{onClick:()=>{var s;return(s=U.current)==null?void 0:s.requestTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(He,{className:"h-3 w-3"}),a("tasks.take_over")]}),!v&&V==="manual"&&e.jsxs("button",{onClick:()=>{var s;return(s=U.current)==null?void 0:s.releaseTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(be,{className:"h-3 w-3"}),a("tasks.restore_auto")]}),t.currentStage&&e.jsxs("span",{className:"text-[11px] text-[var(--accent)]",children:[a("tasks.stage"),": ",t.currentStage]}),e.jsx("button",{onClick:()=>Ie(!1),className:"flex items-center rounded-[4px] bg-[var(--bg-card)] px-2.5 py-1 text-[var(--text-muted)]",children:e.jsx(Rt,{className:"h-3 w-3"})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Ve,{ref:U,taskId:x,sessionId:t.currentSessionId??void 0,taskFinished:v,onStatusChange:$e,onTakeoverChange:Re})}),Ge,fe]}):t.status===D.SUSPENDED?e.jsxs("div",{className:"flex h-full flex-col font-mono lowercase",children:[Ue,he,e.jsx("div",{className:"flex items-center gap-2 border-b px-4 md:px-6 py-2 text-xs shrink-0",style:{backgroundColor:"rgba(245,158,11,0.08)",borderColor:"rgba(245,158,11,0.2)",color:"var(--warning)"},children:a("tasks.task_suspended_banner")}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row gap-4 md:gap-6 p-4 md:p-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsxs("span",{className:"text-xl font-bold text-[var(--text-primary)]",children:["#",t.id]}),e.jsx("span",{className:"text-base text-[var(--text-secondary)] truncate max-w-[60%]",children:e.jsx(Et,{content:bt(t),children:We(t,200)})}),e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px] font-bold text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:a("tasks.status_suspended")})]}),e.jsx("div",{className:"flex items-center gap-2 md:hidden",children:e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px] font-bold text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:a("tasks.status_suspended")})}),o&&e.jsxs("div",{className:"rounded-[4px] border p-4",style:{borderColor:"rgba(245,158,11,0.27)",backgroundColor:"#1a1a1a"},children:[e.jsx("p",{className:"mb-2 text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pending_confirmation")}),e.jsx("p",{className:"mb-3 text-xs text-[var(--text-secondary)]",children:o.prompt??a("tasks.pipeline_requires_confirmation")}),e.jsx("div",{className:"mb-3 flex flex-col gap-1.5 text-[11px]",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"stage"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:o.stageName})]})}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:gap-3",children:[e.jsx("button",{onClick:async()=>{try{await g.post(`web/tasks/${x}/confirm-stage`,{json:{stageName:o.stageName,approved:!0}}),se()}catch{J.error(a("tasks.confirm_failed"))}},className:"flex-1 md:flex-none rounded-[4px] bg-[var(--accent)] px-4 py-2.5 md:py-2 text-[11px] font-bold text-[#0c0c0c]",children:a("tasks.confirm_and_proceed")}),e.jsx("button",{onClick:async()=>{try{await g.post(`web/tasks/${x}/confirm-stage`,{json:{stageName:o.stageName,approved:!1}}),se()}catch{J.error(a("tasks.confirm_failed"))}},className:"flex-1 md:flex-none rounded-[4px] bg-[#1a1a1a] px-4 py-2.5 md:py-2 text-[11px] text-[var(--destructive)]",style:{border:"1px solid rgba(239,68,68,0.27)"},children:a("tasks.reject")})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:hidden",children:[e.jsx("span",{className:"text-xs font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"status"}),e.jsx("span",{className:"font-bold text-[var(--warning)]",children:"suspended"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"created"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:re(t.createdAt)})]})]})]}),e.jsx("div",{className:"hidden md:flex flex-wrap items-center gap-2 py-2",children:N.map((s,i)=>{const d=s.status==="failed",h=s.status==="completed",P=s.status==="running"&&t.status===D.SUSPENDED,B=d?"var(--destructive)":h?"var(--accent)":P?"var(--warning)":"#525252",ae=d?"rgba(239,68,68,0.12)":h?"rgba(34,197,94,0.12)":P?"rgba(245,158,11,0.12)":"transparent";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px]",style:{color:B,backgroundColor:ae,fontWeight:P?700:400,border:P?`1px solid ${B}`:void 0},children:P?"confirm":`${s.name}${h?" ✓":d?" ✗":""}`}),i<N.length-1&&e.jsx("div",{className:"h-px w-6 bg-[var(--border)]"})]},s.name)})}),e.jsxs("div",{className:"hidden md:block min-h-[200px] flex-1 rounded-[4px] border border-[var(--border)] bg-[#0c0c0c] p-4",children:[e.jsx("p",{className:"mb-2 text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pty_output")}),e.jsxs("div",{className:"flex flex-col gap-1",children:[u.slice(-10).map((s,i)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-secondary)]",children:s},i)),u.length===0&&e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_output")})]})]})]}),e.jsxs("div",{className:"hidden w-[280px] shrink-0 flex-col gap-4 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:flex",children:[e.jsx("span",{className:"text-[13px] font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"status"}),e.jsx("span",{className:"font-bold text-[var(--warning)]",children:"suspended"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsx("span",{className:"text-xs font-bold text-[var(--accent)]",children:a("tasks.stage_timeline")}),e.jsx("div",{className:"flex flex-col gap-2",children:N.map(s=>{const i=s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#525252",d=s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#a3a3a3",h=s.status==="completed"?"completed":s.status==="running"?"suspended":s.status==="failed"?"failed":"pending";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-[4px]",style:{backgroundColor:i}}),e.jsxs("span",{className:"text-[11px]",style:{color:d,fontWeight:s.status==="running"?700:400},children:[s.name," ",h]})]},s.name)})}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsx("div",{className:"flex flex-col gap-1.5 text-[11px]",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"created"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:re(t.createdAt)})]})})]})]}),o&&e.jsx(Qe,{isOpen:!!o,onClose:Me,taskId:x,stageName:o.stageName,timeoutSeconds:Math.ceil(o.timeout/1e3),onSubmitted:se}),fe]}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden font-mono lowercase",children:[Ue,e.jsxs("div",{className:"flex flex-wrap items-center gap-3 gap-y-1 border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 py-2 shrink-0 md:hidden",children:[e.jsx(Ne,{status:t.status}),y&&e.jsxs("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:["// time cost: ",y]}),e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:t.projectKey}),t.workerName&&e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:t.workerName}),t.branch&&(ne(p,t.branch)?e.jsx("a",{href:ne(p,t.branch),target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-[11px] text-[var(--text-muted)] hover:text-[var(--info)] hover:underline truncate max-w-[80px] md:max-w-[120px] transition-colors",children:t.branch}):e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)] truncate max-w-[80px] md:max-w-[120px]",children:t.branch}))]}),he,t.errorMessage&&e.jsxs("div",{className:"flex items-center gap-2 border-b px-6 py-2 text-xs shrink-0 bg-[var(--destructive)]/10 text-[var(--destructive)]",style:{borderColor:"rgba(239,68,68,0.2)"},children:["// error: ",t.errorMessage]}),w&&e.jsxs("div",{className:"flex items-center gap-2 border-b px-4 md:px-6 py-2 text-xs shrink-0 text-[var(--info)]",style:{backgroundColor:"color-mix(in srgb, var(--info) 8%, transparent)",borderColor:"color-mix(in srgb, var(--info) 20%, transparent)"},children:[e.jsx(It,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{children:[a("tasks.queue_position_banner",{position:String(w.position),total:String(w.total)}),w.position>1?` — ${a("tasks.queue_ahead",{count:String(w.position-1)})}`:` — ${a("tasks.queue_next")}`]})]}),o&&e.jsx(Qe,{isOpen:!!o,onClose:Me,taskId:x,stageName:o.stageName,timeoutSeconds:Math.ceil(o.timeout/1e3),onSubmitted:se}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"flex items-center border-b border-[var(--border)] shrink-0 overflow-x-auto no-scrollbar",children:["terminal","pipeline","logs"].map(s=>e.jsx("button",{onClick:()=>xe(s),className:`shrink-0 whitespace-nowrap px-4 py-2.5 text-xs transition-colors ${k===s?"border-b-2 border-[var(--accent)] text-[var(--accent)] font-medium":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:a(s==="terminal"?"tasks.terminal":s==="pipeline"?"tasks.pipeline_tab":"tasks.logs")},s))}),k==="terminal"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 md:px-5 shrink-0",style:{height:36,backgroundColor:"#111111"},children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pty_terminal")}),e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] ${T==="connected"?"text-[var(--accent)]":T==="connecting"?"text-[var(--warning)]":"text-[var(--text-muted)]"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${T==="connected"?"bg-[var(--accent)]":T==="connecting"?"bg-[var(--warning)]":"bg-[#525252]"}`}),a(`tasks.${T}`)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v&&V==="auto"&&e.jsxs("button",{onClick:()=>{var s;return(s=U.current)==null?void 0:s.requestTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(He,{className:"h-3 w-3"}),a("tasks.take_over")]}),!v&&V==="manual"&&e.jsxs("button",{onClick:()=>{var s;return(s=U.current)==null?void 0:s.releaseTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(be,{className:"h-3 w-3"}),a("tasks.restore_auto")]}),!v&&V==="requesting"&&e.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 h-10 md:h-8 text-[11px] text-[var(--warning)]",children:[e.jsx(ge,{className:"h-3 w-3 animate-spin"}),a("tasks.requesting_takeover")]}),!v&&t.currentStage&&e.jsxs("button",{className:"hidden md:flex items-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-2.5 h-10 md:h-8 text-[11px] text-[var(--text-muted)]",children:[e.jsx(Pt,{className:"h-3 w-3"}),a("tasks.skip_stage")]}),e.jsx("button",{onClick:()=>Ie(!0),className:"hidden md:flex items-center rounded-[4px] bg-[var(--bg-card)] px-2.5 h-10 md:h-8 text-[var(--text-muted)]",children:e.jsx($t,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-4 py-2 shrink-0 md:hidden",children:[e.jsx(Ne,{status:t.status}),t.workerName&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["on ",t.workerName]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] px-4 py-3 shrink-0 md:hidden",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.stage_progress")}),e.jsx("div",{className:"mt-2 overflow-x-auto no-scrollbar pr-4",style:{borderRadius:0},children:e.jsx("div",{className:"flex items-center gap-1 py-0.5",children:N.map((s,i)=>{const d=s.status==="completed",h=s.status==="running",B=s.status==="failed"?"var(--destructive)":d||h?"var(--accent)":"#525252";return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"shrink-0 text-[11px] leading-normal whitespace-nowrap",style:{color:B,fontWeight:h?600:400},children:[s.name,d?" ✓":h?" ...":""]}),i<N.length-1&&e.jsx("div",{className:"mx-1.5 h-px w-4 shrink-0",style:{backgroundColor:B}})]},s.name)})})})]}),e.jsx("div",{className:"px-4 pt-3 pb-1 shrink-0 md:hidden",children:e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pty_output")})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Ve,{ref:U,taskId:x,sessionId:t.currentSessionId??void 0,taskFinished:v,onStatusChange:$e,onTakeoverChange:Re})}),Ge]}),k==="pipeline"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-4 md:p-6 lg:p-8",children:[e.jsx("div",{className:"mb-4 md:mb-5 overflow-x-auto no-scrollbar",style:{borderRadius:0},children:e.jsx("div",{className:"flex items-center py-5",children:N.map((s,i)=>{const d=s.status==="completed",h=s.status==="running",ae=s.status==="failed"?"var(--destructive)":d||h?"var(--accent)":"#525252";return e.jsxs("div",{className:"flex items-center",style:{flex:i<N.length-1?1:void 0},children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"flex h-6 w-6 md:h-7 md:w-7 items-center justify-center rounded-full shrink-0",style:{backgroundColor:ae},children:[d&&e.jsx("span",{className:"text-[11px] md:text-xs font-semibold text-[#0c0c0c]",children:"✓"}),h&&e.jsx("span",{className:"h-2 w-2 md:h-2.5 md:w-2.5 rounded-full bg-[#0c0c0c]"})]}),e.jsx("span",{className:"text-[11px] leading-normal font-medium whitespace-nowrap",style:{color:ae},children:s.name})]}),i<N.length-1&&e.jsx("div",{className:"mx-1 md:mx-2 h-0.5 flex-1 min-w-3 rounded-full",style:{backgroundColor:i<(ue>=0?ue:0)?"var(--accent)":"#525252"}})]},s.name)})})}),t.currentStage&&e.jsxs("div",{className:"mb-4 md:mb-5 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3 text-xs leading-relaxed",children:[e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// stage: ",t.currentStage," (",ue+1,"/",N.length,")"]}),t.startedAt&&e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// elapsed: ",re(t.startedAt).replace(" ago","")]}),y&&e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// time cost: ",y]}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// retries: ",t.retryCount,"/2"]})]}),!t.currentStage&&y&&e.jsx("div",{className:"mb-4 md:mb-5 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3 text-xs leading-relaxed",children:e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// time cost: ",y]})}),e.jsx("button",{onClick:()=>xe("terminal"),className:"flex-1 min-h-[100px] rounded-[4px] border border-dashed border-[var(--border)] flex items-center justify-center gap-2 text-[11px] text-[var(--text-muted)] hover:border-[var(--accent)] hover:text-[var(--accent)] transition-colors",children:e.jsxs("span",{children:["// ",a("tasks.view_terminal")]})}),e.jsxs("div",{className:"mt-4 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:hidden",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"branch"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.branch??"-"})]}),qe]})]}),e.jsxs("div",{className:"flex flex-col gap-6 mt-4 lg:hidden",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pipeline_stages")}),N.map(s=>{const i=s.status==="completed",d=s.status==="running",h=s.status==="failed";return e.jsxs("div",{className:`flex items-center gap-2 rounded-[4px] px-2 py-2 ${d?"bg-[var(--bg-input)]":""}`,children:[i&&e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),d&&e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),h&&e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 text-[var(--destructive)]"}),s.status==="pending"&&e.jsx(Je,{className:"h-3.5 w-3.5 shrink-0 text-[#525252]"}),e.jsx("span",{className:"text-xs leading-normal",style:{color:i?"var(--accent)":d?"var(--text-primary)":h?"var(--destructive)":"#525252",fontWeight:d?500:400},children:d?`> ${s.name}`:s.name})]},s.name)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.activity_log")}),u.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:u.slice(-12).map((s,i)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-muted)]",children:s},i))}):e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_activity")})]})]})]}),k==="logs"&&e.jsxs("div",{className:"flex flex-1 flex-col gap-3 md:gap-5 overflow-y-auto p-4 md:p-6 lg:p-8",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)] md:hidden",children:a("tasks.task_logs")}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar md:hidden",children:["","error","system"].map(s=>e.jsx("button",{onClick:()=>{De(s),O(0)},className:`shrink-0 rounded-[4px] px-2.5 py-1 text-[11px] ${H===s?"text-[var(--accent)] bg-[var(--bg-input)]":"text-[var(--text-muted)]"}`,children:s||"all"},s))}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Ct,{value:H,onChange:s=>{De(s),O(0)},options:[{value:"",label:"all"},{value:"stage_change",label:"stage_change"},{value:"info",label:"info"},{value:"warning",label:"warning"},{value:"error",label:"error"},{value:"system",label:"system"}],className:"w-36"})}),e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2",children:[e.jsx(gt,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",placeholder:a("tasks.search_logs"),value:ee,onChange:s=>{tt(s.target.value),O(0)},className:"flex-1 bg-transparent text-xs text-[var(--text-primary)] outline-none placeholder:text-[var(--text-muted)]"})]})]}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[Ee.map((s,i)=>e.jsxs("div",{className:`flex items-start md:items-center gap-2 md:gap-4 rounded-[4px] px-2 md:px-3 py-2 text-[11px] md:text-xs ${i%2===0?"bg-[var(--bg-card)]":""}`,children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:new Date(s.timestamp).toLocaleTimeString("en-US",{hour12:!1})}),e.jsx("span",{className:`shrink-0 font-medium ${Ut(s.type)}`,children:s.type}),e.jsx("span",{className:"min-w-0 break-words md:truncate text-[var(--text-primary)]",children:s.message})]},s.id)),Ee.length===0&&!st&&e.jsx("p",{className:"py-8 text-center text-xs text-[var(--text-muted)]",children:a("tasks.no_log_entries")})]}),Z>50&&e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Array.from({length:Math.ceil(Z/50)}).slice(0,5).map((s,i)=>e.jsx("button",{onClick:()=>O(i),className:`rounded-[4px] px-2 py-1 text-xs ${X===i?"bg-[var(--accent)] text-black font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:i+1},i)),Math.ceil(Z/50)>5&&e.jsx("button",{onClick:()=>O(X+1),disabled:X>=Math.ceil(Z/50)-1,className:"rounded-[4px] px-2 py-1 text-xs text-[var(--text-muted)] disabled:opacity-30",children:">"})]})]})]}),k==="terminal"&&it,k==="pipeline"&&e.jsxs("div",{className:"hidden w-[420px] shrink-0 flex-col gap-5 overflow-y-auto border-l border-[var(--border)] bg-[var(--bg-primary)] p-5 lg:flex",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"creator"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.creatorName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("common.created_at")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:re(t.createdAt)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("tasks.form_agent_type")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.agentType??"claude"})]}),y&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"time cost"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:y})]}),qe]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.workspace_section")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs",children:[e.jsxs("div",{className:"flex min-w-0 justify-between",children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:"branch"}),e.jsx("span",{className:"ml-4 min-w-0 truncate text-[var(--text-primary)]",children:t.branch??(q==null?void 0:q.branch)??"-"})]}),e.jsxs("div",{className:"flex min-w-0 justify-between",children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:"worktree"}),e.jsx("span",{className:"ml-4 min-w-0 truncate text-[var(--text-primary)]",children:(q==null?void 0:q.path)??"-"})]}),t.mrUrl&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("tasks.mr_link")}),e.jsx("a",{href:t.mrUrl,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[var(--info)] hover:underline",children:((Be=t.mrUrl.match(/!?\d+$/))==null?void 0:Be[0])??"view"})]})]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{ref:Pe,className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.cursor_tunnel_section")}),t.workerId?e.jsx(Ft,{taskId:x,taskFinished:v,compact:!0}):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.no_worker_assigned")})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.stage_timeline")}),e.jsx("div",{className:"flex flex-col gap-2 text-xs",children:N.map(s=>{const i=s.status==="completed"?"✓":s.status==="running"?"→":"·",d=s.status==="running"?"var(--accent)":s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":"#525252",h=s.status==="completed"?"done":s.status==="running"?"running...":s.status==="failed"?"failed":"pending";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold",style:{color:d},children:i}),e.jsx("span",{className:s.status==="running"?"font-medium":"",style:{color:d},children:s.name}),e.jsxs("span",{className:"text-[11px]",style:{color:"#525252"},children:["— ",h]})]},s.name)})})]})]})]}),fe]})}export{ts as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as pe,f as $,a as O,p as m,j as e,l as X,n as me,u as ue,i as be,r,h as E,X as ve,k as he,w as fe,H as ge,t as Q,x as ye,y as U,m as je}from"./index-XDDf1Oy_.js";import{a as ke,A as Ne,u as W}from"./task-constants-DkWAZdpz.js";import{T as Z}from"./TaskStatusBadge-CJTrG6-l.js";import{f as ee}from"./date-RFA7-ZGs.js";import{T as Ce}from"./Tooltip-DYbD-tQw.js";import{G as te}from"./git-fork-BSMVuD3x.js";import{S as P}from"./Select-CvM411zU.js";import{C as we}from"./copy-BpM8iA-r.js";import{E as Y}from"./EmptyState-aKMHLBhj.js";import{T as V}from"./Skeleton-qXDikSxR.js";import{P as Se}from"./plus-R7zuZ-Lg.js";import{C as _e}from"./chevron-left-B5ojlwvf.js";import{C as Te}from"./chevron-right-Yoiq-SRa.js";import"./status-colors-JE6CIHvW.js";const Ee=pe.memo(function({task:s}){const d=$(),{t:c}=O(),x=(a,v)=>c(`common.${a}`,{n:v}),i=s.status===m.COMPLETED||s.status===m.FAILED||s.status===m.CANCELLED;return e.jsxs("tr",{onClick:()=>d(`/tasks/${s.id}`),className:"cursor-pointer border-b border-[var(--border-row)] transition-colors hover:bg-[var(--bg-input)]",children:[e.jsxs("td",{className:"w-16 py-3 pr-4 font-mono text-xs font-medium text-[var(--text-secondary)] text-right tabular-nums",children:["#",s.id]}),e.jsx("td",{className:"py-3 pr-4 text-sm text-[var(--text-primary)]",children:e.jsx(Ce,{content:me(s),children:X(s)})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx(Z,{status:s.status})}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.projectKey}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.developerName??s.creatorName??"-"}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.workerName??"—"}),e.jsx("td",{className:"py-3 font-mono text-xs text-[var(--text-muted)]",children:e.jsxs("span",{className:"flex items-center gap-2",children:[ee(s.createdAt,x),i&&e.jsx("button",{onClick:a=>{a.stopPropagation(),d(`/tasks/${s.id}?action=fork`)},className:"shrink-0 rounded-[4px] p-1 text-[var(--text-muted)] hover:text-[var(--accent)] hover:bg-[var(--bg-input)] transition-colors",title:c("tasks.fork_task"),children:e.jsx(te,{className:"h-3 w-3"})})]})})]})});function Pe({isOpen:n,onClose:s,projects:d,projectsLoading:c,onSubmit:x,isSubmitting:i}){const{t:a}=O();ue(o=>o.user);const v=be(),[u,A]=r.useState(""),[b,I]=r.useState(""),[p,D]=r.useState("feat"),[k,C]=r.useState(""),[w,S]=r.useState(""),[y,_]=r.useState(""),[h,j]=r.useState(""),[L,R]=r.useState([]),[F,N]=r.useState("");r.useEffect(()=>{if(!n||(A(""),I(""),D("feat"),C(""),S(""),_(""),j(""),N(""),!v))return;const o=new AbortController;return E.get("admin/developers",{signal:o.signal}).json().then(R).catch(()=>{}),()=>o.abort()},[n,v]),r.useEffect(()=>{if(!n)return;function o(f){f.key==="Escape"&&s()}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n,s]);async function z(o){if(o.preventDefault(),N(""),!u||!b.trim()){N(a("tasks.project_and_description_required"));return}try{await x({projectKey:u,description:b.trim(),workerId:y||void 0,developerId:h?Number(h):void 0,taskType:p,branchSlug:w.trim()||void 0,agentType:k||void 0})}catch(f){const B=f instanceof Error?f.message:a("tasks.failed_to_create_task");N(B)}}return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 font-mono",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:o=>{o.target===o.currentTarget&&s()},children:e.jsxs("div",{className:"w-full max-w-[480px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)]",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-6 py-4",children:[e.jsxs("h2",{className:"text-sm text-[var(--text-primary)]",children:["// ",a("tasks.new_task")]}),e.jsx("button",{onClick:s,className:"text-[var(--text-muted)] transition-colors hover:text-[var(--text-primary)]",children:e.jsx(ve,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:z,className:"px-6 py-5",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.project")}),e.jsx(P,{value:u,onChange:A,options:d.map(o=>({value:o.key,label:o.name})),placeholder:a(c?"common.loading":"tasks.select_project"),disabled:c})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.task_type")}),e.jsx(P,{value:p,onChange:D,options:ke})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.form_agent_type")}),e.jsx(P,{value:k,onChange:C,options:Ne})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.task_description")}),e.jsx("textarea",{value:b,onChange:o=>I(o.target.value),placeholder:a("tasks.describe_task_placeholder"),rows:4,className:"w-full resize-none rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.target_worker")}),e.jsx("input",{type:"text",value:y,onChange:o=>_(o.target.value),placeholder:a("tasks.any_able"),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.branch_slug")}),e.jsx("input",{type:"text",value:w,onChange:o=>S(o.target.value),placeholder:a("tasks.branch_slug_placeholder"),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),v&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.assign_developer")}),e.jsx(P,{value:h,onChange:j,options:L.map(o=>({value:String(o.id),label:o.name})),placeholder:a("tasks.select_developer")})]}),F&&e.jsx("div",{className:"rounded-[4px] bg-[#2a1515] border border-[var(--destructive)]/30 px-3 py-2 text-xs text-[var(--destructive)]",children:F})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:s,className:"rounded-[4px] border border-[var(--border)] bg-transparent px-4 py-2 text-xs text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]",children:a("common.cancel")}),e.jsx("button",{type:"submit",disabled:i||!u||!b.trim(),className:"rounded-[4px] bg-[var(--accent)] px-4 py-2 text-xs text-black transition-opacity hover:opacity-90 disabled:opacity-40",children:a(i?"common.creating":"tasks.create_task")})]})]})]})}):null}function De({isOpen:n,onClose:s,onForceCreate:d,onViewExisting:c,similarTask:x,isLoading:i}){const{t:a}=O();return!x||!n?null:e.jsx("div",{onClick:s,style:{position:"fixed",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},children:e.jsxs("div",{onClick:v=>v.stopPropagation(),style:{width:"100%",maxWidth:"480px",backgroundColor:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"4px",padding:"1.5rem",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsxs("div",{style:{marginBottom:"1.25rem"},children:[e.jsxs("div",{style:{color:"var(--accent)",fontSize:"0.875rem",fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx(we,{style:{width:"1rem",height:"1rem"}}),a("tasks.dedup_title")]}),e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.7rem",marginTop:"0.25rem"},children:a("tasks.dedup_description")})]}),e.jsxs("div",{style:{marginBottom:"1.25rem",padding:"0.75rem",border:"1px solid var(--border)",borderRadius:"4px",backgroundColor:"var(--bg-primary)"},children:[e.jsxs("div",{style:{color:"var(--text-muted)",fontSize:"0.65rem",fontFamily:"'JetBrains Mono', monospace"},children:["#",x.id," · ",x.status]}),e.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.75rem",marginTop:"0.375rem",lineHeight:"1.5"},children:x.description})]}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[e.jsx("button",{type:"button",onClick:s,disabled:i,className:"text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--text-muted)]",style:{flex:1,padding:"0.5rem",backgroundColor:"transparent",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"0.75rem",fontFamily:"'JetBrains Mono', monospace",cursor:i?"not-allowed":"pointer",opacity:i?.7:1,transition:"color 0.15s, border-color 0.15s"},children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>c(x.id),style:{flex:1,padding:"0.5rem",backgroundColor:"transparent",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"0.75rem",fontFamily:"'JetBrains Mono', monospace",cursor:"pointer"},children:a("tasks.view_existing")}),e.jsx("button",{type:"button",onClick:d,disabled:i,style:{flex:1,padding:"0.5rem",backgroundColor:"var(--warning)",color:"#0C0C0C",border:"none",borderRadius:"4px",fontSize:"0.75rem",fontWeight:600,fontFamily:"'JetBrains Mono', monospace",cursor:i?"not-allowed":"pointer",opacity:i?.7:1},children:a(i?"common.creating":"tasks.dedup_create_anyway")})]})]})})}function Fe({task:n}){const s=$(),d=n.status===m.COMPLETED||n.status===m.FAILED||n.status===m.CANCELLED;return e.jsxs("div",{onClick:()=>s(`/tasks/${n.id}`),className:"cursor-pointer rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3 transition-colors active:bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] text-[var(--text-primary)] leading-tight line-clamp-2",title:je(n),children:["#",n.id," ",X(n)]}),e.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[d&&e.jsx("button",{onClick:c=>{c.stopPropagation(),s(`/tasks/${n.id}?action=fork`)},className:"rounded-[4px] p-1 text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors",children:e.jsx(te,{className:"h-3 w-3"})}),e.jsx(Z,{status:n.status})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[11px] text-[var(--text-muted)]",children:[e.jsx("span",{children:ee(n.createdAt)}),e.jsx("span",{children:"·"}),e.jsx("span",{children:n.projectKey}),n.workerName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:n.workerName})]})]})]})}const Ae=[{key:"all",labelKey:"tasks.tab_all"},{key:m.RUNNING,labelKey:"tasks.tab_running"},{key:m.QUEUED,labelKey:"tasks.tab_queued"},{key:m.COMPLETED,labelKey:"tasks.tab_completed"},{key:m.FAILED,labelKey:"tasks.tab_failed"},{key:m.CANCELLED,labelKey:"tasks.tab_cancelled"}],Ie=20;function We(){const n=$(),{t:s}=O(),{tasks:d,loading:c,fetchTasks:x}=W(),i=he(t=>t.taskSeq),[a,v]=r.useState("all"),[u,A]=r.useState(""),[b,I]=r.useState(""),[p,D]=r.useState(""),[k,C]=r.useState(void 0),[w,S]=r.useState([]),y=W(t=>t.nextCursor),[_,h]=r.useState(!1);fe(r.useMemo(()=>e.jsxs("button",{onClick:()=>h(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs font-mono text-black transition-opacity hover:opacity-90",children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),s("tasks.new_task")]}),[s]));const[j,L]=r.useState([]),[R,F]=r.useState(!1),[N,z]=r.useState([]),[o,f]=r.useState(!1),[B,K]=r.useState(!1),[se,re]=r.useState(null),[q,M]=r.useState(null),G=r.useCallback(t=>{const l={limit:String(Ie)};return a!=="all"&&(l.status=a),u&&(l.projectKey=u),b&&(l.developerId=b),t&&(l.cursor=t),l},[a,u,b]);r.useEffect(()=>{x(G(k))},[G,k,x,i]),r.useEffect(()=>{C(void 0),S([])},[a,u,b]),r.useEffect(()=>{let t=!1;return(async()=>{try{const[g,xe]=await Promise.all([E.get("web/projects").json(),E.get("web/projects/-/developers").json()]);if(t)return;L(g),z(xe)}catch{}})(),()=>{t=!0}},[]),r.useEffect(()=>{if(!_||j.length>0)return;F(!0);let t=!1;return(async()=>{try{const g=await E.get("web/projects").json();t||L(g)}catch{}finally{t||F(!1)}})(),()=>{t=!0}},[_,j.length]);const ae=r.useCallback(async t=>{f(!0);try{const l=await E.post("web/tasks",{json:{projectKey:t.projectKey,description:t.description,workerId:t.workerId,developerId:t.developerId,taskType:t.taskType,branchSlug:t.branchSlug,agentType:t.agentType}}).json();h(!1),n(`/tasks/${l.task.id}`)}catch(l){if(l instanceof ge&&l.response.status===409){try{const g=await l.response.json();if(g.confirmRequired){re({id:g.confirmRequired.taskId,description:g.confirmRequired.message,status:"active"}),M(t),h(!1),K(!0);return}}catch{}Q.error(s("tasks.similar_task_exists"))}else{const g=l instanceof Error?l.message:String(l);Q.error(g)}}finally{f(!1)}},[n]),oe=r.useCallback(async()=>{if(q){f(!0);try{const t=await E.post("web/tasks",{json:{...q,force:!0}}).json();K(!1),M(null),n(`/tasks/${t.task.id}`)}finally{f(!1)}}},[q,n]),T=r.useMemo(()=>{if(!p.trim())return d;const t=p.toLowerCase();return d.filter(l=>(l.name??"").toLowerCase().includes(t)||l.description.toLowerCase().includes(t)||String(l.id).includes(p))},[d,p]),ne=r.useCallback(()=>{y&&(S(t=>[...t,k??""]),C(y))},[y,k]),le=r.useCallback(()=>{S(t=>{if(t.length===0)return t;const l=t.slice(0,-1);return C(t.at(-1)||void 0),l})},[]),ce=w.length+1,ie=r.useMemo(()=>[{value:"",label:s("tasks.filter_project")},...j.map(t=>({value:t.key,label:t.name}))],[j,s]),de=r.useMemo(()=>[{value:"",label:s("tasks.filter_developer")},...N.map(t=>({value:String(t.id),label:t.name}))],[N,s]),H=s(p?"tasks.try_adjusting_search":"tasks.create_first_task"),J=p?void 0:e.jsx("button",{onClick:()=>h(!0),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:s("tasks.create_task")});return e.jsxs("div",{className:"mx-auto max-w-6xl px-2 py-4 md:px-4 md:py-6 font-mono",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 md:gap-4 md:flex-row md:items-center",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 md:pb-0 no-scrollbar pr-4 md:pr-0",children:Ae.map(t=>e.jsx("button",{onClick:()=>v(t.key),className:`shrink-0 rounded-[4px] px-3 py-2 h-10 md:h-8 text-xs transition-colors ${a===t.key?"text-[var(--accent)] bg-[var(--bg-input)]":"text-[var(--text-muted)] bg-[var(--bg-card)] hover:text-[var(--text-secondary)]"}`,children:s(t.labelKey)},t.key))}),e.jsxs("div",{className:"flex flex-col gap-2 md:ml-auto md:flex-row md:items-center",children:[e.jsxs("div",{className:"relative md:w-52",children:[e.jsx(ye,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",placeholder:s("tasks.search_tasks"),value:p,onChange:t=>D(t.target.value),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] py-1.5 pl-8 pr-3 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"}),p&&e.jsx("button",{onClick:()=>D(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)]",children:"x"})]}),e.jsx(P,{value:u,onChange:A,options:ie,className:"md:w-40"}),e.jsx(P,{value:b,onChange:I,options:de,className:"md:w-40"})]})]}),e.jsx("div",{className:"hidden md:block rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)]",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)] text-[11px] font-medium text-[#525252]",children:[e.jsx("th",{className:"w-16 px-4 py-2.5 text-right",children:s("tasks.id")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.description_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.status_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.project_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.assignee")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.worker")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.time")})]})}),e.jsxs("tbody",{children:[c&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(V,{rows:5})})}),!c&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(Y,{icon:U,title:s("tasks.no_tasks_found"),description:H,action:J})})}),T.map(t=>e.jsx(Ee,{task:t},t.id))]})]})}),e.jsxs("div",{className:"flex flex-col gap-2 md:hidden",children:[c&&T.length===0&&e.jsx("div",{className:"p-4",children:e.jsx(V,{rows:5})}),!c&&T.length===0&&e.jsx(Y,{icon:U,title:s("tasks.no_tasks_found"),description:H,action:J}),T.map(t=>e.jsx(Fe,{task:t},t.id))]}),(w.length>0||y)&&e.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["// page ",ce]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:le,disabled:w.length===0,className:"flex items-center justify-center gap-1 rounded-[4px] border border-[var(--border)] px-2.5 py-1 min-h-[44px] min-w-[44px] md:min-h-0 md:min-w-0 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--accent)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),s("tasks.prev")]}),e.jsxs("button",{onClick:ne,disabled:!y,className:"flex items-center justify-center gap-1 rounded-[4px] border border-[var(--border)] px-2.5 py-1 min-h-[44px] min-w-[44px] md:min-h-0 md:min-w-0 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--accent)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[s("common.next"),e.jsx(Te,{className:"h-3.5 w-3.5"})]})]})]}),e.jsx(Pe,{isOpen:_,onClose:()=>h(!1),projects:j,projectsLoading:R,onSubmit:ae,isSubmitting:o}),e.jsx(De,{isOpen:B,onClose:()=>{K(!1),M(null)},onForceCreate:oe,onViewExisting:t=>{K(!1),M(null),n(`/tasks/${t}`)},similarTask:se,isLoading:o})]})}export{We as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l,j as a}from"./index-
|
|
1
|
+
import{a as l,j as a}from"./index-XDDf1Oy_.js";import{a as u}from"./status-colors-JE6CIHvW.js";const r={QUEUED:"tasks.status_queued",ASSIGNED:"tasks.status_assigned",RUNNING:"tasks.status_running",SUSPENDED:"tasks.status_suspended",COMPLETED:"tasks.status_completed",FAILED:"tasks.status_failed",CANCELLED:"tasks.status_cancelled"};function E({status:s}){const{t:e}=l(),t=r[s],n=t?e(t):(s??"unknown").toLowerCase(),o=u(s);return a.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs",style:{color:o},children:[a.jsx("span",{style:{fontSize:"0.6rem"},children:"●"}),n]})}export{E as T};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as Z,o as ce,h as M,p as y,a as P,r as c,k as q,q as le,s as oe,j as e,X as ee,v as de,f as xe,l as me,m as ue}from"./index-XDDf1Oy_.js";import{T as H,u as pe,a as z,C as G}from"./task-constants-DkWAZdpz.js";import{P as he,H as fe,C as ve}from"./PtyTerminal-DJ4ToCWx.js";import{i as J,O as te}from"./OnboardingGuide-Cj_QW_kH.js";import{S as C,C as ge}from"./Select-CvM411zU.js";import{a as se}from"./status-colors-JE6CIHvW.js";import{a as be}from"./date-RFA7-ZGs.js";import{u as ae}from"./useFetch-D6-vLVQP.js";import{P as $}from"./plus-R7zuZ-Lg.js";import{R as je}from"./rotate-ccw-B1uEgqoV.js";import{W as ke}from"./wifi-B8ZV0Cuq.js";import"./chevron-right-Yoiq-SRa.js";/**
|
|
2
|
+
* @license lucide-react v0.469.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 Ne=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
|
7
|
+
* @license lucide-react v0.469.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 ye=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),ne="overlord_home_terminal";function we(){try{const t=localStorage.getItem(ne);if(t)return JSON.parse(t)}catch{}return{pinnedTaskIds:[],activeTaskId:null}}let Y="";function U(t){const a=JSON.stringify(t);a!==Y&&(Y=a,localStorage.setItem(ne,a))}const Q=we(),Te=new Set([y.QUEUED,y.ASSIGNED,y.RUNNING,y.SUSPENDED]);let L=!1;const Se=ce((t,a)=>({pinnedTaskIds:Q.pinnedTaskIds,activeTaskId:Q.activeTaskId,taskMetas:{},stageConfirm:null,loading:!1,setActiveTask:s=>{t({activeTaskId:s}),U({pinnedTaskIds:a().pinnedTaskIds,activeTaskId:s})},pinTask:s=>{const{pinnedTaskIds:n}=a();if(n.includes(s))return;const l=[...n,s];t({pinnedTaskIds:l}),U({pinnedTaskIds:l,activeTaskId:a().activeTaskId})},unpinTask:s=>{const{pinnedTaskIds:n,activeTaskId:l,taskMetas:x}=a(),r=n.filter(h=>h!==s),d=l===s?r[0]??null:l,{[s]:p,...i}=x;t({pinnedTaskIds:r,activeTaskId:d,taskMetas:i}),U({pinnedTaskIds:r,activeTaskId:d})},loadActiveTasks:async()=>{if(!L){L=!0,t({loading:!0});try{const n=(await M.get("web/tasks",{searchParams:{limit:"30"}}).json()).data.filter(i=>Te.has(i.status)),l={};for(const i of n)l[i.id]={id:i.id,name:i.name,description:i.description,status:i.status,projectKey:i.projectKey,currentStage:i.currentStage,currentSessionId:i.currentSessionId,updatedAt:i.updatedAt};const r=[...n].sort((i,h)=>h.updatedAt.localeCompare(i.updatedAt)).map(i=>i.id),{activeTaskId:d}=a(),p=d&&r.includes(d)?d:r[0]??null;t({taskMetas:l,pinnedTaskIds:r,activeTaskId:p}),U({pinnedTaskIds:r,activeTaskId:p})}catch{}finally{L=!1,t({loading:!1})}}},fetchStageConfirm:async s=>{try{const n=await M.get(`web/tasks/${s}/pending-confirm`).json();t({stageConfirm:n.confirm})}catch{t({stageConfirm:null})}},clearStageConfirm:()=>t({stageConfirm:null}),updateTaskMeta:(s,n)=>{const{taskMetas:l}=a(),x=l[s];x&&t({taskMetas:{...l,[s]:{...x,...n}}})}}));function Ce(){const[t,a]=c.useState(()=>J());c.useEffect(()=>{const n=()=>a(!0),l=()=>a(J());return window.addEventListener("onboarding-dismissed",n),window.addEventListener("storage",l),()=>{window.removeEventListener("onboarding-dismissed",n),window.removeEventListener("storage",l)}},[]);const{data:s}=ae(()=>t?Promise.resolve(null):M.get("web/dashboard/stats").json(),[t]);return t||!s?null:{activeTasks:(s.active_tasks??0)+(s.queued_tasks??0),totalWorkers:s.online_workers??0,totalProjects:s.project_count??0,totalDevelopers:s.developer_count??0}}function _e({taskId:t,confirm:a,onSubmitted:s}){const{t:n}=P(),[l,x]=c.useState(a.timeout),[r,d]=c.useState(!1);c.useEffect(()=>{x(a.timeout);const i=setInterval(()=>{x(h=>h<=1?(clearInterval(i),0):h-1)},1e3);return()=>clearInterval(i)},[a.timeout,a.stageName]);const p=c.useCallback(async i=>{d(!0);try{await M.post(`web/tasks/${t}/confirm-stage`,{json:{stageName:a.stageName,approved:i}}),s()}catch{}finally{d(!1)}},[t,a.stageName,s]);return e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b-2 border-[var(--warning)] bg-[var(--warning)]/10 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 text-[var(--warning)]"}),e.jsxs("span",{className:"truncate text-xs text-[var(--text-primary)]",children:["// stage: ",a.stageName]}),e.jsx("span",{className:"shrink-0 text-xs text-[var(--warning)]",children:be(l)})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("button",{onClick:()=>p(!1),disabled:r,className:"rounded-[4px] border border-[var(--border)] px-2 py-1 text-[11px] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",children:n("tasks.reject")}),e.jsx("button",{onClick:()=>p(!0),disabled:r,className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:n(r?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})]})}function Ie({projectKey:t,onProjectChange:a,onCreated:s}){const{t:n}=P(),l=pe(u=>u.createTask),[x,r]=c.useState(""),[d,p]=c.useState("feat"),[i,h]=c.useState(void 0),[f,_]=c.useState(!1),[I,E]=c.useState(!1),[F,D]=c.useState(!1),{data:w}=ae(()=>M.get("web/projects").json(),[]),v=c.useMemo(()=>{const u=(w??[]).map(R=>({value:R.key,label:R.key}));return[{value:"",label:n("terminal_home.all_projects")},...u]},[w,n]),g=c.useMemo(()=>(w??[]).find(u=>u.key===t)??null,[w,t]),b=c.useRef(!1);c.useEffect(()=>{if(!b.current){if(t){b.current=!0;return}v.length>1&&(a(v[1].value),b.current=!0)}},[t,v,a]),c.useEffect(()=>{h(void 0)},[t]);const A=i??(g==null?void 0:g.agentType)??"",m=c.useCallback(u=>{if(!g||u===g.agentType){h(void 0);return}h(u)},[g]),T=!!t&&!!x.trim();function N(){T&&E(!0)}async function k(){if(E(!1),!!T){_(!0);try{const u=await l({projectKey:t,description:x.trim(),taskType:d,agentType:i||void 0});r(""),s(u.id)}catch{}finally{_(!1)}}}const S=n("terminal_home.confirm_create_message").replace("{taskType}",d).replace("{projectKey}",t).replace("{description}",x.trim()),O="flex-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex items-center gap-2 border-b border-[var(--border)] bg-[var(--bg-card)] px-3 py-2",children:[e.jsx("div",{className:"w-[140px]",children:e.jsx(C,{value:t,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(C,{value:d,onChange:p,options:z})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(C,{value:A,onChange:m,options:G,placeholder:n("tasks.form_agent_type"),disabled:f||!t})}),e.jsx("input",{type:"text",value:x,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&N(),placeholder:n("terminal_home.task_description_placeholder"),className:O,disabled:f}),e.jsxs("button",{onClick:N,disabled:f||!T,className:"flex items-center gap-1 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx($,{className:"h-3 w-3"}),n(f?"common.creating":"terminal_home.new_task")]})]}),e.jsx("div",{className:"md:hidden border-b border-[var(--border)] bg-[var(--bg-card)]",children:F?e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(C,{value:t,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(C,{value:d,onChange:p,options:z})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(C,{value:A,onChange:m,options:G,placeholder:n("tasks.form_agent_type"),disabled:f||!t})}),e.jsx("button",{onClick:()=>D(!1),className:"p-1 text-[var(--text-muted)]",children:e.jsx(ee,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&N(),placeholder:n("terminal_home.task_description_placeholder"),className:O,disabled:f}),e.jsx("button",{onClick:N,disabled:f||!T,className:"rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:e.jsx($,{className:"h-3 w-3"})})]})]}):e.jsxs("button",{onClick:()=>D(!0),className:"flex w-full items-center justify-center gap-1 py-2 text-xs text-[var(--accent)] hover:opacity-80",children:[e.jsx($,{className:"h-3.5 w-3.5"}),n("terminal_home.new_task")]})}),e.jsx(de,{isOpen:I,onClose:()=>E(!1),onConfirm:k,title:n("terminal_home.confirm_create_title"),message:S,confirmVariant:"accent",confirmLabel:n("terminal_home.new_task"),isLoading:f})]})}function V({status:t,size:a}){const s=t===y.SUSPENDED,n=se(t),l=a==="sm"?"h-1.5 w-1.5":"h-2 w-2";return e.jsx("span",{className:`${l} shrink-0 rounded-full ${s?"animate-pulse":""}`,style:{backgroundColor:s?"var(--warning)":n}})}function Ee({tasks:t,activeId:a,onSelect:s,onUnpin:n,children:l}){const x=xe();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex flex-col border-r border-[var(--border)] bg-[var(--bg-card)] overflow-y-auto",style:{width:200,minWidth:200},children:[e.jsx("div",{className:"border-b border-[var(--border)] px-3 py-2",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"// active tasks"})}),t.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):e.jsx("div",{className:"flex-1",children:t.map(r=>{const d=r.id===a;return e.jsxs("div",{onClick:()=>s(r.id),className:`group flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${d?"bg-[var(--accent)]/10 text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-input)] hover:text-[var(--text-primary)]"}`,children:[e.jsx(V,{status:r.status,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",title:ue(r),children:[e.jsxs("div",{className:"truncate text-xs",children:["#",r.id," ",me(r)]}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)]",children:r.projectKey})]}),e.jsx("button",{onClick:p=>{p.stopPropagation(),n(r.id)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--text-primary)]",title:"unpin",children:e.jsx(ee,{className:"h-3 w-3"})}),e.jsx("button",{onClick:p=>{p.stopPropagation(),x(`/tasks/${r.id}`)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--accent)]",title:"open detail",children:e.jsx("span",{className:"text-[10px] leading-none",children:"→"})})]},r.id)})})]}),e.jsxs("div",{className:"flex flex-col md:hidden",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar border-b border-[var(--border)] bg-[var(--bg-card)] px-2",style:{height:44},children:t.length===0?e.jsx("div",{className:"flex items-center justify-center w-full",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):t.map(r=>{const d=r.id===a;return e.jsxs("button",{onClick:()=>s(r.id),className:`flex shrink-0 items-center gap-1.5 px-3 border-b-2 transition-colors ${d?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)]"}`,style:{height:44},children:[e.jsx(V,{status:r.status,size:"sm"}),e.jsxs("span",{className:"text-[11px] whitespace-nowrap",children:["#",r.id]})]},r.id)})}),l]})]})}function Ae({task:t,takeoverState:a,onTakeover:s,onRelease:n}){const l=se(t.status),x=a==="manual";return e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:36,minHeight:36},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:t.projectKey}),e.jsx("span",{className:"text-[11px]",style:{color:l},children:t.status.toLowerCase()}),t.currentStage&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["// ",t.currentStage]})]}),e.jsx("div",{className:"flex items-center gap-1",children:!H.includes(t.status)&&(x?e.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(je,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"restore auto"})]}):e.jsxs("button",{onClick:s,disabled:a==="requesting",className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--warning)] disabled:opacity-50",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(fe,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"take over"})]}))})]})}function Me({task:t,ptyStatus:a}){const s=a==="connected";return e.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:28,minHeight:28},children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:t.currentStage?`stage: ${t.currentStage}`:`task #${t.id}`}),e.jsxs("span",{className:`flex items-center gap-1 text-[10px] ${s?"text-[var(--accent)]":"text-[var(--text-muted)]"}`,children:[s?e.jsx(ke,{className:"h-2.5 w-2.5"}):e.jsx(ye,{className:"h-2.5 w-2.5"}),s?"connected":a]})]})}function K({onboardingData:t}){const[a,s]=c.useState(!1),{t:n}=P();return t?a?e.jsxs("div",{className:"border-b border-[var(--accent)]/30",children:[e.jsxs("button",{onClick:()=>s(!1),className:"flex w-full items-center justify-between bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(Ne,{className:"h-3 w-3 text-[var(--text-muted)]"})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(te,{data:t})})]}):e.jsxs("button",{onClick:()=>s(!0),className:"flex w-full items-center justify-between border-b border-[var(--accent)]/30 bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",style:{height:36},children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(ge,{className:"h-3 w-3 text-[var(--text-muted)]"})]}):null}function X({onboardingData:t}){const{t:a}=P();return e.jsx("div",{className:`flex flex-1 flex-col items-center p-4 md:p-6 ${t?"overflow-auto":"justify-center"}`,children:t?e.jsx("div",{className:"w-full max-w-lg",children:e.jsx(te,{data:t})}):e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"mb-3 text-3xl text-[var(--border)]",children:[">","_"]}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:a("terminal_home.no_active_tasks")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:a("terminal_home.create_task_hint")})]})})}function ze(){const{t}=P(),{pinnedTaskIds:a,activeTaskId:s,taskMetas:n,stageConfirm:l,loading:x,setActiveTask:r,pinTask:d,unpinTask:p,loadActiveTasks:i,fetchStageConfirm:h,clearStageConfirm:f,updateTaskMeta:_}=Se(),I=c.useRef(null),[E,F]=c.useState("disconnected"),[D,w]=c.useState("auto"),[v,g]=c.useState(""),b=q(o=>o.lastEvent),A=q(o=>o.status),m=s?n[s]??null:null,T=m?H.includes(m.status):!1,N=c.useRef(!1);c.useEffect(()=>{!N.current&&m&&(g(m.projectKey),N.current=!0)},[m]);const k=c.useMemo(()=>{const o=a.map(j=>n[j]).filter(Boolean);return v?o.filter(j=>j.projectKey===v):o},[a,n,v]);c.useEffect(()=>{k.length>0&&s&&!k.some(o=>o.id===s)&&r(k[0].id)},[k,s,r]);const S=Ce();le(m?oe(m):null),c.useEffect(()=>{i()},[i]),c.useEffect(()=>{s&&(m==null?void 0:m.status)===y.SUSPENDED?h(s):f()},[s,m==null?void 0:m.status,h,f]),c.useEffect(()=>{if(b){if(b.event==="task_status_changed"){const{taskId:o,status:j,currentStage:B}=b,W={status:j,updatedAt:new Date().toISOString()};B!==void 0&&(W.currentStage=B),_(o,W),j===y.SUSPENDED&&o===s&&h(o),H.includes(j)&&o===s&&f()}b.event==="task_created"&&i()}},[b,s,h,f,_,i]),c.useEffect(()=>{if(A==="connected")return;const j=setInterval(()=>{document.visibilityState!=="hidden"&&i()},15e3);return()=>clearInterval(j)},[A,i]);const O=c.useCallback(o=>{d(o),r(o),i()},[d,r,i]),u=c.useCallback(()=>{f(),i()},[f,i]),R=c.useCallback(()=>{var o;(o=I.current)==null||o.requestTakeover()},[]),re=c.useCallback(()=>{var o;(o=I.current)==null||o.releaseTakeover()},[]);if(x&&a.length===0)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:t("common.loading")})});const ie=k.length>0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx(Ie,{projectKey:v,onProjectChange:g,onCreated:O}),e.jsx("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{tasks:k,activeId:s,onSelect:r,onUnpin:p,children:e.jsx("div",{className:"md:hidden",children:e.jsx(K,{onboardingData:S})})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:m?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(K,{onboardingData:S})}),e.jsx(Ae,{task:m,takeoverState:D,onTakeover:R,onRelease:re}),l&&s&&e.jsx(_e,{taskId:s,confirm:l,onSubmitted:u}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(he,{taskId:s,sessionId:m.currentSessionId??void 0,taskFinished:T,onStatusChange:F,onTakeoverChange:w,ref:I},s)}),e.jsx(Me,{task:m,ptyStatus:E})]}):e.jsx(X,{onboardingData:S})})]}):e.jsx(X,{onboardingData:S})})]})}export{ze as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,r as n,j as e,h as w,f as M,z as O,Q as k,K as $,a0 as T,p as K}from"./index-Cxiuct-Z.js";import{K as E}from"./key-CFQniqbQ.js";import{C as S}from"./copy-DsibVBOY.js";import{E as V}from"./external-link-oEMmDqkw.js";import{E as P}from"./EmptyState-CSnE65GT.js";import{T as W}from"./Skeleton-CW5d7fJ4.js";import{u as B}from"./useFetch-DiJtqzkU.js";import{e as R}from"./status-colors-BH60BXIE.js";import{P as J}from"./plus-26O7XffR.js";function z({isOpen:a,onClose:y,onCreated:b}){const{t:s}=C(),[r,c]=n.useState(""),[i,d]=n.useState(!1),[l,v]=n.useState("");function h(){c(""),v(""),y()}async function x(){if(v(""),!r.trim()){v(s("admin.pat_label_required"));return}try{d(!0);const o=await w.post("admin/worker-tokens",{json:{label:r.trim()}}).json();c(""),b({token:o.token,id:o.id})}catch(o){const m=o instanceof Error?o.message:s("admin.pat_failed_to_generate");v(m)}finally{d(!1)}}return a?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:o=>{o.target===o.currentTarget&&h()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{maxWidth:"480px",borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("admin.generate_worker_token_title")})]}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[l&&e.jsx("div",{className:"border border-[var(--destructive)]/30 bg-[var(--destructive)]/10 px-3 py-2 text-xs text-[var(--destructive)]",style:{borderRadius:"4px"},children:l}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:s("admin.create_one_time_token")}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs text-[var(--text-muted)]",children:s("admin.label")}),e.jsx("input",{type:"text",placeholder:s("admin.pat_label_placeholder"),value:r,onChange:o=>c(o.target.value),className:"w-full border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},onKeyDown:o=>{o.key==="Enter"&&x()}}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s("admin.label_identifies_worker")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[e.jsx("button",{onClick:h,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s("common.cancel")}),e.jsx("button",{onClick:x,disabled:i,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80 disabled:opacity-50",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s(i?"admin.generating":"admin.generate")})]})]})}):null}const X=3e3,q=600*1e3;function G({isOpen:a,token:y,tokenId:b,onClose:s}){const{t:r}=C(),[c,i]=n.useState("command"),[d,l]=n.useState(!1),[v,h]=n.useState(!1),[x,o]=n.useState(""),[m,g]=n.useState(null),p=n.useRef(void 0),N=n.useRef(Date.now()),_=M(),j=typeof window<"u"?window.location.origin:"https://overlord.example.com",t=`overlord setup worker --token ${y} --server ${j}`;async function D(){try{await navigator.clipboard.writeText(y),l(!0),setTimeout(()=>l(!1),2e3)}catch{}}async function L(){try{await navigator.clipboard.writeText(t),h(!0),setTimeout(()=>h(!1),2e3)}catch{}}const A=n.useCallback(async()=>{try{const f=await w.get(`admin/worker-tokens/${b}/status`).json();f.status==="used"&&f.worker_name&&(i("success"),o(f.worker_name),g(f.worker_id??null),p.current&&clearInterval(p.current))}catch{}Date.now()-N.current>q&&(i("timeout"),p.current&&clearInterval(p.current))},[b]);function F(){i("waiting"),N.current=Date.now(),p.current=setInterval(A,X)}n.useEffect(()=>()=>{p.current&&clearInterval(p.current)},[]);function I(){s(),m&&_(`/workers/${m}`)}if(!a)return null;const u={fontFamily:"'JetBrains Mono', monospace",borderRadius:"4px"};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:f=>{f.target===f.currentTarget&&s()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{...u,maxWidth:"480px"},children:[e.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:c==="success"?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_registered")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_token_generated")})]})}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[c!=="success"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("admin.run_command_desc")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsx("code",{className:"block break-all pr-20 text-xs text-[var(--text-primary)]",children:y}),e.jsx("button",{onClick:D,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:d?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:r("admin.setup_command")}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsxs("code",{className:"block break-all pr-20 text-xs text-[var(--accent)]",children:["$ ",t]}),e.jsx("button",{onClick:L,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:v?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsx("div",{className:"border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-400",style:{borderRadius:"4px"},children:r("admin.token_shown_once")})]}),c==="waiting"&&e.jsxs("div",{className:"flex items-center gap-3 border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-[var(--accent)] border-t-transparent"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:r("admin.waiting_for_worker")})]}),c==="timeout"&&e.jsx("div",{className:"border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3 text-xs text-[var(--text-muted)]",style:{borderRadius:"4px"},children:r("admin.token_not_yet_used")}),c==="success"&&e.jsxs("div",{className:"border border-[var(--accent)]/30 bg-[var(--accent)]/10 px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("p",{className:"text-xs text-[var(--accent)]",children:r("admin.worker_registered_success")}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--text-primary)]",children:[r("admin.worker"),": ",e.jsx("span",{className:"text-[var(--accent)]",children:x})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[c==="command"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsx("button",{onClick:F,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:r("admin.copied_wait_for_worker")})]}),c==="waiting"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("admin.close_worker_can_register")}),c==="timeout"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),c==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsxs("button",{onClick:I,className:"flex items-center gap-1.5 bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:[e.jsx(V,{className:"h-3 w-3"}),r("admin.view_worker")]})]})]})]})})}function se(){const{t:a}=C(),[y,b]=n.useState(!1),[s,r]=n.useState(null),[c,i]=n.useState(!1),[d,l]=n.useState(null),[v,h]=n.useState(!1),[x,o]=n.useState(!1),{data:m,loading:g,refetch:p}=B(()=>w.get("admin/worker-tokens").json(),[]);async function N(){if(d){h(!0);try{await w.post(`admin/worker-tokens/${d.id}/revoke`),i(!1),l(null),p()}catch{}finally{h(!1)}}}function _(t){b(!1),r(t),p()}const j=n.useMemo(()=>(m??[]).filter(t=>x||t.status!==k.REVOKED),[m,x]);return e.jsxs("div",{className:"font-mono",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm text-[var(--text-primary)]",children:a("admin.tokens_title")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:a("admin.tokens_subtitle")})]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",onClick:()=>b(!0),children:[e.jsx(J,{className:"h-3.5 w-3.5"}),a("admin.generate_token")]})]}),!g&&(m==null?void 0:m.some(t=>t.status===k.REVOKED))&&e.jsx("div",{className:"mb-4 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>o(!x),className:`text-xs transition-colors ${x?"text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:a(x?"admin.hide_revoked":"admin.show_revoked")})}),g?e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:e.jsx(W,{rows:3})}):j.length===0?e.jsx(P,{icon:$,title:a("admin.no_worker_tokens"),description:a("admin.generate_token_desc"),actionLabel:a("admin.generate_token"),onAction:()=>b(!0)}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)] text-left text-[var(--text-muted)]",children:[e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.label")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.purpose")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.status")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("common.created_at")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.expires_at")}),e.jsx("th",{className:"pb-2 font-normal",children:a("common.actions")})]})}),e.jsx("tbody",{children:j.map(t=>e.jsxs("tr",{className:"border-b border-[var(--border-row)] hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-primary)]",children:t.label}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-secondary)]",children:t.purpose}),e.jsx("td",{className:"py-2.5 pr-4",children:e.jsx("span",{className:R(t.status),children:t.status})}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-muted)]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-2.5 pr-4",children:t.expiresAt?e.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(t.expiresAt).toLocaleDateString()}):e.jsx("span",{className:"text-[var(--text-muted)]",children:"—"})}),e.jsx("td",{className:"py-2.5",children:t.status===k.ACTIVE&&e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:j.map(t=>e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-[var(--text-primary)] font-medium truncate mr-2",children:t.label}),e.jsx("span",{className:`text-[11px] shrink-0 ${R(t.status)}`,children:t.status})]}),e.jsx("div",{className:"text-[11px] text-[var(--text-secondary)] truncate mb-1",children:t.purpose}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-[var(--text-muted)]",children:[e.jsx("span",{children:new Date(t.createdAt).toLocaleDateString()}),t.expiresAt&&e.jsx("span",{children:new Date(t.expiresAt).toLocaleDateString()})]}),t.status===k.ACTIVE&&e.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)]",children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-[11px] text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]}),e.jsx(z,{isOpen:y,onClose:()=>b(!1),onCreated:_}),s&&e.jsx(G,{isOpen:!!s,token:s.token,tokenId:s.id,onClose:()=>r(null)}),e.jsx(K,{isOpen:c,onClose:()=>{i(!1),l(null)},onConfirm:N,title:a("admin.revoke_token"),message:a("admin.revoke_token_confirm",{label:(d==null?void 0:d.label)??""}),confirmLabel:a("admin.revoke"),confirmVariant:"danger",isLoading:v})]})}export{se as default};
|
|
1
|
+
import{a as C,r as n,j as e,h as w,f as M,E as O,Y as k,U as $,a3 as T,v as V}from"./index-XDDf1Oy_.js";import{K as E}from"./key-y6VWhViZ.js";import{C as S}from"./copy-BpM8iA-r.js";import{E as K}from"./external-link-BgyHxzCy.js";import{E as P}from"./EmptyState-aKMHLBhj.js";import{T as W}from"./Skeleton-qXDikSxR.js";import{u as B}from"./useFetch-D6-vLVQP.js";import{e as R}from"./status-colors-JE6CIHvW.js";import{P as J}from"./plus-R7zuZ-Lg.js";function z({isOpen:a,onClose:y,onCreated:b}){const{t:s}=C(),[r,c]=n.useState(""),[i,d]=n.useState(!1),[l,v]=n.useState("");function h(){c(""),v(""),y()}async function x(){if(v(""),!r.trim()){v(s("admin.pat_label_required"));return}try{d(!0);const o=await w.post("admin/worker-tokens",{json:{label:r.trim()}}).json();c(""),b({token:o.token,id:o.id})}catch(o){const m=o instanceof Error?o.message:s("admin.pat_failed_to_generate");v(m)}finally{d(!1)}}return a?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:o=>{o.target===o.currentTarget&&h()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{maxWidth:"480px",borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("admin.generate_worker_token_title")})]}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[l&&e.jsx("div",{className:"border border-[var(--destructive)]/30 bg-[var(--destructive)]/10 px-3 py-2 text-xs text-[var(--destructive)]",style:{borderRadius:"4px"},children:l}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:s("admin.create_one_time_token")}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs text-[var(--text-muted)]",children:s("admin.label")}),e.jsx("input",{type:"text",placeholder:s("admin.pat_label_placeholder"),value:r,onChange:o=>c(o.target.value),className:"w-full border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},onKeyDown:o=>{o.key==="Enter"&&x()}}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s("admin.label_identifies_worker")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[e.jsx("button",{onClick:h,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s("common.cancel")}),e.jsx("button",{onClick:x,disabled:i,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80 disabled:opacity-50",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s(i?"admin.generating":"admin.generate")})]})]})}):null}const U=3e3,X=600*1e3;function q({isOpen:a,token:y,tokenId:b,onClose:s}){const{t:r}=C(),[c,i]=n.useState("command"),[d,l]=n.useState(!1),[v,h]=n.useState(!1),[x,o]=n.useState(""),[m,g]=n.useState(null),p=n.useRef(void 0),N=n.useRef(Date.now()),_=M(),j=typeof window<"u"?window.location.origin:"https://overlord.example.com",t=`overlord setup worker --token ${y} --server ${j}`;async function D(){try{await navigator.clipboard.writeText(y),l(!0),setTimeout(()=>l(!1),2e3)}catch{}}async function L(){try{await navigator.clipboard.writeText(t),h(!0),setTimeout(()=>h(!1),2e3)}catch{}}const A=n.useCallback(async()=>{try{const f=await w.get(`admin/worker-tokens/${b}/status`).json();f.status==="used"&&f.worker_name&&(i("success"),o(f.worker_name),g(f.worker_id??null),p.current&&clearInterval(p.current))}catch{}Date.now()-N.current>X&&(i("timeout"),p.current&&clearInterval(p.current))},[b]);function F(){i("waiting"),N.current=Date.now(),p.current=setInterval(A,U)}n.useEffect(()=>()=>{p.current&&clearInterval(p.current)},[]);function I(){s(),m&&_(`/workers/${m}`)}if(!a)return null;const u={fontFamily:"'JetBrains Mono', monospace",borderRadius:"4px"};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:f=>{f.target===f.currentTarget&&s()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{...u,maxWidth:"480px"},children:[e.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:c==="success"?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_registered")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_token_generated")})]})}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[c!=="success"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("admin.run_command_desc")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsx("code",{className:"block break-all pr-20 text-xs text-[var(--text-primary)]",children:y}),e.jsx("button",{onClick:D,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:d?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:r("admin.setup_command")}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsxs("code",{className:"block break-all pr-20 text-xs text-[var(--accent)]",children:["$ ",t]}),e.jsx("button",{onClick:L,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:v?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsx("div",{className:"border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-400",style:{borderRadius:"4px"},children:r("admin.token_shown_once")})]}),c==="waiting"&&e.jsxs("div",{className:"flex items-center gap-3 border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-[var(--accent)] border-t-transparent"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:r("admin.waiting_for_worker")})]}),c==="timeout"&&e.jsx("div",{className:"border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3 text-xs text-[var(--text-muted)]",style:{borderRadius:"4px"},children:r("admin.token_not_yet_used")}),c==="success"&&e.jsxs("div",{className:"border border-[var(--accent)]/30 bg-[var(--accent)]/10 px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("p",{className:"text-xs text-[var(--accent)]",children:r("admin.worker_registered_success")}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--text-primary)]",children:[r("admin.worker"),": ",e.jsx("span",{className:"text-[var(--accent)]",children:x})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[c==="command"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsx("button",{onClick:F,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:r("admin.copied_wait_for_worker")})]}),c==="waiting"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("admin.close_worker_can_register")}),c==="timeout"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),c==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsxs("button",{onClick:I,className:"flex items-center gap-1.5 bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:[e.jsx(K,{className:"h-3 w-3"}),r("admin.view_worker")]})]})]})]})})}function se(){const{t:a}=C(),[y,b]=n.useState(!1),[s,r]=n.useState(null),[c,i]=n.useState(!1),[d,l]=n.useState(null),[v,h]=n.useState(!1),[x,o]=n.useState(!1),{data:m,loading:g,refetch:p}=B(()=>w.get("admin/worker-tokens").json(),[]);async function N(){if(d){h(!0);try{await w.post(`admin/worker-tokens/${d.id}/revoke`),i(!1),l(null),p()}catch{}finally{h(!1)}}}function _(t){b(!1),r(t),p()}const j=n.useMemo(()=>(m??[]).filter(t=>x||t.status!==k.REVOKED),[m,x]);return e.jsxs("div",{className:"font-mono",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm text-[var(--text-primary)]",children:a("admin.tokens_title")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:a("admin.tokens_subtitle")})]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",onClick:()=>b(!0),children:[e.jsx(J,{className:"h-3.5 w-3.5"}),a("admin.generate_token")]})]}),!g&&(m==null?void 0:m.some(t=>t.status===k.REVOKED))&&e.jsx("div",{className:"mb-4 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>o(!x),className:`text-xs transition-colors ${x?"text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:a(x?"admin.hide_revoked":"admin.show_revoked")})}),g?e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:e.jsx(W,{rows:3})}):j.length===0?e.jsx(P,{icon:$,title:a("admin.no_worker_tokens"),description:a("admin.generate_token_desc"),actionLabel:a("admin.generate_token"),onAction:()=>b(!0)}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)] text-left text-[var(--text-muted)]",children:[e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.label")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.purpose")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.status")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("common.created_at")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.expires_at")}),e.jsx("th",{className:"pb-2 font-normal",children:a("common.actions")})]})}),e.jsx("tbody",{children:j.map(t=>e.jsxs("tr",{className:"border-b border-[var(--border-row)] hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-primary)]",children:t.label}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-secondary)]",children:t.purpose}),e.jsx("td",{className:"py-2.5 pr-4",children:e.jsx("span",{className:R(t.status),children:t.status})}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-muted)]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-2.5 pr-4",children:t.expiresAt?e.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(t.expiresAt).toLocaleDateString()}):e.jsx("span",{className:"text-[var(--text-muted)]",children:"—"})}),e.jsx("td",{className:"py-2.5",children:t.status===k.ACTIVE&&e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:j.map(t=>e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-[var(--text-primary)] font-medium truncate mr-2",children:t.label}),e.jsx("span",{className:`text-[11px] shrink-0 ${R(t.status)}`,children:t.status})]}),e.jsx("div",{className:"text-[11px] text-[var(--text-secondary)] truncate mb-1",children:t.purpose}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-[var(--text-muted)]",children:[e.jsx("span",{children:new Date(t.createdAt).toLocaleDateString()}),t.expiresAt&&e.jsx("span",{children:new Date(t.expiresAt).toLocaleDateString()})]}),t.status===k.ACTIVE&&e.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)]",children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-[11px] text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]}),e.jsx(z,{isOpen:y,onClose:()=>b(!1),onCreated:_}),s&&e.jsx(q,{isOpen:!!s,token:s.token,tokenId:s.id,onClose:()=>r(null)}),e.jsx(V,{isOpen:c,onClose:()=>{i(!1),l(null)},onConfirm:N,title:a("admin.revoke_token"),message:a("admin.revoke_token_confirm",{label:(d==null?void 0:d.label)??""}),confirmLabel:a("admin.revoke"),confirmVariant:"danger",isLoading:v})]})}export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O as m,r as e,j as t}from"./index-XDDf1Oy_.js";var b=m();function g({content:n,children:a,delay:l=100,className:i}){const[p,u]=e.useState(!1),[c,f]=e.useState({top:0,left:0}),r=e.useRef(null),o=e.useRef(null),x=e.useCallback(()=>{r.current=setTimeout(()=>{if(o.current){const s=o.current.getBoundingClientRect();f({top:s.top-4,left:s.left+s.width/2})}u(!0)},l)},[l]),d=e.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null),u(!1)},[]);return n?t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:o,onMouseEnter:x,onMouseLeave:d,className:i,children:a}),p&&b.createPortal(t.jsx("div",{role:"tooltip",style:{position:"fixed",top:c.top,left:c.left,transform:"translate(-50%, -100%)",zIndex:9999},className:"pointer-events-none max-w-sm rounded-[4px] bg-[var(--bg-card)] px-2.5 py-1.5 text-xs text-[var(--text-primary)] shadow-lg border border-[var(--border-row)]",children:n}),document.body)]}):t.jsx(t.Fragment,{children:a})}export{g as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as A,g as he,f as fe,u as Y,a as me,r as _,j as M,h as W,t as ge}from"./index-
|
|
1
|
+
import{R as A,g as he,f as fe,u as Y,a as me,r as _,j as M,h as W,t as ge}from"./index-XDDf1Oy_.js";var pe=Object.defineProperty,j=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(u,a,i)=>a in u?pe(u,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[a]=i,k=(u,a)=>{for(var i in a||(a={}))X.call(a,i)&&V(u,i,a[i]);if(j)for(var i of j(a))K.call(a,i)&&V(u,i,a[i]);return u},U=(u,a)=>{var i={};for(var l in u)X.call(u,l)&&a.indexOf(l)<0&&(i[l]=u[l]);if(u!=null&&j)for(var l of j(u))a.indexOf(l)<0&&K.call(u,l)&&(i[l]=u[l]);return i};/**
|
|
2
2
|
* @license QR Code generator library (TypeScript)
|
|
3
3
|
* Copyright (c) Project Nayuki.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,j as e,v as A,A as H,f as P,r as m,u as R,k as D,w as V,W as c,D as S,L as z,I,h,l as B,n as J}from"./index-XDDf1Oy_.js";import{t as K,c as E}from"./date-RFA7-ZGs.js";import{w as Q,b as X,t as Y}from"./status-colors-JE6CIHvW.js";import{I as i}from"./InfoRow-BQI_KKyp.js";import{M as N}from"./MetricBar-DaWuVJHZ.js";import{u as Z}from"./useFetch-D6-vLVQP.js";import{T as ee}from"./Tooltip-DYbD-tQw.js";import{T as M}from"./trash-2-BYatp6Y5.js";import{A as re}from"./arrow-left-B5R31ze1.js";function se({isOpen:t,onClose:a,onConfirm:r,workerName:o,isDraining:l,loading:j}){const{t:d}=u();return e.jsx(A,{isOpen:t,onClose:a,onConfirm:r,title:d(l?"workers.undrain_worker_title":"workers.drain_worker_title"),message:l?d("workers.undrain_confirm",{name:o}):d("workers.drain_confirm",{name:o}),confirmLabel:d(l?"workers.undrain":"workers.drain"),confirmVariant:l?"accent":"warning",isLoading:j})}function ue(){const{id:t}=H(),a=P(),{t:r}=u(),[o,l]=m.useState(!1),[j,d]=m.useState(!1),[T,p]=m.useState(!1),[$,y]=m.useState(!1),w=R(n=>{var v;return(v=n.user)==null?void 0:v.role}),F=D(n=>n.workerSeq),U=D(n=>n.taskSeq),{data:x,loading:W,error:_,refetch:C}=Z(async()=>{if(!t)throw new Error("Missing worker ID");const[n,v]=await Promise.all([h.get(`web/workers/${t}`).json(),h.get(`web/workers/${t}/tasks`).json().catch(()=>[])]);return{worker:n,tasks:v}},[t,F,U]),s=(x==null?void 0:x.worker)??null,g=(x==null?void 0:x.tasks)??[];V(m.useMemo(()=>!s||s.status===c.DECOMMISSIONED?null:e.jsxs("div",{className:"flex items-center gap-2",children:[s.status===c.ONLINE&&e.jsxs("button",{onClick:()=>l(!0),className:"rounded-[4px] border border-[var(--warning)]/40 px-3 py-1.5 text-xs text-[var(--warning)] hover:bg-[var(--warning)]/10 transition-colors",children:["> ",r("workers.drain")]}),w===S.ADMIN&&e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-1 rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-xs text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors",children:[e.jsx(M,{className:"h-3 w-3"}),r("workers.decommission")]})]}),[s,w,r]));async function q(){if(s){d(!0);try{const n=s.status===c.DRAINING?"undrain":"drain";await h.post(`web/workers/${s.id}/${n}`),await C()}catch{}finally{d(!1),l(!1)}}}async function G(){if(s){y(!0);try{await h.delete(`admin/workers/${s.id}`),a("/workers")}catch{}finally{y(!1),p(!1)}}}if(W)return e.jsx("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:r("workers.loading_worker")})});if(_)return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--destructive)]",children:_}),e.jsx("button",{onClick:()=>C(),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:r("common.retry")})]});if(!s)return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r("workers.worker_not_found")}),e.jsxs("button",{onClick:()=>a("/workers"),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:["< ",r("workers.back_to_workers")]})]});const b=s.status===c.DRAINING,k=s.status!==c.DECOMMISSIONED;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mx-auto max-w-5xl font-mono lowercase",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 shrink-0 md:hidden",style:{height:56},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{onClick:()=>a("/workers"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(re,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",children:s.name})]}),!b&&s.status!==c.OFFLINE&&k&&e.jsxs("button",{onClick:()=>l(!0),className:"shrink-0 rounded-[4px] border border-[var(--warning)]/40 px-3 py-1.5 text-xs text-[var(--warning)] hover:bg-[var(--warning)]/10 transition-colors",children:["> ",r("workers.drain")]})]}),e.jsxs("div",{className:"px-4 md:px-6 py-8",children:[b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(z,{to:"/workers",className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors",children:r("workers.title")}),e.jsx("span",{className:"text-[var(--text-muted)]",children:"/"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k&&e.jsxs("button",{onClick:()=>l(!0),className:"rounded-[4px] border border-[var(--accent)] px-4 py-1.5 text-xs text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors",children:["> ",r("workers.undrain")]}),w===S.ADMIN&&k&&e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-1 rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-xs text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors",children:[e.jsx(M,{className:"h-3 w-3"}),r("workers.decommission")]})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx("span",{className:"rounded-[4px] bg-[var(--warning)]/20 px-2.5 py-1 text-xs font-medium text-[var(--warning)]",children:r("workers.draining")})}),e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--warning)]/40 bg-[var(--warning)]/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(I,{className:"h-3.5 w-3.5 text-[var(--warning)]"}),e.jsx("span",{className:"text-xs text-[var(--warning)]",children:r("workers.draining_warning")})]}),e.jsx("p",{className:"text-xs text-[var(--warning)]/70 ml-5.5",children:r("workers.draining_active_tasks")})]}),e.jsxs("div",{className:"mb-6 grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(f,{label:r("workers.cpu"),value:s.cpuUsage,unit:"%"}),e.jsx(f,{label:r("workers.memory"),value:s.memoryUsage,unit:"%"}),e.jsx(f,{label:r("workers.disk"),value:s.diskUsage,unit:"%"}),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("workers.slots")}),e.jsxs("p",{className:"mt-2 text-lg font-semibold text-[var(--text-primary)]",children:[s.activeSlots,"/",s.maxSlots]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>a("/workers"),className:"mb-4 text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors",children:["< ",r("workers.back_to_workers")]}),e.jsxs("h1",{className:"mb-2 text-lg font-bold text-[var(--text-primary)] flex items-center gap-2",children:[s.name,e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-normal",style:{color:Q[s.status]},children:[e.jsx("span",{style:{fontSize:"0.5rem"},children:"●"}),s.status.toLowerCase()]})]}),e.jsx("p",{className:"mb-6 text-xs text-[var(--text-muted)]",children:r("workers.last_heartbeat",{time:K(s.lastHeartbeat,"never")})}),s.status===c.DECOMMISSIONED&&e.jsx("div",{className:"mb-6 rounded-[4px] border border-[var(--text-muted)]/40 bg-[var(--text-muted)]/10 p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["this worker has been decommissioned",s.decommissionedAt?` on ${E(s.decommissionedAt)}`:""," and can no longer accept tasks."]})]})}),e.jsxs("div",{className:"mb-6 grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.resource_usage")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(N,{label:r("workers.cpu"),value:s.cpuUsage}),e.jsx(N,{label:r("workers.mem"),value:s.memoryUsage}),e.jsx(N,{label:r("workers.disk"),value:s.diskUsage})]})]}),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.connection_info")}),e.jsx(L,{worker:s})]})]})]}),b?e.jsxs(e.Fragment,{children:[e.jsx(O,{title:r("workers.active_tasks"),tasks:g,navigate:a}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-4 text-sm font-medium text-[var(--accent)]",children:r("workers.capabilities")}),s.capabilities.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:s.capabilities.map(n=>e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:e.jsx("p",{className:"text-xs text-[var(--text-primary)]",children:n})},n))}):e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("workers.no_capabilities_short")})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-4 text-sm font-medium text-[var(--accent)]",children:r("workers.worker_info")}),e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:e.jsx(L,{worker:s,showExtended:!0})})]})]}):e.jsxs(e.Fragment,{children:[s.capabilities.length>0&&e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.capabilities")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.capabilities.map(n=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-2.5 py-1 text-xs text-[var(--text-secondary)]",children:n},n))})]}),e.jsx(O,{title:`${r("workers.current_tasks")} (${g.length})`,tasks:g,navigate:a})]})]})]}),e.jsx(se,{isOpen:o,onClose:()=>l(!1),onConfirm:q,workerName:s.name,isDraining:b,loading:j}),e.jsx(A,{isOpen:T,onClose:()=>p(!1),onConfirm:G,title:r("workers.decommission_title"),message:r("workers.decommission_confirm",{name:s.name}),confirmLabel:r("workers.decommission"),confirmVariant:"danger",isLoading:$})]})}function L({worker:t,showExtended:a=!1}){const{t:r}=u();return e.jsxs("div",{className:"flex flex-col gap-2 text-xs",children:[e.jsx(i,{label:r("workers.worker_id"),value:t.id}),e.jsx(i,{label:r("workers.host"),value:t.host}),e.jsx(i,{label:r("workers.port"),value:String(t.port)}),e.jsx(i,{label:r("workers.os"),value:t.os??r("workers.unknown")}),e.jsx(i,{label:r("workers.cpu_model"),value:t.cpuModel??r("workers.n_a")}),e.jsx(i,{label:r("workers.cpu_cores"),value:t.cpuCores!=null?String(t.cpuCores):r("workers.n_a")}),e.jsx(i,{label:r("workers.memory"),value:t.memoryGb!=null?`${t.memoryGb} gb`:r("workers.n_a")}),e.jsx(i,{label:r("workers.last_heartbeat_label"),value:E(t.lastHeartbeat)}),e.jsx(i,{label:r("workers.slots"),value:`${t.activeSlots}/${t.maxSlots}`}),a&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:r("workers.status_label"),value:t.status.toLowerCase()}),e.jsx(i,{label:r("workers.worker_version"),value:t.workerVersion??r("workers.n_a")})]})]})}function O({title:t,tasks:a,navigate:r}){const{t:o}=u();return e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:t}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e.jsx("span",{className:"text-xl font-bold text-[var(--border)]",children:"[ ]"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o("workers.no_active_tasks")})]}):e.jsx(te,{tasks:a,navigate:r})]})}function te({tasks:t,navigate:a}){const{t:r}=u();return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-row)]",children:[e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.id")}),e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.description")}),e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.status_label")}),e.jsx("th",{className:"py-2 text-left font-normal text-[var(--text-muted)]",children:r("workers.stage")})]})}),e.jsx("tbody",{children:t.map(o=>e.jsxs("tr",{onClick:()=>a(`/tasks/${o.id}`),className:"cursor-pointer border-b border-[var(--border-row)] hover:bg-[var(--bg-input)] transition-colors",children:[e.jsxs("td",{className:"py-2 pr-4 text-[var(--text-primary)]",children:["#",o.id]}),e.jsx("td",{className:"max-w-[120px] md:max-w-xs truncate py-2 pr-4 text-[var(--text-secondary)]",children:e.jsx(ee,{content:J(o),children:B(o)})}),e.jsx("td",{className:"py-2 pr-4",children:e.jsxs("span",{style:{color:Y[o.status]},children:["● ",o.status.toLowerCase()]})}),e.jsx("td",{className:"py-2 text-[var(--text-secondary)]",children:o.currentStage??"-"})]},o.id))})]})})}function f({label:t,value:a,unit:r}){const o=Math.round(a*100);return e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t}),e.jsxs("p",{className:"mt-2 text-lg font-semibold text-[var(--text-primary)]",children:[o,r]}),e.jsx("div",{className:"mt-3 h-1.5 w-full rounded-[2px] bg-[var(--bg-input)]",children:e.jsx("div",{className:"h-full rounded-[2px] transition-all",style:{width:`${o}%`,backgroundColor:X(a)}})})]})}export{ue as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as G,R as U,a as C,j as e,r as o,h as S,X as q,E as K,f as H,u as V,k as X,W as N,w as J,D as Q,S as M}from"./index-XDDf1Oy_.js";import{w as W}from"./status-colors-JE6CIHvW.js";import{M as _}from"./MetricBar-DaWuVJHZ.js";import Y from"./WorkerSetupGuidePage-DNy2wbA9.js";import{C as z}from"./copy-BpM8iA-r.js";import{L as Z}from"./loader-circle-CMxLiCu8.js";import{S as ee}from"./Select-CvM411zU.js";import{E as te}from"./EmptyState-aKMHLBhj.js";import{C as re}from"./Skeleton-qXDikSxR.js";import{u as se}from"./useFetch-D6-vLVQP.js";import{P as ae}from"./plus-R7zuZ-Lg.js";import"./key-y6VWhViZ.js";import"./download-DMI0uxkZ.js";import"./settings-IoIv8DUf.js";import"./wifi-B8ZV0Cuq.js";/**
|
|
2
2
|
* @license lucide-react v0.469.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const oe=B("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ne=G.memo(function({worker:r,onClick:l}){const{t}=C();return e.jsxs("div",{onClick:l,className:`rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase transition-colors ${l?"cursor-pointer hover:border-[var(--accent)]/40 hover:bg-[var(--bg-input)]":""}`,children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h3",{className:"truncate text-sm text-[var(--text-primary)]",children:[e.jsx("span",{style:{color:W[r.status],fontSize:"0.6rem"},children:"●"})," ",r.name]}),e.jsx("span",{className:"text-xs",style:{color:W[r.status]},children:r.status})]}),e.jsxs("div",{className:"mb-3 text-xs text-[var(--text-muted)]",children:[r.host,r.os?`:${r.os}`:""]}),e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsx(_,{label:t("workers.cpu"),value:r.cpuUsage,variant:"inline"}),e.jsx(_,{label:t("workers.mem"),value:r.memoryUsage,variant:"inline"}),e.jsx(_,{label:t("workers.disk"),value:r.diskUsage,variant:"inline"})]}),e.jsx("div",{className:"flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workers.tasks_slots",{active:String(r.activeSlots),max:String(r.maxSlots)})})}),r.capabilities.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:r.capabilities.map(s=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-1.5 py-0.5 text-[11px] text-[var(--text-muted)]",children:s},s))})]})});function le({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[v,p]=o.useState(!1),[i,m]=o.useState(""),[u,g]=o.useState(null),[b,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[A,w]=o.useState(!1),[F,T]=o.useState(""),[I,$]=o.useState(""),x=o.useRef(null),O={1:t("workers.reg_step_generate_token"),2:t("workers.reg_step_install_worker"),3:t("workers.reg_step_waiting_activation"),4:t("workers.reg_step_activated")};o.useEffect(()=>(d&&(c(1),m(""),g(null),h(""),a(""),y(!1),w(!1),T(""),$(""),p(!1)),()=>{x.current&&clearInterval(x.current)}),[d]);const E=async()=>{const n=b.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),p(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();m(f.token),g(f.tokenId),c(2)}catch{}finally{p(!1)}},P=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=i?`overlord setup worker --token ${i} --server ${P}`:"",R=()=>{navigator.clipboard.writeText(i),y(!0),setTimeout(()=>y(!1),2e3)},D=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},q=o.useCallback(()=>{u&&(c(3),x.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${u}/status`).json();n.used&&n.workerName&&(T(n.workerName),$(n.workerId??""),c(4),x.current&&clearInterval(x.current),l==null||l())}catch{}},3e3))},[u,l]);return o.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]),d?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center font-mono lowercase",children:[e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-primary)]/60 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative z-10 w-full max-w-[1080px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-8",children:[e.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(U,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-[var(--accent)]",children:t("workers.reg_title")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:t("workers.reg_subtitle")}),e.jsx("div",{className:"mt-6 flex items-center justify-center gap-2",children:[1,2,3,4].map((n,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`rounded-[4px] px-3 py-1.5 text-[11px] font-bold ${n===s?"bg-[var(--accent)] text-black":n<s?"bg-[var(--accent)]/20 text-[var(--accent)]":"border border-[var(--border)] bg-[var(--bg-primary)] text-[var(--text-muted)]"}`,children:[n,". ",O[n]]}),f<3&&e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"→"})]},n))}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===1?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--accent)]",children:["> ",t("workers.reg_step_generate_token")]}),s===1&&!i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_click_to_generate")}),k&&e.jsx("p",{className:"text-[11px] text-red-400",children:k}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] text-[var(--text-muted)]",children:t("admin.label")}),e.jsx("input",{type:"text",placeholder:t("admin.pat_label_placeholder"),value:b,onChange:n=>h(n.target.value),onKeyDown:n=>{n.key==="Enter"&&E()},className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-1.5 text-[11px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none"})]}),e.jsx("button",{type:"button",onClick:E,disabled:v,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(v?"admin.generating":"workers.reg_step_generate_token")})]}):i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_token_generated")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsx("code",{className:"block break-all text-[11px] text-[var(--text-primary)]",children:i}),e.jsx("button",{type:"button",onClick:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:j?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:t("admin.setup_command")}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsxs("code",{className:"block break-all text-[11px] text-[var(--accent)]",children:["$ ",L]}),e.jsx("button",{type:"button",onClick:D,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:A?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsx("div",{className:"rounded-[4px] border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-[11px] text-yellow-400",children:t("admin.token_shown_once")})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_completed")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===2?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_install_worker")]}),e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_running_installation")}),s>=2&&e.jsxs("div",{className:"mt-3 space-y-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] p-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-primary)]",children:"$ overlord setup worker"}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"server url: https://..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker token: ovw_..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker name: my-worker"}),e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:"config written. starting worker..."}),s===2&&e.jsx("p",{className:"text-[11px] text-[var(--accent)] animate-pulse",children:"█"})]}),s===2&&e.jsx("button",{type:"button",onClick:q,className:"mt-3 rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black",children:t("workers.reg_installed_wait")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===3?"border-amber-500 bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_waiting_activation")]}),s>=3?e.jsx("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:s===3?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border-2 border-amber-500",children:e.jsx(Z,{className:"h-5 w-5 animate-spin text-amber-500"})}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_listening_for_worker")})]}):e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:t("workers.reg_worker_connected")})}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_waiting_for_worker")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===4?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_activated")]}),s===4?e.jsxs("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--accent)]/20",children:e.jsx(K,{className:"h-6 w-6 text-[var(--accent)]"})}),e.jsx("p",{className:"text-xs font-bold text-[var(--accent)]",children:t("workers.reg_worker_activated",{name:F})}),I&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)]",children:["worker_id: ",I]})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_worker_registered")})]})]}),s===4&&e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{type:"button",onClick:r,className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-xs font-bold text-black",children:t("workers.reg_done")})})]})]}):null}function we(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[v,p]=o.useState(!1),[i,m]=o.useState(0),u=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:b,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,i,g]),k=o.useMemo(()=>[{value:"all",label:r("workers.all_statuses")},{value:N.ONLINE,label:r("workers.online")},{value:N.OFFLINE,label:r("workers.offline")},{value:N.DRAINING,label:r("workers.draining")}],[r]);return J(o.useMemo(()=>u===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",children:[e.jsx(ae,{size:14}),r("workers.register_worker")]}):null,[u,r])),e.jsxs("div",{className:"mx-auto max-w-6xl px-4 md:px-6 py-8 font-mono lowercase",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex overflow-x-auto no-scrollbar",children:[e.jsxs("button",{type:"button",onClick:()=>{c("fleet"),m(a=>a+1)},className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="fleet"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(M,{size:14}),r("workers.fleet")]}),e.jsxs("button",{type:"button",onClick:()=>c("setup_guide"),className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="setup_guide"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(oe,{size:14}),r("workers.setup_guide")]})]}),s==="fleet"&&e.jsx(ee,{value:l,onChange:t,options:k})]}),s==="fleet"?h?e.jsx(re,{cards:6}):!b||b.length===0?e.jsx(te,{icon:M,title:r("workers.no_workers_found"),description:r(l!=="all"?"workers.try_changing_status_filter":"workers.no_workers_registered"),action:e.jsx("button",{type:"button",onClick:()=>c("setup_guide"),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:r("workers.view_setup_guide")})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:(b??[]).map(a=>e.jsx(ne,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(le,{isOpen:v,onClose:()=>{p(!1),m(a=>a+1)},onRegistered:()=>{m(a=>a+1)}})]})}export{we as default};
|
|
6
|
+
*/const oe=G("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ne=U.memo(function({worker:r,onClick:l}){const{t}=C();return e.jsxs("div",{onClick:l,className:`rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase transition-colors ${l?"cursor-pointer hover:border-[var(--accent)]/40 hover:bg-[var(--bg-input)]":""}`,children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h3",{className:"truncate text-sm text-[var(--text-primary)]",children:[e.jsx("span",{style:{color:W[r.status],fontSize:"0.6rem"},children:"●"})," ",r.name]}),e.jsx("span",{className:"text-xs",style:{color:W[r.status]},children:r.status})]}),e.jsxs("div",{className:"mb-3 text-xs text-[var(--text-muted)]",children:[r.host,r.os?`:${r.os}`:""]}),e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsx(_,{label:t("workers.cpu"),value:r.cpuUsage,variant:"inline"}),e.jsx(_,{label:t("workers.mem"),value:r.memoryUsage,variant:"inline"}),e.jsx(_,{label:t("workers.disk"),value:r.diskUsage,variant:"inline"})]}),e.jsx("div",{className:"flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workers.tasks_slots",{active:String(r.activeSlots),max:String(r.maxSlots)})})}),r.capabilities.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:r.capabilities.map(s=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-1.5 py-0.5 text-[11px] text-[var(--text-muted)]",children:s},s))})]})});function le({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[v,p]=o.useState(!1),[i,m]=o.useState(""),[u,g]=o.useState(null),[b,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[A,w]=o.useState(!1),[F,T]=o.useState(""),[I,E]=o.useState(""),x=o.useRef(null),O={1:t("workers.reg_step_generate_token"),2:t("workers.reg_step_install_worker"),3:t("workers.reg_step_waiting_activation"),4:t("workers.reg_step_activated")};o.useEffect(()=>(d&&(c(1),m(""),g(null),h(""),a(""),y(!1),w(!1),T(""),E(""),p(!1)),()=>{x.current&&clearInterval(x.current)}),[d]);const $=async()=>{const n=b.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),p(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();m(f.token),g(f.tokenId),c(2)}catch{}finally{p(!1)}},P=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=i?`overlord setup worker --token ${i} --server ${P}`:"",R=()=>{navigator.clipboard.writeText(i),y(!0),setTimeout(()=>y(!1),2e3)},D=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},B=o.useCallback(()=>{u&&(c(3),x.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${u}/status`).json();n.used&&n.workerName&&(T(n.workerName),E(n.workerId??""),c(4),x.current&&clearInterval(x.current),l==null||l())}catch{}},3e3))},[u,l]);return o.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]),d?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center font-mono lowercase",children:[e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-primary)]/60 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative z-10 w-full max-w-[1080px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-8",children:[e.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(q,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-[var(--accent)]",children:t("workers.reg_title")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:t("workers.reg_subtitle")}),e.jsx("div",{className:"mt-6 flex items-center justify-center gap-2",children:[1,2,3,4].map((n,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`rounded-[4px] px-3 py-1.5 text-[11px] font-bold ${n===s?"bg-[var(--accent)] text-black":n<s?"bg-[var(--accent)]/20 text-[var(--accent)]":"border border-[var(--border)] bg-[var(--bg-primary)] text-[var(--text-muted)]"}`,children:[n,". ",O[n]]}),f<3&&e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"→"})]},n))}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===1?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--accent)]",children:["> ",t("workers.reg_step_generate_token")]}),s===1&&!i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_click_to_generate")}),k&&e.jsx("p",{className:"text-[11px] text-red-400",children:k}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] text-[var(--text-muted)]",children:t("admin.label")}),e.jsx("input",{type:"text",placeholder:t("admin.pat_label_placeholder"),value:b,onChange:n=>h(n.target.value),onKeyDown:n=>{n.key==="Enter"&&$()},className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-1.5 text-[11px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none"})]}),e.jsx("button",{type:"button",onClick:$,disabled:v,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(v?"admin.generating":"workers.reg_step_generate_token")})]}):i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_token_generated")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsx("code",{className:"block break-all text-[11px] text-[var(--text-primary)]",children:i}),e.jsx("button",{type:"button",onClick:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:j?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:t("admin.setup_command")}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsxs("code",{className:"block break-all text-[11px] text-[var(--accent)]",children:["$ ",L]}),e.jsx("button",{type:"button",onClick:D,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:A?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsx("div",{className:"rounded-[4px] border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-[11px] text-yellow-400",children:t("admin.token_shown_once")})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_completed")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===2?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_install_worker")]}),e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_running_installation")}),s>=2&&e.jsxs("div",{className:"mt-3 space-y-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] p-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-primary)]",children:"$ overlord setup worker"}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"server url: https://..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker token: ovw_..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker name: my-worker"}),e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:"config written. starting worker..."}),s===2&&e.jsx("p",{className:"text-[11px] text-[var(--accent)] animate-pulse",children:"█"})]}),s===2&&e.jsx("button",{type:"button",onClick:B,className:"mt-3 rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black",children:t("workers.reg_installed_wait")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===3?"border-amber-500 bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_waiting_activation")]}),s>=3?e.jsx("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:s===3?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border-2 border-amber-500",children:e.jsx(Z,{className:"h-5 w-5 animate-spin text-amber-500"})}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_listening_for_worker")})]}):e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:t("workers.reg_worker_connected")})}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_waiting_for_worker")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===4?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_activated")]}),s===4?e.jsxs("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--accent)]/20",children:e.jsx(K,{className:"h-6 w-6 text-[var(--accent)]"})}),e.jsx("p",{className:"text-xs font-bold text-[var(--accent)]",children:t("workers.reg_worker_activated",{name:F})}),I&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)]",children:["worker_id: ",I]})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_worker_registered")})]})]}),s===4&&e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{type:"button",onClick:r,className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-xs font-bold text-black",children:t("workers.reg_done")})})]})]}):null}function we(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[v,p]=o.useState(!1),[i,m]=o.useState(0),u=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:b,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,i,g]),k=o.useMemo(()=>[{value:"all",label:r("workers.all_statuses")},{value:N.ONLINE,label:r("workers.online")},{value:N.OFFLINE,label:r("workers.offline")},{value:N.DRAINING,label:r("workers.draining")}],[r]);return J(o.useMemo(()=>u===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",children:[e.jsx(ae,{size:14}),r("workers.register_worker")]}):null,[u,r])),e.jsxs("div",{className:"mx-auto max-w-6xl px-4 md:px-6 py-8 font-mono lowercase",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex overflow-x-auto no-scrollbar",children:[e.jsxs("button",{type:"button",onClick:()=>{c("fleet"),m(a=>a+1)},className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="fleet"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(M,{size:14}),r("workers.fleet")]}),e.jsxs("button",{type:"button",onClick:()=>c("setup_guide"),className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="setup_guide"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(oe,{size:14}),r("workers.setup_guide")]})]}),s==="fleet"&&e.jsx(ee,{value:l,onChange:t,options:k})]}),s==="fleet"?h?e.jsx(re,{cards:6}):!b||b.length===0?e.jsx(te,{icon:M,title:r("workers.no_workers_found"),description:r(l!=="all"?"workers.try_changing_status_filter":"workers.no_workers_registered"),action:e.jsx("button",{type:"button",onClick:()=>c("setup_guide"),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:r("workers.view_setup_guide")})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:(b??[]).map(a=>e.jsx(ne,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(le,{isOpen:v,onClose:()=>{p(!1),m(a=>a+1)},onRegistered:()=>{m(a=>a+1)}})]})}export{we as default};
|