maestro-flow 0.3.6 → 0.3.8

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 (106) hide show
  1. package/.claude/commands/learn-retro.md +303 -0
  2. package/.claude/commands/maestro-execute.md +3 -2
  3. package/.claude/commands/maestro-learn.md +74 -298
  4. package/.claude/commands/manage-learn.md +21 -15
  5. package/.claude/commands/manage-memory-capture.md +13 -15
  6. package/.claude/commands/manage-memory.md +1 -1
  7. package/.claude/commands/quality-retrospective.md +5 -5
  8. package/.claude/commands/spec-load.md +7 -2
  9. package/.claude/commands/wiki-digest.md +27 -2
  10. package/README.md +103 -220
  11. package/README.zh-CN.md +159 -181
  12. package/dashboard/dist/assets/{ArtifactsPage-A9yzYtpj.js → ArtifactsPage-BmPOu8sO.js} +1 -1
  13. package/dashboard/dist/assets/{ChatInput-PuCvZZ3y.js → ChatInput-CL8YDfOU.js} +1 -1
  14. package/dashboard/dist/assets/ChatPage-CT-ozBK2.js +8 -0
  15. package/dashboard/dist/assets/{CollabPage-I5k_mCbG.js → CollabPage-C0rWMden.js} +1 -1
  16. package/dashboard/dist/assets/{KanbanPage-PDDBv5-9.js → KanbanPage-C6WbAlwI.js} +1 -1
  17. package/dashboard/dist/assets/{MarkdownRenderer-CCXHaut3.js → MarkdownRenderer-BjZ43aSa.js} +1 -1
  18. package/dashboard/dist/assets/{McpPage-CiqXpCHg.js → McpPage-BPIXADQi.js} +1 -1
  19. package/dashboard/dist/assets/{RequirementBoardPage-CEOvppGn.js → RequirementBoardPage-B7yRL0s_.js} +1 -1
  20. package/dashboard/dist/assets/{RequirementPage-DpnbTEqY.js → RequirementPage-D8J_-b6O.js} +1 -1
  21. package/dashboard/dist/assets/{SpecsPage-CYqOfFkB.js → SpecsPage-6lO8v8_C.js} +1 -1
  22. package/dashboard/dist/assets/{SupervisorPage-B2sZwkq8.js → SupervisorPage-Ds5N378a.js} +1 -1
  23. package/dashboard/dist/assets/{TeamsPage-CkZdCAVZ.js → TeamsPage-DrkKr17T.js} +1 -1
  24. package/dashboard/dist/assets/{TreeBrowser-0VIMWclo.js → TreeBrowser-g_QUKemL.js} +1 -1
  25. package/dashboard/dist/assets/WorkflowPage-X8aNkDEr.js +6 -0
  26. package/dashboard/dist/assets/{arrow-left-6fktHyjN.js → arrow-left-CadP5YgU.js} +1 -1
  27. package/dashboard/dist/assets/{check-Cbxq2l1-.js → check-5xufDzS8.js} +1 -1
  28. package/dashboard/dist/assets/{chevron-right-Yts3bi8p.js → chevron-right-CYbpR4ev.js} +1 -1
  29. package/dashboard/dist/assets/{circle-4Ci4Xolf.js → circle-Bm-5Q-Yh.js} +1 -1
  30. package/dashboard/dist/assets/{circle-alert-B25g9BTL.js → circle-alert-BqcYuT7x.js} +1 -1
  31. package/dashboard/dist/assets/{circle-check-BA5_XqeV.js → circle-check-DEVzW_lm.js} +1 -1
  32. package/dashboard/dist/assets/{circle-check-big-DzO2BlL7.js → circle-check-big-yyzAFysU.js} +1 -1
  33. package/dashboard/dist/assets/{code-zxwuybO8.js → code-BBdC8Wmw.js} +1 -1
  34. package/dashboard/dist/assets/{columns-3-DV4oeCfU.js → columns-3-CQ9Trztr.js} +1 -1
  35. package/dashboard/dist/assets/{download-CXCyQw8M.js → download-DayuF-sn.js} +1 -1
  36. package/dashboard/dist/assets/{folder-Bvjj8Vn9.js → folder-CqXeSKeC.js} +1 -1
  37. package/dashboard/dist/assets/{git-branch-DL8p9kVC.js → git-branch-SqFf4Ru5.js} +1 -1
  38. package/dashboard/dist/assets/{index-BvScJmJM.js → index-Dru5HYy0.js} +1 -1
  39. package/dashboard/dist/assets/{index-11DuhKhc.js → index-nufWop4p.js} +18 -18
  40. package/dashboard/dist/assets/{list-Dj4i9N75.js → list-DBOD6IUt.js} +1 -1
  41. package/dashboard/dist/assets/{minus-DwlFabsT.js → minus-fQI1Syn2.js} +1 -1
  42. package/dashboard/dist/assets/{pen-line-D7UzECt6.js → pen-line-Bkbbngl5.js} +1 -1
  43. package/dashboard/dist/assets/{proxy-B9XRqHD9.js → proxy-teW12DdZ.js} +1 -1
  44. package/dashboard/dist/assets/{search-BQbBTIYl.js → search-Bq3ygFUW.js} +1 -1
  45. package/dashboard/dist/assets/{shallow-Clb1Lyd_.js → shallow-22ZN8sFt.js} +1 -1
  46. package/dashboard/dist/assets/{table-BqxCXid2.js → table-BEYtdWc4.js} +1 -1
  47. package/dashboard/dist/assets/{trash-2-6rN9B-EQ.js → trash-2-DMqGBgcF.js} +1 -1
  48. package/dashboard/dist/assets/{wrench-BScEJFqC.js → wrench-B84-zdLI.js} +1 -1
  49. package/dashboard/dist/assets/{zap-DxUhG-gk.js → zap-9DVkGVtt.js} +1 -1
  50. package/dashboard/dist/index.html +1 -1
  51. package/dashboard/dist-server/dashboard/src/server/agents/agent-sdk-adapter.d.ts +1 -1
  52. package/dashboard/dist-server/dashboard/src/server/agents/agent-sdk-adapter.js +5 -4
  53. package/dashboard/dist-server/dashboard/src/server/agents/agent-sdk-adapter.js.map +1 -1
  54. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +1 -1
  55. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  56. package/dashboard/dist-server/dashboard/src/server/agents/tools/issue-mcp-server.d.ts +1 -1
  57. package/dashboard/dist-server/dashboard/src/server/agents/tools/issue-mcp-server.js +3 -4
  58. package/dashboard/dist-server/dashboard/src/server/agents/tools/issue-mcp-server.js.map +1 -1
  59. package/dashboard/dist-server/dashboard/src/server/agents/tools/issue-mcp-server.test.js +4 -4
  60. package/dashboard/dist-server/dashboard/src/server/agents/tools/issue-mcp-server.test.js.map +1 -1
  61. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js +4 -3
  62. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js.map +1 -1
  63. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.test.js +20 -7
  64. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.test.js.map +1 -1
  65. package/dashboard/dist-server/dashboard/src/server/execution/wave-executor.d.ts +1 -1
  66. package/dashboard/dist-server/dashboard/src/server/execution/wave-executor.js +4 -4
  67. package/dashboard/dist-server/dashboard/src/server/execution/wave-executor.js.map +1 -1
  68. package/dashboard/dist-server/dashboard/src/server/index.js +2 -1
  69. package/dashboard/dist-server/dashboard/src/server/index.js.map +1 -1
  70. package/dashboard/dist-server/dashboard/src/server/routes/issues.js +14 -14
  71. package/dashboard/dist-server/dashboard/src/server/routes/issues.js.map +1 -1
  72. package/dashboard/dist-server/dashboard/src/server/routes/linear.js +7 -5
  73. package/dashboard/dist-server/dashboard/src/server/routes/linear.js.map +1 -1
  74. package/dashboard/dist-server/dashboard/src/server/state/state-manager.js +144 -23
  75. package/dashboard/dist-server/dashboard/src/server/state/state-manager.js.map +1 -1
  76. package/dashboard/dist-server/dashboard/src/server/utils/issue-store.d.ts +6 -0
  77. package/dashboard/dist-server/dashboard/src/server/utils/issue-store.js +24 -2
  78. package/dashboard/dist-server/dashboard/src/server/utils/issue-store.js.map +1 -1
  79. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js +4 -7
  80. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js.map +1 -1
  81. package/dashboard/dist-server/dashboard/src/shared/constants.js +2 -1
  82. package/dashboard/dist-server/dashboard/src/shared/constants.js.map +1 -1
  83. package/dashboard/dist-server/dashboard/src/shared/constants.test.js +5 -5
  84. package/dashboard/dist-server/dashboard/src/shared/constants.test.js.map +1 -1
  85. package/dashboard/dist-server/dashboard/src/shared/issue-types.test.js +4 -4
  86. package/dashboard/dist-server/dashboard/src/shared/issue-types.test.js.map +1 -1
  87. package/dashboard/dist-server/src/commands/delegate.js +7 -1
  88. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  89. package/dist/src/commands/delegate.d.ts.map +1 -1
  90. package/dist/src/commands/delegate.js +7 -1
  91. package/dist/src/commands/delegate.js.map +1 -1
  92. package/package.json +1 -1
  93. package/workflows/delegate-usage.md +39 -41
  94. package/workflows/execute.md +154 -34
  95. package/workflows/init.md +1 -1
  96. package/workflows/maestro-coordinate.codex.md +1 -1
  97. package/workflows/maestro-coordinate.md +1 -1
  98. package/workflows/maestro.md +2 -2
  99. package/workflows/memory.md +2 -1
  100. package/workflows/plan.md +9 -2
  101. package/workflows/retrospective.md +2 -2
  102. package/workflows/roadmap.md +1 -1
  103. package/.claude/commands/learn-retro-decision.md +0 -198
  104. package/.claude/commands/learn-retro-git.md +0 -160
  105. package/dashboard/dist/assets/ChatPage-v19GURYH.js +0 -8
  106. package/dashboard/dist/assets/WorkflowPage-Csm23wUS.js +0 -6
@@ -1,160 +0,0 @@
1
- ---
2
- name: learn-retro-git
3
- description: Git activity retrospective with metrics, session detection, per-author breakdown, and trend tracking
4
- argument-hint: "[--days N] [--author <name>] [--area <path>] [--compare]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Bash
9
- - Glob
10
- - Grep
11
- - Agent
12
- - AskUserQuestion
13
- ---
14
- <purpose>
15
- Git-activity retrospective that works on raw git history regardless of workflow phase state. Complements `quality-retrospective` (which requires completed phase artifacts) by analyzing commit metrics, detecting work sessions, computing test ratios, and tracking trends over time.
16
-
17
- Inspired by gstack `/retro`: per-author breakdown, session clustering, LOC metrics, file hotspot detection, and comparison against prior retrospectives.
18
-
19
- All insights are persisted to `.workflow/learning/lessons.jsonl` (source: "git-retro") so they're queryable via `manage-learn search/list`.
20
- </purpose>
21
-
22
- <context>
23
- Arguments: $ARGUMENTS
24
-
25
- **Flags:**
26
- - `--days N` — Time window in days (default: 7)
27
- - `--author <name>` — Filter commits by author name (substring match)
28
- - `--area <path>` — Scope to files under a specific directory
29
- - `--compare` — Compare against the previous retro-git report if one exists
30
-
31
- **Storage written:**
32
- - `.workflow/learning/retro-git-{YYYY-MM-DD}.json` — Structured metrics (machine-readable)
33
- - `.workflow/learning/retro-git-{YYYY-MM-DD}.md` — Human-readable retrospective report
34
- - `.workflow/learning/lessons.jsonl` — Appended insights (source: "git-retro")
35
- - `.workflow/learning/learning-index.json` — Updated index
36
-
37
- **Storage read:**
38
- - `.workflow/state.json` — Current phase context (optional)
39
- - `.workflow/learning/retro-git-*.json` — Prior retro for trend comparison
40
- - `.workflow/learning/lessons.jsonl` — Existing insights for dedup
41
- </context>
42
-
43
- <execution>
44
-
45
- ### Stage 1: Parse Arguments
46
- - Resolve date range: `--days N` or default 7. Compute absolute start date at midnight.
47
- - Extract `--author`, `--area`, `--compare` flags.
48
- - Check `.workflow/learning/` exists; bootstrap if missing.
49
-
50
- ### Stage 2: Gather Raw Data (parallel git commands)
51
- Run ALL these git commands in parallel (they are independent):
52
-
53
- ```bash
54
- # 1. Commit stats with author, timestamp, subject, files changed
55
- git log --since="<start-date>T00:00:00" --format="%H|%aN|%ae|%ai|%s" --shortstat
56
-
57
- # 2. Per-commit numstat for test vs production LOC split
58
- # Test files: match test/|spec/|__tests__/|*.test.*|*.spec.*
59
- git log --since="<start-date>T00:00:00" --format="COMMIT:%H|%aN" --numstat
60
-
61
- # 3. Timestamps for session detection (sorted)
62
- git log --since="<start-date>T00:00:00" --format="%at|%aN|%ai|%s" | sort -n
63
-
64
- # 4. File hotspots (most frequently changed files)
65
- git log --since="<start-date>T00:00:00" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn | head -20
66
-
67
- # 5. Per-author commit counts
68
- git shortlog --since="<start-date>T00:00:00" -sn --no-merges
69
-
70
- # 6. Per-author file hotspots
71
- git log --since="<start-date>T00:00:00" --format="AUTHOR:%aN" --name-only
72
- ```
73
-
74
- Apply `--author` filter and `--area` path filter to all commands if provided.
75
-
76
- ### Stage 3: Compute Metrics
77
- Calculate and build a metrics object:
78
-
79
- | Metric | Computation |
80
- |--------|-------------|
81
- | Commits | Count of non-merge commits |
82
- | Contributors | Unique author count |
83
- | Total insertions / deletions | Sum from shortstat |
84
- | Net LOC | insertions - deletions |
85
- | Test LOC (insertions) | Sum insertions for test files from numstat |
86
- | Test ratio | test_insertions / total_insertions × 100% |
87
- | Churn rate | Files changed >2 times / total unique files |
88
- | Active days | Distinct dates with commits |
89
- | Area concentration | Top directory % of total commits (Herfindahl) |
90
-
91
- ### Stage 4: Detect Work Sessions
92
- Cluster commits by >2hr gaps in timestamps:
93
- - Group consecutive commits within 2-hour windows into sessions
94
- - Per session: start time, end time, duration, commit count, primary focus area (most-touched directory)
95
- - Compute: total sessions, avg session duration, avg LOC/session-hour
96
-
97
- ### Stage 5: Per-Author Breakdown
98
- For each author:
99
- - Commit count, LOC added/removed, top 3 file areas
100
- - Test ratio (their test LOC / their total LOC)
101
- - Session count and patterns
102
-
103
- ### Stage 6: Trend Comparison (if --compare or prior report exists)
104
- - Find most recent `.workflow/learning/retro-git-*.json`
105
- - If found, compute deltas: commits Δ, LOC Δ, test ratio Δ, churn rate Δ, session count Δ
106
- - Flag significant changes (>20% delta) as trend highlights
107
-
108
- ### Stage 7: Distill Insights
109
- Identify actionable insights from metrics:
110
- - **High churn files** (changed >3 times): instability signal → suggest refactor or test coverage
111
- - **Low test ratio areas** (<20%): testing gap → suggest test generation
112
- - **Session patterns**: scattered sessions (many short) vs deep sessions (few long)
113
- - **Area drift**: if commits don't align with current roadmap phase
114
-
115
- Each insight: title, description, category (pattern/antipattern/technique), tags, confidence.
116
-
117
- ### Stage 8: Persist & Report
118
- 1. Write `.workflow/learning/retro-git-{date}.json` with full metrics structure
119
- 2. Write `.workflow/learning/retro-git-{date}.md` with formatted report:
120
- - Summary metrics table
121
- - Per-author leaderboard
122
- - Session timeline
123
- - File hotspots
124
- - Insights with recommendations
125
- - Trend deltas (if comparing)
126
- 3. Append each insight to `lessons.jsonl` with `source: "git-retro"`, `lens: null`, using stable INS-id from `hash(metric_name + date)`
127
- 4. Update `learning-index.json`
128
- 5. Display summary and next-step suggestions
129
-
130
- **Next-step routing:**
131
- - Browse insights → `Skill({ skill: "manage-learn", args: "list --tag git-retro" })`
132
- - Deep dive on high-churn file → `Skill({ skill: "learn-follow", args: "<path>" })`
133
- - Fix test gaps → `Skill({ skill: "quality-test-gen", args: "<area>" })`
134
- </execution>
135
-
136
- <error_codes>
137
- | Code | Severity | Condition | Recovery |
138
- |------|----------|-----------|----------|
139
- | E001 | error | Not inside a git repository | Navigate to a git repo directory |
140
- | E002 | error | No commits found in the specified time window | Increase --days or check --author/--area filters |
141
- | W001 | warning | `.workflow/learning/` not found, bootstrapping | Auto-created; proceed normally |
142
- | W002 | warning | No prior retro-git report for comparison | Skip trend section; first retro establishes baseline |
143
- | W003 | warning | Author filter matched 0 commits | Show available authors and re-prompt |
144
- </error_codes>
145
-
146
- <success_criteria>
147
- - [ ] Date range parsed correctly (absolute midnight-aligned start date)
148
- - [ ] All 6 git commands executed successfully
149
- - [ ] Metrics computed: commits, LOC, test ratio, churn rate, sessions, area concentration
150
- - [ ] Sessions detected with >2hr gap clustering
151
- - [ ] Per-author breakdown generated for all contributors
152
- - [ ] Trend comparison computed if prior report exists and --compare used
153
- - [ ] At least 1 actionable insight distilled from metrics
154
- - [ ] `retro-git-{date}.json` written with valid JSON
155
- - [ ] `retro-git-{date}.md` written and human-readable
156
- - [ ] `lessons.jsonl` appended with insights (source: "git-retro", stable INS-ids)
157
- - [ ] `learning-index.json` updated
158
- - [ ] No files modified outside `.workflow/learning/`
159
- - [ ] Summary displayed with next-step routing
160
- </success_criteria>
@@ -1,8 +0,0 @@
1
- import{d as ae,r as i,j as e,k as T,s as W,q as te,t as re,v as oe,X as $,F as ce,w as U,m as ie,M as de}from"./index-11DuhKhc.js";import{S as ue}from"./search-BQbBTIYl.js";import{G as pe}from"./git-branch-DL8p9kVC.js";import{Z as xe}from"./zap-DxUhG-gk.js";import{M as q,C as z,L as fe}from"./ChatInput-PuCvZZ3y.js";import{T as ge,a as ye}from"./TreeBrowser-0VIMWclo.js";import"./MarkdownRenderer-CCXHaut3.js";import"./wrench-BScEJFqC.js";import"./chevron-right-Yts3bi8p.js";import"./circle-alert-B25g9BTL.js";import"./folder-Bvjj8Vn9.js";/**
2
- * @license lucide-react v0.577.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const he=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ve=ae("columns-2",he),L=(t,r)=>(window.addEventListener(t,r),()=>window.removeEventListener(t,r)),me=(...t)=>()=>{const r=t.slice();for(;r.length;)r.pop()()};function be(t,r,o,n){if(!t)return r;try{const s=localStorage.getItem(t);if(s){const a=parseFloat(s);if(!isNaN(a)&&a>=o&&a<=n)return a}}catch{}return r}function je(t={}){const{defaultRatio:r=50,minRatio:o=25,maxRatio:n=75,storageKey:s}=t,[a,d]=i.useState(()=>be(s,r,o,n)),x=i.useCallback(u=>{if(d(u),s)try{localStorage.setItem(s,u.toString())}catch{}},[s]),l=i.useCallback((u=!1)=>c=>{if(c.pointerType!=="touch"&&c.button!==0)return;c.preventDefault();const y=c.currentTarget,S=y.parentElement,k=S==null?void 0:S.parentElement,N=(k==null?void 0:k.offsetWidth)||0;if(!N)return;const m=c.clientX,j=a,b=c.pointerId;let f=null,w=null,R=j,I=!0,P=null;const E=()=>{w!==null&&(R=w,d(w))},F=()=>{const h=document.body.style.userSelect;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.body.style.userSelect=h,document.body.style.cursor="",f!==null&&(cancelAnimationFrame(f),f=null)}},M=h=>{if(!I)return;I=!1,f!==null&&(cancelAnimationFrame(f),f=null),E();let X=R;if(h&&"clientX"in h&&typeof h.clientX=="number"){const le=(u?m-h.clientX:h.clientX-m)/N*100;X=Math.max(o,Math.min(n,j+le))}x(X),P==null||P()},B=h=>{if(!I)return;if(h.buttons===0){M(h);return}const _=(u?m-h.clientX:h.clientX-m)/N*100;w=Math.max(o,Math.min(n,j+_)),f===null&&(f=requestAnimationFrame(()=>{f=null,E()}))},D=()=>M(),A=h=>M(h),g=h=>M(h),C=h=>M(h);if(y.setPointerCapture)try{y.setPointerCapture(b),y.addEventListener("lostpointercapture",D)}catch{}const ne=()=>{var h;y.releasePointerCapture&&((h=y.hasPointerCapture)!=null&&h.call(y,b))&&y.releasePointerCapture(b),y.removeEventListener("lostpointercapture",D)};P=me(F(),ne,L("pointermove",B),L("pointerup",A),L("pointercancel",g),L("mouseup",C),L("blur",()=>M()))},[a,o,n,x]),p=i.useCallback((u={})=>{const{className:c="",style:y,reverse:S,linePlacement:k,lineClassName:N="",lineStyle:m}=u,j=k?k==="start"?"justify-start":"justify-end":S?"justify-start":"justify-end";return e.jsx("div",{className:`group absolute top-0 bottom-0 z-20 cursor-col-resize flex items-center ${j} ${c}`,style:{width:"12px",...y},onPointerDown:l(S),onDoubleClick:()=>x(r),children:e.jsx("span",{className:`pointer-events-none block h-full rounded-full transition-all duration-150 w-[2px] opacity-60 group-hover:w-[5px] group-hover:opacity-100 group-active:w-[5px] group-active:opacity-100 ${N}`,style:{backgroundColor:"var(--color-border)",...m}})})},[l,x,r]),v=p({className:"right-0"});return{ratio:a,setRatio:x,dragHandle:v,createDragHandle:p}}function ke(t){const r=T(n=>n.pendingApprovals),o=i.useMemo(()=>t?Object.values(r).find(n=>n.processId===t)??null:null,[t,r]);i.useEffect(()=>{if(!o)return;function n(s){const a=s.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const d=s.key;if(d==="y"||d==="Y"){s.preventDefault(),W({action:"approve",processId:o.processId,requestId:o.id,allow:!0});return}if(d==="Escape"){s.preventDefault(),W({action:"approve",processId:o.processId,requestId:o.id,allow:!1});return}if(d==="a"||d==="A"){s.preventDefault(),W({action:"approve",processId:o.processId,requestId:o.id,allow:!0});return}}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[o])}function we(){const[t,r]=i.useState([]),[o,n]=i.useState(!0),s=i.useCallback(async()=>{n(!0);try{const a=await fetch("/api/workspace?tree=true");a.ok&&r(await a.json())}catch{}finally{n(!1)}},[]);return i.useEffect(()=>{s()},[s]),{tree:t,loading:o,refreshTree:s}}function H(t){if(t<60)return`${t}s`;const r=Math.floor(t/60),o=t%60;return`${r}m ${o}s`}function Y({processId:t}){const r=T(l=>t?l.processThoughts[t]:void 0),o=T(l=>t?l.processStreaming[t]??!1:!1),[n,s]=i.useState(0),a=i.useRef(Date.now());if(i.useEffect(()=>{if(!o&&!(r!=null&&r.subject)){s(0);return}a.current=Date.now(),s(0);const l=setInterval(()=>{s(Math.floor((Date.now()-a.current)/1e3))},1e3);return()=>clearInterval(l)},[o,r==null?void 0:r.subject]),!o&&!(r!=null&&r.subject))return null;const d=()=>{t&&W({action:"stop",processId:t})};if(o&&!(r!=null&&r.subject))return e.jsx("div",{style:G,children:e.jsxs("div",{style:K,children:[e.jsx(V,{}),e.jsxs("span",{style:{color:"var(--color-text-secondary)",fontSize:12},children:["Processing...",e.jsxs("span",{style:{marginLeft:6,opacity:.6},children:["(",H(n),")"]})]}),e.jsx(Q,{onClick:d})]})});const x=r&&r.description&&r.description!==r.subject;return e.jsx("div",{style:G,children:e.jsxs("div",{style:K,children:[o&&e.jsx(V,{}),(r==null?void 0:r.subject)&&e.jsx("span",{style:Ce,children:r.subject}),x&&e.jsx("span",{style:{flex:1,fontSize:12,color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.description}),o&&e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",whiteSpace:"nowrap"},children:["(",H(n),")"]}),o&&e.jsx(Q,{onClick:d})]})})}const G={background:"linear-gradient(135deg, var(--color-bg-card) 0%, var(--color-bg-primary) 100%)",borderRadius:10,padding:"8px 12px",margin:"0 16px 4px 16px",border:"1px solid var(--color-border-divider)"},K={display:"flex",alignItems:"center",gap:8},Ce={display:"inline-block",fontSize:11,fontWeight:600,padding:"2px 8px",borderRadius:6,backgroundColor:"var(--color-tint-exploring)",color:"var(--color-accent-blue)",whiteSpace:"nowrap"};function V(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-accent-blue)",strokeWidth:"2.5",strokeLinecap:"round",style:{animation:"spin 1s linear infinite",flexShrink:0},children:[e.jsx("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]})}function Q({onClick:t}){return e.jsx("button",{type:"button",onClick:t,style:{marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:6,border:"1px solid var(--color-border)",backgroundColor:"var(--color-bg-card)",cursor:"pointer",color:"var(--color-text-tertiary)",flexShrink:0,padding:0,transition:"all 150ms"},onMouseEnter:r=>{const o=r.currentTarget;o.style.borderColor="var(--color-accent-red)",o.style.backgroundColor="var(--color-tint-blocked)",o.style.color="var(--color-accent-red)"},onMouseLeave:r=>{const o=r.currentTarget;o.style.borderColor="var(--color-border)",o.style.backgroundColor="var(--color-bg-card)",o.style.color="var(--color-text-tertiary)"},"aria-label":"Stop process",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})})}function Se(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Ne(t){try{return new Date(t).toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function Z(t){return t.asyncDelegate===!0}function Te(t,r){const o=[];for(const n of r)n.status!=="dispatched"&&(o.push({id:`${n.messageId}:user`,processId:t,timestamp:n.createdAt,type:"user_message",content:n.message}),n.status==="dropped"&&o.push({id:`${n.messageId}:error`,processId:t,timestamp:n.dispatchedAt??n.createdAt,type:"error",message:n.dispatchReason?`Follow-up dropped: ${n.dispatchReason}`:"Follow-up dropped"}));return o}function Me(t){return t.delegateStatus==="cancelling"?{label:"Cancelling",bg:"var(--color-tint-planning)",fg:"var(--color-accent-orange)"}:t.cancelledAt||t.delegateStatus==="cancelled"?{label:"Cancelled",bg:"var(--color-bg-hover)",fg:"var(--color-text-secondary)"}:t.exitCode!==void 0?{label:t.exitCode===0?"OK":`Exit ${t.exitCode}`,bg:t.exitCode===0?"var(--color-tint-exploring)":"var(--color-tint-blocked)",fg:t.exitCode===0?"var(--color-accent-green)":"var(--color-accent-red)"}:t.delegateStatus?{label:t.delegateStatus,bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"}:null}function Ie({open:t}){const[r,o]=i.useState([]),[n,s]=i.useState("async"),a=T(l=>l.processes);i.useEffect(()=>{t&&fetch("/api/cli-history?limit=20").then(l=>l.ok?l.json():[]).then(l=>o(l)).catch(()=>{})},[t]);const d=i.useMemo(()=>new Set(Object.keys(a)),[a]),x=i.useMemo(()=>{const l=r.filter(p=>!d.has(p.execId)&&!d.has(`cli-history-${p.execId}`));switch(n){case"async":return l.filter(Z);case"other":return l.filter(p=>!Z(p));default:return l}},[r,d,n]);return e.jsxs("div",{className:"absolute right-0 top-0 bottom-0 z-40 overflow-y-auto flex flex-col",style:{width:280,backgroundColor:"var(--color-bg-secondary)",borderLeft:"1px solid var(--color-border)",boxShadow:t?"-4px 0 16px rgba(0,0,0,0.06)":"none",transform:t?"translateX(0)":"translateX(100%)",opacity:t?1:0,transition:"transform 200ms cubic-bezier(0.34,1.56,0.64,1), opacity 180ms ease",pointerEvents:t?"auto":"none"},children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 border-b shrink-0",style:{borderColor:"var(--color-border-divider)"},children:[e.jsx(te,{size:14,strokeWidth:1.8,style:{color:"var(--color-text-tertiary)"}}),e.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--color-text-primary)"},children:"History"})]}),e.jsx("div",{className:"flex gap-1 px-2 py-2 border-b shrink-0",style:{borderColor:"var(--color-border-divider)"},children:[["async","Async"],["all","All"],["other","Other CLI"]].map(([l,p])=>e.jsx("button",{type:"button",onClick:()=>s(l),className:"px-2 py-1 rounded-md text-[11px] border-none cursor-pointer transition-colors duration-150",style:{backgroundColor:n===l?"var(--color-bg-active)":"transparent",color:n===l?"var(--color-text-primary)":"var(--color-text-tertiary)"},children:p},l))}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:x.length===0?e.jsx("div",{className:"px-3 py-4 text-center text-[12px]",style:{color:"var(--color-text-tertiary)"},children:"No history entries"}):x.map(l=>e.jsx(Pe,{meta:l,onRemove:p=>o(v=>v.filter(u=>u.execId!==p))},l.execId))})]})}function Pe({meta:t,onRemove:r}){const{addProcess:o,addEntry:n,setActiveProcessId:s}=T.getState(),a=t.tool==="claude"?"claude-code":t.tool,d=oe[a]??"var(--color-text-tertiary)",x=re[a]??t.tool,l=async()=>{const c=`cli-history-${t.execId}`;if(T.getState().processes[c]){s(c);return}const y={id:c,type:a,status:t.delegateStatus==="cancelling"?"stopping":t.delegateStatus==="queued"?"spawning":t.delegateStatus==="running"?"running":"stopped",config:{type:a,prompt:t.prompt,workDir:t.workDir},startedAt:t.startedAt,interactive:t.asyncDelegate===!0};o(y),s(c);try{const[S,k]=await Promise.all([fetch(`/api/cli-history/${encodeURIComponent(t.execId)}/entries`),t.asyncDelegate?fetch(`/api/cli-history/${encodeURIComponent(t.execId)}/messages`):Promise.resolve(null)]);if(S.ok){const N=await S.json(),m=[];for(const j of N){const b={...j,processId:c};if(b.type==="assistant_message"){b.partial=!1;const f=m[m.length-1];if(f&&f.type==="assistant_message"){f.content+=b.content;continue}}if(b.type==="tool_use"&&(b.status==="completed"||b.status==="failed")){const f=m.findLastIndex(w=>w.type==="tool_use"&&w.status==="running");if(f!==-1){const w=m[f];m[f]={...w,status:b.status,result:b.result??w.result,input:w.input&&Object.keys(w.input).length>0?w.input:b.input};continue}}m.push(b)}for(const j of m)n(c,j)}if(k!=null&&k.ok){const N=await k.json();for(const m of Te(c,N))n(c,m)}}catch{}},p=c=>{c.stopPropagation();const y=`cli-history-${t.execId}`;T.getState().dismissProcess(y),r(t.execId)},v=Me(t),u=v?e.jsx("span",{className:"text-[10px] font-medium px-[5px] py-[1px] rounded",style:{backgroundColor:v.bg,color:v.fg},children:v.label}):null;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-[10px] rounded-lg border-none bg-transparent cursor-pointer transition-colors duration-150",style:{color:"var(--color-text-secondary)"},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="var(--color-bg-hover)"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent"},children:[e.jsxs("div",{className:"flex items-center gap-[6px] mb-[4px]",children:[e.jsx("span",{className:"w-[7px] h-[7px] rounded-full shrink-0",style:{backgroundColor:d}}),e.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--color-text-primary)"},children:x}),t.asyncDelegate&&e.jsx("span",{className:"text-[9px] font-semibold px-[4px] py-[1px] rounded",style:{backgroundColor:"var(--color-tint-exploring)",color:"var(--color-accent-blue)"},children:"ASYNC"}),u]}),e.jsxs("div",{className:"text-[11px] truncate mb-[4px]",style:{color:"var(--color-text-tertiary)"},children:[t.prompt.slice(0,60),t.prompt.length>60?"...":""]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",style:{color:"var(--color-text-placeholder)"},children:[e.jsx("span",{children:Ne(t.startedAt)}),e.jsx("span",{children:Se(t.startedAt)}),t.model&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-border-divider)"},children:"·"}),e.jsx("span",{children:t.model})]})]})]}),e.jsx("button",{type:"button",onClick:p,className:"absolute top-1 right-1 w-5 h-5 rounded flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity border-none bg-transparent cursor-pointer",style:{color:"var(--color-text-placeholder)"},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="var(--color-tint-blocked)",c.currentTarget.style.color="var(--color-accent-red)"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent",c.currentTarget.style.color="var(--color-text-placeholder)"},"aria-label":"Remove history item",children:e.jsx($,{size:12,strokeWidth:2})})]})}function J({filePath:t,onClose:r}){const[o,n]=i.useState(null),[s,a]=i.useState(!0),[d,x]=i.useState(null);i.useEffect(()=>{let p=!1;return a(!0),x(null),fetch(`/api/workspace/file?path=${encodeURIComponent(t)}`).then(async v=>{p||(v.ok?n(await v.text()):(x(`Failed to load: ${v.status}`),n(null)))}).catch(()=>{p||x("Failed to fetch file")}).finally(()=>{p||a(!1)}),()=>{p=!0}},[t]);const l=t.split("/").pop()??t;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b",style:{borderColor:"var(--color-border-divider)",backgroundColor:"var(--color-bg-secondary)"},children:[e.jsx(ce,{size:13,strokeWidth:1.8,style:{color:"var(--color-text-tertiary)"}}),e.jsx("span",{className:"text-[12px] font-medium truncate flex-1",style:{color:"var(--color-text-primary)"},title:t,children:l}),e.jsx("span",{className:"text-[10px] truncate max-w-[200px]",style:{color:"var(--color-text-tertiary)"},children:t}),e.jsx("button",{type:"button",onClick:r,className:"w-6 h-6 rounded flex items-center justify-center transition-colors",style:{color:"var(--color-text-tertiary)"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor="var(--color-bg-hover)",p.currentTarget.style.color="var(--color-text-primary)"},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent",p.currentTarget.style.color="var(--color-text-tertiary)"},"aria-label":"Close file viewer",children:e.jsx($,{size:12,strokeWidth:2})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[s&&e.jsx("div",{className:"p-4 text-[12px] animate-pulse",style:{color:"var(--color-text-tertiary)"},children:"Loading..."}),d&&e.jsx("div",{className:"p-4 text-[12px]",style:{color:"var(--color-accent-red)"},children:d}),!s&&!d&&o!==null&&e.jsx("pre",{className:"p-4 m-0 text-[12px] leading-[1.7] whitespace-pre-wrap break-words",style:{color:"var(--color-text-secondary)",fontFamily:"var(--font-mono)",tabSize:2},children:o})]})]})}function Re(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}const Ee={spawning:"Starting…",running:"Running",paused:"Paused",stopping:"Stopping…",stopped:"Stopped",error:"Error"};function De(t){return t.id.startsWith("cli-history-")}const Le=[{title:"Explore your codebase",desc:"Ask questions, trace code paths, understand architecture",icon:ue,iconColor:"var(--color-accent-blue)",iconBg:"var(--color-tint-exploring)"},{title:"Plan a feature",desc:"Break down requirements into phases and tasks",icon:pe,iconColor:"var(--color-accent-purple)",iconBg:"var(--color-tint-planning)"},{title:"Execute a workflow",desc:"Run parallel tasks with automatic verification",icon:xe,iconColor:"var(--color-accent-orange)",iconBg:"var(--color-tint-verifying)"},{title:"Review & debug",desc:"Multi-dimensional code review and hypothesis-driven debugging",icon:fe,iconColor:"var(--color-accent-green)",iconBg:"var(--color-tint-completed)"}];function We(){return ie(r=>r.stylePreset)==="cowork"?e.jsx("div",{className:"flex-1 flex flex-col",style:{paddingTop:"12vh"},children:e.jsxs("div",{className:"w-full px-6",style:{maxWidth:680},children:[e.jsx("h1",{style:{fontFamily:"var(--style-heading-font)",fontSize:"var(--style-heading-size)",fontWeight:"var(--style-heading-weight)",letterSpacing:"var(--style-heading-letter-spacing)",color:"var(--color-text-primary)",margin:0},children:"Let's build something together"}),e.jsx("p",{className:"mt-2 mb-6",style:{color:"var(--color-text-tertiary)",fontSize:14,margin:"8px 0 24px"},children:"Maestro workflow orchestration."}),e.jsx(z,{}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"mb-3",style:{color:"var(--color-text-tertiary)",fontSize:12,fontWeight:500},children:"Get started with Maestro"}),e.jsx("div",{className:"flex flex-col gap-[2px]",children:Le.map(r=>e.jsxs("div",{className:"flex items-center gap-3 px-2 py-[6px] rounded-[8px] cursor-pointer transition-colors duration-150",onMouseEnter:o=>{o.currentTarget.style.backgroundColor="var(--color-bg-hover)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="transparent"},children:[e.jsx("div",{className:"shrink-0 flex items-center justify-center rounded-[10px]",style:{width:36,height:36,backgroundColor:r.iconBg},children:e.jsx(r.icon,{size:18,strokeWidth:1.5,style:{color:r.iconColor}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--color-text-primary)"},children:r.title}),e.jsx("div",{style:{fontSize:12,color:"var(--color-text-tertiary)"},children:r.desc})]})]},r.title))})]})]})}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",style:{marginTop:"-5vh"},children:e.jsxs("div",{className:"w-full px-4",style:{maxWidth:"clamp(360px, calc(100% - 32px), 780px)"},children:[e.jsxs("div",{className:"flex flex-col items-center mb-8",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center mb-4",style:{backgroundColor:"var(--color-tint-exploring)"},children:e.jsx(de,{size:24,strokeWidth:1.5,style:{color:"var(--color-accent-blue)"}})}),e.jsx("h1",{className:"text-xl font-semibold mb-2 text-center",style:{color:"var(--color-text-primary)"},children:"Start a new conversation"}),e.jsx("p",{className:"text-[13px] text-center",style:{color:"var(--color-text-tertiary)"},children:"Select an agent, type a message, and press Enter to begin."})]}),e.jsx(z,{})]})})}function se({process:t,isActive:r,onClick:o,onDismiss:n}){const s=oe[t.type]??"var(--color-text-tertiary)",a=re[t.type]??t.type,d=De(t),x=`${a}${d?" · Async Delegate":""} · ${Ee[t.status]??t.status}
7
- ${t.config.prompt.slice(0,100)}${t.config.prompt.length>100?"…":""}
8
- ${Re(t.startedAt)} · ${t.type}`;return e.jsxs("button",{type:"button",onClick:o,title:x,className:"group/tab flex items-center gap-[6px] px-3 py-[5px] rounded-[9px] border-none text-[11px] font-medium cursor-pointer transition-all duration-150 shrink-0 relative",style:{backgroundColor:r?"var(--color-text-primary)":"transparent",color:r?"#fff":"var(--color-text-tertiary)",paddingRight:n?"22px":void 0},onMouseEnter:l=>{r||(l.currentTarget.style.backgroundColor="var(--color-bg-hover)",l.currentTarget.style.color="var(--color-text-primary)")},onMouseLeave:l=>{r||(l.currentTarget.style.backgroundColor="transparent",l.currentTarget.style.color="var(--color-text-tertiary)")},children:[e.jsx("span",{className:"w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:r?"#fff":s}}),a,d&&e.jsx("span",{className:"px-[4px] py-[1px] rounded text-[9px] font-semibold",style:{backgroundColor:r?"rgba(255,255,255,0.16)":"var(--color-tint-exploring)",color:r?"#fff":"var(--color-accent-blue)"},children:"ASYNC"}),n&&e.jsx("span",{onClick:l=>{l.stopPropagation(),n()},className:"absolute right-[6px] top-1/2 -translate-y-1/2 w-[14px] h-[14px] rounded-sm flex items-center justify-center opacity-0 group-hover/tab:opacity-100 transition-opacity duration-100",style:{color:r?"rgba(255,255,255,0.6)":"var(--color-text-placeholder)"},onMouseEnter:l=>{l.currentTarget.style.color=r?"#fff":"var(--color-accent-red)",l.currentTarget.style.backgroundColor=r?"rgba(255,255,255,0.15)":"var(--color-tint-blocked)"},onMouseLeave:l=>{l.currentTarget.style.color=r?"rgba(255,255,255,0.6)":"var(--color-text-placeholder)",l.currentTarget.style.backgroundColor="transparent"},children:e.jsx($,{size:10,strokeWidth:2})})]})}function ze({sortedProcesses:t,activeProcessId:r,splitOpen:o,historyOpen:n,fileTreeOpen:s,onSelectProcess:a,onDismissProcess:d,onNewSession:x,onToggleSplit:l,onToggleHistory:p,onToggleFileTree:v}){return e.jsx("div",{className:"sticky top-0 z-30 flex justify-center pt-2 pointer-events-none shrink-0",children:e.jsxs("div",{className:"inline-flex items-center gap-[2px] border rounded-[12px] p-[3px] pointer-events-auto",style:{backgroundColor:"var(--color-bg-card)",borderColor:"var(--color-border)",boxShadow:"0 4px 20px rgba(0,0,0,0.06)",maxWidth:"calc(100% - 32px)"},children:[!o&&(t.length>0||r===null)&&e.jsxs("div",{className:"flex items-center gap-[2px] overflow-x-auto",style:{scrollbarWidth:"thin",maxWidth:"min(600px, 60vw)"},onWheel:u=>{Math.abs(u.deltaY)>Math.abs(u.deltaX)&&(u.currentTarget.scrollLeft+=u.deltaY,u.preventDefault())},children:[t.map(u=>e.jsx(se,{process:u,isActive:u.id===r,onClick:()=>a(u.id),onDismiss:()=>d(u.id)},u.id)),r===null&&e.jsxs("button",{type:"button",className:"flex items-center gap-[6px] px-3 py-[5px] rounded-[9px] border-none text-[11px] font-medium cursor-pointer shrink-0",style:{backgroundColor:"var(--color-text-primary)",color:"#fff"},children:[e.jsx(U,{size:10,strokeWidth:2.5}),"New"]})]}),t.length>1&&e.jsxs(e.Fragment,{children:[!o&&t.length>0&&e.jsx("div",{className:"w-px h-4 shrink-0",style:{backgroundColor:"var(--color-border-divider)",margin:"0 2px"}}),e.jsx(O,{icon:e.jsx(ve,{size:14,strokeWidth:1.8}),isActive:o,onClick:l,label:"Toggle split view"})]}),e.jsx("button",{type:"button",onClick:x,className:"w-7 h-7 rounded-[8px] border-none bg-transparent flex items-center justify-center cursor-pointer transition-all duration-150 shrink-0",style:{color:"var(--color-text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--color-bg-hover)",u.currentTarget.style.color="var(--color-text-primary)"},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color="var(--color-text-tertiary)"},"aria-label":"New session",children:e.jsx(U,{size:14,strokeWidth:2})}),e.jsx("div",{className:"w-px h-4 shrink-0",style:{backgroundColor:"var(--color-border-divider)",margin:"0 2px"}}),e.jsx(O,{icon:e.jsx(ye,{size:14,strokeWidth:1.8}),isActive:s,onClick:v,label:"Toggle file tree"}),e.jsx(O,{icon:e.jsx(te,{size:14,strokeWidth:1.8}),isActive:n,onClick:p,label:"Toggle history"})]})})}function ee({sortedProcesses:t,currentProcessId:r,onSelectProcess:o,onClose:n}){return e.jsx("div",{className:"flex justify-center pt-[6px] pb-[2px] pointer-events-none shrink-0",children:e.jsxs("div",{className:"inline-flex items-center gap-[2px] border rounded-[10px] p-[2px] pointer-events-auto",style:{backgroundColor:"var(--color-bg-card)",borderColor:"var(--color-border)",boxShadow:"0 2px 12px rgba(0,0,0,0.04)",maxWidth:"calc(100% - 16px)"},children:[e.jsx("div",{className:"flex items-center gap-[2px] overflow-x-auto",style:{scrollbarWidth:"thin",maxWidth:"min(400px, 100%)"},onWheel:s=>{Math.abs(s.deltaY)>Math.abs(s.deltaX)&&(s.currentTarget.scrollLeft+=s.deltaY,s.preventDefault())},children:t.map(s=>e.jsx(se,{process:s,isActive:s.id===r,onClick:()=>o(s.id)},s.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 shrink-0",style:{backgroundColor:"var(--color-border-divider)",margin:"0 1px"}}),e.jsx("button",{type:"button",onClick:n,className:"w-[22px] h-[22px] rounded-[6px] border-none bg-transparent flex items-center justify-center cursor-pointer transition-all duration-100 shrink-0",style:{color:"var(--color-text-placeholder)"},onMouseEnter:s=>{s.currentTarget.style.backgroundColor="var(--color-tint-blocked)",s.currentTarget.style.color="var(--color-accent-red)"},onMouseLeave:s=>{s.currentTarget.style.backgroundColor="transparent",s.currentTarget.style.color="var(--color-text-placeholder)"},"aria-label":"Close pane",children:e.jsx($,{size:10,strokeWidth:2})})]})]})})}function O({icon:t,isActive:r,onClick:o,label:n}){return e.jsx("button",{type:"button",onClick:o,className:"flex items-center px-2 py-[5px] rounded-[9px] border-none bg-transparent cursor-pointer transition-all duration-150 shrink-0",style:{color:r?"var(--color-accent-blue)":"var(--color-text-tertiary)",backgroundColor:r?"var(--color-tint-exploring)":"transparent"},onMouseEnter:s=>{r||(s.currentTarget.style.backgroundColor="var(--color-bg-hover)",s.currentTarget.style.color="var(--color-text-primary)")},onMouseLeave:s=>{r||(s.currentTarget.style.backgroundColor="transparent",s.currentTarget.style.color="var(--color-text-tertiary)")},"aria-label":n,children:t})}function Ge(){var A;const t=T(g=>g.processes),r=T(g=>g.activeProcessId),o=T(g=>g.setActiveProcessId),n=T(g=>g.dismissProcess),[s,a]=i.useState(!1),[d,x]=i.useState(null),[l,p]=i.useState(!1),[v,u]=i.useState(!1),[c,y]=i.useState(null),{ratio:S,setRatio:k,createDragHandle:N}=je({defaultRatio:50,minRatio:25,maxRatio:75,storageKey:"chat-split-ratio"}),m=we(),j=i.useMemo(()=>Object.values(t).sort((g,C)=>new Date(C.startedAt).getTime()-new Date(g.startedAt).getTime()),[t]),b=i.useRef(!1),f=Object.keys(t).length,w=i.useRef(f),R=i.useRef(j);R.current=j,i.useEffect(()=>{const g=w.current;if(w.current=f,b.current){if(f>g){b.current=!1;const C=R.current[0];C&&o(C.id)}return}if(!r&&f>0){const C=R.current[0];C&&o(C.id)}},[r,f,o]);const I=d?t[d]:null,P=!r;ke(r),i.useEffect(()=>{s&&d&&!t[d]&&(a(!1),x(null))},[s,d,t]);const E=i.useCallback(()=>{if(s)a(!1),x(null),y(null);else{const g=j.find(C=>C.id!==r);g&&(x(g.id),a(!0),k(50))}},[s,j,r,k]),F=i.useCallback(g=>{const C=t[g];C&&(C.status==="running"||C.status==="spawning")&&W({action:"stop",processId:g}),n(g)},[t,n]),M=i.useCallback(()=>{b.current=!0,o(null)},[o]),B=i.useCallback(g=>{c!==null?y(g):(y(g),a(!0),x(null),k(50))},[c,k]),D=i.useCallback(()=>{y(null),a(!1),x(null)},[]);return e.jsxs("div",{className:"h-full flex min-w-0 overflow-hidden relative",children:[e.jsx("div",{className:"shrink-0 flex flex-col overflow-hidden border-r transition-[width] duration-200 ease-[var(--ease-notion)]",style:{width:v?260:0,borderColor:v?"var(--color-border)":"transparent"},children:v&&e.jsx(ge,{tree:m.tree,selectedPath:c,onSelectFile:B,loading:m.loading})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[e.jsx(ze,{sortedProcesses:j,activeProcessId:r,splitOpen:s,historyOpen:l,fileTreeOpen:v,onSelectProcess:o,onDismissProcess:F,onNewSession:M,onToggleSplit:E,onToggleHistory:()=>p(!l),onToggleFileTree:()=>u(!v)}),P&&c?e.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:e.jsx(J,{filePath:c,onClose:D})}):P?e.jsx(We,{}):e.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 relative",children:[e.jsxs("div",{className:"flex flex-col min-w-0 overflow-hidden",style:{flex:s?`0 0 ${S}%`:"1"},children:[s&&!c&&e.jsx(ee,{sortedProcesses:j,currentProcessId:r,onSelectProcess:o}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:e.jsx(q,{processId:r})}),e.jsx(Y,{processId:r}),s&&!c?e.jsx(z,{processId:r,executor:(A=t[r])==null?void 0:A.type}):e.jsx(z,{})]}),s&&e.jsx("div",{className:"relative shrink-0",style:{width:0},children:N({className:"left-[-6px]",linePlacement:"end",lineClassName:"opacity-40 group-hover:opacity-100 group-active:opacity-100",lineStyle:{backgroundColor:"var(--color-accent-orange)"}})}),s&&e.jsx("div",{className:"flex flex-col min-w-0 overflow-hidden border-l",style:{flex:`0 0 ${100-S}%`,borderColor:"var(--color-border)"},children:c?e.jsx(J,{filePath:c,onClose:D}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{sortedProcesses:j,currentProcessId:d,onSelectProcess:x,onClose:E}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:e.jsx(q,{processId:d})}),e.jsx(Y,{processId:d}),e.jsx(z,{processId:d,executor:I==null?void 0:I.type})]})})]})]}),e.jsx(Ie,{open:l})]})}export{Ge as ChatPage};
@@ -1,6 +0,0 @@
1
- import{d as K,j as e,S as m,a as w,r as f,c as H,L as _,V as J,b as X,p as Y}from"./index-11DuhKhc.js";import{u as Z}from"./shallow-Clb1Lyd_.js";import{u as T,S as I,P as E,T as ee,D as te,K as se}from"./table-BqxCXid2.js";import{C as $}from"./check-Cbxq2l1-.js";import{L as U}from"./list-Dj4i9N75.js";import{C as L}from"./circle-check-BA5_XqeV.js";import{C as ae}from"./circle-alert-B25g9BTL.js";import{C as re}from"./columns-3-DV4oeCfU.js";/**
2
- * @license lucide-react v0.577.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ne=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ie=K("play",ne),W=[{status:"pending",label:"Pending"},{status:"exploring",label:"Exploring"},{status:"planning",label:"Planning"},{status:"executing",label:"Executing"},{status:"verifying",label:"Verifying"},{status:"completed",label:"Complete"}];function le(t,s){return s==="completed"?t.filter(a=>a.status==="completed").length:s==="verifying"?t.filter(a=>a.status==="verifying"||a.status==="testing").length:t.filter(a=>a.status===s).length}function oe({phases:t}){return e.jsx("div",{className:"flex items-center px-[var(--spacing-4)] py-[var(--spacing-3)] border-b border-border-divider bg-bg-primary shrink-0 gap-0 overflow-x-auto",children:W.map((s,a)=>{const r=le(t,s.status),n=m[s.status];return e.jsxs("div",{className:"contents",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-3-5)] py-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-tertiary",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full shrink-0",style:{backgroundColor:n}}),s.label,e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-px rounded-full bg-bg-secondary text-text-tertiary font-mono",children:r})]}),a<W.length-1&&e.jsx("div",{className:"relative w-5 h-px bg-border shrink-0",children:e.jsx("div",{className:"absolute -right-px -top-[3px] border-[3px] border-transparent border-l-[4px] border-l-border"})})]},s.status)})})}const S={feat:{bg:"rgba(74,144,217,0.12)",text:"var(--color-status-exploring)"},feature:{bg:"rgba(74,144,217,0.12)",text:"var(--color-status-exploring)"},fix:{bg:"rgba(208,84,84,0.12)",text:"var(--color-status-blocked)"},refac:{bg:"rgba(139,107,191,0.12)",text:"var(--color-status-planning)"},refactor:{bg:"rgba(139,107,191,0.12)",text:"var(--color-status-planning)"},docs:{bg:"rgba(160,157,151,0.12)",text:"var(--color-status-pending)"},test:{bg:"rgba(91,141,184,0.12)",text:"var(--color-status-testing)"}},O={in_progress:{bg:"rgba(201,155,45,0.1)",text:"var(--color-status-executing)"},running:{bg:"rgba(201,155,45,0.1)",text:"var(--color-status-executing)"},pending:{bg:"rgba(160,157,151,0.1)",text:"var(--color-status-pending)"},queued:{bg:"rgba(160,157,151,0.1)",text:"var(--color-status-pending)"},completed:{bg:"rgba(61,155,111,0.1)",text:"var(--color-status-completed)"},done:{bg:"rgba(61,155,111,0.1)",text:"var(--color-status-completed)"},failed:{bg:"rgba(208,84,84,0.1)",text:"var(--color-status-blocked)"}},ce={in_progress:"Running",running:"Running",pending:"Queued",queued:"Queued",completed:"Done",done:"Done",failed:"Failed"};function B(t){return{feature:"feat",refactor:"refac"}[t]??t}function de({task:t}){const s=S[t.type]??S[B(t.type)]??S.feat,a=O[t.status]??O.pending,r=ce[t.status]??t.status;return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-2-5)] py-[var(--spacing-1-5)] rounded-[var(--radius-default)] bg-bg-card text-[length:var(--font-size-xs)] cursor-pointer transition-colors duration-[var(--duration-fast)] hover:bg-bg-hover",children:[e.jsx("span",{className:"font-mono text-[length:10px] text-text-tertiary min-w-[60px] shrink-0",children:t.id}),e.jsx("span",{className:"text-[length:9px] font-[var(--font-weight-semibold)] uppercase px-[7px] py-[2px] rounded-full shrink-0",style:{backgroundColor:s.bg,color:s.text},children:B(t.type)}),e.jsx("span",{className:"flex-1 text-text-primary whitespace-nowrap overflow-hidden text-ellipsis",children:t.title}),e.jsx("span",{className:"text-[length:10px] font-[var(--font-weight-semibold)] px-[7px] py-[2px] rounded-full shrink-0",style:{backgroundColor:a.bg,color:a.text},children:r})]})}const xe={pending:"var(--color-tint-pending)",exploring:"var(--color-tint-exploring)",planning:"var(--color-tint-planning)",executing:"var(--color-tint-executing)",verifying:"var(--color-tint-verifying)",testing:"var(--color-tint-testing)",completed:"var(--color-tint-completed)",blocked:"var(--color-tint-blocked)"};function pe({phase:t,onSelectTask:s,recommendedAdvance:a}){const r=w(g=>g.setSelectedPhase),[n,x]=f.useState(!1),{tasks:i,loading:d}=T(n?t.phase:null),{tasks_completed:p,tasks_total:l,current_wave:c}=t.execution,u=m[t.status],j=t.verification.gaps.length>0,y=t.plan.task_count>0,o=H(g=>g.issues),h=f.useMemo(()=>o.filter(g=>g.phase_id===t.phase),[o,t.phase]),b=h.filter(g=>{var v;return((v=g.execution)==null?void 0:v.status)==="running"}).length;return e.jsxs("div",{children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>r(t.phase),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),r(t.phase))},className:"rounded-[10px] px-[var(--spacing-3-5)] py-[var(--spacing-3)] cursor-pointer transition-all duration-[var(--duration-normal)] ease-[var(--ease-spring)] hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(0,0,0,0.06)] focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",style:{backgroundColor:xe[t.status]??"var(--color-tint-pending)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-[var(--spacing-1-5)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)]",children:[y&&e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),x(!n)},className:"w-4 h-4 flex items-center justify-center text-text-tertiary hover:text-text-primary transition-colors","aria-label":n?"Collapse tasks":"Expand tasks",children:e.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${n?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}),e.jsx(I,{status:t.status,cardVariant:!0})]}),e.jsxs("span",{className:"text-[length:var(--font-size-xs)] font-mono text-text-tertiary",children:["P-",String(t.phase).padStart(2,"0")]})]}),e.jsx("div",{className:"text-[length:var(--font-size-base)] font-[var(--font-weight-semibold)] text-text-primary mb-[var(--spacing-0-5)]",children:t.title}),t.goal&&e.jsx("p",{className:"text-[12px] text-text-secondary leading-[var(--line-height-normal)] line-clamp-2 mb-[var(--spacing-2)]",children:t.goal}),l>0&&e.jsx(E,{completed:p,total:l,color:u}),t.status==="executing"&&c>0&&e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-medium)] mt-[var(--spacing-1-5)]",style:{color:u},children:[e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full animate-pulse motion-reduce:animate-none",style:{backgroundColor:u}}),"Wave ",c," active"]}),j&&e.jsxs("div",{className:"inline-flex items-center gap-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[var(--spacing-0-5)] rounded-full",style:{backgroundColor:"rgba(196, 101, 85, 0.1)",color:"var(--color-status-blocked)"},children:[t.verification.gaps.length," Gap",t.verification.gaps.length>1?"s":""]}),a&&e.jsxs("div",{className:"inline-flex items-center gap-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[var(--spacing-0-5)] rounded-full",style:{backgroundColor:"rgba(91, 141, 184, 0.1)",color:"var(--color-accent-blue)"},children:[e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full animate-pulse",style:{backgroundColor:"var(--color-accent-blue)"}}),"Advance recommended"]}),b>0&&e.jsxs(_,{to:`/kanban?phase=${t.phase}`,onClick:g=>g.stopPropagation(),className:"inline-flex items-center gap-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-medium)] px-[var(--spacing-2)] py-[var(--spacing-0-5)] rounded-full no-underline transition-colors hover:opacity-80",style:{backgroundColor:"rgba(184, 149, 64, 0.1)",color:"#B89540"},title:`${b} issue(s) running — view in Kanban`,children:[e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full animate-pulse",style:{backgroundColor:"#B89540"}}),b," running"]}),h.length>0&&b===0&&e.jsxs(_,{to:`/kanban?phase=${t.phase}`,onClick:g=>g.stopPropagation(),className:"inline-flex items-center gap-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-medium)] px-[var(--spacing-2)] py-[var(--spacing-0-5)] rounded-full no-underline transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-secondary)",color:"var(--color-text-tertiary)",border:"1px solid var(--color-border)"},children:[h.length," issue",h.length>1?"s":""]})]}),n&&e.jsx("div",{className:"mt-[var(--spacing-1)] flex flex-col gap-[var(--spacing-1)]",children:d?e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary px-[var(--spacing-3)] py-[var(--spacing-2)]",children:"Loading tasks..."}):i.length===0?e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary px-[var(--spacing-3)] py-[var(--spacing-2)]",children:"No tasks"}):i.map(g=>e.jsx("div",{onClick:()=>s==null?void 0:s({type:"task",task:g,phaseId:t.phase}),children:e.jsx(de,{task:{id:g.id,title:g.title,type:g.type,status:g.meta.status}})},g.id))})]})}function ge({color:t,phases:s,label:a,onSelectTask:r}){return e.jsxs("div",{className:"flex flex-col min-w-[220px] flex-1 bg-bg-secondary rounded-[12px] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-3-5)] py-[var(--spacing-2-5)]",children:[e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:t}}),e.jsx("span",{className:"text-[12px] font-[var(--font-weight-semibold)] text-text-primary",children:a}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-tertiary bg-bg-card px-[var(--spacing-1-5)] rounded-full",children:s.length})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-2)] pb-[var(--spacing-2)] flex flex-col gap-[var(--spacing-2)]",children:s.map(n=>e.jsx(pe,{phase:n,onSelectTask:r},n.phase))})]})}function ue(){var p;const t=w(l=>l.board),s=(t==null?void 0:t.phases)??[],a=s.filter(l=>l.status==="completed").length,r=s.length,n=s.reduce((l,c)=>l+c.execution.tasks_completed,0),x=s.reduce((l,c)=>l+c.execution.tasks_total,0),i=x>0?Math.round(n/x*100):0,d=((p=t==null?void 0:t.project)==null?void 0:p.current_milestone)??"";return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-5)] px-[var(--spacing-5)] py-[var(--spacing-2)] border-t border-border bg-bg-secondary text-[12px] shrink-0",children:[d&&e.jsx("span",{className:"font-[var(--font-weight-semibold)] text-text-primary",children:d}),e.jsxs("span",{className:"text-text-secondary",children:["Phases: ",e.jsxs("strong",{className:"font-[var(--font-weight-semibold)] text-text-primary",children:[a,"/",r]})," complete"]}),e.jsxs("span",{className:"text-text-secondary",children:["Tasks: ",e.jsxs("strong",{className:"font-[var(--font-weight-semibold)] text-text-primary",children:[n,"/",x]})]}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] w-36",children:[e.jsx("div",{className:"flex-1 h-1 rounded-full bg-border overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${i}%`,backgroundColor:"var(--color-status-completed)"}})}),e.jsxs("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-medium)] text-text-secondary font-mono tabular-nums",children:[i,"%"]})]})]})}const P=[{status:"pending",label:"Pending",match:["pending"]},{status:"exploring",label:"Exploring",match:["exploring"]},{status:"planning",label:"Planning",match:["planning"]},{status:"executing",label:"Executing",match:["executing"]},{status:"verifying",label:"Verifying",match:["verifying","testing"]},{status:"completed",label:"Complete",match:["completed"]}];function me(t){const s=new Map;for(const a of P)s.set(a.status,[]);for(const a of t){const r=P.find(n=>n.match.includes(a.status));r&&s.get(r.status).push(a)}return s}function ve({onSelectTask:t}){const s=w(r=>{var n;return((n=r.board)==null?void 0:n.phases)??[]}),a=f.useMemo(()=>me(s),[s]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(oe,{phases:s}),e.jsx("div",{className:"flex gap-[var(--spacing-2-5)] flex-1 overflow-x-auto px-[var(--spacing-3)] py-[var(--spacing-3)]",children:P.map(r=>e.jsx(ge,{status:r.status,color:m[r.status],label:r.label,phases:a.get(r.status)??[],onSelectTask:t},r.status))}),e.jsx(ue,{})]})}const he=6,fe=Array.from({length:he},(t,s)=>`Week ${s+1}`),R={pending:"var(--color-status-pending)",in_progress:"var(--color-status-executing)",completed:"var(--color-status-completed)",failed:"var(--color-status-blocked)"},be={pending:"Queued",in_progress:"Running",completed:"Done",failed:"Failed"};function je({phaseId:t,onSelectTask:s}){const{tasks:a,loading:r}=T(t);return r?e.jsxs("div",{className:"grid items-center py-[var(--spacing-1)] border-b border-border-divider",style:{gridTemplateColumns:"180px 1fr"},children:[e.jsx("div",{className:"pl-[var(--spacing-6)] text-[length:var(--font-size-xs)] text-text-tertiary",children:"Loading..."}),e.jsx("div",{})]}):a.length===0?null:e.jsx(e.Fragment,{children:a.map(n=>e.jsxs("div",{className:"grid items-center py-[var(--spacing-1)] border-b border-border-divider bg-[rgba(0,0,0,0.02)] cursor-pointer hover:bg-bg-hover transition-colors duration-[var(--duration-fast)]",style:{gridTemplateColumns:"180px 1fr"},onClick:()=>s==null?void 0:s({type:"task",task:n,phaseId:t}),children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] pl-[var(--spacing-6)] text-[length:var(--font-size-xs)]",children:[e.jsx("span",{className:"w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:R[n.meta.status]??"var(--color-status-pending)"}}),e.jsx("span",{className:"font-mono text-[length:10px] text-text-tertiary shrink-0",children:n.id}),e.jsx("span",{className:"text-text-secondary truncate",children:n.title}),e.jsx("span",{className:"ml-auto pr-[var(--spacing-3)] text-[length:10px] font-[var(--font-weight-medium)] shrink-0",style:{color:R[n.meta.status]??"var(--color-text-tertiary)"},children:be[n.meta.status]??n.meta.status})]}),e.jsx("div",{})]},n.id))})}function ye({onSelectPhase:t,onSelectTask:s}){const a=w(o=>o.board),[r,n]=f.useState(new Set);if(!a||a.phases.length===0)return e.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-[length:var(--font-size-sm)]",children:"No phases to display"});const x=a.phases,i=x.length,d=x.reduce((o,h)=>o+h.execution.tasks_total,0),p=x.reduce((o,h)=>o+h.execution.tasks_completed,0),l=d>0?Math.round(p/d*100):0,c=x.find(o=>o.status==="executing"),u=c?x.indexOf(c):-1,j=u>=0&&c?(()=>{const o=u/i*100,h=1/i*100,b=c.execution.tasks_total>0?c.execution.tasks_completed/c.execution.tasks_total:0;return o+h*b})():-1;function y(o){n(h=>{const b=new Set(h);return b.has(o)?b.delete(o):b.add(o),b})}return e.jsxs("div",{className:"p-[var(--spacing-4)] h-full overflow-auto",children:[e.jsxs("div",{className:"grid border-b border-border pb-[var(--spacing-2)] mb-[var(--spacing-1)]",style:{gridTemplateColumns:"180px 1fr"},children:[e.jsx("span",{className:"text-[length:11px] font-[var(--font-weight-semibold)] text-text-tertiary uppercase tracking-[0.04em]",children:"Phase"}),e.jsx("div",{className:"flex justify-between",children:fe.map(o=>e.jsx("span",{className:"text-[length:10px] text-text-tertiary",children:o},o))})]}),x.map((o,h)=>{const b=m[o.status],g=h/i*100,v=1/i*100,N=o.execution.tasks_total>0?o.execution.tasks_completed/o.execution.tasks_total:0,G=o.status==="pending"?.5:o.status==="completed"?1:.85,A=o.plan.task_count>0,z=r.has(o.phase);return e.jsxs("div",{children:[e.jsxs("div",{className:"grid items-center py-[var(--spacing-1-5)] border-b border-border-divider cursor-pointer hover:bg-bg-hover transition-colors duration-[var(--duration-fast)]",style:{gridTemplateColumns:"180px 1fr"},onClick:()=>t(o.phase),children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] text-[length:var(--font-size-xs)]",children:[A&&e.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),y(o.phase)},className:"w-4 h-4 flex items-center justify-center text-text-tertiary hover:text-text-primary transition-colors shrink-0","aria-label":z?"Collapse tasks":"Expand tasks",children:e.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${z?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}),!A&&e.jsx("span",{className:"w-4 shrink-0"}),e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:b}}),e.jsx("span",{className:"font-[var(--font-weight-medium)] text-text-primary truncate",children:o.title}),e.jsxs("span",{className:"ml-auto pr-[var(--spacing-3)] font-mono text-[length:10px] text-text-tertiary",children:[o.execution.tasks_completed,"/",o.execution.tasks_total]})]}),e.jsxs("div",{className:"relative h-7 bg-bg-secondary rounded-[var(--radius-default)] overflow-visible",children:[e.jsxs("div",{className:"absolute top-1 h-5 rounded-[var(--radius-default)] flex items-center px-[var(--spacing-2)] text-[length:10px] font-[var(--font-weight-semibold)] text-white transition-[width] duration-300 ease-[var(--ease-out)]",style:{left:`${g}%`,width:`${v}%`,backgroundColor:b,opacity:G},children:[N>0&&N<1&&e.jsx("div",{className:"absolute top-0 left-0 h-full rounded-[var(--radius-default)] opacity-30 bg-white",style:{width:`${N*100}%`}}),e.jsxs("span",{className:"relative z-[1] whitespace-nowrap",children:["P-",String(o.phase).padStart(2,"0"),N>0&&N<1?` (${Math.round(N*100)}%)`:""]})]}),j>=0&&(c==null?void 0:c.phase)===o.phase&&e.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-[var(--color-status-blocked)] z-[5] rounded-sm",style:{left:`${j}%`},children:e.jsx("span",{className:"absolute -top-[18px] -left-3 text-[length:9px] font-[var(--font-weight-semibold)] text-[var(--color-status-blocked)]",children:"Today"})})]})]}),z&&e.jsx(je,{phaseId:o.phase,onSelectTask:s})]},o.phase)}),e.jsxs("div",{className:"mt-[var(--spacing-5)] pt-[var(--spacing-3)] border-t border-border flex items-center gap-[var(--spacing-5)]",children:[e.jsxs("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary",children:[e.jsx("strong",{className:"font-[var(--font-weight-semibold)] text-text-primary",children:"Overall:"})," ",p,"/",d," tasks complete (",l,"%)"]}),e.jsx("div",{className:"w-[200px]",children:e.jsx(E,{completed:p,total:d})})]})]})}const Ne={pending:"Pending",exploring:"Explore",planning:"Plan",executing:"Execute",verifying:"Verify",testing:"Test",completed:"Done",blocked:"Blocked"};function F(t){return t==="completed"}function q(t){return t==="executing"}function we(t){return F(t)||q(t)?1:t==="verifying"||t==="testing"||t==="planning"?.7:t==="exploring"?.5:.4}function ke({phases:t}){return e.jsx("div",{className:"flex items-center gap-0 px-[var(--spacing-6)] py-[var(--spacing-4)] border-b border-border bg-bg-primary overflow-x-auto shrink-0",children:t.map((s,a)=>{const r=m[s.status],n=F(s.status),x=q(s.status),i=we(s.status);return e.jsxs("div",{className:"contents",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 shrink-0 cursor-pointer group",children:[e.jsxs("div",{className:"relative w-[42px] h-[42px] rounded-[12px] flex items-center justify-center text-[length:var(--font-size-sm)] font-bold text-white transition-transform duration-200 group-hover:scale-110",style:{backgroundColor:r,opacity:i},children:[n?e.jsx($,{size:18,strokeWidth:2.5}):s.phase,x&&e.jsx("span",{className:"absolute -inset-1 rounded-[14px] border-2 animate-pulse opacity-30",style:{borderColor:r}})]}),e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] max-w-[80px] text-center truncate text-text-tertiary",style:x?{color:r,fontWeight:700}:void 0,children:s.title}),e.jsx("span",{className:"text-[8px] font-[var(--font-weight-semibold)] uppercase tracking-wide px-[5px] py-px rounded-full",style:{backgroundColor:`color-mix(in srgb, ${r} 12%, transparent)`,color:r},children:Ne[s.status]})]}),a<t.length-1&&e.jsxs("div",{className:"relative w-10 h-0.5 shrink-0 mb-[22px]",children:[e.jsx("div",{className:"absolute inset-0 bg-border"}),n&&e.jsx("div",{className:"absolute top-0 left-0 h-full rounded-sm",style:{width:"100%",backgroundColor:"var(--color-status-completed)"}}),!n&&e.jsx("div",{className:"absolute -right-px -top-[3px] border-[3px] border-transparent border-l-[5px] border-l-border"})]})]},s.phase)})})}const Ce={pending:"/maestro-analyze {N}",exploring:"/maestro-plan {N}",planning:"/maestro-execute {N}",executing:"/maestro-execute {N}",verifying:"/quality-review {N}",testing:"/quality-test {N}",completed:"/maestro-phase-transition",blocked:"/quality-debug"};function ze(t){const s=t.filter(a=>a.status!=="completed"&&a.status!=="blocked");return s.length===0?null:s.reduce((a,r)=>r.phase<a.phase?r:a,s[0])}function Se({phase:t}){const[s,a]=f.useState(!1),r=f.useRef(null);if(f.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),!t)return e.jsx("div",{className:"text-[length:var(--font-size-sm)] text-text-tertiary italic text-center py-[var(--spacing-6)]",children:"All phases complete"});const x=(Ce[t.status]??"").replace("{N}",String(t.phase)),i=m[t.status];function d(){navigator.clipboard.writeText(x).then(()=>{a(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>a(!1),2e3)})}return e.jsxs("div",{className:"flex flex-col gap-[var(--spacing-2)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2-5)] mb-[var(--spacing-2)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] flex items-center justify-center text-[length:var(--font-size-base)] font-bold text-white shrink-0",style:{backgroundColor:i},children:t.phase}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[length:var(--font-size-sm)] font-bold text-text-primary truncate",children:t.title}),e.jsx("span",{className:"inline-block text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-px rounded-full mt-px",style:{backgroundColor:`${i}1a`,color:i},children:t.status})]})]}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)]",children:[e.jsx("code",{className:"flex-1 font-mono bg-bg-primary border border-border-divider rounded px-[var(--spacing-1-5)] py-[var(--spacing-0-5)] text-[length:var(--font-size-xs)] text-text-primary truncate",children:x}),e.jsx("button",{type:"button",onClick:d,className:"shrink-0 cursor-pointer text-text-tertiary hover:text-text-primary transition-colors text-[length:var(--font-size-xs)]",children:s?"Copied!":"Copy"})]})]})}function _e(){const t=w(a=>{var r;return((r=a.board)==null?void 0:r.phases)??[]}),s=t.find(a=>a.status==="executing")??null;return e.jsxs("div",{className:"flex flex-col overflow-hidden border-r border-r-border-divider border-b border-b-border-divider",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-4)] py-[var(--spacing-2-5)] border-b border-border-divider shrink-0",children:[e.jsx(ie,{size:14,strokeWidth:2,className:"text-text-tertiary"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] uppercase tracking-wider text-text-tertiary",children:"Active Execution"}),s&&s.execution.current_wave>0&&e.jsxs("span",{className:"ml-auto text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-px rounded-full",style:{backgroundColor:"rgba(184, 149, 64, 0.12)",color:m.executing},children:["Wave ",s.execution.current_wave]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-4)] py-[var(--spacing-3)]",children:s?e.jsx(Pe,{phase:s}):e.jsx(Se,{phase:ze(t)})})]})}function Pe({phase:t}){const{tasks_completed:s,tasks_total:a,current_wave:r}=t.execution,n=a>0?Math.round(s/a*100):0,x=m[t.status];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2-5)] mb-[var(--spacing-3)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-[10px] flex items-center justify-center text-[length:var(--font-size-base)] font-bold text-white",style:{backgroundColor:x},children:t.phase}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[length:var(--font-size-base)] font-bold text-text-primary",children:t.title}),t.goal&&e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",children:t.goal})]})]}),e.jsxs("div",{className:"mb-[var(--spacing-3-5)]",children:[e.jsx("div",{className:"h-1.5 bg-border rounded-full overflow-hidden mb-1",children:e.jsx("div",{className:"h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${n}%`,backgroundColor:"var(--color-status-completed)"}})}),e.jsxs("div",{className:"flex justify-between text-[length:var(--font-size-xs)] text-text-tertiary",children:[e.jsxs("span",{children:[s," of ",a," tasks complete"]}),e.jsxs("span",{children:[n,"%"]})]})]}),r>0&&e.jsxs("div",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-secondary mb-[var(--spacing-1-5)]",children:["Wave ",r]}),t.plan.task_ids.length>0&&e.jsx("div",{className:"flex flex-col gap-1",children:t.plan.task_ids.map(i=>e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-2-5)] py-[var(--spacing-1-5)] rounded-[var(--radius-md)] bg-bg-primary border border-border-divider text-[length:var(--font-size-sm)]",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 bg-text-quaternary"}),e.jsx("span",{className:"flex-1 text-text-primary font-[var(--font-weight-medium)] truncate",children:i}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-mono text-text-quaternary",children:i})]},i))})]})}const Te={pending:"Pending",exploring:"Exploring",planning:"Planning",executing:"Executing",verifying:"Verifying",testing:"Testing",completed:"Completed",blocked:"Blocked"};function Ee(){const t=w(s=>{var a;return((a=s.board)==null?void 0:a.phases)??[]});return e.jsxs("div",{className:"flex flex-col overflow-hidden border-r border-r-border-divider border-b border-border-divider",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-4)] py-[var(--spacing-2-5)] border-b border-border-divider shrink-0",children:[e.jsx(U,{size:14,strokeWidth:2,className:"text-text-tertiary"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] uppercase tracking-wider text-text-tertiary",children:"Phase Queue"}),e.jsxs("span",{className:"ml-auto text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-px rounded-full bg-border-subtle text-text-secondary",children:[t.length," phases"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-4)] py-[var(--spacing-3)]",children:t.map(s=>{const a=m[s.status],{tasks_completed:r,tasks_total:n,current_wave:x}=s.execution,i=n>0?Math.round(r/n*100):0,d=s.status==="executing",p=s.status==="completed";let l=Te[s.status];return d&&x>0&&(l+=` -- Wave ${x}`),s.verification.gaps.length>0&&(l+=` -- ${s.verification.gaps.length} gap(s)`),e.jsxs("div",{className:["flex items-center gap-[var(--spacing-2-5)] px-[var(--spacing-2-5)] py-[var(--spacing-2)] rounded-[var(--radius-md)] cursor-pointer transition-all duration-150 mb-0.5",d?"bg-[var(--color-tint-executing)]":"hover:bg-bg-primary"].join(" "),children:[e.jsx("div",{className:"w-6 h-6 rounded-[7px] flex items-center justify-center text-[length:var(--font-size-xs)] font-bold text-white shrink-0",style:{backgroundColor:a},children:p?e.jsx($,{size:12,strokeWidth:2.5}):s.phase}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[length:var(--font-size-sm)] font-[var(--font-weight-semibold)] text-text-primary truncate",children:s.title}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",style:d?{color:a}:void 0,children:l})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("div",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] font-mono text-text-tertiary",style:p?{color:a}:void 0,children:[r,"/",n]}),e.jsx("div",{className:"w-10 h-[3px] bg-border rounded-full overflow-hidden mt-0.5",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${i}%`,backgroundColor:a}})})]})]},s.phase)})})]})}function $e(){const t=w(l=>l.board),s=(t==null?void 0:t.phases)??[],a=s.reduce((l,c)=>l+c.execution.tasks_completed,0),r=s.reduce((l,c)=>l+c.execution.tasks_total,0),n=s.filter(l=>l.status==="completed").length,x=s.length,i=s.reduce((l,c)=>l+c.execution.commits.length,0),d=s.filter(l=>l.status==="verifying"||l.status==="testing"),p=s.flatMap(l=>l.verification.gaps.map(c=>({phase:l.phase,text:typeof c=="string"?c:c.description??c.id??JSON.stringify(c)})));return e.jsxs("div",{className:"flex flex-col overflow-hidden border-b border-border-divider",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-4)] py-[var(--spacing-2-5)] border-b border-border-divider shrink-0",children:[e.jsx(L,{size:14,strokeWidth:2,className:"text-text-tertiary"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] uppercase tracking-wider text-text-tertiary",children:"Quality"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-4)] py-[var(--spacing-3)]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-[var(--spacing-2)] mb-[var(--spacing-3-5)]",children:[e.jsx(C,{label:"Tasks",value:a,sub:`/${r}`,detail:`${r>0?Math.round(a/r*100):0}% complete`}),e.jsx(C,{label:"Phases",value:n,sub:`/${x}`,detail:`${x>0?Math.round(n/x*100):0}% complete`}),e.jsx(C,{label:"Gaps",value:p.length,color:p.length>0?m.blocked:void 0,detail:"active"}),e.jsx(C,{label:"Commits",value:i,detail:"this milestone"})]}),d.length>0&&e.jsx("div",{className:"mb-[var(--spacing-3-5)]",children:d.map(l=>e.jsxs("div",{className:"mb-[var(--spacing-3)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-secondary mb-[var(--spacing-1-5)]",children:[e.jsx(L,{size:12,strokeWidth:2,style:{color:m[l.status]}}),"Verification (P-",String(l.phase).padStart(2,"0"),")"]}),l.verification.must_haves.map((c,u)=>{const y=l.verification.gaps.map(o=>typeof o=="string"?o:o.description??o.id??"").includes(c);return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] py-1 border-b border-border-divider text-[length:var(--font-size-sm)]",children:[y?e.jsx(ae,{size:12,strokeWidth:2.5,style:{color:m.blocked}}):e.jsx($,{size:12,strokeWidth:2.5,style:{color:m.completed}}),e.jsx("span",{className:"flex-1 text-text-secondary",children:c}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)]",style:{color:y?m.blocked:m.completed},children:y?"Gap":"Verified"})]},u)})]},l.phase))}),s.some(l=>l.validation.test_coverage!==null)&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-secondary mb-[var(--spacing-1-5)]",children:"Test Coverage"}),s.filter(l=>l.validation.test_coverage!==null).map(l=>{const c=l.validation.test_coverage,u=typeof c=="number"?c:typeof c=="object"&&c!==null?c.statements??0:0,j=u>=80?m.completed:u>=60?m.executing:m.verifying;return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] text-[length:var(--font-size-xs)] mb-1",children:[e.jsxs("span",{className:"w-[70px] text-text-tertiary font-[var(--font-weight-medium)]",children:["P-",String(l.phase).padStart(2,"0")]}),e.jsx("div",{className:"flex-1 h-1.5 bg-border rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${u}%`,backgroundColor:j}})}),e.jsxs("span",{className:"w-9 text-right font-mono font-[var(--font-weight-semibold)] text-text-secondary",children:[u.toFixed(1),"%"]})]},l.phase)})]})]})]})}function C({label:t,value:s,sub:a,detail:r,color:n}){return e.jsxs("div",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] rounded-[10px] bg-bg-primary border border-border-divider",children:[e.jsx("div",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] uppercase tracking-wide text-text-tertiary mb-1",children:t}),e.jsxs("div",{className:"text-[length:var(--font-size-xl)] font-bold text-text-primary",style:n?{color:n}:void 0,children:[s,a&&e.jsx("span",{className:"text-[length:var(--font-size-sm)] font-[var(--font-weight-medium)] text-text-tertiary",children:a})]}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-0.5",children:r})]})}function Ae(t){const s=[];for(const a of t){const r=m[a.status],n=`P-${String(a.phase).padStart(2,"0")} ${a.title}`;a.status==="executing"&&a.execution.current_wave>0&&s.push({color:r,time:"",text:`Wave ${a.execution.current_wave} active -- ${n}`}),a.status==="verifying"&&a.verification.gaps.length>0&&s.push({color:m.blocked,time:"",text:`${a.verification.gaps.length} gap(s) -- ${n}`}),a.status==="completed"&&s.push({color:r,time:"",text:`Completed -- ${n}`})}return s.slice(0,6)}function Le(){const t=w(a=>{var r;return((r=a.board)==null?void 0:r.phases)??[]}),s=Ae(t);return s.length===0?null:e.jsxs("div",{className:"col-span-full flex items-center gap-[var(--spacing-4)] px-[var(--spacing-4)] py-[var(--spacing-2)] border-t border-border bg-bg-secondary overflow-x-auto shrink-0",children:[e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] uppercase tracking-wider text-text-quaternary whitespace-nowrap",children:"Activity"}),s.map((a,r)=>e.jsxs("span",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:var(--font-size-xs)] text-text-secondary whitespace-nowrap shrink-0",children:[e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full shrink-0",style:{backgroundColor:a.color}}),a.text,r<s.length-1&&e.jsx("span",{className:"inline-block w-px h-3.5 bg-border-divider ml-[var(--spacing-4)]"})]},r))]})}function We(){const t=w(s=>{var a;return((a=s.board)==null?void 0:a.phases)??[]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(ke,{phases:t}),e.jsxs("div",{className:"flex-1 grid grid-cols-[1fr_1fr_320px] grid-rows-[1fr_auto] overflow-hidden",children:[e.jsx(_e,{}),e.jsx(Ee,{}),e.jsx($e,{}),e.jsx(Le,{})]})]})}const k="text-left px-[var(--spacing-3)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-tertiary uppercase tracking-wide",M={pending:"var(--color-status-pending)",in_progress:"var(--color-status-executing)",completed:"var(--color-status-completed)",failed:"var(--color-status-blocked)"},Oe={pending:"Queued",in_progress:"Running",completed:"Done",failed:"Failed"};function Be({phaseId:t,onSelectTask:s}){const{tasks:a,loading:r}=T(t);return r?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-[var(--spacing-6)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] text-text-tertiary",children:"Loading tasks..."})}):a.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-[var(--spacing-6)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] text-text-tertiary",children:"No tasks"})}):e.jsx(e.Fragment,{children:a.map(n=>e.jsxs("tr",{className:"bg-[rgba(0,0,0,0.03)] border-t border-border-divider cursor-pointer hover:bg-bg-hover transition-colors",onClick:()=>s==null?void 0:s({type:"task",task:n,phaseId:t}),children:[e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2)] pl-[var(--spacing-6)]",children:e.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:M[n.meta.status]??"var(--color-status-pending)"}})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] font-mono text-text-tertiary",children:n.id}),e.jsx("td",{colSpan:2,className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] text-text-primary",children:n.title}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-center hidden sm:table-cell",children:e.jsxs("span",{className:"text-[length:10px] text-text-tertiary tabular-nums",children:["W",n.meta.wave]})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-right hidden sm:table-cell",children:e.jsx("span",{className:"text-[length:10px] font-[var(--font-weight-medium)]",style:{color:M[n.meta.status]??"var(--color-text-tertiary)"},children:Oe[n.meta.status]??n.meta.status})})]},n.id))})}function Re({onSelectTask:t}){const s=w(i=>{var d;return((d=i.board)==null?void 0:d.phases)??[]}),[a,r]=f.useState(new Set),n=f.useMemo(()=>[...s].sort((i,d)=>i.phase-d.phase),[s]);function x(i){r(d=>{const p=new Set(d);return p.has(i)?p.delete(i):p.add(i),p})}return n.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-[length:var(--font-size-sm)]",children:"No phases available"}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-3)] px-[var(--spacing-4)] py-[var(--spacing-2-5)] border-b border-border-divider shrink-0 bg-bg-secondary",children:[e.jsx("span",{className:"text-[length:var(--font-size-xs)] font-[var(--font-weight-semibold)] text-text-primary",children:"All Phases"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-tertiary bg-bg-card rounded-full px-[var(--spacing-1-5)] tabular-nums",children:n.length}),e.jsx("div",{className:"ml-auto flex items-center gap-[var(--spacing-3)]",children:["executing","verifying","planning","completed"].map(i=>{const d=n.filter(p=>p.status===i||i==="verifying"&&p.status==="testing").length;return d===0?null:e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m[i]}}),e.jsx("span",{className:"text-[length:10px] text-text-secondary tabular-nums",children:d})]},i)})})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"sticky top-0 z-10",children:e.jsxs("tr",{className:"bg-bg-secondary border-b border-border-divider",children:[e.jsx("th",{className:`${k} w-[60px]`,children:"#"}),e.jsx("th",{className:`${k} w-[120px]`,children:"Status"}),e.jsx("th",{className:k,children:"Title"}),e.jsx("th",{className:`${k} hidden lg:table-cell`,children:"Goal"}),e.jsx("th",{className:`${k} w-[60px] text-center hidden sm:table-cell`,children:"Wave"}),e.jsx("th",{className:`${k} text-right w-[130px] hidden sm:table-cell`,children:"Progress"})]})}),e.jsx("tbody",{children:n.map((i,d)=>{const{tasks_completed:p,tasks_total:l,current_wave:c}=i.execution,u=a.has(i.phase),j=i.plan.task_count>0;return e.jsxs(f.Fragment,{children:[e.jsxs("tr",{className:["border-t border-border-divider transition-colors",d%2===0?"bg-bg-primary":"bg-[rgba(0,0,0,0.015)]"].join(" "),children:[e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] text-[length:var(--font-size-xs)] font-mono text-text-tertiary whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",children:[j&&e.jsx("button",{type:"button",onClick:()=>x(i.phase),className:"w-4 h-4 flex items-center justify-center text-text-tertiary hover:text-text-primary transition-colors","aria-label":u?"Collapse tasks":"Expand tasks",children:e.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${u?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}),"P-",String(i.phase).padStart(2,"0")]})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)]",children:e.jsx(I,{status:i.status,cardVariant:!0})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] text-[length:var(--font-size-sm)] font-[var(--font-weight-medium)] text-text-primary",children:i.title}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] text-[length:var(--font-size-xs)] text-text-secondary hidden lg:table-cell max-w-[320px]",children:e.jsx("span",{className:"line-clamp-1",children:i.goal})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] text-center hidden sm:table-cell",children:i.status==="executing"&&c>0?e.jsxs("span",{className:"text-[length:10px] font-[var(--font-weight-semibold)] tabular-nums",style:{color:m.executing},children:["W",c]}):e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",children:"—"})}),e.jsx("td",{className:"px-[var(--spacing-3)] py-[var(--spacing-2-5)] hidden sm:table-cell",children:l>0?e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] justify-end",children:[e.jsx("div",{className:"w-[56px]",children:e.jsx(E,{completed:p,total:l,color:m[i.status]})}),e.jsxs("span",{className:"text-[length:10px] text-text-tertiary tabular-nums w-[32px] text-right shrink-0",children:[p,"/",l]})]}):e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-tertiary block text-right",children:"—"})})]}),u&&e.jsx(Be,{phaseId:i.phase,onSelectTask:t})]},i.phase)})})]})})]})}const D=[{id:"init",label:"Initialize Project",command:"/maestro-init",description:"Set up project configuration and workspace",done:t=>!!(t!=null&&t.project_name&&t.project_name!=="")},{id:"roadmap",label:"Create Roadmap",command:"/maestro-roadmap",description:"Define phases and milestones for your project",done:t=>!1},{id:"plan",label:"Plan Phase 1",command:"/maestro-plan 1",description:"Create execution plan for the first phase",done:t=>!1}];function Me({project:t}){var x;const[s,a]=f.useState(null),r=((x=D.find(i=>!i.done(t)))==null?void 0:x.id)??null;function n(i){navigator.clipboard.writeText(i.command).catch(()=>{}),a(i.id),setTimeout(()=>a(d=>d===i.id?null:d),2e3)}return e.jsxs("div",{className:"flex flex-col gap-[var(--spacing-4)] px-[var(--spacing-6)] py-[var(--spacing-6)] h-full overflow-y-auto",children:[e.jsxs("div",{className:"flex flex-col gap-[var(--spacing-1)]",children:[e.jsx("h2",{className:"text-[length:var(--font-size-lg)] font-bold text-text-primary",children:"Project Setup"}),e.jsx("p",{className:"text-[length:var(--font-size-sm)] text-text-tertiary",children:"Run these commands to initialize your project"})]}),e.jsx("div",{className:"flex flex-col gap-[var(--spacing-3)]",children:D.map(i=>{const d=i.done(t),p=i.id===r,l=d?"rounded-[var(--radius-lg)] border border-border-divider bg-bg-primary p-[var(--spacing-4)] opacity-60":p?"rounded-[var(--radius-lg)] border border-border-focus bg-bg-secondary p-[var(--spacing-4)]":"rounded-[var(--radius-lg)] border border-border-divider bg-bg-primary p-[var(--spacing-4)]";return e.jsx("div",{className:l,children:e.jsxs("div",{className:"flex items-start gap-[var(--spacing-3)]",children:[e.jsx("div",{className:"flex-shrink-0 mt-[var(--spacing-0-5)]",children:d?e.jsx("span",{className:"text-[#5A9E78] text-[length:var(--font-size-base)] font-bold leading-none",children:"✓"}):e.jsx("span",{className:"text-text-tertiary text-[length:var(--font-size-base)] leading-none",children:"○"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-[var(--spacing-1-5)]",children:[e.jsx("span",{className:"text-[length:var(--font-size-base)] font-[var(--font-weight-semibold)] text-text-primary",children:i.label}),e.jsx("p",{className:"text-[length:var(--font-size-sm)] text-text-tertiary",children:i.description}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)]",children:[e.jsx("code",{className:"font-mono text-[length:var(--font-size-sm)] bg-bg-primary border border-border-divider rounded px-[var(--spacing-2)] py-[var(--spacing-0-5)] text-text-primary",children:i.command}),e.jsx("button",{type:"button",onClick:()=>n(i),className:"cursor-pointer text-text-tertiary hover:text-text-primary text-[length:var(--font-size-sm)] transition-colors",children:s===i.id?"Copied!":"Copy"})]})]})]})},i.id)})})]})}const V=["board","timeline","center","table"];function Ke(){const[t,s]=f.useState("board"),[a,r]=f.useState(null),{register:n,unregister:x}=f.useContext(J),i=X(v=>v.recentDecisions),d=f.useMemo(()=>i.flatMap(v=>v.actions.filter(N=>N.type==="advance_phase")).slice(-3),[i]),{phases:p,board:l,selectedPhase:c,setSelectedPhase:u}=w(Z(v=>{var N;return{phases:((N=v.board)==null?void 0:N.phases)??[],board:v.board,selectedPhase:v.selectedPhase,setSelectedPhase:v.setSelectedPhase}})),j=f.useCallback(v=>{s(V[v]),u(null),r(null)},[u]),y=f.useCallback(v=>{r(v),u(null)},[u]),o=f.useMemo(()=>({items:[{label:"Board",icon:e.jsx(re,{size:14,strokeWidth:2}),shortcut:"1"},{label:"Timeline",icon:e.jsx(U,{size:14,strokeWidth:2}),shortcut:"2"},{label:"Center",icon:e.jsx(Y,{size:14,strokeWidth:2}),shortcut:"3"},{label:"Table",icon:e.jsx(ee,{size:14,strokeWidth:2}),shortcut:"4"}],activeIndex:V.indexOf(t),onSwitch:j}),[t,j]);f.useEffect(()=>{n(o)},[o,n]),f.useEffect(()=>()=>x(),[x]);const h=a??(c!==null?{type:"phase",phaseId:c}:null),b=h!==null,g=(h==null?void 0:h.type)==="task"?"Task Detail":"Phase Detail";return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-end px-[var(--spacing-4)] py-[var(--spacing-1)] border-b border-border-divider bg-bg-secondary text-[length:var(--font-size-xs)]",children:[d.length>0&&e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mr-auto",children:[e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full bg-accent-blue animate-pulse"}),e.jsxs("span",{className:"text-text-secondary",children:["Commander recommends advancing: ",d.map(v=>v.target).join(", ")]})]}),e.jsx(_,{to:"/supervisor",className:"text-text-secondary hover:text-text-primary transition-colors font-[var(--font-weight-medium)]",children:"Supervisor →"})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.length===0?e.jsx(Me,{project:l==null?void 0:l.project}):e.jsxs(e.Fragment,{children:[t==="board"&&e.jsx(ve,{onSelectTask:y}),t==="timeline"&&e.jsx(ye,{onSelectPhase:v=>{r(null),u(c===v?null:v)},onSelectTask:y}),t==="center"&&e.jsx(We,{}),t==="table"&&e.jsx(Re,{onSelectTask:y})]})}),e.jsx(te,{open:b,onClose:()=>{u(null),r(null)},title:g,children:h!==null&&e.jsx(se,{selectedItem:h})})]})]})}export{Ke as WorkflowPage};