@overlordai/server 1.0.142 → 1.0.143
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/database/migrations/012-schema-index-fixes.sql +1 -0
- package/database/migrations/013-review-status.sql +8 -0
- package/dist/adapters/command-parser.utils.d.ts +26 -1
- package/dist/adapters/command-parser.utils.d.ts.map +1 -1
- package/dist/adapters/command-parser.utils.js +112 -26
- package/dist/adapters/command-parser.utils.js.map +1 -1
- package/dist/adapters/help-text.d.ts.map +1 -1
- package/dist/adapters/help-text.js +5 -1
- package/dist/adapters/help-text.js.map +1 -1
- package/dist/adapters/lark/lark-message.parser.d.ts.map +1 -1
- package/dist/adapters/lark/lark-message.parser.js +3 -1
- package/dist/adapters/lark/lark-message.parser.js.map +1 -1
- package/dist/adapters/lark/lark.adapter.d.ts.map +1 -1
- package/dist/adapters/lark/lark.adapter.js +46 -9
- package/dist/adapters/lark/lark.adapter.js.map +1 -1
- package/dist/adapters/nlu-fallback.utils.d.ts +27 -0
- package/dist/adapters/nlu-fallback.utils.d.ts.map +1 -0
- package/dist/adapters/nlu-fallback.utils.js +57 -0
- package/dist/adapters/nlu-fallback.utils.js.map +1 -0
- package/dist/adapters/nlu.service.d.ts.map +1 -1
- package/dist/adapters/nlu.service.js +22 -6
- package/dist/adapters/nlu.service.js.map +1 -1
- package/dist/adapters/slack/slack-message.parser.d.ts.map +1 -1
- package/dist/adapters/slack/slack-message.parser.js +3 -1
- package/dist/adapters/slack/slack-message.parser.js.map +1 -1
- package/dist/adapters/slack/slack.adapter.d.ts.map +1 -1
- package/dist/adapters/slack/slack.adapter.js +31 -6
- package/dist/adapters/slack/slack.adapter.js.map +1 -1
- package/dist/database/repositories/project-member.repository.js +4 -4
- package/dist/database/repositories/project-member.repository.js.map +1 -1
- package/dist/database/repositories/project.repository.d.ts.map +1 -1
- package/dist/database/repositories/project.repository.js +9 -7
- package/dist/database/repositories/project.repository.js.map +1 -1
- package/dist/database/repositories/task.repository.d.ts +18 -0
- package/dist/database/repositories/task.repository.d.ts.map +1 -1
- package/dist/database/repositories/task.repository.js +104 -58
- package/dist/database/repositories/task.repository.js.map +1 -1
- package/dist/dispatcher/dispatcher.service.d.ts +24 -1
- package/dist/dispatcher/dispatcher.service.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.service.js +124 -113
- package/dist/dispatcher/dispatcher.service.js.map +1 -1
- package/dist/notifier/notification-consumer.d.ts.map +1 -1
- package/dist/notifier/notification-consumer.js +14 -9
- package/dist/notifier/notification-consumer.js.map +1 -1
- package/dist/web/frame-handlers/review-report.handler.d.ts.map +1 -1
- package/dist/web/frame-handlers/review-report.handler.js +15 -0
- package/dist/web/frame-handlers/review-report.handler.js.map +1 -1
- package/dist/web/task.controller.d.ts +11 -1
- package/dist/web/task.controller.d.ts.map +1 -1
- package/dist/web/task.controller.js +51 -6
- package/dist/web/task.controller.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/{AccessTokensPage-DsNgVUdv.js → AccessTokensPage-BSxprw7x.js} +1 -1
- package/public/assets/{AdminPage-NZC6yOHW.js → AdminPage-CxHMuTgJ.js} +1 -1
- package/public/assets/{AgentCliPage-Bp8tQiWl.js → AgentCliPage-DxZUrhjz.js} +1 -1
- package/public/assets/{ApiReferencePage-DXNSPdww.js → ApiReferencePage-Cc_-lPFn.js} +1 -1
- package/public/assets/{ArchitecturePage-DFUNHKTN.js → ArchitecturePage-CpXl4jb3.js} +1 -1
- package/public/assets/{AuditLogPage-Wtpr8CDi.js → AuditLogPage-CvG7Kmpn.js} +1 -1
- package/public/assets/{BindPlatformPage-Bp_NG22g.js → BindPlatformPage-DQEP-N9z.js} +1 -1
- package/public/assets/{BotIntegrationPage-DuH_f_mp.js → BotIntegrationPage-DP1ipK65.js} +1 -1
- package/public/assets/{BotManage-CJ5GZ0HR.js → BotManage-B1lkaWlW.js} +1 -1
- package/public/assets/{BotSetupPage-Ct_gjzJt.js → BotSetupPage-kJHd4z6w.js} +1 -1
- package/public/assets/{ChangelogPage-DrpgpyjK.js → ChangelogPage-QheUxtEJ.js} +1 -1
- package/public/assets/{CliReferencePage-BiUl0LtI.js → CliReferencePage-Dy78S9h1.js} +1 -1
- package/public/assets/{ConfirmStageDialog-BsoAtSes.js → ConfirmStageDialog-rt45LR8Q.js} +4 -4
- package/public/assets/{DeploymentPage-DtlH8d7p.js → DeploymentPage-CaIslw2W.js} +1 -1
- package/public/assets/{DevWorkflowPage-BoZm03L7.js → DevWorkflowPage-DjmFkvCo.js} +1 -1
- package/public/assets/{DeveloperManage-hoNX7J5P.js → DeveloperManage-Ab6SdQEz.js} +1 -1
- package/public/assets/{DeveloperSetupPage-D3FDp-R7.js → DeveloperSetupPage-D3RvWqx0.js} +1 -1
- package/public/assets/{DocsIndexPage-ZBDBTreg.js → DocsIndexPage-BHnvOEn8.js} +1 -1
- package/public/assets/{DocsLayout-CX3AKUlL.js → DocsLayout-BdWlFJ_G.js} +1 -1
- package/public/assets/{DocsPrimitives-B3qhkVFu.js → DocsPrimitives-BRoBpWHe.js} +1 -1
- package/public/assets/{EditProjectPage-DKaSpnod.js → EditProjectPage-CepF7mnT.js} +2 -2
- package/public/assets/{EmptyState-BKUHLcAb.js → EmptyState-BIXXLer_.js} +1 -1
- package/public/assets/{EnvVariablesPage-C2nu-wxe.js → EnvVariablesPage-DxRT4ql6.js} +1 -1
- package/public/assets/HomePage-CkiXfp2H.js +1 -0
- package/public/assets/{InfoRow-CBKDMEtd.js → InfoRow-DXCzjoGj.js} +1 -1
- package/public/assets/{InstallationPage-0TO7IQzJ.js → InstallationPage-CF8j4Y-C.js} +1 -1
- package/public/assets/{LandingPage-YcgE-OTL.js → LandingPage-CaYr_-RD.js} +1 -1
- package/public/assets/{LocalDevelopmentPage-BDpTHWAo.js → LocalDevelopmentPage-HIFhYvHJ.js} +1 -1
- package/public/assets/{LoginPage-F34Kt4ot.js → LoginPage-D17Mq8Qe.js} +1 -1
- package/public/assets/{MetricBar-xV1juDz6.js → MetricBar-DDJWywkw.js} +1 -1
- package/public/assets/{NotFoundPage-DPZDwk1M.js → NotFoundPage-BTlUFX7F.js} +1 -1
- package/public/assets/{OnboardingGuide-C8QTC3cZ.js → OnboardingGuide-CTJYul4_.js} +1 -1
- package/public/assets/{PermissionsPage-DsNmsUoe.js → PermissionsPage-Dj27JR_m.js} +1 -1
- package/public/assets/PipelineConfigPage-BTy8cOFI.js +22 -0
- package/public/assets/{PipelineEditorPage-18u7wxjE.js → PipelineEditorPage-CuSW0B-0.js} +2 -2
- package/public/assets/PlanPage-CMQs2Hiz.js +1 -0
- package/public/assets/{ProfilePage-D3YRdW9C.js → ProfilePage-BRxrQCQd.js} +1 -1
- package/public/assets/ProjectDetailPage-CRHNrgPt.js +7 -0
- package/public/assets/{ProjectListPage-D62NmkBp.js → ProjectListPage-QM4505IY.js} +2 -2
- package/public/assets/{PtyTerminal-B3lRN-u1.js → PtyTerminal-BxD1WFmu.js} +1 -1
- package/public/assets/{QuickAuth-DzYrNwL-.js → QuickAuth-Dx-LoUjm.js} +1 -1
- package/public/assets/{RemoveMemberConfirmDialog-svHE4uU4.js → RemoveMemberConfirmDialog-pg5SnIU8.js} +1 -1
- package/public/assets/{ReviewAggregatePage-Dq3hl9db.js → ReviewAggregatePage-DHUyVVeT.js} +2 -2
- package/public/assets/ReviewPage-DzNkeQXP.js +1 -0
- package/public/assets/{Select-BMBYwPr-.js → Select-DYnPuPlP.js} +1 -1
- package/public/assets/{SettingsPage-Ml3L-j5R.js → SettingsPage-YpqaOT8x.js} +1 -1
- package/public/assets/{Skeleton-9LGrFcdv.js → Skeleton-tFvClhRo.js} +1 -1
- package/public/assets/{SkillPage-BGYJMqPr.js → SkillPage-BQto2TJm.js} +1 -1
- package/public/assets/TaskDetailPage-BAnCb9zv.js +21 -0
- package/public/assets/{TaskGuidePage-CKnugDRu.js → TaskGuidePage-Bs-Unzck.js} +1 -1
- package/public/assets/TaskListPage-CL98Ev5l.js +1 -0
- package/public/assets/{TaskStatusBadge-B_S_xjEI.js → TaskStatusBadge-BUczBM5S.js} +1 -1
- package/public/assets/TerminalHomePage-CgZYHN7Y.js +6 -0
- package/public/assets/{TokenManage-BqOEJDHV.js → TokenManage-BU8KbNvZ.js} +1 -1
- package/public/assets/{Tooltip-BFj-n88a.js → Tooltip-BTMAbLUj.js} +1 -1
- package/public/assets/{TotpSetupPage-CI411-Y7.js → TotpSetupPage-B9IghCSA.js} +1 -1
- package/public/assets/WorkerDetailPage-D0Vz2Z_J.js +1 -0
- package/public/assets/{WorkerListPage-nPKvREXn.js → WorkerListPage-B4aOYXSX.js} +2 -2
- package/public/assets/{WorkerOperationsPage-qgdLSK1X.js → WorkerOperationsPage-Du5dUuwe.js} +1 -1
- package/public/assets/{WorkerSetupGuidePage-DHbju_7j.js → WorkerSetupGuidePage-Chgd3lOw.js} +1 -1
- package/public/assets/{WorkerSetupPage-D0Cob5nl.js → WorkerSetupPage-DOy5dzpL.js} +1 -1
- package/public/assets/{agent-type-options-CdJpMswW.js → agent-type-options-DYVQzNPE.js} +1 -1
- package/public/assets/{arrow-left-BOJ_pZwC.js → arrow-left-BmJhqQxJ.js} +1 -1
- package/public/assets/{arrow-right-GWPYDcKr.js → arrow-right-za11FMwb.js} +1 -1
- package/public/assets/{bot-DZ_48uoa.js → bot-BREu_dZH.js} +1 -1
- package/public/assets/{chevron-down-DiFQzkq3.js → chevron-down-pInOI1Sz.js} +1 -1
- package/public/assets/{chevron-left-PB0m_3-R.js → chevron-left-9sE-mZhp.js} +1 -1
- package/public/assets/{chevron-right-Bsbm1nYp.js → chevron-right-BTVDsZF2.js} +1 -1
- package/public/assets/{chevron-up-CvYNL872.js → chevron-up-7pQBLB6e.js} +1 -1
- package/public/assets/{copy-DR5cQtVj.js → copy-Ciibu4ij.js} +1 -1
- package/public/assets/{download-FpaVrNQK.js → download-C5M-xVQE.js} +1 -1
- package/public/assets/{external-link-CiQhHCsl.js → external-link-DXCE8f-2.js} +1 -1
- package/public/assets/{file-text-Gk2VyRBd.js → file-text-FxjQforC.js} +1 -1
- package/public/assets/{git-fork-CLaKXs0Y.js → git-fork-BnUjRz81.js} +1 -1
- package/public/assets/{index-CfvO5R0v.js → index-CTVNJXL0.js} +5 -5
- package/public/assets/{key-b2-JaSCL.js → key-DORG2Bvk.js} +1 -1
- package/public/assets/{loader-circle-_Xw40aLD.js → loader-circle-Ce741dwH.js} +1 -1
- package/public/assets/{pencil-z5Zqj0qg.js → pencil-C4ejRMe1.js} +1 -1
- package/public/assets/{play-D2z1wzeo.js → play-w6NUT3Ge.js} +1 -1
- package/public/assets/{plus-DDEIETPT.js → plus-CgnoWo2P.js} +1 -1
- package/public/assets/{rotate-ccw-DryDtPrl.js → rotate-ccw-DE82XdM1.js} +1 -1
- package/public/assets/{scroll-text-DdAPH940.js → scroll-text-DAbRTvTk.js} +1 -1
- package/public/assets/{settings-DLSb7OkM.js → settings-B6CvfGJs.js} +1 -1
- package/public/assets/{skip-forward-Dshgkb5J.js → skip-forward-kX5fzSWO.js} +1 -1
- package/public/assets/{status-colors-w6Ie5LWO.js → status-colors-DTc6Ynln.js} +1 -1
- package/public/assets/{task-constants-DpDhF7YW.js → task-constants-DFxPkPUs.js} +1 -1
- package/public/assets/{task.store-QLdgw-z_.js → task.store-VJg4-Qif.js} +1 -1
- package/public/assets/{trash-2-DN1oshyp.js → trash-2-BTUlSSX7.js} +1 -1
- package/public/assets/{useFetch-DpOLDSFc.js → useFetch-DLQT-fqN.js} +1 -1
- package/public/assets/{users-DrLwCx8Z.js → users-B6ZPxGEF.js} +1 -1
- package/public/assets/{wifi-B4XgJ6JW.js → wifi-RZmzDeRm.js} +1 -1
- package/public/assets/{workflow-Cd6zqDgi.js → workflow-C1oJzdp3.js} +1 -1
- package/public/index.html +1 -1
- package/public/sw.js +1 -1
- package/public/assets/HomePage-CQ0Upd0D.js +0 -1
- package/public/assets/PipelineConfigPage-D5gx3bIv.js +0 -22
- package/public/assets/PlanPage-Dds_7koM.js +0 -1
- package/public/assets/ProjectDetailPage-1mftEUqP.js +0 -7
- package/public/assets/ReviewPage-CNeCz2eT.js +0 -1
- package/public/assets/TaskDetailPage-Beto_Zqp.js +0 -21
- package/public/assets/TaskListPage-CFri9wCk.js +0 -1
- package/public/assets/TerminalHomePage-CDr4Mq6o.js +0 -6
- package/public/assets/WorkerDetailPage-DcMycoTh.js +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{c as oe,a as xe,r as n,y as $,h as f,j as e,H as Kt,t as W,s as Ee,z as Wt,f as Vt,A as Xt,p as Ht,q as Jt,k as dt,o as y,R as Qt,L as ie,l as mt,m as Yt,X as Ce,w as Zt,U as es,b as ts,G as _t,B as ss}from"./index-CTVNJXL0.js";import{u as as}from"./task.store-VJg4-Qif.js";import{u as rs,g as ns,a as pt,M as ls,H as cs}from"./ConfirmStageDialog-rt45LR8Q.js";import{P as ut}from"./PtyTerminal-BxD1WFmu.js";import{S as ht}from"./Select-DYnPuPlP.js";import{b as is,f as Y,c as os}from"./date-RFA7-ZGs.js";import{a as St}from"./status-colors-DTc6Ynln.js";import{a as ft}from"./agent-type-options-DYVQzNPE.js";import{T as xs,g as Z}from"./task-constants-DFxPkPUs.js";import{T as ds}from"./Tooltip-BTMAbLUj.js";import{A as ms}from"./arrow-left-BmJhqQxJ.js";import{R as Ct}from"./rotate-ccw-DE82XdM1.js";import{G as ps}from"./git-fork-BnUjRz81.js";import{P as vt}from"./play-w6NUT3Ge.js";import{E as gt}from"./external-link-DXCE8f-2.js";import{L as Tt}from"./loader-circle-Ce741dwH.js";import{S as us}from"./skip-forward-kX5fzSWO.js";import{F as bt}from"./file-text-FxjQforC.js";import"./chevron-down-pInOI1Sz.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 hs=oe("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 fs=oe("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 vs=oe("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 gs=oe("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"}]]);function bs(l,c){const a=new Date(l).getTime()-Date.now();if(a<=0)return c("tasks.tunnel_expired");const r=Math.floor(a/36e5),t=Math.floor(a%36e5/6e4);return r>0?c("tasks.tunnel_expires_hm",{h:r,m:t}):c("tasks.tunnel_expires_m",{m:t})}function jt(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 Nt(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 js({taskId:l,taskFinished:c,compact:a}){const{t:r}=xe(),[t,x]=n.useState($.IDLE),[m,_]=n.useState(null),[h,P]=n.useState(null),[R,ee]=n.useState(""),[d,S]=n.useState(!1),[de,O]=n.useState(!1),F=n.useRef(null),M=n.useCallback(async()=>{try{const v=await f.get(`web/workspace-tunnel/${l}/status`).json();x(v.status),_(v.tunnelUrl??null),P(v.expiresAt??null),(v.status==="EXPIRED"||v.status==="IDLE"||v.status==="CLOSED")&&C()}catch{}},[l]);function me(){C(),F.current=setInterval(M,5e3)}function C(){F.current&&(clearInterval(F.current),F.current=null)}n.useEffect(()=>{c&&(t===$.STARTING||t===$.CONNECTED)&&(x($.IDLE),_(null),C())},[c,t]),n.useEffect(()=>{if(t!=="CONNECTED"||!h)return;const v=()=>{const T=bs(h,r);ee(T),T===r("tasks.tunnel_expired")&&(x($.EXPIRED),_(null),C())};v();const I=setInterval(v,3e4);return()=>clearInterval(I)},[t,h]),n.useEffect(()=>()=>C(),[]),n.useEffect(()=>{c||M()},[M,c]);async function V(){S(!0);try{await f.post(`web/workspace-tunnel/${l}/start`),x($.STARTING),me()}catch(v){let I=r("tasks.tunnel_start_failed");try{if(v instanceof Kt){const T=await v.response.json();T!=null&&T.error&&(I=T.error,/code.*not found|ENOENT.*code|spawn code/i.test(I)&&(I+=". "+r("tasks.tunnel_install_code_hint")))}}catch{}W.error(I)}finally{S(!1)}}async function A(){S(!0);try{await f.post(`web/workspace-tunnel/${l}/stop`),x($.IDLE),_(null),C()}catch{}finally{S(!1)}}async function U(){m&&(await navigator.clipboard.writeText(m),O(!0),setTimeout(()=>O(!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:jt(t)},children:Nt(t,r)}),(t==="IDLE"||t==="CLOSED"||t==="EXPIRED")&&e.jsx("button",{onClick:V,disabled:d,className:"rounded-[4px] px-2 py-1 text-[var(--info)] disabled:opacity-50",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:r(d?"tasks.tunnel_starting":"tasks.tunnel_start")}),t==="CONNECTED"&&m&&e.jsx("a",{href:m.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:r("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:r("tasks.tunnel_header")}),e.jsxs("span",{className:"text-xs",style:{color:jt(t)},children:["● ",Nt(t,r)]})]}),t==="CONNECTED"&&h&&e.jsxs("p",{className:"mb-2 text-xs text-[var(--text-muted)]",children:["// ",R]}),t==="CONNECTED"&&m&&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:m}),e.jsxs("button",{onClick:U,className:"shrink-0 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors","aria-label":r("tasks.tunnel_copy_url"),children:["[",r("common.copy"),"]"]})]}),de&&e.jsx("p",{className:"mb-2 text-xs text-[var(--accent)]",children:r("tasks.tunnel_copied")}),t==="STARTING"&&e.jsx("p",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("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:V,disabled:d,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:r(d?"tasks.tunnel_starting_button":"tasks.tunnel_start_button")}),t==="STARTING"&&e.jsx("button",{onClick:A,disabled:d,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:r(d?"tasks.tunnel_stopping":"tasks.tunnel_cancel")}),t==="CONNECTED"&&m&&e.jsxs(e.Fragment,{children:[e.jsx("a",{href:m.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:r("tasks.tunnel_open_cursor")}),e.jsx("a",{href:m.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:r("tasks.tunnel_open_vscode")}),e.jsx("button",{onClick:A,disabled:d,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:r(d?"tasks.tunnel_stopping":"tasks.tunnel_stop")})]}),t==="EXPIRED"&&e.jsx("button",{onClick:V,disabled:d,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:r(d?"tasks.tunnel_starting_button":"tasks.tunnel_restart")})]})]})}function Ns({isOpen:l,onClose:c,onConfirm:a,taskId:r,isLoading:t}){const{t:x}=xe();return e.jsx(Ee,{isOpen:l,onClose:c,onConfirm:a,title:x("tasks.cancel_task_title"),message:x("tasks.cancel_task_message",{id:String(r)}),confirmLabel:x("tasks.cancel_task_confirm_label"),confirmVariant:"danger",isLoading:t})}function ys({isOpen:l,onClose:c,onConfirm:a,taskId:r,mrUrl:t,isLoading:x,reuseWorkspace:m,onReuseWorkspaceChange:_}){const{t:h}=xe(),P=t?h("tasks.retry_message_with_mr",{id:String(r),url:t}):h("tasks.retry_message_without_mr",{id:String(r)});return e.jsx(Ee,{isOpen:l,onClose:c,onConfirm:a,title:h("tasks.retry_title"),message:P,confirmLabel:h("tasks.retry_confirm_label"),confirmVariant:"accent",isLoading:x,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:m,onChange:R=>_(R.target.checked),className:"w-3.5 h-3.5 cursor-pointer accent-[var(--accent)]"}),h("tasks.reuse_workspace_label")]})})}const _e=["implement","test","verify","review","simplify","rebase","submit"],ks=["analyze","discuss","document","confirm"],ws=["review","report","fix"],_s=["review","report"];function Te(l){if(typeof l=="string")try{return Te(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(r=>r&&typeof r=="object"?r.name:null).filter(r=>typeof r=="string"&&r.length>0);return a.length===c.length?a:null}function Ss(l){if(l.taskMode==="plan")return ks;if(l.taskMode==="review"){let c=!1;if(l.configSnapshot)try{c=!!JSON.parse(l.configSnapshot).skipFix}catch{}return c?_s:ws}if(!l.configSnapshot)return _e;try{const c=JSON.parse(l.configSnapshot);return Te(c.pipeline)??Te(c)??_e}catch{return _e}}function Cs(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 Se({status:l,agentType:c}){const a=St(l),r=Z(c);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-[4px] px-2 py-0.5 text-xs",style:{color:a},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-[3px]",style:{backgroundColor:a}}),l.toLowerCase()," / ",r]})}function yt({stages:l,runningBg:c="bg-[#1a1a1a]",py:a="py-1.5"}){return e.jsx(e.Fragment,{children:l.map(r=>{const t=r.status==="completed",x=r.status==="running",m=r.status==="failed";return e.jsxs("div",{className:`flex items-center gap-2 rounded-[4px] px-2 ${a} ${x?c:""}`,children:[t&&e.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),x&&e.jsx(Tt,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),m&&e.jsx(Ce,{className:"h-3.5 w-3.5 shrink-0 text-[var(--destructive)]"}),r.status==="pending"&&e.jsx(hs,{className:"h-3.5 w-3.5 shrink-0 text-[#525252]"}),e.jsx("span",{className:"text-xs",style:{color:t?"var(--accent)":x?"#e5e5e5":m?"var(--destructive)":"#525252",fontWeight:x?500:400},children:x?`> ${r.name}`:r.name})]},r.name)})})}function kt({task:l,ptyStatus:c,displayAgentType:a,t:r,gap:t="gap-2 md:gap-3"}){return e.jsxs("div",{className:`flex items-center ${t}`,children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:r("tasks.pty_terminal")}),e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] ${c==="connected"?"text-[var(--accent)]":c==="connecting"?"text-[var(--warning)]":"text-[var(--text-muted)]"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c==="connected"?"bg-[var(--accent)]":c==="connecting"?"bg-[var(--warning)]":"bg-[#525252]"}`}),r(`tasks.${c}`)]}),e.jsx("span",{className:"text-[11px]",style:{color:St(l.status)},children:l.status.toLowerCase()}),l.currentStage&&e.jsxs("span",{className:"hidden md:inline text-[11px] text-[var(--accent)]",children:[r("tasks.stage"),": ",l.currentStage]}),e.jsxs("span",{className:"hidden md:inline text-[11px] text-[var(--text-muted)]",children:["agent: ",a]}),l.workerName&&e.jsxs("span",{className:"hidden md:inline text-[11px] text-[var(--text-muted)]",children:["worker: ",l.workerName]})]})}function wt({isFinished:l,takeoverState:c,ptyRef:a,t:r}){return e.jsxs(e.Fragment,{children:[!l&&c==="auto"&&e.jsxs("button",{onClick:()=>{var t;return(t=a.current)==null?void 0:t.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(cs,{className:"h-3 w-3"}),r("tasks.take_over")]}),!l&&c==="manual"&&e.jsxs("button",{onClick:()=>{var t;return(t=a.current)==null?void 0:t.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(Ct,{className:"h-3 w-3"}),r("tasks.restore_auto")]})]})}function Ts(l){const c=Ss(l),a=l.currentStage?c.indexOf(l.currentStage):-1;return c.map((r,t)=>{let x="pending";return l.status===y.COMPLETED?x="completed":l.status===y.FAILED&&t<=a?x=t===a?"failed":"completed":a>=0&&(t<a?x="completed":t===a&&(x="running")),{name:r,status:x}})}function K(l,c){if(!l||!c)return null;const a=l.repoUrl.replace(/\.git$/,"").replace(/\/+$/,""),r=c.split("/").map(encodeURIComponent).join("/");return l.gitPlatform===_t.GITLAB?`${a}/-/tree/${r}`:`${a}/tree/${r}`}function Es(l,c){if(!l)return null;const a=l.repoUrl.replace(/\.git$/,"").replace(/\/+$/,""),r=c.split("/").map(encodeURIComponent).join("/");return l.gitPlatform===_t.GITLAB?`${a}/-/tree/${r}/docs/specs`:`${a}/tree/${r}/docs/specs`}function Hs(){var it,ot,xt;const{id:l}=Wt(),c=Vt(),{t:a}=xe(),r=as(s=>s.cancelTask),[t,x]=n.useState(null),[m,_]=n.useState(null),[h,P]=n.useState([]),[R,ee]=n.useState(!0),[d,S]=n.useState(null),[de,O]=n.useState(!1),[F,M]=n.useState(!1),[me,C]=n.useState(!1),[V,A]=n.useState(!1),[U,v]=n.useState(["claude"]),[I,T]=n.useState(""),[Le,Ie]=n.useState(!1),[De,Re]=n.useState(!1),[Et,Me]=n.useState(!1),[Lt,Ae]=n.useState(!1),[It,$e]=n.useState(!1),[Pe,Oe]=n.useState(""),[Fe,Ue]=n.useState(""),[qe,Be]=n.useState("append"),[Ge,pe]=n.useState(!1),[ze,Dt]=Xt(),[N,ue]=n.useState("terminal"),[Ke,We]=n.useState([]),[te,Ve]=n.useState(0),[X,q]=n.useState(0),[H,Xe]=n.useState(""),[se,Rt]=n.useState(""),[Mt,he]=n.useState(!1),[At,He]=n.useState(!1),[B,fe]=n.useState(null),[Je,ve]=n.useState("disconnected"),[ge,be]=n.useState("auto"),J=n.useRef(null),Qe=n.useRef(null),$t=rs(),[Ye,Ze]=n.useState([]),o=Number(l),g=t?xs.includes(t.status):!1;Ht(t?Jt(t,100):null);const E=n.useCallback(async()=>{try{const s=await f.get(`web/tasks/${o}`).json();x(s)}catch{}},[o]),ae=n.useCallback(async()=>{try{const s=await f.get(`web/tasks/${o}/logs`).json();P(s.lines)}catch{}},[o]),G=n.useCallback(async()=>{try{const s=await f.get(`web/tasks/${o}/pending-confirm`).json();S(s.confirm)}catch{S(null)}},[o]),et=n.useCallback(async()=>{he(!0);try{const s=new URLSearchParams;s.set("limit","50"),s.set("offset",String(X*50)),H&&s.set("type",H),se&&s.set("search",se);const i=await f.get(`web/tasks/${o}/events?${s}`).json();We(i.events),Ve(i.total)}catch{}finally{he(!1)}},[o,X,H,se]);n.useEffect(()=>{N==="logs"&&et()},[N,et]),n.useEffect(()=>{N==="pipeline"&&!g&&f.get(`web/workspaces/${o}`).json().then(fe).catch(()=>fe(null))},[N,o,g]);const z=dt(s=>s.lastEvent),tt=dt(s=>s.eventSeq);n.useEffect(()=>{ee(!0),x(null),_(null),P([]),S(null),fe(null),We([]),Ve(0),q(0),he(!1),Promise.all([E(),ae(),G()]).finally(()=>ee(!1))},[E,ae,G]),n.useEffect(()=>{t!=null&&t.projectKey&&f.get(`web/projects/${t.projectKey}`).json().then(_).catch(()=>_(null))},[t==null?void 0:t.projectKey]),n.useEffect(()=>{if(!t)return;let s=!1;return(async()=>{try{const i=[],p=[];let u=t.sourceTaskId??null,L=0;for(;u!=null&&L<2;){const w=await f.get(`web/tasks/${u}`).json();p.unshift({id:w.id,taskMode:w.taskMode??"develop"}),u=w.sourceTaskId??null,L++}i.push(...p),i.push({id:t.id,taskMode:t.taskMode??"develop"});const D=await f.get(`web/tasks?${new URLSearchParams({sourceTaskId:String(t.id),limit:"20"})}`).json();for(const w of D.data??[])i.push({id:w.id,taskMode:w.taskMode??"develop"});s||Ze(i)}catch{s||Ze([])}})(),()=>{s=!0}},[t==null?void 0:t.id,t==null?void 0:t.sourceTaskId,t==null?void 0:t.taskMode]),n.useEffect(()=>{!z||tt===0||(z.event==="task_status_changed"&&z.taskId===o||z.event==="task_created"&&z.taskId===o)&&(E(),G())},[tt,z,o,E,G]),n.useEffect(()=>{if(g)return;const i=setInterval(()=>{document.visibilityState!=="hidden"&&Promise.all([E(),ae(),G()])},15e3);return()=>clearInterval(i)},[g,E,ae,G]);const st=n.useCallback(()=>S(null),[]),re=n.useCallback(()=>{S(null),E()},[E]),Pt=(t==null?void 0:t.status)===y.FAILED||(t==null?void 0:t.status)===y.CANCELLED,je=(t==null?void 0:t.status)===y.COMPLETED||(t==null?void 0:t.status)===y.FAILED||(t==null?void 0:t.status)===y.CANCELLED,Ot=(t==null?void 0:t.status)===y.COMPLETED&&(!(t!=null&&t.taskMode)||(t==null?void 0:t.taskMode)==="develop");n.useEffect(()=>{ze.get("action")==="fork"&&t&&!R&&(je&&at(),Dt(s=>(s.delete("action"),s),{replace:!0}))},[t,R,ze,je]);async function Ft(){Me(!0);try{await r(o),O(!1),await E()}finally{Me(!1)}}async function Ut(){Ae(!0);try{await f.post(`web/tasks/${o}/retry`,{json:{reuseWorkspace:Ge}}),M(!1),pe(!1),await E()}finally{Ae(!1)}}function at(){Oe(""),Ue(""),Be("append"),C(!0)}async function qt(){$e(!0);try{const s=Pe.trim()||void 0,i=await f.post(`web/tasks/${o}/fork`,{json:{description:s,descriptionMode:s?qe:void 0,agentType:Fe||void 0}}).json();C(!1),W.success(a("tasks.fork_success")),c(`/tasks/${i.task.id}`)}catch{W.error(a("tasks.fork_error"))}finally{$e(!1)}}async function Bt(){if(t){Re(!0);try{await f.post(`web/tasks/${o}/review`,{json:{agentTypes:U.length>0?U:["claude"],description:I.trim()||void 0,skipFix:Le||void 0}}).json(),A(!1),T(""),Ie(!1),c(`/review/${o}`)}catch(s){const i=s instanceof Error?s.message:String(s);W.error(i)}finally{Re(!1)}}}const j=n.useMemo(()=>t?Ts(t):[],[t==null?void 0:t.configSnapshot,t==null?void 0:t.currentStage,t==null?void 0:t.status]),Ne=j.findIndex(s=>s.status==="running"),ne=n.useMemo(()=>{if(!(t!=null&&t.configSnapshot))return[];try{const s=JSON.parse(t.configSnapshot);return Array.isArray(s.defaultReviewers)?s.defaultReviewers:[]}catch{return[]}},[t==null?void 0:t.configSnapshot]);if(n.useEffect(()=>{ne.length>0&&v(ne)},[ne.join(",")]),R)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 k=t.status===y.QUEUED&&t.queuePosition!=null&&t.queueTotal!=null?{position:t.queuePosition,total:t.queueTotal}:null,b=is(t.startedAt,t.completedAt),Q=ns(t),ye=Z(t.agentType),Gt=[{value:"",label:a("tasks.fork_agent_type_placeholder",{agent:Z(Q)})},...ft(Z,Q)],le=`${a("tasks.status_suspended")} / ${ye}`,rt=k?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:["#",k.position," / ",k.total]})]}):null,nt=t.taskMode&&t.taskMode!=="develop"?e.jsx("span",{className:"rounded-[4px] px-2 py-0.5 text-[10px] font-bold uppercase",style:t.taskMode==="plan"?{color:"#3b82f6",backgroundColor:"rgba(59,130,246,0.12)"}:{color:"#a855f7",backgroundColor:"rgba(168,85,247,0.12)"},children:t.taskMode}):null,ce=Ye.length>1?e.jsx("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:Ye.map((s,i)=>e.jsxs(Qt.Fragment,{children:[i>0&&e.jsx("span",{className:"text-[var(--text-muted)]",children:"→"}),e.jsxs(ie,{to:`/tasks/${s.id}`,className:s.id===t.id?"text-[var(--accent)]":"text-[var(--info)] hover:underline",children:[s.taskMode," #",s.id]})]},s.id))}):t.sourceTaskId?e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["source:"," ",e.jsxs(ie,{to:`/tasks/${t.sourceTaskId}`,className:"text-[var(--info)] hover:underline",children:["#",t.sourceTaskId]})]}):null,lt=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(ms,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",title:Yt(t),children:["#",t.id," ",mt(t,80)]}),nt]}),ce&&e.jsx("div",{className:"text-[11px]",children:ce})]})]}),ke=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(Se,{status:t.status,agentType:t.agentType}),nt,b&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["// time cost: ",b]}),k&&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(k.position),total:String(k.total)})})]}),e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs(ie,{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: ",K(m,t.branch)?e.jsx("a",{href:K(m,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: ",((it=t.mrUrl.match(/!?\d+$/))==null?void 0:it[0])??"view"]})]}),ce&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),ce]})]}),ct=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:[!g&&e.jsxs("button",{onClick:()=>O(!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(Ce,{className:"h-3 w-3"}),a("tasks.cancel_task")]}),Pt&&e.jsxs("button",{onClick:()=>M(!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(Ct,{className:"h-3 w-3"}),a("tasks.retry_task")]}),je&&e.jsxs("button",{onClick:at,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(ps,{className:"h-3 w-3"}),a("tasks.fork_task")]}),Ot&&e.jsxs("button",{onClick:()=>A(!0),className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] px-3 h-8 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(vt,{className:"h-3 w-3"}),a("review.launch")]}),t.workerId&&!g&&e.jsxs("button",{onClick:()=>{ue("pipeline"),setTimeout(()=>{var s,i;(i=(s=Qe.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(gt,{className:"h-3 w-3"}),a("tasks.cursor_tunnel")]})]}),zt=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")}),e.jsx(yt,{stages:j})]}),b&&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: ",b]}),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")}),h.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:h.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")})]})]}),we=e.jsxs(e.Fragment,{children:[e.jsx(Ns,{isOpen:de,onClose:()=>O(!1),onConfirm:Ft,taskId:o,isLoading:Et}),e.jsx(ys,{isOpen:F,onClose:()=>{M(!1),pe(!1)},onConfirm:Ut,taskId:o,mrUrl:t.mrUrl??void 0,isLoading:Lt,reuseWorkspace:Ge,onReuseWorkspaceChange:pe}),e.jsx(Ee,{isOpen:me,onClose:()=>C(!1),onConfirm:qt,title:a("tasks.fork_task"),message:a("tasks.fork_task_desc"),confirmLabel:a("tasks.fork_task"),confirmVariant:"accent",isLoading:It,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 #",o]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.form_agent_type")}),e.jsx(ht,{value:Fe,onChange:Ue,options:Gt})]}),e.jsx("textarea",{value:Pe,onChange:s=>Oe(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"}),e.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 text-[11px] text-[var(--text-secondary)]",children:[e.jsx("input",{type:"checkbox",checked:qe==="replace",onChange:s=>Be(s.target.checked?"replace":"append"),className:"mt-0.5 h-3.5 w-3.5 rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] accent-[var(--accent)]"}),e.jsxs("span",{children:[a("tasks.fork_replace_description"),e.jsx("span",{className:"mt-1 block text-[10px] text-[var(--text-muted)]",children:a("tasks.fork_append_hint")})]})]})]})}),V&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:e.jsxs("div",{className:"w-full max-w-sm rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5 font-mono",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-bold text-[var(--text-primary)]",children:a("review.launch")}),e.jsx("button",{onClick:()=>A(!1),className:"text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(Ce,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)]",children:["task #",o," — ",a("review.select_agents")]}),ne.length>0&&e.jsx("span",{className:"rounded-[4px] border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-500",children:"using project defaults"})]}),e.jsx("div",{className:"mb-4 flex flex-col gap-2",children:ft(Z).map(s=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 rounded-[4px] border border-[var(--border)] px-3 py-2 text-xs hover:bg-[var(--bg-input)] transition-colors",children:[e.jsx("input",{type:"checkbox",checked:U.includes(s.value),onChange:()=>v(i=>i.includes(s.value)?i.filter(p=>p!==s.value):[...i,s.value]),className:"h-3.5 w-3.5 accent-[var(--accent)]"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:s.label})]},s.value))}),e.jsx("textarea",{value:I,onChange:s=>T(s.target.value),placeholder:a("review.description_placeholder"),rows:3,className:"mb-3 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"}),e.jsxs("label",{className:"mb-4 flex cursor-pointer items-center gap-2.5 rounded-[4px] border border-[var(--border)] px-3 py-2 text-xs hover:bg-[var(--bg-input)] transition-colors",children:[e.jsx("input",{type:"checkbox",checked:Le,onChange:s=>Ie(s.target.checked),className:"h-3.5 w-3.5 accent-[var(--accent)]"}),e.jsx("span",{className:"text-[var(--text-muted)]",children:a("review.skip_fix_label")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:Bt,disabled:De||U.length===0,className:"flex flex-1 items-center justify-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-4 py-2 text-xs font-bold text-black disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(vt,{className:"h-3 w-3"}),a(De?"common.processing":"review.launch")]}),e.jsx("button",{onClick:()=>A(!1),className:"rounded-[4px] border border-[var(--border)] px-4 py-2 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:a("common.cancel")})]})]})})]});return At&&N==="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:[ke,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.jsx(kt,{task:t,ptyStatus:Je,displayAgentType:Q,t:a,gap:"gap-3"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wt,{isFinished:g,takeoverState:ge,ptyRef:J,t:a}),e.jsx("button",{onClick:()=>He(!1),className:"flex items-center rounded-[4px] bg-[var(--bg-card)] px-2.5 py-1 text-[var(--text-muted)]",children:e.jsx(gs,{className:"h-3 w-3"})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(ut,{ref:J,taskId:o,sessionId:t.currentSessionId??void 0,taskFinished:g,onStatusChange:ve,onTakeoverChange:be})}),ct,we]}):t.status===y.SUSPENDED?e.jsxs("div",{className:"flex h-full flex-col font-mono lowercase",children:[lt,ke,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(ds,{content:t.description,children:mt(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:le})]}),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:le})}),d&&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:d.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:d.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 f.post(`web/tasks/${o}/confirm-stage`,{json:{stageName:d.stageName,approved:!0,feedback:""}}),re()}catch{W.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 f.post(`web/tasks/${o}/confirm-stage`,{json:{stageName:d.stageName,approved:!1,feedback:""}}),re()}catch{W.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:le})]}),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:Y(t.createdAt)})]})]})]}),e.jsx("div",{className:"hidden md:flex flex-wrap items-center gap-2 py-2",children:j.map((s,i)=>{const p=s.status==="failed",u=s.status==="completed",L=s.status==="running"&&t.status===y.SUSPENDED,D=p?"var(--destructive)":u?"var(--accent)":L?"var(--warning)":"#525252",w=p?"rgba(239,68,68,0.12)":u?"rgba(34,197,94,0.12)":L?"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:D,backgroundColor:w,fontWeight:L?700:400,border:L?`1px solid ${D}`:void 0},children:L?"confirm":`${s.name}${u?" ✓":p?" ✗":""}`}),i<j.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:[h.slice(-10).map((s,i)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-secondary)]",children:s},i)),h.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:le})]}),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:j.map(s=>{const i=s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#525252",p=s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#a3a3a3",u=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:p,fontWeight:s.status==="running"?700:400},children:[s.name," ",u]})]},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:Y(t.createdAt)})]})})]})]}),d&&e.jsx(pt,{isOpen:!!d,onClose:st,taskId:o,stageName:d.stageName,timeoutSeconds:Math.ceil(d.timeout/1e3),confirmType:d.confirmType,onSubmitted:re}),we]}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden font-mono lowercase",children:[lt,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(Se,{status:t.status,agentType:t.agentType}),b&&e.jsxs("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:["// time cost: ",b]}),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&&(K(m,t.branch)?e.jsx("a",{href:K(m,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}))]}),ke,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]}),k&&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(fs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{children:[a("tasks.queue_position_banner",{position:String(k.position),total:String(k.total)}),k.position>1?` — ${a("tasks.queue_ahead",{count:String(k.position-1)})}`:` — ${a("tasks.queue_next")}`]})]}),d&&e.jsx(pt,{isOpen:!!d,onClose:st,taskId:o,stageName:d.stageName,timeoutSeconds:Math.ceil(d.timeout/1e3),confirmType:d.confirmType,onSubmitted:re}),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","detail"].map(s=>e.jsx("button",{onClick:()=>ue(s),className:`shrink-0 whitespace-nowrap px-4 py-2.5 text-xs transition-colors ${N===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":s==="logs"?"tasks.logs":"tasks.detail_tab")},s))}),N==="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.jsx(kt,{task:t,ptyStatus:Je,displayAgentType:Q,t:a}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wt,{isFinished:g,takeoverState:ge,ptyRef:J,t:a}),!g&&ge==="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(Tt,{className:"h-3 w-3 animate-spin"}),a("tasks.requesting_takeover")]}),!g&&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(us,{className:"h-3 w-3"}),a("tasks.skip_stage")]}),e.jsx("button",{onClick:()=>He(!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(vs,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] px-4 py-2 shrink-0 md:hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.currentStage&&e.jsxs("span",{className:"text-[11px] font-semibold text-[var(--accent)]",children:[a("tasks.stage"),": ",t.currentStage]}),e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["agent: ",Q]}),t.workerName&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["worker: ",t.workerName]})]}),e.jsx("div",{className:"overflow-x-auto no-scrollbar pr-4",style:{borderRadius:0},children:e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[e.jsx("span",{className:"shrink-0 text-[11px] font-bold text-[var(--accent)]",children:a("tasks.stage_progress")}),j.map((s,i)=>{const p=s.status==="completed",u=s.status==="running",D=s.status==="failed"?"var(--destructive)":p||u?"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:D,fontWeight:u?600:400},children:[s.name,p?" ✓":u?" ...":""]}),i<j.length-1&&e.jsx("div",{className:"mx-1.5 h-px w-4 shrink-0",style:{backgroundColor:D}})]},s.name)})]})})]}),$t?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(ls,{ref:J,taskId:o,sessionId:t.currentSessionId??void 0,taskFinished:g,onStatusChange:ve,onTakeoverChange:be})}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(ut,{ref:J,taskId:o,sessionId:t.currentSessionId??void 0,taskFinished:g,onStatusChange:ve,onTakeoverChange:be})}),ct]}),N==="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:j.map((s,i)=>{const p=s.status==="completed",u=s.status==="running",w=s.status==="failed"?"var(--destructive)":p||u?"var(--accent)":"#525252";return e.jsxs("div",{className:"flex items-center",style:{flex:i<j.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:w},children:[p&&e.jsx("span",{className:"text-[11px] md:text-xs font-semibold text-[#0c0c0c]",children:"✓"}),u&&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:w},children:s.name})]}),i<j.length-1&&e.jsx("div",{className:"mx-1 md:mx-2 h-0.5 flex-1 min-w-3 rounded-full",style:{backgroundColor:i<(Ne>=0?Ne: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," (",Ne+1,"/",j.length,")"]}),t.startedAt&&e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// elapsed: ",Y(t.startedAt).replace(" ago","")]}),b&&e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// time cost: ",b]}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// retries: ",t.retryCount,"/2"]})]}),!t.currentStage&&b&&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: ",b]})}),e.jsx("button",{onClick:()=>ue("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??"-"})]}),rt]})]}),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")}),e.jsx(yt,{stages:j,runningBg:"bg-[var(--bg-input)]",py:"py-2"})]}),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")}),h.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:h.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")})]})]})]}),N==="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:()=>{Xe(s),q(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(ht,{value:H,onChange:s=>{Xe(s),q(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(Zt,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",placeholder:a("tasks.search_logs"),value:se,onChange:s=>{Rt(s.target.value),q(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:[Ke.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 ${Cs(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)),Ke.length===0&&!Mt&&e.jsx("p",{className:"py-8 text-center text-xs text-[var(--text-muted)]",children:a("tasks.no_log_entries")})]}),te>50&&e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Array.from({length:Math.ceil(te/50)}).slice(0,5).map((s,i)=>e.jsx("button",{onClick:()=>q(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(te/50)>5&&e.jsx("button",{onClick:()=>q(X+1),disabled:X>=Math.ceil(te/50)-1,className:"rounded-[4px] px-2 py-1 text-xs text-[var(--text-muted)] disabled:opacity-30",children:">"})]})]}),N==="detail"&&e.jsxs("div",{className:"flex flex-1 flex-col gap-4 md:gap-5 overflow-y-auto p-4 md:p-6 lg:p-8",children:[e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(es,{className:"h-3.5 w-3.5 text-[var(--accent)]"}),e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.detail_basic_info")})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_creator")}),e.jsx("span",{className:"text-xs text-[var(--text-primary)]",children:t.creatorName??"-"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("common.created_at")}),e.jsx("span",{className:"text-xs text-[var(--text-primary)]",children:os(t.createdAt)}),e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:Y(t.createdAt)})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("common.status")}),e.jsx(Se,{status:t.status,agentType:t.agentType})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_project")}),e.jsx(ie,{to:`/projects/${t.projectKey}`,className:"text-xs text-[var(--info)] hover:underline transition-colors",children:t.projectKey})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_worker")}),e.jsx("span",{className:"text-xs text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.form_agent_type")}),e.jsx("span",{className:"text-xs text-[var(--text-primary)]",children:ye})]}),b&&e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_time_cost")}),e.jsx("span",{className:"text-xs text-[var(--text-primary)]",children:b})]}),t.branch&&e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_branch")}),K(m,t.branch)?e.jsx("a",{href:K(m,t.branch),target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--info)] hover:underline transition-colors truncate",children:t.branch}):e.jsx("span",{className:"text-xs text-[var(--text-primary)] truncate",children:t.branch})]}),t.mrUrl&&/^https?:\/\//.test(t.mrUrl)&&e.jsxs("div",{className:"flex flex-col gap-1 rounded-[4px] bg-[var(--bg-primary)] p-3",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.mr_link")}),e.jsx("a",{href:t.mrUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--info)] hover:underline truncate",children:((ot=t.mrUrl.match(/!?\d+$/))==null?void 0:ot[0])??"view"})]})]})]}),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(bt,{className:"h-3.5 w-3.5 text-[var(--accent)]"}),e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.detail_task_name")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[t.name&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_ai_name")}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.name})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_task_id")}),e.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["#",t.id]})]}),t.sourcePlatform&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.detail_source")}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:t.sourcePlatform})]})]})]}),t.taskMode==="plan"&&t.status===y.COMPLETED&&(()=>{let s="main";if(t.configSnapshot)try{const p=JSON.parse(t.configSnapshot);p.defaultBranch&&(s=p.defaultBranch)}catch{}const i=Es(m,s);return i?e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(bt,{className:"h-3.5 w-3.5 text-[var(--accent)]"}),e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("plan.view_spec")})]}),e.jsxs("p",{className:"mb-2 text-xs text-[var(--text-muted)]",children:["the spec document was pushed to ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:s})," at ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:"docs/specs/"})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--info)] hover:underline transition-colors",children:[e.jsx(gt,{className:"h-3 w-3"}),a("plan.view_spec")]})]}):null})(),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(ts,{className:"h-3.5 w-3.5 text-[var(--accent)]"}),e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.detail_description")})]}),e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[#0c0c0c] p-4 overflow-x-auto",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--text-secondary)] font-mono",children:t.description})})]})]})]}),N==="terminal"&&zt,N==="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:Y(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:ye})]}),b&&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:b})]}),rt]})]}),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??(B==null?void 0:B.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:(B==null?void 0:B.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:((xt=t.mrUrl.match(/!?\d+$/))==null?void 0:xt[0])??"view"})]})]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{ref:Qe,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(js,{taskId:o,taskFinished:g,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:j.map(s=>{const i=s.status==="completed"?"✓":s.status==="running"?"→":"·",p=s.status==="running"?"var(--accent)":s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":"#525252",u=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:p},children:i}),e.jsx("span",{className:s.status==="running"?"font-medium":"",style:{color:p},children:s.name}),e.jsxs("span",{className:"text-[11px]",style:{color:"#525252"},children:["— ",u]})]},s.name)})})]})]})]}),we]})}export{Hs as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./index-
|
|
1
|
+
import{j as e}from"./index-CTVNJXL0.js";import{a as s}from"./DocsPrimitives-BRoBpWHe.js";import"./copy-Ciibu4ij.js";const a=`ov task create -d "implement oauth login" -p WEB -t feat
|
|
2
2
|
ov task plan -d "design auth system" -p WEB
|
|
3
3
|
ov task review 42 --agent codex,cursor
|
|
4
4
|
ov task fork 42 -d "retry with a simpler approach"`,r=`develop "implement oauth login" --project WEB --type feat
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as pe,f as J,a as $,o as u,j as e,l as ee,u as me,i as ue,r,h as P,X as ve,k as he,v as be,H as fe,t as W,w as ge,x as V,m as ye}from"./index-CTVNJXL0.js";import{u as X}from"./task.store-VJg4-Qif.js";import{T as te}from"./TaskStatusBadge-BUczBM5S.js";import{f as se}from"./date-RFA7-ZGs.js";import{T as je}from"./Tooltip-BTMAbLUj.js";import{G as re}from"./git-fork-BnUjRz81.js";import{S as A}from"./Select-DYnPuPlP.js";import{a as ke}from"./task-constants-DFxPkPUs.js";import{g as Ne}from"./agent-type-options-DYVQzNPE.js";import{C as Ce}from"./copy-Ciibu4ij.js";import{E as Y}from"./EmptyState-BIXXLer_.js";import{T as Z}from"./Skeleton-tFvClhRo.js";import{P as we}from"./plus-CgnoWo2P.js";import{C as Se}from"./chevron-left-9sE-mZhp.js";import{C as _e}from"./chevron-right-BTVDsZF2.js";import"./status-colors-DTc6Ynln.js";import"./chevron-down-pInOI1Sz.js";const Te=pe.memo(function({task:s}){const d=J(),{t:c}=$(),x=(a,h)=>c(`common.${a}`,{n:h}),i=s.status===u.COMPLETED||s.status===u.FAILED||s.status===u.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(je,{content:s.description,children:ee(s)})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx(te,{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:[se(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(re,{className:"h-3 w-3"})})]})})]})});function Ee({isOpen:n,onClose:s,projects:d,projectsLoading:c,onSubmit:x,isSubmitting:i}){const{t:a}=$();me(o=>o.user);const h=ue(),[p,K]=r.useState(""),[v,B]=r.useState(""),[m,I]=r.useState("feat"),[N,w]=r.useState(""),[b,S]=r.useState(""),[g,_]=r.useState(""),[y,j]=r.useState(""),[T,M]=r.useState(""),[O,R]=r.useState([]),[z,C]=r.useState(""),k=d.find(o=>o.key===p),H=Ne(o=>o,k==null?void 0:k.agentType);r.useEffect(()=>{if(!n||(K(""),B(""),I("feat"),w(""),S(""),_(""),j(""),M(""),C(""),!h))return;const o=new AbortController;return P.get("admin/developers",{signal:o.signal}).json().then(R).catch(()=>{}),()=>o.abort()},[n,h]),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 E(o){if(o.preventDefault(),C(""),!p||!v.trim()){C(a("tasks.project_and_description_required"));return}try{await x({projectKey:p,description:v.trim(),workerId:y||void 0,developerId:T?Number(T):void 0,taskType:m,branchSlug:b.trim()||void 0,agentType:N||void 0,targetBranch:g.trim()||void 0})}catch(F){const L=F instanceof Error?F.message:a("tasks.failed_to_create_task");C(L)}}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:E,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(A,{value:p,onChange:K,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(A,{value:m,onChange:I,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(A,{value:N,onChange:w,options:H})]}),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:v,onChange:o=>B(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=>j(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:b,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)]"})]}),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_branch")}),e.jsx("input",{type:"text",value:g,onChange:o=>_(o.target.value),placeholder:a("tasks.target_branch_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)]"})]}),h&&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(A,{value:T,onChange:M,options:O.map(o=>({value:String(o.id),label:o.name})),placeholder:a("tasks.select_developer")})]}),z&&e.jsx("div",{className:"rounded-[4px] bg-[#2a1515] border border-[var(--destructive)]/30 px-3 py-2 text-xs text-[var(--destructive)]",children:z})]}),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||!p||!v.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 Fe({isOpen:n,onClose:s,onForceCreate:d,onViewExisting:c,similarTask:x,isLoading:i}){const{t:a}=$();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:h=>h.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(Ce,{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 De({task:n}){const s=J(),d=n.status===u.COMPLETED||n.status===u.FAILED||n.status===u.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:ye(n),children:["#",n.id," ",ee(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(re,{className:"h-3 w-3"})}),e.jsx(te,{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:se(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 Pe=[{key:"all",labelKey:"tasks.tab_all"},{key:u.RUNNING,labelKey:"tasks.tab_running"},{key:u.QUEUED,labelKey:"tasks.tab_queued"},{key:u.COMPLETED,labelKey:"tasks.tab_completed"},{key:u.FAILED,labelKey:"tasks.tab_failed"},{key:u.CANCELLED,labelKey:"tasks.tab_cancelled"}],Ae=20;function Xe(){const n=J(),{t:s}=$(),{tasks:d,loading:c,fetchTasks:x}=X(),i=he(t=>t.taskSeq),[a,h]=r.useState("all"),[p,K]=r.useState(""),[v,B]=r.useState(""),[m,I]=r.useState(""),[N,w]=r.useState(void 0),[b,S]=r.useState([]),g=X(t=>t.nextCursor),[_,y]=r.useState(!1);be(r.useMemo(()=>e.jsxs("button",{onClick:()=>y(!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(we,{className:"h-3.5 w-3.5"}),s("tasks.new_task")]}),[s]));const[j,T]=r.useState([]),[M,O]=r.useState(!1),[R,z]=r.useState([]),[C,k]=r.useState(!1),[H,E]=r.useState(!1),[o,F]=r.useState(null),[L,q]=r.useState(null),G=r.useCallback(t=>{const l={limit:String(Ae),taskMode:"develop"};return a!=="all"&&(l.status=a),p&&(l.projectKey=p),v&&(l.developerId=v),t&&(l.cursor=t),l},[a,p,v]);r.useEffect(()=>{x(G(N))},[G,N,x,i]),r.useEffect(()=>{w(void 0),S([])},[a,p,v]),r.useEffect(()=>{let t=!1;return(async()=>{try{const[f,xe]=await Promise.all([P.get("web/projects").json(),P.get("web/projects/-/developers").json()]);if(t)return;T(f),z(xe)}catch{}})(),()=>{t=!0}},[]),r.useEffect(()=>{if(!_||j.length>0)return;O(!0);let t=!1;return(async()=>{try{const f=await P.get("web/projects").json();t||T(f)}catch{}finally{t||O(!1)}})(),()=>{t=!0}},[_,j.length]);const ae=r.useCallback(async t=>{k(!0);try{const l=await P.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,targetBranch:t.targetBranch}}).json();y(!1),n(`/tasks/${l.task.id}`)}catch(l){if(l instanceof fe&&l.response.status===409){try{const f=await l.response.json();if(f.confirmRequired){F({id:f.confirmRequired.taskId,description:f.confirmRequired.message,status:"active"}),q(t),y(!1),E(!0);return}}catch{}W.error(s("tasks.similar_task_exists"))}else{const f=l instanceof Error?l.message:String(l);W.error(f)}}finally{k(!1)}},[n]),oe=r.useCallback(async()=>{if(L){k(!0);try{const t=await P.post("web/tasks",{json:{...L,force:!0}}).json();E(!1),q(null),n(`/tasks/${t.task.id}`)}finally{k(!1)}}},[L,n]),D=r.useMemo(()=>{if(!m.trim())return d;const t=m.toLowerCase();return d.filter(l=>(l.name??"").toLowerCase().includes(t)||l.description.toLowerCase().includes(t)||String(l.id).includes(m))},[d,m]),ne=r.useCallback(()=>{g&&(S(t=>[...t,N??""]),w(g))},[g,N]),le=r.useCallback(()=>{b.length!==0&&(w(b.at(-1)||void 0),S(t=>t.slice(0,-1)))},[b]),ce=b.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")},...R.map(t=>({value:String(t.id),label:t.name}))],[R,s]),Q=s(m?"tasks.try_adjusting_search":"tasks.create_first_task"),U=m?void 0:e.jsx("button",{onClick:()=>y(!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:Pe.map(t=>e.jsx("button",{onClick:()=>h(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(ge,{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:m,onChange:t=>I(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)]"}),m&&e.jsx("button",{onClick:()=>I(""),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(A,{value:p,onChange:K,options:ie,className:"md:w-40"}),e.jsx(A,{value:v,onChange:B,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&&D.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(Z,{rows:5})})}),!c&&D.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(Y,{icon:V,title:s("tasks.no_tasks_found"),description:Q,action:U})})}),D.map(t=>e.jsx(Te,{task:t},t.id))]})]})}),e.jsxs("div",{className:"flex flex-col gap-2 md:hidden",children:[c&&D.length===0&&e.jsx("div",{className:"p-4",children:e.jsx(Z,{rows:5})}),!c&&D.length===0&&e.jsx(Y,{icon:V,title:s("tasks.no_tasks_found"),description:Q,action:U}),D.map(t=>e.jsx(De,{task:t},t.id))]}),(b.length>0||g)&&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:b.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(Se,{className:"h-3.5 w-3.5"}),s("tasks.prev")]}),e.jsxs("button",{onClick:ne,disabled:!g,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(_e,{className:"h-3.5 w-3.5"})]})]})]}),e.jsx(Ee,{isOpen:_,onClose:()=>y(!1),projects:j,projectsLoading:M,onSubmit:ae,isSubmitting:C}),e.jsx(Fe,{isOpen:H,onClose:()=>{E(!1),q(null)},onForceCreate:oe,onViewExisting:t=>{E(!1),q(null),n(`/tasks/${t}`)},similarTask:o,isLoading:C})]})}export{Xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l,j as a}from"./index-
|
|
1
|
+
import{a as l,j as a}from"./index-CTVNJXL0.js";import{a as u}from"./status-colors-DTc6Ynln.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,6 @@
|
|
|
1
|
+
import{c as ce,n as le,h as D,o as S,a as O,r,k as q,p as de,q as xe,j as e,X as Z,s as me,f as pe,l as ue,m as ve}from"./index-CTVNJXL0.js";import{g as ee,M as he,C as fe,a as ge}from"./ConfirmStageDialog-rt45LR8Q.js";import{u as be}from"./task.store-VJg4-Qif.js";import{i as z,O as te}from"./OnboardingGuide-CTJYul4_.js";import{S as E}from"./Select-DYnPuPlP.js";import{a as se}from"./status-colors-DTc6Ynln.js";import{a as je}from"./date-RFA7-ZGs.js";import{T as G,a as J,g as ke}from"./task-constants-DFxPkPUs.js";import{g as ye}from"./agent-type-options-DYVQzNPE.js";import{u as ae}from"./useFetch-DLQT-fqN.js";import{P as $}from"./plus-CgnoWo2P.js";import{C as Ne}from"./chevron-down-pInOI1Sz.js";import{C as Te}from"./chevron-up-7pQBLB6e.js";import{W as we}from"./wifi-RZmzDeRm.js";import"./loader-circle-Ce741dwH.js";import"./rotate-ccw-DE82XdM1.js";import"./PtyTerminal-BxD1WFmu.js";import"./file-text-FxjQforC.js";import"./chevron-right-BTVDsZF2.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 Se=ce("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 Ce(){try{const t=localStorage.getItem(ne);if(t)return JSON.parse(t)}catch{}return{pinnedTaskIds:[],activeTaskId:null}}let Q="";function R(t){const a=JSON.stringify(t);a!==Q&&(Q=a,localStorage.setItem(ne,a))}const V=Ce(),_e=new Set([S.QUEUED,S.ASSIGNED,S.RUNNING,S.SUSPENDED]);let B=!1;const Ie=le((t,a)=>({pinnedTaskIds:V.pinnedTaskIds,activeTaskId:V.activeTaskId,taskMetas:{},stageConfirm:null,loading:!1,initialLoaded:!1,setActiveTask:s=>{t({activeTaskId:s}),R({pinnedTaskIds:a().pinnedTaskIds,activeTaskId:s})},pinTask:s=>{const{pinnedTaskIds:n}=a();if(n.includes(s))return;const c=[...n,s];t({pinnedTaskIds:c}),R({pinnedTaskIds:c,activeTaskId:a().activeTaskId})},unpinTask:s=>{const{pinnedTaskIds:n,activeTaskId:c,taskMetas:x}=a(),i=n.filter(o=>o!==s),l=c===s?i[0]??null:c,{[s]:v,...f}=x;t({pinnedTaskIds:i,activeTaskId:l,taskMetas:f}),R({pinnedTaskIds:i,activeTaskId:l})},loadActiveTasks:async()=>{if(B)return;B=!0;const s=!a().initialLoaded;s&&t({loading:!0});try{const c=(await D.get("web/tasks",{searchParams:{limit:"30"}}).json()).data.filter(o=>_e.has(o.status)),x={};for(const o of c)x[o.id]={id:o.id,name:o.name,description:o.description,status:o.status,projectKey:o.projectKey,workerName:o.workerName??null,agentType:ee(o),currentStage:o.currentStage,currentSessionId:o.currentSessionId,updatedAt:o.updatedAt};const l=[...c].sort((o,u)=>u.updatedAt.localeCompare(o.updatedAt)).map(o=>o.id),{activeTaskId:v}=a(),f=v&&l.includes(v)?v:l[0]??null;t({taskMetas:x,pinnedTaskIds:l,activeTaskId:f,initialLoaded:!0}),R({pinnedTaskIds:l,activeTaskId:f})}catch{}finally{B=!1,s&&t({loading:!1})}},fetchStageConfirm:async s=>{try{const n=await D.get(`web/tasks/${s}/pending-confirm`).json();t({stageConfirm:n.confirm})}catch{t({stageConfirm:null})}},clearStageConfirm:()=>t({stageConfirm:null}),updateTaskMeta:(s,n)=>{const{taskMetas:c}=a(),x=c[s];x&&t({taskMetas:{...c,[s]:{...x,...n}}})}}));function Ee(){const[t,a]=r.useState(()=>z());r.useEffect(()=>{const n=()=>a(!0),c=()=>a(z());return window.addEventListener("onboarding-dismissed",n),window.addEventListener("storage",c),()=>{window.removeEventListener("onboarding-dismissed",n),window.removeEventListener("storage",c)}},[]);const{data:s}=ae(()=>t?Promise.resolve(null):D.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 Ae({taskId:t,confirm:a,onSubmitted:s}){const{t:n}=O(),[c,x]=r.useState(a.timeout),[i,l]=r.useState(!1),[v,f]=r.useState(!1),o=a.confirmType==="plan_review"||a.confirmType==="code_review",u=a.confirmType==="plan_decompose";r.useEffect(()=>{x(a.timeout);const j=setInterval(()=>{x(b=>b<=1?(clearInterval(j),0):b-1)},1e3);return()=>clearInterval(j)},[a.timeout,a.stageName]);const h=r.useCallback(async j=>{l(!0);try{await D.post(`web/tasks/${t}/confirm-stage`,{json:{stageName:a.stageName,approved:j}}),s()}catch{}finally{l(!1)}},[t,a.stageName,s]);return e.jsxs(e.Fragment,{children:[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(fe,{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:je(c)})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>h(!1),disabled:i,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_plan_decompose")}),e.jsx("button",{onClick:()=>h(!0),disabled:i,className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:n(i?"tasks.stage_submitting":"tasks.approve_plan_decompose")})]}):o?e.jsx("button",{onClick:()=>f(!0),className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity",children:a.confirmType==="plan_review"?n("tasks.approve_plan"):n("tasks.approve_review")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>h(!1),disabled:i,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:()=>h(!0),disabled:i,className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:n(i?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})})]}),o&&e.jsx(ge,{isOpen:v,onClose:()=>f(!1),taskId:t,stageName:a.stageName,timeoutSeconds:Math.ceil(a.timeout/1e3),confirmType:a.confirmType,onSubmitted:s})]})}function Me({projectKey:t,onProjectChange:a,onCreated:s}){const{t:n}=O(),c=be(m=>m.createTask),[x,i]=r.useState(""),[l,v]=r.useState("feat"),[f,o]=r.useState(void 0),[u,h]=r.useState(!1),[j,b]=r.useState(!1),[U,L]=r.useState(!1),{data:C}=ae(()=>D.get("web/projects").json(),[]),T=r.useMemo(()=>{const m=(C??[]).map(F=>({value:F.key,label:F.key}));return[{value:"",label:n("terminal_home.all_projects")},...m]},[C,n]),g=r.useMemo(()=>(C??[]).find(m=>m.key===t)??null,[C,t]),A=r.useMemo(()=>ye(m=>m,g==null?void 0:g.agentType),[g==null?void 0:g.agentType]),k=r.useRef(!1);r.useEffect(()=>{if(!k.current){if(t){k.current=!0;return}T.length>1&&(a(T[1].value),k.current=!0)}},[t,T,a]),r.useEffect(()=>{o(void 0)},[t]);const M=f??"",p=r.useCallback(m=>{o(m||void 0)},[]),_=!!t&&!!x.trim();function w(){_&&b(!0)}async function N(){if(b(!1),!!_){h(!0);try{const m=await c({projectKey:t,description:x.trim(),taskType:l,agentType:f||void 0});i(""),s(m.id)}catch{}finally{h(!1)}}}const I=n("terminal_home.confirm_create_message").replace("{taskType}",l).replace("{projectKey}",t).replace("{description}",x.trim()),P="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(E,{value:t,onChange:a,options:T,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(E,{value:l,onChange:v,options:J})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(E,{value:M,onChange:p,options:A,placeholder:n("tasks.form_agent_type"),disabled:u||!t})}),e.jsx("input",{type:"text",value:x,onChange:m=>i(m.target.value),onKeyDown:m=>m.key==="Enter"&&w(),placeholder:n("terminal_home.task_description_placeholder"),className:P,disabled:u}),e.jsxs("button",{onClick:w,disabled:u||!_,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(u?"common.creating":"terminal_home.new_task")]})]}),e.jsx("div",{className:"md:hidden border-b border-[var(--border)] bg-[var(--bg-card)]",children:U?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(E,{value:t,onChange:a,options:T,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(E,{value:l,onChange:v,options:J})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(E,{value:M,onChange:p,options:A,placeholder:n("tasks.form_agent_type"),disabled:u||!t})}),e.jsx("button",{onClick:()=>L(!1),className:"p-1 text-[var(--text-muted)]",children:e.jsx(Z,{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:m=>i(m.target.value),onKeyDown:m=>m.key==="Enter"&&w(),placeholder:n("terminal_home.task_description_placeholder"),className:P,disabled:u}),e.jsx("button",{onClick:w,disabled:u||!_,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:()=>L(!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(me,{isOpen:j,onClose:()=>b(!1),onConfirm:N,title:n("terminal_home.confirm_create_title"),message:I,confirmVariant:"accent",confirmLabel:n("terminal_home.new_task"),isLoading:u})]})}function Y({status:t,size:a}){const s=t===S.SUSPENDED,n=se(t),c=a==="sm"?"h-1.5 w-1.5":"h-2 w-2";return e.jsx("span",{className:`${c} shrink-0 rounded-full ${s?"animate-pulse":""}`,style:{backgroundColor:s?"var(--warning)":n}})}function De({tasks:t,activeId:a,onSelect:s,onUnpin:n,children:c}){const x=pe();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(i=>{const l=i.id===a;return e.jsxs("div",{onClick:()=>s(i.id),className:`group flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${l?"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(Y,{status:i.status,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",title:ve(i),children:[e.jsxs("div",{className:"truncate text-xs",children:["#",i.id," ",ue(i)]}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)]",children:i.projectKey})]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),n(i.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(Z,{className:"h-3 w-3"})}),e.jsx("button",{onClick:v=>{v.stopPropagation(),x(`/tasks/${i.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:"→"})})]},i.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(i=>{const l=i.id===a;return e.jsxs("button",{onClick:()=>s(i.id),className:`flex shrink-0 items-center gap-1.5 px-3 border-b-2 transition-colors ${l?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)]"}`,style:{height:44},children:[e.jsx(Y,{status:i.status,size:"sm"}),e.jsxs("span",{className:"text-[11px] whitespace-nowrap",children:["#",i.id]})]},i.id)})}),c]})]})}function Oe({task:t,takeoverState:a,onTakeover:s,onRelease:n}){const c=se(t.status),x=ke(t.agentType),i=ee(t);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.jsxs("span",{className:"text-[11px]",style:{color:c},children:[t.status.toLowerCase()," / ",x]}),t.currentStage&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"hidden md:inline text-[11px] text-[var(--text-muted)]",children:["// stage: ",t.currentStage]}),e.jsxs("span",{className:"md:hidden text-[11px] text-[var(--text-muted)]",children:["stage: ",t.currentStage]})]}),e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["agent: ",i]}),t.workerName&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["worker: ",t.workerName]})]}),e.jsx("div",{className:"flex items-center gap-1"})]})}function Le({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(we,{className:"h-2.5 w-2.5"}):e.jsx(Se,{className:"h-2.5 w-2.5"}),s?"connected":a]})]})}function K({onboardingData:t}){const[a,s]=r.useState(!1),{t:n}=O();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(Te,{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(Ne,{className:"h-3 w-3 text-[var(--text-muted)]"})]}):null}function X({onboardingData:t}){const{t:a}=O();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 tt(){const{t}=O(),{pinnedTaskIds:a,activeTaskId:s,taskMetas:n,stageConfirm:c,loading:x,initialLoaded:i,setActiveTask:l,pinTask:v,unpinTask:f,loadActiveTasks:o,fetchStageConfirm:u,clearStageConfirm:h,updateTaskMeta:j}=Ie(),b=r.useRef(null),[U,L]=r.useState("disconnected"),[C,T]=r.useState("auto"),[g,A]=r.useState(""),k=q(d=>d.lastEvent),M=q(d=>d.status),p=s?n[s]??null:null,_=p?G.includes(p.status):!1,w=r.useRef(!1);r.useEffect(()=>{!w.current&&p&&(A(p.projectKey),w.current=!0)},[p]);const N=r.useMemo(()=>{const d=a.map(y=>n[y]).filter(Boolean);return g?d.filter(y=>y.projectKey===g):d},[a,n,g]);r.useEffect(()=>{N.length>0&&s&&!N.some(d=>d.id===s)&&l(N[0].id)},[N,s,l]);const I=Ee();de(p?xe(p):null),r.useEffect(()=>{o()},[o]),r.useEffect(()=>{s&&(p==null?void 0:p.status)===S.SUSPENDED?u(s):h()},[s,p==null?void 0:p.status,u,h]),r.useEffect(()=>{if(k){if(k.event==="task_status_changed"){const{taskId:d,status:y,currentStage:H}=k,W={status:y,updatedAt:new Date().toISOString()};H!==void 0&&(W.currentStage=H),j(d,W),y===S.SUSPENDED&&d===s&&u(d),G.includes(y)&&d===s&&h()}k.event==="task_created"&&o()}},[k,s,u,h,j,o]),r.useEffect(()=>{if(M==="connected")return;const y=setInterval(()=>{document.visibilityState!=="hidden"&&o()},15e3);return()=>clearInterval(y)},[M,o]);const P=r.useCallback(d=>{v(d),l(d),o()},[v,l,o]),m=r.useCallback(()=>{h(),o()},[h,o]),F=r.useCallback(()=>{var d;(d=b.current)==null||d.requestTakeover()},[]),re=r.useCallback(()=>{var d;(d=b.current)==null||d.releaseTakeover()},[]),ie=N.length>0,oe=x&&!i;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx(Me,{projectKey:g,onProjectChange:A,onCreated:P}),oe?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:t("common.loading")})}):e.jsx("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(De,{tasks:N,activeId:s,onSelect:l,onUnpin:f,children:e.jsx("div",{className:"md:hidden",children:e.jsx(K,{onboardingData:I})})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:p?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(K,{onboardingData:I})}),e.jsx(Oe,{task:p,takeoverState:C,onTakeover:F,onRelease:re}),c&&s&&e.jsx(Ae,{taskId:s,confirm:c,onSubmitted:m}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(he,{taskId:s,sessionId:p.currentSessionId??void 0,taskFinished:_,onStatusChange:L,onTakeoverChange:T,ref:b},s)}),e.jsx(Le,{task:p,ptyStatus:U})]}):e.jsx(X,{onboardingData:I})})]}):e.jsx(X,{onboardingData:I})})]})}export{tt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,r as n,j as e,h as w,f as M,F as O,a3 as k,a1 as $,J as T,v as V}from"./index-CfvO5R0v.js";import{K as E}from"./key-b2-JaSCL.js";import{C as S}from"./copy-DR5cQtVj.js";import{E as J}from"./external-link-CiQhHCsl.js";import{E as K}from"./EmptyState-BKUHLcAb.js";import{T as P}from"./Skeleton-9LGrFcdv.js";import{u as W}from"./useFetch-DpOLDSFc.js";import{e as R}from"./status-colors-w6Ie5LWO.js";import{P as B}from"./plus-DDEIETPT.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(J,{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}=W(()=>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(B,{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(P,{rows:3})}):j.length===0?e.jsx(K,{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(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
|
+
import{a as C,r as n,j as e,h as w,f as M,B as O,a2 as k,a0 as $,I as T,s as V}from"./index-CTVNJXL0.js";import{K as E}from"./key-DORG2Bvk.js";import{C as S}from"./copy-Ciibu4ij.js";import{E as B}from"./external-link-DXCE8f-2.js";import{E as K}from"./EmptyState-BIXXLer_.js";import{T as P}from"./Skeleton-tFvClhRo.js";import{u as W}from"./useFetch-DLQT-fqN.js";import{e as R}from"./status-colors-DTc6Ynln.js";import{P as J}from"./plus-CgnoWo2P.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(B,{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}=W(()=>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(P,{rows:3})}):j.length===0?e.jsx(K,{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(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{_ as m,r as e,j as t}from"./index-CTVNJXL0.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-CTVNJXL0.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 b,j as e,s as T,z as se,f as te,r as x,u as ae,k as R,v as ne,W as m,D as N,L as oe,Q as F,h as g,l as ie}from"./index-CTVNJXL0.js";import{t as le,c as H}from"./date-RFA7-ZGs.js";import{w as ce,b as de,t as xe}from"./status-colors-DTc6Ynln.js";import{I as l}from"./InfoRow-DXCzjoGj.js";import{M as S}from"./MetricBar-DDJWywkw.js";import{u as me}from"./useFetch-DLQT-fqN.js";import{T as pe}from"./Tooltip-BTMAbLUj.js";import{T as U}from"./trash-2-BTUlSSX7.js";import{A as ue}from"./arrow-left-BmJhqQxJ.js";function be({isOpen:t,onClose:n,onConfirm:r,workerName:o,isDraining:i,loading:p}){const{t:c}=b();return e.jsx(T,{isOpen:t,onClose:n,onConfirm:r,title:c(i?"workers.undrain_worker_title":"workers.drain_worker_title"),message:i?c("workers.undrain_confirm",{name:o}):c("workers.drain_confirm",{name:o}),confirmLabel:c(i?"workers.undrain":"workers.drain"),confirmVariant:i?"accent":"warning",isLoading:p})}function V(t){return t==="rate_limit"?"rate limited":t}function ve(t,n){return n(t==="binary_missing"?"workers.manual_restore_required":"workers.awaiting_auto_recovery")}function Se(){var $,A;const{id:t}=se(),n=te(),{t:r}=b(),[o,i]=x.useState(!1),[p,c]=x.useState(!1),[P,w]=x.useState(!1),[z,L]=x.useState(!1),[B,j]=x.useState(!1),[Q,I]=x.useState(!1),[y,f]=x.useState(null),v=ae(a=>{var d;return(d=a.user)==null?void 0:d.role}),J=R(a=>a.workerSeq),K=R(a=>a.taskSeq),{data:u,loading:X,error:M,refetch:_}=me(async()=>{if(!t)throw new Error("Missing worker ID");const[a,d]=await Promise.all([g.get(`web/workers/${t}`).json(),g.get(`web/workers/${t}/tasks`).json().catch(()=>[])]);return{worker:a,tasks:d}},[t,J,K]),s=(u==null?void 0:u.worker)??null,C=(u==null?void 0:u.tasks)??[],O=v===N.LEAD||v===N.ADMIN;ne(x.useMemo(()=>!s||s.status===m.DECOMMISSIONED?null:e.jsxs("div",{className:"flex items-center gap-2",children:[s.status===m.ONLINE&&e.jsxs("button",{onClick:()=>i(!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")]}),v===N.ADMIN&&e.jsxs("button",{onClick:()=>w(!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(U,{className:"h-3 w-3"}),r("workers.decommission")]})]}),[s,v,r]));async function Y(){if(s){c(!0);try{const a=s.status===m.DRAINING?"undrain":"drain";await g.post(`web/workers/${s.id}/${a}`),await _()}catch{}finally{c(!1),i(!1)}}}async function Z(){if(s){L(!0);try{await g.delete(`admin/workers/${s.id}`),n("/workers")}catch{}finally{L(!1),w(!1)}}}async function ee(){if(!(!s||!y)){I(!0);try{await g.post(`web/workers/${s.id}/capabilities/${encodeURIComponent(y)}/restore`),await _()}catch{}finally{I(!1),j(!1),f(null)}}}if(X)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(M)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:M}),e.jsx("button",{onClick:()=>_(),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:()=>n("/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 k=s.status===m.DRAINING,h=s.status!==m.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:()=>n("/workers"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",children:s.name})]}),!k&&s.status!==m.OFFLINE&&h&&e.jsxs("button",{onClick:()=>i(!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:[k?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(oe,{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:[h&&e.jsxs("button",{onClick:()=>i(!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")]}),v===N.ADMIN&&h&&e.jsxs("button",{onClick:()=>w(!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(U,{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(F,{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(D,{label:r("workers.cpu"),value:s.cpuUsage,unit:"%"}),e.jsx(D,{label:r("workers.memory"),value:s.memoryUsage,unit:"%"}),e.jsx(D,{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:()=>n("/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:ce[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:le(s.lastHeartbeat,"never")})}),s.status===m.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(F,{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 ${H(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(S,{label:r("workers.cpu"),value:s.cpuUsage}),e.jsx(S,{label:r("workers.mem"),value:s.memoryUsage}),e.jsx(S,{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(q,{worker:s})]})]})]}),k?e.jsxs(e.Fragment,{children:[e.jsx(G,{title:r("workers.active_tasks"),tasks:C,navigate:n}),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(a=>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:a})},a))}):e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("workers.no_capabilities_short")}),((($=s.degradedCapabilities)==null?void 0:$.length)??0)>0&&e.jsx("div",{className:"mt-3 space-y-2",children:s.degradedCapabilities.map(a=>e.jsx(W,{agentType:a.agentType,failureType:a.failureType,failureCount:a.failureCount,showRestore:O&&h,onRestore:()=>{f(a.agentType),j(!0)}},a.agentType))})]}),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(q,{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(a=>{var E;const d=(E=s.degradedCapabilities)==null?void 0:E.find(re=>re.agentType===a);return e.jsxs("span",{className:`rounded-[4px] border px-2.5 py-1 text-xs ${d?"border-[var(--warning)] text-[var(--warning)] bg-[var(--warning)]/5":"border-[var(--border)] text-[var(--text-secondary)]"}`,children:[a,d&&e.jsx("span",{className:"ml-1.5 text-[10px]",children:V(d.failureType)})]},a)})}),(((A=s.degradedCapabilities)==null?void 0:A.length)??0)>0&&e.jsx("div",{className:"mt-3 space-y-2",children:s.degradedCapabilities.map(a=>e.jsx(W,{agentType:a.agentType,failureType:a.failureType,failureCount:a.failureCount,showRestore:O&&h,onRestore:()=>{f(a.agentType),j(!0)}},a.agentType))})]}),e.jsx(G,{title:`${r("workers.current_tasks")} (${C.length})`,tasks:C,navigate:n})]})]})]}),e.jsx(be,{isOpen:o,onClose:()=>i(!1),onConfirm:Y,workerName:s.name,isDraining:k,loading:p}),e.jsx(T,{isOpen:P,onClose:()=>w(!1),onConfirm:Z,title:r("workers.decommission_title"),message:r("workers.decommission_confirm",{name:s.name}),confirmLabel:r("workers.decommission"),confirmVariant:"danger",isLoading:z}),e.jsx(T,{isOpen:B,onClose:()=>{j(!1),f(null)},onConfirm:ee,title:r("workers.restore_capability_title"),message:r("workers.restore_capability_confirm",{capability:y??r("workers.unknown"),name:s.name}),confirmLabel:r("workers.restore_capability"),confirmVariant:"accent",isLoading:Q})]})}function W({agentType:t,failureType:n,failureCount:r,showRestore:o,onRestore:i}){const{t:p}=b();return e.jsx("div",{className:"rounded-[4px] border border-[var(--warning)] bg-[var(--warning)]/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium",children:t}),e.jsxs("span",{className:"text-[var(--text-muted)] ml-2 text-xs",children:[V(n)," · ",r," consecutive failure",r!==1?"s":""," · ",ve(n,p)]})]}),o&&e.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded-[4px] border border-[var(--accent)]/40 px-2.5 py-1 text-xs text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors",children:p("workers.restore_capability")})]})})}function q({worker:t,showExtended:n=!1}){const{t:r}=b();return e.jsxs("div",{className:"flex flex-col gap-2 text-xs",children:[e.jsx(l,{label:r("workers.worker_id"),value:t.id}),e.jsx(l,{label:r("workers.host"),value:t.host}),e.jsx(l,{label:r("workers.os"),value:t.os??r("workers.unknown")}),e.jsx(l,{label:r("workers.cpu_model"),value:t.cpuModel??r("workers.n_a")}),e.jsx(l,{label:r("workers.cpu_cores"),value:t.cpuCores!=null?String(t.cpuCores):r("workers.n_a")}),e.jsx(l,{label:r("workers.memory"),value:t.memoryGb!=null?`${t.memoryGb} gb`:r("workers.n_a")}),e.jsx(l,{label:r("workers.last_heartbeat_label"),value:H(t.lastHeartbeat)}),e.jsx(l,{label:r("workers.slots"),value:`${t.activeSlots}/${t.maxSlots}`}),n&&e.jsxs(e.Fragment,{children:[e.jsx(l,{label:r("workers.status_label"),value:t.status.toLowerCase()}),e.jsx(l,{label:r("workers.worker_version"),value:t.workerVersion??r("workers.n_a")})]})]})}function G({title:t,tasks:n,navigate:r}){const{t:o}=b();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}),n.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(he,{tasks:n,navigate:r})]})}function he({tasks:t,navigate:n}){const{t:r}=b();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:()=>n(`/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(pe,{content:o.description,children:ie(o)})}),e.jsx("td",{className:"py-2 pr-4",children:e.jsxs("span",{style:{color:xe[o.status]},children:["● ",o.status.toLowerCase()]})}),e.jsx("td",{className:"py-2 text-[var(--text-secondary)]",children:o.currentStage??"-"})]},o.id))})]})})}function D({label:t,value:n,unit:r}){const o=Math.round(n*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:de(n)}})})]})}export{Se as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as G,R as U,a as C,j as e,r as o,h as S,X as q,
|
|
1
|
+
import{c as G,R as U,a as C,j as e,r as o,h as S,X as q,B as K,f as H,u as V,k as X,W as N,v as J,D as Q,S as M}from"./index-CTVNJXL0.js";import{w as W}from"./status-colors-DTc6Ynln.js";import{M as _}from"./MetricBar-DDJWywkw.js";import Y from"./WorkerSetupGuidePage-Chgd3lOw.js";import{C as A}from"./copy-Ciibu4ij.js";import{L as Z}from"./loader-circle-Ce741dwH.js";import{S as ee}from"./Select-DYnPuPlP.js";import{E as te}from"./EmptyState-BIXXLer_.js";import{C as re}from"./Skeleton-tFvClhRo.js";import{u as se}from"./useFetch-DLQT-fqN.js";import{P as ae}from"./plus-CgnoWo2P.js";import{A as oe}from"./arrow-left-BmJhqQxJ.js";import"./key-DORG2Bvk.js";import"./download-C5M-xVQE.js";import"./settings-B6CvfGJs.js";import"./play-w6NUT3Ge.js";import"./wifi-RZmzDeRm.js";import"./chevron-down-pInOI1Sz.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 ne=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"}]]),le=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=>{var m;const c=(m=r.degradedCapabilities)==null?void 0:m.some(i=>i.agentType===s);return e.jsx("span",{className:`rounded-[4px] border px-1.5 py-0.5 text-[11px] ${c?"border-[var(--warning)] text-[var(--warning)]":"border-[var(--border)] text-[var(--text-muted)]"}`,children:s},s)})})]})});function ce({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[m,i]=o.useState(!1),[x,u]=o.useState(""),[b,g]=o.useState(null),[v,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[z,w]=o.useState(!1),[F,T]=o.useState(""),[I,$]=o.useState(""),p=o.useRef(null),D={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),u(""),g(null),h(""),a(""),y(!1),w(!1),T(""),$(""),i(!1)),()=>{p.current&&clearInterval(p.current)}),[d]);const E=async()=>{const n=v.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),i(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();u(f.token),g(f.tokenId),c(2)}catch{}finally{i(!1)}},O=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=x?`overlord setup worker --token ${x} --server ${O}`:"",P=()=>{navigator.clipboard.writeText(x),y(!0),setTimeout(()=>y(!1),2e3)},R=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},B=o.useCallback(()=>{b&&(c(3),p.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${b}/status`).json();n.used&&n.workerName&&(T(n.workerName),$(n.workerId??""),c(4),p.current&&clearInterval(p.current),l==null||l())}catch{}},3e3))},[b,l]);return o.useEffect(()=>()=>{p.current&&clearInterval(p.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,". ",D[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&&!x?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:v,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:m,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(m?"admin.generating":"workers.reg_step_generate_token")})]}):x?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:x}),e.jsx("button",{type:"button",onClick:P,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(A,{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:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:z?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{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 Ce(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[m,i]=o.useState(!1),[x,u]=o.useState(0),b=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:v,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,x,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(()=>b===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>i(!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,[b,r])),e.jsxs("div",{className:"mx-auto max-w-6xl font-mono lowercase",children:[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:()=>d("/dashboard"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",children:r("workers.title")})]}),e.jsxs("div",{className:"px-4 md:px-6 py-8",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"),u(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(ne,{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}):!v||v.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:(v??[]).map(a=>e.jsx(le,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(ce,{isOpen:m,onClose:()=>{i(!1),u(a=>a+1)},onRegistered:()=>{u(a=>a+1)}})]})]})}export{Ce as default};
|
|
6
|
+
*/const ne=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"}]]),le=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=>{var m;const c=(m=r.degradedCapabilities)==null?void 0:m.some(i=>i.agentType===s);return e.jsx("span",{className:`rounded-[4px] border px-1.5 py-0.5 text-[11px] ${c?"border-[var(--warning)] text-[var(--warning)]":"border-[var(--border)] text-[var(--text-muted)]"}`,children:s},s)})})]})});function ce({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[m,i]=o.useState(!1),[x,u]=o.useState(""),[b,g]=o.useState(null),[v,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[z,w]=o.useState(!1),[D,T]=o.useState(""),[I,$]=o.useState(""),p=o.useRef(null),F={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),u(""),g(null),h(""),a(""),y(!1),w(!1),T(""),$(""),i(!1)),()=>{p.current&&clearInterval(p.current)}),[d]);const E=async()=>{const n=v.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),i(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();u(f.token),g(f.tokenId),c(2)}catch{}finally{i(!1)}},O=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=x?`overlord setup worker --token ${x} --server ${O}`:"",P=()=>{navigator.clipboard.writeText(x),y(!0),setTimeout(()=>y(!1),2e3)},R=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},B=o.useCallback(()=>{b&&(c(3),p.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${b}/status`).json();n.used&&n.workerName&&(T(n.workerName),$(n.workerId??""),c(4),p.current&&clearInterval(p.current),l==null||l())}catch{}},3e3))},[b,l]);return o.useEffect(()=>()=>{p.current&&clearInterval(p.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,". ",F[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&&!x?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:v,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:m,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(m?"admin.generating":"workers.reg_step_generate_token")})]}):x?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:x}),e.jsx("button",{type:"button",onClick:P,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(A,{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:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:z?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{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:D})}),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 Ce(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[m,i]=o.useState(!1),[x,u]=o.useState(0),b=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:v,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,x,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(()=>b===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>i(!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,[b,r])),e.jsxs("div",{className:"mx-auto max-w-6xl font-mono lowercase",children:[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:()=>d("/dashboard"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",children:r("workers.title")})]}),e.jsxs("div",{className:"px-4 md:px-6 py-8",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"),u(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(ne,{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}):!v||v.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:(v??[]).map(a=>e.jsx(le,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(ce,{isOpen:m,onClose:()=>{i(!1),u(a=>a+1)},onRegistered:()=>{u(a=>a+1)}})]})]})}export{Ce as default};
|