@wrongstack/webui 0.301.0 → 0.302.2

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.
Files changed (60) hide show
  1. package/dist/assets/{AgentRosterView-BV6ysoGs.js → AgentRosterView-BwukmHoA.js} +1 -1
  2. package/dist/assets/{AnalyticsDashboard-UWNP8zjE.js → AnalyticsDashboard-C9aPEyov.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-DwDKbvSA.js → AudienceMemoryPanel-Bciki41o.js} +1 -1
  4. package/dist/assets/{ChangesView-DuVlGWkD.js → ChangesView-DumffowD.js} +1 -1
  5. package/dist/assets/{ChronicleDashboard-cs16n708.js → ChronicleDashboard-BYGV5twz.js} +1 -1
  6. package/dist/assets/CodeEditor-D2Dnax7e.js +1 -0
  7. package/dist/assets/{CodeMap-CtK-C8gK.js → CodeMap-DIKKs3Ux.js} +1 -1
  8. package/dist/assets/{ConfirmModal-ndS17YwF.js → ConfirmModal-CdKg3EOQ.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-Dovomns5.js → CronJobsPanel-CJ7Vc1Am.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-DjR4LLMs.js → DeadCodeScanPanel-DaeHUzc5.js} +1 -1
  11. package/dist/assets/{DebugDashboard-jK1yp3qS.js → DebugDashboard-BI3EmXrM.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-CqXlEUzE.js → DesignGalleryView-DMW6Ab__.js} +1 -1
  13. package/dist/assets/{GoalView-CGNLrnA4.js → GoalView-3291Hxnb.js} +1 -1
  14. package/dist/assets/KanbanView-CFE63A4a.js +3 -0
  15. package/dist/assets/{MailboxDetailView-0TBzZTdN.js → MailboxDetailView-CUTWkSyK.js} +1 -1
  16. package/dist/assets/MemoryDrawer-Dsy0AX6f.js +1 -0
  17. package/dist/assets/MemoryManager-D1kXeVE3.js +1 -0
  18. package/dist/assets/{ModelPicker-BbBZuQwR.js → ModelPicker-IOZSUnqM.js} +1 -1
  19. package/dist/assets/{OfficeMapPanel-68sVzHRD.js → OfficeMapPanel-Q81eioDB.js} +1 -1
  20. package/dist/assets/{ProcessMonitor-gFwiF8gX.js → ProcessMonitor-TGqyXxmB.js} +1 -1
  21. package/dist/assets/{QueuePanel-Cx-isRGl.js → QueuePanel-5aMgQbHv.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-C9tdu6Ld.js → RefreshDebugView-DfBYFPEF.js} +1 -1
  23. package/dist/assets/{RequirementIntakeView-cPEw-RpV.js → RequirementIntakeView-CNAFKiQ3.js} +1 -1
  24. package/dist/assets/SageTabs-olgLJfg_.js +2 -0
  25. package/dist/assets/{SddHub-NKvDRECi.js → SddHub-7Z55QY-M.js} +1 -1
  26. package/dist/assets/SessionInspectView-CytBw7Y9.js +1 -0
  27. package/dist/assets/{SessionList-ncl-20X_.js → SessionList-C3ygQN8A.js} +1 -1
  28. package/dist/assets/{SessionsDashboard-D23UVLr4.js → SessionsDashboard-CridPbkX.js} +1 -1
  29. package/dist/assets/{SetupScreen-D3XQ8MGk.js → SetupScreen-BkVjdky4.js} +1 -1
  30. package/dist/assets/{SkillDetailView-DDPhVFet.js → SkillDetailView-Cp-xEHww.js} +1 -1
  31. package/dist/assets/{SpecsView-afIS0QpX.js → SpecsView-DUx1sgtH.js} +1 -1
  32. package/dist/assets/{TechStackView-kQ2OGxxw.js → TechStackView-CvUiAISX.js} +1 -1
  33. package/dist/assets/{TerminalPanel-GcJWeldW.js → TerminalPanel-Dg5hqYTA.js} +1 -1
  34. package/dist/assets/{Toaster-CgQA9256.js → Toaster-BgN2bRJx.js} +1 -1
  35. package/dist/assets/{activity-DxDRJ8kN.js → activity-BLSyJfTr.js} +2 -2
  36. package/dist/assets/{activity-DsSuflRW.js → activity-BnTQWNPX.js} +2 -2
  37. package/dist/assets/{activity-nVmsmqAI.js → activity-BwEBEQ51.js} +2 -2
  38. package/dist/assets/{activity-CRTVZ5A4.js → activity-C-9I3_s4.js} +2 -2
  39. package/dist/assets/{activity-VI776bUZ.js → activity-CRMLR4a3.js} +2 -2
  40. package/dist/assets/{activity-Ba3aMzvo.js → activity-CZIixoel.js} +2 -2
  41. package/dist/assets/{activity-B-cvKIfT.js → activity-Xqrt9v4z.js} +2 -2
  42. package/dist/assets/{i18n-COgumVF5.js → i18n-9T7iGYgW.js} +2 -2
  43. package/dist/assets/index-Cw20Xg0d.css +1 -0
  44. package/dist/assets/{index-CtpViiZy.js → index-FHt-sKVF.js} +4 -4
  45. package/dist/assets/{progress-ring-D_48qsBl.js → progress-ring-B9pqitSa.js} +1 -1
  46. package/dist/assets/{stores-ChEnUmic.js → stores-vuG0AaKy.js} +2 -2
  47. package/dist/assets/{useWebSocket-_gk4MRJz.js → useWebSocket-CZSpbA3M.js} +1 -1
  48. package/dist/components/KanbanBoardState.d.ts +0 -1
  49. package/dist/components/KanbanTaskInspector.d.ts +1 -2
  50. package/dist/index.html +9 -9
  51. package/dist/index.js +7533 -7321
  52. package/dist/lib/kanban-cleaner.d.ts +7 -1
  53. package/dist/stores/kanban-store.d.ts +12 -0
  54. package/package.json +8 -8
  55. package/dist/assets/CodeEditor-sr50ljZN.js +0 -1
  56. package/dist/assets/KanbanView--tAf_K7N.js +0 -3
  57. package/dist/assets/MemoryManager-CDK_MO8A.js +0 -1
  58. package/dist/assets/SageTabs-BbK6VFO0.js +0 -2
  59. package/dist/assets/SessionInspectView-DPG5qWhj.js +0 -1
  60. package/dist/assets/index-fIsq43fR.css +0 -1
@@ -17,7 +17,13 @@ export interface KanbanAuditSummary {
17
17
  export interface KanbanAuditOptions {
18
18
  /** Explicit time input keeps the audit pure, deterministic, and unit-testable. */
19
19
  now: number | Date;
20
- /** IDs or names of agents currently reported as running by the WebUI fleet roster. */
20
+ /**
21
+ * @deprecated A valid assignment lease is the authoritative liveness
22
+ * signal. The WebUI fleet roster only sees the connected session, so a
23
+ * locally-unknown agent may simply be running in another session — flagging
24
+ * it produced false "abandoned" errors. Kept for API compatibility; ignored
25
+ * by the audit.
26
+ */
21
27
  liveAgentIdentities?: ReadonlySet<string> | readonly string[] | undefined;
22
28
  /** Enable only when the shared Kanban task contract exposes a due date. */
23
29
  requireDueDate?: boolean | undefined;
@@ -12,6 +12,7 @@ interface KanbanState {
12
12
  activeBoardId: string | null;
13
13
  activeBoard: KanbanBoard | null;
14
14
  loading: boolean;
15
+ lastOutboundAction: string | null;
15
16
  error: string | null;
16
17
  queueHealth: KanbanQueueHealth | null;
17
18
  supervisorSnapshot: KanbanSupervisorSnapshot | null;
@@ -24,6 +25,17 @@ interface KanbanState {
24
25
  setError: (error: string | null) => void;
25
26
  setQueueHealth: (health: KanbanQueueHealth | null) => void;
26
27
  handleResult: (type: string, payload: KanbanResultPayload) => void;
28
+ /**
29
+ * Mark a kanban outbound call as in-flight. Caller is still responsible for
30
+ * putting the message on the wire (KanbanView owns ws.send); this only
31
+ * surfaces the loading spinner and ensures handleResult's failure path can
32
+ * clear it. Returns the action type so callers can correlate results.
33
+ */
34
+ sendKanban: (type: string, payload?: Record<string, unknown>) => string;
35
+ transitionTask: (boardId: string, taskId: string, to: 'backlog' | 'todo' | 'running' | 'review' | 'done', extra?: Record<string, unknown>) => string;
36
+ dispatchTask: (boardId: string, taskId: string, description: string) => string;
37
+ moveTask: (boardId: string, taskId: string, targetColumnId: string) => string;
38
+ removeTask: (boardId: string, taskId: string) => string;
27
39
  }
28
40
  export declare const useKanbanStore: import("zustand").UseBoundStore<import("zustand").StoreApi<KanbanState>>;
29
41
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/webui",
3
- "version": "0.301.0",
3
+ "version": "0.302.2",
4
4
  "license": "MIT",
5
5
  "description": "Browser-based WebUI for WrongStack — React + Vite frontend. The WebSocket backend lives in the separate @wrongstack/webui-server package (extracted in PR #018b to remove the CLI -> @wrongstack/webui/server cross-package edge).",
6
6
  "keywords": [
@@ -76,12 +76,12 @@
76
76
  "tailwind-merge": "^3.6.0",
77
77
  "virtua": "^0.49.3",
78
78
  "zustand": "^5.0.14",
79
- "@wrongstack/kanban": "0.301.0",
80
- "@wrongstack/core": "0.301.0",
81
- "@wrongstack/providers": "0.301.0",
82
- "@wrongstack/tools": "0.301.0",
83
- "@wrongstack/plugins": "0.301.0",
84
- "@wrongstack/webui-server": "0.301.0"
79
+ "@wrongstack/providers": "0.302.2",
80
+ "@wrongstack/core": "0.302.2",
81
+ "@wrongstack/kanban": "0.302.2",
82
+ "@wrongstack/tools": "0.302.2",
83
+ "@wrongstack/plugins": "0.302.2",
84
+ "@wrongstack/webui-server": "0.302.2"
85
85
  },
86
86
  "optionalDependencies": {
87
87
  "node-pty": "1.2.0-beta.14"
@@ -103,7 +103,7 @@
103
103
  "typescript": "^7.0.2",
104
104
  "vite": "^8.1.5",
105
105
  "vitest": "^4.1.10",
106
- "@wrongstack/sdd": "0.301.0"
106
+ "@wrongstack/sdd": "0.302.2"
107
107
  },
108
108
  "scripts": {
109
109
  "dev": "vite",
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Nr as n,Oa as r,Pa as i,Qi as a,Qt as o,Ui as s,Vt as c,Xr as l,Yi as u,ar as d,dt as f,in as p,ir as m,la as h,lt as g,ri as _,si as v,vn as y,y as b,yt as x,za as S}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{a as C,i as w,n as ee,o as T,r as E,t as D}from"./monaco-BLUV5g0U.js";import{t as te}from"./ws-client-TTMa0XaT.js";import{t as O}from"./utils-B-9lSDIn.js";import{i as ne}from"./codemap-activity-store-DQfjo7-j.js";import{I as re,N as k,c as ie,j as A,p as ae}from"./stores-ChEnUmic.js";import{o as j}from"./view-navigation-DIDEcp4V.js";import{O as M,v as oe,y as N}from"./index-CtpViiZy.js";import{t as P}from"./empty-state-RRSqQaCk.js";import{t as F}from"./monaco-theme-DSeCDzQy.js";var I={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},L=Array.from(new Set(Object.values(I))).filter(e=>e!==`plaintext`),R=12e3,z=4e3,se=5e3,B=1e4;function V(e){return I[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function H(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function U(e,t){return e.triggerCharacter?!0:t.length>=3}function W(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function G(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var K=e(S(),1),q=g();function ce(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var J=150,le=224,ue=38,Y=/(write|edit|update|create|delete|rename|modified|changed)/i;function X(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=X(e),r=X(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function de(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>Y.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function Q(e){return typeof e==`string`&&e.length>0?e:void 0}function fe(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function pe(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:fe(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function me(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function he(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function ge(e){return e?e.split(/\r?\n/).length:0}function _e(e){return new TextEncoder().encode(e).length}function ve(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ye(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function be(e,t){let n=N(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function xe({file:e}){let{t}=i(),[o,l]=(0,K.useState)(!0),[f,p]=(0,K.useState)(le),[m,h]=(0,K.useState)(`overview`),[g,b]=(0,K.useState)([]),[x,S]=(0,K.useState)([]),[C,w]=(0,K.useState)(!1),[ee,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),k=(0,K.useRef)(null),A=re(e=>e.wsUrl),j=ne(e=>e.history),M=ne(e=>e.activeOperations),N=ae(e=>e.activeBoard),P=ie(e=>e.snapshot),F=(0,K.useMemo)(()=>te(A),[A]),I=(0,K.useCallback)(()=>{T(null),w(!0),typeof F.getGitDiff==`function`&&F.getGitDiff(e.path);let t=typeof F.supportsCapability==`function`?F.supportsCapability.bind(F):null;t?.(`chronicle.query`)?F.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&F.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[F,e.path]);(0,K.useEffect)(()=>{b([]),S([]),D(null);let t=F.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=F.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=F.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(T(e.payload.message),w(!1))}),i=F.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){D({text:e.savedContent,available:!1,error:n.error});return}D({text:n.oldText??``,available:!0})});return I(),()=>{t(),n(),r(),i()}},[F,e.path,e.savedContent,I]),(0,K.useEffect)(()=>{let e=e=>{if(!k.current)return;let t=k.current.startY-e.clientY,n=Math.max(J,Math.floor(window.innerHeight*.62));p(Math.min(n,Math.max(J,k.current.startHeight+t)))},t=()=>{k.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let L=(0,K.useMemo)(()=>{let t=[];for(let[n,r]of j)Z(n,e.path)&&t.push(...r);for(let n of M.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[M,e.path,j]),R=(0,K.useMemo)(()=>he([...L.map(me),...g.map(pe)]),[g,L]),z=(0,K.useMemo)(()=>de(R),[R]),se=(0,K.useMemo)(()=>ce(x),[x]),B=E?.text??e.savedContent,V=(0,K.useMemo)(()=>be(B,e.content),[B,e.content]),H=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.sessionId).filter(e=>!!e))],[R]),U=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.actor).filter(Boolean))],[R]),W=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.taskId).filter(e=>!!e))],[R]),G=(0,K.useCallback)(e=>{let t=N?.tasks.find(t=>t.id===e),n=P?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[N,P]),Y=e=>{o||l(!0),k.current={startY:e.clientY,startHeight:o?f:J},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},X=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,q.jsx)(r,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,q.jsx)(_,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,q.jsx)(d,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,q.jsx)(c,{})}];return(0,q.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:o?f:ue},"data-testid":`file-activity-drawer`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:Y,onDoubleClick:()=>{l(!0),p(le)},title:t(`activity:fileActivity.resizeHint`),children:(0,q.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,q.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":o,children:[(0,q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,q.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),o?(0,q.jsx)(a,{className:`h-3 w-3`}):(0,q.jsx)(u,{className:`h-3 w-3`})]}),(0,q.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,q.jsx)(Se,{label:`${ge(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,q.jsx)(Se,{label:ve(_e(e.content))}),!V.large&&(V.added>0||V.removed>0)&&(0,q.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,q.jsxs)(`span`,{className:`text-success`,children:[`+`,V.added]}),(0,q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,V.removed]})]}),(0,q.jsxs)(`span`,{className:O(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,z.level===`churn`&&`bg-destructive/10 text-destructive`,z.level===`active`&&`bg-warning/10 text-warning`,z.level===`quiet`&&`bg-success/10 text-success`),children:[(0,q.jsx)(s,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${z.level}`)]}),(0,q.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:R.length})}),o&&(0,q.jsx)(`button`,{type:`button`,onClick:I,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,q.jsx)(y,{className:O(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),o&&(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[X.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>h(e.id),className:O(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,m===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),ee&&(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:ee})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m===`overview`&&(0,q.jsx)(Ce,{analysis:z,lifetime:se,records:R,sessions:H,agents:U,tasks:W,taskLabel:G}),m===`changes`&&(0,q.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,q.jsx)(n,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:E?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,q.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),E?.error&&(0,q.jsx)(`span`,{className:`truncate text-warning`,children:E.error})]}),(0,q.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,q.jsx)(oe,{oldText:B,newText:e.content,caption:e.path,fill:!0})})]}),m===`context`&&(0,q.jsx)(Te,{sessions:H,agents:U,tasks:W,records:R,taskLabel:G,boardTitle:N?.title??P?.title}),m===`logs`&&(0,q.jsx)(Oe,{records:R,loading:C})]})]})]})}function Se({label:e}){return(0,q.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Ce({analysis:e,lifetime:t,records:n,sessions:r,agents:a,tasks:s,taskLabel:c}){let{t:l}=i();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,q.jsx)(_,{})},{label:l(`activity:fileActivity.sessions`),value:r.length,icon:(0,q.jsx)(x,{})},{label:l(`activity:fileActivity.actors`),value:a.length,icon:(0,q.jsx)(h,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,q.jsx)(d,{})}].map(e=>(0,q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,q.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,q.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,q.jsx)(we,{lifetime:t}),(0,q.jsxs)(`div`,{className:O(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,q.jsx)(o,{className:O(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,q.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:l(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),s.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:c(e)},e))]})]}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:l(`activity:fileActivity.recentActivity`)}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,q.jsx)($,{text:l(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,q.jsx)(ke,{record:e},`${e.id}:${e.at}`))})]})]})}function we({lifetime:e}){let{t}=i(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,q.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,q.jsx)(v,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[n.map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,q.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,q.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function Te({sessions:e,agents:t,tasks:n,records:r,taskLabel:a,boardTitle:o}){let{t:s}=i();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,q.jsx)(Ee,{icon:(0,q.jsx)(x,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,q.jsx)(De,{title:ye(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,q.jsx)(Ee,{icon:(0,q.jsx)(h,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,q.jsx)(De,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,q.jsx)(Ee,{icon:(0,q.jsx)(d,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,q.jsx)(De,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Ee({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,q.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,q.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,q.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,q.jsx)($,{text:n})})]})}function De({title:e,subtitle:t,raw:n}){return(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,q.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Oe({records:e,loading:t}){let{t:n}=i();return t&&e.length===0?(0,q.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,q.jsx)($,{text:n(`activity:fileActivity.noEvidence`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(ke,{record:e,raw:!0},`${e.id}:${e.at}`))})}function ke({record:e,raw:t=!1}){let n=(0,q.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,q.jsx)(`span`,{className:O(`w-fit rounded px-1.5 py-0.5 font-mono`,Y.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,q.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,q.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,q.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,q.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,q.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function $({text:e}){return(0,q.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}ee.config({monaco:D});function Ae(e){switch(e){case`method`:return T.CompletionItemKind.Method;case`function`:return T.CompletionItemKind.Function;case`constructor`:return T.CompletionItemKind.Constructor;case`field`:return T.CompletionItemKind.Field;case`variable`:return T.CompletionItemKind.Variable;case`class`:return T.CompletionItemKind.Class;case`interface`:return T.CompletionItemKind.Interface;case`module`:return T.CompletionItemKind.Module;case`property`:return T.CompletionItemKind.Property;case`unit`:return T.CompletionItemKind.Unit;case`value`:return T.CompletionItemKind.Value;case`enum`:return T.CompletionItemKind.Enum;case`keyword`:return T.CompletionItemKind.Keyword;case`snippet`:return T.CompletionItemKind.Snippet;case`file`:return T.CompletionItemKind.File;case`reference`:return T.CompletionItemKind.Reference;default:return T.CompletionItemKind.Text}}function je(){let e=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.setActiveFile),i=A(e=>e.closeFile);return e.length===0?null:(0,q.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let a=e.path===n,o=e.path.split(`/`).pop()??e.path;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(e.path))},className:O(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,a?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,q.jsx)(t,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:o}),(0,q.jsx)(f,{className:O(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,a&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Me(){let{t:e}=i(),t=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.updateContent),{theme:a}=M(),o=(0,K.useRef)(null),s=(0,K.useRef)(n),c=(0,K.useRef)(new Map),u=(0,K.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?V(n):`plaintext`,f=F(),[m,h]=(0,K.useState)(!1);(0,K.useEffect)(()=>{s.current=n},[n]),(0,K.useEffect)(()=>{let e=F();C.setTheme(e)},[a]),(0,K.useEffect)(()=>{let e=L.map(e=>T.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-R),a),u=o.slice(a,a+z),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=H(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!U(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=te(re.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?T.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=G({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(c.current.set(y,{expiresAt:Date.now()+B,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),se),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:W(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,K.useCallback)(()=>{let e=o.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,K.useCallback)(()=>{j(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,K.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(k.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,K.useCallback)(()=>{let e=s.current;e&&(k.getState().addRef({kind:`file`,path:e}),_())},[_]),x=(0,K.useCallback)(t=>{o.current=t,C.setTheme(F()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();h(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|E.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),S=(0,K.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,K.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&A.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,q.jsx)(P,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(je,{}),(0,q.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(m||u)&&(0,q.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:m?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(m?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[m?(0,q.jsx)(p,{className:`h-3 w-3`}):(0,q.jsx)(l,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e(m?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,q.jsx)(b,{language:d,value:u.content,onChange:S,theme:f,onMount:x,loading:(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,q.jsx)(xe,{file:u})]})}export{Me as CodeEditor};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Bn as n,Bt as r,Cn as i,Er as a,Gn as o,Ii as s,Ki as c,Li as l,Mt as u,Nr as d,Oa as f,Ot as p,Pa as m,Qi as h,Qt as g,Si as _,St as v,Ti as y,Ui as b,Wi as x,Wt as S,Xi as C,Xr as w,Yt as T,Zn as ee,Zt as E,an as D,ar as O,cn as k,dt as A,fn as j,gi as M,hn as te,in as ne,ir as N,ji as re,jt as ie,kn as ae,la as oe,lt as se,mn as ce,oa as le,oi as ue,qt as de,un as fe,vi as pe,vn as me,wn as P,xa as F,za as he}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as I}from"./ws-client-TTMa0XaT.js";import{t as L}from"./utils-B-9lSDIn.js";import{t as ge}from"./session-store-Df7_hhe9.js";import{I as _e,T as ve,m as ye,p as be}from"./stores-ChEnUmic.js";import{n as R}from"./ui-store-CE4-TlwB.js";import{n as xe,t as Se}from"./ModelPicker-BbBZuQwR.js";import{b as Ce,c as we,x as Te}from"./index-CtpViiZy.js";import{n as z,t as Ee}from"./progress-ring-D_48qsBl.js";var B=e(he(),1);function De(e,t=!0){(0,B.useEffect)(()=>{let n=e.current;if(!n||!t)return;let r=e=>{if(!e.shiftKey||n.scrollWidth<=n.clientWidth+1)return;let t=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;t!==0&&(e.preventDefault(),n.scrollLeft+=t)},i=e=>{if(!e.ctrlKey&&!e.metaKey||n.scrollWidth<=n.clientWidth+1)return;let t=n.clientWidth*.8;e.key===`ArrowLeft`?(e.preventDefault(),n.scrollLeft-=t):e.key===`ArrowRight`&&(e.preventDefault(),n.scrollLeft+=t)};return n.addEventListener(`wheel`,r,{passive:!1}),n.addEventListener(`keydown`,i),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`keydown`,i)}},[e,t])}var Oe=4320*60*1e3,V=new Set([`completed`,`archived`]);function ke(e,t){let n=Ue(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=ze(t.liveAgentIdentities),i=Pe(e,t.defaultReviewStaleAfterMs??Oe),a=Ne(e),o=[];for(let s of e.tasks)V.has(s.status)||(H(o,s,t.requireDueDate===!0),Ae(o,s,n,r),je(o,s,n,i),a.length>1&&Me(o,s,a));return o.sort(We),{issues:o,counts:{error:o.filter(e=>e.severity===`error`).length,warning:o.filter(e=>e.severity===`warning`).length},affectedTaskCount:new Set(o.map(e=>e.taskId)).size}}function H(e,t,n){W(t.description)||G(e,t,`missing-description`,`warning`,`Add a description`),Le(t).length===0&&G(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!W(t.dueDate)&&G(e,t,`missing-due-date`,`warning`,`Set a due date`),!Ve(t.labels)&&!Ve(t.tags)&&G(e,t,`missing-labels`,`warning`,`Add labels or tags`),!Ve(t.childTaskIds)&&!Ve(t.subtasks)&&G(e,t,`missing-subtasks`,`warning`,`Define subtasks`),Ve(t.successCriteria)||G(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function Ae(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Le(t);if(!i||a.length===0||!W(i.leaseId)||!W(i.leaseExpiresAt)){G(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=Ue(i.leaseExpiresAt);if(o===null||o<=n){G(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(U(e)))||G(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function je(e,t,n,r){if(t.status!==`review`)return;let i=Ie(t,`review`)??Ue(t.updatedAt);i===null||n-i<=r||G(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function Me(e,t,n){let r=Fe(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[U(e),t]));for(let n=1;n<r.length;n+=1){let a=r[n-1],o=r[n];if(!a||!o)continue;let s=i.get(U(a.state)),c=i.get(U(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){G(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function Ne(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=Re(e);if(t.length>1)return t;if(!e||typeof e!=`object`||Array.isArray(e))continue;let n=e;if(n.mode===`managed`&&n.columns){let e=[`backlog`,`todo`,`running`,`review`,`done`].map(e=>n.columns?.[e]).filter(e=>W(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=Re(e);if(t.length>1)return t}}return[]}function Pe(e,t){let n=[e,e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e;if(He(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(He(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(He(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Fe(e){let t=e.lifecycle?.history??e.lifecycleHistory??e.statusHistory??e.history;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e==`string`&&W(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=Be(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:Ue(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function Ie(e,t){let n=null;for(let r of Fe(e))U(r.state)!==U(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Le(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(W)}function Re(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(W(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=Be(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function ze(e){let t=new Set;if(!e)return t;for(let n of e)W(n)&&t.add(U(n));return t}function U(e){return e.trim().toLocaleLowerCase()}function Be(...e){for(let t of e)if(W(t))return t.trim();return null}function W(e){return typeof e==`string`&&e.trim().length>0}function Ve(e){return Array.isArray(e)&&e.length>0}function He(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Ue(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function G(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function We(e,t){let n=Ge(e.severity)-Ge(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function Ge(e){return e===`error`?0:1}function Ke(e){let t=_e(e=>e.wsUrl),n=_e(e=>e.provider),r=_e(e=>e.model),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)({}),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(``);return(0,B.useEffect)(()=>{let e=I(t).on(`kanban.meta`,e=>{let t=e.payload?.data;t&&(a(t.tools??[]),s(t.skills??[]),l(t.fallbackProfiles??{}),t.sessionProvider&&d(t.sessionProvider),t.sessionModel&&p(t.sessionModel))});return()=>e()},[t]),(0,B.useEffect)(()=>{e&&I(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}var K=se();function q({options:e,selected:n,onChange:r,placeholder:a,emptyLabel:o}){let{t:s}=m(),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!c)return;let e=e=>{f.current&&!f.current.contains(e.target)&&l(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[c]);let p=(0,B.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),g=(0,B.useMemo)(()=>{let t=u.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,u]),_=e=>{r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,K.jsxs)(`div`,{ref:f,className:`relative`,children:[n.length>0&&(0,K.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:n.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px]`,children:[(0,K.jsx)(`span`,{className:`max-w-[150px] truncate`,children:p(e)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${p(e)}`,children:(0,K.jsx)(A,{size:11})})]},e))}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,K.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:a??`Add…`}),(0,K.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),c&&(0,K.jsxs)(`div`,{className:`absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:s(`activity:chipMultiSelect.filter`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),u&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(``),className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(A,{className:`h-3 w-3`})})]}),(0,K.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[g.map(e=>{let r=n.includes(e.value);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>_(e.value),className:L(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,r?`bg-primary/8 text-primary`:`text-foreground`),children:[r?(0,K.jsx)(t,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,K.jsx)(`span`,{className:`w-3 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,K.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:e.description})]}),e.tag&&(0,K.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:e.tag})]},e.value)}),g.length===0&&(0,K.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:e.length===0?o??`Nothing available`:`No match`})]})]})]})}function qe(e){let t=Math.max(0,Date.now()-Date.parse(e));return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Je(e,t){if(!e)return null;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;let i=Math.max(0,Math.floor((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m`;let o=Math.floor(a/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function Ye({presence:e=[]}){let{t}=m();return e.length===0?null:(0,K.jsxs)(`section`,{"aria-label":t(`activity:kanban.boardPresence`),className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/50 px-4 py-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:t(`activity:kanban.liveBoardUsers`)}),e.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 text-xs shadow-sm`,title:`Session ${e.sessionId} · last seen ${e.lastSeenAt}`,children:[(0,K.jsx)(`span`,{role:`img`,"aria-label":e.active?`active`:`inactive`,className:L(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,K.jsx)(l,{size:13,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`max-w-32 truncate font-medium`,children:e.agentName??e.agentId}),(0,K.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,children:e.sessionId}),(0,K.jsx)(re,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:qe(e.lastSeenAt)})]},e.id))]})}function Xe({board:e,snapshot:t,sendKanban:n}){let{t:r}=m(),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!0),[c,l]=(0,B.useState)(`deterministic`),[u,d]=(0,B.useState)(`session`),[p,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)([]),[C,w]=(0,B.useState)([]),[T,ee]=(0,B.useState)(10),D=xe(i&&c===`agentic`),O=Ke(i&&c===`agentic`);(0,B.useEffect)(()=>{let t=e.supervisor;s(t?.enabled??!0),l(t?.mode??`deterministic`),d(t?.routing?.mode??`session`),g(t?.routing?.provider??``),v(t?.routing?.model??``),b(t?.routing?.fallbackProfile??``),S(t?.routing?.fallbackModels??[]),w(t?.skills??[]),ee(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,JSON.stringify(e.supervisor)]);let k=()=>{let t={mode:u,...u===`fixed`&&p?{provider:p}:{},...u===`fixed`&&_?{model:_}:{},...u===`fallback_profile`&&y?{fallbackProfile:y}:{},...x.length?{fallbackModels:x}:{}};n(`kanban.update`,{boardId:e.id,supervisor:{enabled:o,mode:c,intervalMs:Math.max(2,T)*1e3,recoveryMode:`auto`,...c===`agentic`?{routing:t,skills:C}:{}}}),window.setTimeout(()=>n(`kanban.supervisor.audit`,{boardId:e.id}),150)},A=o?t?.status??`starting`:`disabled`;return(0,K.jsxs)(`div`,{className:`shrink-0 border-b bg-background/80`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-1.5 text-left text-[11px] hover:bg-muted/40`,children:[(0,K.jsx)(E,{size:13,className:A===`healthy`?`text-success`:`text-warning`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:r(`activity:kanban.kanbanAgent`)}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 capitalize text-muted-foreground`,children:[c,` · `,A]}),t?.summary&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.summary}),(0,K.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?.lastAuditAt?r(`activity:kanban.checkedAgo`,{ago:Je(t.lastAuditAt)}):r(`activity:kanban.notChecked`)}),(0,K.jsx)(h,{size:13,className:L(`transition-transform`,i&&`rotate-180`)})]}),i&&(0,K.jsxs)(`div`,{className:`grid gap-3 border-t p-3 text-xs lg:grid-cols-[220px_220px_1fr_auto]`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border bg-card px-2 py-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,K.jsx)(`span`,{children:r(`activity:kanban.watchThisBoard`)})]}),(0,K.jsx)(Ze,{label:r(`activity:kanban.supervisorEngine`),value:c,options:[`deterministic`,`agentic`],onChange:e=>l(e)}),(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:r(`activity:kanban.auditInterval`)}),(0,K.jsx)(`input`,{type:`number`,min:2,value:T,onChange:e=>ee(Number(e.target.value)||2),className:`h-8 w-full rounded-md border bg-background px-2 outline-none focus:border-primary`})]}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:k,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,K.jsx)(fe,{size:13}),` `,r(`activity:boardChrome.save`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.supervisor.audit`,{boardId:e.id}),className:`inline-flex h-8 items-center gap-1 rounded-md border px-3 hover:bg-muted`,children:[(0,K.jsx)(f,{size:13}),` `,r(`activity:boardChrome.auditNow`)]})]}),c===`deterministic`?(0,K.jsx)(`div`,{className:`lg:col-span-4 rounded-md border border-success/20 bg-success/5 px-3 py-2 text-muted-foreground`,children:r(`activity:boardChrome.deterministicModeUsesNoProviderModel`)}):(0,K.jsxs)(`div`,{className:`grid gap-3 lg:col-span-4 lg:grid-cols-2`,children:[(0,K.jsx)(Ze,{label:r(`activity:kanban.kanbanAgentModelSource`),value:u,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>d(e)}),u===`fixed`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:r(`activity:boardChrome.fixedProviderModel`)}),(0,K.jsx)(Se,{value:_||void 0,provider:p||void 0,candidates:D,placeholder:r(`activity:kanban.selectProviderModel`),onPick:(e,t)=>{v(e),g(t)}})]}),u===`fallback_profile`&&(0,K.jsx)(Ze,{label:r(`activity:kanban.fallbackProfile`),value:y,options:Object.keys(O.fallbackProfiles),placeholder:r(`activity:kanban.selectProfile`),onChange:b}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:r(`activity:kanban.supervisorSkills`)}),(0,K.jsx)(q,{options:O.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:C,onChange:w,placeholder:r(`activity:kanban.forceLoadSkills`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:r(`activity:kanban.extraFallbackModels`)}),(0,K.jsx)(q,{options:D.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:x,onChange:S,placeholder:r(`activity:kanban.optionalFallbacks`)})]})]})]})]})}function Ze({label:e,value:t,options:n,onChange:r,placeholder:i}){return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,K.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`,children:[i&&(0,K.jsx)(`option`,{value:``,children:i}),n.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]})}function Qe(e){let t=new Set;for(let n of e)n.status===`running`&&(t.add(n.id),t.add(n.name));return t}function $e(e){let t=new Set;e.sessionId&&t.add(e.sessionId);for(let n of e.registrySessionIds)t.add(n);for(let n of e.agents)n.status===`running`&&n.sessionId&&t.add(n.sessionId);return[...t]}function et(e){return e?e.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0}function tt(e){let t=e?.tags??[],n=t.includes(`sdd`)?`sdd`:t.includes(`goal`)?`goal`:null;if(!n)return null;let r=t.find(e=>e.startsWith(`run:`))?.slice(4);return{engine:n,...r?{runId:r}:{}}}function nt({boardTotal:e,activeBoardTotal:t,orphanedBoardTotal:n,activeBoardId:r,activeBoards:a,orphanedBoards:o,boardPage:s,boardPageSize:c,loading:l,newBoardTitle:u,onClose:d,onRefresh:f,onNewBoardTitleChange:p,onCreateBoard:h,onBoardSelect:g,onBoardPageChange:_}){let{t:v}=m();return(0,K.jsxs)(`aside`,{className:`flex max-h-[45dvh] w-full shrink-0 flex-col border-b bg-card/40 md:max-h-none md:w-[280px] md:border-b-0 md:border-r`,children:[(0,K.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-3`,children:[(0,K.jsx)(`button`,{type:`button`,title:v(`common:action.back`),onClick:d,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(F,{size:16})}),(0,K.jsx)(y,{size:17,className:`text-primary`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:v(`activity:kanban.kanban`)}),(0,K.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:[e,` boards · `,t,` active · `,n,` orphaned`]})]}),(0,K.jsx)(`button`,{type:`button`,title:v(`common:action.refresh`),onClick:f,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(me,{size:15,className:l?`animate-spin`:void 0})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,K.jsx)(`input`,{value:u,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},placeholder:v(`activity:kanban.newBoard`),className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:border-primary`}),(0,K.jsx)(`button`,{type:`button`,title:v(`activity:kanban.createBoard`),onClick:h,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,K.jsx)(i,{size:16})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[a.length>0&&(0,K.jsxs)(`div`,{className:`mb-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-success`,children:[`Active session · `,a.length]}),a.map(e=>(0,K.jsx)(rt,{board:e,active:r===e.id,dotClassName:`bg-success`,onSelect:g},e.id)),o.length>0&&(0,K.jsxs)(`div`,{className:`mb-1 mt-2 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`No active session · `,o.length]}),o.map(e=>(0,K.jsx)(rt,{board:e,active:r===e.id,dotClassName:`bg-muted-foreground/45`,onSelect:g},e.id))]}),(0,K.jsx)(Ce,{page:s,pageSize:c,totalItems:e,onPageChange:_,compact:!0,itemLabel:`boards`})]})}function rt({board:e,active:t,dotClassName:n,onSelect:r}){return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:L(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,t?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,n)}),e.taskCount,` tasks`]}),(0,K.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]})}var it={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function at({title:e,value:t,inherited:n,onSave:r}){let{t:i}=m(),[a,o]=(0,B.useState)(t??it),[s,c]=(0,B.useState)(st(t?.allow??[])),[l,u]=(0,B.useState)(st(t?.deny??[])),[d,f]=(0,B.useState)(null);return(0,B.useEffect)(()=>{o(t??it),c(st(t?.allow??[])),u(st(t?.deny??[])),f(null)},[t]),(0,K.jsxs)(`details`,{className:`rounded-md border border-primary/25 bg-primary/5`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-xs font-semibold`,children:[(0,K.jsx)(E,{size:14,className:`text-primary`}),(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`span`,{className:`ml-auto font-normal text-muted-foreground`,children:t?.enabled?`${t.enforcement} · ${t.allow.length} allow · shell ${t.shellAccess}`:n?.enabled?`inherits board boundary`:`unrestricted`})]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t p-3 text-xs`,children:[n?.enabled&&(0,K.jsx)(`div`,{className:`rounded border border-warning/25 bg-warning/10 px-2 py-1.5 text-muted-foreground`,children:i(`activity:kanbanBoundaryEditor.boardPolicyRemainsAuthoritativeThisTask`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a.enabled,onChange:e=>o({...a,enabled:e.target.checked})}),i(`activity:kanban.enableLayer`)]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:i(`activity:kanban.outsideScope`)}),(0,K.jsxs)(`select`,{value:a.enforcement,onChange:e=>o({...a,enforcement:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,K.jsx)(`option`,{value:`confirm`,children:i(`activity:kanban.askPermission`)}),(0,K.jsx)(`option`,{value:`block`,children:i(`activity:kanban.alwaysBlock`)})]})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:i(`activity:kanbanBoundaryEditor.shellOpaqueTools`)}),(0,K.jsxs)(`select`,{value:a.shellAccess,onChange:e=>o({...a,shellAccess:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,K.jsx)(`option`,{value:`confirm`,children:i(`activity:kanban.askPermission`)}),(0,K.jsx)(`option`,{value:`block`,children:i(`activity:kanban.alwaysBlock`)}),(0,K.jsx)(`option`,{value:`allow`,children:i(`activity:kanban.allow`)})]})]})]}),(0,K.jsx)(ot,{label:i(`activity:kanban.allowSelectors`),value:s,onChange:c}),(0,K.jsx)(ot,{label:i(`activity:kanban.denySelectors`),value:l,onChange:u}),(0,K.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[`One per line: kind:access:path — for example directory:read_write:packages/webui or file:read:README.md. Kinds: file, directory, package, glob. If an access type has no allow selector, it remains unrestricted except for deny rules. `,i(`activity:kanban.crossPathSelectors`)]}),d&&(0,K.jsx)(`div`,{className:`text-destructive`,children:d}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=ct(s),t=ct(l);r({...a,allow:e,deny:t}),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}},className:`inline-flex h-8 flex-1 items-center justify-center gap-2 rounded bg-primary text-primary-foreground`,children:[(0,K.jsx)(fe,{size:13}),` `,i(`activity:kanbanBoundaryEditor.saveBoundary`)]}),t&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`h-8 rounded border px-3 text-muted-foreground hover:bg-muted`,children:i(`activity:kanban.removeLayer`)})]})]})]})}function ot({label:e,value:t,onChange:n}){return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,K.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value),className:`w-full resize-y rounded border bg-background px-2 py-1.5 font-mono text-[11px] outline-none focus:border-primary`})]})}function st(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
2
- `)}function ct(e){let t=new Set([`file`,`directory`,`package`,`glob`]),n=new Set([`read`,`write`,`read_write`]);return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map((e,r)=>{let i=e.indexOf(`:`),a=e.indexOf(`:`,i+1);if(i<=0||a<=i+1||a===e.length-1)throw Error(`Boundary line ${r+1} must use kind:access:path.`);let o=e.slice(0,i),s=e.slice(i+1,a),c=e.slice(a+1).trim();if(!c)throw Error(`Boundary line ${r+1} must use kind:access:path.`);if(!t.has(o))throw Error(`Boundary line ${r+1} has unknown kind.`);if(!n.has(s))throw Error(`Boundary line ${r+1} has unknown access.`);return{kind:o,access:s,path:c}})}function lt({audit:e,onSelectTask:t}){let[n,r]=(0,B.useState)(!0),i=(0,B.useId)();if((0,B.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let a=ut(e.issues);return(0,K.jsxs)(`section`,{"aria-labelledby":`${i}-title`,className:`shrink-0 border-b border-warning/25 bg-card/95 shadow-[inset_0_1px_0_hsl(var(--warning)/0.08)]`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,role:`status`,"aria-live":`polite`,children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-warning/25 bg-warning/10 text-warning`,children:(0,K.jsx)(S,{size:14,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`h2`,{id:`${i}-title`,className:`text-xs font-semibold text-foreground`,children:[`Kanban Cleaner found `,e.issues.length,` `,e.issues.length===1?`issue`:`issues`]}),(0,K.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[e.affectedTaskCount,` `,e.affectedTaskCount===1?`card needs`:`cards need`,` attention`]})]})]}),e.counts.error>0&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-destructive/25 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive`,children:[(0,K.jsx)(c,{size:11,"aria-hidden":`true`}),` `,e.counts.error,` critical`]}),e.counts.warning>0&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-[10px] font-medium text-warning`,children:[(0,K.jsx)(p,{size:11,"aria-hidden":`true`}),` `,e.counts.warning,` warning`]}),(0,K.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,"aria-label":n?`Collapse Kanban Cleaner issues`:`Expand Kanban Cleaner issues`,onClick:()=>r(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,K.jsx)(h,{size:14,"aria-hidden":`true`,className:L(`transition-transform`,n&&`rotate-180`)})})]}),n&&(0,K.jsx)(`ul`,{id:i,className:`grid max-h-36 gap-1 overflow-y-auto px-3 pb-2 sm:grid-cols-2 sm:px-4 xl:grid-cols-3`,children:a.map(({taskId:e,taskTitle:n,issues:r})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Open ${n}: ${r.map(e=>e.message).join(`, `)}`,className:`group flex w-full items-start gap-2 rounded-md border border-border/70 bg-background/70 px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,K.jsx)(`span`,{className:L(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,r.some(e=>e.severity===`error`)?`bg-destructive shadow-[0_0_8px_hsl(var(--destructive)/0.55)]`:`bg-warning shadow-[0_0_8px_hsl(var(--warning)/0.45)]`),"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-[11px] font-semibold text-foreground group-hover:text-primary`,children:n}),(0,K.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[10px] leading-4 text-muted-foreground`,children:r.map(e=>e.message).join(` · `)})]})]})},e))})]})}function ut(e){let t=new Map;for(let n of e){let e=t.get(n.taskId);e?e.issues.push(n):t.set(n.taskId,{taskId:n.taskId,taskTitle:n.taskTitle,issues:[n]})}return[...t.values()]}function dt({board:e,sendKanban:n,onSelectTask:r}){let{t:i}=m(),[a,o]=(0,B.useState)(!1),s=e.tasks.filter(e=>e.decomposition?.status===`proposed`);return s.length?(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-warning/30 bg-warning/5 px-4 py-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 text-left text-xs font-semibold text-warning`,children:[a?(0,K.jsx)(C,{size:13}):(0,K.jsx)(h,{size:13}),(0,K.jsx)(k,{size:13}),s.length,` decomposition proposal`,s.length>1?`s`:``,` awaiting approval`]}),!a&&(0,K.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:s.map(a=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(a.id),className:`min-w-0 flex-1 truncate text-left hover:underline`,children:[a.title,(0,K.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`→ `,a.decomposition?.proposedSubtasks.length??0,` subtasks`]})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.approve`,{boardId:e.id,taskId:a.id,proposalId:a.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2 py-1 text-[11px] font-medium text-success hover:bg-success/20`,children:[(0,K.jsx)(t,{size:12}),` `,i(`activity:kanbanDecomp.approve`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.reject`,{boardId:e.id,taskId:a.id,proposalId:a.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20`,children:[(0,K.jsx)(A,{size:12}),` `,i(`activity:kanbanDecomp.reject`)]})]},a.id))})]}):null}var ft=[`assessed`,`proposed`,`approval`,`applied`];function pt(e){let t=e.decomposition?.status;return t===`applied`?3:t===`approved`||t===`rejected`?2:t===`proposed`?1:e.atomicityAssessment?0:-1}function mt({board:e,task:n,sendKanban:r,onSelectTask:i}){let{t:a}=m(),o=n.decomposition,s=pt(n),c=(0,B.useMemo)(()=>{if(!o)return null;let t=(o.appliedChildTaskIds??[]).map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return{tasks:[{id:n.id,shortId:`parent`,title:n.title,displayStatus:o.status===`applied`?`completed`:`in_progress`,priority:n.priority,deps:[]},...o.proposedSubtasks.map((e,r)=>{let i=t[r];return{id:i?.id??`proposed-${r}`,shortId:`s${r}`,title:e.title,displayStatus:i?i.status===`completed`?`completed`:i.status===`failed`?`failed`:i.status===`in_progress`?`in_progress`:`pending`:o.status===`approved`?`queued`:`pending`,priority:n.priority,deps:(e.dependsOnIndex??[]).map(e=>`s${e}`)}})],columns:[{label:a(`activity:kanbanDecomp.parent`),taskIds:[`parent`]},{label:o.status===`applied`?`Subtasks`:`Proposed subtasks`,taskIds:o.proposedSubtasks.map((e,t)=>`s${t}`)}],appliedChildren:t}},[e,o,n]);return!o&&!n.atomicityAssessment?null:(0,K.jsxs)(`div`,{className:`mt-4 rounded-md border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,K.jsx)(k,{size:13}),a(`activity:kanbanDecomp.decomposition`)]}),(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 text-[11px]`,children:[ft.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,K.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,K.jsx)(`span`,{className:L(`rounded px-1.5 py-0.5`,o?.status===`rejected`&&t===2?`bg-destructive/10 text-destructive`:t<=s?`bg-primary/10 font-medium text-primary`:`bg-muted text-muted-foreground`),children:o?.status===`rejected`&&t===2?`rejected`:e})]},e)),n.atomicityAssessment&&(0,K.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[n.atomicityAssessment.verdict,` · score `,n.atomicityAssessment.score]})]}),!o&&n.atomicityAssessment?.verdict===`needs_decomposition`&&(0,K.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-warning`,children:[a(`activity:kanbanDecomp.thisTaskShouldBeSplitBefore`),(0,K.jsx)(`ul`,{className:`ml-4 mt-1 list-disc`,children:n.atomicityAssessment.criteria.filter(e=>e.score<1).map(e=>(0,K.jsx)(`li`,{children:e.reason},e.id))})]}),o&&c&&(0,K.jsxs)(K.Fragment,{children:[o.rationale&&(0,K.jsxs)(`div`,{className:`mb-2 text-[11px] text-muted-foreground`,children:[`“`,o.rationale,`”`]}),(0,K.jsx)(`div`,{className:`h-64 overflow-hidden rounded-md border`,children:(0,K.jsx)(z,{tasks:c.tasks,columns:c.columns,onTaskClick:t=>{e.tasks.some(e=>e.id===t)&&i(t)}})}),(0,K.jsx)(`ul`,{className:`mt-2 space-y-1 text-[11px]`,children:o.proposedSubtasks.map((e,t)=>(0,K.jsxs)(`li`,{className:`rounded bg-muted/40 px-2 py-1`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.title}),e.successCriteria?.length?(0,K.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`✓ `,e.successCriteria.join(` · `)]}):null]},`${e.title}-${t}`))}),o.status===`proposed`&&(0,K.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(`kanban.decomposition.approve`,{boardId:e.id,taskId:n.id,proposalId:o.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2.5 py-1.5 text-xs font-medium text-success hover:bg-success/20`,children:[(0,K.jsx)(t,{size:13}),` `,a(`activity:kanbanDecomp.approveAmpSplit`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(`kanban.decomposition.reject`,{boardId:e.id,taskId:n.id,proposalId:o.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/20`,children:[(0,K.jsx)(A,{size:13}),` `,a(`activity:kanbanDecomp.reject`)]})]}),o.status===`applied`&&c.appliedChildren.length>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:c.appliedChildren.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`rounded-md border px-2 py-1 text-[11px] hover:bg-muted`,children:[e.title,(0,K.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`[`,e.status,`]`]})]},e.id))}),o.status===`rejected`&&o.resolutionReason&&(0,K.jsxs)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Rejected: `,o.resolutionReason]})]})]})}var ht=[`id`,`name`,`type`];function J(e){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;for(let e of ht){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}function gt(e,t){return t?`running`:e.verificationReport?.verdict||`unverified`}var _t=new Set([`completed`,`review`,`failed`]);function vt(e){let t={totalTasks:e.tasks.length,gradedTasks:0,passed:0,failed:0,needsHuman:0,incomplete:0,unverified:0,failingChecks:[],missingEvidence:[],needsDecomposition:[],pendingProposals:[]};for(let n of e.tasks){if(n.status===`archived`)continue;let e=n.verificationReport;if(_t.has(n.status)&&(t.gradedTasks+=1,e?e.verdict===`passed`?t.passed+=1:e.verdict===`failed`?t.failed+=1:e.verdict===`needs_human`?t.needsHuman+=1:t.incomplete+=1:t.unverified+=1),e)for(let r of e.checks)(r.status===`failed`||r.status===`error`)&&t.failingChecks.push({task:n,check:r}),(r.type===`agent`||r.type===`council`)&&r.status===`passed`&&!r.backingRefs?.length&&t.missingEvidence.push({task:n,check:r});!n.childTaskIds?.length&&n.atomicityAssessment?.verdict===`needs_decomposition`&&n.status!==`completed`&&t.needsDecomposition.push(n),n.decomposition?.status===`proposed`&&t.pendingProposals.push(n)}return t}function yt(e){let t=new Map(e.tasks.map(e=>[e.id,e])),n=new Set,r=(e,i)=>{n.add(e.id);let a=e.childTaskIds??[],o=[];for(let e of a){let a=t.get(e);!a||n.has(a.id)||o.push(r(a,i+1))}return{task:e,children:o,depth:i}},i=[];for(let a of e.tasks)a.parentTaskId&&t.get(a.parentTaskId)||n.has(a.id)||i.push(r(a,0));for(let t of e.tasks)n.has(t.id)||i.push(r(t,0));return i}function bt(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};for(let t of e)n(t);return t}function xt(e,t){return e?.columns.find(e=>e.id===t)?.title??t}function St({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`rounded-md border bg-background px-2 py-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:e}),(0,K.jsx)(`div`,{className:`mt-0.5 truncate text-xs font-medium`,children:t})]})}function Y({label:e,value:t,onChange:n}){return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,K.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`})]})}function Ct({label:e,value:t,options:n,placeholder:r,onChange:i}){return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,K.jsxs)(`select`,{value:t,onChange:e=>i(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:[r&&(0,K.jsx)(`option`,{value:``,children:r}),n.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]})}function wt(e){let t=`rounded px-1.5 py-0.5`;return e===`critical`?`${t} bg-destructive/10 text-destructive`:e===`high`?`${t} bg-warning/10 text-warning`:e===`low`?`${t} bg-muted text-muted-foreground`:`${t} bg-info/10 text-info`}function Tt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Et(e){return e===`completed`||e===`failed`||e===`cancelled`}function Dt(e,t){return t?Math.round(e/t*100):0}function Ot(e,t,n,r=new Date){let i=[],a=n.filter(e=>e.taskId===t.id),o=a.filter(e=>e.type!==`task.created`),s=o.filter(e=>e.type!==`task.assignment.heartbeat`&&e.type!==`task.assignment.snapshot`),c=s.filter(e=>!!e.note?.trim()),l=t.assignment,u=r.getTime(),d=100,f=(e,t=0)=>{i.some(t=>t.id===e.id)||(i.push(e),d=Math.max(0,d-t))};t.dueDate&&![`completed`,`archived`].includes(t.status)&&Date.parse(t.dueDate)<u&&f({id:`overdue`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.overdueTitle`,detailKey:`activity:taskRisk.overdueDetail`,detailParams:{dueDate:String(t.dueDate),status:String(t.status)},remediationKey:`activity:taskRisk.overdueFix`});let p=(t.dependsOn??[]).filter(t=>!e.tasks.some(e=>e.id===t));p.length&&f({id:`missing-dependency`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.missingDependencyTitle`,detailKey:`activity:taskRisk.missingDependencyDetail`,detailParams:{count:p.length},remediationKey:`activity:taskRisk.missingDependencyFix`});let m=(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return n&&![`completed`,`archived`].includes(n.status)});m.length&&f({id:`unresolved-dependency`,severity:`warning`,category:`operational`,titleKey:`activity:taskRisk.unresolvedDependencyTitle`,detailKey:`activity:taskRisk.unresolvedDependencyDetail`,detailParams:{count:m.length},remediationKey:`activity:taskRisk.unresolvedDependencyFix`}),(l?.status===`failed`||l?.error)&&f({id:`assignment-failed`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.assignmentFailedTitle`,...l.error??l.lastFailureKind?{detailKey:`activity:taskRisk.assignmentFailedDetail`,detailParams:{reason:String(l.error??l.lastFailureKind)}}:{detailKey:`activity:taskRisk.assignmentFailedDetailGeneric`},remediationKey:`activity:taskRisk.assignmentFailedFix`}),l?.status===`failed`&&l.maxAttempts!==void 0&&(l.attempt??0)>=l.maxAttempts&&f({id:`retry-exhausted`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.retryExhaustedTitle`,detailKey:`activity:taskRisk.retryExhaustedDetail`,detailParams:{used:l.attempt??0,max:String(l.maxAttempts)},remediationKey:`activity:taskRisk.retryExhaustedFix`}),l&&[`queued`,`running`].includes(l.status)&&l.leaseExpiresAt&&Date.parse(l.leaseExpiresAt)<=u&&f({id:`lease-expired`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.leaseExpiredTitle`,detailKey:`activity:taskRisk.leaseExpiredDetail`,detailParams:{expiresAt:String(l.leaseExpiresAt),status:String(l.status)},remediationKey:`activity:taskRisk.leaseExpiredFix`}),l?.status===`running`&&l.heartbeatAt&&u-Date.parse(l.heartbeatAt)>5*6e4&&f({id:`heartbeat-stale`,severity:`warning`,category:`operational`,titleKey:`activity:taskRisk.staleHeartbeatTitle`,detailKey:`activity:taskRisk.staleHeartbeatDetail`,detailParams:{since:String(l.heartbeatAt)},remediationKey:`activity:taskRisk.staleHeartbeatFix`}),t.status===`in_progress`&&!l&&f({id:`unowned-in-progress`,severity:`warning`,category:`operational`,titleKey:`activity:taskRisk.noAssignmentTitle`,detailKey:`activity:taskRisk.noAssignmentDetail`,remediationKey:`activity:taskRisk.noAssignmentFix`});let h=(t.successCriteria??[]).filter(e=>e.status===`failed`),g=(t.successCriteria??[]).filter(e=>e.status===`pending`);h.length&&f({id:`failed-checks`,severity:t.status===`completed`?`critical`:`warning`,category:`operational`,titleKey:`activity:taskRisk.failedChecksTitle`,detailKey:`activity:taskRisk.failedChecksDetail`,detailParams:{count:h.length},remediationKey:`activity:taskRisk.failedChecksFix`}),t.status===`completed`&&g.length&&f({id:`completed-with-pending-checks`,severity:`critical`,category:`operational`,titleKey:`activity:taskRisk.pendingChecksTitle`,detailKey:`activity:taskRisk.pendingChecksDetail`,detailParams:{count:g.length},remediationKey:`activity:taskRisk.pendingChecksFix`}),a.length?a.some(e=>e.type===`task.created`)||f({id:`missing-creation-event`,severity:`warning`,category:`audit`,titleKey:`activity:taskRisk.noProvenanceTitle`,detailKey:`activity:taskRisk.noProvenanceDetail`,remediationKey:`activity:taskRisk.noProvenanceFix`},10):f({id:`no-durable-events`,severity:`critical`,category:`audit`,titleKey:`activity:taskRisk.noEventsTitle`,detailKey:`activity:taskRisk.noEventsDetail`,remediationKey:`activity:taskRisk.noEventsFix`},25);let _=Dt(o.filter(e=>!!e.actor).length,o.length),v=Dt(o.filter(e=>!!e.sessionId).length,o.length),y=Dt(c.length,s.length);o.length&&_<100&&f({id:`actor-coverage`,severity:`warning`,category:`audit`,titleKey:`activity:taskRisk.actorCoverageTitle`,detailKey:`activity:taskRisk.actorCoverageDetail`,detailParams:{percent:_},remediationKey:`activity:taskRisk.actorCoverageFix`},10),o.length&&v<100&&f({id:`session-coverage`,severity:`warning`,category:`audit`,titleKey:`activity:taskRisk.sessionCoverageTitle`,detailKey:`activity:taskRisk.sessionCoverageDetail`,detailParams:{percent:v},remediationKey:`activity:taskRisk.sessionCoverageFix`},10),s.length&&y<50&&f({id:`reason-coverage`,severity:`info`,category:`audit`,titleKey:`activity:taskRisk.reasonCoverageTitle`,detailKey:`activity:taskRisk.reasonCoverageDetail`,detailParams:{percent:y},remediationKey:`activity:taskRisk.reasonCoverageFix`},10);let b={...Tt([...a].sort((e,t)=>t.ts.localeCompare(e.ts)).find(e=>e.type===`task.assigned`||e.type.startsWith(`task.assignment.`))?.after),...l??{}},x=!!(b.provider||b.model||b.modelRouting);l&&!x&&f({id:`missing-route`,severity:`warning`,category:`audit`,titleKey:`activity:taskRisk.noRouteTitle`,detailKey:`activity:taskRisk.noRouteDetail`,remediationKey:`activity:taskRisk.noRouteFix`},10);let S=!!(l?.lastResult||l?.error||a.some(e=>Et(String(Tt(e.after).status??``))&&!!e.note?.trim()));return Et(l?.status)&&!S&&f({id:`missing-terminal-evidence`,severity:`critical`,category:`audit`,titleKey:`activity:taskRisk.missingTerminalEvidenceTitle`,detailKey:`activity:taskRisk.missingTerminalEvidenceDetail`,detailParams:{status:String(l?.status)},remediationKey:`activity:taskRisk.missingTerminalEvidenceFix`},15),i.sort((e,t)=>{let n={critical:0,warning:1,info:2};return n[e.severity]-n[t.severity]}),{score:d,findings:i,critical:i.filter(e=>e.severity===`critical`).length,warnings:i.filter(e=>e.severity===`warning`).length,coverage:{durableEvents:a.length,actorPercent:_,sessionPercent:v,reasonPercent:y,hasExecutionRoute:x,hasTerminalEvidence:S}}}function kt(e){return e===`critical`?`border-destructive/30 bg-destructive/5 text-destructive`:e===`warning`?`border-warning/30 bg-warning/5 text-warning`:`border-info/30 bg-info/5 text-info`}function At({board:e,task:t,events:n}){let{t:r}=m(),i=Ot(e,t,n),a=Te(i.findings,8,t.id);return(0,K.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/10`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(g,{className:`size-4 text-primary`}),(0,K.jsx)(`span`,{className:`text-xs font-semibold`,children:r(`activity:taskRisk.riskAuditQuality`)}),(0,K.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${i.score>=90?`bg-success/10 text-success`:i.score>=70?`bg-warning/10 text-warning`:`bg-destructive/10 text-destructive`}`,children:r(`activity:taskRisk.auditScore`,{score:i.score})}),i.critical>0&&(0,K.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[9px] text-destructive`,children:r(`activity:taskRisk.criticalCount`,{count:i.critical})}),(0,K.jsx)(h,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-center sm:grid-cols-6`,children:[[r(`activity:taskRisk.covEvents`),i.coverage.durableEvents],[r(`activity:taskRisk.covActor`),`${i.coverage.actorPercent}%`],[r(`activity:taskRisk.covSession`),`${i.coverage.sessionPercent}%`],[r(`activity:taskRisk.covReasons`),`${i.coverage.reasonPercent}%`],[r(`activity:taskRisk.covRoute`),i.coverage.hasExecutionRoute?r(`common:action.yes`):r(`common:action.no`)],[r(`activity:taskRisk.covOutcome`),i.coverage.hasTerminalEvidence?r(`common:action.yes`):r(`common:action.no`)]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`rounded border bg-background/70 px-1 py-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[11px] font-semibold`,children:t}),(0,K.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),i.findings.length===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-success/30 bg-success/5 px-2.5 py-2 text-[11px] text-success`,children:[(0,K.jsx)(x,{className:`size-4`}),` `,r(`activity:taskRisk.noDeterministicTaskRisksDetected`)]}):(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[a.pageItems.map(e=>(0,K.jsxs)(`section`,{className:`rounded border px-2.5 py-2 ${kt(e.severity)}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold`,children:[e.category===`audit`?(0,K.jsx)(pe,{className:`size-3.5`}):(0,K.jsx)(p,{className:`size-3.5`}),r(e.titleKey),(0,K.jsxs)(`span`,{className:`ml-auto text-[8px] uppercase opacity-75`,children:[r(`activity:taskRisk.cat.${e.category}`),` ·`,` `,r(`activity:taskRisk.sev.${e.severity}`)]})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 opacity-90`,children:r(e.detailKey,e.detailParams??{})}),(0,K.jsxs)(`p`,{className:`mt-1 text-[9px] leading-4 opacity-75`,children:[(0,K.jsx)(`strong`,{children:r(`activity:taskRisk.next`)}),` `,r(e.remediationKey)]})]},e.id)),(0,K.jsx)(Ce,{page:a.page,pageSize:a.pageSize,totalItems:a.totalItems,onPageChange:a.setPage,compact:!0,itemLabel:r(`activity:taskRisk.itemLabel`)})]})]})]})}function jt(e,t,n){let r=t.assignment,i=Ot(e,t,[]).findings.filter(e=>e.category===`operational`),a=J(r?.provider),o=J(r?.model);return{owner:J(r?.name)??J(r?.agentId)??J(r?.role)??J(t.assignee)??J(t.assignedAgent)??`Unassigned`,route:a||o?`${a?`${a}/`:``}${o??`default`}`:r?.modelRouting===`session`?`session default`:`default route`,blockers:(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return!n||![`completed`,`archived`].includes(n.status)}).length,attempts:r?.attempt?`${r.attempt}${r.maxAttempts?`/${r.maxAttempts}`:``}`:`0`,fallbackCount:+!!r?.fallbackProfile+(r?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||r?.status===`failed`||!!r?.error,criticalRisks:i.filter(e=>e.severity===`critical`).length,warningRisks:i.filter(e=>e.severity===`warning`).length,verification:gt(t,n?.[`${e.id}:${t.id}`]),subtaskCounts:(()=>{let n=t.childTaskIds??[];if(!n.length)return null;let r=n.map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return r.length?{done:r.filter(e=>[`completed`,`review`,`archived`].includes(e.status)).length,total:r.length}:null})(),atomicityVerdict:t.atomicityAssessment?.verdict??null,evidenceCount:t.verificationReport?.attachments.length??0,pendingDecomposition:t.decomposition?.status===`proposed`}}function Mt({board:e,column:t,selectedTaskId:n,dragTaskId:r,setDragTaskId:i,onSelectTask:a,onDeleteTask:o,onMoveTask:s}){let{t:c}=m(),l=be(e=>e.verificationActivity),u=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,K.jsxs)(`section`,{className:L(`flex h-full shrink-0 flex-col rounded-md border bg-muted/25 transition-[width] duration-200`,u.length===0?`w-[180px]`:`w-[310px]`),children:[(0,K.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b px-3`,children:[(0,K.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{background:t.color??`hsl(var(--primary))`}}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,children:t.title}),(0,K.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:u.length})]}),(0,K.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 [scrollbar-gutter:stable]`,onDragOver:e=>e.preventDefault(),onDrop:n=>{n.preventDefault(),e.lifecycle?.mode!==`managed`&&r&&s(r,t.id),i(null)},children:u.map(t=>{let r=jt(e,t,l);return(0,K.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&i(t.id)},onDragEnd:()=>i(null),className:L(`relative rounded-md border bg-background p-3 shadow-sm transition-colors`,n===t.id?`border-primary`:`hover:border-primary/50`),children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Select task: ${t.title}`,onClick:()=>a(t.id),className:`absolute inset-0 cursor-pointer rounded-md`}),(0,K.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(t.atomic||r.atomicityVerdict)&&(0,K.jsx)(`span`,{className:L(`shrink-0 rounded px-1 py-0.5 text-[10px] font-medium`,r.atomicityVerdict===`needs_decomposition`?`bg-destructive/15 text-destructive`:r.atomicityVerdict===`composite`?`bg-info/15 text-info`:r.atomicityVerdict===`borderline`||t.atomic?`bg-warning/15 text-warning`:`bg-muted text-muted-foreground`),title:r.atomicityVerdict?`Atomicity: ${r.atomicityVerdict}`:`Atomic task (subtree verification required)`,children:t.atomic?`atomic`:r.atomicityVerdict===`needs_decomposition`?`split me`:r.atomicityVerdict}),(0,K.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-5`,children:t.title})]}),t.description&&(0,K.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground`,children:t.description})]}),(0,K.jsx)(`button`,{type:`button`,title:c(`activity:kanban.deleteTask`),"aria-label":c(`activity:kanban.deleteTaskAria`,{title:t.title}),onClick:()=>o(t),className:`pointer-events-auto relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,K.jsx)(ie,{size:14})})]}),(0,K.jsxs)(`div`,{className:`pointer-events-none relative mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,K.jsx)(`span`,{className:wt(t.priority),children:t.priority}),(0,K.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:t.status}),r.owner!==`Unassigned`&&(0,K.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:r.owner}),t.assignment&&(0,K.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:r.route}),t.assignment?.attempt?(0,K.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[`attempt `,r.attempts]}):null,r.fallbackCount>0&&(0,K.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.fallbackCount,` fallback`]}),r.blockers>0?(0,K.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.blockers,` blocker`]}):null,r.activeUsers>0&&(0,K.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[r.activeUsers,` active`]}),r.failed&&(0,K.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:c(`activity:kanban.runFailed`)}),r.criticalRisks>0&&(0,K.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[r.criticalRisks,` critical risk`]}),r.warningRisks>0&&(0,K.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.warningRisks,` warning`]}),t.chain&&(0,K.jsxs)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:[`chain `,t.chain.order+1]}),t.assignment?.skills?.length?(0,K.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[t.assignment.skills.length,` skills`]}):null,r.verification!==`unverified`&&(0,K.jsxs)(`span`,{className:L(`rounded px-1.5 py-0.5`,r.verification===`passed`?`bg-success/10 text-success`:r.verification===`failed`?`bg-destructive/10 text-destructive`:`bg-warning/10 text-warning`),children:[`✓ `,r.verification]}),r.subtaskCounts&&(0,K.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.subtaskCounts.done,`/`,r.subtaskCounts.total,` subtasks`]}),r.evidenceCount>0&&(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[r.evidenceCount,` evidence`]}),r.pendingDecomposition&&(0,K.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:c(`activity:kanban.splitPendingApproval`)})]})]},t.id)})})]})}function Nt({queueHealth:e,runningCostTotal:t}){let{t:n}=m();return(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:n(`activity:kanban.queueHealth`)}),e.counts.ready>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.claimableTasks`),className:`inline-flex items-center gap-1 text-success`,children:[e.counts.ready,` `,n(`activity:kanban.statusReady`)]}),e.counts.running>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.runningAssignments`),className:`inline-flex items-center gap-1 text-warning`,children:[e.counts.running,` `,n(`activity:kanban.statusRunning`)]}),e.counts.review>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.inReview`),className:`inline-flex items-center gap-1 text-primary`,children:[e.counts.review,` `,n(`activity:kanban.statusReview`)]}),e.counts.blocked>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.manuallyBlocked`),className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.blocked,` `,n(`activity:kanban.statusBlocked`)]}),e.counts.failed>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.failedTasks`),className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.failed,` `,n(`activity:kanban.statusFailed`)]}),e.dependencyBlocked.count>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.blockedByDeps`),className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[e.dependencyBlocked.count,` `,n(`activity:kanban.statusBlockedByDeps`)]}),e.staleAssignments.count>0&&(0,K.jsxs)(`span`,{title:n(`activity:kanban.expiredLeases`),className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[e.staleAssignments.count,` `,n(`activity:kanban.statusStale`)]}),e.heartbeatDue.count===0&&e.staleAssignments.count===0&&e.dependencyBlocked.count===0&&(0,K.jsx)(`span`,{className:`text-success`,children:n(`activity:kanban.healthy`)}),t>0&&(0,K.jsx)(`span`,{title:n(`activity:kanban.costCeilingSum`),className:`inline-flex items-center gap-1 text-info`,children:n(`activity:kanban.runningCost`,{cost:t.toFixed(2)})})]})}function Pt({runLink:e,sendRaw:t}){let{t:n}=m(),i=e.engine===`sdd`,a=i?`sdd.board`:`goal`,o=R(e=>e.setCurrentView),s=(n,r={})=>t(n,e.runId?{runId:e.runId,...r}:r),c=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium hover:bg-muted`;return(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-primary/5 px-4 py-1.5`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-primary`,children:[(0,K.jsx)(te,{size:11}),` `,e.engine]}),(0,K.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`activity:kanban.liveRunSteer`)}),i&&(0,K.jsxs)(`button`,{type:`button`,className:c,title:n(`activity:kanban.openLiveRun`),onClick:()=>o(`sddhub`),children:[(0,K.jsx)(te,{size:12}),` `,n(`activity:kanban.openLiveRun`)]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:c,onClick:()=>s(`${a}.pause`),children:[(0,K.jsx)(ae,{size:12}),` `,n(`activity:kanban.actionPause`)]}),(0,K.jsxs)(`button`,{type:`button`,className:c,onClick:()=>s(`${a}.resume`),children:[(0,K.jsx)(P,{size:12}),` `,n(`activity:kanban.actionResume`)]}),i&&(0,K.jsxs)(`button`,{type:`button`,className:c,onClick:()=>s(`sdd.board.retry_all_failed`),children:[(0,K.jsx)(ce,{size:12}),` `,n(`activity:kanban.actionRetryFailed`)]}),(0,K.jsxs)(`button`,{type:`button`,className:L(c,`text-destructive hover:bg-destructive/10`),onClick:()=>s(`${a}.stop`),children:[(0,K.jsx)(r,{size:12}),` `,n(`activity:kanban.actionStop`)]})]})]})}function Ft({boardId:e,sendKanban:t}){let{t:n}=m(),r=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium text-primary hover:bg-primary/10`;return(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-1.5`,children:[(0,K.jsx)(te,{size:13,className:`text-primary`}),(0,K.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`activity:kanban.runAsLiveJob`)}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,className:r,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`goal`}),children:n(`activity:kanban.startAsGoal`)}),(0,K.jsx)(`button`,{type:`button`,className:r,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`sdd`}),children:n(`activity:kanban.startAsSdd`)})]})]})}function It({runLink:e,runTaskId:n,modelCandidates:i,sendRaw:a}){let{t:o}=m(),s=e.engine===`sdd`,[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=(t,n={})=>a(t,e.runId?{runId:e.runId,...n}:n),p=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,h=()=>{let e=u.trim();e&&(f(s?`sdd.board.reassign`:`goal.assignTask`,{taskId:n,agentName:e}),l(!1),d(``))};return(0,K.jsxs)(`div`,{className:`mt-4 rounded-md border bg-primary/5 p-2.5`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-primary`,children:o(`activity:kanban.runControls`)}),s&&(0,K.jsxs)(`div`,{className:`mb-2`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:o(`activity:kanban.workerModel`)}),(0,K.jsx)(Se,{candidates:i,placeholder:o(`activity:kanban.setModelForTask`),onPick:(e,t)=>f(`sdd.board.set_task_model`,{taskId:n,model:e,provider:t})})]}),c?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&l(!1)},placeholder:o(`activity:kanban.newWorkerName`),className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-xs outline-none focus:border-primary`}),(0,K.jsx)(`button`,{type:`button`,onClick:h,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,K.jsx)(t,{size:14})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`rounded-md bg-muted px-2 py-1.5`,children:(0,K.jsx)(A,{size:14})})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:p,onClick:()=>f(s?`sdd.board.retry`:`goal.retryTask`,{taskId:n}),children:[(0,K.jsx)(ce,{size:13}),` `,o(`common:action.retry`)]}),(0,K.jsxs)(`button`,{type:`button`,className:p,onClick:()=>l(!0),children:[(0,K.jsx)(v,{size:13}),` `,o(`activity:kanban.actionReassign`)]}),s?(0,K.jsxs)(`button`,{type:`button`,className:L(p,`text-destructive hover:bg-destructive/10`),onClick:()=>f(`sdd.board.cancel_task`,{taskId:n}),children:[(0,K.jsx)(r,{size:13}),` `,o(`common:action.cancel`)]}):(0,K.jsxs)(`button`,{type:`button`,className:p,onClick:()=>f(`goal.runTask`,{taskId:n}),children:[(0,K.jsx)(P,{size:13}),` `,o(`activity:kanban.actionRunNow`)]})]})]})}var Lt={unverified:{labelKey:`activity:kanbanTree.verifyUnverified`,className:`bg-muted text-muted-foreground`,icon:T},running:{labelKey:`activity:kanbanTree.verifyVerifying`,className:`bg-info/10 text-info`,icon:N},passed:{labelKey:`activity:kanbanTree.verifyVerified`,className:`bg-success/10 text-success`,icon:E},failed:{labelKey:`activity:kanbanTree.verifyFailed`,className:`bg-destructive/10 text-destructive`,icon:de},needs_human:{labelKey:`activity:kanbanTree.verifyNeedsReview`,className:`bg-warning/10 text-warning`,icon:p},incomplete:{labelKey:`activity:kanbanTree.verifyIncomplete`,className:`bg-warning/10 text-warning`,icon:p}};function Rt({task:e}){return e.status===`completed`?(0,K.jsx)(t,{size:13,className:`text-success`}):e.status===`failed`?(0,K.jsx)(A,{size:13,className:`text-destructive`}):e.status===`in_progress`?(0,K.jsx)(N,{size:13,className:`animate-spin text-info`}):(0,K.jsx)(b,{size:13,className:`text-muted-foreground`})}function zt({board:e,selectedTaskId:t,onSelectTask:n}){let{t:r}=m(),i=be(e=>e.verificationActivity),a=(0,B.useMemo)(()=>bt(yt(e)),[e]);return a.length?(0,K.jsx)(`div`,{className:`h-full overflow-y-auto p-4`,children:(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:a.map(({task:a,depth:o,children:s})=>{let c=gt(a,i[`${e.id}:${a.id}`]),l=Lt[c],u=l.icon,d=a.atomicityAssessment?.verdict;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(a.id),style:{paddingLeft:`${o*22+8}px`},className:L(`flex w-full items-center gap-2 rounded-md border py-1.5 pr-2 text-left text-xs transition-colors`,t===a.id?`border-primary bg-primary/5`:`border-transparent hover:border-primary/40 hover:bg-muted/40`),children:[s.length>0?(0,K.jsx)(C,{size:12,className:`shrink-0 text-muted-foreground`}):(0,K.jsx)(`span`,{className:`w-3 shrink-0`}),(0,K.jsx)(Rt,{task:a}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:a.title}),a.atomic&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-warning/15 px-1 py-0.5 text-[10px] text-warning`,children:`atomic`}),d&&d!==`atomic`&&(0,K.jsx)(`span`,{className:L(`shrink-0 rounded px-1 py-0.5 text-[10px]`,d===`needs_decomposition`?`bg-destructive/15 text-destructive`:d===`composite`?`bg-info/15 text-info`:`bg-warning/15 text-warning`),children:d===`needs_decomposition`?`split me`:d}),a.decomposition?.status===`proposed`&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-warning/10 px-1 py-0.5 text-[10px] text-warning`,children:r(`activity:kanbanTree.proposalPending`)}),(0,K.jsxs)(`span`,{className:L(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px]`,l.className),children:[(0,K.jsx)(u,{size:11,className:c===`running`?`animate-spin`:void 0}),r(l.labelKey)]})]})},a.id)})})}):(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`activity:kanbanTree.noTasksOnThisBoardYet`)})}function Bt({label:e,value:t,tone:n}){return(0,K.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,K.jsx)(`div`,{className:L(`text-xl font-bold`,n===`success`&&`text-success`,n===`destructive`&&`text-destructive`,n===`warning`&&`text-warning`,n===`muted`&&`text-muted-foreground`),children:t}),(0,K.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e})]})}function Vt({title:e,icon:t,tone:n,rows:r,onSelectTask:i}){return r.length?(0,K.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,K.jsxs)(`div`,{className:L(`flex items-center gap-2 border-b px-3 py-2 text-xs font-semibold`,n),children:[(0,K.jsx)(t,{size:14}),e,(0,K.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r.length})]}),(0,K.jsx)(`ul`,{className:`divide-y`,children:r.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(e.taskId),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-xs hover:bg-muted/40`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.primary}),e.secondary&&(0,K.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.secondary})]})},e.id))})]}):null}function Ht({board:e,onSelectTask:t}){let{t:n}=m(),r=(0,B.useMemo)(()=>vt(e),[e]);return(0,K.jsxs)(`div`,{className:`h-full space-y-4 overflow-y-auto p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 rounded-md border bg-background p-4`,children:[(0,K.jsx)(Ee,{pct:r.gradedTasks?r.passed/r.gradedTasks*100:0}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-semibold`,children:n(`activity:kanban.definitionOfDone`)}),(0,K.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[r.passed,` of `,r.gradedTasks,` graded tasks verified passed ·`,` `,r.totalTasks,` tasks total`]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[(0,K.jsx)(Bt,{label:`verified`,value:r.passed,tone:`success`}),(0,K.jsx)(Bt,{label:`failed`,value:r.failed,tone:`destructive`}),(0,K.jsx)(Bt,{label:n(`activity:verifyReport.verdictNeedsHuman`),value:r.needsHuman,tone:`warning`}),(0,K.jsx)(Bt,{label:`incomplete`,value:r.incomplete,tone:`warning`}),(0,K.jsx)(Bt,{label:`unverified`,value:r.unverified,tone:`muted`})]}),(0,K.jsx)(Vt,{title:n(`activity:kanban.failingChecks`),icon:de,tone:`text-destructive`,onSelectTask:t,rows:r.failingChecks.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:`${t.description}${t.error?` — ${t.error}`:``}`}))}),(0,K.jsx)(Vt,{title:n(`activity:kanban.evidenceMissing`),icon:p,tone:`text-warning`,onSelectTask:t,rows:r.missingEvidence.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:t.description}))}),(0,K.jsx)(Vt,{title:n(`activity:kanban.needsDecomposition`),icon:k,tone:`text-warning`,onSelectTask:t,rows:r.needsDecomposition.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`atomicity score ${e.atomicityAssessment?.score??`?`} — split before dispatch`}))}),(0,K.jsx)(Vt,{title:n(`activity:kanban.decompositionPending`),icon:T,tone:`text-info`,onSelectTask:t,rows:r.pendingProposals.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`${e.decomposition?.proposedSubtasks.length??0} proposed subtasks`}))}),r.failingChecks.length===0&&r.missingEvidence.length===0&&r.needsDecomposition.length===0&&r.pendingProposals.length===0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-success/30 bg-success/5 p-3 text-xs text-success`,children:[(0,K.jsx)(E,{size:14}),n(`activity:kanban.noOutstanding`)]})]})}var Ut={assigned:`bg-info/10 text-info`,queued:`bg-info/10 text-info`,running:`bg-warning/10 text-warning`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,cancelled:`bg-muted text-muted-foreground`};function Wt(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=t?Date.parse(t):Date.now();if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function Gt({assignment:e}){let{t}=m(),n=e.status===`running`,r=Wt(e.dispatchedAt,e.completedAt),i=J(e.name)??J(e.agentId),a=J(e.role),o=J(e.provider),s=J(e.model),c=[];return i&&c.push({label:t(`activity:kanbanRun.agent`),value:i}),a&&c.push({label:t(`activity:kanbanRun.role`),value:a}),e.modelRouting&&c.push({label:t(`activity:kanbanRun.modelSource`),value:e.modelRouting}),(o||s)&&c.push({label:t(`activity:kanbanRun.model`),value:(0,K.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[o?`${o}/`:``,s??`—`]})}),e.subagentId&&c.push({label:t(`activity:kanban.subagent`),value:(0,K.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.subagentId})}),r&&c.push({label:e.completedAt?t(`activity:kanban.duration`):t(`activity:kanban.elapsed`),value:r}),typeof e.attempt==`number`&&c.push({label:t(`activity:kanbanRun.attempt`),value:`${e.attempt}${e.maxAttempts?` / ${e.maxAttempts}`:``}`}),e.costCeilingUsd&&c.push({label:t(`activity:kanbanRun.costCeiling`),value:`$${e.costCeilingUsd.toFixed(2)}`}),e.fallbackProfile&&c.push({label:t(`activity:kanbanRun.fallbackProfile`),value:e.fallbackProfile}),e.fallbackModels?.length&&c.push({label:t(`activity:kanbanRun.fallbacks`),value:e.fallbackModels.join(` → `)}),e.skills?.length&&c.push({label:t(`activity:kanbanRun.skills`),value:e.skills.join(`, `)}),e.tools?.length&&c.push({label:t(`activity:kanbanRun.tools`),value:e.tools.join(`, `)}),e.leaseExpiresAt&&c.push({label:t(`activity:kanbanRun.leaseExpires`),value:new Date(e.leaseExpiresAt).toLocaleString()}),(0,K.jsxs)(`div`,{className:`mt-4 rounded-md border bg-background p-2.5`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:kanban.liveRun`)}),(0,K.jsxs)(`span`,{className:L(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Ut[e.status]??`bg-muted text-muted-foreground`),children:[n&&(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current`,"aria-hidden":!0}),e.status]})]}),c.length>0&&(0,K.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:c.map(e=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,K.jsx)(`dd`,{className:`min-w-0 truncate text-right text-foreground`,children:e.value})]},e.label))}),e.lastResult&&(0,K.jsxs)(`div`,{className:`mt-2`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:t(`activity:kanban.lastResult`)}),(0,K.jsx)(`div`,{className:`max-h-24 overflow-y-auto whitespace-pre-wrap rounded bg-muted px-2 py-1 text-[11px] leading-relaxed text-foreground`,children:e.lastResult})]}),e.error&&(0,K.jsx)(`div`,{className:`mt-2 rounded border border-destructive/30 bg-destructive/10 px-2 py-1 text-[11px] text-destructive`,children:e.error})]})}function Kt({activityKind:e,activityOutcome:t,note:n,details:r,onActivityKindChange:a,onActivityOutcomeChange:o,onNoteChange:s,onDetailsChange:c,onRecordActivity:l}){let{t:u}=m();return(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:u(`activity:kanbanRecorder.recordDecisionOutcome`)}),(0,K.jsxs)(`div`,{className:`mb-1.5 grid grid-cols-2 gap-1.5`,children:[(0,K.jsx)(`select`,{value:e,onChange:e=>a(e.target.value),"aria-label":u(`activity:kanbanRecorder.taskActivityKind`),className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`decision`,`attempt`,`result`,`blocker`,`observation`].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),(0,K.jsx)(`select`,{value:t,onChange:e=>o(e.target.value),"aria-label":u(`activity:kanbanRecorder.taskActivityOutcome`),className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`unknown`,`succeeded`,`failed`,`partial`,`skipped`].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(`input`,{value:n,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&l(),placeholder:u(`activity:kanbanRecorder.whatWasDecidedAttemptedOrProduced`),className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,K.jsx)(`button`,{type:`button`,onClick:l,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":u(`activity:kanbanRecorder.recordTaskDecisionOrOutcome`),children:(0,K.jsx)(i,{size:14})})]}),(0,K.jsx)(`input`,{value:r,onChange:e=>c(e.target.value),placeholder:u(`activity:kanbanRecorder.optionalEvidenceRationaleCommandLinkOrFailureDetail`),"aria-label":u(`activity:kanbanRecorder.taskActivityDetails`),className:`mt-1.5 h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`})]})}function qt({board:e,task:n,newCheck:r,onNewCheckChange:a,onAddCheck:o,sendKanban:s}){let{t:c}=m();return(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:c(`activity:kanbanTaskCompletionChecks.completionChecks`)}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(n.successCriteria??[]).map(r=>(0,K.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_92px] items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs`,children:[(0,K.jsx)(t,{size:13,className:r.status===`passed`?`text-success`:`text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:r.description}),(0,K.jsx)(`select`,{value:r.status,onChange:t=>s(`kanban.task.check.update`,{boardId:e?.id,taskId:n.id,checkId:r.id,status:t.target.value}),className:`h-7 rounded border bg-background px-1 text-[11px]`,children:[`pending`,`passed`,`failed`,`skipped`].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]},r.id)),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(`input`,{value:r,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&o(),placeholder:c(`activity:kanbanTaskCompletionChecks.addAVerifiableCompletionCheck`),className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,K.jsx)(`button`,{type:`button`,onClick:o,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,K.jsx)(i,{size:14})})]})]})]})}var Jt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Yt=[{value:`fs.read`,label:`Read files`,description:`fs.read`},{value:`fs.write`,label:`Write files (in project)`,description:`fs.write`},{value:`fs.write.outside-project`,label:`Write outside project`,description:`fs.write.outside-project`},{value:`net.outbound`,label:`Outbound network`,description:`net.outbound`},{value:`shell.exec`,label:`Run project commands`,description:`shell.exec`},{value:`shell.restricted`,label:`Restricted shell`,description:`shell.restricted`},{value:`shell.arbitrary`,label:`Arbitrary shell`,description:`shell.arbitrary`},{value:`session.todo`,label:`Session todos`,description:`session.todo`},{value:`tool.meta`,label:`Tool metadata`,description:`tool.meta`},{value:`tool.mutate.any`,label:`Invoke any tool`,description:`tool.mutate.any`},{value:`memory.read`,label:`Read memory`,description:`memory.read`},{value:`memory.write`,label:`Write memory`,description:`memory.write`},{value:`package.install`,label:`Install packages`,description:`package.install`},{value:`subagent.spawn`,label:`Spawn subagents`,description:`subagent.spawn`},{value:`config.mutate`,label:`Mutate config / trust`,description:`config.mutate`}];function Xt(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function Zt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Qt(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?X(Zt(e.after).outcome)===`failed`?`failures`:e.type===`task.activity.attempt`?`execution`:`notes`:e.type.includes(`failed`)||e.type.includes(`cancelled`)?`failures`:e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type.startsWith(`task.assignment.`)||e.type===`task.stale_recovered`?`execution`:e.type.includes(`note`)||e.type.includes(`check`)||e.type.includes(`metric`)?`notes`:`changes`}function $t(e){let t=Zt(e.before),n=Zt(e.after);return[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>JSON.stringify(t[e])!==JSON.stringify(n[e])).map(e=>({field:e,before:t[e],after:n[e]}))}function en(e){if(e.type.startsWith(`task.file.`))return`File ${e.type.slice(10)}`.replace(/\b\w/g,e=>e.toUpperCase());if(e.type.startsWith(`task.activity.`))return`Recorded ${e.type.slice(14)}`.replace(/\b\w/g,e=>e.toUpperCase());switch(e.type){case`task.created`:return`Task created`;case`task.copied`:return`Task copied`;case`task.updated`:return`Task contract updated`;case`task.moved`:return`Task moved`;case`task.assigned`:return`Agent assigned`;case`task.claimed`:return`Task claimed`;case`task.released`:return`Assignment released`;case`task.assignment.updated`:return`Assignment updated`;case`task.assignment.running`:return`Agent started work`;case`task.assignment.completed`:return`Agent completed work`;case`task.assignment.failed`:return`Agent run failed`;case`task.assignment.cancelled`:return`Agent run cancelled`;case`task.assignment.heartbeat`:return`Agent heartbeat`;case`task.note.added`:return`Operator note added`;case`task.check.added`:return`Acceptance check added`;case`task.check.updated`:return`Acceptance check updated`;case`task.metric.added`:return`Goal metric added`;case`task.metric.updated`:return`Goal metric updated`;case`task.lifecycle.transition`:return`Lifecycle advanced`;case`task.assignment.snapshot`:return`Current assignment observed`;case`task.stale_recovered`:return`Stale assignment recovered`;case`task.reconciled`:return`Task state reconciled`;default:return e.type.replace(/^task\./,``).replaceAll(`.`,` `).replace(/\b\w/g,e=>e.toUpperCase())}}function tn(e){let t=Zt(e.before),n=Zt(e.after);if(e.type.startsWith(`task.file.`)){let e=X(n.filePath),t=X(n.toolName),r=typeof n.durationMs==`number`?n.durationMs:void 0,i=typeof n.lines==`number`?n.lines:void 0;return[e,t?`tool:${t}`:void 0,r===void 0?void 0:`${r}ms`,i===void 0?void 0:`${i} lines`].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.activity.`))return[X(n.outcome),X(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=X(t.columnId),r=X(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=$t(e);if(t.length)return`${t.length} field${t.length===1?``:`s`} changed: ${t.map(e=>e.field).join(`, `)}`}if(e.type===`task.lifecycle.transition`){let e=X(t.stage),r=X(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=X(n.name)??X(n.agentId)??X(n.role),t=X(n.provider),r=X(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[X(n.description),X(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[X(n.name),X(n.status)].filter(Boolean).join(` · `)||void 0}function nn(e){let t=e.type;return X(Zt(e.after).outcome)===`failed`||t.includes(`failed`)||t.includes(`cancelled`)?`bg-destructive ring-destructive/20`:t.includes(`completed`)||t.includes(`reconciled`)?`bg-success ring-success/20`:t.includes(`running`)||t.includes(`claimed`)||t.includes(`assigned`)?`bg-info ring-info/20`:t.includes(`note`)?`bg-warning ring-warning/20`:`bg-primary ring-primary/20`}function rn(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(t):e}function an(e){if(e===void 0)return`unset`;if(e===null)return`none`;if(typeof e==`string`)return e||`empty`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function on(e,t,n){let r=t.filter(t=>t.taskId===e.id).map(e=>({...e}));(e=>r.some(t=>t.type===e))(`task.created`)||r.push({id:`created:${e.id}`,boardId:``,taskId:e.id,type:`task.created`,ts:e.createdAt,...n?{sessionId:n}:{},after:{title:e.title,status:`created`,columnId:e.columnId}});for(let[t,i]of(e.lifecycle?.history??[]).entries())r.some(e=>e.type===`task.lifecycle.transition`&&e.ts===i.at&&e.actor===i.actor)||r.push({id:`lifecycle:${e.id}:${t}`,boardId:``,taskId:e.id,type:`task.lifecycle.transition`,ts:i.at,actor:i.actor,...n?{sessionId:n}:{},before:i.from?{stage:i.from}:void 0,after:{stage:i.to,action:i.action,attachment:i.attachment},note:i.comment});for(let t of e.notes??[])r.some(e=>e.type===`task.note.added`&&e.note===t.content&&Math.abs(Date.parse(e.ts)-Date.parse(t.createdAt))<2e3)||r.push({id:`note:${t.id}`,boardId:``,taskId:e.id,type:`task.note.added`,ts:t.createdAt,actor:t.author,...n?{sessionId:n}:{},note:t.content});let i=r.some(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`));return e.assignment&&!i&&r.push({id:`assignment:${e.id}`,boardId:``,taskId:e.id,type:`task.assignment.snapshot`,ts:e.assignment.completedAt??e.assignment.dispatchedAt??e.assignment.claimedAt??e.updatedAt,actor:e.assignment.agentId??e.assignment.name??e.assignment.role,...n?{sessionId:n}:{},subagentId:e.assignment.subagentId,runTaskId:e.assignment.runTaskId,after:{...e.assignment},note:e.assignment.error??e.assignment.lastResult}),r.sort((e,t)=>t.ts.localeCompare(e.ts))}function sn({event:e}){let t=Zt(e.after),n=X(t.provider),r=X(t.model),i=X(t.modelRouting),a=X(t.fallbackProfile),o=Array.isArray(t.fallbackModels)?t.fallbackModels.filter(e=>typeof e==`string`):[],s=typeof t.attempt==`number`?t.attempt:void 0,c=typeof t.maxAttempts==`number`?t.maxAttempts:void 0,l=X(t.status);return!n&&!r&&!i&&!a&&!o.length&&s===void 0&&!l?null:(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[l&&(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`status:`,l]}),i&&(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`route:`,i]}),(n||r)&&(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`model:`,n?`${n}/`:``,r??`default`]}),a&&(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`profile:`,a]}),o.map((e,t)=>(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`fallback-`,t+1,`:`,e]},`${e}:${t}`)),s!==void 0&&(0,K.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`attempt:`,s,c?`/${c}`:``]})]})}function cn({task:e,events:n,sessionId:r,loading:i=!1,error:a,onRefresh:o}){let{t:s}=m(),[c,l]=(0,B.useState)(`all`),[u,d]=(0,B.useState)(``),[p,h]=(0,B.useState)(!1),g=(0,B.useMemo)(()=>on(e,n,r),[e,n,r]),v=(0,B.useMemo)(()=>({all:g.length,execution:g.filter(e=>Qt(e)===`execution`).length,changes:g.filter(e=>Qt(e)===`changes`).length,notes:g.filter(e=>Qt(e)===`notes`).length,failures:g.filter(e=>Qt(e)===`failures`).length}),[g]),y=(0,B.useMemo)(()=>{let e=u.trim().toLowerCase();return g.filter(t=>c!==`all`&&Qt(t)!==c?!1:!e||[en(t),t.type,t.actor,t.sessionId,t.subagentId,t.runTaskId,t.note,JSON.stringify(t.before),JSON.stringify(t.after)].filter(Boolean).join(` `).toLowerCase().includes(e))},[g,c,u]),b=Te(y,50,`${c}:${u}`),x=b.pageItems,S=[...new Set(g.map(e=>e.actor).filter(Boolean))].length,C=[...new Set(g.map(e=>e.sessionId??r).filter(Boolean))].length;return(0,K.jsxs)(`section`,{"aria-label":s(`activity:taskTimeline.taskActivity`),className:`mt-5`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,K.jsx)(f,{className:`size-3.5 text-primary`}),(0,K.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:s(`activity:taskTimeline.activityLedger`)}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:[y.length,`/`,g.length]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(Xt(e,y,`filtered`),null,2)),h(!0)}catch{h(!1)}},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":s(`activity:taskTimeline.copyVisibleTaskActivityJson`),title:s(`activity:taskTimeline.copyFilteredActivityJson`),children:p?(0,K.jsx)(t,{className:`size-3 text-success`}):(0,K.jsx)(_,{className:`size-3`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(Xt(e,g,`full`),null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${e.title.replace(/[^a-z0-9]+/gi,`-`).replace(/^-|-$/g,``).toLowerCase()||e.id}-activity.json`,r.click(),URL.revokeObjectURL(n)},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":s(`activity:taskTimeline.downloadFullTaskActivityJson`),title:s(`activity:taskTimeline.downloadFullActivityJson`),children:(0,K.jsx)(M,{className:`size-3`})}),o&&(0,K.jsx)(`button`,{type:`button`,onClick:o,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":s(`activity:taskTimeline.refreshTaskActivity`),children:(0,K.jsx)(me,{className:L(`size-3`,i&&`animate-spin`)})})]})]}),(0,K.jsx)(`div`,{className:`mb-2 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60 text-center`,children:[[`Events`,g.length],[`Actors`,S],[`Sessions`,C],[`Failures`,v.failures]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`bg-background/90 px-1 py-1.5`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold tabular-nums`,children:t}),(0,K.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),(0,K.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:[`all`,`execution`,`changes`,`notes`,`failures`].map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:L(`rounded border px-1.5 py-1 text-[9px] capitalize`,c===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,v[e]]},e))}),(0,K.jsxs)(`div`,{className:`relative mb-3`,children:[(0,K.jsx)(D,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),"aria-label":s(`activity:taskTimeline.searchTaskActivity`),placeholder:s(`activity:taskTimeline.searchAgentSessionModelResultField`),className:`h-8 w-full rounded-md border bg-background pl-7 pr-7 text-[11px] outline-none focus:border-primary`}),u&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(``),"aria-label":s(`activity:taskTimeline.clearTaskActivitySearch`),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(A,{className:`size-3`})})]}),a&&(0,K.jsx)(`div`,{className:`mb-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-[11px] text-destructive`,children:a}),y.length===0?(0,K.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-6 text-center text-[11px] text-muted-foreground`,children:s(`activity:taskTimeline.noActivityMatchesThisFilter`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{className:`relative ml-1.5 space-y-0 border-l border-border/70`,children:x.map(e=>{let t=tn(e),n=e.sessionId??r,i=$t(e),a=Qt(e)===`failures`,o=e.type.includes(`completed`)||X(Zt(e.after).outcome)===`succeeded`;return(0,K.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,K.jsx)(`span`,{className:L(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,nn(e))}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium leading-5`,children:en(e)}),(0,K.jsx)(`code`,{className:`block truncate text-[8px] text-muted-foreground/70`,title:e.type,children:e.type})]}),(0,K.jsx)(`time`,{dateTime:e.ts,title:new Date(e.ts).toLocaleString(),className:`shrink-0 text-[9px] text-muted-foreground`,children:rn(e.ts)})]}),t&&(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-[11px] leading-4 text-muted-foreground`,children:t}),e.note&&(0,K.jsxs)(`div`,{className:L(`mt-1.5 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border px-2 py-1.5 text-[10px] leading-4`,a?`border-destructive/30 bg-destructive/5 text-destructive`:o?`border-success/30 bg-success/5 text-success`:`border-border/70 bg-muted/35 text-foreground`),children:[(0,K.jsxs)(`strong`,{children:[a?`Error`:o?`Result`:`Reason / result`,`:`]}),` `,e.note]}),i.length>0&&e.type!==`task.assigned`&&e.type!==`task.assignment.snapshot`&&!e.type.startsWith(`task.file.`)&&(0,K.jsx)(`div`,{className:`mt-1.5 space-y-1 rounded border border-border/60 bg-background/50 p-1.5`,children:i.map(e=>(0,K.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-1.5 text-[9px] leading-4`,children:[(0,K.jsx)(`code`,{className:`truncate text-primary`,title:e.field,children:e.field}),(0,K.jsxs)(`span`,{className:`min-w-0 break-all text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`line-through opacity-70`,children:an(e.before)}),` `,(0,K.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,K.jsx)(`span`,{className:`text-foreground`,children:an(e.after)})]})]},e.field))}),(0,K.jsx)(sn,{event:e}),(e.actor||n||e.subagentId||e.runTaskId||e.correlationId)&&(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[e.actor&&(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`agent:`,e.actor]}),n&&(0,K.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:n,children:[`session:`,n]}),e.subagentId&&(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`subagent:`,e.subagentId]}),e.runTaskId&&(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`run:`,e.runTaskId]}),e.correlationId&&(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`trace:`,e.correlationId]})]}),(0,K.jsxs)(`details`,{className:`mt-1.5 text-[9px] text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:s(`activity:taskTimeline.fullEventPayload`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto rounded border bg-muted/30 p-2 text-[9px] leading-4 text-foreground`,children:JSON.stringify(e,null,2)})]})]},e.id)})}),(0,K.jsx)(Ce,{page:b.page,pageSize:b.pageSize,totalItems:b.totalItems,onPageChange:b.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function ln(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function un(e){return e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type===`task.assignment.snapshot`||e.type===`task.stale_recovered`||e.type.startsWith(`task.assignment.`)}function dn(e,t){return Z(t.status)||(e.type===`task.claimed`?`claimed`:e.type===`task.released`?`released`:e.type===`task.stale_recovered`?`recovered`:e.type.split(`.`).at(-1)??`unknown`)}function fn(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function pn(e,t){if(!t)return;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):void 0}function mn(e,t,n){let r=on(e,t,n).filter(un).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=ln(e.after),r=Number(t.attempt),c=e.type===`task.assigned`||e.type===`task.claimed`;Number.isFinite(r)&&r>0?a=Math.trunc(r):c&&(a===0||s)?a=o+1:a===0&&(a=1),o=Math.max(o,a);let l=dn(e,t),u=i.get(a)??{attempt:a,status:l,startedAt:e.ts,fallbackModels:[],sessionIds:new Set,eventCount:0};u.status=l,u.eventCount+=1,(e.sessionId??n)&&u.sessionIds.add(e.sessionId??n),u.owner=Z(t.name)??Z(t.agentId)??Z(t.role)??e.actor??u.owner,u.provider=Z(t.provider)??u.provider,u.model=Z(t.model)??u.model,u.routingMode=Z(t.modelRouting)??u.routingMode,u.fallbackProfile=Z(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??Z(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??Z(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=Z(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=Z(t.error)??e.note??u.error),fn(l)&&(u.endedAt=e.ts),i.set(a,u),s=fn(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:pn(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function hn(e){if(e===void 0)return`running`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function gn(e){return e===`completed`?`bg-success/10 text-success`:e===`failed`||e===`cancelled`?`bg-destructive/10 text-destructive`:e===`running`?`bg-info/10 text-info`:`bg-muted text-muted-foreground`}function _n({task:e,events:t,sessionId:n}){let{t:r}=m(),i=mn(e,t,n),o=Te(i,8,e.id);return i.length?(0,K.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/15`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(a,{className:`size-4 text-primary`}),(0,K.jsx)(`span`,{className:`text-xs font-semibold`,children:r(`activity:taskExecutionAttempts.executionAttempts`)}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:[i.length,` total`]}),(0,K.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${gn(i[0].status)}`,children:[`latest:`,i[0].status]}),(0,K.jsx)(h,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[o.pageItems.map(e=>(0,K.jsxs)(`section`,{className:`rounded-md border bg-background/70 p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,K.jsxs)(`strong`,{className:`text-xs`,children:[`Attempt #`,e.attempt]}),(0,K.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${gn(e.status)}`,children:e.status}),(0,K.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-muted-foreground`,children:[(0,K.jsx)(u,{className:`size-3`}),` `,hn(e.durationMs),` · `,e.eventCount,` `,`events`]})]}),(0,K.jsxs)(`div`,{className:`mt-2 grid gap-1 text-[10px] text-muted-foreground sm:grid-cols-2`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(oe,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,K.jsx)(j,{className:`size-3`}),e.provider||e.model?`${e.provider?`${e.provider}/`:``}${e.model??`default`}`:e.routingMode??`default route`]}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[`session:`,e.sessionIds.join(`, `)||`unknown`]}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[`subagent:`,e.subagentId??`—`,` · run:`,e.runTaskId??`—`]})]}),(e.fallbackProfile||e.fallbackModels.length>0)&&(0,K.jsxs)(`p`,{className:`mt-1.5 break-all font-mono text-[9px] text-muted-foreground`,children:[`fallback:`,[e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...e.fallbackModels].filter(Boolean).join(` → `)]}),e.error&&(0,K.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[10px] text-destructive`,children:[(0,K.jsx)(`strong`,{children:r(`activity:taskExecutionAttempts.error`)}),` `,e.error]}),e.result&&(0,K.jsxs)(`p`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border border-success/30 bg-success/5 px-2 py-1.5 text-[10px] text-success`,children:[(0,K.jsx)(`strong`,{children:r(`activity:taskExecutionAttempts.result`)}),` `,e.result]})]},e.attempt)),(0,K.jsx)(Ce,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function vn(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Q(e){return J(e)}function yn(e,t){return(t??[]).map(t=>{let n=e.tasks.find(e=>e.id===t);return{id:t,title:n?.title??t,status:n?.status??`missing`}})}function bn(e,t,n,r,i,a,o){let s=on(t,n,r),c=yn(e,t.dependsOn),l=c.filter(e=>![`completed`,`archived`].includes(e.status)),u=t.assignment,d=(o??e.presence??[]).filter(e=>e.taskId===t.id),f=vn(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Q(u?.modelRouting)??Q(f.modelRouting)??`session`,m=Q(u?.provider)??Q(f.provider)??(p===`session`?Q(i):void 0),h=Q(u?.model)??Q(f.model)??(p===`session`?Q(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Q).filter(e=>e!==void 0),_=Q(u?.fallbackProfile)??Q(f.fallbackProfile),v=Q(u?.name)??Q(u?.agentId)??Q(u?.role)??Q(t.assignee)??Q(t.assignedAgent)??`Unassigned`,y=t.lifecycle?.history.at(-1),b=s.find(e=>e.note&&e.type!==`task.note.added`)?.note,x=`Placed in ${e.columns.find(e=>e.id===t.columnId)?.title??t.columnId}.`;u?.error?x=`Agent run failed: ${u.error}`:l.length?x=`Blocked by ${l.map(e=>e.title).join(`, `)}.`:y?.comment?x=y.comment:b?x=b:t.status===`review`?x=`Implementation is waiting for review evidence or approval.`:t.status===`in_progress`?x=`${v} is currently working on this task.`:t.status===`completed`&&(x=`The task and its current assignment are complete.`);let S=s.map(e=>Number(vn(e.after).attempt)).filter(e=>Number.isFinite(e)),C=s.filter(e=>e.type===`task.claimed`||e.type===`task.assigned`).length,w=s.find(e=>Qt(e)===`failures`),T=s.find(e=>e.type.includes(`completed`));return{column:e.columns.find(e=>e.id===t.columnId)?.title??t.columnId,reason:x,owner:v,routingMode:p,provider:m,model:h,primaryModel:m||h?`${m?`${m}/`:``}${h??`default`}`:`Session default`,fallbackRoute:[_?`profile:${_}`:``,...g].filter(Boolean).join(` → `)||`None configured`,blockers:l,dependencies:c,actors:[...new Set([...s.map(e=>e.actor).filter(e=>!!e),...d.map(e=>e.agentId)])],sessions:[...new Set([...s.map(e=>e.sessionId??r),...d.map(e=>e.sessionId)].filter(e=>!!e))],presence:d.map(e=>`${e.agentName??e.agentId} · ${e.active?`active`:`last seen ${xn(e.lastSeenAt)}`}`),activePresence:d.filter(e=>e.active).length,attempts:Math.max(u?.attempt??0,...S,C),failures:s.filter(e=>e.type.includes(`failed`)).length,completions:s.filter(e=>e.type.includes(`completed`)).length,lastFailure:u?.lastFailureKind??u?.error??w?.note,lastResult:u?.lastResult??T?.note,eventCount:s.length,lastActivity:s[0]}}function xn(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Sn(e,t){if(!e)return`—`;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return`—`;let i=Math.max(0,Math.round((r-n)/6e4));return i<1?`<1m`:i<60?`${i}m`:`${Math.floor(i/60)}h ${i%60}m`}function $({label:e,value:t,mono:n=!1}){return(0,K.jsxs)(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-2 py-1 text-[11px]`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:n?`break-all font-mono text-[10px]`:`min-w-0 break-words`,children:t})]})}function Cn({icon:e,title:t,children:n}){return(0,K.jsxs)(`section`,{className:`rounded-md border border-border/70 bg-background/55 p-2.5`,children:[(0,K.jsxs)(`h4`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,t]}),(0,K.jsx)(`dl`,{className:`divide-y divide-border/35`,children:n})]})}function wn({items:e}){let{t}=m();return e.length?(0,K.jsx)(`span`,{className:`space-y-1`,children:e.map(e=>(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate`,title:e.title,children:e.title}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 py-0.5 text-[9px]`,children:e.status})]},e.id))}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:t(`activity:taskIntel.none`)})}function Tn({board:e,task:t,events:n,presence:r,sessionId:i,sessionProvider:a,sessionModel:o}){let{t:s}=m(),c=bn(e,t,n,i,a,o,r),l=t.assignment,u=t.successCriteria?.length??0,p=t.successCriteria?.filter(e=>e.status===`passed`).length??0,g=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),_=yn(e,[...new Set(g)]);return(0,K.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-primary/25 bg-primary/[0.025]`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(le,{className:`size-4 text-primary`}),(0,K.jsx)(`span`,{className:`text-xs font-semibold`,children:s(`activity:taskIntel.heading`)}),(0,K.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground`,children:t.status}),(0,K.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:s(`activity:taskIntel.eventsCount`,{count:c.eventCount})}),(0,K.jsx)(h,{className:`size-3.5 text-muted-foreground`})]}),(0,K.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/60 p-2.5`,children:[(0,K.jsxs)(`section`,{className:`rounded-md border border-info/25 bg-info/5 p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,K.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-semibold text-info`,children:c.column}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[s(`activity:taskIntel.stagePrefix`),t.lifecycle?.currentStage??s(`activity:taskIntel.legacyStage`)]}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[s(`activity:taskIntel.priorityPrefix`),t.priority]}),(0,K.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[s(`activity:taskIntel.typePrefix`),t.type??s(`activity:taskIntel.inferredType`)]})]}),(0,K.jsxs)(`p`,{className:`mt-2 text-[11px] leading-4`,children:[(0,K.jsx)(`strong`,{children:s(`activity:taskIntel.whyHere`)}),` `,c.reason]}),c.blockers.length>0&&(0,K.jsx)(`p`,{className:`mt-1 text-[10px] text-warning`,children:s(`activity:taskIntel.unresolvedBlockers`,{count:c.blockers.length})})]}),(0,K.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,K.jsxs)(Cn,{icon:(0,K.jsx)(oe,{className:`size-3`}),title:s(`activity:taskIntel.ownershipRuntime`),children:[(0,K.jsx)($,{label:s(`activity:taskIntel.owner`),value:c.owner}),(0,K.jsx)($,{label:s(`activity:taskIntel.assignee`),value:Q(t.assignee)??Q(t.assignedAgent)??`—`}),(0,K.jsx)($,{label:s(`activity:taskIntel.agentId`),value:Q(l?.agentId)??`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.agentNameRole`),value:[Q(l?.name),Q(l?.role)].filter(Boolean).join(` · `)||`—`}),(0,K.jsx)($,{label:s(`activity:taskIntel.runStatus`),value:Q(l?.status)??`unassigned`}),(0,K.jsx)($,{label:s(`activity:taskIntel.subagent`),value:Q(l?.subagentId)??`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.runTask`),value:Q(l?.runTaskId)??`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.sessionS`),value:c.sessions.join(`, `)||`Unknown`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.usersPresence`),value:c.presence.length?c.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,K.jsxs)(Cn,{icon:(0,K.jsx)(j,{className:`size-3`}),title:s(`activity:taskIntel.modelRouteFallback`),children:[(0,K.jsx)($,{label:s(`activity:taskIntel.routingMode`),value:c.routingMode}),(0,K.jsx)($,{label:s(`activity:taskIntel.primary`),value:c.primaryModel,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.provider`),value:c.provider??`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.model`),value:c.model??`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.fallbackRoute`),value:c.fallbackRoute,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.skills`),value:l?.skills?.map(Q).filter(Boolean).join(`, `)||`Default`}),(0,K.jsx)($,{label:s(`activity:taskIntel.tools`),value:l?.tools?.map(Q).filter(Boolean).join(`, `)||`Default toolset`}),(0,K.jsx)($,{label:s(`activity:taskIntel.capabilities`),value:l?.allowedCapabilities?.map(Q).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,K.jsxs)(Cn,{icon:(0,K.jsx)(E,{className:`size-3`}),title:s(`activity:taskIntel.executionPolicyOutcome`),children:[(0,K.jsx)($,{label:s(`activity:taskIntel.attempts`),value:`${c.attempts}${l?.maxAttempts?` / ${l.maxAttempts}`:``}`}),(0,K.jsx)($,{label:s(`activity:taskIntel.retryPolicy`),value:l?.retryPolicy??t.retryPolicy??`off`}),(0,K.jsx)($,{label:s(`activity:taskIntel.costCeiling`),value:(l?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(l?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,K.jsx)($,{label:s(`activity:taskIntel.failuresDone`),value:`${c.failures} / ${c.completions}`}),(0,K.jsx)($,{label:s(`activity:taskIntel.checks`),value:`${p} / ${u} passed`}),(0,K.jsx)($,{label:s(`activity:taskIntel.lastFailure`),value:c.lastFailure??`—`}),(0,K.jsx)($,{label:s(`activity:taskIntel.result`),value:c.lastResult??`No result recorded`})]}),(0,K.jsxs)(Cn,{icon:(0,K.jsx)(f,{className:`size-3`}),title:s(`activity:taskIntel.timingAuditCoverage`),children:[(0,K.jsx)($,{label:s(`activity:taskIntel.created`),value:xn(t.createdAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.updated`),value:xn(t.updatedAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.due`),value:xn(t.dueDate)}),(0,K.jsx)($,{label:s(`activity:taskIntel.dispatched`),value:xn(l?.dispatchedAt??l?.claimedAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.completed`),value:xn(l?.completedAt??t.completedAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.duration`),value:Sn(l?.dispatchedAt??l?.claimedAt,l?.completedAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.heartbeat`),value:xn(l?.heartbeatAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.leaseExpires`),value:xn(l?.leaseExpiresAt)}),(0,K.jsx)($,{label:s(`activity:taskIntel.actors`),value:c.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,K.jsxs)(Cn,{icon:(0,K.jsx)(d,{className:`size-3`}),title:s(`activity:taskIntel.dependenciesChainProvenance`),children:[(0,K.jsx)($,{label:s(`activity:taskIntel.dependencies`),value:(0,K.jsx)(wn,{items:c.dependencies})}),(0,K.jsx)($,{label:s(`activity:taskIntel.otherRelations`),value:(0,K.jsx)(wn,{items:_})}),(0,K.jsx)($,{label:s(`activity:taskIntel.chain`),value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.originSystem`),value:t.origin?.system??`manual`}),(0,K.jsx)($,{label:s(`activity:taskIntel.originIds`),value:t.origin&&[t.origin.graphId,t.origin.phaseId,t.origin.taskId,t.origin.specId].filter(Boolean).join(` · `)||`—`,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.taskId`),value:t.id,mono:!0}),(0,K.jsx)($,{label:s(`activity:taskIntel.boardId`),value:e.id,mono:!0})]})]})]})}var En={passed:{icon:x,labelKey:`activity:verifyReport.verdictPassed`,className:`text-success`},failed:{icon:s,labelKey:`activity:verifyReport.verdictFailed`,className:`text-destructive`},needs_human:{icon:p,labelKey:`activity:verifyReport.verdictNeedsHuman`,className:`text-warning`},incomplete:{icon:g,labelKey:`activity:verifyReport.verdictIncomplete`,className:`text-muted-foreground`}},Dn={passed:{labelKey:`activity:verifyReport.checkPassed`,className:`text-success`},failed:{labelKey:`activity:verifyReport.checkFailed`,className:`text-destructive`},skipped:{labelKey:`activity:verifyReport.checkSkipped`,className:`text-muted-foreground`},error:{labelKey:`activity:verifyReport.checkError`,className:`text-warning`}};function On(e,t){let n=Date.parse(t)-Date.parse(e);return Number.isNaN(n)||n<0?``:n<1e3?`${n}ms`:n<6e4?`${Math.round(n/1e3)}s`:`${Math.floor(n/6e4)}m ${Math.round(n%6e4/1e3)}s`}function kn({verdict:e}){let{t}=m(),n=En[e],r=n.icon;return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${n.className}`,children:[(0,K.jsx)(r,{size:13}),t(n.labelKey)]})}function An({title:e,icon:t,defaultOpen:n=!1,children:r}){let[i,a]=(0,B.useState)(n);return(0,K.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-xs font-semibold uppercase text-muted-foreground hover:bg-muted/50`,children:[i?(0,K.jsx)(h,{size:13}):(0,K.jsx)(C,{size:13}),(0,K.jsx)(t,{size:13}),e]}),i&&(0,K.jsx)(`div`,{className:`border-t px-3 py-2 space-y-2`,children:r})]})}function jn({check:e}){let t=Dn[e.status],{t:n}=m(),[r,i]=(0,B.useState)(!1),a=e.error||e.backingRefs?.length;return(0,K.jsxs)(`div`,{className:`rounded border bg-muted/30 px-2.5 py-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-medium ${t.className}`,children:n(t.labelKey)}),(0,K.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:e.type})]}),(0,K.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]}),a&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(!r),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:r?(0,K.jsx)(h,{size:13}):(0,K.jsx)(C,{size:13})})]}),r&&(0,K.jsxs)(`div`,{className:`mt-2 space-y-1.5 border-t pt-2`,children:[e.error&&(0,K.jsx)(`div`,{className:`rounded bg-destructive/10 px-2 py-1 text-destructive`,children:e.error}),e.backingRefs?.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(ue,{size:11}),(0,K.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.path}),(0,K.jsxs)(`span`,{className:`text-[10px]`,children:[`(`,e.kind,`)`]}),e.summary&&(0,K.jsxs)(`span`,{className:`truncate`,children:[`— `,e.summary]})]},t))]})]})}function Mn({fileScope:e}){let{t}=m();return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:verifyReport.expected`),` `,(0,K.jsx)(`strong`,{children:e.expectedChanges}),` changes`]}),(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:verifyReport.actual`),` `,(0,K.jsx)(`strong`,{children:e.actualChanges}),` changes`]}),(0,K.jsx)(`span`,{className:e.scopeMatches?`text-success`:`text-destructive`,children:e.scopeMatches?`✅ Scope matches`:`❌ Scope mismatch`})]}),(0,K.jsx)(`div`,{className:`space-y-1`,children:e.files.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-mono text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:e.operation===`create`?`text-success`:e.operation===`delete`?`text-destructive`:`text-muted-foreground`,children:e.operation===`create`?`+`:e.operation===`delete`?`−`:`∼`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path}),(0,K.jsxs)(`span`,{className:`text-[10px]`,children:[e.linesChanged,` line`,e.linesChanged===1?``:`s`]}),!e.expected&&(0,K.jsx)(`span`,{className:`rounded bg-warning/10 px-1 text-[10px] text-warning`,children:`unexpected`})]},t))})]})}function Nn({subtasks:e}){let{t}=m();return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[t(`activity:verifyReport.total`),` `,(0,K.jsx)(`strong`,{children:e.total})]}),(0,K.jsxs)(`span`,{className:`text-success`,children:[t(`activity:verifyReport.completed`),` `,(0,K.jsx)(`strong`,{children:e.completed})]}),e.failed>0&&(0,K.jsxs)(`span`,{className:`text-destructive`,children:[t(`activity:verifyReport.failed`),` `,(0,K.jsx)(`strong`,{children:e.failed})]})]}),(0,K.jsx)(`div`,{className:`space-y-1`,children:e.children.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.verdict===`passed`?(0,K.jsx)(`span`,{className:`text-success`,children:`✓`}):e.verdict===`failed`?(0,K.jsx)(`span`,{className:`text-destructive`,children:`✗`}):e.verdict===`needs_human`?(0,K.jsx)(`span`,{className:`text-warning`,children:`⚠`}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},t))})]})}function Pn({attachments:e}){return(0,K.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded border bg-muted/30 px-2 py-1.5 text-xs`,children:[(0,K.jsx)(w,{size:12,className:`mt-0.5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,K.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground`,children:e.path?(0,K.jsxs)(`span`,{className:`truncate block`,children:[e.path,(0,K.jsx)(`span`,{className:`ml-1 rounded bg-muted px-1 text-[10px]`,children:e.kind})]}):(0,K.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px]`,children:e.kind})}),e.content&&(0,K.jsxs)(`pre`,{className:`mt-1 max-h-20 overflow-auto rounded bg-background p-1 text-[10px] text-muted-foreground`,children:[e.content.slice(0,500),e.content.length>500?`
3
- …`:``]})]})]},t))})}function Fn({report:e}){let{t}=m();return(0,K.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:t(`activity:verifyReport.verificationReport`)}),(0,K.jsx)(kn,{verdict:e.verdict})]}),e.markdownSummary&&(0,K.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:On(e.startedAt,e.completedAt)})]}),e.markdownSummary&&(0,K.jsx)(`div`,{className:`rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground whitespace-pre-wrap`,children:e.markdownSummary}),e.checks.length>0&&(0,K.jsx)(An,{title:t(`activity:verifyReport.checkResults`),icon:O,defaultOpen:e.verdict!==`passed`,children:e.checks.map(e=>(0,K.jsx)(jn,{check:e},e.checkId))}),e.fileScope&&(0,K.jsx)(An,{title:t(`activity:verifyReport.fileScope`),icon:ue,defaultOpen:!e.fileScope.scopeMatches,children:(0,K.jsx)(Mn,{fileScope:e.fileScope})}),e.subtasks&&(0,K.jsx)(An,{title:t(`activity:verifyReport.subTasks`),icon:O,children:(0,K.jsx)(Nn,{subtasks:e.subtasks})}),e.attachments.length>0&&(0,K.jsx)(An,{title:`Attachments (${e.attachments.length})`,icon:w,children:(0,K.jsx)(Pn,{attachments:e.attachments})})]})}function In({boardId:e,task:t,sendKanban:n}){let{t:r}=m();return gt(t,be(n=>n.verificationActivity[`${e}:${t.id}`]))===`running`?(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border border-info/30 bg-info/5 p-3 text-xs text-info`,children:[(0,K.jsx)(N,{size:14,className:`animate-spin`}),r(`activity:taskVerify.verificationRunningChecksAreBeingExecuted`)]}):t.verificationReport?(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(Fn,{report:t.verificationReport}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-1.5 rounded-md border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted`,children:r(`activity:taskVerify.reRunVerification`)})]}):(0,K.jsxs)(`div`,{className:`mt-4 rounded-md border border-dashed p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(T,{size:14}),(0,K.jsx)(`span`,{className:`font-medium`,children:r(`activity:taskVerify.unverified`)}),(0,K.jsx)(`span`,{children:r(`activity:taskVerify.noVerificationReportExistsForThis`)})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-2 rounded-md bg-primary/10 px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-primary/20`,children:r(`activity:taskVerify.runVerification`)})]})}function Ln({boards:e,board:t,task:r,runLink:i,onClose:a,onSelectTask:s,sendKanban:c,sendRaw:l,refreshBoard:u,activityEvents:d,activityPresence:f,activityLoading:p,activityError:g,activitySessionId:y,refreshActivity:b}){let{t:x}=m(),[S,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(``),[D,O]=(0,B.useState)(``),[k,j]=(0,B.useState)(``),[M,te]=(0,B.useState)(``),[N,re]=(0,B.useState)(`session`),[ie,ae]=(0,B.useState)(``),[oe,se]=(0,B.useState)([]),[ce,le]=(0,B.useState)([]),[ue,de]=(0,B.useState)([]),[pe,me]=(0,B.useState)([]),[P,F]=(0,B.useState)(``),he=xe(!!r),I=Ke(!!r),ge=J(I.sessionProvider),_e=J(I.sessionModel),ve=we(`kanban-task-inspector`,!!r),[ye,be]=(0,B.useState)(!1),[R,Ce]=(0,B.useState)(!1),[Te,z]=(0,B.useState)(``),[Ee,De]=(0,B.useState)(``),[Oe,V]=(0,B.useState)(``),[ke,H]=(0,B.useState)(`pending`),[Ae,je]=(0,B.useState)(``),[Me,Ne]=(0,B.useState)(``),[Pe,Fe]=(0,B.useState)(``),[Ie,Le]=(0,B.useState)(`medium`),[Re,ze]=(0,B.useState)(`chore`),[U,Be]=(0,B.useState)(``),[W,Ve]=(0,B.useState)([]),[He,Ue]=(0,B.useState)([]),[G,We]=(0,B.useState)(!1),[Ge,qe]=(0,B.useState)(``),[Je,Ye]=(0,B.useState)(``),[Xe,Ze]=(0,B.useState)(`off`),[Qe,$e]=(0,B.useState)(``),[et,tt]=(0,B.useState)(``),[nt,rt]=(0,B.useState)(``),[it,ot]=(0,B.useState)(``),[st,ct]=(0,B.useState)(``),[lt,ut]=(0,B.useState)(`observation`),[dt,ft]=(0,B.useState)(`unknown`),[pt,ht]=(0,B.useState)(``);(0,B.useEffect)(()=>{let n=J(r?.assignment?.provider),i=J(r?.assignment?.model);C(J(r?.assignment?.agentId)??J(r?.assignedAgent)??``),T(J(r?.assignment?.name)??``),O(J(r?.assignment?.role)??``),j(n??``),te(i??``),re(r?.assignment?.modelRouting??(n||i?`fixed`:`session`)),ae(J(r?.assignment?.fallbackProfile)??``),se(r?.assignment?.fallbackModels??[]),le(r?.assignment?.skills??[]),de(r?.assignment?.tools??[]),me(r?.assignment?.allowedCapabilities??[]),F(e.find(e=>e.id!==t?.id)?.id??``),z(r?.title??``),De(r?.description??``),V(r?.dueDate??``),H(r?.status??`pending`),je(``),Ne(``),Fe(``),Le(r?.priority??`medium`),ze(r?.type??`chore`),Be(r?.labels?.join(`, `)??``),Ve(r?.dependsOn??[]),Ue(r?.chain&&t?t.tasks.filter(e=>e.chain?.chainId===r.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):r?[r.id]:[]),We(!1),qe(r?.estimatedHours?.toString()??``),Ye(r?.actualHours?.toString()??``),Ze(r?.retryPolicy??r?.assignment?.retryPolicy??`off`),$e((r?.costCeilingUsd??r?.assignment?.costCeilingUsd)?.toString()??``),tt(r?.assignment?.maxAttempts?.toString()??``),rt(``),ot(``),ct(``),ut(`observation`),ft(`unknown`),ht(``)},[t?.id,r?.id]);let gt=e=>({boardId:t?.id,taskId:r?.id,...S.trim()?{agentId:S.trim()}:{},...w.trim()?{name:w.trim()}:{},...D.trim()?{role:D.trim()}:{},modelRouting:N,...N===`fixed`&&k.trim()?{provider:k.trim()}:{},...N===`fixed`&&M.trim()?{model:M.trim()}:{},...N===`fallback_profile`&&ie.trim()?{fallbackProfile:ie.trim()}:{},fallbackModels:oe,skills:ce,tools:ue,allowedCapabilities:pe,...et?{maxAttempts:Number(et)}:{},...Qe?{costCeilingUsd:Number(Qe)}:{},retryPolicy:Xe,activityNote:pt.trim()||`${x(`activity:kanban.activityNoteTemplate`,{action:x(e===`dispatch`?`activity:kanban.dispatched`:`activity:kanban.assigned`),target:w.trim()||S.trim()||D.trim()||x(`activity:kanban.configuredAgentRoute`)})}`}),_t=()=>{!t||!r||!Te.trim()||(c(`kanban.task.update`,{boardId:t.id,taskId:r.id,title:Te.trim(),description:Ee,dueDate:Oe||null,...t.lifecycle?.mode===`managed`?{}:{status:ke},priority:Ie,type:Re,labels:U.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:W,...r.chain&&He.length<=1?{chain:null}:{},estimatedHours:Ge?Number(Ge):0,actualHours:Je?Number(Je):0,retryPolicy:Xe,costCeilingUsd:Qe?Number(Qe):null,activityNote:pt.trim()||`Task contract edited in WebUI.`}),He.length>1&&c(`kanban.task.chain`,{boardId:t.id,taskIds:He,enforceDependencies:G}),window.setTimeout(()=>u(t.id),180),ht(``))},vt=[`backlog`,`todo`,`running`,`review`,`done`],yt=r?.lifecycle?.currentStage,bt=yt?vt.indexOf(yt):-1,wt=bt>=0&&bt<vt.length-1?vt[bt+1]:void 0;return r?(0,K.jsxs)(`aside`,{"aria-label":x(`activity:kanban.taskInspector`),"data-expanded":R?`true`:`false`,className:L(`flex max-h-[42dvh] w-full shrink-0 flex-col border-t bg-card/40 transition-[width] duration-200 ease-out md:max-h-none md:border-l md:border-t-0`,R?`fixed inset-0 z-50 h-dvh max-h-none w-screen border-0 bg-card transition-none md:w-screen md:border-0`:`md:w-[420px] xl:w-[480px]`),children:[(0,K.jsxs)(`div`,{className:L(`flex h-12 items-center gap-2 border-b px-3`,R&&`px-5`),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:x(`activity:kanban.task`)}),(0,K.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:r.id.slice(0,8)})]}),(0,K.jsx)(`button`,{type:`button`,title:x(R?`activity:kanban.collapseDetails`:`activity:kanban.expandDetails`),"aria-label":x(R?`activity:kanban.collapseDetails`:`activity:kanban.expandDetails`),"aria-pressed":R,onClick:()=>Ce(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:R?(0,K.jsx)(o,{size:16}):(0,K.jsx)(ee,{size:16})}),(0,K.jsx)(`button`,{type:`button`,title:x(`common:action.close`),onClick:()=>{Ce(!1),a()},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(A,{size:16})})]}),r?(0,K.jsxs)(`div`,{ref:ve,className:L(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,R&&`px-5 py-4 xl:px-7`),children:[(0,K.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-background p-2.5`,children:[(0,K.jsx)(at,{title:x(`activity:kanban.taskBoundary`),value:r.boundary,inherited:t?.boundary,onSave:e=>{t&&(c(`kanban.task.update`,{boardId:t.id,taskId:r.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>u(t.id),150))}}),(0,K.jsx)(Y,{label:x(`activity:kanban.title`),value:Te,onChange:z}),(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanbanInspector.descriptionWorkingContext`)}),(0,K.jsx)(`textarea`,{value:Ee,onChange:e=>De(e.target.value),rows:5,className:`w-full resize-y rounded-md border bg-background px-2 py-1.5 text-xs leading-5 outline-none focus:border-primary`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[t?.lifecycle?.mode===`managed`?(0,K.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-2 py-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:x(`activity:kanban.managedStage`)}),(0,K.jsx)(`div`,{className:`mt-1 text-xs font-semibold capitalize`,children:r.lifecycle?.currentStage??`Backlog`})]}):(0,K.jsx)(Ct,{label:x(`activity:kanban.status`),value:ke,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>H(e)}),(0,K.jsx)(Ct,{label:x(`activity:kanban.priority`),value:Ie,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Le(e)}),(0,K.jsx)(Ct,{label:x(`activity:kanban.type`),value:Re,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>ze(e)}),(0,K.jsx)(Y,{label:x(`activity:kanban.labelsCommaSeparated`),value:U,onChange:Be})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(Y,{label:x(`activity:kanban.dueDatePlaceholder`),value:Oe,onChange:V}),(0,K.jsx)(Y,{label:x(`activity:kanban.estimatedHours`),value:Ge,onChange:qe}),(0,K.jsx)(Y,{label:x(`activity:kanban.actualHours`),value:Je,onChange:Ye})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanbanInspector.dependencies`)}),(0,K.jsx)(q,{options:(t?.tasks??[]).filter(e=>e.id!==r.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:W,onChange:Ve,placeholder:x(`activity:kanban.selectBlockingTasks`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanbanInspector.taskChainSelectionOrder`)}),(0,K.jsx)(q,{options:(t?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:He,onChange:e=>Ue(e.includes(r.id)?e:[r.id,...e]),placeholder:x(`activity:kanban.selectSequentialChain`)}),(0,K.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:G,onChange:e=>We(e.target.checked)}),x(`activity:kanban.enforceChainOrder`)]})]}),(0,K.jsx)(Y,{label:x(`activity:kanban.assignmentReason`),value:pt,onChange:ht}),(0,K.jsxs)(`button`,{type:`button`,onClick:_t,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,K.jsx)(fe,{size:15}),` `,x(`activity:kanbanInspector.saveTaskContract`)]}),t?.lifecycle?.mode===`managed`&&wt&&(0,K.jsxs)(`section`,{"aria-label":x(`activity:kanban.managedLifecycle`),className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-primary`,children:x(`activity:kanban.kanbanAgentTransition`)}),(0,K.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[yt,` → `,wt,`; no stages can be skipped.`]})]}),(0,K.jsx)(E,{size:16,className:`text-primary`})]}),(0,K.jsx)(Y,{label:x(`activity:kanban.completedAction`),value:Me,onChange:Ne}),(0,K.jsx)(Y,{label:x(`activity:kanban.progressComment`),value:Ae,onChange:je}),(0,K.jsx)(Y,{label:x(`activity:kanban.evidenceUrl`),value:Pe,onChange:Fe}),(0,K.jsxs)(`button`,{type:`button`,disabled:!Ae.trim(),onClick:()=>{!t||!r||!wt||!Ae.trim()||(c(`kanban.task.transition`,{boardId:t.id,taskId:r.id,to:wt,actor:S.trim()||w.trim()||r.assignee||r.assignedAgent||`webui-agent`,comment:Ae.trim(),...Me.trim()?{action:Me.trim()}:{},...Pe.trim()?{attachment:{url:Pe.trim(),type:`url`,title:`Evidence for ${r.title}`}}:{}}),window.setTimeout(()=>u(t.id),180))},className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,K.jsx)(n,{size:15}),` Advance to `,wt]})]})]}),t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Tn,{board:t,task:r,events:d,presence:f,sessionId:y,sessionProvider:ge,sessionModel:_e}),(0,K.jsx)(_n,{task:r,events:d,sessionId:y}),(0,K.jsx)(At,{board:t,task:r,events:d})]}),(0,K.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,K.jsx)(St,{label:x(`activity:kanban.source`),value:r.origin?.system??`manual`}),(0,K.jsx)(St,{label:x(`activity:kanban.taskId`),value:r.id.slice(0,8)}),(0,K.jsx)(St,{label:x(`activity:kanban.run`),value:r.assignment?.status??`unassigned`}),(0,K.jsx)(St,{label:x(`activity:kanban.column`),value:xt(t,r.columnId)})]}),r.assignment&&(0,K.jsx)(Gt,{assignment:r.assignment}),i&&r.origin?.taskId&&(0,K.jsx)(It,{runLink:i,runTaskId:r.origin.taskId,modelCandidates:he,sendRaw:l}),!i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,K.jsx)(Ct,{label:x(`activity:kanban.primaryModelSource`),value:N,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>re(e)}),N===`session`&&(0,K.jsxs)(`div`,{className:`rounded-md border bg-info/5 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Uses the live session model: `,ge?`${ge}/`:``,_e||`not available`,`.`]}),N===`fixed`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanbanInspector.fixedProviderModel`)}),(0,K.jsx)(Se,{value:M||void 0,provider:k||void 0,candidates:he,placeholder:x(`activity:kanban.selectProviderModel`),onPick:(e,t)=>{te(e),j(t)}})]}),N===`fallback_profile`&&(0,K.jsx)(Ct,{label:x(`activity:kanban.fallbackProfile`),value:ie,options:Object.keys(I.fallbackProfiles),placeholder:x(`activity:kanban.selectProfile`),onChange:ae}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanban.fallbackModels`)}),(0,K.jsx)(q,{options:he.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:oe,onChange:se,placeholder:x(`activity:kanban.addFallbackModel`),emptyLabel:`No models — add a provider in Settings`})]}),(0,K.jsx)(Ct,{label:x(`activity:kanban.role`),value:D,options:Jt,placeholder:x(`activity:kanban.selectRole`),onChange:O}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Agentic skills`,` `,(0,K.jsx)(`span`,{className:`text-muted-foreground/70`,children:x(`activity:kanbanInspector.forceLoadedIntoTheWorker`)})]}),(0,K.jsx)(q,{options:I.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:ce,onChange:le,placeholder:x(`activity:kanban.assignSkills`),emptyLabel:`No skills registered`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Tools`,` `,(0,K.jsx)(`span`,{className:`text-muted-foreground/70`,children:x(`activity:kanbanInspector.blankFullDefaultToolset`)})]}),(0,K.jsx)(q,{options:I.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:ue,onChange:de,placeholder:x(`activity:kanban.restrictTools`),emptyLabel:`Tool list unavailable on this server`})]}),(0,K.jsxs)(`div`,{className:`rounded-md border bg-background/60`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>be(e=>!e),className:`flex w-full items-center justify-between px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[x(`activity:kanbanInspector.advanced`),(0,K.jsx)(h,{size:13,className:L(`transition-transform`,ye&&`rotate-180`)})]}),ye&&(0,K.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,K.jsx)(Y,{label:x(`activity:kanban.agentNameOptional`),value:w,onChange:T}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(Ct,{label:x(`activity:kanban.retryPolicy`),value:Xe,options:[`off`,`incremental`,`exponential`],onChange:e=>Ze(e)}),(0,K.jsx)(Y,{label:x(`activity:kanban.maxAttempts`),value:et,onChange:tt}),(0,K.jsx)(Y,{label:x(`activity:kanban.costCeilingUsd`),value:Qe,onChange:$e})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Capabilities`,` `,(0,K.jsx)(`span`,{className:`text-muted-foreground/70`,children:x(`activity:kanbanInspector.blankSafeDefaults`)})]}),(0,K.jsx)(q,{options:Yt,selected:pe,onChange:me,placeholder:x(`activity:kanban.grantCapability`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||(c(`kanban.task.assign`,gt(`assign`)),ht(``),window.setTimeout(()=>u(t.id),150))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted`,children:[(0,K.jsx)(v,{size:15}),x(`activity:kanbanInspector.assign`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||(c(`kanban.task.dispatch`,gt(`dispatch`)),ht(``),window.setTimeout(()=>u(t.id),200))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,K.jsx)(ne,{size:15}),x(`activity:kanbanInspector.dispatch`)]})]})]}),e.length>1&&!i?(0,K.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-background p-2`,children:[(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:x(`activity:kanban.targetBoard`)}),(0,K.jsx)(`select`,{value:P,onChange:e=>F(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:e.filter(e=>e.id!==t?.id).map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||!P||c(`kanban.task.copy`,{boardId:t.id,taskId:r.id,targetBoardId:P})},disabled:!P,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,K.jsx)(_,{size:15}),x(`activity:kanbanInspector.copy`)]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||!P||c(`kanban.task.transfer`,{boardId:t.id,taskId:r.id,targetBoardId:P})},disabled:!P,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,K.jsx)(n,{size:15}),x(`activity:kanbanInspector.transfer`)]})]})]}):null,(0,K.jsx)(qt,{board:t,task:r,newCheck:nt,onNewCheckChange:rt,onAddCheck:()=>{!t||!r||!nt.trim()||(c(`kanban.task.check.add`,{boardId:t.id,taskId:r.id,description:nt.trim(),checkType:`manual`}),rt(``))},sendKanban:c}),t&&(0,K.jsx)(In,{boardId:t.id,task:r,sendKanban:c}),t&&(0,K.jsx)(mt,{board:t,task:r,sendKanban:c,onSelectTask:s}),(0,K.jsx)(cn,{task:r,events:d,sessionId:y,loading:p,error:g,onRefresh:b}),(0,K.jsx)(Kt,{activityKind:lt,activityOutcome:dt,note:it,details:st,onActivityKindChange:ut,onActivityOutcomeChange:ft,onNoteChange:ot,onDetailsChange:ct,onRecordActivity:()=>{!t||!r||!it.trim()||(c(`kanban.task.activity.add`,{boardId:t.id,taskId:r.id,kind:lt,outcome:dt,summary:it.trim(),...st.trim()?{details:st.trim()}:{},actor:w.trim()||S.trim()||`webui-operator`}),ot(``),ct(``),window.setTimeout(b,150))}})]}):null]}):null}var Rn=[[`board`,`Board`],[`tree`,`Tree`],[`dashboard`,`Verification`]];function zn({viewMode:e,onViewModeChange:t}){return(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-4 py-1.5`,children:Rn.map(([n,r])=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:L(`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors`,e===n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted`),children:r},n))})}function Bn(){let[e,t]=(0,B.useState)([]);return(0,B.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/api/sessions`);if(!n.ok)return;let r=await n.json();if(!Array.isArray(r)||e)return;let i=r.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();t(e=>e.length===i.length&&e.every((e,t)=>e===i[t])?e:i)}catch{}};n();let r=window.setInterval(n,8e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}var Vn=5e3,Hn=12;function Un({onClose:e}){let{t}=m(),n=_e(e=>e.wsUrl),r=ge(e=>e.session?.id??null),a=ve(e=>e.agents),{boards:o,boardTotal:s,activeBoardTotal:c,orphanedBoardTotal:l,activeBoardId:u,activeBoard:d,loading:f,error:p,queueHealth:h,supervisorSnapshot:g,setLoading:v,setActiveBoardId:b}=be(),[x,S]=(0,B.useState)(``),[C,w]=(0,B.useState)(1),T=Bn(),[ee,E]=(0,B.useState)(``),D=(0,B.useRef)(null);De(D);let[O,k]=(0,B.useState)(``),[j,M]=(0,B.useState)(null),[te,ne]=(0,B.useState)([]),[N,re]=(0,B.useState)(),[ae,oe]=(0,B.useState)(!1),[se,ce]=(0,B.useState)(null),[le,ue]=(0,B.useState)(0),[de,fe]=(0,B.useState)(null),[pe,me]=(0,B.useState)(`board`),P=(0,B.useRef)(null),F=(0,B.useMemo)(()=>I(n),[n]),he=d?.tasks.find(e=>e.id===j)??null,L=(0,B.useMemo)(()=>Qe(a.values()),[a]),R=(0,B.useRef)([]),xe=(0,B.useMemo)(()=>{let e=$e({sessionId:r,registrySessionIds:T,agents:a.values()}),t=R.current;return t.length===e.length&&t.every((t,n)=>t===e[n])?t:(R.current=e,e)},[a,T,r]),Se=o.filter(e=>ye(e,xe)),Ce=o.filter(e=>!ye(e,xe)),we=(0,B.useMemo)(()=>d?ke(d,{now:Date.now(),liveAgentIdentities:L,requireDueDate:d.lifecycle?.mode===`managed`}):null,[d,L]),Te=(0,B.useMemo)(()=>et(d),[d]),z=(e,t={})=>{v(!0),F.send({type:e,payload:t})},Ee=(e,t={})=>{F.send({type:e,payload:t})},Oe=(0,B.useMemo)(()=>tt(d),[d]),V=(e=C)=>z(`kanban.list`,{page:e,pageSize:Hn,activeSessionIds:xe}),H=(e=u)=>{e&&z(`kanban.get`,{boardId:e})};(0,B.useEffect)(()=>{V()},[]),(0,B.useEffect)(()=>{let e=r?o.find(e=>e.tags?.includes(`session:${r}`)):void 0,t=!!(r&&e)&&P.current!==r,n=t?e:u?void 0:o[0];n?.id&&(t&&(P.current=r),b(n.id),z(`kanban.get`,{boardId:n.id}))},[o,u,r,b]),(0,B.useEffect)(()=>{d&&j&&!d.tasks.some(e=>e.id===j)&&M(null)},[d,j]),(0,B.useEffect)(()=>{u&&(z(`kanban.health`,{boardId:u}),z(`kanban.supervisor.status`,{boardId:u}))},[u]),(0,B.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{F.send({type:`kanban.get`,payload:{boardId:u}}),F.send({type:`kanban.health`,payload:{boardId:u}})},5e3);return()=>clearInterval(e)},[u,F]),(0,B.useEffect)(()=>{let e=setInterval(()=>{F.send({type:`kanban.list`,payload:{page:C,pageSize:Hn,activeSessionIds:xe}})},8e3);return()=>clearInterval(e)},[xe,C,F]);let Ae=e=>{w(e),b(null),V(e)};(0,B.useEffect)(()=>{re(void 0)},[u,j]),(0,B.useEffect)(()=>{if(!u||!j)return;let e=u,t=j;oe(!0),ce(null);let n=F.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){ce(r.error??`Task activity could not be loaded.`),oe(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ne(r.data.events??[]),re(r.data.presence??[]),oe(!1))});return F.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:Vn}}),n},[u,j,he?.updatedAt,le,F]),(0,B.useEffect)(()=>{if(!(!u||!j))return F.on.bind(F)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===u&&t.taskId===j&&ue(e=>e+1)})},[u,j,F]);let je=()=>{let e=x.trim();e&&(S(``),z(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},Me=()=>{if(!d)return;let e=ee.trim();e&&(E(``),z(`kanban.task.add`,{boardId:d.id,title:e,columnId:d.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>H(d.id),150))},Ne=()=>{if(!d)return;let e=O.trim();e&&(k(``),z(`kanban.column.add`,{boardId:d.id,title:e}),window.setTimeout(()=>H(d.id),150))},Pe=()=>{d&&(z(`kanban.delete`,{boardId:d.id}),window.setTimeout(V,150))},Fe=()=>{d&&(z(`kanban.duplicate`,{boardId:d.id,title:`${d.title} Copy`}),window.setTimeout(V,150))},Ie=e=>{d&&(z(`kanban.task.remove`,{boardId:d.id,taskId:e.id}),window.setTimeout(()=>H(d.id),150))},Le=(e,t)=>{if(!d)return;let n=d.tasks.find(t=>t.id===e),r=d.columns.find(e=>e.id===n?.columnId)?.title,i=d.columns.find(e=>e.id===t)?.title??t;z(`kanban.task.move`,{boardId:d.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>H(d.id),150)};return(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground md:flex-row`,children:[(0,K.jsx)(nt,{boardTotal:s,activeBoardTotal:c,orphanedBoardTotal:l,activeBoardId:u,activeBoards:Se,orphanedBoards:Ce,boardPage:C,boardPageSize:Hn,loading:f,newBoardTitle:x,onClose:e,onRefresh:()=>V(),onNewBoardTitleChange:S,onCreateBoard:je,onBoardSelect:e=>{b(e),z(`kanban.get`,{boardId:e})},onBoardPageChange:Ae}),(0,K.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2 sm:px-4`,children:[(0,K.jsxs)(`div`,{className:`w-full min-w-0 sm:w-auto sm:flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:d?.title??`No board selected`}),(0,K.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:d?`${d.columns.length} columns / ${d.tasks.length} tasks`:`Create or select a board`})]}),d&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{value:ee,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Me()},placeholder:t(`activity:kanban.newTask`),className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-56`}),(0,K.jsx)(`button`,{type:`button`,title:t(`activity:kanban.addTask`),onClick:Me,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,K.jsx)(i,{size:16})}),(0,K.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ne()},placeholder:t(`activity:kanban.newColumn`),className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-44`}),(0,K.jsx)(`button`,{type:`button`,title:t(`activity:kanban.addColumn`),onClick:Ne,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex`,children:(0,K.jsx)(y,{size:16})}),(0,K.jsx)(`button`,{type:`button`,title:t(`activity:kanban.duplicateBoard`),onClick:Fe,className:`flex h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(_,{size:16})}),(0,K.jsx)(`button`,{type:`button`,title:t(`activity:kanban.deleteBoard`),onClick:Pe,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:flex`,children:(0,K.jsx)(ie,{size:16})})]})]}),d&&(0,K.jsx)(Ye,{presence:d.presence}),d&&(0,K.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,K.jsx)(at,{title:t(`activity:kanban.boardBoundary`),value:d.boundary,onSave:e=>{z(`kanban.update`,{boardId:d.id,boundary:e}),window.setTimeout(()=>H(d.id),150)}})}),d&&Oe&&(0,K.jsx)(Pt,{runLink:Oe,sendRaw:Ee}),d&&!Oe&&d.tasks.length>0&&(0,K.jsx)(Ft,{boardId:d.id,sendKanban:z}),d&&(0,K.jsx)(Xe,{board:d,snapshot:g,sendKanban:z}),we&&(0,K.jsx)(lt,{audit:we,onSelectTask:M}),d&&(0,K.jsx)(dt,{board:d,sendKanban:z,onSelectTask:M}),d&&(0,K.jsx)(zn,{viewMode:pe,onViewModeChange:me}),p&&(0,K.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 text-sm text-destructive`,children:[(0,K.jsx)(A,{size:15}),(0,K.jsx)(`span`,{className:`truncate`,children:p})]}),(0,K.jsx)(`div`,{ref:D,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:d?(0,K.jsxs)(K.Fragment,{children:[h&&(0,K.jsx)(Nt,{queueHealth:h,runningCostTotal:Te}),pe===`tree`?(0,K.jsx)(zt,{board:d,selectedTaskId:j,onSelectTask:M}):pe===`dashboard`?(0,K.jsx)(Ht,{board:d,onSelectTask:M}):(0,K.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...d.columns].sort((e,t)=>e.order-t.order).map(e=>(0,K.jsx)(Mt,{board:d,column:e,selectedTaskId:j,dragTaskId:de,setDragTaskId:fe,onSelectTask:M,onDeleteTask:Ie,onMoveTask:Le},e.id))})]}):(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:t(`activity:kanban.noBoardSelected`)})})]}),(0,K.jsx)(Ln,{boards:o,board:d,task:he,runLink:Oe,onClose:()=>M(null),onSelectTask:M,sendKanban:z,sendRaw:Ee,refreshBoard:H,activityEvents:te,activityPresence:N,activityLoading:ae,activityError:se,activitySessionId:d?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>ue(e=>e+1)},he?.id??`none`)]})}export{Un as KanbanView};